CMS 3D CMS Logo

ElectronSelector.h
Go to the documentation of this file.
6 #include <vector>
7 
8 std::vector<reco::GsfElectronRef> electronSelector(const std::vector<reco::GsfElectronRef>& electrons,
10  const int filterId,
11  const std::vector<double>& Cuts) {
12  std::vector<reco::GsfElectronRef> ChosenOnes;
13  const trigger::Keys& ring = pHLT->filterKeys(filterId);
14  const trigger::TriggerObjectCollection& HltObjColl = pHLT->getObjects();
15  //const edm::ValueMap<double>& eIsoMapTrk = *eIsoMap[0];
16  //const edm::ValueMap<double>& eIsoMapEcal = *eIsoMap[1];
17  //const edm::ValueMap<double>& eIsoMapHcal = *eIsoMap[2];
18  edm::LogDebug_("electronSelector", "", 16) << "Number of electrons to select from = " << electrons.size();
19  for (std::vector<reco::GsfElectronRef>::const_iterator Relec = electrons.begin(); Relec != electrons.end(); ++Relec) {
20  reco::GsfElectronRef elec = *Relec;
21  edm::LogDebug_("electronSelector", "", 17) << "Analysing elec, id = " << elec.id() << "\tkey = " << elec.key();
22  double scEta = elec->superCluster()->eta();
23  if (fabs(scEta) < 1.4442 || fabs(scEta) > 1.56) {
24  bool HLTMatch = false;
25  for (unsigned int k = 0; k < ring.size(); ++k) {
26  const trigger::TriggerObject& HltObj = HltObjColl[ring[k]];
27  if (reco::deltaR(*elec, HltObj) < 0.1)
28  HLTMatch = true;
29  }
30  edm::LogDebug_("electronSelector", "", 16) << "HLT Match = " << HLTMatch;
31  std::cout << "HLT Match = " << HLTMatch << std::endl;
32  // if(HLTMatch) ChosenOnes.push_back(elec);
33  if (HLTMatch) {
34  if (fabs(scEta) < 1.479) {
35  float sIhIh = elec->scSigmaIEtaIEta();
36  edm::LogDebug_("electronSelector", "", 32) << "SigIetaIeta = " << sIhIh << "\tCut Value = " << Cuts[1];
37  if (sIhIh < Cuts[1]) {
38  edm::LogDebug_("elecSel", "", 39)
39  << "dEta = " << elec->deltaEtaSuperClusterTrackAtVtx() << "\tCut Value = " << Cuts[2];
40  if (fabs(elec->deltaEtaSuperClusterTrackAtVtx()) < Cuts[2]) {
41  edm::LogDebug_("elecSel", "", 39)
42  << "dPhi = " << elec->deltaPhiSuperClusterTrackAtVtx() << "\tCut Value = " << Cuts[3];
43  if (fabs(elec->deltaPhiSuperClusterTrackAtVtx()) < Cuts[3]) {
44  float trckiso = elec->isolationVariables03().tkSumPt;
45  edm::LogDebug_("", "", 29) << "Track isolation = " << trckiso << "\tCut Value = " << Cuts[4];
46  if (trckiso < Cuts[4]) {
47  float ecaliso = elec->isolationVariables04().ecalRecHitSumEt;
48  edm::LogDebug_("", "", 29) << "ECAL isolation = " << ecaliso << "\tCut Value = " << Cuts[5];
49  if (ecaliso < Cuts[5]) {
50  float hcaliso = elec->isolationVariables04().hcalDepth1TowerSumEt +
51  elec->isolationVariables04().hcalDepth2TowerSumEt;
52  edm::LogDebug_("", "", 29) << "HCAL isolation = " << hcaliso << "\tCut Value = " << Cuts[6];
53  if (hcaliso < Cuts[6])
54  ChosenOnes.push_back(elec);
55  }
56  }
57  }
58  }
59  }
60  } else {
61  float sIhIh = elec->scSigmaIEtaIEta();
62  edm::LogDebug_("electronSelector", "", 32) << "SigIetaIeta = " << sIhIh << "\tCut Value = " << Cuts[7];
63  if (sIhIh < Cuts[7]) {
64  edm::LogDebug_("elecSel", "", 39)
65  << "dEta = " << elec->deltaEtaSuperClusterTrackAtVtx() << "\tCut Value = " << Cuts[8];
66  if (fabs(elec->deltaEtaSuperClusterTrackAtVtx()) < Cuts[8]) {
67  edm::LogDebug_("elecSel", "", 39)
68  << "dPhi = " << elec->deltaPhiSuperClusterTrackAtVtx() << "\tCut Value = " << Cuts[9];
69  if (fabs(elec->deltaPhiSuperClusterTrackAtVtx()) < Cuts[9]) {
70  float trckiso = elec->isolationVariables03().tkSumPt;
71  edm::LogDebug_("", "", 29) << "Track isolation = " << trckiso << "\tCut Value = " << Cuts[10];
72  if (trckiso < Cuts[10]) {
73  float ecaliso = elec->isolationVariables04().ecalRecHitSumEt;
74  edm::LogDebug_("", "", 29) << "ECAL isolation = " << ecaliso << "\tCut Value = " << Cuts[11];
75  if (ecaliso < Cuts[11]) {
76  float hcaliso = elec->isolationVariables04().hcalDepth1TowerSumEt +
77  elec->isolationVariables04().hcalDepth2TowerSumEt;
78  edm::LogDebug_("", "", 29) << "HCAL isolation = " << hcaliso << "\tCut Value = " << Cuts[12];
79  if (hcaliso < Cuts[12])
80  ChosenOnes.push_back(elec);
81  }
82  }
83  }
84  }
85  }
86  }
87  // ChosenOnes.push_back(elec);
88  }
89  }
90  }
91  return ChosenOnes;
92 }
Handle.h
trigger::TriggerEvent::filterKeys
const Keys & filterKeys(trigger::size_type index) const
Definition: TriggerEvent.h:118
TriggerEvent.h
edm::LogDebug_
Definition: MessageLogger.h:510
gather_cfg.cout
cout
Definition: gather_cfg.py:144
edm::Handle< trigger::TriggerEvent >
electronSelector
std::vector< reco::GsfElectronRef > electronSelector(const std::vector< reco::GsfElectronRef > &electrons, const edm::Handle< trigger::TriggerEvent > &pHLT, const int filterId, const std::vector< double > &Cuts)
Definition: ElectronSelector.h:8
edm::Ref
Definition: AssociativeIterator.h:58
deltaR.h
dqmdumpme.k
k
Definition: dqmdumpme.py:60
trigger::TriggerObject
Single trigger physics object (e.g., an isolated muon)
Definition: TriggerObject.h:21
GsfElectronFwd.h
trigger::TriggerObjectCollection
std::vector< TriggerObject > TriggerObjectCollection
collection of trigger physics objects (e.g., all isolated muons)
Definition: TriggerObject.h:75
LorentzVector.h
trigger::Keys
std::vector< size_type > Keys
Definition: TriggerTypeDefs.h:19
trigger::TriggerEvent::getObjects
const TriggerObjectCollection & getObjects() const
Definition: TriggerEvent.h:101
edm::Ref::id
ProductID id() const
Accessor for product ID.
Definition: Ref.h:244
pwdgSkimBPark_cfi.electrons
electrons
Definition: pwdgSkimBPark_cfi.py:6
relativeConstraints.ring
ring
Definition: relativeConstraints.py:68
reco::deltaR
constexpr auto deltaR(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
Definition: deltaR.h:30
edm::Ref::key
key_type key() const
Accessor for product key.
Definition: Ref.h:250