CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 
108 
109 private:
110 
111  virtual Bool_t filter(edm::Event&, const edm::EventSetup&) override;
112 
113  virtual 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.size() >=1 ) {
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().hasValidHitInFirstPixelBarrel();
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().hasValidHitInFirstPixelBarrel();
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().numberOfHits(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().numberOfHits(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  ConversionFinder convFinder;
936  ConversionInfo convInfo = convFinder.getConversionInfo(maxETelec1, ctfTracks, bfield);
937 
938  Float_t dist = convInfo.dist();
939  Float_t dcot = convInfo.dcot();
940 
941  Bool_t isConv = ( ( TMath::Abs(dist) < dist1_ ) && ( TMath::Abs(dcot) < dcot1_ ) ) ;
942 
943  std::cout << "Filter: for electron #1 the conversion says " << isConv << std::endl;
944 
945  if ( isConv && useConversionRejection1_ ) {
946  delete [] sorted;
947  delete [] et;
948  return false;
949  }
950 
952 
953  maxETelec1.addUserFloat("Dist", Float_t(dist));
954  maxETelec1.addUserFloat("Dcot", Float_t(dcot));
955 
956  if ( isConv ) {
957  maxETelec1.addUserInt("PassConversionRejection",0);
958  }
959  else {
960  maxETelec1.addUserInt("PassConversionRejection",1);
961  }
962 
963  }
964 
965  }
966  else {
967  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;
968  }
969 
970  }
971 
973  // use of conversion rejection as it is implemented in egamma
974  // you have to get the general track collection to do that
975  // WARNING! you have to supply the correct B-field in Tesla
976  // the magnetic field
977 
978  Double_t bfield;
979 
980  if ( dataMagneticFieldSetUp_ ) {
981 
983  iEvent.getByToken(dcsToken_, dcsHandle);
984 
985  // scale factor = 3.801/18166.0 which are
986  // average values taken over a stable two
987  // week period
988 
989  Double_t currentToBFieldScaleFactor = 2.09237036221512717e-04;
990  Double_t current = (*dcsHandle)[0].magnetCurrent();
991  bfield = current*currentToBFieldScaleFactor;
992 
993  } else {
994 
996  iSetup.get<IdealMagneticFieldRecord>().get(magneticField);
997  const MagneticField *mField = magneticField.product();
998  bfield = mField->inTesla(GlobalPoint(0.0,0.0,0.0)).z();
999 
1000  }
1001 
1003 
1004  if ( iEvent.getByToken(tracksToken_, ctfTracks) ) {
1005 
1006  ConversionFinder convFinder;
1007  ConversionInfo convInfo = convFinder.getConversionInfo(maxETelec2, ctfTracks, bfield);
1008 
1009  Float_t dist = convInfo.dist();
1010  Float_t dcot = convInfo.dcot();
1011 
1012  Bool_t isConv = ( ( TMath::Abs(dist) < dist2_ ) && ( TMath::Abs(dcot) < dcot2_ ) ) ;
1013 
1014  std::cout << "Filter: for electron #2 the conversion says " << isConv << std::endl;
1015 
1016  if ( isConv && useConversionRejection2_ ) {
1017  delete [] sorted;
1018  delete [] et;
1019  return false;
1020  }
1021 
1023 
1024  maxETelec2.addUserFloat("Dist", Float_t(dist));
1025  maxETelec2.addUserFloat("Dcot", Float_t(dcot));
1026 
1027  if ( isConv ) {
1028  maxETelec2.addUserInt("PassConversionRejection",0);
1029  }
1030  else {
1031  maxETelec2.addUserInt("PassConversionRejection",1);
1032  }
1033 
1034  }
1035 
1036  }
1037  else {
1038  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;
1039  }
1040 
1041  }
1042 
1043  std::cout << "HLT matching starts" << std::endl;
1044 
1046 
1047  Double_t matched_dr_distance1 = 999999.;
1048  Int_t trigger_int_probe1 = 0;
1049 
1050  Double_t matched_dr_distance2 = 999999.;
1051  Int_t trigger_int_probe2 = 0;
1052 
1053  if ( finalpathfound ) {
1054 
1055  if ( nF != filterInd ) {
1056 
1057  const trigger::Keys& KEYS(pHLT->filterKeys(filterInd));
1058  const Int_t nK(KEYS.size());
1059 
1060  std::cout << "Found trig objects #" << nK << std::endl;
1061 
1062  for ( Int_t iTrig = 0; iTrig < nK; ++iTrig ) {
1063 
1064  const trigger::TriggerObject& TO(TOC[KEYS[iTrig]]);
1065 
1066  if ( useHLTObjectETCut_ ) {
1067  if ( TO.et() < hltObjectETCut_ ) {
1068  continue;
1069  }
1070  }
1071 
1072  Double_t dr_ele_HLT1 = reco::deltaR(maxETelec1.superCluster()->eta(),maxETelec1.superCluster()->phi(),TO.eta(),TO.phi());
1073  Double_t dr_ele_HLT2 = reco::deltaR(maxETelec2.superCluster()->eta(),maxETelec2.superCluster()->phi(),TO.eta(),TO.phi());
1074 
1075  //std::cout << "-->found dr=" << dr_ele_HLT << std::endl;
1076 
1077  if ( TMath::Abs(dr_ele_HLT1) < matched_dr_distance1 ) {
1078  matched_dr_distance1 = dr_ele_HLT1;
1079  }
1080 
1081  if ( TMath::Abs(dr_ele_HLT2) < matched_dr_distance2 ) {
1082  matched_dr_distance2 = dr_ele_HLT2;
1083  }
1084 
1085  }
1086 
1087  }
1088 
1089  if ( useExtraTrigger_ ) {
1090 
1091  for (Int_t itrig=0; itrig < (Int_t) filterIndExtra.size(); ++itrig ) {
1092 
1093  if ( filterIndExtra[itrig] == nF ) {
1094  continue;
1095  }
1096 
1097  std::cout << "working on #" << itrig << std::endl; std::cout << " ---> " << filterIndExtra[itrig] << std::endl;
1098 
1099  const trigger::Keys& KEYS(pHLT->filterKeys(filterIndExtra[itrig]));
1100  const Int_t nK(KEYS.size());
1101 
1102  std::cout << "Found trig objects #" << nK << std::endl;
1103 
1104  for (Int_t iTrig = 0; iTrig <nK; ++iTrig ) {
1105 
1106  const trigger::TriggerObject& TO(TOC[KEYS[iTrig]]);
1107 
1108  Double_t dr_ele_HLT1 = reco::deltaR(maxETelec1.eta(),maxETelec1.phi(),TO.eta(),TO.phi());
1109  Double_t dr_ele_HLT2 = reco::deltaR(maxETelec2.eta(),maxETelec2.phi(),TO.eta(),TO.phi());
1110 
1111  //std::cout << "-->found dr=" << dr_ele_HLT << std::endl;
1112 
1113  if ( TMath::Abs(dr_ele_HLT1) < matched_dr_distance1 ) {
1114  matched_dr_distance1 = dr_ele_HLT1;
1115  }
1116 
1117  if ( TMath::Abs(dr_ele_HLT2) < matched_dr_distance2 ) {
1118  matched_dr_distance2 = dr_ele_HLT2;
1119  }
1120  }
1121  }
1122  }
1123 
1124  if ( matched_dr_distance1 < electronMatched2HLT_DR_ ) {
1125  ++trigger_int_probe1;
1126  }
1127 
1128  if ( matched_dr_distance2 < electronMatched2HLT_DR_ ) {
1129  ++trigger_int_probe2;
1130  }
1131 
1132  if ( ( trigger_int_probe1 == 0 ) && ( trigger_int_probe2 == 0 ) ) { std::cout << "No electron could be matched to an HLT object with " << std::endl;
1133 
1134  delete [] sorted;
1135  delete [] et;
1136 
1137  return false; // RETURN: electron is not matched to an HLT object
1138  }
1139 
1140  maxETelec1.addUserFloat("HLTMatchingDR", Float_t(matched_dr_distance1));
1141  maxETelec2.addUserFloat("HLTMatchingDR", Float_t(matched_dr_distance2));
1142 
1143  }
1144  else { //std::cout << "Electron filter not found - should not be like that... " << std::endl;
1145 
1146  delete [] sorted;
1147  delete [] et;
1148 
1149  return false; // RETURN: electron is not matched to an HLT object
1150  }
1151  }
1152 
1153  std::cout << "HLT matching has finished" << std::endl;
1154 
1155  // ___________________________________________________________________
1156  //
1157 
1158  // add information of whether the event passes the following sets of
1159  // triggers. Currently Hardwired, to be changed in the future
1160 
1161  if ( HLTResults.isValid() ) {
1162 
1164  //
1165  std::string HLTPath[18];
1166  HLTPath[0 ] = "HLT_Photon10_L1R" ;
1167  HLTPath[1 ] = "HLT_Photon15_L1R" ;
1168  HLTPath[2 ] = "HLT_Photon20_L1R" ;
1169  HLTPath[3 ] = "HLT_Photon15_TrackIso_L1R" ;
1170  HLTPath[4 ] = "HLT_Photon15_LooseEcalIso_L1R" ;
1171  HLTPath[5 ] = "HLT_Photon30_L1R_8E29" ;
1172  HLTPath[6 ] = "HLT_Photon30_L1R_8E29" ;
1173  HLTPath[7 ] = "HLT_Ele10_LW_L1R" ;
1174  HLTPath[8 ] = "HLT_Ele15_LW_L1R" ;
1175  HLTPath[9 ] = "HLT_Ele20_LW_L1R" ;
1176  HLTPath[10] = "HLT_Ele10_LW_EleId_L1R" ;
1177  HLTPath[11] = "HLT_Ele15_SiStrip_L1R" ;
1178  HLTPath[12] = "HLT_IsoTrackHB_8E29" ;
1179  HLTPath[13] = "HLT_IsoTrackHE_8E29" ;
1180  HLTPath[14] = "HLT_DiJetAve15U_8E29" ;
1181  HLTPath[15] = "HLT_MET45" ;
1182  HLTPath[16] = "HLT_L1MET20" ;
1183  HLTPath[17] = "HLT_MET100" ;
1184  //
1185  edm::InputTag HLTFilterType[15];
1186  HLTFilterType[0 ]= edm::InputTag("hltL1NonIsoHLTNonIsoSinglePhotonEt10HcalIsolFilter","",process) ; //HLT_Photon10_L1R
1187  HLTFilterType[1 ]= edm::InputTag("hltL1NonIsoHLTNonIsoSinglePhotonEt15HcalIsolFilter" ,"",process) ; //HLT_Photon15_L1R
1188  HLTFilterType[2 ]= edm::InputTag("hltL1NonIsoHLTNonIsoSinglePhotonEt20HcalIsolFilter" ,"",process) ; //HLT_Photon20_L1R
1189  HLTFilterType[3 ]= edm::InputTag("hltL1NonIsoSinglePhotonEt15HTITrackIsolFilter","",process) ; //HLT_Photon15_TrackIso_L1R
1190  HLTFilterType[4 ]= edm::InputTag("hltL1NonIsoSinglePhotonEt15LEIHcalIsolFilter","",process) ; //HLT_Photon15_LooseEcalIso_L1R
1191  HLTFilterType[5 ]= edm::InputTag("hltL1NonIsoHLTNonIsoSinglePhotonEt15EtFilterESet308E29","",process) ; //HLT_Photon30_L1R_8E29
1192  HLTFilterType[6 ]= edm::InputTag("hltL1NonIsoHLTNonIsoSinglePhotonEt15HcalIsolFilter","",process) ; //HLT_Photon30_L1R_8E29
1193  HLTFilterType[7 ]= edm::InputTag("hltL1NonIsoHLTNonIsoSingleElectronLWEt10PixelMatchFilter","",process) ;
1194  HLTFilterType[8 ]= edm::InputTag("hltL1NonIsoHLTNonIsoSingleElectronLWEt15PixelMatchFilter","",process) ;
1195  HLTFilterType[9 ]= edm::InputTag("hltL1NonIsoHLTNonIsoSingleElectronLWEt15EtFilterESet20","",process) ;
1196  HLTFilterType[10]= edm::InputTag("hltL1NonIsoHLTNonIsoSingleElectronLWEt10EleIdDphiFilter","",process) ;
1197  HLTFilterType[11]= edm::InputTag("hltL1NonIsoHLTNonIsoSingleElectronSiStripEt15PixelMatchFilter","",process) ;
1198  HLTFilterType[12]= edm::InputTag("hltIsolPixelTrackL3FilterHB8E29","",process) ;
1199  HLTFilterType[13]= edm::InputTag("hltIsolPixelTrackL2FilterHE8E29","",process) ;
1200  HLTFilterType[14]= edm::InputTag("hltL1sDiJetAve15U8E29","",process) ;
1201  //
1202  Int_t triggerDecision = 0;
1203  UInt_t trigger_size = HLTResults->size();
1204 
1205  for (Int_t i=0; i<18; ++i ) {
1206 
1207  const edm::TriggerNames & triggerNames = iEvent.triggerNames(*HLTResults);
1208  UInt_t trigger_position = triggerNames.triggerIndex(HLTPath[i]);
1209  Int_t passTrigger = 0;
1210 
1211  if ( trigger_position < trigger_size ) {
1212  passTrigger = (Int_t)HLTResults->accept(trigger_position);
1213  }
1214 
1215  if ( passTrigger > 0 ) {
1216  if ( i >= 15 ) {
1217  triggerDecision += (Int_t)(TMath::Power(2,i));
1218  }
1219  else {
1220  const Int_t myfilterInd = pHLT->filterIndex(HLTFilterType[i]);
1221  if ( myfilterInd != nF ) {
1222  triggerDecision += (Int_t)(TMath::Power(2,i));
1223  }
1224  }
1225  }
1226  }
1227 
1228  // add the info in the maxETelec1 and maxETelec2
1229  maxETelec1.addUserInt("triggerDecision",triggerDecision);
1230  maxETelec2.addUserInt("triggerDecision",triggerDecision);
1231  }
1232 
1233  // ___________________________________________________________________
1234  //
1235 
1236  // MET Collection
1238  iEvent.getByToken(metCollectionToken_, patMET);
1239 
1241  iEvent.getByToken(pfMetCollectionToken_, patpfMET);
1242 
1244  iEvent.getByToken(tcMetCollectionToken_, pattcMET);
1245 
1246  const pat::METCollection *pMet = patMET.product();
1247  const pat::METCollection::const_iterator met = pMet->begin();
1248  const pat::MET theMET = *met;
1249  //
1250  const pat::METCollection *pPfMet = patpfMET.product();
1251  const pat::METCollection::const_iterator pfmet = pPfMet->begin();
1252  const pat::MET thePfMET = *pfmet;
1253  //
1254  const pat::METCollection *pTcMet = pattcMET.product();
1255  const pat::METCollection::const_iterator tcmet = pTcMet->begin();
1256  const pat::MET theTcMET = *tcmet;
1257 
1258  Double_t metEt = met->et();
1259  //Double_t metEta = met->eta();
1260  //Double_t metMt = met->mt();
1261  //Double_t metPhi = met->phi();
1262  //Double_t metSig = met->mEtSig();
1263  //std::cout<<"met properties: et=" << met->et() << ", eta: " << met->eta()
1264  // << std::endl;
1265  //
1266  if ( metEt < METCut_ ) { std::cout << "MET is " << metEt << std::endl;
1267 
1268  delete [] sorted;
1269  delete [] et;
1270 
1271  return false; // RETURN if MET is < Metcut
1272  }
1273 
1274 
1275  // if you have indeed reached this point then you have a zeeCandidate!!!
1276 
1277  pat::CompositeCandidate zeeCandidate;
1278 
1279  zeeCandidate.addDaughter(maxETelec1, "electron1");
1280  zeeCandidate.addDaughter(maxETelec2, "electron2");
1281 
1282  zeeCandidate.addDaughter(theMET, "met");
1283  zeeCandidate.addDaughter(thePfMET, "pfmet");
1284  zeeCandidate.addDaughter(theTcMET, "tcmet");
1285 
1286  auto_ptr<pat::CompositeCandidateCollection>selectedZeeCandidates(new pat::CompositeCandidateCollection);
1287 
1288  selectedZeeCandidates->push_back(zeeCandidate);
1289 
1290  iEvent.put(selectedZeeCandidates, "selectedZeeCandidates");
1291 
1292  // release your memory
1293  delete [] sorted;
1294  delete [] et;
1295 
1296  std::cout << "Run = " << iEvent.run() << " "
1297  << "Lumi = " << (Int_t)iEvent.luminosityBlock() << " "
1298  << "Event = " << iEvent.eventAuxiliary().event() << " "
1299  << "FILTER-MSG: Event Accepted for Z Candidate"
1300  << std::endl;
1301 
1302  return true;
1303 
1304 }
1305 
1306 // ------------ method called once each job just after ending the event loop -
1308 
1310 {
1311  if ( TMath::Abs(eta) < BarrelMaxEta_ ) {
1312  return true;
1313  }
1314  else if ( ( TMath::Abs(eta) < EndCapMaxEta_ ) && ( TMath::Abs(eta) > EndCapMinEta_ ) ) {
1315  return true;
1316  }
1317 
1318  return false;
1319 
1320 }
1321 
1322 // Bool_t ZeeCandidateFilter::passEleIDCuts(pat::Electron *ele)
1323 // {
1324 // if ( ! useVetoSecondElectronID_) return true;
1325 // if ( ! ele->isElectronIDAvailable(vetoSecondElectronIDType_) ) {
1326 // std::cout << "ZeeCandidateFilter: request ignored: 2nd electron ID type "
1327 // << "not found in electron object" << std::endl;
1328 // return true;
1329 // }
1330 // if ( vetoSecondElectronIDSign_ == ">" ) {
1331 // if ( ele->electronID(vetoSecondElectronIDType_)>vetoSecondElectronIDValue_)
1332 // return true;
1333 // else return false;
1334 // }
1335 // else if ( vetoSecondElectronIDSign_ == "<" ) {
1336 // if ( ele->electronID(vetoSecondElectronIDType_)<vetoSecondElectronIDValue_)
1337 // return true;
1338 // else return false;
1339 // }
1340 // else {
1341 // if ( TMath::Abs(ele->electronID(vetoSecondElectronIDType_)-
1342 // vetoSecondElectronIDValue_) < 0.1)
1343 // return true;
1344 // else return false;
1345 // }
1346 // }
1347 
1348 //define this as a plug-in
Analysis-level particle class.
Analysis-level MET class.
Definition: MET.h:43
T getUntrackedParameter(std::string const &, T const &) const
int i
Definition: DBlmapReader.cc:9
virtual edm::TriggerNames const & triggerNames(edm::TriggerResults const &triggerResults) const
Definition: Event.cc:220
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:464
float phi() const
Definition: TriggerObject.h:58
edm::InputTag triggerCollectionTag_
virtual GlobalVector inTesla(const GlobalPoint &gp) const =0
Field value ad specified global point, in Tesla.
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
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)
std::vector< MET > METCollection
Definition: MET.h:32
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
double dist() const
edm::LuminosityBlockNumber_t luminosityBlock() const
Definition: EventBase.h:63
Strings::size_type size() const
Definition: TriggerNames.cc:39
double deltaR(const T1 &t1, const T2 &t2)
Definition: deltaR.h:48
float eta() const
Definition: TriggerObject.h:57
std::vector< edm::InputTag > vHltpathFilterExtra_
edm::EDGetTokenT< edm::TriggerResults > triggerCollectionToken_
edm::EDGetTokenT< reco::TrackCollection > tracksToken_
edm::EDGetTokenT< pat::METCollection > pfMetCollectionToken_
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:230
std::vector< Electron > ElectronCollection
Definition: Electron.h:37
unsigned int triggerIndex(std::string const &name) const
Definition: TriggerNames.cc:32
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:120
T z() const
Definition: PV3DBase.h:64
T Abs(T a)
Definition: MathUtil.h:49
RunNumber_t run() const
Definition: Event.h:92
edm::EDGetTokenT< pat::ElectronCollection > electronCollectionToken_
Bool_t isInFiducial(Double_t eta)
edm::EDGetTokenT< pat::METCollection > metCollectionToken_
virtual void endJob() override
void addDaughter(const Candidate &, const std::string &s="")
add a clone of the passed candidate as daughter
virtual Bool_t filter(edm::Event &, const edm::EventSetup &) override
edm::InputTag electronCollectionTag_
Double_t spikeCleaningSwissCrossCut_
std::vector< TriggerObject > TriggerObjectCollection
collection of trigger physics objects (e.g., all isolated muons)
Definition: TriggerObject.h:81
EventAuxiliary const & eventAuxiliary() const
Definition: Event.h:76
Definition: DetId.h:18
std::vector< CompositeCandidate > CompositeCandidateCollection
T const * product() const
Definition: Handle.h:81
std::vector< size_type > Keys
const T & get() const
Definition: EventSetup.h:56
T const * product() const
Definition: ESHandle.h:86
std::vector< std::string > vHltpathExtra_
Analysis-level electron class.
Definition: Electron.h:52
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:47
edm::InputTag hltpathFilter_
static std::atomic< unsigned int > counter
static int position[264][3]
Definition: ReadPGInfo.cc:509
edm::EDGetTokenT< EcalRecHitCollection > eeRecHitsToken_
edm::EDGetTokenT< EcalRecHitCollection > ebRecHitsToken_
const_iterator begin() const
first daughter const_iterator
Definition: Candidate.h:144
edm::EDGetTokenT< trigger::TriggerEvent > triggerEventToken_
tuple cout
Definition: gather_cfg.py:121
double dcot() const
tuple process
Definition: LaserDQM_cfg.py:3
edm::EDGetTokenT< std::vector< reco::Vertex > > PrimaryVerticesCollectionToken_
EventNumber_t event() const