CMS 3D CMS Logo

HGCalTriggerNtupleHGCClusters.cc
Go to the documentation of this file.
1 
2 #include <algorithm>
9 
11 public:
14  void initialize(TTree&, const edm::ParameterSet&, edm::ConsumesCollector&&) final;
15  void fill(const edm::Event& e, const edm::EventSetup& es) final;
16 
17 private:
18  void clear() final;
19 
23 
24  int cl_n_;
25  std::vector<uint32_t> cl_id_;
26  std::vector<float> cl_mipPt_;
27  std::vector<float> cl_pt_;
29  std::vector<float> cl_eta_;
30  std::vector<float> cl_phi_;
37 };
38 
40 
42  : HGCalTriggerNtupleBase(conf),
44 
46  const edm::ParameterSet& conf,
47  edm::ConsumesCollector&& collector) {
48  clusters_token_ = collector.consumes<l1t::HGCalClusterBxCollection>(conf.getParameter<edm::InputTag>("Clusters"));
50  collector.consumes<l1t::HGCalMulticlusterBxCollection>(conf.getParameter<edm::InputTag>("Multiclusters"));
51 
52  std::string prefix(conf.getUntrackedParameter<std::string>("Prefix", "cl"));
53 
54  std::string bname;
55  auto withPrefix([&prefix, &bname](char const* vname) -> char const* {
56  bname = prefix + "_" + vname;
57  return bname.c_str();
58  });
59 
60  // note: can't use withPrefix() twice within a same statement because bname gets overwritten
61  tree.Branch(withPrefix("n"), &cl_n_, (prefix + "_n/I").c_str());
62  tree.Branch(withPrefix("id"), &cl_id_);
63  tree.Branch(withPrefix("mipPt"), &cl_mipPt_);
64  tree.Branch(withPrefix("pt"), &cl_pt_);
65  tree.Branch(withPrefix("energy"), &cl_energy_);
66  tree.Branch(withPrefix("eta"), &cl_eta_);
67  tree.Branch(withPrefix("phi"), &cl_phi_);
68  tree.Branch(withPrefix("layer"), &cl_layer_);
69  tree.Branch(withPrefix("subdet"), &cl_subdet_);
70  tree.Branch(withPrefix("cells_n"), &cl_cells_n_);
71  tree.Branch(withPrefix("cells_id"), &cl_cells_id_);
72  tree.Branch(withPrefix("multicluster_id"), &cl_multicluster_id_);
73  tree.Branch(withPrefix("multicluster_pt"), &cl_multicluster_pt_);
74 }
75 
77  // retrieve clusters
79  e.getByToken(clusters_token_, clusters_h);
80  const l1t::HGCalClusterBxCollection& clusters = *clusters_h;
82  e.getByToken(multiclusters_token_, multiclusters_h);
83  const l1t::HGCalMulticlusterBxCollection& multiclusters = *multiclusters_h;
84 
85  // retrieve geometry
88 
90 
91  // Associate cells to clusters
92  std::unordered_map<uint32_t, l1t::HGCalMulticlusterBxCollection::const_iterator> cluster2multicluster;
93  for (auto mcl_itr = multiclusters.begin(0); mcl_itr != multiclusters.end(0); mcl_itr++) {
94  // loop on 2D clusters inside 3D clusters
95  for (const auto& cl_ptr : mcl_itr->constituents()) {
96  cluster2multicluster.emplace(cl_ptr.second->detId(), mcl_itr);
97  }
98  }
99 
100  clear();
101  for (auto cl_itr = clusters.begin(0); cl_itr != clusters.end(0); cl_itr++) {
102  auto mcl_itr = cluster2multicluster.find(cl_itr->detId());
103  uint32_t mcl_id = (mcl_itr != cluster2multicluster.end() ? mcl_itr->second->detId() : 0);
104  float mcl_pt = (mcl_itr != cluster2multicluster.end() ? mcl_itr->second->pt() : 0.);
105  if (filter_clusters_in_multiclusters_ && mcl_id == 0)
106  continue;
107  cl_n_++;
108  cl_mipPt_.emplace_back(cl_itr->mipPt());
109  // physical values
110  cl_pt_.emplace_back(cl_itr->pt());
111  cl_energy_.emplace_back(cl_itr->energy());
112  cl_eta_.emplace_back(cl_itr->eta());
113  cl_phi_.emplace_back(cl_itr->phi());
114 
115  cl_id_.emplace_back(cl_itr->detId());
116  cl_layer_.emplace_back(triggerTools_.layerWithOffset(cl_itr->detId()));
117  cl_subdet_.emplace_back(cl_itr->subdetId());
118  cl_cells_n_.emplace_back(cl_itr->constituents().size());
119  // Retrieve indices of trigger cells inside cluster
120  cl_cells_id_.emplace_back(cl_itr->constituents().size());
122  cl_itr->constituents_begin(),
123  cl_itr->constituents_end(),
124  cl_cells_id_.back().begin(),
125  [](const std::pair<uint32_t, edm::Ptr<l1t::HGCalTriggerCell>>& id_tc) { return id_tc.second->detId(); });
126  cl_multicluster_id_.emplace_back(mcl_id);
127  cl_multicluster_pt_.emplace_back(mcl_pt);
128  }
129 }
130 
132  cl_n_ = 0;
133  cl_id_.clear();
134  cl_mipPt_.clear();
135  cl_pt_.clear();
136  cl_energy_.clear();
137  cl_eta_.clear();
138  cl_phi_.clear();
139  cl_layer_.clear();
140  cl_subdet_.clear();
141  cl_cells_n_.clear();
142  cl_cells_id_.clear();
143  cl_multicluster_id_.clear();
144  cl_multicluster_pt_.clear();
145 }
HGCalTriggerTools.h
HGCalTriggerNtupleHGCClusters::clusters_token_
edm::EDGetToken clusters_token_
Definition: HGCalTriggerNtupleHGCClusters.cc:21
HGCalTriggerTools::eventSetup
void eventSetup(const edm::EventSetup &)
Definition: HGCalTriggerTools.cc:35
HGCalTriggerNtupleHGCClusters::cl_energy_
std::vector< float > cl_energy_
Definition: HGCalTriggerNtupleHGCClusters.cc:28
hgcalTriggerNtuples_cfi.FilterClustersInMulticlusters
FilterClustersInMulticlusters
Definition: hgcalTriggerNtuples_cfi.py:87
CaloGeometryRecord
Definition: CaloGeometryRecord.h:30
edm
HLT enums.
Definition: AlignableModifier.h:19
HGCalTriggerNtupleHGCClusters::cl_cells_n_
std::vector< int > cl_cells_n_
Definition: HGCalTriggerNtupleHGCClusters.cc:33
tree
Definition: tree.py:1
geometry
Definition: geometry.py:1
HGCalTriggerNtupleHGCClusters::cl_pt_
std::vector< float > cl_pt_
Definition: HGCalTriggerNtupleHGCClusters.cc:27
relativeConstraints.geometry
geometry
Definition: relativeConstraints.py:39
HGCalTriggerNtupleHGCClusters::clear
void clear() final
Definition: HGCalTriggerNtupleHGCClusters.cc:131
edm::ParameterSet::getUntrackedParameter
T getUntrackedParameter(std::string const &, T const &) const
watchdog.const
const
Definition: watchdog.py:83
edm::Handle
Definition: AssociativeIterator.h:50
BXVector
Definition: BXVector.h:15
HGCalTriggerNtupleHGCClusters::~HGCalTriggerNtupleHGCClusters
~HGCalTriggerNtupleHGCClusters() override
Definition: HGCalTriggerNtupleHGCClusters.cc:13
HGCalTriggerNtupleBase
Definition: HGCalTriggerNtupleBase.h:10
HGCalTriggerNtupleHGCClusters::cl_subdet_
std::vector< int > cl_subdet_
Definition: HGCalTriggerNtupleHGCClusters.cc:32
HGCalTriggerNtupleHGCClusters::cl_id_
std::vector< uint32_t > cl_id_
Definition: HGCalTriggerNtupleHGCClusters.cc:25
HGCalMulticluster.h
edm::EventSetup::get
T get() const
Definition: EventSetup.h:87
HGCalTriggerGeometryBase.h
HGCalTriggerNtupleHGCClusters::cl_multicluster_id_
std::vector< uint32_t > cl_multicluster_id_
Definition: HGCalTriggerNtupleHGCClusters.cc:35
edm::ESHandle< HGCalTriggerGeometryBase >
Event
HcalDetIdTransform::transform
unsigned transform(const HcalDetId &id, unsigned transformCode)
Definition: HcalDetIdTransform.cc:7
HGCalTriggerTools::layerWithOffset
unsigned layerWithOffset(const DetId &) const
Definition: HGCalTriggerTools.cc:134
BXVector::begin
const_iterator begin(int bx) const
DEFINE_EDM_PLUGIN
#define DEFINE_EDM_PLUGIN(factory, type, name)
Definition: PluginFactory.h:124
HGCalTriggerNtupleHGCClusters::cl_cells_id_
std::vector< std::vector< uint32_t > > cl_cells_id_
Definition: HGCalTriggerNtupleHGCClusters.cc:34
CaloGeometryRecord.h
bsc_activity_cfg.clusters
clusters
Definition: bsc_activity_cfg.py:36
HGCalTriggerNtupleHGCClusters::cl_mipPt_
std::vector< float > cl_mipPt_
Definition: HGCalTriggerNtupleHGCClusters.cc:26
HGCalTriggerNtupleHGCClusters::cl_layer_
std::vector< int > cl_layer_
Definition: HGCalTriggerNtupleHGCClusters.cc:31
BXVector::end
const_iterator end(int bx) const
edm::ParameterSet
Definition: ParameterSet.h:47
HGCalTriggerNtupleHGCClusters::triggerTools_
HGCalTriggerTools triggerTools_
Definition: HGCalTriggerNtupleHGCClusters.cc:22
ParameterSet
Definition: Functions.h:16
HGCalTriggerNtupleHGCClusters::multiclusters_token_
edm::EDGetToken multiclusters_token_
Definition: HGCalTriggerNtupleHGCClusters.cc:21
edmplugin::PluginFactory
Definition: PluginFactory.h:34
HGCalTriggerNtupleBase.h
trackerHitRTTI::vector
Definition: trackerHitRTTI.h:21
HGCalTriggerNtupleHGCClusters
Definition: HGCalTriggerNtupleHGCClusters.cc:10
edm::EventSetup
Definition: EventSetup.h:58
HGCalCluster.h
get
#define get
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
EDGetToken
std
Definition: JetResolutionObject.h:76
HGCalTriggerNtupleHGCClusters::filter_clusters_in_multiclusters_
bool filter_clusters_in_multiclusters_
Definition: HGCalTriggerNtupleHGCClusters.cc:20
HGCalTriggerNtupleHGCClusters::initialize
void initialize(TTree &, const edm::ParameterSet &, edm::ConsumesCollector &&) final
Definition: HGCalTriggerNtupleHGCClusters.cc:45
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
HGCalTriggerTools
Definition: HGCalTriggerTools.h:32
HGCalTriggerNtupleHGCClusters::cl_phi_
std::vector< float > cl_phi_
Definition: HGCalTriggerNtupleHGCClusters.cc:30
HGCalTriggerNtupleHGCClusters::cl_multicluster_pt_
std::vector< float > cl_multicluster_pt_
Definition: HGCalTriggerNtupleHGCClusters.cc:36
HGCalTriggerNtupleHGCClusters::cl_n_
int cl_n_
Definition: HGCalTriggerNtupleHGCClusters.cc:24
EventSetup
edm::Event
Definition: Event.h:73
HGCalTriggerNtupleHGCClusters::fill
void fill(const edm::Event &e, const edm::EventSetup &es) final
Definition: HGCalTriggerNtupleHGCClusters.cc:76
edm::InputTag
Definition: InputTag.h:15
edm::ConsumesCollector
Definition: ConsumesCollector.h:45
HGCalTriggerNtupleHGCClusters::cl_eta_
std::vector< float > cl_eta_
Definition: HGCalTriggerNtupleHGCClusters.cc:29
hcallasereventfilter2012_cfi.prefix
prefix
Definition: hcallasereventfilter2012_cfi.py:10
HGCalTriggerNtupleHGCClusters::HGCalTriggerNtupleHGCClusters
HGCalTriggerNtupleHGCClusters(const edm::ParameterSet &conf)
Definition: HGCalTriggerNtupleHGCClusters.cc:41
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37