CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
EgammaHLTIslandClusterProducer.cc
Go to the documentation of this file.
1 // C/C++ headers
2 #include <iostream>
3 #include <vector>
4 #include <memory>
5 
6 // Framework
13 
14 // Reconstruction Classes
20 
21 // Geometry
28 
29 // Level 1 Trigger
34 
35 // EgammaCoreTools
38 
39 // Class header file
41 
43 {
44  // The verbosity level
45  std::string verbosityString = ps.getParameter<std::string>("VerbosityLevel");
46  if (verbosityString == "DEBUG") verbosity = IslandClusterAlgo::pDEBUG;
47  else if (verbosityString == "WARNING") verbosity = IslandClusterAlgo::pWARNING;
48  else if (verbosityString == "INFO") verbosity = IslandClusterAlgo::pINFO;
50 
51  doBarrel_ = ps.getParameter<bool>("doBarrel");
52  doEndcaps_ = ps.getParameter<bool>("doEndcaps");
53  doIsolated_ = ps.getParameter<bool>("doIsolated");
54 
55  // Parameters to identify the hit collections
56  barrelHitProducer_ = ps.getParameter<edm::InputTag>("barrelHitProducer");
57  endcapHitProducer_ = ps.getParameter<edm::InputTag>("endcapHitProducer");
58  barrelHitCollection_ = ps.getParameter<std::string>("barrelHitCollection");
59  endcapHitCollection_ = ps.getParameter<std::string>("endcapHitCollection");
60 
61  // The names of the produced cluster collections
62  barrelClusterCollection_ = ps.getParameter<std::string>("barrelClusterCollection");
63  endcapClusterCollection_ = ps.getParameter<std::string>("endcapClusterCollection");
64 
65  // Island algorithm parameters
66  double barrelSeedThreshold = ps.getParameter<double>("IslandBarrelSeedThr");
67  double endcapSeedThreshold = ps.getParameter<double>("IslandEndcapSeedThr");
68 
69  // L1 matching parameters
70  l1TagIsolated_ = ps.getParameter< edm::InputTag > ("l1TagIsolated");
71  l1TagNonIsolated_ = ps.getParameter< edm::InputTag > ("l1TagNonIsolated");
72  l1LowerThr_ = ps.getParameter<double> ("l1LowerThr");
73  l1UpperThr_ = ps.getParameter<double> ("l1UpperThr");
74  l1LowerThrIgnoreIsolation_ = ps.getParameter<double> ("l1LowerThrIgnoreIsolation");
75 
76  regionEtaMargin_ = ps.getParameter<double>("regionEtaMargin");
77  regionPhiMargin_ = ps.getParameter<double>("regionPhiMargin");
78 
79  // Parameters for the position calculation:
80  posCalculator_ = PositionCalc( ps.getParameter<edm::ParameterSet>("posCalcParameters") );
81 
82  // Produces a collection of barrel and a collection of endcap clusters
83 
84  produces< reco::BasicClusterCollection >(endcapClusterCollection_);
85  produces< reco::BasicClusterCollection >(barrelClusterCollection_);
86 
87  island_p = new IslandClusterAlgo(barrelSeedThreshold, endcapSeedThreshold, posCalculator_,verbosity);
88 
89  nEvt_ = 0;
90 }
91 
92 
94 {
95  delete island_p;
96 }
97 
98 
100 {
101  //Get the L1 EM Particle Collection
103  if(doIsolated_)
104  evt.getByLabel(l1TagIsolated_, emIsolColl);
105  //Get the L1 EM Particle Collection
107  evt.getByLabel(l1TagNonIsolated_, emNonIsolColl);
108  // Get the CaloGeometry
109  edm::ESHandle<L1CaloGeometry> l1CaloGeom ;
110  es.get<L1CaloGeometryRecord>().get(l1CaloGeom) ;
111 
112  std::vector<EcalEtaPhiRegion> barrelRegions;
113  std::vector<EcalEtaPhiRegion> endcapRegions;
114 
115  if(doIsolated_) {
116  for( l1extra::L1EmParticleCollection::const_iterator emItr = emIsolColl->begin(); emItr != emIsolColl->end() ;++emItr ){
117 
118  if (emItr->et() > l1LowerThr_ && emItr->et() < l1UpperThr_) {
119 
120  // Access the GCT hardware object corresponding to the L1Extra EM object.
121  int etaIndex = emItr->gctEmCand()->etaIndex() ;
122 
123 
124  int phiIndex = emItr->gctEmCand()->phiIndex() ;
125  // Use the L1CaloGeometry to find the eta, phi bin boundaries.
126  double etaLow = l1CaloGeom->etaBinLowEdge( etaIndex ) ;
127  double etaHigh = l1CaloGeom->etaBinHighEdge( etaIndex ) ;
128  double phiLow = l1CaloGeom->emJetPhiBinLowEdge( phiIndex ) ;
129  double phiHigh = l1CaloGeom->emJetPhiBinHighEdge( phiIndex ) ;
130 
131  //Attention isForward does not work
132  int isforw=0;
133  int isbarl=0;
134  if((float)(etaHigh)>1.479 || (float)(etaLow)<-1.479) isforw=1;
135  if(((float)(etaLow)>-1.479 && (float)(etaLow)<1.479) ||
136  ((float)(etaHigh)>-1.479 && (float)(etaHigh)<1.479)) isbarl=1;
137 
138  //std::cout<<"Island etaindex "<<etaIndex<<" low hig : "<<etaLow<<" "<<etaHigh<<" phi low hig" <<phiLow<<" " << phiHigh<<" isforw "<<emItr->gctEmCand()->regionId().isForward()<<" isforwnew" <<isforw<< std::endl;
139 
140  etaLow -= regionEtaMargin_;
141  etaHigh += regionEtaMargin_;
142  phiLow -= regionPhiMargin_;
143  phiHigh += regionPhiMargin_;
144 
145  //if (emItr->gctEmCand()->regionId().isForward()) {
146  if (isforw) {
147  if (etaHigh>-1.479 && etaHigh<1.479) etaHigh=-1.479;
148  if ( etaLow>-1.479 && etaLow<1.479) etaLow=1.479;
149  EcalEtaPhiRegion region(etaLow,etaHigh,phiLow,phiHigh);
150  endcapRegions.push_back(region);
151  }
152  if (isbarl) {
153  if (etaHigh>1.479) etaHigh=1.479;
154  if (etaLow<-1.479) etaLow=-1.479;
155  EcalEtaPhiRegion region(etaLow,etaHigh,phiLow,phiHigh);
156  barrelRegions.push_back(region);
157  }
158  EcalEtaPhiRegion region(etaLow,etaHigh,phiLow,phiHigh);
159 
160  }
161  }
162  }
163 
164 
166  for( l1extra::L1EmParticleCollection::const_iterator emItr = emNonIsolColl->begin(); emItr != emNonIsolColl->end() ;++emItr ){
167 
168  if(doIsolated_&&emItr->et()<l1LowerThrIgnoreIsolation_) continue;
169 
170  if (emItr->et() > l1LowerThr_ && emItr->et() < l1UpperThr_) {
171 
172  // Access the GCT hardware object corresponding to the L1Extra EM object.
173  int etaIndex = emItr->gctEmCand()->etaIndex() ;
174 
175 
176  int phiIndex = emItr->gctEmCand()->phiIndex() ;
177  // Use the L1CaloGeometry to find the eta, phi bin boundaries.
178  double etaLow = l1CaloGeom->etaBinLowEdge( etaIndex ) ;
179  double etaHigh = l1CaloGeom->etaBinHighEdge( etaIndex ) ;
180  double phiLow = l1CaloGeom->emJetPhiBinLowEdge( phiIndex ) ;
181  double phiHigh = l1CaloGeom->emJetPhiBinHighEdge( phiIndex ) ;
182 
183 
184  int isforw=0;
185  int isbarl=0;
186  if((float)(etaHigh)>1.479 || (float)(etaLow)<-1.479) isforw=1;
187  if(((float)(etaLow)>-1.479 && (float)(etaLow)<1.479) ||
188  ((float)(etaHigh)>-1.479 && (float)(etaHigh)<1.479)) isbarl=1;
189 
190  //std::cout<<"Island etaindex "<<etaIndex<<" low hig : "<<etaLow<<" "<<etaHigh<<" phi low hig" <<phiLow<<" " << phiHigh<<" isforw "<<emItr->gctEmCand()->regionId().isForward()<<" isforwnew" <<isforw<< std::endl;
191 
192  etaLow -= regionEtaMargin_;
193  etaHigh += regionEtaMargin_;
194  phiLow -= regionPhiMargin_;
195  phiHigh += regionPhiMargin_;
196 
197  //if (emItr->gctEmCand()->regionId().isForward()) {
198  if (isforw) {
199  if (etaHigh>-1.479 && etaHigh<1.479) etaHigh=-1.479;
200  if ( etaLow>-1.479 && etaLow<1.479) etaLow=1.479;
201  EcalEtaPhiRegion region(etaLow,etaHigh,phiLow,phiHigh);
202  endcapRegions.push_back(region);
203  }
204  if (isbarl) {
205  if (etaHigh>1.479) etaHigh=1.479;
206  if (etaLow<-1.479) etaLow=-1.479;
207  EcalEtaPhiRegion region(etaLow,etaHigh,phiLow,phiHigh);
208  barrelRegions.push_back(region);
209  }
210 
211  }
212  }
213  }
214 
215  if (doEndcaps_
216  //&&endcapRegions.size()!=0
217  ) {
218 
220  }
221  if (doBarrel_
222  //&& barrelRegions.size()!=0
223  ) {
225  }
226  nEvt_++;
227 }
228 
229 
231  const std::string& hitProducer_,
232  const std::string& hitCollection_)
233 {
235 
236  evt.getByLabel(hitProducer_, hitCollection_, rhcHandle);
237  if (!(rhcHandle.isValid()))
238  {
239  std::cout << "could not get a handle on the EcalRecHitCollection!" << std::endl;
240  edm::LogError("EgammaHLTIslandClusterProducerError") << "Error! can't get the product " << hitCollection_.c_str() ;
241  return 0;
242  }
243  return rhcHandle.product();
244 }
245 
246 
248  const std::string& hitProducer,
249  const std::string& hitCollection,
250  const std::string& clusterCollection,
251  const std::vector<EcalEtaPhiRegion>& regions,
252  const IslandClusterAlgo::EcalPart& ecalPart)
253 {
254  // get the hit collection from the event:
255  const EcalRecHitCollection *hitCollection_p = getCollection(evt, hitProducer, hitCollection);
256 
257  // get the geometry and topology from the event setup:
258  edm::ESHandle<CaloGeometry> geoHandle;
259  es.get<CaloGeometryRecord>().get(geoHandle);
260 
261  const CaloSubdetectorGeometry *geometry_p;
262  CaloSubdetectorTopology *topology_p;
263 
264  if (ecalPart == IslandClusterAlgo::barrel)
265  {
266  geometry_p = geoHandle->getSubdetectorGeometry(DetId::Ecal, EcalBarrel);
267  topology_p = new EcalBarrelTopology(geoHandle);
268  }
269  else
270  {
271  geometry_p = geoHandle->getSubdetectorGeometry(DetId::Ecal, EcalEndcap);
272  topology_p = new EcalEndcapTopology(geoHandle);
273  }
274 
275  const CaloSubdetectorGeometry *geometryES_p;
276  geometryES_p = geoHandle->getSubdetectorGeometry(DetId::Ecal, EcalPreshower);
277 
278  // Run the clusterization algorithm:
280  clusters = island_p->makeClusters(hitCollection_p, geometry_p, topology_p, geometryES_p, ecalPart, true, regions);
281 
282  // create an auto_ptr to a BasicClusterCollection, copy the barrel clusters into it and put in the Event:
283  std::auto_ptr< reco::BasicClusterCollection > clusters_p(new reco::BasicClusterCollection);
284  clusters_p->assign(clusters.begin(), clusters.end());
286  if (ecalPart == IslandClusterAlgo::barrel)
287  bccHandle = evt.put(clusters_p, barrelClusterCollection_);
288  else
289  bccHandle = evt.put(clusters_p, endcapClusterCollection_);
290 
291  delete topology_p;
292 }
T getParameter(std::string const &) const
void clusterizeECALPart(edm::Event &evt, const edm::EventSetup &es, const std::string &hitProducer, const std::string &hitCollection, const std::string &clusterCollection, const std::vector< EcalEtaPhiRegion > &regions, const IslandClusterAlgo::EcalPart &ecalPart)
IslandClusterAlgo::VerbosityLevel verbosity
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:84
EgammaHLTIslandClusterProducer(const edm::ParameterSet &ps)
std::vector< reco::BasicCluster > makeClusters(const EcalRecHitCollection *hits, const CaloSubdetectorGeometry *geometry, const CaloSubdetectorTopology *topology_p, const CaloSubdetectorGeometry *geometryES_p, EcalPart ecalPart, bool regional=false, const std::vector< EcalEtaPhiRegion > &regions=std::vector< EcalEtaPhiRegion >())
const EcalRecHitCollection * getCollection(edm::Event &evt, const std::string &hitProducer_, const std::string &hitCollection_)
bool isValid() const
Definition: HandleBase.h:76
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:355
const T & get() const
Definition: EventSetup.h:55
std::vector< BasicCluster > BasicClusterCollection
collection of BasicCluster objects
T const * product() const
Definition: Handle.h:74
std::string const & label() const
Definition: InputTag.h:25
tuple cout
Definition: gather_cfg.py:41
virtual void produce(edm::Event &, const edm::EventSetup &)