15 barrelHitsToken_ = consumes<EBRecHitCollection>(barrelHits_);
16 barrelClustersToken_ = consumes<reco::BasicClusterCollection>(barrelClusters_);
20 endcapHitsToken_ = consumes<EERecHitCollection>(endcapHits_);
21 endcapClustersToken_ = consumes<reco::BasicClusterCollection>(endcapClusters_);
23 doSelBarrel_ = iConfig.
getParameter<
bool>(
"doSelBarrel");
30 region1_Barrel_ = barrelSelection.
getParameter<
double> (
"region1_Barrel");
31 selePtGammaBarrel_region1_ = barrelSelection.
getParameter<
double> (
"selePtGammaBarrel_region1");
32 selePtPairBarrel_region1_ = barrelSelection.
getParameter<
double> (
"selePtPairBarrel_region1");
33 seleS4S9GammaBarrel_region1_ = barrelSelection.
getParameter<
double> (
"seleS4S9GammaBarrel_region1");
34 seleIsoBarrel_region1_ = barrelSelection.
getParameter<
double> (
"seleIsoBarrel_region1");
35 seleNxtalBarrel_region1_ = barrelSelection.
getParameter<uint32_t> (
"seleNxtalBarrel_region1");
38 selePtGammaBarrel_region2_ = barrelSelection.
getParameter<
double> (
"selePtGammaBarrel_region2");
39 selePtPairBarrel_region2_ = barrelSelection.
getParameter<
double> (
"selePtPairBarrel_region2");
40 seleS4S9GammaBarrel_region2_ = barrelSelection.
getParameter<
double> (
"seleS4S9GammaBarrel_region2");
41 seleIsoBarrel_region2_ = barrelSelection.
getParameter<
double> (
"seleIsoBarrel_region2");
42 seleNxtalBarrel_region2_ = barrelSelection.
getParameter<uint32_t> (
"seleNxtalBarrel_region2");
45 seleS9S25Gamma_ = barrelSelection.
getParameter<
double> (
"seleS9S25Gamma");
48 seleMinvMaxBarrel_ = barrelSelection.
getParameter<
double> (
"seleMinvMaxBarrel");
49 seleMinvMinBarrel_ = barrelSelection.
getParameter<
double> (
"seleMinvMinBarrel");
52 removePi0CandidatesForEta_ = barrelSelection.
getParameter<
bool>(
"removePi0CandidatesForEta");
53 if(removePi0CandidatesForEta_){
54 massLowPi0Cand_ = barrelSelection.
getParameter<
double>(
"massLowPi0Cand");
55 massHighPi0Cand_ = barrelSelection.
getParameter<
double>(
"massHighPi0Cand");
59 ptMinForIsolation_ = barrelSelection.
getParameter<
double> (
"ptMinForIsolation");
60 seleBeltDR_ = barrelSelection.
getParameter<
double> (
"seleBeltDR");
61 seleBeltDeta_ = barrelSelection.
getParameter<
double> (
"seleBeltDeta");
64 store5x5RecHitEB_ = barrelSelection.
getParameter<
bool> (
"store5x5RecHitEB");
65 BarrelHits_ = barrelSelection.
getParameter<
string> (
"barrelHitCollection");
72 produces<EBRecHitCollection>(BarrelHits_);
76 doSelEndcap_ = iConfig.
getParameter<
bool>(
"doSelEndcap");
81 seleMinvMaxEndCap_ = endcapSelection.
getParameter<
double> (
"seleMinvMaxEndCap");
82 seleMinvMinEndCap_ = endcapSelection.
getParameter<
double> (
"seleMinvMinEndCap");
85 region1_EndCap_ = endcapSelection.
getParameter<
double> (
"region1_EndCap");
86 selePtGammaEndCap_region1_ = endcapSelection.
getParameter<
double> (
"selePtGammaEndCap_region1");
87 selePtPairEndCap_region1_ = endcapSelection.
getParameter<
double> (
"selePtPairEndCap_region1");
88 seleS4S9GammaEndCap_region1_ = endcapSelection.
getParameter<
double> (
"seleS4S9GammaEndCap_region1");
89 seleIsoEndCap_region1_ = endcapSelection.
getParameter<
double> (
"seleIsoEndCap_region1");
90 seleNxtalEndCap_region1_ = endcapSelection.
getParameter<uint32_t> (
"seleNxtalEndCap_region1");
93 region2_EndCap_ = endcapSelection.
getParameter<
double> (
"region2_EndCap");
94 selePtGammaEndCap_region2_ = endcapSelection.
getParameter<
double> (
"selePtGammaEndCap_region2");
95 selePtPairEndCap_region2_ = endcapSelection.
getParameter<
double> (
"selePtPairEndCap_region2");
96 seleS4S9GammaEndCap_region2_ = endcapSelection.
getParameter<
double> (
"seleS4S9GammaEndCap_region2");
97 seleIsoEndCap_region2_ = endcapSelection.
getParameter<
double> (
"seleIsoEndCap_region2");
98 seleNxtalEndCap_region2_ = endcapSelection.
getParameter<uint32_t> (
"seleNxtalEndCap_region2");
101 selePtGammaEndCap_region3_ = endcapSelection.
getParameter<
double> (
"selePtGammaEndCap_region3");
102 selePtPairEndCap_region3_ = endcapSelection.
getParameter<
double> (
"selePtPairEndCap_region3");
103 selePtPairMaxEndCap_region3_ = endcapSelection.
getParameter<
double> (
"selePtPairMaxEndCap_region3");
104 seleS4S9GammaEndCap_region3_ = endcapSelection.
getParameter<
double> (
"seleS4S9GammaEndCap_region3");
105 seleIsoEndCap_region3_ = endcapSelection.
getParameter<
double> (
"seleIsoEndCap_region3");
106 seleNxtalEndCap_region3_ = endcapSelection.
getParameter<uint32_t> (
"seleNxtalEndCap_region3");
108 seleS9S25GammaEndCap_ = endcapSelection.
getParameter<
double> (
"seleS9S25GammaEndCap");
111 ptMinForIsolationEndCap_ = endcapSelection.
getParameter<
double> (
"ptMinForIsolationEndCap");
112 seleBeltDREndCap_ = endcapSelection.
getParameter<
double> (
"seleBeltDREndCap");
113 seleBeltDetaEndCap_ = endcapSelection.
getParameter<
double> (
"seleBeltDetaEndCap");
116 store5x5RecHitEE_ = endcapSelection.
getParameter<
bool> (
"store5x5RecHitEE");
117 EndcapHits_ = endcapSelection.
getParameter<
string > (
"endcapHitCollection");
122 produces< EERecHitCollection >(EndcapHits_);
126 useRecoFlag_ = iConfig.
getParameter<
bool>(
"useRecoFlag");
127 flagLevelRecHitsToUse_ = iConfig.
getParameter<
int>(
"flagLevelRecHitsToUse");
129 useDBStatus_ = iConfig.
getParameter<
bool>(
"useDBStatus");
130 statusLevelRecHitsToUse_ = iConfig.
getParameter<
int>(
"statusLevelRecHitsToUse");
134 preshHitsToken_ = consumes<EBRecHitCollection>(preshHitProducer_);
137 storeRecHitES_ = iConfig.
getParameter<
bool>(
"storeRecHitES");
143 preshNclust_ = preshowerSelection.
getParameter<
int>(
"preshNclust");
145 preshClustECut = preshowerSelection.
getParameter<
double>(
"preshClusterEnergyCut");
147 float preshStripECut = preshowerSelection.
getParameter<
double>(
"preshStripEnergyCut");
148 int preshSeededNst = preshowerSelection.
getParameter<
int>(
"preshSeededNstrip");
150 calib_planeX_ = preshowerSelection.
getParameter<
double>(
"preshCalibPlaneX");
151 calib_planeY_ = preshowerSelection.
getParameter<
double>(
"preshCalibPlaneY");
152 gamma_ = preshowerSelection.
getParameter<
double>(
"preshCalibGamma");
153 mip_ = preshowerSelection.
getParameter<
double>(
"preshCalibMIP");
159 produces< ESRecHitCollection >(ESHits_);
183 desc.
add<
bool>(
"useRecoFlag",
false);
184 desc.
add<
int>(
"flagLevelRecHitsToUse",1);
185 desc.
add<
bool>(
"useDBStatus",
true);
186 desc.
add<
int>(
"statusLevelRecHitsToUse",1);
189 desc.
add<
bool>(
"doSelBarrel",
true);
193 barrelSelection.
add<
double>(
"region1_Barrel", 1.0);
194 barrelSelection.add<
double>(
"selePtGammaBarrel_region1", 1.0);
195 barrelSelection.add<
double>(
"selePtPairBarrel_region1", 2.0);
196 barrelSelection.add<
double>(
"seleIsoBarrel_region1", 0.5);
197 barrelSelection.add<uint32_t>(
"seleNxtalBarrel_region1", 6);
198 barrelSelection.add<
double>(
"seleS4S9GammaBarrel_region1", 0.83);
201 barrelSelection.add<
double>(
"selePtGammaBarrel_region2", 1.0);
202 barrelSelection.add<
double>(
"selePtPairBarrel_region2", 2.0);
203 barrelSelection.add<
double>(
"seleIsoBarrel_region2", 0.5);
204 barrelSelection.add<uint32_t>(
"seleNxtalBarrel_region2", 6);
205 barrelSelection.add<
double>(
"seleS4S9GammaBarrel_region2", 0.83);
208 barrelSelection.add<
double>(
"ptMinForIsolation", 1.0);
209 barrelSelection.add<
double>(
"seleBeltDR", 0.2);
210 barrelSelection.add<
double>(
"seleBeltDeta", 0.05);
213 barrelSelection.add<
double>(
"seleMinvMaxBarrel", 0.22);
214 barrelSelection.add<
double>(
"seleMinvMinBarrel", 0.06);
215 barrelSelection.add<
bool>(
"removePi0CandidatesForEta",
false);
216 barrelSelection.add<
double>(
"massLowPi0Cand", 0.104);
217 barrelSelection.add<
double>(
"massHighPi0Cand", 0.163);
218 barrelSelection.add<
double>(
"seleS9S25Gamma", 0.);
221 barrelSelection.add<
bool>(
"store5x5RecHitEB",
false);
222 barrelSelection.add<
std::string>(
"barrelHitCollection",
"pi0EcalRecHitsEB");
233 desc.
add<
bool>(
"doSelEndcap",
true);
236 endcapSelection.
add<
double>(
"seleMinvMaxEndCap", 0.3);
237 endcapSelection.add<
double>(
"seleMinvMinEndCap", 0.05);
240 endcapSelection.add<
double>(
"region1_EndCap", 2.0);
241 endcapSelection.add<
double>(
"selePtGammaEndCap_region1", 0.8);
242 endcapSelection.add<
double>(
"selePtPairEndCap_region1", 3.0);
243 endcapSelection.add<
double>(
"seleS4S9GammaEndCap_region1", 0.9);
244 endcapSelection.add<
double>(
"seleIsoEndCap_region1", 0.5);
245 endcapSelection.add<uint32_t>(
"seleNxtalEndCap_region1", 6);
248 endcapSelection.add<
double>(
"region2_EndCap", 2.5);
249 endcapSelection.add<
double>(
"selePtGammaEndCap_region2", 0.5);
250 endcapSelection.add<
double>(
"selePtPairEndCap_region2", 2.0);
251 endcapSelection.add<
double>(
"seleS4S9GammaEndCap_region2", 0.9);
252 endcapSelection.add<
double>(
"seleIsoEndCap_region2", 0.5);
253 endcapSelection.add<uint32_t>(
"seleNxtalEndCap_region2", 6);
256 endcapSelection.add<
double>(
"selePtGammaEndCap_region3", 0.3);
257 endcapSelection.add<
double>(
"selePtPairEndCap_region3", 1.2);
258 endcapSelection.add<
double>(
"selePtPairMaxEndCap_region3", 2.5);
259 endcapSelection.add<
double>(
"seleS4S9GammaEndCap_region3", 0.9);
260 endcapSelection.add<
double>(
"seleIsoEndCap_region3", 0.5);
261 endcapSelection.add<uint32_t>(
"seleNxtalEndCap_region3", 6);
264 endcapSelection.add<
double>(
"seleS9S25GammaEndCap", 0.);
267 endcapSelection.add<
double>(
"ptMinForIsolationEndCap", 0.5);
268 endcapSelection.add<
double>(
"seleBeltDREndCap", 0.2);
269 endcapSelection.add<
double>(
"seleBeltDetaEndCap", 0.05);
272 endcapSelection.add<
bool>(
"store5x5RecHitEE",
false);
273 endcapSelection.add<
std::string>(
"endcapHitCollection",
"pi0EcalRecHitsEE");
280 desc.
add<
bool>(
"storeRecHitES",
true);
282 preshowerSelection.
add<
std::string>(
"ESCollection",
"pi0EcalRecHitsES");
283 preshowerSelection.add<
int>(
"preshNclust",4);
284 preshowerSelection.add<
double>(
"preshClusterEnergyCut",0.0);
285 preshowerSelection.add<
double>(
"preshStripEnergyCut",0.0);
286 preshowerSelection.add<
int>(
"preshSeededNstrip",15);
287 preshowerSelection.add<
double>(
"preshCalibPlaneX",1.0);
288 preshowerSelection.add<
double>(
"preshCalibPlaneY",0.7);
289 preshowerSelection.add<
double>(
"preshCalibGamma",0.024);
290 preshowerSelection.add<
double>(
"preshCalibMIP",9.0E-5);
291 preshowerSelection.add<
std::string>(
"debugLevelES",
"");
294 desc.
add<
int>(
"debugLevel",0);
295 descriptions.
add(
"hltRegionalEcalResonanceFilter",desc);
302 std::unique_ptr< EBRecHitCollection > selEBRecHitCollection(
new EBRecHitCollection );
304 std::unique_ptr< EERecHitCollection > selEERecHitCollection(
new EERecHitCollection );
308 vector<DetId> selectedEBDetIds;
309 vector<DetId> selectedEEDetIds;
321 std::unique_ptr<CaloSubdetectorTopology> topology_es;
323 topology_es = std::make_unique<EcalPreshowerTopology>();
325 storeRecHitES_ =
false;
338 iEvent.
getByToken(barrelHitsToken_,barrelRecHitsHandle);
339 if (!barrelRecHitsHandle.
isValid()) {
340 LogError(
"AlCaEcalResonanceProducer") <<
"AlCaEcalResonanceProducer: Error! can't get product barrel hits!";
347 iEvent.
getByToken(barrelClustersToken_,barrelClustersHandle);
348 if (!barrelClustersHandle.
isValid()) {
349 LogError(
"AlCaEcalResonanceProducer") <<
"AlCaEcalResonanceProducer: Error! can't get product barrel clusters!";
353 LogDebug(
"AlCaEcalResonanceProducer") <<
" barrel_input_size: run "<<iEvent.
id().
run()<<
" event "<<iEvent.
id().
event()<<
" nhitEB: "<<hitCollection_eb->
size()<<
" nCluster: "<< clusterCollection_eb->size();
358 map<int, vector<EcalRecHit> > RecHits5x5_clus;
359 vector<int> indIsoClus;
360 vector<int> indCandClus;
361 vector<int> indClusSelected;
363 doSelection(
EcalBarrel,clusterCollection_eb, hitCollection_eb, channelStatus,topology_eb,
365 indCandClus,indIsoClus, indClusSelected);
369 for(
int ind : indClusSelected){
370 auto it_bc3 = clusterCollection_eb->begin() + ind;
371 const std::vector< std::pair<DetId, float> > &
vid = it_bc3->hitsAndFractions();
372 for (
auto const & idItr : vid){
373 auto hit = hitCollection_eb->
find(idItr.first);
374 if(
hit == hitCollection_eb->
end())
continue;
375 selEBRecHitCollection->push_back(*
hit);
376 selectedEBDetIds.push_back(idItr.first);
381 if( store5x5RecHitEB_ ){
383 for(
int ind : indCandClus){
384 vector<EcalRecHit> v5x5 = RecHits5x5_clus[ind];
385 for(
auto &
n : v5x5){
387 auto itdet =
find(selectedEBDetIds.begin(),selectedEBDetIds.end(),ed);
388 if( itdet == selectedEBDetIds.end()){
389 selectedEBDetIds.push_back(ed);
390 selEBRecHitCollection->push_back(
n);
397 for(
int ind : indIsoClus){
398 auto it =
find(indCandClus.begin(),indCandClus.end(), ind);
399 if( it != indCandClus.end())
continue;
401 auto it_bc3 = clusterCollection_eb->begin() + ind;
402 DetId seedId = it_bc3->seed();
403 std::vector<DetId> clus_v5x5 = topology_eb->
getWindow(seedId,5,5);
404 for( std::vector<DetId>::const_iterator idItr = clus_v5x5.begin(); idItr != clus_v5x5.end(); idItr++){
406 auto rit = hitCollection_eb->
find( ed );
407 if ( rit == hitCollection_eb->
end() )
continue;
408 if( ! checkStatusOfEcalRecHit(channelStatus, *rit) )
continue;
409 auto itdet =
find(selectedEBDetIds.begin(),selectedEBDetIds.end(),ed);
410 if( itdet == selectedEBDetIds.end()){
411 selectedEBDetIds.push_back(ed);
412 selEBRecHitCollection->push_back(*rit);
421 int eb_collsize = selEBRecHitCollection->size();
424 LogDebug(
"AlCaEcalResonanceProducer") <<
" barrel_output_size_run "<<iEvent.
id().
run()<<
" event "<<iEvent.
id().
event()<<
" nEBSaved "<<selEBRecHitCollection->size();
432 iEvent.
getByToken(preshHitsToken_,esRecHitsHandle);
433 if( !esRecHitsHandle.
isValid()){
434 LogError(
"AlCaEcalResonanceProducer") <<
"AlCaEcalResonanceProducer: Error! can't get product esRecHit!";
438 m_esrechit_map.clear();
440 for (iter = esRecHitsHandle->
begin(); iter != esRecHitsHandle->
end(); iter++) {
442 m_esrechit_map.insert(std::make_pair(iter->id(), *iter));
445 m_used_strips.clear();
449 iEvent.
getByToken(endcapHitsToken_,endcapRecHitsHandle);
450 if (!endcapRecHitsHandle.
isValid()) {
451 LogError(
"AlCaEcalResonanceProducer") <<
"AlCaEcalResonanceProducer: Error! can't get product endcap hits!";
455 iEvent.
getByToken(endcapClustersToken_,endcapClustersHandle);
456 if (!endcapClustersHandle.
isValid()) {
457 LogError(
"AlCaEcalResonanceProducer") <<
"AlCaEcalResonanceProducer: Error! can't get product endcap clusters!";
461 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();
466 map<int, vector<EcalRecHit> > RecHits5x5_clus;
467 vector<int> indIsoClus;
468 vector<int> indCandClus;
469 vector<int> indClusSelected;
471 doSelection(
EcalEndcap,clusterCollection_ee, hitCollection_ee, channelStatus,topology_ee,
473 indCandClus,indIsoClus, indClusSelected);
476 for(
int ind : indClusSelected){
477 auto it_bc3 = clusterCollection_ee->begin() + ind;
478 const std::vector< std::pair<DetId, float> > &
vid = it_bc3->hitsAndFractions();
479 for (
auto const & idItr : vid){
480 auto hit = hitCollection_ee->
find(idItr.first);
481 if(
hit == hitCollection_ee->
end())
continue;
482 selEERecHitCollection->push_back(*
hit);
483 selectedEEDetIds.push_back(idItr.first);
487 std::set<DetId> used_strips_before = m_used_strips;
488 makeClusterES(it_bc3->x(),it_bc3->y(),it_bc3->z(),geometry_es,topology_es.get());
489 auto ites = m_used_strips.begin();
490 for(; ites != m_used_strips.end(); ++ ites ){
492 auto ites2 =
find(used_strips_before.begin(),used_strips_before.end(),d1);
493 if( (ites2 == used_strips_before.end())){
494 auto itmap = m_esrechit_map.find(d1);
495 selESRecHitCollection->push_back(itmap->second);
502 if( store5x5RecHitEE_ ){
504 for(
int ind : indCandClus){
505 vector<EcalRecHit> v5x5 = RecHits5x5_clus[ind];
506 for(
auto &
n : v5x5){
508 auto itdet =
find(selectedEEDetIds.begin(),selectedEEDetIds.end(),ed);
509 if( itdet == selectedEEDetIds.end()){
510 selectedEEDetIds.push_back(ed);
511 selEERecHitCollection->push_back(
n);
518 for(
int ind : indIsoClus){
519 auto it =
find(indCandClus.begin(),indCandClus.end(), ind);
520 if( it != indCandClus.end())
continue;
522 auto it_bc3 = clusterCollection_ee->begin() + ind;
523 DetId seedId = it_bc3->seed();
524 std::vector<DetId> clus_v5x5 = topology_ee->
getWindow(seedId,5,5);
525 for( std::vector<DetId>::const_iterator idItr = clus_v5x5.begin(); idItr != clus_v5x5.end(); idItr++){
527 auto rit = hitCollection_ee->
find( ed );
528 if ( rit == hitCollection_ee->
end() )
continue;
529 if( ! checkStatusOfEcalRecHit(channelStatus, *rit) )
continue;
530 auto itdet =
find(selectedEEDetIds.begin(),selectedEEDetIds.end(),ed);
531 if( itdet == selectedEEDetIds.end()){
532 selectedEEDetIds.push_back(ed);
533 selEERecHitCollection->push_back(*rit);
546 LogDebug(
"AlCaEcalResonanceProducer") <<
" endcap_output_size run "<<iEvent.
id().
run()<<
"_"<<iEvent.
id().
event()<<
" nEESaved "<<selEERecHitCollection->size()<<
" nESSaved: " << selESRecHitCollection->size();
550 int ee_collsize = selEERecHitCollection->size();
552 if( eb_collsize < 2 && ee_collsize <2)
557 iEvent.
put(
std::move(selEBRecHitCollection), BarrelHits_);
560 iEvent.
put(
std::move(selEERecHitCollection), EndcapHits_);
577 map<
int, vector<EcalRecHit> > &RecHits5x5_clus,
578 vector<int> &indCandClus,
579 vector<int> &indIsoClus,
580 vector<int> &indClusSelected
584 vector<int> indClusPi0Candidates;
585 if( detector ==
EcalBarrel && removePi0CandidatesForEta_){
586 for(
auto it_bc = clusterCollection->begin(); it_bc != clusterCollection->end();it_bc++){
587 for(
auto it_bc2 = it_bc + 1 ; it_bc2 != clusterCollection->end();it_bc2++){
588 float m_pair,pt_pair,eta_pair, phi_pair;
589 calcPaircluster(*it_bc,*it_bc2, m_pair, pt_pair,eta_pair,phi_pair);
590 if(m_pair > massLowPi0Cand_ && m_pair < massHighPi0Cand_){
591 int indtmp[2]={
int( it_bc - clusterCollection->begin()),
int( it_bc2 - clusterCollection->begin())};
592 for(
int &
k : indtmp){
593 auto it =
find(indClusPi0Candidates.begin(),indClusPi0Candidates.end(),
k);
594 if( it == indClusPi0Candidates.end()) indClusPi0Candidates.push_back(
k);
602 double m_minCut = seleMinvMinBarrel_;
603 double m_maxCut = seleMinvMaxBarrel_;
606 double ptminforIso = ptMinForIsolation_;
607 double isoBeltdrCut = seleBeltDR_ ;
608 double isoBeltdetaCut = seleBeltDeta_;
611 double s9s25Cut = seleS9S25Gamma_;
612 bool store5x5 = store5x5RecHitEB_;
619 m_minCut = seleMinvMinEndCap_;
620 m_maxCut = seleMinvMaxEndCap_;
623 ptminforIso = ptMinForIsolationEndCap_;
624 isoBeltdrCut = seleBeltDREndCap_;
625 isoBeltdetaCut = seleBeltDetaEndCap_;
628 s9s25Cut = seleS9S25GammaEndCap_ ;
629 store5x5 = store5x5RecHitEE_;
635 map<int,bool> passShowerShape_clus;
637 for(
auto it_bc = clusterCollection->begin(); it_bc != clusterCollection->end();it_bc++){
639 if( detector ==
EcalBarrel && removePi0CandidatesForEta_){
640 auto it =
find(indClusPi0Candidates.begin(),indClusPi0Candidates.end(),
int(it_bc - clusterCollection->begin()) );
641 if( it != indClusPi0Candidates.end())
continue;
644 float en1 = it_bc->energy();
646 v1 *= (en1 / v1.R());
647 float pt1 = v1.Rho();
649 int ind1 =
int( it_bc - clusterCollection->begin() );
650 auto itmap = passShowerShape_clus.find(ind1);
651 if( itmap != passShowerShape_clus.end()){
652 if( itmap->second ==
false){
657 for(
auto it_bc2 = it_bc + 1 ; it_bc2 != clusterCollection->end();it_bc2++){
658 if( detector ==
EcalBarrel && removePi0CandidatesForEta_){
659 auto it =
find(indClusPi0Candidates.begin(),indClusPi0Candidates.end(),
int(it_bc2 - clusterCollection->begin()) );
660 if( it != indClusPi0Candidates.end())
continue;
663 float en2 = it_bc2 ->energy();
665 v2 *= (en2 / v2.R());
666 float pt2 = v2.Rho();
668 int ind2 =
int( it_bc2 - clusterCollection->begin() );
669 auto itmap = passShowerShape_clus.find(ind2);
670 if( itmap != passShowerShape_clus.end()){
671 if( itmap->second ==
false){
676 float m_pair,pt_pair,eta_pair, phi_pair;
677 calcPaircluster(*it_bc,*it_bc2, m_pair, pt_pair,eta_pair,phi_pair);
681 float etapair = fabs(eta_pair);
688 if(etapair <= region1_Barrel_){
689 if(ptmin < selePtGammaBarrel_region1_ || pt_pair < selePtPairBarrel_region1_)
continue;
693 if(ptmin < selePtGammaBarrel_region2_ || pt_pair < selePtPairBarrel_region2_)
continue;
698 if(etapair <= region1_EndCap_){
699 if(ptmin < selePtGammaEndCap_region1_ || pt_pair < selePtPairEndCap_region1_)
continue;
702 else if( etapair <= region2_EndCap_){
703 if(ptmin < selePtGammaEndCap_region2_ || pt_pair < selePtPairEndCap_region2_)
continue;
707 if(ptmin < selePtGammaEndCap_region3_ || pt_pair < selePtPairEndCap_region3_)
continue;
708 if(pt_pair > selePtPairMaxEndCap_region3_ )
continue;
713 if( m_pair < m_minCut || m_pair > m_maxCut)
continue;
717 IsoClus.push_back(ind1);
718 IsoClus.push_back(ind2);
721 for(
auto it_bc3 = clusterCollection->begin(); it_bc3 != clusterCollection->end();it_bc3++){
722 if( it_bc3->seed() == it_bc->seed() || it_bc3->seed() == it_bc2->seed())
continue;
723 float drcl = std::hypot(eta_pair - it_bc3->eta(),
deltaPhi(phi_pair, it_bc3->phi()));
724 float dretacl = fabs( eta_pair - it_bc3->eta());
725 if( drcl > isoBeltdrCut || dretacl > isoBeltdetaCut )
continue;
726 float pt3 = it_bc3->energy()*
sin(it_bc3->position().theta()) ;
727 if( pt3 < ptminforIso)
continue;
729 int ind3 =
int(it_bc3 - clusterCollection->begin());
730 IsoClus.push_back( ind3);
737 uint32_t Nxtal_pho1 = it_bc->size();
738 uint32_t Nxtal_pho2 = it_bc2->size();
743 if(etapair <= region1_Barrel_){
744 if(Nxtal_pho1 < seleNxtalBarrel_region1_ || Nxtal_pho2 < seleNxtalBarrel_region1_)
continue;
748 if(Nxtal_pho1 < seleNxtalBarrel_region2_ || Nxtal_pho2 < seleNxtalBarrel_region2_)
continue;
754 if(etapair <= region1_EndCap_){
755 if(Nxtal_pho1 < seleNxtalEndCap_region1_ || Nxtal_pho2 < seleNxtalEndCap_region1_)
continue;
758 else if( etapair <= region2_EndCap_){
759 if(Nxtal_pho1 < seleNxtalEndCap_region2_ || Nxtal_pho2 < seleNxtalEndCap_region2_)
continue;
763 if(Nxtal_pho1 < seleNxtalEndCap_region3_ || Nxtal_pho2 < seleNxtalEndCap_region3_)
continue;
770 float iso_val = Iso/pt_pair;
774 if(etapair <= region1_Barrel_){
775 if(iso_val > seleIsoBarrel_region1_ )
continue;
779 if(iso_val > seleIsoBarrel_region2_ )
continue;
785 if(etapair <= region1_EndCap_){
786 if(iso_val > seleIsoEndCap_region1_ )
continue;
789 else if( etapair <= region2_EndCap_){
790 if(iso_val > seleIsoEndCap_region2_ )
continue;
794 if(iso_val > seleIsoEndCap_region3_ )
continue;
805 bool failShowerShape =
false;
806 for(
int n=0;
n<2;
n++){
807 int ind = IsoClus[
n];
808 auto it_bc3 = clusterCollection->begin() + ind;
809 auto itmap = passShowerShape_clus.find(ind);
811 if( itmap != passShowerShape_clus.end()){
812 if( itmap->second ==
false){
813 failShowerShape =
true;
818 vector<EcalRecHit> RecHitsCluster_5x5;
822 calcShowerShape(*it_bc3, channelStatus,hitCollection, topology_p,store5x5, RecHitsCluster_5x5, res);
823 float s4s9 = res[1] >0 ? res[0]/ res[1] : -1;
824 float s9s25 = res[2] >0 ? res[1] / res[2] : -1;
831 if(etapair <= region1_Barrel_){
832 passed = s4s9 > seleS4S9GammaBarrel_region1_;
836 passed = s4s9 > seleS4S9GammaBarrel_region2_;
842 if( etapair <= region1_EndCap_){
843 passed = s4s9 > seleS4S9GammaEndCap_region1_;
846 else if( etapair <= region2_EndCap_){
847 passed = s4s9 > seleS4S9GammaEndCap_region2_;
851 passed = s4s9 > seleS4S9GammaEndCap_region3_;
856 passed = passed && (s9s25 > s9s25Cut);
857 passShowerShape_clus.insert(pair<int, bool>(ind, passed));
860 failShowerShape =
true;
864 RecHits5x5_clus.insert(pair<
int, vector<EcalRecHit> >(ind,RecHitsCluster_5x5) );
869 if( failShowerShape ==
true)
continue;
873 for(
unsigned int iii=0 ; iii<IsoClus.size() ; iii++){
874 int ind = IsoClus[iii];
877 auto it =
find(indCandClus.begin(),indCandClus.end(), ind);
878 if( it == indCandClus.end()) indCandClus.push_back(ind);
882 auto it =
find(indIsoClus.begin(),indIsoClus.end(), ind);
883 if( it == indIsoClus.end()) indIsoClus.push_back(ind);
887 auto it =
find(indClusSelected.begin(),indClusSelected.end(),ind);
888 if( it != indClusSelected.end())
continue;
889 indClusSelected.push_back(ind);
907 if(neta > 0) neta -= 1;
908 if(nphi > 359) nphi=nphi-360;
911 if(nphi >359 || nphi <0 || neta< -85 || neta > 84)
913 LogError(
"") <<
" unexpected fatal error in HLTEcalResonanceFilter::convxtalid "<< nphi <<
" " << neta <<
" " <<std::endl;
934 if(nphi1>nphi2) mdiff=-mdiff;
943 const std::vector< std::pair<DetId, float> > &
vid = bc.hitsAndFractions();
951 DetId seedId = bc.seed();
953 bool InBarrel =
true;
958 convxtalid(seedy,seedx);
971 std::vector<DetId> clus_v5x5;
972 clus_v5x5 = topology_p->
getWindow(seedId,5,5);
974 for( std::vector<DetId>::const_iterator idItr = clus_v5x5.begin(); idItr != clus_v5x5.end(); idItr++){
976 if( InBarrel ==
true){
981 dx = diff_neta_s(x,seedx);
982 dy = diff_nphi_s(y,seedy);
990 auto rit = recHits->
find( ed );
991 if ( rit == recHits->
end() )
continue;
992 if( ! checkStatusOfEcalRecHit(channelStatus, *rit) )
continue;
994 float energy = (*rit).energy();
997 auto idItrF =
std::find( vid.begin(),vid.end(), std::make_pair(ed,1.0
f));
998 if( idItrF == vid.end()){
999 rechit5x5.push_back(*rit);
1002 if(dx <= 0 && dy <=0) e2x2[0] += energy;
1003 if(dx >= 0 && dy <=0) e2x2[1] += energy;
1004 if(dx <= 0 && dy >=0) e2x2[2] += energy;
1005 if(dx >= 0 && dy >=0) e2x2[3] += energy;
1014 for (
auto const & idItr : vid){
1015 DetId ed = idItr.first;
1016 if( InBarrel ==
true){
1021 dx = diff_neta_s(x,seedx);
1022 dy = diff_nphi_s(y,seedy);
1030 auto rit = recHits->
find( ed );
1031 if ( rit == recHits->
end() ) {
1035 float energy = (*rit).energy();
1037 if(dx <= 0 && dy <=0) e2x2[0] += energy;
1038 if(dx >= 0 && dy <=0) e2x2[1] += energy;
1039 if(dx <= 0 && dy >=0) e2x2[2] += energy;
1040 if(dx >= 0 && dy >=0) e2x2[3] += energy;
1051 res[0] = *max_element( e2x2,e2x2+4);
1069 float en1 = bc1.energy();
1077 float energysum = bc2.energy();
1078 scaleFactor = energysum / vsum.R();
1086 m_pair =
sqrt( energysum * energysum - vsum.Mag2());
1087 pt_pair = vsum.Rho();
1088 eta_pair = vsum.Eta();
1089 phi_pair = vsum.Phi();
1102 if( flagLevelRecHitsToUse_ ==0){
1103 if( flag != 0)
return false;
1105 else if( flagLevelRecHitsToUse_ ==1){
1106 if( flag !=0 && flag != 4 )
return false;
1108 else if( flagLevelRecHitsToUse_ ==2){
1109 if( flag !=0 && flag != 4 && flag != 6 && flag != 7)
return false;
1114 if ( status > statusLevelRecHitsToUse_ )
return false;
1134 for (
int i2=0; i2<preshNclust_; i2++) {
1135 reco::PreshowerCluster cl1 = presh_algo_->makeOneCluster(strip1,&m_used_strips,&m_esrechit_map,geometry_es,topology_es);
1136 reco::PreshowerCluster cl2 = presh_algo_->makeOneCluster(strip2,&m_used_strips,&m_esrechit_map,geometry_es,topology_es);
~HLTRegionalEcalResonanceFilter() override
T getParameter(std::string const &) const
const CaloSubdetectorGeometry * getSubdetectorGeometry(const DetId &id) const
access the subdetector geometry for the given subdetector directly
EventNumber_t event() const
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
int diff_neta_s(int, int)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
bool checkStatusOfEcalRecHit(const EcalChannelStatus &channelStatus, const EcalRecHit &rh)
Sin< T >::type sin(const T &t)
bool filter(edm::Event &, const edm::EventSetup &) override
constexpr uint32_t rawId() const
get the raw id
std::vector< EcalRecHit >::const_iterator const_iterator
void makeClusterES(float x, float y, float z, const CaloSubdetectorGeometry *iSubGeom, const CaloSubdetectorTopology *topology_p)
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
void convxtalid(int &, int &)
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
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
#define DEFINE_FWK_MODULE(type)
void calcPaircluster(const reco::BasicCluster &bc1, const reco::BasicCluster &bc2, float &mpair, float &ptpair, float &etapair, float &phipair)
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum) ...
Abs< T >::type abs(const T &t)
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
ParameterDescriptionBase * add(U const &iLabel, T const &value)
const_iterator end() const
int diff_nphi_s(int, int)
virtual std::vector< DetId > getWindow(const DetId &id, const int &northSouthSize, const int &eastWestSize) const
DetId id() const
get the id
T const * product() const
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Flags recoFlag() const
DEPRECATED provided for temporary backward compatibility.
void add(std::string const &label, ParameterSetDescription const &psetDescription)
const CaloSubdetectorTopology * getSubdetectorTopology(const DetId &id) const
access the subdetector Topology for the given subdetector directly
std::vector< BasicCluster > BasicClusterCollection
collection of BasicCluster objects
iterator find(key_type k)
*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
const_iterator begin() const