CMS 3D CMS Logo

HGCClusterAlgo.cc
Go to the documentation of this file.
12 
13 using namespace HGCalTriggerBackend;
14 
15 
16 template<typename FECODEC, typename DATA>
17 class HGCClusterAlgo : public Algorithm<FECODEC>
18 {
19  public:
21 
22  protected:
24 
25  private:
28  NNC2d
29  };
30 
31  public:
32 
34  Algorithm<FECODEC>(conf, cc),
35  trgcell_product_( new l1t::HGCalTriggerCellBxCollection ),
36  cluster_product_( new l1t::HGCalClusterBxCollection ),
37  multicluster_product_( new l1t::HGCalMulticlusterBxCollection ),
38  HGCalEESensitive_( conf.getParameter<std::string>("HGCalEESensitive_tag") ),
39  HGCalHESiliconSensitive_( conf.getParameter<std::string>("HGCalHESiliconSensitive_tag") ),
40  calibration_( conf.getParameterSet("calib_parameters") ),
41  clustering_( conf.getParameterSet("C2d_parameters") ),
42  multiclustering_( conf.getParameterSet("C3d_parameters" ) )
43  {
44  clustering_threshold_ = conf.getParameterSet("C2d_parameters").getParameter<double>("clustering_threshold");
45  std::string type(conf.getParameterSet("C2d_parameters").getParameter<std::string>("clusterType"));
46  if(type=="dRC2d"){
47  clusteringAlgorithmType_ = dRC2d;
48  }else if(type=="NNC2d"){
49  clusteringAlgorithmType_ = NNC2d;
50  }else {
51  edm::LogWarning("ParameterError") << "Unknown clustering type '" << type
52  << "'. Using nearest neighbor NNC2d instead.\n";
53  clusteringAlgorithmType_ = NNC2d;
54  }
55 
56  }
57 
58  virtual void setProduces(edm::stream::EDProducer<>& prod) const override final
59  {
60  prod.produces<l1t::HGCalTriggerCellBxCollection>( "calibratedTriggerCells" );
61  prod.produces<l1t::HGCalClusterBxCollection>( "cluster2D" );
62  prod.produces<l1t::HGCalMulticlusterBxCollection>( "cluster3D" );
63  }
64 
65  virtual void run(const l1t::HGCFETriggerDigiCollection& coll, const edm::EventSetup& es, edm::Event&evt ) override final;
66 
67 
68  virtual void putInEvent(edm::Event& evt) override final
69  {
70 
71  }
72 
73 
74  virtual void reset() override final
75  {
76  trgcell_product_.reset( new l1t::HGCalTriggerCellBxCollection );
77  cluster_product_.reset( new l1t::HGCalClusterBxCollection );
78  multicluster_product_.reset( new l1t::HGCalMulticlusterBxCollection );
79  }
80 
81 
82  private:
83 
84  /* pointers to collections of trigger-cells, clusters and multiclusters */
85  std::unique_ptr<l1t::HGCalTriggerCellBxCollection> trgcell_product_;
86  std::unique_ptr<l1t::HGCalClusterBxCollection> cluster_product_;
87  std::unique_ptr<l1t::HGCalMulticlusterBxCollection> multicluster_product_;
88 
89  /* lables of sensitive detector (geometry record) */
92 
93  /* handles to the detector topologies */
97 
98  /* algorithms instances */
102 
103  /* algorithm type */
106 };
107 
108 
109 template<typename FECODEC, typename DATA>
111  const edm::EventSetup & es,
112  edm::Event & evt )
113 {
114 
115  es.get<IdealGeometryRecord>().get( HGCalEESensitive_, hgceeTopoHandle_ );
116  es.get<IdealGeometryRecord>().get( HGCalHESiliconSensitive_, hgchefTopoHandle_ );
117  es.get<IdealGeometryRecord>().get("", triggerGeometry_);
118 
119  for( const auto& digi : coll ){
120 
121  HGCalDetId module_id( digi.id() );
122 
123  DATA data;
124  data.reset();
125  digi.decode(codec_, data);
126 
127  for(const auto& triggercell : data.payload)
128  {
129 
130  if( triggercell.hwPt() > 0 )
131  {
132 
133  HGCalDetId detid(triggercell.detId());
134  int subdet = detid.subdetId();
135  int cellThickness = 0;
136 
137  if( subdet == HGCEE ){
138  cellThickness = hgceeTopoHandle_->dddConstants().waferTypeL( (unsigned int)detid.wafer() );
139  }
140  else if( subdet == HGCHEF ){
141  cellThickness = hgchefTopoHandle_->dddConstants().waferTypeL( (unsigned int)detid.wafer() );
142  }
143  else if( subdet == HGCHEB ){
144  edm::LogWarning("DataNotFound") << "ATTENTION: the BH trigger cells are not yet implemented";
145  }
146 
147  l1t::HGCalTriggerCell calibratedtriggercell( triggercell );
148  calibration_.calibrateInGeV( calibratedtriggercell, cellThickness );
149  if(calibratedtriggercell.mipPt()<clustering_threshold_) continue;
150  trgcell_product_->push_back( 0, calibratedtriggercell );
151  }
152 
153  }
154 
155  }
156 
157  /* orphan handles to the collections of trigger-cells, clusters and multiclusters */
161 
162  /* retrieve the orphan handle to the trigger-cells collection and put the collection in the event */
163  triggerCellsHandle = evt.put( std::move( trgcell_product_ ), "calibratedTriggerCells");
164 
165  /* create a persistent vector of pointers to the trigger-cells */
166  edm::PtrVector<l1t::HGCalTriggerCell> triggerCellsPtrs;
167  for( unsigned i = 0; i < triggerCellsHandle->size(); ++i ) {
168  edm::Ptr<l1t::HGCalTriggerCell> ptr(triggerCellsHandle,i);
169  triggerCellsPtrs.push_back(ptr);
170  }
171 
172  /* call to C2d clustering */
173  switch(clusteringAlgorithmType_){
174  case dRC2d :
175  clustering_.clusterizeDR( triggerCellsPtrs, *cluster_product_);
176  break;
177  case NNC2d:
178  clustering_.clusterizeNN( triggerCellsPtrs, *cluster_product_, *triggerGeometry_ );
179  break;
180  default:
181  // Should not happen, clustering type checked in constructor
182  break;
183  }
184 
185  /* retrieve the orphan handle to the clusters collection and put the collection in the event */
186  clustersHandle = evt.put( std::move( cluster_product_ ), "cluster2D");
187 
188  /* create a persistent vector of pointers to the trigger-cells */
190  for( unsigned i = 0; i < clustersHandle->size(); ++i ) {
191  edm::Ptr<l1t::HGCalCluster> ptr(clustersHandle,i);
192  clustersPtrs.push_back(ptr);
193  }
194 
195  /* call to multiclustering */
196  multiclustering_.clusterize( clustersPtrs, *multicluster_product_ );
197 
198  /* retrieve the orphan handle to the multiclusters collection and put the collection in the event */
199  multiclustersHandle = evt.put( std::move( multicluster_product_ ), "cluster3D");
200 
201 }
202 
205 
206 
209  "HGCClusterAlgoBestChoice");
210 
213  "HGCClusterAlgoThreshold");
type
Definition: HCALResponse.h:21
T getParameter(std::string const &) const
ClusterType clusteringAlgorithmType_
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:122
HGCalTriggerCellCalibration calibration_
unsigned size(int bx) const
BXVector< HGCalTriggerCell > HGCalTriggerCellBxCollection
virtual void setProduces(edm::stream::EDProducer<> &prod) const override final
void push_back(Ptr< T > const &iPtr)
Definition: PtrVector.h:141
virtual void putInEvent(edm::Event &evt) override final
ParameterSet const & getParameterSet(ParameterSetID const &id)
edm::ESHandle< HGCalTopology > hgchefTopoHandle_
std::string HGCalEESensitive_
HGCClusterAlgo< HGCalTriggerCellThresholdCodec, HGCalTriggerCellThresholdCodec::data_type > HGCClusterAlgoThreshold
delete x;
Definition: CaloConfig.h:22
double mipPt() const
HGCClusterAlgo(const edm::ParameterSet &conf, edm::ConsumesCollector &cc)
std::unique_ptr< l1t::HGCalTriggerCellBxCollection > trgcell_product_
virtual void run(const l1t::HGCFETriggerDigiCollection &coll, const edm::EventSetup &es, edm::Event &evt) override final
HGCClusterAlgo< HGCalTriggerCellBestChoiceCodec, HGCalTriggerCellBestChoiceCodec::data_type > HGCClusterAlgoBestChoice
BXVector< HGCalMulticluster > HGCalMulticlusterBxCollection
HGCalMulticlusteringImpl multiclustering_
int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:37
double clustering_threshold_
HGCalClusteringImpl clustering_
JetCorrectorParametersCollection coll
Definition: classes.h:10
std::string HGCalHESiliconSensitive_
ParameterSet const & getParameterSet(std::string const &) const
virtual void reset() override final
const T & get() const
Definition: EventSetup.h:56
std::unique_ptr< l1t::HGCalMulticlusterBxCollection > multicluster_product_
BXVector< HGCalCluster > HGCalClusterBxCollection
Definition: HGCalCluster.h:36
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
#define DEFINE_EDM_PLUGIN(factory, type, name)
std::unique_ptr< l1t::HGCalClusterBxCollection > cluster_product_
edm::ESHandle< HGCalTopology > hgceeTopoHandle_
edm::ESHandle< HGCalTriggerGeometryBase > triggerGeometry_
def move(src, dest)
Definition: eostools.py:510