CMS 3D CMS Logo

ZeeCandidateFilter.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: ZeeCandidateFilter
4 // Class: ZeeCandidateFilter
5 //
54 #ifndef ZeeCandidateFilter_H
55 #define ZeeCandidateFilter_H
56 
57 // System include files
58 #include <memory>
59 
60 // User include files
63 
66 
68 
69 #include <vector>
70 #include <iostream>
76 
77 #include "TString.h"
78 #include "TMath.h"
82 
83 // For conversion finder
89 //
92 //#include "RecoLocalCalo/EcalRecAlgos/interface/EcalSeverityLevelAlgo.h"
96 
97 
98 // Class Declaration
99 // -----------------
100 //
102 
103 public:
104 
105  explicit ZeeCandidateFilter(const edm::ParameterSet&);
106 
107  ~ZeeCandidateFilter() override;
108 
109 private:
110 
111  Bool_t filter(edm::Event&, const edm::EventSetup&) override;
112 
113  void endJob() override ;
114 
115  Bool_t isInFiducial(Double_t eta);
116 
117  //Bool_t passEleIDCuts(pat::Electron *ele);
118 
119  // ----- Data Members -----
120 
121  Double_t ETCut_ ;
122  Double_t METCut_ ;
123 
125 
126  /* Electron 1 */
134 
135  /* Electron 2 */
143 
144  /* Electron 1 */
145  Double_t dist1_ ;
146  Double_t dcot1_ ;
147 
148  /* Electron 2 */
149  Double_t dist2_ ;
150  Double_t dcot2_ ;
151 
153 
157 
158  Double_t BarrelMaxEta_ ;
159  Double_t EndCapMaxEta_ ;
160  Double_t EndCapMinEta_ ;
161 
168 
169  Double_t hltObjectETCut_ ;
170 
172 
173  std::vector<std::string> vHltpathExtra_ ;
174  std::vector<edm::InputTag> vHltpathFilterExtra_ ;
175 
179 
182 
186 
188 
191 
193 
195 
196 };
197 
198 #endif
199 
200 // Constants, Enums and Typedefs
201 // -----------------------------
202 //
203 
204 // Static Data Member Definitions
205 // ------------------------------
206 //
207 
208 // Constructors and Destructor
209 // ---------------------------
210 //
212 {
213  //
214  //-------------------------------------//
215  // INITIALIZATION //
216  //-------------------------------------//
217  //
218 
219 
220  // Cuts
221  // ----
222  ETCut_ = iConfig.getUntrackedParameter<Double_t>("ETCut");
223  METCut_ = iConfig.getUntrackedParameter<Double_t>("METCut");
224 
225  useEcalDrivenElectrons_ = iConfig.getUntrackedParameter<Bool_t>("useEcalDrivenElectrons", false);
226  //--------------------------------------------------------------------------------------------------------------------
227 
228 
229  // Preselection Criteria: Hit Pattern
230  // ----------------------------------
231  //
232  /* Electron 1 */
233  useValidFirstPXBHit1_ = iConfig.getUntrackedParameter<Bool_t>("useValidFirstPXBHit1",false);
234  calculateValidFirstPXBHit1_ = iConfig.getUntrackedParameter<Bool_t>("calculateValidFirstPXBHit1",false);
235  useConversionRejection1_ = iConfig.getUntrackedParameter<Bool_t>("useConversionRejection1",false);
236  calculateConversionRejection1_ = iConfig.getUntrackedParameter<Bool_t>("calculateConversionRejection1",false);
237  useExpectedMissingHits1_ = iConfig.getUntrackedParameter<Bool_t>("useExpectedMissingHits1",false);
238  calculateExpectedMissingHits1_ = iConfig.getUntrackedParameter<Bool_t>("calculateExpectedMissingHits1",false);
239  maxNumberOfExpectedMissingHits1_ = iConfig.getUntrackedParameter<Int_t>("maxNumberOfExpectedMissingHits1",1);
240  //
241  /* Electron 2 */
242  useValidFirstPXBHit2_ = iConfig.getUntrackedParameter<Bool_t>("useValidFirstPXBHit2",false);
243  calculateValidFirstPXBHit2_ = iConfig.getUntrackedParameter<Bool_t>("calculateValidFirstPXBHit2",false);
244  useConversionRejection2_ = iConfig.getUntrackedParameter<Bool_t>("useConversionRejection2",false);
245  calculateConversionRejection2_ = iConfig.getUntrackedParameter<Bool_t>("calculateConversionRejection2",false);
246  useExpectedMissingHits2_ = iConfig.getUntrackedParameter<Bool_t>("useExpectedMissingHits2",false);
247  calculateExpectedMissingHits2_ = iConfig.getUntrackedParameter<Bool_t>("calculateExpectedMissingHits2",false);
248  maxNumberOfExpectedMissingHits2_ = iConfig.getUntrackedParameter<Int_t>("maxNumberOfExpectedMissingHits2",1);
249  //--------------------------------------------------------------------------------------------------------------------
250 
251 
252  // Conversion Rejection Variables
253  // ------------------------------
254  //
255  /* Electron 1 */
256  Double_t dist1_D = 0.02 ;
257  Double_t dcot1_D = 0.02 ;
258  //
259  dist1_ = iConfig.getUntrackedParameter<Double_t>("conversionRejectionDist1", dist1_D);
260  dcot1_ = iConfig.getUntrackedParameter<Double_t>("conversionRejectionDcot1", dcot1_D);
261  //
262  /* Electron 2 */
263  Double_t dist2_D = 0.02 ;
264  Double_t dcot2_D = 0.02 ;
265  //
266  dist2_ = iConfig.getUntrackedParameter<Double_t>("conversionRejectionDist2", dist2_D);
267  dcot2_ = iConfig.getUntrackedParameter<Double_t>("conversionRejectionDcot2", dcot2_D);
268  //--------------------------------------------------------------------------------------------------------------------
269 
270 
271  // Magnetic Field
272  // --------------
273  //
274  dataMagneticFieldSetUp_ = iConfig.getUntrackedParameter<Bool_t>("dataMagneticFieldSetUp",false);
275 
276  if ( dataMagneticFieldSetUp_ ) {
277  dcsTag_ = iConfig.getUntrackedParameter<edm::InputTag>("dcsTag");
278  dcsToken_ = mayConsume<DcsStatusCollection>(dcsTag_);
279  }
280  tracksToken_ = mayConsume<reco::TrackCollection>(edm::InputTag("generalTracks"));
281  //--------------------------------------------------------------------------------------------------------------------
282 
283 
284  // Detector Fiducial Cuts
285  // ----------------------
286  //
287  Double_t BarrelMaxEta_D = 1.4442 ;
288  Double_t EndCapMinEta_D = 1.5660 ;
289  Double_t EndCapMaxEta_D = 2.5000 ;
290 
291  BarrelMaxEta_ = iConfig.getUntrackedParameter<Double_t>("BarrelMaxEta", BarrelMaxEta_D);
292  EndCapMaxEta_ = iConfig.getUntrackedParameter<Double_t>("EndCapMaxEta", EndCapMaxEta_D);
293  EndCapMinEta_ = iConfig.getUntrackedParameter<Double_t>("EndCapMinEta", EndCapMinEta_D);
294  //--------------------------------------------------------------------------------------------------------------------
295 
296 
297  // Trigger Related
298  // ---------------
299  //
300  hltpath_ = iConfig.getUntrackedParameter<std::string>("hltpath");
301  triggerCollectionTag_ = iConfig.getUntrackedParameter<edm::InputTag>("triggerCollectionTag");
302  triggerCollectionToken_ = consumes<edm::TriggerResults>(triggerCollectionTag_);
303  triggerEventToken_ = consumes<trigger::TriggerEvent>(iConfig.getUntrackedParameter<edm::InputTag>("triggerEventTag"));
304  hltpathFilter_ = iConfig.getUntrackedParameter<edm::InputTag>("hltpathFilter");
305  useHLTObjectETCut_ = iConfig.getUntrackedParameter<Bool_t>("useHLTObjectETCut", false);
306 
307  if ( useHLTObjectETCut_ ) {
308  hltObjectETCut_ = iConfig.getUntrackedParameter<Double_t>("hltObjectETCut");
309  }
310 
311  // Dirty way to add a second trigger with OR, to be done properly in the next tag
312  useExtraTrigger_ = iConfig.getUntrackedParameter<Bool_t>("useExtraTrigger");
313 
314  if ( useExtraTrigger_ ) {
315 
316  vHltpathExtra_ = iConfig.getUntrackedParameter< std::vector<std::string> >("vHltpathExtra");
317  vHltpathFilterExtra_ = iConfig.getUntrackedParameter< std::vector<edm::InputTag> >("vHltpathFilterExtra");
318 
319  if ( Int_t(vHltpathExtra_.size()) != Int_t(vHltpathFilterExtra_.size()) ) {
320  std::cout << "ZeeCandidateFilter: ERROR IN Configuration: vHltpathExtra and vHltpathFilterExtra" << " should have the same dimensions " << std::endl;
321  }
322  }
323  //--------------------------------------------------------------------------------------------------------------------
324 
325 
326  // Trigger Matching Related
327  // ------------------------
328  //
329  useTriggerInfo_ = iConfig.getUntrackedParameter<Bool_t>("useTriggerInfo",true);
330  electronMatched2HLT_ = iConfig.getUntrackedParameter<Bool_t>("electronMatched2HLT");
331  electronMatched2HLT_DR_ = iConfig.getUntrackedParameter<Double_t>("electronMatched2HLT_DR");
332  //--------------------------------------------------------------------------------------------------------------------
333 
334 
335  // Electrons, MET's Vtx's and other
336  // --------------------------------
337  //
338  electronCollectionTag_ = iConfig.getUntrackedParameter<edm::InputTag>("electronCollectionTag");
339  electronCollectionToken_ = consumes<pat::ElectronCollection>(electronCollectionTag_);
340 
341  metCollectionToken_ = consumes<pat::METCollection>(iConfig.getUntrackedParameter<edm::InputTag>("metCollectionTag"));
342  pfMetCollectionToken_ = consumes<pat::METCollection>(iConfig.getUntrackedParameter<edm::InputTag>("pfMetCollectionTag"));
343  tcMetCollectionToken_ = consumes<pat::METCollection>(iConfig.getUntrackedParameter<edm::InputTag>("tcMetCollectionTag"));
344 
345  PrimaryVerticesCollectionToken_ = consumes< std::vector<reco::Vertex> >(iConfig.getUntrackedParameter<edm::InputTag>("PrimaryVerticesCollection"));
346 
347  ebRecHitsToken_ = mayConsume<EcalRecHitCollection>(iConfig.getUntrackedParameter<edm::InputTag>("ebRecHits"));
348  eeRecHitsToken_ = mayConsume<EcalRecHitCollection>(iConfig.getUntrackedParameter<edm::InputTag>("eeRecHits"));
349  //--------------------------------------------------------------------------------------------------------------------
350 
351 
352  // Spike Cleaning
353  // --------------
354  //
355  useSpikeRejection_ = iConfig.getUntrackedParameter<Bool_t>("useSpikeRejection");
356 
357  if ( useSpikeRejection_ ) {
358  spikeCleaningSwissCrossCut_ = iConfig.getUntrackedParameter<Double_t>("spikeCleaningSwissCrossCut");
359  }
360  //--------------------------------------------------------------------------------------------------------------------
361 
362 
363  //
364  //-------------------------------------//
365  // SUMMARY PRINTOUT //
366  //-------------------------------------//
367  //
368 
369  std::cout << "ZeeCandidateFilter: Running Zee Filter..." << std::endl;
370 
371  if ( useTriggerInfo_ ) {
372  std::cout << "ZeeCandidateFilter: HLT Path " << hltpath_ << std::endl;
373  std::cout << "ZeeCandidateFilter: HLT Filter " << hltpathFilter_ << std::endl;
374 
375  if ( useExtraTrigger_ ) {
376  for (Int_t itrig=0; itrig < (Int_t)vHltpathExtra_.size(); ++itrig ) {
377 
378  std::cout << "ZeeCandidateFilter: OR " << vHltpathExtra_[itrig] << " with filter: " << vHltpathFilterExtra_[itrig] << std::endl;
379  }
380  }
381  }
382  else {
383  std::cout << "ZeeCandidateFilter: Trigger info will not be used here" << std::endl;
384  }
385 
386  std::cout << "ZeeCandidateFilter: ET > " << ETCut_ << std::endl;
387  std::cout << "ZeeCandidateFilter: MET > " << METCut_ << std::endl;
388 
389 
390  if ( useEcalDrivenElectrons_ ) {
391  std::cout << "ZeeCandidateFilter: Electron Candidate(s) is required to be ecal driven" << std::endl;
392  }
393 
394  if ( electronMatched2HLT_ && useTriggerInfo_ ) {
395  std::cout << "ZeeCandidateFilter: At least one electron is required to match an HLT object with DR < " << electronMatched2HLT_DR_ << std::endl;
396  }
397  else {
398  std::cout << "ZeeCandidateFilter: Electron Candidates NOT required to match HLT object " << std::endl;
399  }
400 
401  if ( useValidFirstPXBHit1_ ) {
402  std::cout << "ZeeCandidateFilter: Electron Candidate #1 required to have a valid hit in 1st PXB layer " << std::endl;
403  }
404 
405  if ( useValidFirstPXBHit2_ ) {
406  std::cout << "ZeeCandidateFilter: Electron Candidate #2 required to have a valid hit in 1st PXB layer " << std::endl;
407  }
408 
409  if ( calculateValidFirstPXBHit1_ ) {
410  std::cout << "ZeeCandidateFilter: Info about whether there is a valid 1st layer PXB hit for electron candidate #1 will be stored: you can access that later by myElec.userInt(\"PassValidFirstPXBHit\")==1" << std::endl;
411  }
412 
413  if ( calculateValidFirstPXBHit2_ ) {
414  std::cout << "ZeeCandidateFilter: Info about whether there is a valid 1st layer PXB hit for electron candidate #2 will be stored: you can access that later by myElec.userInt(\"PassValidFirstPXBHit\")==1" << std::endl;
415  }
416 
417  if ( useExpectedMissingHits1_ ) {
418  std::cout << "ZeeCandidateFilter: Electron Candidate #1 is required to have less than " << maxNumberOfExpectedMissingHits1_ << " expected hits missing " << std::endl;
419  }
420 
421  if ( useExpectedMissingHits2_ ) {
422  std::cout << "ZeeCandidateFilter: Electron Candidate #2 is required to have less than " << maxNumberOfExpectedMissingHits2_ << " expected hits missing " << std::endl;
423  }
424 
425  if ( calculateExpectedMissingHits1_ ) {
426  std::cout << "ZeeCandidateFilter: Missing Hits from expected inner layers for electron candidate #1 will be calculated and stored: you can access them later by myElec.userInt(\"NumberOfExpectedMissingHits\")" << std::endl;
427  }
428 
429  if ( calculateExpectedMissingHits2_ ) {
430  std::cout << "ZeeCandidateFilter: Missing Hits from expected inner layers for electron candidate #2 will be calculated and stored: you can access them later by myElec.userInt(\"NumberOfExpectedMissingHits\")" << std::endl;
431  }
432 
433  if ( useConversionRejection1_ ) {
434  std::cout << "ZeeCandidateFilter: Electron Candidate #1 is required to pass EGAMMA Conversion Rejection criteria" << std::endl;
435  }
436 
437  if ( useConversionRejection2_ ) {
438  std::cout << "ZeeCandidateFilter: Electron Candidate #2 is required to pass EGAMMA Conversion Rejection criteria" << std::endl;
439  }
440 
441  if ( calculateConversionRejection1_ ) {
442  std::cout << "ZeeCandidateFilter: EGAMMA Conversion Rejection criteria for electron candidate #1 will be calculated and stored: you can access them later by demanding for a successful electron myElec.userInt(\"PassConversionRejection\")==1" << std::endl;
443  }
444 
445  if ( calculateConversionRejection2_ ) {
446  std::cout << "ZeeCandidateFilter: EGAMMA Conversion Rejection criteria for electron candidate #2 will be calculated and stored: you can access them later by demanding for a successful electron myElec.userInt(\"PassConversionRejection\")==1" << std::endl;
447  }
448 
449  if ( dataMagneticFieldSetUp_ ) {
450  std::cout << "ZeeCandidateFilter: Data Configuration for Magnetic Field DCS tag " << dcsTag_ << std::endl;
451  }
452 
453  if ( useSpikeRejection_ ) {
454  std::cout << "ZeeCandidateFilter: Spike Cleaning will be done with the Swiss Cross Criterion cutting at " << spikeCleaningSwissCrossCut_ << std::endl;
455  }
456 
457  std::cout << "ZeeCandidateFilter: Fiducial Cut: " << std::endl;
458  std::cout << "ZeeCandidateFilter: BarrelMax: " << BarrelMaxEta_ << std::endl;
459  std::cout << "ZeeCandidateFilter: EndcapMin: " << EndCapMinEta_ << " EndcapMax: " << EndCapMaxEta_ << std::endl;
460 
461  //
462  //------------------------------------------//
463  // EXTRA INFO IN THE EVENT //
464  //------------------------------------------//
465  //
466  produces<pat::CompositeCandidateCollection>("selectedZeeCandidates").setBranchAlias("selectedZeeCandidates");
467 
468 }
469 
470 
472 {
473  // do anything here that needs to be done at desctruction time
474  // (e.g. close files, deallocate resources etc.)
475 }
476 
477 
478 // Member Functions
479 // ----------------
480 //
481 
482 // ------------ method called on each new Event ------------
484 {
485  using namespace edm;
486  using namespace std;
487  using namespace pat;
488 
489 
490  std::cout << "FILTER-MSG: Begin Processing ... "
491  << "Run = " << iEvent.run() << " "
492  << "Lumi = " << (Int_t) iEvent.luminosityBlock() << " "
493  << "Event = " << iEvent.eventAuxiliary().event() << " "
494  << std::endl;
495 
496 
497  /*** TRIGGER REQUIREMENT - Event should pass the trigger, otherwise no zee candidate ***/
498 
500  iEvent.getByToken(triggerCollectionToken_, HLTResults);
501 
502  Int_t passTrigger = 0;
503 
504  if ( HLTResults.isValid() ) {
505 
506  const edm::TriggerNames & triggerNames = iEvent.triggerNames(*HLTResults);
507 
508  UInt_t trigger_size = HLTResults->size();
509  UInt_t trigger_position = triggerNames.triggerIndex(hltpath_);
510  UInt_t trigger_position_extra;
511 
512  if ( trigger_position < trigger_size ) {
513  passTrigger = (Int_t)HLTResults->accept(trigger_position);
514  }
515 
516  // Tested TriggerPath firing results printout
517  std::cout << "SK_HLT_INFO"
518  << " | " << "trigger_size = " << trigger_size
519  << " | " << "hltpath_ = " << hltpath_
520  << " | " << "trigger_position = " << trigger_position
521  << " | " << "passTrigger = " << passTrigger
522  << std::endl;
523 
524  if ( useExtraTrigger_ && passTrigger==0 ) {
525  for (Int_t itrig=0; itrig < (Int_t)vHltpathExtra_.size(); ++itrig ) {
526  trigger_position_extra = triggerNames.triggerIndex(vHltpathExtra_[itrig]);
527 
528  if ( trigger_position_extra < trigger_size ) {
529  passTrigger = (Int_t)HLTResults->accept(trigger_position_extra);
530  }
531 
532  // Tested TriggerPath firing results printout
533  std::cout << "SK_HLT_INFO"
534  << " | " << "vHltpathExtra_[" << itrig << "] = " << vHltpathExtra_[itrig]
535  << " | " << "trigger_position_extra = " << trigger_position_extra
536  << " | " << "passTrigger = " << passTrigger
537  << " | " << "vHltpathExtra_.size() = " << vHltpathExtra_.size()
538  << std::endl;
539 
540  if ( passTrigger > 0 ) { break ; }
541 
542  } // for Loop
543 
544  } // if ( useExtraTrigger_ && passTrigger==0 )
545 
546  }
547  else { std::cout << "TriggerResults are missing from this event.." << std::endl;
548  if ( useTriggerInfo_ ) {
549  return false; // RETURN if trigger is missing
550  }
551  }
552 
553  if ( passTrigger == 0 && useTriggerInfo_ ) { std::cout << "No HLT Path is firing in this event" << std::endl;
554  return false; // RETURN if event fails the trigger
555  }
556 
557 
559  iEvent.getByToken(triggerEventToken_, pHLT);
560 
561  const Int_t nF(pHLT->sizeFilters());
562  const Int_t filterInd = pHLT->filterIndex(hltpathFilter_);
563 
564  std::vector<Int_t> filterIndExtra;
565 
566  if ( useExtraTrigger_ ) {
567  for (Int_t itrig =0; itrig < (Int_t)vHltpathFilterExtra_.size(); ++itrig ) { std::cout << "working on #" << itrig << std::endl; std::cout << " ---> " << vHltpathFilterExtra_[itrig] << std::endl;
568  filterIndExtra.push_back( pHLT->filterIndex(vHltpathFilterExtra_[itrig]) );
569  }
570  }
571 
572  Bool_t finalpathfound = false;
573 
574  if ( nF != filterInd ) {
575  finalpathfound = true;
576  }
577  else {
578  for (Int_t itrig=0; itrig < (Int_t)filterIndExtra.size(); ++itrig ) { std::cout << "working on #" << itrig << std::endl; std::cout << " ---> " << filterIndExtra[itrig] << std::endl;
579  if ( nF != filterIndExtra[itrig] ) {
580  finalpathfound = true;
581  break;
582  }
583  }
584  }
585 
586  if ( ! finalpathfound ) { std::cout << "No HLT Filter was not found in this event..." << std::endl;
587  if ( useTriggerInfo_ ) {
588  return false; // RETURN if event fails the trigger
589  }
590  }
591 
592  const trigger::TriggerObjectCollection& TOC(pHLT->getObjects());
593 
594  /*** ET CUT: At least one electron in the event with ET > ETCut_ ***/
595 
596  // Electron Collection
598  iEvent.getByToken(electronCollectionToken_, patElectron);
599 
600  if ( ! patElectron.isValid() ) { std::cout << "No electrons found in this event with tag " << electronCollectionTag_ << std::endl;
601  return false; // RETURN if no elecs in the event
602  }
603 
604  const pat::ElectronCollection *pElecs = patElectron.product();
605 
606 // // MET Collection -> relocated block bellow
607 // edm::Handle<pat::METCollection> patMET;
608 // iEvent.getByToken(metCollectionToken_, patMET);
609 //
610 // edm::Handle<pat::METCollection> patpfMET;
611 // iEvent.getByToken(pfMetCollectionToken_, patpfMET);
612 //
613 // edm::Handle<pat::METCollection> pattcMET;
614 // iEvent.getByToken(tcMetCollectionToken_, pattcMET);
615 
616  //
617  // Note: best to do Duplicate removal here, since the current
618  // implementation does not remove triplicates
619  // duplicate removal is on at PAT, but does it remove triplicates?
620  //
621 
622 // pat::ElectronCollection::const_iterator elec; // relocated bellow
623 
624  // check how many electrons there are in the event
625  const Int_t Nelecs = pElecs->size();
626 
627  if ( Nelecs <= 1 ) { std::cout << "No more than 1 electrons found in this event" << std::endl;
628  return false; // RETURN if less than 2 elecs in the event
629  }
630 
631  // Order your electrons: first the ones with the higher ET
632  Int_t counter = 0;
633  std::vector<Int_t> indices;
634  std::vector<Double_t> ETs;
635  pat::ElectronCollection myElectrons;
636 
637  for (pat::ElectronCollection::const_iterator elec = pElecs->begin(); elec != pElecs->end(); ++elec) { // the definition of the electron ET is wrt Gsf track eta
638  Double_t sc_et = elec->caloEnergy()/TMath::CosH(elec->gsfTrack()->eta());
639  indices.push_back(counter);
640  ETs.push_back(sc_et);
641  myElectrons.push_back(*elec);
642  ++counter;
643  }
644 
645  const Int_t event_elec_number = (Int_t)indices.size();
646 
647  if ( event_elec_number <= 1 ) { std::cout << "No more than 1 electrons in fiducial were found" << std::endl;
648  return false; // RETURN if no more than 1 electron in fiducial
649  }
650 
651  // Memory allocation (must be released every time we return back.
652  Int_t *sorted = new Int_t[event_elec_number];
653  Double_t *et = new Double_t[event_elec_number];
654 
655  for (Int_t i=0; i<event_elec_number; ++i ) {
656  et[i] = ETs[i];
657  }
658 
659  // array sorted now has the indices of the highest ET electrons
660  TMath::Sort(event_elec_number, et, sorted, true);
661  //
662  // if the 2 highest electrons in the event has ET < ETCut_ return
663  Int_t max_et_index1 = sorted[0];
664  Int_t max_et_index2 = sorted[1];
665 
666  if ( ( ETs[max_et_index1] < ETCut_ ) || ( ETs[max_et_index2] < ETCut_ ) ) {
667  delete [] sorted;
668  delete [] et;
669  return false; // RETURN: demand the highest ET electrons to have ET > ETcut
670  }
671 
672  // my electrons now:
673  pat::Electron maxETelec1 = myElectrons[max_et_index1];
674  pat::Electron maxETelec2 = myElectrons[max_et_index2];
675 
676  // demand that they are in fiducial:
677  if ( ! isInFiducial(maxETelec1.caloPosition().eta()) ) {
678  delete [] sorted;
679  delete [] et;
680  return false; // RETURN highest ET electron is not in fiducial
681  }
682 
683  if ( ! isInFiducial(maxETelec2.caloPosition().eta()) ) {
684  delete [] sorted;
685  delete [] et;
686  return false; // RETURN 2nd highest ET electron is not in fiducial
687  }
688 
689  // demand that they are ecal driven
690  if ( useEcalDrivenElectrons_ ) {
691  if ( ( ! maxETelec1.ecalDrivenSeed() ) || ( ! maxETelec2.ecalDrivenSeed() ) ) {
692  delete [] sorted;
693  delete [] et;
694  return false; // RETURN At least one high ET electron is not ecal driven
695  }
696  }
697 
698  // spike rejection;
699  if ( useSpikeRejection_ && maxETelec1.isEB() ) {
700 
702 
703 // if ( maxETelec1.isEB() ) {
704 // iEvent.getByToken(ebRecHitsToken_, recHits);
705 // }
706 // else {
707 // iEvent.getByToken(eeRecHitsToken_, recHits);
708 // }
709 
710  iEvent.getByToken(ebRecHitsToken_, recHits);
711 
712  const EcalRecHitCollection *myRecHits = recHits.product();
713  const DetId seedId = maxETelec1.superCluster()->seed()->seed();
714 
715  Double_t swissCross = EcalTools::swissCross(seedId, *myRecHits,0.);
716 
717  if ( swissCross > spikeCleaningSwissCrossCut_ ) {
718  delete [] sorted;
719  delete [] et;
720  return false; // RETURN highest ET electron is a spike
721  }
722  }
723 
724  if ( useSpikeRejection_ && maxETelec2.isEB() ) {
725 
727 
728 // if ( maxETelec2.isEB()) {
729 // iEvent.getByToken(ebRecHitsToken_, recHits);
730 // }
731 // else {
732 // iEvent.getByToken(eeRecHitsToken_, recHits);
733 // }
734 
735  iEvent.getByToken(ebRecHitsToken_, recHits);
736 
737  const EcalRecHitCollection *myRecHits = recHits.product();
738  const DetId seedId = maxETelec2.superCluster()->seed()->seed();
739 
740  Double_t swissCross = EcalTools::swissCross(seedId, *myRecHits,0.);
741 
742  if ( swissCross > spikeCleaningSwissCrossCut_ ) {
743  delete [] sorted;
744  delete [] et;
745  return false; // RETURN 2nd highest ET electron is a spike
746  }
747  }
748 
749  // add the primary vtx information in the electron:
752 
753  const std::vector<reco::Vertex> Vtx = *(pVtx.product());
754 
755  Double_t pv_x = -999999.;
756  Double_t pv_y = -999999.;
757  Double_t pv_z = -999999.;
758 
759  Double_t ele_tip_pv1 = -999999.;
760  Double_t ele_tip_pv2 = -999999.;
761 
762  if ( !Vtx.empty() ) {
763  pv_x = Vtx[0].position().x();
764  pv_y = Vtx[0].position().y();
765  pv_z = Vtx[0].position().z();
766  ele_tip_pv1 = (-1.0) * ( maxETelec1.gsfTrack()->dxy(Vtx[0].position()) ) ;
767  ele_tip_pv2 = (-1.0) * ( maxETelec2.gsfTrack()->dxy(Vtx[0].position()) ) ;
768  }
769 
770  maxETelec1.addUserFloat("pv_x", Float_t(pv_x));
771  maxETelec1.addUserFloat("pv_x", Float_t(pv_y));
772  maxETelec1.addUserFloat("pv_z", Float_t(pv_z));
773  maxETelec1.addUserFloat("ele_tip_pv", Float_t(ele_tip_pv1));
774 
775  maxETelec2.addUserFloat("pv_x", Float_t(pv_x));
776  maxETelec2.addUserFloat("pv_x", Float_t(pv_y));
777  maxETelec2.addUserFloat("pv_z", Float_t(pv_z));
778  maxETelec2.addUserFloat("ele_tip_pv", Float_t(ele_tip_pv2));
779 
780 // Double_t pv_x1 = -999999.;
781 // Double_t pv_y1 = -999999.;
782 // Double_t pv_z1 = -999999.;
783 // Double_t ele_tip_pv1 = -999999.;
784 //
785 // if ( Vtx.size() >=1 ) {
786 // pv_x1 = Vtx[0].position().x();
787 // pv_y1 = Vtx[0].position().y();
788 // pv_z1 = Vtx[0].position().z();
789 // ele_tip_pv1 = (-1.0) * ( maxETelec1.gsfTrack()->dxy(Vtx[0].position()) ) ;
790 // }
791 //
792 // maxETelec1.addUserFloat("pv_x", Float_t(pv_x1));
793 // maxETelec1.addUserFloat("pv_x", Float_t(pv_y1));
794 // maxETelec1.addUserFloat("pv_z", Float_t(pv_z1));
795 // maxETelec1.addUserFloat("ele_tip_pv", Float_t(ele_tip_pv1));
796 //
797 // edm::Handle< std::vector<reco::Vertex> > pVtx2;
798 // iEvent.getByToken(PrimaryVerticesCollectionToken_, pVtx2);
799 //
800 // const std::vector<reco::Vertex> Vtx2 = *(pVtx2.product());
801 //
802 // Double_t pv_x2 = -999999.;
803 // Double_t pv_y2 = -999999.;
804 // Double_t pv_z2 = -999999.;
805 // Double_t ele_tip_pv2 = -999999.;
806 //
807 // if ( Vtx2.size() >=1 ) {
808 // pv_x2 = Vtx2[0].position().x();
809 // pv_y2 = Vtx2[0].position().y();
810 // pv_z2 = Vtx2[0].position().z();
811 // ele_tip_pv2 = -maxETelec2.gsfTrack()->dxy(Vtx2[0].position());
812 // }
813 //
814 // maxETelec2.addUserFloat("pv_x", Float_t(pv_x1));
815 // maxETelec2.addUserFloat("pv_x", Float_t(pv_y1));
816 // maxETelec2.addUserFloat("pv_z", Float_t(pv_z1));
817 // maxETelec2.addUserFloat("ele_tip_pv", Float_t(ele_tip_pv2));
818 
819 
820  // Special pre-selection requirements (hit pattern and conversion rejection)
821 
823 
824  Bool_t fail = !maxETelec1.gsfTrack()->hitPattern().hasValidHitInPixelLayer(PixelSubdetector::SubDetector::PixelBarrel, 1);
825 
826  if ( useValidFirstPXBHit1_ && fail ) { std::cout << "Filter: there is no valid hit for electron #1 in 1st layer PXB" << std::endl;
827  delete [] sorted;
828  delete [] et;
829  return false;
830  }
831 
833 
834  std::string vfpx("PassValidFirstPXBHit");
835 
836  if ( fail ) {
837  maxETelec1.addUserInt(vfpx,0);
838  }
839  else {
840  maxETelec1.addUserInt(vfpx,1);
841  }
842 
843  }
844 
845  }
846 
848 
849  Bool_t fail = !maxETelec2.gsfTrack()->hitPattern().hasValidHitInPixelLayer(PixelSubdetector::SubDetector::PixelBarrel, 1);
850 
851  if ( useValidFirstPXBHit2_ && fail ) { std::cout << "Filter: there is no valid hit for electron #1 in 1st layer PXB" << std::endl;
852  delete [] sorted;
853  delete [] et;
854  return false;
855  }
856 
858 
859  std::string vfpx("PassValidFirstPXBHit");
860 
861  if ( fail ) {
862  maxETelec2.addUserInt(vfpx,0);
863  }
864  else {
865  maxETelec2.addUserInt(vfpx,1);
866  }
867 
868  }
869 
870  }
871 
873 
874  Int_t numberOfInnerHits = (Int_t)( maxETelec1.gsfTrack()->hitPattern().numberOfLostHits(reco::HitPattern::MISSING_INNER_HITS));
875 
876  if ( ( numberOfInnerHits > maxNumberOfExpectedMissingHits1_ ) && useExpectedMissingHits1_ ) {
877  delete [] sorted;
878  delete [] et;
879  return false;
880  }
881 
883  maxETelec1.addUserInt("NumberOfExpectedMissingHits",numberOfInnerHits);
884  }
885 
886  }
887 
889 
890  Int_t numberOfInnerHits = (Int_t)( maxETelec2.gsfTrack()->hitPattern().numberOfLostHits(reco::HitPattern::MISSING_INNER_HITS) );
891 
892  if ( ( numberOfInnerHits > maxNumberOfExpectedMissingHits2_ ) && useExpectedMissingHits2_ ) {
893  delete [] sorted;
894  delete [] et;
895  return false;
896  }
897 
899  maxETelec2.addUserInt("NumberOfExpectedMissingHits",numberOfInnerHits);
900  }
901  }
902 
904  // use of conversion rejection as it is implemented in egamma
905  // you have to get the general track collection to do that
906  // WARNING! you have to supply the correct B-field in Tesla
907  // the magnetic field
908 
909  Double_t bfield;
910 
911  if ( dataMagneticFieldSetUp_ ) {
912 
914  iEvent.getByToken(dcsToken_, dcsHandle);
915  // scale factor = 3.801/18166.0 which are
916  // average values taken over a stable two
917  // week period
918  Double_t currentToBFieldScaleFactor = 2.09237036221512717e-04;
919  Double_t current = (*dcsHandle)[0].magnetCurrent();
920  bfield = current*currentToBFieldScaleFactor;
921 
922  } else {
923 
925  iSetup.get<IdealMagneticFieldRecord>().get(magneticField);
926  const MagneticField *mField = magneticField.product();
927  bfield = mField->inTesla(GlobalPoint(0.0,0.0,0.0)).z();
928 
929  }
930 
932 
933  if ( iEvent.getByToken(tracksToken_, ctfTracks) ) {
934 
935  ConversionInfo convInfo = egammaTools::getConversionInfo(maxETelec1, ctfTracks, bfield);
936 
937  Float_t dist = convInfo.dist;
938  Float_t dcot = convInfo.dcot;
939 
940  Bool_t isConv = ( ( TMath::Abs(dist) < dist1_ ) && ( TMath::Abs(dcot) < dcot1_ ) ) ;
941 
942  std::cout << "Filter: for electron #1 the conversion says " << isConv << std::endl;
943 
944  if ( isConv && useConversionRejection1_ ) {
945  delete [] sorted;
946  delete [] et;
947  return false;
948  }
949 
951 
952  maxETelec1.addUserFloat("Dist", Float_t(dist));
953  maxETelec1.addUserFloat("Dcot", Float_t(dcot));
954 
955  if ( isConv ) {
956  maxETelec1.addUserInt("PassConversionRejection",0);
957  }
958  else {
959  maxETelec1.addUserInt("PassConversionRejection",1);
960  }
961 
962  }
963 
964  }
965  else {
966  std::cout << "WARNING! Track Collection with input name: generalTracks was not found. Conversion Rejection for electron #1 is not going to be applied!!!" << std::endl;
967  }
968 
969  }
970 
972  // use of conversion rejection as it is implemented in egamma
973  // you have to get the general track collection to do that
974  // WARNING! you have to supply the correct B-field in Tesla
975  // the magnetic field
976 
977  Double_t bfield;
978 
979  if ( dataMagneticFieldSetUp_ ) {
980 
982  iEvent.getByToken(dcsToken_, dcsHandle);
983 
984  // scale factor = 3.801/18166.0 which are
985  // average values taken over a stable two
986  // week period
987 
988  Double_t currentToBFieldScaleFactor = 2.09237036221512717e-04;
989  Double_t current = (*dcsHandle)[0].magnetCurrent();
990  bfield = current*currentToBFieldScaleFactor;
991 
992  } else {
993 
995  iSetup.get<IdealMagneticFieldRecord>().get(magneticField);
996  const MagneticField *mField = magneticField.product();
997  bfield = mField->inTesla(GlobalPoint(0.0,0.0,0.0)).z();
998 
999  }
1000 
1002 
1003  if ( iEvent.getByToken(tracksToken_, ctfTracks) ) {
1004 
1005  ConversionInfo convInfo = egammaTools::getConversionInfo(maxETelec2, ctfTracks, bfield);
1006 
1007  Float_t dist = convInfo.dist;
1008  Float_t dcot = convInfo.dcot;
1009 
1010  Bool_t isConv = ( ( TMath::Abs(dist) < dist2_ ) && ( TMath::Abs(dcot) < dcot2_ ) ) ;
1011 
1012  std::cout << "Filter: for electron #2 the conversion says " << isConv << std::endl;
1013 
1014  if ( isConv && useConversionRejection2_ ) {
1015  delete [] sorted;
1016  delete [] et;
1017  return false;
1018  }
1019 
1021 
1022  maxETelec2.addUserFloat("Dist", Float_t(dist));
1023  maxETelec2.addUserFloat("Dcot", Float_t(dcot));
1024 
1025  if ( isConv ) {
1026  maxETelec2.addUserInt("PassConversionRejection",0);
1027  }
1028  else {
1029  maxETelec2.addUserInt("PassConversionRejection",1);
1030  }
1031 
1032  }
1033 
1034  }
1035  else {
1036  std::cout << "WARNING! Track Collection with input name: generalTracks was not found. Conversion Rejection for electron #2 is not going to be applied!!!" << std::endl;
1037  }
1038 
1039  }
1040 
1041  std::cout << "HLT matching starts" << std::endl;
1042 
1044 
1045  Double_t matched_dr_distance1 = 999999.;
1046  Int_t trigger_int_probe1 = 0;
1047 
1048  Double_t matched_dr_distance2 = 999999.;
1049  Int_t trigger_int_probe2 = 0;
1050 
1051  if ( finalpathfound ) {
1052 
1053  if ( nF != filterInd ) {
1054 
1055  const trigger::Keys& KEYS(pHLT->filterKeys(filterInd));
1056  const Int_t nK(KEYS.size());
1057 
1058  std::cout << "Found trig objects #" << nK << std::endl;
1059 
1060  for ( Int_t iTrig = 0; iTrig < nK; ++iTrig ) {
1061 
1062  const trigger::TriggerObject& TO(TOC[KEYS[iTrig]]);
1063 
1064  if ( useHLTObjectETCut_ ) {
1065  if ( TO.et() < hltObjectETCut_ ) {
1066  continue;
1067  }
1068  }
1069 
1070  Double_t dr_ele_HLT1 = reco::deltaR(maxETelec1.superCluster()->eta(),maxETelec1.superCluster()->phi(),TO.eta(),TO.phi());
1071  Double_t dr_ele_HLT2 = reco::deltaR(maxETelec2.superCluster()->eta(),maxETelec2.superCluster()->phi(),TO.eta(),TO.phi());
1072 
1073  //std::cout << "-->found dr=" << dr_ele_HLT << std::endl;
1074 
1075  if ( TMath::Abs(dr_ele_HLT1) < matched_dr_distance1 ) {
1076  matched_dr_distance1 = dr_ele_HLT1;
1077  }
1078 
1079  if ( TMath::Abs(dr_ele_HLT2) < matched_dr_distance2 ) {
1080  matched_dr_distance2 = dr_ele_HLT2;
1081  }
1082 
1083  }
1084 
1085  }
1086 
1087  if ( useExtraTrigger_ ) {
1088 
1089  for (Int_t itrig=0; itrig < (Int_t) filterIndExtra.size(); ++itrig ) {
1090 
1091  if ( filterIndExtra[itrig] == nF ) {
1092  continue;
1093  }
1094 
1095  std::cout << "working on #" << itrig << std::endl; std::cout << " ---> " << filterIndExtra[itrig] << std::endl;
1096 
1097  const trigger::Keys& KEYS(pHLT->filterKeys(filterIndExtra[itrig]));
1098  const Int_t nK(KEYS.size());
1099 
1100  std::cout << "Found trig objects #" << nK << std::endl;
1101 
1102  for (Int_t iTrig = 0; iTrig <nK; ++iTrig ) {
1103 
1104  const trigger::TriggerObject& TO(TOC[KEYS[iTrig]]);
1105 
1106  Double_t dr_ele_HLT1 = reco::deltaR(maxETelec1.eta(),maxETelec1.phi(),TO.eta(),TO.phi());
1107  Double_t dr_ele_HLT2 = reco::deltaR(maxETelec2.eta(),maxETelec2.phi(),TO.eta(),TO.phi());
1108 
1109  //std::cout << "-->found dr=" << dr_ele_HLT << std::endl;
1110 
1111  if ( TMath::Abs(dr_ele_HLT1) < matched_dr_distance1 ) {
1112  matched_dr_distance1 = dr_ele_HLT1;
1113  }
1114 
1115  if ( TMath::Abs(dr_ele_HLT2) < matched_dr_distance2 ) {
1116  matched_dr_distance2 = dr_ele_HLT2;
1117  }
1118  }
1119  }
1120  }
1121 
1122  if ( matched_dr_distance1 < electronMatched2HLT_DR_ ) {
1123  ++trigger_int_probe1;
1124  }
1125 
1126  if ( matched_dr_distance2 < electronMatched2HLT_DR_ ) {
1127  ++trigger_int_probe2;
1128  }
1129 
1130  if ( ( trigger_int_probe1 == 0 ) && ( trigger_int_probe2 == 0 ) ) { std::cout << "No electron could be matched to an HLT object with " << std::endl;
1131 
1132  delete [] sorted;
1133  delete [] et;
1134 
1135  return false; // RETURN: electron is not matched to an HLT object
1136  }
1137 
1138  maxETelec1.addUserFloat("HLTMatchingDR", Float_t(matched_dr_distance1));
1139  maxETelec2.addUserFloat("HLTMatchingDR", Float_t(matched_dr_distance2));
1140 
1141  }
1142  else { //std::cout << "Electron filter not found - should not be like that... " << std::endl;
1143 
1144  delete [] sorted;
1145  delete [] et;
1146 
1147  return false; // RETURN: electron is not matched to an HLT object
1148  }
1149  }
1150 
1151  std::cout << "HLT matching has finished" << std::endl;
1152 
1153  // ___________________________________________________________________
1154  //
1155 
1156  // add information of whether the event passes the following sets of
1157  // triggers. Currently Hardwired, to be changed in the future
1158 
1159  if ( HLTResults.isValid() ) {
1160 
1162  //
1163  std::string HLTPath[18];
1164  HLTPath[0 ] = "HLT_Photon10_L1R" ;
1165  HLTPath[1 ] = "HLT_Photon15_L1R" ;
1166  HLTPath[2 ] = "HLT_Photon20_L1R" ;
1167  HLTPath[3 ] = "HLT_Photon15_TrackIso_L1R" ;
1168  HLTPath[4 ] = "HLT_Photon15_LooseEcalIso_L1R" ;
1169  HLTPath[5 ] = "HLT_Photon30_L1R_8E29" ;
1170  HLTPath[6 ] = "HLT_Photon30_L1R_8E29" ;
1171  HLTPath[7 ] = "HLT_Ele10_LW_L1R" ;
1172  HLTPath[8 ] = "HLT_Ele15_LW_L1R" ;
1173  HLTPath[9 ] = "HLT_Ele20_LW_L1R" ;
1174  HLTPath[10] = "HLT_Ele10_LW_EleId_L1R" ;
1175  HLTPath[11] = "HLT_Ele15_SiStrip_L1R" ;
1176  HLTPath[12] = "HLT_IsoTrackHB_8E29" ;
1177  HLTPath[13] = "HLT_IsoTrackHE_8E29" ;
1178  HLTPath[14] = "HLT_DiJetAve15U_8E29" ;
1179  HLTPath[15] = "HLT_MET45" ;
1180  HLTPath[16] = "HLT_L1MET20" ;
1181  HLTPath[17] = "HLT_MET100" ;
1182  //
1183  edm::InputTag HLTFilterType[15];
1184  HLTFilterType[0 ]= edm::InputTag("hltL1NonIsoHLTNonIsoSinglePhotonEt10HcalIsolFilter","",process) ; //HLT_Photon10_L1R
1185  HLTFilterType[1 ]= edm::InputTag("hltL1NonIsoHLTNonIsoSinglePhotonEt15HcalIsolFilter" ,"",process) ; //HLT_Photon15_L1R
1186  HLTFilterType[2 ]= edm::InputTag("hltL1NonIsoHLTNonIsoSinglePhotonEt20HcalIsolFilter" ,"",process) ; //HLT_Photon20_L1R
1187  HLTFilterType[3 ]= edm::InputTag("hltL1NonIsoSinglePhotonEt15HTITrackIsolFilter","",process) ; //HLT_Photon15_TrackIso_L1R
1188  HLTFilterType[4 ]= edm::InputTag("hltL1NonIsoSinglePhotonEt15LEIHcalIsolFilter","",process) ; //HLT_Photon15_LooseEcalIso_L1R
1189  HLTFilterType[5 ]= edm::InputTag("hltL1NonIsoHLTNonIsoSinglePhotonEt15EtFilterESet308E29","",process) ; //HLT_Photon30_L1R_8E29
1190  HLTFilterType[6 ]= edm::InputTag("hltL1NonIsoHLTNonIsoSinglePhotonEt15HcalIsolFilter","",process) ; //HLT_Photon30_L1R_8E29
1191  HLTFilterType[7 ]= edm::InputTag("hltL1NonIsoHLTNonIsoSingleElectronLWEt10PixelMatchFilter","",process) ;
1192  HLTFilterType[8 ]= edm::InputTag("hltL1NonIsoHLTNonIsoSingleElectronLWEt15PixelMatchFilter","",process) ;
1193  HLTFilterType[9 ]= edm::InputTag("hltL1NonIsoHLTNonIsoSingleElectronLWEt15EtFilterESet20","",process) ;
1194  HLTFilterType[10]= edm::InputTag("hltL1NonIsoHLTNonIsoSingleElectronLWEt10EleIdDphiFilter","",process) ;
1195  HLTFilterType[11]= edm::InputTag("hltL1NonIsoHLTNonIsoSingleElectronSiStripEt15PixelMatchFilter","",process) ;
1196  HLTFilterType[12]= edm::InputTag("hltIsolPixelTrackL3FilterHB8E29","",process) ;
1197  HLTFilterType[13]= edm::InputTag("hltIsolPixelTrackL2FilterHE8E29","",process) ;
1198  HLTFilterType[14]= edm::InputTag("hltL1sDiJetAve15U8E29","",process) ;
1199  //
1200  Int_t triggerDecision = 0;
1201  UInt_t trigger_size = HLTResults->size();
1202 
1203  for (Int_t i=0; i<18; ++i ) {
1204 
1205  const edm::TriggerNames & triggerNames = iEvent.triggerNames(*HLTResults);
1206  UInt_t trigger_position = triggerNames.triggerIndex(HLTPath[i]);
1207  Int_t passTrigger = 0;
1208 
1209  if ( trigger_position < trigger_size ) {
1210  passTrigger = (Int_t)HLTResults->accept(trigger_position);
1211  }
1212 
1213  if ( passTrigger > 0 ) {
1214  if ( i >= 15 ) {
1215  triggerDecision += (Int_t)(TMath::Power(2,i));
1216  }
1217  else {
1218  const Int_t myfilterInd = pHLT->filterIndex(HLTFilterType[i]);
1219  if ( myfilterInd != nF ) {
1220  triggerDecision += (Int_t)(TMath::Power(2,i));
1221  }
1222  }
1223  }
1224  }
1225 
1226  // add the info in the maxETelec1 and maxETelec2
1227  maxETelec1.addUserInt("triggerDecision",triggerDecision);
1228  maxETelec2.addUserInt("triggerDecision",triggerDecision);
1229  }
1230 
1231  // ___________________________________________________________________
1232  //
1233 
1234  // MET Collection
1236  iEvent.getByToken(metCollectionToken_, patMET);
1237 
1239  iEvent.getByToken(pfMetCollectionToken_, patpfMET);
1240 
1242  iEvent.getByToken(tcMetCollectionToken_, pattcMET);
1243 
1244  const pat::METCollection *pMet = patMET.product();
1245  const pat::METCollection::const_iterator met = pMet->begin();
1246  const pat::MET theMET = *met;
1247  //
1248  const pat::METCollection *pPfMet = patpfMET.product();
1249  const pat::METCollection::const_iterator pfmet = pPfMet->begin();
1250  const pat::MET thePfMET = *pfmet;
1251  //
1252  const pat::METCollection *pTcMet = pattcMET.product();
1253  const pat::METCollection::const_iterator tcmet = pTcMet->begin();
1254  const pat::MET theTcMET = *tcmet;
1255 
1256  Double_t metEt = met->et();
1257  //Double_t metEta = met->eta();
1258  //Double_t metMt = met->mt();
1259  //Double_t metPhi = met->phi();
1260  //Double_t metSig = met->mEtSig();
1261  //std::cout<<"met properties: et=" << met->et() << ", eta: " << met->eta()
1262  // << std::endl;
1263  //
1264  if ( metEt < METCut_ ) { std::cout << "MET is " << metEt << std::endl;
1265 
1266  delete [] sorted;
1267  delete [] et;
1268 
1269  return false; // RETURN if MET is < Metcut
1270  }
1271 
1272 
1273  // if you have indeed reached this point then you have a zeeCandidate!!!
1274 
1275  pat::CompositeCandidate zeeCandidate;
1276 
1277  zeeCandidate.addDaughter(maxETelec1, "electron1");
1278  zeeCandidate.addDaughter(maxETelec2, "electron2");
1279 
1280  zeeCandidate.addDaughter(theMET, "met");
1281  zeeCandidate.addDaughter(thePfMET, "pfmet");
1282  zeeCandidate.addDaughter(theTcMET, "tcmet");
1283 
1284  unique_ptr<pat::CompositeCandidateCollection>selectedZeeCandidates(new pat::CompositeCandidateCollection);
1285 
1286  selectedZeeCandidates->push_back(zeeCandidate);
1287 
1288  iEvent.put(std::move(selectedZeeCandidates), "selectedZeeCandidates");
1289 
1290  // release your memory
1291  delete [] sorted;
1292  delete [] et;
1293 
1294  std::cout << "Run = " << iEvent.run() << " "
1295  << "Lumi = " << (Int_t)iEvent.luminosityBlock() << " "
1296  << "Event = " << iEvent.eventAuxiliary().event() << " "
1297  << "FILTER-MSG: Event Accepted for Z Candidate"
1298  << std::endl;
1299 
1300  return true;
1301 
1302 }
1303 
1304 // ------------ method called once each job just after ending the event loop -
1306 
1308 {
1309  if ( TMath::Abs(eta) < BarrelMaxEta_ ) {
1310  return true;
1311  }
1312  else if ( ( TMath::Abs(eta) < EndCapMaxEta_ ) && ( TMath::Abs(eta) > EndCapMinEta_ ) ) {
1313  return true;
1314  }
1315 
1316  return false;
1317 
1318 }
1319 
1320 // Bool_t ZeeCandidateFilter::passEleIDCuts(pat::Electron *ele)
1321 // {
1322 // if ( ! useVetoSecondElectronID_) return true;
1323 // if ( ! ele->isElectronIDAvailable(vetoSecondElectronIDType_) ) {
1324 // std::cout << "ZeeCandidateFilter: request ignored: 2nd electron ID type "
1325 // << "not found in electron object" << std::endl;
1326 // return true;
1327 // }
1328 // if ( vetoSecondElectronIDSign_ == ">" ) {
1329 // if ( ele->electronID(vetoSecondElectronIDType_)>vetoSecondElectronIDValue_)
1330 // return true;
1331 // else return false;
1332 // }
1333 // else if ( vetoSecondElectronIDSign_ == "<" ) {
1334 // if ( ele->electronID(vetoSecondElectronIDType_)<vetoSecondElectronIDValue_)
1335 // return true;
1336 // else return false;
1337 // }
1338 // else {
1339 // if ( TMath::Abs(ele->electronID(vetoSecondElectronIDType_)-
1340 // vetoSecondElectronIDValue_) < 0.1)
1341 // return true;
1342 // else return false;
1343 // }
1344 // }
1345 
1346 //define this as a plug-in
Analysis-level particle class.
Analysis-level MET class.
Definition: MET.h:40
const double dist
T getUntrackedParameter(std::string const &, T const &) const
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:125
EventAuxiliary const & eventAuxiliary() const override
Definition: Event.h:92
double eta() const final
momentum pseudorapidity
trigger::size_type sizeFilters() const
Definition: TriggerEvent.h:135
ConversionInfo getConversionInfo(const reco::GsfElectronCore &, const edm::Handle< reco::TrackCollection > &ctftracks_h, const edm::Handle< reco::GsfTrackCollection > &gsftracks_h, const double bFieldAtOrigin, const double minFracSharedHits=0.45)
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:517
float phi() const
Definition: TriggerObject.h:58
edm::InputTag triggerCollectionTag_
std::vector< MET > METCollection
Definition: MET.h:31
bool accept() const
Has at least one path accepted the event?
const Keys & filterKeys(trigger::size_type index) const
Definition: TriggerEvent.h:111
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
trigger::size_type filterIndex(const edm::InputTag &filterTag) const
find index of filter in data-member vector from filter tag
Definition: TriggerEvent.h:123
edm::LuminosityBlockNumber_t luminosityBlock() const
Definition: EventBase.h:61
void addUserFloat(const std::string &label, float data, const bool overwrite=false)
Set user-defined float.
Definition: PATObject.h:813
float eta() const
Definition: TriggerObject.h:57
std::vector< edm::InputTag > vHltpathFilterExtra_
edm::EDGetTokenT< edm::TriggerResults > triggerCollectionToken_
edm::EDGetTokenT< reco::TrackCollection > tracksToken_
bool isEB() const
Definition: GsfElectron.h:356
edm::EDGetTokenT< pat::METCollection > pfMetCollectionToken_
Definition: HeavyIon.h:7
ZeeCandidateFilter(const edm::ParameterSet &)
Single trigger physics object (e.g., an isolated muon)
Definition: TriggerObject.h:22
edm::EDGetTokenT< pat::METCollection > tcMetCollectionToken_
edm::EDGetTokenT< DcsStatusCollection > dcsToken_
int iEvent
Definition: GenABIO.cc:224
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
std::vector< Electron > ElectronCollection
Definition: Electron.h:37
unsigned int triggerIndex(std::string const &name) const
Definition: TriggerNames.cc:24
double et() const final
transverse energy
const TriggerObjectCollection & getObjects() const
Definition: TriggerEvent.h:98
unsigned int size() const
Get number of paths stored.
T z() const
Definition: PV3DBase.h:64
T Abs(T a)
Definition: MathUtil.h:49
RunNumber_t run() const
Definition: Event.h:101
edm::EDGetTokenT< pat::ElectronCollection > electronCollectionToken_
Bool_t isInFiducial(Double_t eta)
edm::EDGetTokenT< pat::METCollection > metCollectionToken_
bool isValid() const
Definition: HandleBase.h:74
void addUserInt(const std::string &label, int32_t data, const bool overwrite=false)
Set user-defined int.
Definition: PATObject.h:855
virtual GlobalVector inTesla(const GlobalPoint &gp) const =0
Field value ad specified global point, in Tesla.
void addDaughter(const Candidate &, const std::string &s="")
add a clone of the passed candidate as daughter
Bool_t filter(edm::Event &, const edm::EventSetup &) override
constexpr auto deltaR(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
Definition: deltaR.h:28
const double dcot
edm::InputTag electronCollectionTag_
Double_t spikeCleaningSwissCrossCut_
std::vector< TriggerObject > TriggerObjectCollection
collection of trigger physics objects (e.g., all isolated muons)
Definition: TriggerObject.h:81
Definition: DetId.h:18
std::vector< CompositeCandidate > CompositeCandidateCollection
T const * product() const
Definition: Handle.h:74
met
===> hadronic RAZOR
std::vector< size_type > Keys
std::vector< std::string > vHltpathExtra_
math::XYZPoint caloPosition() const
Definition: GsfElectron.h:329
Analysis-level electron class.
Definition: Electron.h:52
et
define resolution functions of each parameter
static float swissCross(const DetId &id, const EcalRecHitCollection &recHits, float recHitThreshold, bool avoidIeta85=true)
the good old 1-e4/e1. Ignore hits below recHitThreshold
Definition: EcalTools.cc:11
std::string const & process() const
Definition: InputTag.h:40
HLT enums.
edm::InputTag hltpathFilter_
static std::atomic< unsigned int > counter
static int position[264][3]
Definition: ReadPGInfo.cc:509
edm::EDGetTokenT< EcalRecHitCollection > eeRecHitsToken_
T get() const
Definition: EventSetup.h:71
edm::EDGetTokenT< EcalRecHitCollection > ebRecHitsToken_
edm::EDGetTokenT< trigger::TriggerEvent > triggerEventToken_
reco::GsfTrackRef gsfTrack() const override
override the reco::GsfElectron::gsfTrack method, to access the internal storage of the supercluster ...
def fail(errstr="")
edm::EDGetTokenT< std::vector< reco::Vertex > > PrimaryVerticesCollectionToken_
double phi() const final
momentum azimuthal angle
T const * product() const
Definition: ESHandle.h:86
reco::SuperClusterRef superCluster() const override
override the reco::GsfElectron::superCluster method, to access the internal storage of the superclust...
edm::TriggerNames const & triggerNames(edm::TriggerResults const &triggerResults) const override
Definition: Event.cc:256
EventNumber_t event() const
def move(src, dest)
Definition: eostools.py:511
bool ecalDrivenSeed() const
Definition: GsfElectron.h:188