CMS 3D CMS Logo

HGCClusterAlgo.cc
Go to the documentation of this file.
13 
14 using namespace HGCalTriggerBackend;
15 
16 
17 template<typename FECODEC, typename DATA>
18 class HGCClusterAlgo : public Algorithm<FECODEC>
19 {
20  public:
22 
23  protected:
25 
26  private:
30  dRNNC2d
31  };
34  DBSCANC3d
35  };
36 
37  public:
38 
40  Algorithm<FECODEC>(conf, cc),
41  trgcell_product_( new l1t::HGCalTriggerCellBxCollection ),
42  cluster_product_( new l1t::HGCalClusterBxCollection ),
43  multicluster_product_( new l1t::HGCalMulticlusterBxCollection ),
44  calibration_( conf.getParameterSet("calib_parameters") ),
45  clustering_( conf.getParameterSet("C2d_parameters") ),
46  multiclustering_( conf.getParameterSet("C3d_parameters" ) ),
47  triggercell_threshold_silicon_( conf.getParameter<double>("triggercell_threshold_silicon") ),
48  triggercell_threshold_scintillator_( conf.getParameter<double>("triggercell_threshold_scintillator") )
49  {
50  std::string typeCluster(conf.getParameterSet("C2d_parameters").getParameter<std::string>("clusterType"));
51  if(typeCluster=="dRC2d"){
52  clusteringAlgorithmType_ = dRC2d;
53  }else if(typeCluster=="NNC2d"){
54  clusteringAlgorithmType_ = NNC2d;
55  }else if(typeCluster=="dRNNC2d"){
56  clusteringAlgorithmType_ = dRNNC2d;
57  }else {
58  throw cms::Exception("HGCTriggerParameterError")
59  << "Unknown clustering type '" << typeCluster;
60  }
61  std::string typeMulticluster(conf.getParameterSet("C3d_parameters").getParameter<std::string>("type_multicluster"));
62  if(typeMulticluster=="dRC3d"){
63  multiclusteringAlgoType_ = dRC3d;
64  }else if(typeMulticluster=="DBSCANC3d"){
65  multiclusteringAlgoType_ = DBSCANC3d;
66  }else {
67  throw cms::Exception("HGCTriggerParameterError")
68  << "Unknown Multiclustering type '" << typeMulticluster;
69  }
70 
71  }
72 
74  {
75  prod.produces<l1t::HGCalTriggerCellBxCollection>( "calibratedTriggerCells" );
76  prod.produces<l1t::HGCalClusterBxCollection>( "cluster2D" );
77  prod.produces<l1t::HGCalMulticlusterBxCollection>( "cluster3D" );
78  }
79 
80  void run(const l1t::HGCFETriggerDigiCollection& coll, const edm::EventSetup& es, edm::Event&evt ) final;
81 
82 
83  void putInEvent(edm::Event& evt) final
84  {
85 
86  }
87 
88 
89  void reset() final
90  {
91  trgcell_product_.reset( new l1t::HGCalTriggerCellBxCollection );
92  cluster_product_.reset( new l1t::HGCalClusterBxCollection );
93  multicluster_product_.reset( new l1t::HGCalMulticlusterBxCollection );
94  }
95 
96 
97  private:
98 
99  /* pointers to collections of trigger-cells, clusters and multiclusters */
100  std::unique_ptr<l1t::HGCalTriggerCellBxCollection> trgcell_product_;
101  std::unique_ptr<l1t::HGCalClusterBxCollection> cluster_product_;
102  std::unique_ptr<l1t::HGCalMulticlusterBxCollection> multicluster_product_;
103 
105 
106  /* algorithms instances */
110 
111  /* algorithm type */
116 };
117 
118 
119 template<typename FECODEC, typename DATA>
121  const edm::EventSetup & es,
122  edm::Event & evt )
123 {
124  es.get<CaloGeometryRecord>().get("", triggerGeometry_);
125  calibration_.eventSetup(es);
126  clustering_.eventSetup(es);
127  multiclustering_.eventSetup(es);
128 
129  for( const auto& digi : coll ){
130 
131  HGCalDetId module_id( digi.id() );
132 
133  DATA data;
134  data.reset();
135  digi.decode(codec_, data);
136 
137  for(const auto& triggercell : data.payload)
138  {
139 
140  if( triggercell.hwPt() > 0 )
141  {
142  l1t::HGCalTriggerCell calibratedtriggercell( triggercell );
143  calibration_.calibrateInGeV( calibratedtriggercell);
144  double triggercell_threshold = (triggercell.subdetId()==HGCHEB ? triggercell_threshold_scintillator_ : triggercell_threshold_silicon_);
145  if(calibratedtriggercell.mipPt()<triggercell_threshold) continue;
146  trgcell_product_->push_back( 0, calibratedtriggercell );
147  }
148 
149  }
150 
151  }
152 
153  /* orphan handles to the collections of trigger-cells, clusters and multiclusters */
157 
158  /* retrieve the orphan handle to the trigger-cells collection and put the collection in the event */
159  triggerCellsHandle = evt.put( std::move( trgcell_product_ ), "calibratedTriggerCells");
160 
161  /* create a persistent vector of pointers to the trigger-cells */
162  std::vector<edm::Ptr<l1t::HGCalTriggerCell>> triggerCellsPtrs;
163  for( unsigned i = 0; i < triggerCellsHandle->size(); ++i ) {
164  edm::Ptr<l1t::HGCalTriggerCell> ptr(triggerCellsHandle,i);
165  triggerCellsPtrs.push_back(ptr);
166  }
167 
168  /* call to C2d clustering */
169  switch(clusteringAlgorithmType_){
170  case dRC2d :
171  clustering_.clusterizeDR( triggerCellsPtrs, *cluster_product_);
172  break;
173  case NNC2d:
174  clustering_.clusterizeNN( triggerCellsPtrs, *cluster_product_, *triggerGeometry_ );
175  break;
176  case dRNNC2d:
177  clustering_.clusterizeDRNN( triggerCellsPtrs, *cluster_product_, *triggerGeometry_ );
178  break;
179  default:
180  // Should not happen, clustering type checked in constructor
181  break;
182  }
183 
184  /* retrieve the orphan handle to the clusters collection and put the collection in the event */
185  clustersHandle = evt.put( std::move( cluster_product_ ), "cluster2D");
186 
187  /* create a persistent vector of pointers to the trigger-cells */
188  std::vector<edm::Ptr<l1t::HGCalCluster>> clustersPtrs;
189  for( unsigned i = 0; i < clustersHandle->size(); ++i ) {
190  edm::Ptr<l1t::HGCalCluster> ptr(clustersHandle,i);
191  clustersPtrs.push_back(ptr);
192  }
193 
194  /* call to multiclustering and compute shower shape*/
195  switch(multiclusteringAlgoType_){
196  case dRC3d :
197  multiclustering_.clusterizeDR( clustersPtrs, *multicluster_product_, *triggerGeometry_);
198  break;
199  case DBSCANC3d:
200  multiclustering_.clusterizeDBSCAN( clustersPtrs, *multicluster_product_, *triggerGeometry_);
201  break;
202  default:
203  // Should not happen, clustering type checked in constructor
204  break;
205  }
206 
207  /* retrieve the orphan handle to the multiclusters collection and put the collection in the event */
208  multiclustersHandle = evt.put( std::move( multicluster_product_ ), "cluster3D");
209 
210 
211 
212 }
213 
216 
217 
220  "HGCClusterAlgoBestChoice");
221 
224  "HGCClusterAlgoThreshold");
T getParameter(std::string const &) const
ClusterType clusteringAlgorithmType_
void putInEvent(edm::Event &evt) final
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:137
HGCalTriggerCellCalibration calibration_
unsigned size(int bx) const
BXVector< HGCalTriggerCell > HGCalTriggerCellBxCollection
ParameterSet const & getParameterSet(ParameterSetID const &id)
HGCClusterAlgo< HGCalTriggerCellThresholdCodec, HGCalTriggerCellThresholdCodec::data_type > HGCClusterAlgoThreshold
delete x;
Definition: CaloConfig.h:22
void run(const l1t::HGCFETriggerDigiCollection &coll, const edm::EventSetup &es, edm::Event &evt) final
void setProduces(edm::stream::EDProducer<> &prod) const final
double mipPt() const
HGCClusterAlgo(const edm::ParameterSet &conf, edm::ConsumesCollector &cc)
std::unique_ptr< l1t::HGCalTriggerCellBxCollection > trgcell_product_
void reset() final
HGCClusterAlgo< HGCalTriggerCellBestChoiceCodec, HGCalTriggerCellBestChoiceCodec::data_type > HGCClusterAlgoBestChoice
BXVector< HGCalMulticluster > HGCalMulticlusterBxCollection
HGCalMulticlusteringImpl multiclustering_
HGCalClusteringImpl clustering_
MulticlusterType multiclusteringAlgoType_
JetCorrectorParametersCollection coll
Definition: classes.h:10
ParameterSet const & getParameterSet(std::string const &) const
double triggercell_threshold_scintillator_
std::unique_ptr< l1t::HGCalMulticlusterBxCollection > multicluster_product_
BXVector< HGCalCluster > HGCalClusterBxCollection
Definition: HGCalCluster.h:36
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
T get() const
Definition: EventSetup.h:63
#define DEFINE_EDM_PLUGIN(factory, type, name)
std::unique_ptr< l1t::HGCalClusterBxCollection > cluster_product_
edm::ESHandle< HGCalTriggerGeometryBase > triggerGeometry_
double triggercell_threshold_silicon_
def move(src, dest)
Definition: eostools.py:510