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