test
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
11 
12 // Reconstruction Classes
17 
18 // Geometry
25 
26 // Level 1 Trigger
29 
30 // EgammaCoreTools
33 
34 // Class header file
36 
38 {
39  // The verbosity level
40  std::string verbosityString = ps.getParameter<std::string>("VerbosityLevel");
41  if (verbosityString == "DEBUG") verbosity = IslandClusterAlgo::pDEBUG;
42  else if (verbosityString == "WARNING") verbosity = IslandClusterAlgo::pWARNING;
43  else if (verbosityString == "INFO") verbosity = IslandClusterAlgo::pINFO;
45 
46  doBarrel_ = ps.getParameter<bool>("doBarrel");
47  doEndcaps_ = ps.getParameter<bool>("doEndcaps");
48  doIsolated_ = ps.getParameter<bool>("doIsolated");
49 
50  // Parameters to identify the hit collections
51  barrelHitCollection_ = ps.getParameter<edm::InputTag>("barrelHitProducer");
52  endcapHitCollection_ = ps.getParameter<edm::InputTag>("endcapHitProducer");
53  barrelHitToken_ = consumes<EcalRecHitCollection>(barrelHitCollection_);
54  endcapHitToken_ = consumes<EcalRecHitCollection>(endcapHitCollection_);
55 
56  // The names of the produced cluster collections
57  barrelClusterCollection_ = ps.getParameter<std::string>("barrelClusterCollection");
58  endcapClusterCollection_ = ps.getParameter<std::string>("endcapClusterCollection");
59 
60  // Island algorithm parameters
61  double barrelSeedThreshold = ps.getParameter<double>("IslandBarrelSeedThr");
62  double endcapSeedThreshold = ps.getParameter<double>("IslandEndcapSeedThr");
63 
64  // L1 matching parameters
65  l1TagIsolated_ = consumes<l1extra::L1EmParticleCollection>(ps.getParameter< edm::InputTag > ("l1TagIsolated"));
66  l1TagNonIsolated_ = consumes<l1extra::L1EmParticleCollection>(ps.getParameter< edm::InputTag > ("l1TagNonIsolated"));
67  l1LowerThr_ = ps.getParameter<double> ("l1LowerThr");
68  l1UpperThr_ = ps.getParameter<double> ("l1UpperThr");
69  l1LowerThrIgnoreIsolation_ = ps.getParameter<double> ("l1LowerThrIgnoreIsolation");
70 
71  regionEtaMargin_ = ps.getParameter<double>("regionEtaMargin");
72  regionPhiMargin_ = ps.getParameter<double>("regionPhiMargin");
73 
74  // Parameters for the position calculation:
75  posCalculator_ = PositionCalc( ps.getParameter<edm::ParameterSet>("posCalcParameters") );
76 
77  // Produces a collection of barrel and a collection of endcap clusters
78 
79  produces< reco::BasicClusterCollection >(endcapClusterCollection_);
80  produces< reco::BasicClusterCollection >(barrelClusterCollection_);
81 
82  island_p = new IslandClusterAlgo(barrelSeedThreshold, endcapSeedThreshold, posCalculator_,verbosity);
83 
84  nEvt_ = 0;
85 }
86 
88  delete island_p;
89 }
90 
92 
94  desc.add<std::string>("VerbosityLevel", "ERROR");
95  desc.add<bool>("doBarrel", true);
96  desc.add<bool>("doEndcaps", true);
97  desc.add<bool>("doIsolated", true);
98  desc.add<edm::InputTag>("barrelHitProducer", edm::InputTag("islandEndcapBasicClusters", "EcalRecHitsEB"));
99  desc.add<edm::InputTag>("endcapHitProducer", edm::InputTag("islandEndcapBasicClusters", "EcalRecHitsEB"));
100  desc.add<std::string>("barrelClusterCollection", "islandBarrelBasicClusters");
101  desc.add<std::string>("endcapClusterCollection", "islandEndcapBasicClusters");
102  desc.add<double>("IslandBarrelSeedThr", 0.5);
103  desc.add<double>("IslandEndcapSeedThr", 0.18);
104  desc.add<edm::InputTag>("l1TagIsolated", edm::InputTag("l1extraParticles","Isolated"));
105  desc.add<edm::InputTag>("l1TagNonIsolated", edm::InputTag("l1extraParticles","NonIsolated"));
106  desc.add<double>("l1LowerThr", 0.0);
107  desc.add<double>("l1UpperThr", 9999.0);
108  desc.add<double>("l1LowerThrIgnoreIsolation", 9999.0);
109  desc.add<double>("regionEtaMargin", 0.3);
110  desc.add<double>("regionPhiMargin", 0.4);
111  //desc.add<edm::ParameterSet>("posCalcParameters"), edm::ParameterSet());
112  descriptions.add("hltEgammaHLTIslandClusterProducer", desc);
113 }
114 
116 
117  //Get the L1 EM Particle Collection
119  if(doIsolated_)
120  evt.getByToken(l1TagIsolated_, emIsolColl);
121 
122  //Get the L1 EM Particle Collection
124  evt.getByToken(l1TagNonIsolated_, emNonIsolColl);
125 
126  // Get the CaloGeometry
127  edm::ESHandle<L1CaloGeometry> l1CaloGeom ;
128  es.get<L1CaloGeometryRecord>().get(l1CaloGeom) ;
129 
130  std::vector<EcalEtaPhiRegion> barrelRegions;
131  std::vector<EcalEtaPhiRegion> endcapRegions;
132 
133  if(doIsolated_) {
134  for( l1extra::L1EmParticleCollection::const_iterator emItr = emIsolColl->begin(); emItr != emIsolColl->end() ;++emItr ){
135 
136  if (emItr->et() > l1LowerThr_ && emItr->et() < l1UpperThr_) {
137 
138  // Access the GCT hardware object corresponding to the L1Extra EM object.
139  int etaIndex = emItr->gctEmCand()->etaIndex() ;
140 
141  int phiIndex = emItr->gctEmCand()->phiIndex() ;
142  // Use the L1CaloGeometry to find the eta, phi bin boundaries.
143  double etaLow = l1CaloGeom->etaBinLowEdge( etaIndex ) ;
144  double etaHigh = l1CaloGeom->etaBinHighEdge( etaIndex ) ;
145  double phiLow = l1CaloGeom->emJetPhiBinLowEdge( phiIndex ) ;
146  double phiHigh = l1CaloGeom->emJetPhiBinHighEdge( phiIndex ) ;
147 
148  //Attention isForward does not work
149  int isforw=0;
150  int isbarl=0;
151  if((float)(etaHigh)>1.479 || (float)(etaLow)<-1.479) isforw=1;
152  if(((float)(etaLow)>-1.479 && (float)(etaLow)<1.479) ||
153  ((float)(etaHigh)>-1.479 && (float)(etaHigh)<1.479)) isbarl=1;
154 
155  //std::cout<<"Island etaindex "<<etaIndex<<" low hig : "<<etaLow<<" "<<etaHigh<<" phi low hig" <<phiLow<<" " << phiHigh<<" isforw "<<emItr->gctEmCand()->regionId().isForward()<<" isforwnew" <<isforw<< std::endl;
156 
157  etaLow -= regionEtaMargin_;
158  etaHigh += regionEtaMargin_;
159  phiLow -= regionPhiMargin_;
160  phiHigh += regionPhiMargin_;
161 
162  //if (emItr->gctEmCand()->regionId().isForward()) {
163  if (isforw) {
164  if (etaHigh>-1.479 && etaHigh<1.479) etaHigh=-1.479;
165  if ( etaLow>-1.479 && etaLow<1.479) etaLow=1.479;
166  EcalEtaPhiRegion region(etaLow,etaHigh,phiLow,phiHigh);
167  endcapRegions.push_back(region);
168  }
169  if (isbarl) {
170  if (etaHigh>1.479) etaHigh=1.479;
171  if (etaLow<-1.479) etaLow=-1.479;
172  EcalEtaPhiRegion region(etaLow,etaHigh,phiLow,phiHigh);
173  barrelRegions.push_back(region);
174  }
175  EcalEtaPhiRegion region(etaLow,etaHigh,phiLow,phiHigh);
176 
177  }
178  }
179  }
180 
181 
183  for( l1extra::L1EmParticleCollection::const_iterator emItr = emNonIsolColl->begin(); emItr != emNonIsolColl->end() ;++emItr ){
184 
185  if(doIsolated_&&emItr->et()<l1LowerThrIgnoreIsolation_) continue;
186 
187  if (emItr->et() > l1LowerThr_ && emItr->et() < l1UpperThr_) {
188 
189  // Access the GCT hardware object corresponding to the L1Extra EM object.
190  int etaIndex = emItr->gctEmCand()->etaIndex() ;
191 
192 
193  int phiIndex = emItr->gctEmCand()->phiIndex() ;
194  // Use the L1CaloGeometry to find the eta, phi bin boundaries.
195  double etaLow = l1CaloGeom->etaBinLowEdge( etaIndex ) ;
196  double etaHigh = l1CaloGeom->etaBinHighEdge( etaIndex ) ;
197  double phiLow = l1CaloGeom->emJetPhiBinLowEdge( phiIndex ) ;
198  double phiHigh = l1CaloGeom->emJetPhiBinHighEdge( phiIndex ) ;
199 
200 
201  int isforw=0;
202  int isbarl=0;
203  if((float)(etaHigh)>1.479 || (float)(etaLow)<-1.479) isforw=1;
204  if(((float)(etaLow)>-1.479 && (float)(etaLow)<1.479) ||
205  ((float)(etaHigh)>-1.479 && (float)(etaHigh)<1.479)) isbarl=1;
206 
207  //std::cout<<"Island etaindex "<<etaIndex<<" low hig : "<<etaLow<<" "<<etaHigh<<" phi low hig" <<phiLow<<" " << phiHigh<<" isforw "<<emItr->gctEmCand()->regionId().isForward()<<" isforwnew" <<isforw<< std::endl;
208 
209  etaLow -= regionEtaMargin_;
210  etaHigh += regionEtaMargin_;
211  phiLow -= regionPhiMargin_;
212  phiHigh += regionPhiMargin_;
213 
214  //if (emItr->gctEmCand()->regionId().isForward()) {
215  if (isforw) {
216  if (etaHigh>-1.479 && etaHigh<1.479) etaHigh=-1.479;
217  if ( etaLow>-1.479 && etaLow<1.479) etaLow=1.479;
218  EcalEtaPhiRegion region(etaLow,etaHigh,phiLow,phiHigh);
219  endcapRegions.push_back(region);
220  }
221  if (isbarl) {
222  if (etaHigh>1.479) etaHigh=1.479;
223  if (etaLow<-1.479) etaLow=-1.479;
224  EcalEtaPhiRegion region(etaLow,etaHigh,phiLow,phiHigh);
225  barrelRegions.push_back(region);
226  }
227 
228  }
229  }
230  }
231 
232  if (doEndcaps_
233  //&&endcapRegions.size()!=0
234  ) {
235 
237  }
238  if (doBarrel_
239  //&& barrelRegions.size()!=0
240  ) {
242  }
243  nEvt_++;
244 }
245 
246 
249 {
251  evt.getByToken(hitToken_, rhcHandle);
252  if (!(rhcHandle.isValid()))
253  {
254  std::cout << "could not get a handle on the EcalRecHitCollection!" << std::endl;
255  edm::LogError("EgammaHLTIslandClusterProducerError") << "Error! can't get the product ";
256  return 0;
257  }
258  return rhcHandle.product();
259 }
260 
261 
264  const std::string& clusterCollection,
265  const std::vector<EcalEtaPhiRegion>& regions,
266  const IslandClusterAlgo::EcalPart& ecalPart)
267 {
268  // get the hit collection from the event:
269  const EcalRecHitCollection *hitCollection_p = getCollection(evt, hitToken);
270 
271  // get the geometry and topology from the event setup:
272  edm::ESHandle<CaloGeometry> geoHandle;
273  es.get<CaloGeometryRecord>().get(geoHandle);
274 
275  const CaloSubdetectorGeometry *geometry_p;
276  CaloSubdetectorTopology *topology_p;
277 
278  if (ecalPart == IslandClusterAlgo::barrel)
279  {
280  geometry_p = geoHandle->getSubdetectorGeometry(DetId::Ecal, EcalBarrel);
281  topology_p = new EcalBarrelTopology(geoHandle);
282  }
283  else
284  {
285  geometry_p = geoHandle->getSubdetectorGeometry(DetId::Ecal, EcalEndcap);
286  topology_p = new EcalEndcapTopology(geoHandle);
287  }
288 
289  const CaloSubdetectorGeometry *geometryES_p;
290  geometryES_p = geoHandle->getSubdetectorGeometry(DetId::Ecal, EcalPreshower);
291 
292  // Run the clusterization algorithm:
294  clusters = island_p->makeClusters(hitCollection_p, geometry_p, topology_p, geometryES_p, ecalPart, true, regions);
295 
296  // create an auto_ptr to a BasicClusterCollection, copy the barrel clusters into it and put in the Event:
297  std::auto_ptr< reco::BasicClusterCollection > clusters_p(new reco::BasicClusterCollection);
298  clusters_p->assign(clusters.begin(), clusters.end());
300  if (ecalPart == IslandClusterAlgo::barrel)
301  bccHandle = evt.put(clusters_p, barrelClusterCollection_);
302  else
303  bccHandle = evt.put(clusters_p, endcapClusterCollection_);
304 
305  delete topology_p;
306 }
T getParameter(std::string const &) const
edm::EDGetTokenT< EcalRecHitCollection > endcapHitToken_
void produce(edm::Event &, const edm::EventSetup &) override
void clusterizeECALPart(edm::Event &evt, const edm::EventSetup &es, edm::EDGetTokenT< EcalRecHitCollection > &hitToken, const std::string &clusterCollection, const std::vector< EcalEtaPhiRegion > &regions, const IslandClusterAlgo::EcalPart &ecalPart)
edm::EDGetTokenT< l1extra::L1EmParticleCollection > l1TagNonIsolated_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:462
IslandClusterAlgo::VerbosityLevel verbosity
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:121
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 >())
ParameterDescriptionBase * add(U const &iLabel, T const &value)
bool isValid() const
Definition: HandleBase.h:75
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
edm::EDGetTokenT< l1extra::L1EmParticleCollection > l1TagIsolated_
T const * product() const
Definition: Handle.h:81
const EcalRecHitCollection * getCollection(edm::Event &evt, edm::EDGetTokenT< EcalRecHitCollection > &hitToken)
const T & get() const
Definition: EventSetup.h:56
void add(std::string const &label, ParameterSetDescription const &psetDescription)
std::vector< BasicCluster > BasicClusterCollection
collection of BasicCluster objects
tuple cout
Definition: gather_cfg.py:145
edm::EDGetTokenT< EcalRecHitCollection > barrelHitToken_