CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
HLTRegionalEcalResonanceFilter.cc
Go to the documentation of this file.
4 
5 using namespace std;
6 using namespace edm;
7 
8 
10 {
11  barrelHits_ = iConfig.getParameter< edm::InputTag > ("barrelHits");
12  barrelClusters_ = iConfig.getParameter< edm::InputTag > ("barrelClusters");
13  barrelHitsToken_ = consumes<EBRecHitCollection>(barrelHits_);
14  barrelClustersToken_ = consumes<reco::BasicClusterCollection>(barrelClusters_);
15 
16  endcapHits_ = iConfig.getParameter< edm::InputTag > ("endcapHits");
17  endcapClusters_ = iConfig.getParameter< edm::InputTag > ("endcapClusters");
18  endcapHitsToken_ = consumes<EERecHitCollection>(endcapHits_);
19  endcapClustersToken_ = consumes<reco::BasicClusterCollection>(endcapClusters_);
20 
21  doSelBarrel_ = iConfig.getParameter<bool>("doSelBarrel");
22 
23  if(doSelBarrel_){
24  edm::ParameterSet barrelSelection = iConfig.getParameter<edm::ParameterSet>( "barrelSelection" );
25 
27  // EB region 1
28  region1_Barrel_ = barrelSelection.getParameter<double> ("region1_Barrel"); //eta dividing between region 1 and region 2
29  selePtGammaBarrel_region1_ = barrelSelection.getParameter<double> ("selePtGammaBarrel_region1");
30  selePtPairBarrel_region1_ = barrelSelection.getParameter<double> ("selePtPairBarrel_region1");
31  seleS4S9GammaBarrel_region1_ = barrelSelection.getParameter<double> ("seleS4S9GammaBarrel_region1");
32  seleIsoBarrel_region1_ = barrelSelection.getParameter<double> ("seleIsoBarrel_region1");
33 
34  // EB region 2
35  selePtGammaBarrel_region2_ = barrelSelection.getParameter<double> ("selePtGammaBarrel_region2");
36  selePtPairBarrel_region2_ = barrelSelection.getParameter<double> ("selePtPairBarrel_region2");
37  seleS4S9GammaBarrel_region2_ = barrelSelection.getParameter<double> ("seleS4S9GammaBarrel_region2");
38  seleIsoBarrel_region2_ = barrelSelection.getParameter<double> ("seleIsoBarrel_region2");
39 
40  // other
41  seleS9S25Gamma_ = barrelSelection.getParameter<double> ("seleS9S25Gamma");
42 
43  //mass window
44  seleMinvMaxBarrel_ = barrelSelection.getParameter<double> ("seleMinvMaxBarrel");
45  seleMinvMinBarrel_ = barrelSelection.getParameter<double> ("seleMinvMinBarrel");
46 
47  // remove pi0 candidates for eta dataset
48  removePi0CandidatesForEta_ = barrelSelection.getParameter<bool>("removePi0CandidatesForEta");
49  if(removePi0CandidatesForEta_){
50  massLowPi0Cand_ = barrelSelection.getParameter<double>("massLowPi0Cand");
51  massHighPi0Cand_ = barrelSelection.getParameter<double>("massHighPi0Cand");
52  }
53 
54  // EB Isolation configuration
55  ptMinForIsolation_ = barrelSelection.getParameter<double> ("ptMinForIsolation");
56  seleBeltDR_ = barrelSelection.getParameter<double> ("seleBeltDR");
57  seleBeltDeta_ = barrelSelection.getParameter<double> ("seleBeltDeta");
58 
59  // EB storage and collection
60  store5x5RecHitEB_ = barrelSelection.getParameter<bool> ("store5x5RecHitEB");
61  BarrelHits_ = barrelSelection.getParameter<string> ("barrelHitCollection");
62 
63  // selePtGamma_ = barrelSelection.getParameter<double> ("selePtGamma"); // old non-region filter
64  // selePtPair_ = barrelSelection.getParameter<double> ("selePtPair"); // old non-region filter
65  // seleS4S9Gamma_ = barrelSelection.getParameter<double> ("seleS4S9Gamma"); //old non-region filter
66  // seleIso_ = barrelSelection.getParameter<double> ("seleIso"); // old non-region filter
67 
68  produces<EBRecHitCollection>(BarrelHits_);
69  }
70 
71 
72  doSelEndcap_ = iConfig.getParameter<bool>("doSelEndcap");
73  if(doSelEndcap_){
74  edm::ParameterSet endcapSelection = iConfig.getParameter<edm::ParameterSet>( "endcapSelection" );
75 
77  seleMinvMaxEndCap_ = endcapSelection.getParameter<double> ("seleMinvMaxEndCap");
78  seleMinvMinEndCap_ = endcapSelection.getParameter<double> ("seleMinvMinEndCap");
79 
80  // EE region 1
81  region1_EndCap_ = endcapSelection.getParameter<double> ("region1_EndCap"); //eta dividing between region 1 and region 2
82  selePtGammaEndCap_region1_ = endcapSelection.getParameter<double> ("selePtGammaEndCap_region1");
83  selePtPairEndCap_region1_ = endcapSelection.getParameter<double> ("selePtPairEndCap_region1");
84  seleS4S9GammaEndCap_region1_ = endcapSelection.getParameter<double> ("seleS4S9GammaEndCap_region1");
85  seleIsoEndCap_region1_ = endcapSelection.getParameter<double> ("seleIsoEndCap_region1");
86 
87  // EE region 2
88  region2_EndCap_ = endcapSelection.getParameter<double> ("region2_EndCap"); //eta dividing between region 2 and region 3
89  selePtGammaEndCap_region2_ = endcapSelection.getParameter<double> ("selePtGammaEndCap_region2");
90  selePtPairEndCap_region2_ = endcapSelection.getParameter<double> ("selePtPairEndCap_region2");
91  seleS4S9GammaEndCap_region2_ = endcapSelection.getParameter<double> ("seleS4S9GammaEndCap_region2");
92  seleIsoEndCap_region2_ = endcapSelection.getParameter<double> ("seleIsoEndCap_region2");
93 
94  // EE region 3 (available but not yet used)
95  selePtGammaEndCap_region3_ = endcapSelection.getParameter<double> ("selePtGammaEndCap_region3");
96  selePtPairEndCap_region3_ = endcapSelection.getParameter<double> ("selePtPairEndCap_region3");
97  selePtPairMaxEndCap_region3_ = endcapSelection.getParameter<double> ("selePtPairMaxEndCap_region3");
98  seleS4S9GammaEndCap_region3_ = endcapSelection.getParameter<double> ("seleS4S9GammaEndCap_region3");
99  seleIsoEndCap_region3_ = endcapSelection.getParameter<double> ("seleIsoEndCap_region3");
100 
101  seleS9S25GammaEndCap_ = endcapSelection.getParameter<double> ("seleS9S25GammaEndCap");
102 
103  // isolation belt and size configuration
104  ptMinForIsolationEndCap_ = endcapSelection.getParameter<double> ("ptMinForIsolationEndCap");
105  seleBeltDREndCap_ = endcapSelection.getParameter<double> ("seleBeltDREndCap");
106  seleBeltDetaEndCap_ = endcapSelection.getParameter<double> ("seleBeltDetaEndCap");
107 
108  // EE storage and collections
109  store5x5RecHitEE_ = endcapSelection.getParameter<bool> ("store5x5RecHitEE");
110  EndcapHits_ = endcapSelection.getParameter<string > ("endcapHitCollection");
111 
112  //seleS4S9GammaEndCap_ = endcapSelection.getParameter<double> ("seleS4S9GammaEndCap"); // old non-region filter
113  //seleIsoEndCap_ = endcapSelection.getParameter<double> ("seleIsoEndCap"); // old non-region filter
114 
115  produces< EERecHitCollection >(EndcapHits_);
116 
117  }
118 
119  useRecoFlag_ = iConfig.getParameter<bool>("useRecoFlag");
120  flagLevelRecHitsToUse_ = iConfig.getParameter<int>("flagLevelRecHitsToUse");
121 
122  useDBStatus_ = iConfig.getParameter<bool>("useDBStatus");
123  statusLevelRecHitsToUse_ = iConfig.getParameter<int>("statusLevelRecHitsToUse");
124 
125 
126  preshHitProducer_ = iConfig.getParameter<edm::InputTag>("preshRecHitProducer");
127  preshHitsToken_ = consumes<EBRecHitCollection>(preshHitProducer_);
128 
130  storeRecHitES_ = iConfig.getParameter<bool>("storeRecHitES");
131  if(storeRecHitES_){
132 
133  edm::ParameterSet preshowerSelection = iConfig.getParameter<edm::ParameterSet>( "preshowerSelection" );
134 
135  // maximum number of matched ES clusters (in each ES layer) to each BC
136  preshNclust_ = preshowerSelection.getParameter<int>("preshNclust");
137  // min energy of ES clusters
138  preshClustECut = preshowerSelection.getParameter<double>("preshClusterEnergyCut");
139  // algo params
140  float preshStripECut = preshowerSelection.getParameter<double>("preshStripEnergyCut");
141  int preshSeededNst = preshowerSelection.getParameter<int>("preshSeededNstrip");
142  // calibration parameters:
143  calib_planeX_ = preshowerSelection.getParameter<double>("preshCalibPlaneX");
144  calib_planeY_ = preshowerSelection.getParameter<double>("preshCalibPlaneY");
145  gamma_ = preshowerSelection.getParameter<double>("preshCalibGamma");
146  mip_ = preshowerSelection.getParameter<double>("preshCalibMIP");
147 
148  // ES algo constructor:
149  presh_algo_ = new PreshowerClusterAlgo(preshStripECut,preshClustECut,preshSeededNst);
150 
151  ESHits_ = preshowerSelection.getParameter< std::string > ("ESCollection");
152  produces< ESRecHitCollection >(ESHits_);
153  }
154 
155  debug_ = iConfig.getParameter<int> ("debugLevel");
156 
157 }
158 
159 
161 {
162  if(storeRecHitES_){
163  delete presh_algo_;
164  }
165 }
166 
167 
168 void
171  desc.add<edm::InputTag>("barrelHits",edm::InputTag("hltEcalRegionalPi0EtaRecHit","EcalRecHitsEB"));
172  desc.add<edm::InputTag>("endcapHits",edm::InputTag("hltEcalRegionalPi0EtaRecHit","EcalRecHitsEE"));
173  desc.add<edm::InputTag>("preshRecHitProducer",edm::InputTag("hltEcalRegionalPi0EtaRecHit","EcalRecHitsES"));
174  desc.add<edm::InputTag>("barrelClusters",edm::InputTag("hltSimple3x3Clusters","Simple3x3ClustersBarrel"));
175  desc.add<edm::InputTag>("endcapClusters",edm::InputTag("hltSimple3x3Clusters","Simple3x3ClustersEndcap"));
176  desc.add<bool>("useRecoFlag",false);
177  desc.add<int>("flagLevelRecHitsToUse",1);
178  desc.add<bool>("useDBStatus",true);
179  desc.add<int>("statusLevelRecHitsToUse",1);
180 
181  //----------------------BARREL CONFIGURATION-----------------
182  desc.add<bool>("doSelBarrel",true);
184 
185  //EB region 1
186  barrelSelection.add<double>("region1_Barrel", 1.0); //separator between barrel region 1 and region 2
187  barrelSelection.add<double>("selePtGammaBarrel_region1", 1.0);
188  barrelSelection.add<double>("selePtPairBarrel_region1", 2.0);
189  barrelSelection.add<double>("seleIsoBarrel_region1", 0.5);
190  barrelSelection.add<double>("seleS4S9GammaBarrel_region1", 0.83);
191 
192  //EB region 2
193  barrelSelection.add<double>("selePtGammaBarrel_region2", 1.0);
194  barrelSelection.add<double>("selePtPairBarrel_region2", 2.0);
195  barrelSelection.add<double>("seleIsoBarrel_region2", 0.5);
196  barrelSelection.add<double>("seleS4S9GammaBarrel_region2", 0.83);
197 
198  //EB Isolation configuration
199  barrelSelection.add<double>("ptMinForIsolation", 1.0);
200  barrelSelection.add<double>("seleBeltDR", 0.2);
201  barrelSelection.add<double>("seleBeltDeta", 0.05);
202 
203  //other parameters
204  barrelSelection.add<double>("seleMinvMaxBarrel", 0.22);
205  barrelSelection.add<double>("seleMinvMinBarrel", 0.06);
206  barrelSelection.add<bool>("removePi0CandidatesForEta",false);
207  barrelSelection.add<double>("massLowPi0Cand", 0.104);
208  barrelSelection.add<double>("massHighPi0Cand", 0.163);
209  barrelSelection.add<double>("seleS9S25Gamma", 0.);
210 
211  //collections and storage
212  barrelSelection.add<bool>("store5x5RecHitEB",false);
213  barrelSelection.add<std::string>("barrelHitCollection","pi0EcalRecHitsEB");
214  desc.add<edm::ParameterSetDescription>("barrelSelection", barrelSelection);
215 
216  //barrelSelection.add<double>("selePtGamma",1.); //old non-region
217  //barrelSelection.add<double>("selePtPair",2.); //old non-regional
218  //barrelSelection.add<double>("seleIso",0.5); //old non-regional
219  //barrelSelection.add<double>("seleS4S9Gamma",0.83); //old non-regional
220 
221 
222  //----------------------ENDCAP CONFIGURATION-----------------
223 
224  desc.add<bool>("doSelEndcap",true);
226  // Mass Cuts
227  endcapSelection.add<double>("seleMinvMaxEndCap", 0.3);
228  endcapSelection.add<double>("seleMinvMinEndCap", 0.05);
229 
230  // EE region 1
231  endcapSelection.add<double>("region1_EndCap", 2.0); // eta division between endcap region 1 and 2
232  endcapSelection.add<double>("selePtGammaEndCap_region1", 0.8);
233  endcapSelection.add<double>("selePtPairEndCap_region1", 3.0);
234  endcapSelection.add<double>("seleS4S9GammaEndCap_region1", 0.9);
235  endcapSelection.add<double>("seleIsoEndCap_region1", 0.5);
236 
237  // EE region 2
238  endcapSelection.add<double>("region2_EndCap", 2.5); // eta division between endcap region 2 and 3
239  endcapSelection.add<double>("selePtGammaEndCap_region2", 0.5);
240  endcapSelection.add<double>("selePtPairEndCap_region2", 2.0);
241  endcapSelection.add<double>("seleS4S9GammaEndCap_region2", 0.9);
242  endcapSelection.add<double>("seleIsoEndCap_region2", 0.5);
243 
244  // EE region 3
245  endcapSelection.add<double>("selePtGammaEndCap_region3", 0.3);
246  endcapSelection.add<double>("selePtPairEndCap_region3", 1.2);
247  endcapSelection.add<double>("selePtPairMaxEndCap_region3", 2.5);
248  endcapSelection.add<double>("seleS4S9GammaEndCap_region3", 0.9);
249  endcapSelection.add<double>("seleIsoEndCap_region3", 0.5);
250 
251  // other
252  endcapSelection.add<double>("seleS9S25GammaEndCap", 0.);
253 
254  // isolation configuration for endcap
255  endcapSelection.add<double>("ptMinForIsolationEndCap", 0.5);
256  endcapSelection.add<double>("seleBeltDREndCap", 0.2);
257  endcapSelection.add<double>("seleBeltDetaEndCap", 0.05);
258 
259  // collections and storage
260  endcapSelection.add<bool>("store5x5RecHitEE", false);
261  endcapSelection.add<std::string>("endcapHitCollection", "pi0EcalRecHitsEE");
262  desc.add<edm::ParameterSetDescription>("endcapSelection", endcapSelection);
263 
264  //endcapSelection.add<double>("seleS4S9GammaEndCap",0.9); //old non-region filter
265 
266  //-----------------------------------------------------------
267 
268  desc.add<bool>("storeRecHitES",true);
270  preshowerSelection.add<std::string>("ESCollection","pi0EcalRecHitsES");
271  preshowerSelection.add<int>("preshNclust",4);
272  preshowerSelection.add<double>("preshClusterEnergyCut",0.0);
273  preshowerSelection.add<double>("preshStripEnergyCut",0.0);
274  preshowerSelection.add<int>("preshSeededNstrip",15);
275  preshowerSelection.add<double>("preshCalibPlaneX",1.0);
276  preshowerSelection.add<double>("preshCalibPlaneY",0.7);
277  preshowerSelection.add<double>("preshCalibGamma",0.024);
278  preshowerSelection.add<double>("preshCalibMIP",9.0E-5);
279  preshowerSelection.add<std::string>("debugLevelES",""); // *** This is not needed and shoul be better removed !
280  desc.add<edm::ParameterSetDescription>("preshowerSelection",preshowerSelection);
281 
282  desc.add<int>("debugLevel",0);
283  descriptions.add("hltRegionalEcalResonanceFilter",desc);
284 }
285 
286 // ------------ method called to produce the data ------------
288 {
289 
290  //Create empty output collections
291  std::auto_ptr< EBRecHitCollection > selEBRecHitCollection( new EBRecHitCollection );
292  //Create empty output collections
293  std::auto_ptr< EERecHitCollection > selEERecHitCollection( new EERecHitCollection );
294 
295 
297  vector<DetId> selectedEBDetIds;
298  vector<DetId> selectedEEDetIds;
299 
300 
301  edm::ESHandle<CaloTopology> pTopology;
302  iSetup.get<CaloTopologyRecord>().get(pTopology);
303  const CaloSubdetectorTopology *topology_eb = pTopology->getSubdetectorTopology(DetId::Ecal,EcalBarrel);
304  const CaloSubdetectorTopology *topology_ee = pTopology->getSubdetectorTopology(DetId::Ecal,EcalEndcap);
305 
306 
307  edm::ESHandle<CaloGeometry> geoHandle;
308  iSetup.get<CaloGeometryRecord>().get(geoHandle);
309  const CaloSubdetectorGeometry *geometry_es = geoHandle->getSubdetectorGeometry(DetId::Ecal, EcalPreshower);
310  CaloSubdetectorTopology *topology_es=0;
311  if (geometry_es) {
312  topology_es = new EcalPreshowerTopology(geoHandle);
313  }else{
314  storeRecHitES_ = false;
315  }
316 
317 
320  if ( useDBStatus_ ) iSetup.get<EcalChannelStatusRcd>().get(csHandle);
321  const EcalChannelStatus &channelStatus = *csHandle;
322 
324 
325  Handle<EBRecHitCollection> barrelRecHitsHandle;
326 
327  iEvent.getByToken(barrelHitsToken_,barrelRecHitsHandle);
328  if (!barrelRecHitsHandle.isValid()) {
329  LogError("AlCaEcalResonanceProducer") << "AlCaEcalResonanceProducer: Error! can't get product barrel hits!";
330  }
331 
332  const EcalRecHitCollection *hitCollection_eb = barrelRecHitsHandle.product();
333 
334 
335  Handle<reco::BasicClusterCollection> barrelClustersHandle;
336  iEvent.getByToken(barrelClustersToken_,barrelClustersHandle);
337  if (!barrelClustersHandle.isValid()) {
338  LogError("AlCaEcalResonanceProducer") << "AlCaEcalResonanceProducer: Error! can't get product barrel clusters!";
339  }
340  const reco::BasicClusterCollection *clusterCollection_eb = barrelClustersHandle.product();
341  if(debug_>=1)
342  LogDebug("AlCaEcalResonanceProducer") <<" barrel_input_size: run "<<iEvent.id().run()<<" event "<<iEvent.id().event()<<" nhitEB: "<<hitCollection_eb->size()<<" nCluster: "<< clusterCollection_eb->size();
343 
344 
345  if(doSelBarrel_){
346 
347  map<int, vector<EcalRecHit> > RecHits5x5_clus;
348  vector<int> indIsoClus;
349  vector<int> indCandClus;
350  vector<int> indClusSelected;
351 
352  doSelection( EcalBarrel,clusterCollection_eb, hitCollection_eb, channelStatus,topology_eb,
353  RecHits5x5_clus,
354  indCandClus,indIsoClus, indClusSelected);
355 
356 
358  for(int i = 0; i < int(indClusSelected.size()); i++){
359  int ind = indClusSelected[i];
360  reco::BasicClusterCollection::const_iterator it_bc3 = clusterCollection_eb->begin() + ind;
361  const std::vector< std::pair<DetId, float> > &vid = it_bc3->hitsAndFractions();
362  for (std::vector<std::pair<DetId,float> >::const_iterator idItr = vid.begin();idItr != vid.end ();++idItr){
363  EcalRecHitCollection::const_iterator hit = hitCollection_eb->find(idItr->first);
364  if( hit == hitCollection_eb->end()) continue; //this should not happen.
365  selEBRecHitCollection->push_back(*hit);
366  selectedEBDetIds.push_back(idItr->first);
367  }
368  }
369 
370 
371  if( store5x5RecHitEB_ ){
373  for(int i = 0; i < int( indCandClus.size()); i++){
374  int ind = indCandClus[i];
375  vector<EcalRecHit> v5x5 = RecHits5x5_clus[ind];
376  for(int n=0; n< int(v5x5.size()); n++){
377  DetId ed = v5x5[n].id();
378  std::vector<DetId>::iterator itdet = find(selectedEBDetIds.begin(),selectedEBDetIds.end(),ed);
379  if( itdet == selectedEBDetIds.end()){
380  selectedEBDetIds.push_back(ed);
381  selEBRecHitCollection->push_back(v5x5[n]);
382  }
383  }
384  }
385 
386 
388  for(int i = 0; i < int( indIsoClus.size()); i++){
389  int ind = indIsoClus[i];
390 
391  std::vector<int>::iterator it = find(indCandClus.begin(),indCandClus.end(), ind);
392  if( it != indCandClus.end()) continue;
393 
394  reco::BasicClusterCollection::const_iterator it_bc3 = clusterCollection_eb->begin() + ind;
395  DetId seedId = it_bc3->seed();
396  std::vector<DetId> clus_v5x5 = topology_eb->getWindow(seedId,5,5);
397  for( std::vector<DetId>::const_iterator idItr = clus_v5x5.begin(); idItr != clus_v5x5.end(); idItr++){
398  DetId ed = *idItr;
399  EcalRecHitCollection::const_iterator rit = hitCollection_eb->find( ed );
400  if ( rit == hitCollection_eb->end() ) continue;
401  if( ! checkStatusOfEcalRecHit(channelStatus, *rit) ) continue;
402  std::vector<DetId>::iterator itdet = find(selectedEBDetIds.begin(),selectedEBDetIds.end(),ed);
403  if( itdet == selectedEBDetIds.end()){
404  selectedEBDetIds.push_back(ed);
405  selEBRecHitCollection->push_back(*rit);
406  }
407  }
408  }
409  }
410 
411 
412  }// end of selection for eta/pi0->gg in the barrel
413 
414  int eb_collsize = selEBRecHitCollection->size();
415 
416  if(debug_>=1)
417  LogDebug("AlCaEcalResonanceProducer") <<" barrel_output_size_run "<<iEvent.id().run()<<" event "<<iEvent.id().event()<<" nEBSaved "<<selEBRecHitCollection->size();
419 
420 
421 
422  //===============Start of Endcap =================/////
424  Handle<ESRecHitCollection> esRecHitsHandle;
425  iEvent.getByToken(preshHitsToken_,esRecHitsHandle);
426  if( !esRecHitsHandle.isValid()){
427  LogError("AlCaEcalResonanceProducer") << "AlCaEcalResonanceProducer: Error! can't get product esRecHit!";
428  }
429  const EcalRecHitCollection* hitCollection_es = esRecHitsHandle.product();
430  // make a map of rechits:
431  m_esrechit_map.clear();
433  for (iter = esRecHitsHandle->begin(); iter != esRecHitsHandle->end(); iter++) {
434  //Make the map of DetID, EcalRecHit pairs
435  m_esrechit_map.insert(std::make_pair(iter->id(), *iter));
436  }
437  // The set of used DetID's for a given event:
438  m_used_strips.clear();
439  std::auto_ptr<ESRecHitCollection> selESRecHitCollection(new ESRecHitCollection );
440 
441  Handle<EERecHitCollection> endcapRecHitsHandle;
442  iEvent.getByToken(endcapHitsToken_,endcapRecHitsHandle);
443  if (!endcapRecHitsHandle.isValid()) {
444  LogError("AlCaEcalResonanceProducer") << "AlCaEcalResonanceProducer: Error! can't get product endcap hits!";
445  }
446  const EcalRecHitCollection *hitCollection_ee = endcapRecHitsHandle.product();
447  Handle<reco::BasicClusterCollection> endcapClustersHandle;
448  iEvent.getByToken(endcapClustersToken_,endcapClustersHandle);
449  if (!endcapClustersHandle.isValid()) {
450  LogError("AlCaEcalResonanceProducer") << "AlCaEcalResonanceProducer: Error! can't get product endcap clusters!";
451  }
452  const reco::BasicClusterCollection *clusterCollection_ee = endcapClustersHandle.product();
453  if(debug_>=1)
454  LogDebug("AlCaEcalResonanceProducer") <<" endcap_input_size: run "<<iEvent.id().run()<<" event "<<iEvent.id().event()<<" nhitEE: "<<hitCollection_ee->size()<<" nhitES: "<<hitCollection_es->size()<<" nCluster: "<< clusterCollection_ee->size();
455 
456 
457  if(doSelEndcap_){
458 
459  map<int, vector<EcalRecHit> > RecHits5x5_clus;
460  vector<int> indIsoClus;
461  vector<int> indCandClus;
462  vector<int> indClusSelected;
463 
464  doSelection( EcalEndcap,clusterCollection_ee, hitCollection_ee, channelStatus,topology_ee,
465  RecHits5x5_clus,
466  indCandClus,indIsoClus, indClusSelected);
467 
469  for(int i = 0; i < int(indClusSelected.size()); i++){
470  int ind = indClusSelected[i];
471  reco::BasicClusterCollection::const_iterator it_bc3 = clusterCollection_ee->begin() + ind;
472  const std::vector< std::pair<DetId, float> > &vid = it_bc3->hitsAndFractions();
473  for (std::vector<std::pair<DetId,float> >::const_iterator idItr = vid.begin();idItr != vid.end ();++idItr){
474  EcalRecHitCollection::const_iterator hit = hitCollection_ee->find(idItr->first);
475  if( hit == hitCollection_ee->end()) continue; //this should not happen.
476  selEERecHitCollection->push_back(*hit);
477  selectedEEDetIds.push_back(idItr->first);
478  }
480  if(storeRecHitES_){
481  std::set<DetId> used_strips_before = m_used_strips;
482  makeClusterES(it_bc3->x(),it_bc3->y(),it_bc3->z(),geometry_es,topology_es);
483  std::set<DetId>::const_iterator ites = m_used_strips.begin();
484  for(; ites != m_used_strips.end(); ++ ites ){
485  ESDetId d1 = ESDetId(*ites);
486  std::set<DetId>::const_iterator ites2 = find(used_strips_before.begin(),used_strips_before.end(),d1);
487  if( (ites2 == used_strips_before.end())){
488  std::map<DetId, EcalRecHit>::iterator itmap = m_esrechit_map.find(d1);
489  selESRecHitCollection->push_back(itmap->second);
490  }
491  }
492  }
493  }
494 
495 
496  if( store5x5RecHitEE_ ){
498  for(int i = 0; i < int( indCandClus.size()); i++){
499  int ind = indCandClus[i];
500  vector<EcalRecHit> v5x5 = RecHits5x5_clus[ind];
501  for(int n=0; n< int(v5x5.size()); n++){
502  DetId ed = v5x5[n].id();
503  std::vector<DetId>::iterator itdet = find(selectedEEDetIds.begin(),selectedEEDetIds.end(),ed);
504  if( itdet == selectedEEDetIds.end()){
505  selectedEEDetIds.push_back(ed);
506  selEERecHitCollection->push_back(v5x5[n]);
507  }
508  }
509  }
510 
511 
513  for(int i = 0; i < int( indIsoClus.size()); i++){
514  int ind = indIsoClus[i];
515 
516  std::vector<int>::iterator it = find(indCandClus.begin(),indCandClus.end(), ind);
517  if( it != indCandClus.end()) continue;
518 
519  reco::BasicClusterCollection::const_iterator it_bc3 = clusterCollection_ee->begin() + ind;
520  DetId seedId = it_bc3->seed();
521  std::vector<DetId> clus_v5x5 = topology_ee->getWindow(seedId,5,5);
522  for( std::vector<DetId>::const_iterator idItr = clus_v5x5.begin(); idItr != clus_v5x5.end(); idItr++){
523  DetId ed = *idItr;
524  EcalRecHitCollection::const_iterator rit = hitCollection_ee->find( ed );
525  if ( rit == hitCollection_ee->end() ) continue;
526  if( ! checkStatusOfEcalRecHit(channelStatus, *rit) ) continue;
527  std::vector<DetId>::iterator itdet = find(selectedEEDetIds.begin(),selectedEEDetIds.end(),ed);
528  if( itdet == selectedEEDetIds.end()){
529  selectedEEDetIds.push_back(ed);
530  selEERecHitCollection->push_back(*rit);
531  }
532  }
533  }
534  }
535 
536  }// end of selection for eta/pi0->gg in the endcap
537 
538 
539 
540  delete topology_es;
541 
543 
544  if(debug_>=1)
545  LogDebug("AlCaEcalResonanceProducer") <<" endcap_output_size run "<<iEvent.id().run()<<"_"<<iEvent.id().event()<<" nEESaved "<<selEERecHitCollection->size()<<" nESSaved: " << selESRecHitCollection->size();
546 
547 
548  //Put selected information in the event
549  int ee_collsize = selEERecHitCollection->size();
550 
551  if( eb_collsize < 2 && ee_collsize <2)
552  return false;
553 
555  if(doSelBarrel_){
556  iEvent.put( selEBRecHitCollection, BarrelHits_);
557  }
558  if(doSelEndcap_){
559  iEvent.put( selEERecHitCollection, EndcapHits_);
560  if(storeRecHitES_){
561  iEvent.put( selESRecHitCollection, ESHits_);
562  }
563  }
564 
565  return true;
566 
567 
568 }
569 
570 
571 
574  const EcalChannelStatus &channelStatus,
575  const CaloSubdetectorTopology *topology_p,
576  map<int, vector<EcalRecHit> > &RecHits5x5_clus,
577  vector<int> &indCandClus,
578  vector<int> &indIsoClus,
579  vector<int> &indClusSelected
580  ){
581 
582 
583  vector<int> indClusPi0Candidates;
584  if( detector ==EcalBarrel && removePi0CandidatesForEta_){
585  for( reco::BasicClusterCollection::const_iterator it_bc = clusterCollection->begin(); it_bc != clusterCollection->end();it_bc++){
586  for( reco::BasicClusterCollection::const_iterator it_bc2 = it_bc + 1 ; it_bc2 != clusterCollection->end();it_bc2++){
587  float m_pair,pt_pair,eta_pair, phi_pair;
588  calcPaircluster(*it_bc,*it_bc2, m_pair, pt_pair,eta_pair,phi_pair);
589  if(m_pair > massLowPi0Cand_ && m_pair < massHighPi0Cand_){
590  int indtmp[2]={ int( it_bc - clusterCollection->begin()), int( it_bc2 - clusterCollection->begin())};
591  for( int k=0;k<2; k++){
592  std::vector<int>::iterator it = find(indClusPi0Candidates.begin(),indClusPi0Candidates.end(),indtmp[k]);
593  if( it == indClusPi0Candidates.end()) indClusPi0Candidates.push_back(indtmp[k]);
594  }
595  }
596  }
597  }//end of loop over finding pi0's clusters
598  }
599 
600  //mass cut
601  double m_minCut = seleMinvMinBarrel_;
602  double m_maxCut = seleMinvMaxBarrel_;
603 
604  //isolation
605  double ptminforIso = ptMinForIsolation_;
606  double isoBeltdrCut = seleBeltDR_ ;
607  double isoBeltdetaCut = seleBeltDeta_;
608 
609  //other
610  double s9s25Cut = seleS9S25Gamma_;
611  bool store5x5 = store5x5RecHitEB_;
612 
613  //double isoCut = seleIso_; //old non-region filter
614  //double s4s9Cut = seleS4S9Gamma_; // old non-region filter
615 
616  if( detector == EcalEndcap){
617  //mass cuts
618  m_minCut = seleMinvMinEndCap_;
619  m_maxCut = seleMinvMaxEndCap_;
620 
621  //isolation
622  ptminforIso = ptMinForIsolationEndCap_;
623  isoBeltdrCut = seleBeltDREndCap_;
624  isoBeltdetaCut = seleBeltDetaEndCap_;
625 
626  //other
627  s9s25Cut = seleS9S25GammaEndCap_ ;
628  store5x5 = store5x5RecHitEE_;
629 
630  //isoCut = seleIsoEndCap_; // old non-region filter
631  //s4s9Cut = seleS4S9GammaEndCap_; //old non-region filter
632  }
633 
634  map<int,bool> passShowerShape_clus; //if this cluster passed showershape cut, so no need to compute the quantity again for each loop
635 
636  for( reco::BasicClusterCollection::const_iterator it_bc = clusterCollection->begin(); it_bc != clusterCollection->end();it_bc++){
637 
638  if( detector == EcalBarrel && removePi0CandidatesForEta_){
639  std::vector<int>::iterator it = find(indClusPi0Candidates.begin(),indClusPi0Candidates.end(),int(it_bc - clusterCollection->begin()) );
640  if( it != indClusPi0Candidates.end()) continue;
641  }
642 
643  float en1 = it_bc->energy();
644  float theta1 = 2. * atan(exp(-it_bc->position().eta()));
645  float pt1 = en1*sin(theta1);
646 
647  int ind1 = int( it_bc - clusterCollection->begin() );
648  std::map<int,bool>::iterator itmap = passShowerShape_clus.find(ind1);
649  if( itmap != passShowerShape_clus.end()){
650  if( itmap->second == false){
651  continue;
652  }
653  }
654 
655  for( reco::BasicClusterCollection::const_iterator it_bc2 = it_bc + 1 ; it_bc2 != clusterCollection->end();it_bc2++){
656  if( detector ==EcalBarrel && removePi0CandidatesForEta_){
657  std::vector<int>::iterator it = find(indClusPi0Candidates.begin(),indClusPi0Candidates.end(),int(it_bc2 - clusterCollection->begin()) );
658  if( it != indClusPi0Candidates.end()) continue;
659  }
660  float en2 = it_bc2 ->energy();
661  float theta2 = 2. * atan(exp(-it_bc2->position().eta()));
662  float pt2 = en2*sin(theta2);
663 
664  int ind2 = int( it_bc2 - clusterCollection->begin() );
665  std::map<int,bool>::iterator itmap = passShowerShape_clus.find(ind2);
666  if( itmap != passShowerShape_clus.end()){
667  if( itmap->second == false){
668  continue;
669  }
670  }
671 
672  float m_pair,pt_pair,eta_pair, phi_pair;
673  calcPaircluster(*it_bc,*it_bc2, m_pair, pt_pair,eta_pair,phi_pair);
674 
676  float ptmin = pt1< pt2 ? pt1:pt2;
677  float etapair = fabs(eta_pair);
678 
679  //-------------------------------------
680  // Region Based Kinematic Cuts: pt of the diphoton system and pt of each photon
681  //-------------------------------------
682  if( detector ==EcalBarrel ){ // BARREL
683  //EB region 1
684  if(etapair <= region1_Barrel_){ //EB region 1
685  if(ptmin < selePtGammaBarrel_region1_ || pt_pair < selePtPairBarrel_region1_) continue;
686  }
687  //EB region 2
688  else{
689  if(ptmin < selePtGammaBarrel_region2_ || pt_pair < selePtPairBarrel_region2_) continue;
690  }
691  }
692  else{ // ENDCAP
693  //EE region 1
694  if(etapair <= region1_EndCap_){
695  if(ptmin < selePtGammaEndCap_region1_ || pt_pair < selePtPairEndCap_region1_) continue;
696  }
697  //EE region 2
698  else if( etapair <= region2_EndCap_){
699  if(ptmin < selePtGammaEndCap_region2_ || pt_pair < selePtPairEndCap_region2_) continue;
700  }
701  //EE region 3
702  else{
703  if(ptmin < selePtGammaEndCap_region3_ || pt_pair < selePtPairEndCap_region3_) continue;
704  if(pt_pair > selePtPairMaxEndCap_region3_ ) continue; // there is also a possible maximum pt for the very forward region
705  }
706  }
707 
709  if( m_pair < m_minCut || m_pair > m_maxCut) continue;
710 
712  vector<int> IsoClus;
713  IsoClus.push_back(ind1); //first two are good clusters
714  IsoClus.push_back(ind2);
715 
716  float Iso = 0;
717  for( reco::BasicClusterCollection::const_iterator it_bc3 = clusterCollection->begin(); it_bc3 != clusterCollection->end();it_bc3++){
718  if( it_bc3->seed() == it_bc->seed() || it_bc3->seed() == it_bc2->seed()) continue;
719  float drcl = GetDeltaR(eta_pair,it_bc3->eta(),phi_pair,it_bc3->phi());
720  float dretacl = fabs( eta_pair - it_bc3->eta());
721  if( drcl > isoBeltdrCut || dretacl > isoBeltdetaCut ) continue;
722  float pt3 = it_bc3->energy()*sin(it_bc3->position().theta()) ;
723  if( pt3 < ptminforIso) continue;
724  Iso += pt3;
725  int ind3 = int(it_bc3 - clusterCollection->begin());
726  IsoClus.push_back( ind3);
727  }
728 
729  //-------------------------------------
730  // Region Based Isolation Cut: pt of the diphoton system and pt of each photon
731  //-------------------------------------
732  float iso_val = Iso/pt_pair;
733  // BARREL
734  if( detector == EcalBarrel ){
735  //EB region 1
736  if(etapair <= region1_Barrel_){ //EB region 1
737  if(iso_val > seleIsoBarrel_region1_ ) continue;
738  }
739  //EB region 2
740  else{
741  if(iso_val > seleIsoBarrel_region2_ ) continue;
742  }
743  }
744  // ENDCAP
745  else{
746  //EE region 1
747  if(etapair <= region1_EndCap_){
748  if(iso_val > seleIsoEndCap_region1_ ) continue;
749  }
750  //EE region 2
751  else if( etapair <= region2_EndCap_){
752  if(iso_val > seleIsoEndCap_region2_ ) continue;
753  }
754  //EE region 3
755  else{
756  if(iso_val > seleIsoEndCap_region3_ ) continue;
757  }
758  }
759  //-------------------------------------
760  //if(Iso/pt_pair > isoCut) continue; //old non-regional cut
761 
762 
763  //-------------------------------------
764  // Region based ShowerShape Cut: S4S9 Cut with possible S9S25 configuration
765  //-------------------------------------
766 
767  bool failShowerShape = false;
768  for(int n=0; n<2; n++){
769  int ind = IsoClus[n];
770  reco::BasicClusterCollection::const_iterator it_bc3 = clusterCollection->begin() + ind;
771  std::map<int,bool>::iterator itmap = passShowerShape_clus.find(ind);
772 
773  if( itmap != passShowerShape_clus.end()){ // if we havent reached the end
774  if( itmap->second == false){
775  failShowerShape = true;
776  n=2; //exit the loop
777  }
778  }
779  else{
780  vector<EcalRecHit> RecHitsCluster_5x5;
781  float res[3];
782 
783  //build the shower shape variables
784  calcShowerShape(*it_bc3, channelStatus,hitCollection, topology_p,store5x5, RecHitsCluster_5x5, res);
785  float s4s9 = res[1] >0 ? res[0]/ res[1] : -1;
786  float s9s25 = res[2] >0 ? res[1] / res[2] : -1;
787 
788  bool passed = false;
789 
790  // BARREL
791  if( detector == EcalBarrel ){
792  //EB region 1
793  if(etapair <= region1_Barrel_){
794  passed = s4s9 > seleS4S9GammaBarrel_region1_;
795  }
796  //EB region 2
797  else{
798  passed = s4s9 > seleS4S9GammaBarrel_region2_;
799  }
800  }
801  // ENDCAP
802  else{
803  //EE region 1
804  if( etapair <= region1_EndCap_){
805  passed = s4s9 > seleS4S9GammaEndCap_region1_;
806  }
807  //EE region 2
808  else if( etapair <= region2_EndCap_){
809  passed = s4s9 > seleS4S9GammaEndCap_region2_;
810  }
811  //EE region 3
812  else{
813  passed = s4s9 > seleS4S9GammaEndCap_region3_;
814  }
815  }
816 
817  //apply the S9S25 cut as well
818  passed = passed && (s9s25 > s9s25Cut);
819  passShowerShape_clus.insert(pair<int, bool>(ind, passed));
820 
821  if( !passed ){
822  failShowerShape = true;
823  n=2; //exit the loop
824  }
825  else{
826  RecHits5x5_clus.insert(pair<int, vector<EcalRecHit> >(ind,RecHitsCluster_5x5) );
827  }
828  }
829  }
830 
831  if( failShowerShape == true) continue; //if any of the two clusters fail shower shape
832 
833 
835  for(unsigned int iii=0 ; iii<IsoClus.size() ; iii++){
836  int ind = IsoClus[iii];
837 
838  if( iii < 2){
839  std::vector<int>::iterator it = find(indCandClus.begin(),indCandClus.end(), ind);
840  if( it == indCandClus.end()) indCandClus.push_back(ind);
841  else continue;
842  }
843  else{
844  std::vector<int>::iterator it = find(indIsoClus.begin(),indIsoClus.end(), ind); //iso cluster
845  if( it == indIsoClus.end()) indIsoClus.push_back(ind);
846  else continue;
847  }
848 
849  std::vector<int>::iterator it = find(indClusSelected.begin(),indClusSelected.end(),ind);
850  if( it != indClusSelected.end()) continue;
851  indClusSelected.push_back(ind);
852  }
853  }
854  }
855 }
856 
857 
858 
859 
860 
861 
862 
863 void HLTRegionalEcalResonanceFilter::convxtalid(Int_t &nphi,Int_t &neta)
864 {
865  // Barrel only
866  // Output nphi 0...359; neta 0...84; nside=+1 (for eta>0), or 0 (for eta<0).
867  // neta will be [-85,-1] , or [0,84], the minus sign indicates the z<0 side.
868 
869  if(neta > 0) neta -= 1;
870  if(nphi > 359) nphi=nphi-360;
871 
872  // final check
873  if(nphi >359 || nphi <0 || neta< -85 || neta > 84)
874  {
875  LogError("") <<" unexpected fatal error in HLTEcalResonanceFilter::convxtalid "<< nphi << " " << neta << " " <<std::endl;
876  }
877 } //end of convxtalid
878 
879 
880 
881 
882 int HLTRegionalEcalResonanceFilter::diff_neta_s(Int_t neta1, Int_t neta2){
883  Int_t mdiff;
884  mdiff=(neta1-neta2);
885  return mdiff;
886 }
887 
888 // Calculate the distance in xtals taking into account the periodicity of the Barrel
889 int HLTRegionalEcalResonanceFilter::diff_nphi_s(Int_t nphi1,Int_t nphi2) {
890  Int_t mdiff;
891  if(std::abs(nphi1-nphi2) < (360-std::abs(nphi1-nphi2))) {
892  mdiff=nphi1-nphi2;
893  }
894  else {
895  mdiff=360-std::abs(nphi1-nphi2);
896  if(nphi1>nphi2) mdiff=-mdiff;
897  }
898  return mdiff;
899 }
900 
901 
902 void HLTRegionalEcalResonanceFilter::calcShowerShape(const reco::BasicCluster &bc, const EcalChannelStatus &channelStatus, const EcalRecHitCollection *recHits, const CaloSubdetectorTopology *topology_p, bool calc5x5, vector<EcalRecHit> &rechit5x5, float res[]){
903 
904 
905  const std::vector< std::pair<DetId, float> > &vid = bc.hitsAndFractions();
906 
907 
908  float e2x2[4]={0};
909  float e3x3 =0 ;
910  float e5x5 =0;
911  int seedx ;
912  int seedy;
913  DetId seedId = bc.seed();
914 
915  bool InBarrel = true;
916  if( seedId.subdetId() == EcalBarrel){
917  EBDetId ebd = EBDetId(seedId);
918  seedx = ebd.ieta();
919  seedy = ebd.iphi();
920  convxtalid(seedy,seedx);
921  }else{
922  InBarrel = false;
923  EEDetId eed = EEDetId(seedId);
924  seedx = eed.ix();
925  seedy = eed.iy();
926  }
927  int x,y, dx, dy;
928 
929 
930 
931  if( calc5x5 ){
932  rechit5x5.clear();
933  std::vector<DetId> clus_v5x5;
934  clus_v5x5 = topology_p->getWindow(seedId,5,5);
935 
936  for( std::vector<DetId>::const_iterator idItr = clus_v5x5.begin(); idItr != clus_v5x5.end(); idItr++){
937  DetId ed = *idItr;
938  if( InBarrel == true){
939  EBDetId ebd = EBDetId(ed);
940  x = ebd.ieta();
941  y = ebd.iphi();
942  convxtalid(y,x);
943  dx = diff_neta_s(x,seedx);
944  dy = diff_nphi_s(y,seedy);
945  }else{
946  EEDetId eed = EEDetId(ed);
947  x = eed.ix();
948  y = eed.iy();
949  dx = x-seedx;
950  dy = y-seedy;
951  }
952  EcalRecHitCollection::const_iterator rit = recHits->find( ed );
953  if ( rit == recHits->end() ) continue;
954  if( ! checkStatusOfEcalRecHit(channelStatus, *rit) ) continue;
955 
956  float energy = (*rit).energy();
957  e5x5 += energy;
958 
959  std::vector<std::pair<DetId,float> >::const_iterator idItrF = std::find( vid.begin(),vid.end(), std::make_pair(ed,1.0f));
960  if( idItrF == vid.end()){
961  rechit5x5.push_back(*rit);
962  }else{
963  if(std::abs(dx)<=1 && std::abs(dy)<=1) {
964  if(dx <= 0 && dy <=0) e2x2[0] += energy;
965  if(dx >= 0 && dy <=0) e2x2[1] += energy;
966  if(dx <= 0 && dy >=0) e2x2[2] += energy;
967  if(dx >= 0 && dy >=0) e2x2[3] += energy;
968  e3x3 += energy;
969  }
970  }
971  }
972 
973 
974  }else{
975 
976  for (std::vector<std::pair<DetId,float> >::const_iterator idItr = vid.begin();idItr != vid.end ();++idItr){
977  DetId ed = idItr->first;
978  if( InBarrel == true){
979  EBDetId ebd = EBDetId(ed);
980  x = ebd.ieta();
981  y = ebd.iphi();
982  convxtalid(y,x);
983  dx = diff_neta_s(x,seedx);
984  dy = diff_nphi_s(y,seedy);
985  }else{
986  EEDetId eed = EEDetId(ed);
987  x = eed.ix();
988  y = eed.iy();
989  dx = x-seedx;
990  dy = y-seedy;
991  }
992  EcalRecHitCollection::const_iterator rit = recHits->find( ed );
993  if ( rit == recHits->end() ) {
994  continue;
995  }
996 
997  float energy = (*rit).energy();
998  if(std::abs(dx)<=1 && std::abs(dy)<=1){
999  if(dx <= 0 && dy <=0) e2x2[0] += energy;
1000  if(dx >= 0 && dy <=0) e2x2[1] += energy;
1001  if(dx <= 0 && dy >=0) e2x2[2] += energy;
1002  if(dx >= 0 && dy >=0) e2x2[3] += energy;
1003  e3x3 += energy;
1004  }
1005 
1006  }
1007  e5x5 = e3x3;
1008  }
1009 
1010 
1011 
1013  res[0] = *max_element( e2x2,e2x2+4);
1014  res[1] = e3x3;
1015  res[2] = e5x5;
1016 
1017 
1018 }
1019 
1020 
1021 
1022 
1023 void HLTRegionalEcalResonanceFilter::calcPaircluster(const reco::BasicCluster &bc1, const reco::BasicCluster &bc2,float &m_pair,float &pt_pair,float &eta_pair, float &phi_pair){
1024 
1025 
1026  float theta1 = 2. * atan(exp(-bc1.eta()));
1027  float en1 = bc1.energy();
1028  float pt1 = en1 * sin(theta1);
1029  TLorentzVector v1( pt1 *cos(bc1.phi()),pt1 * sin(bc1.phi()),en1*cos(theta1),en1);
1030 
1031  float theta2 = 2. * atan(exp(-bc2.eta()));
1032  float en2 = bc2.energy();
1033  float pt2 = en2 * sin(theta2);
1034  TLorentzVector v2( pt2 *cos(bc2.phi()),pt2 * sin(bc2.phi()),en2*cos(theta2),en2);
1035 
1036  TLorentzVector v = v1 + v2;
1037 
1038  m_pair = v.M();
1039  pt_pair = v.Pt();
1040  eta_pair = v.Eta();
1041  phi_pair = v.Phi();
1042 
1043 
1044 }
1045 
1046 
1047 
1048 
1049 
1051 
1052  if(useRecoFlag_ ){
1053  int flag = rh.recoFlag();
1054  if( flagLevelRecHitsToUse_ ==0){
1055  if( flag != 0) return false;
1056  }
1057  else if( flagLevelRecHitsToUse_ ==1){
1058  if( flag !=0 && flag != 4 ) return false;
1059  }
1060  else if( flagLevelRecHitsToUse_ ==2){
1061  if( flag !=0 && flag != 4 && flag != 6 && flag != 7) return false;
1062  }
1063  }
1064  if ( useDBStatus_){
1065  int status = int(channelStatus[rh.id().rawId()].getStatusCode());
1066  if ( status > statusLevelRecHitsToUse_ ) return false;
1067  }
1068 
1069  return true;
1070 }
1071 
1072 
1073 float HLTRegionalEcalResonanceFilter::DeltaPhi(float phi1, float phi2){
1074 
1075  float diff = fabs(phi2 - phi1);
1076 
1077  while (diff >acos(-1)) diff -= 2*acos(-1);
1078  while (diff <= -acos(-1)) diff += 2*acos(-1);
1079 
1080  return diff;
1081 
1082 }
1083 
1084 
1085 float HLTRegionalEcalResonanceFilter::GetDeltaR(float eta1, float eta2, float phi1, float phi2){
1086 
1087  return sqrt( (eta1-eta2)*(eta1-eta2)
1088  + DeltaPhi(phi1, phi2)*DeltaPhi(phi1, phi2) );
1089 
1090 }
1091 
1092 
1093 void HLTRegionalEcalResonanceFilter::makeClusterES(float x, float y, float z,const CaloSubdetectorGeometry*& geometry_es,
1094  CaloSubdetectorTopology*& topology_es
1095  ){
1096 
1097 
1099  const GlobalPoint point(x,y,z);
1100  DetId tmp1 = (dynamic_cast<const EcalPreshowerGeometry*>(geometry_es))->getClosestCellInPlane(point, 1);
1101  DetId tmp2 = (dynamic_cast<const EcalPreshowerGeometry*>(geometry_es))->getClosestCellInPlane(point, 2);
1102  ESDetId strip1 = (tmp1 == DetId(0)) ? ESDetId(0) : ESDetId(tmp1);
1103  ESDetId strip2 = (tmp2 == DetId(0)) ? ESDetId(0) : ESDetId(tmp2);
1104 
1105  // Get ES clusters (found by the PreshSeeded algorithm) associated with a given EE cluster.
1106  for (int i2=0; i2<preshNclust_; i2++) {
1107  reco::PreshowerCluster cl1 = presh_algo_->makeOneCluster(strip1,&m_used_strips,&m_esrechit_map,geometry_es,topology_es);
1108  reco::PreshowerCluster cl2 = presh_algo_->makeOneCluster(strip2,&m_used_strips,&m_esrechit_map,geometry_es,topology_es);
1109  } // end of cycle over ES clusters
1110 
1111 }
#define LogDebug(id)
RunNumber_t run() const
Definition: EventID.h:39
T getParameter(std::string const &) const
EventNumber_t event() const
Definition: EventID.h:41
int i
Definition: DBlmapReader.cc:9
int ix() const
Definition: EEDetId.h:76
virtual bool filter(edm::Event &, const edm::EventSetup &)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:464
bool checkStatusOfEcalRecHit(const EcalChannelStatus &channelStatus, const EcalRecHit &rh)
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
std::vector< EcalRecHit >::const_iterator const_iterator
static float GetDeltaR(float eta1, float eta2, float phi1, float phi2)
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:7
void doSelection(int detector, const reco::BasicClusterCollection *clusterCollection, const EcalRecHitCollection *hitCollection, const EcalChannelStatus &channelStatus, const CaloSubdetectorTopology *topology_p, std::map< int, std::vector< EcalRecHit > > &RecHits5x5_clus, std::vector< int > &indCandClus, std::vector< int > &indIsoClus, std::vector< int > &indClusSelected)
int iphi() const
get the crystal iphi
Definition: EBDetId.h:53
uint32_t rawId() const
get the raw id
Definition: DetId.h:43
T x() const
Cartesian x coordinate.
int iEvent
Definition: GenABIO.cc:230
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:120
T sqrt(T t)
Definition: SSEVec.h:48
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
void calcPaircluster(const reco::BasicCluster &bc1, const reco::BasicCluster &bc2, float &mpair, float &ptpair, float &etapair, float &phipair)
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
double f[11][100]
static float DeltaPhi(float phi1, float phi2)
int iy() const
Definition: EEDetId.h:82
void calcShowerShape(const reco::BasicCluster &bc, const EcalChannelStatus &channelStatus, const EcalRecHitCollection *recHits, const CaloSubdetectorTopology *topology_p, bool calc5x5, std::vector< EcalRecHit > &rechit5x5, float res[])
HLTRegionalEcalResonanceFilter(const edm::ParameterSet &)
int ieta() const
get the crystal ieta
Definition: EBDetId.h:51
ParameterDescriptionBase * add(U const &iLabel, T const &value)
bool isValid() const
Definition: HandleBase.h:75
int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:37
const_iterator end() const
Definition: DetId.h:18
virtual std::vector< DetId > getWindow(const DetId &id, const int &northSouthSize, const int &eastWestSize) const
DetId id() const
get the id
Definition: EcalRecHit.h:76
T const * product() const
Definition: Handle.h:81
void makeClusterES(float x, float y, float z, const CaloSubdetectorGeometry *&iSubGeom, CaloSubdetectorTopology *&topology_p)
Flags recoFlag() const
DEPRECATED provided for temporary backward compatibility.
Definition: EcalRecHit.h:189
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
double ptmin
Definition: HydjetWrapper.h:90
edm::EventID id() const
Definition: EventBase.h:60
iterator find(key_type k)
size_type size() const
tuple status
Definition: ntuplemaker.py:245
*vegas h *****************************************************used in the default bin number in original ***version of VEGAS is ***a higher bin number might help to derive a more precise ***grade subtle point
Definition: invegas.h:5