CMS 3D CMS Logo

SingleEleCalibSelector.cc
Go to the documentation of this file.
1 // my includes
5 
6 // Geometry
10 
13 
18 
20 
21 //CLHEP
22 #include <CLHEP/Vector/LorentzVector.h>
23 
24 #include <iostream>
25 
27  ESCOPinMin_ = iConfig.getParameter<double>("ESCOPinMin");
28  ESCOPinMax_ = iConfig.getParameter<double>("ESCOPinMax");
29  ESeedOPoutMin_ = iConfig.getParameter<double>("ESeedOPoutMin");
30  ESeedOPoutMax_ = iConfig.getParameter<double>("ESeedOPoutMax");
31  PinMPoutOPinMin_ = iConfig.getParameter<double>("PinMPoutOPinMin");
32  PinMPoutOPinMax_ = iConfig.getParameter<double>("PinMPoutOPinMax");
33  E5x5OPoutMin_ = iConfig.getParameter<double>("E5x5OPoutMin");
34  E5x5OPoutMax_ = iConfig.getParameter<double>("E5x5OPoutMax");
35  E3x3OPinMin_ = iConfig.getParameter<double>("E3x3OPinMin");
36  E3x3OPinMax_ = iConfig.getParameter<double>("E3x3OPinMax");
37  E3x3OE5x5Min_ = iConfig.getParameter<double>("E3x3OE5x5Min");
38  E3x3OE5x5Max_ = iConfig.getParameter<double>("E3x3OE5x5Max");
39  EBrecHitLabel_ = iConfig.getParameter<edm::InputTag>("alcaBarrelHitCollection");
40  EErecHitLabel_ = iConfig.getParameter<edm::InputTag>("alcaEndcapHitCollection");
41 }
42 
43 // ------------------------------------------------------------
44 
45 void
46 
48  const edm::Event& iEvent , const edm::EventSetup& iSetup)
49 {
50  selected_.clear();
51 
52  //Get the EB rechit collection
53  edm::Handle<EBRecHitCollection> barrelRecHitsHandle;
54  iEvent.getByLabel(EBrecHitLabel_, barrelRecHitsHandle);
55  const EBRecHitCollection* EBHitsColl = barrelRecHitsHandle.product();
56 
57  //Get the EE rechit collection
58  edm::Handle<EERecHitCollection> endcapRecHitsHandle;
59  iEvent.getByLabel(EErecHitLabel_, endcapRecHitsHandle);
60  const EERecHitCollection* EEHitsColl = endcapRecHitsHandle.product();
61 
62  //To deal with Geometry
64 
65  //Loop over electrons
66  for (collection::const_iterator ele = (*inputHandle).begin(); ele != (*inputHandle).end(); ++ele) {
67  //Find DetID max hit
68  DetId maxHitId = findMaxHit((*ele).superCluster()->hitsAndFractions(), EBHitsColl, EEHitsColl);
69 
70  if (maxHitId.null()) {
71  std::cout << " Null Id" << std::endl;
72  continue;
73  }
74 
75  // Find 3x3 and 5x5 windows around xtal max and compute E3x3,E5x5
76  double E5x5 = 0.;
77  double E3x3 = 0.;
78 
80  int WindowSize = 5;
81  std::vector<DetId> m5x5aroundMax = topology->getWindow(maxHitId, WindowSize, WindowSize);
82  E5x5 = EnergyNxN(m5x5aroundMax, EBHitsColl, EEHitsColl);
83  WindowSize = 3;
84  std::vector<DetId> m3x3aroundMax = topology->getWindow(maxHitId, WindowSize, WindowSize);
85  E3x3 = EnergyNxN(m3x3aroundMax, EBHitsColl, EEHitsColl);
86 
87  double pin = ele->trackMomentumAtVtx().R();
88  double piMpoOpi = (pin - ele->trackMomentumOut().R()) / pin;
89  double E5x5OPout = E5x5 / ele->trackMomentumOut().R();
90  double E3x3OPin = E3x3 / pin;
91  double E3x3OE5x5 = E3x3 / E5x5;
92  double EseedOPout = ele->eSeedClusterOverPout();
93  double EoPin = ele->eSuperClusterOverP();
94 
95  if (piMpoOpi > PinMPoutOPinMin_ && piMpoOpi < PinMPoutOPinMax_ && EseedOPout > ESeedOPoutMin_ &&
96  EseedOPout < ESeedOPoutMax_ && EoPin > ESCOPinMin_ && EoPin < ESCOPinMax_ && E5x5OPout > E5x5OPoutMin_ &&
97  E5x5OPout < E5x5OPoutMax_ && E3x3OPin > E3x3OPinMin_ && E3x3OPin < E3x3OPinMax_ && E3x3OE5x5 > E3x3OE5x5Min_ &&
98  E3x3OE5x5 < E3x3OE5x5Max_) {
99  selected_.push_back(&(*ele));
100  }
101  }
102 
103  return;
104 }
105 
106 // ------------------------------------------------------------
107 
109 
110 // ------------------------------------------------------------
111 
112 // To find Max Hit
113 DetId SingleEleCalibSelector::findMaxHit(const std::vector<std::pair<DetId, float> >& v1,
114  const EBRecHitCollection* EBhits,
115  const EERecHitCollection* EEhits) {
116  double currEnergy = 0.;
117  DetId maxHit;
118  for (std::vector<std::pair<DetId, float> >::const_iterator idsIt = v1.begin(); idsIt != v1.end(); ++idsIt) {
119  if (idsIt->first.subdetId() == EcalBarrel) {
121  itrechit = EBhits->find((*idsIt).first);
122  if (itrechit == EBhits->end()) {
123  edm::LogInfo("reading") << "[findMaxHit] rechit not found! ";
124  continue;
125  }
126  //FIXME: use fraction ??
127  if (itrechit->energy() > currEnergy) {
128  currEnergy = itrechit->energy();
129  maxHit = (*idsIt).first;
130  }
131  } else {
133  itrechit = EEhits->find((*idsIt).first);
134  if (itrechit == EEhits->end()) {
135  edm::LogInfo("reading") << "[findMaxHit] rechit not found! ";
136  continue;
137  }
138 
139  if (itrechit->energy() > currEnergy) {
140  currEnergy = itrechit->energy();
141  maxHit = (*idsIt).first;
142  }
143  }
144  }
145  return maxHit;
146 }
147 
148 // Energy in a window NxN
149 double SingleEleCalibSelector::EnergyNxN(const std::vector<DetId>& vNxN,
150  const EBRecHitCollection* EBhits,
151  const EERecHitCollection* EEhits) {
152  double dummy = 0.;
153  int window_size = vNxN.size();
154  for (int ixtal = 0; ixtal < window_size; ixtal++) {
155  if (vNxN[ixtal].subdetId() == EcalBarrel) {
157  it_rechit = EBhits->find(vNxN[ixtal]);
158  dummy += it_rechit->energy();
159  } else {
161  it_rechit = EEhits->find(vNxN[ixtal]);
162  dummy += it_rechit->energy();
163  }
164  }
165 
166  return dummy;
167 }
SingleEleCalibSelector::E5x5OPoutMin_
double E5x5OPoutMin_
Definition: SingleEleCalibSelector.h:46
edm::SortedCollection< EcalRecHit >::const_iterator
std::vector< EcalRecHit >::const_iterator const_iterator
Definition: SortedCollection.h:80
edm::Handle::product
T const * product() const
Definition: Handle.h:70
ESHandle.h
CaloTopology::getWindow
std::vector< DetId > getWindow(const DetId &id, const int &northSouthSize, const int &eastWestSize) const
Get the neighbors of the given cell in a window of given size.
Definition: CaloTopology.cc:64
gather_cfg.cout
cout
Definition: gather_cfg.py:144
EBDetId.h
EEDetId.h
edm::LogInfo
Definition: MessageLogger.h:254
SingleEleCalibSelector::ESCOPinMin_
double ESCOPinMin_
Definition: SingleEleCalibSelector.h:46
SingleEleCalibSelector::EnergyNxN
double EnergyNxN(const std::vector< DetId > &vNxN, const EBRecHitCollection *EBhits, const EERecHitCollection *EEhits)
Definition: SingleEleCalibSelector.cc:149
SingleEleCalibSelector::PinMPoutOPinMax_
double PinMPoutOPinMax_
Definition: SingleEleCalibSelector.h:47
edm::SortedCollection< EcalRecHit >
SingleEleCalibSelector.h
DetId::null
constexpr bool null() const
is this a null id ?
Definition: DetId.h:59
CaloTopologyRecord
Definition: CaloTopologyRecord.h:10
SingleEleCalibSelector::E3x3OE5x5Max_
double E3x3OE5x5Max_
Definition: SingleEleCalibSelector.h:47
edm::Handle
Definition: AssociativeIterator.h:50
SingleEleCalibSelector::E5x5OPoutMax_
double E5x5OPoutMax_
Definition: SingleEleCalibSelector.h:47
EcalBarrel
Definition: EcalSubdetector.h:10
EcalRecHitCollections.h
SingleEleCalibSelector::PinMPoutOPinMin_
double PinMPoutOPinMin_
Definition: SingleEleCalibSelector.h:46
SingleEleCalibSelector::EErecHitLabel_
edm::InputTag EErecHitLabel_
Definition: SingleEleCalibSelector.h:49
DetId
Definition: DetId.h:17
edm::EventSetup::get
T get() const
Definition: EventSetup.h:73
ecaldqm::topology
const CaloTopology * topology(nullptr)
SingleEleCalibSelector::ESeedOPoutMax_
double ESeedOPoutMax_
Definition: SingleEleCalibSelector.h:47
SingleEleCalibSelector::E3x3OPinMin_
double E3x3OPinMin_
Definition: SingleEleCalibSelector.h:46
SingleEleCalibSelector::SingleEleCalibSelector
SingleEleCalibSelector(const edm::ParameterSet &iConfig)
ctor
Definition: SingleEleCalibSelector.cc:26
SingleEleCalibSelector::EBrecHitLabel_
edm::InputTag EBrecHitLabel_
Definition: SingleEleCalibSelector.h:48
GsfElectron.h
MTVHistoProducerAlgoForTrackerBlock_cfi.maxHit
maxHit
Definition: MTVHistoProducerAlgoForTrackerBlock_cfi.py:37
DetId::subdetId
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum)
Definition: DetId.h:48
GsfElectronFwd.h
edm::ParameterSet
Definition: ParameterSet.h:36
Event.h
SingleEleCalibSelector::theCaloTopology
edm::ESHandle< CaloTopology > theCaloTopology
the selected collection
Definition: SingleEleCalibSelector.h:38
edm::SortedCollection::end
const_iterator end() const
Definition: SortedCollection.h:267
CaloTopology::getSubdetectorTopology
const CaloSubdetectorTopology * getSubdetectorTopology(const DetId &id) const
access the subdetector Topology for the given subdetector directly
Definition: CaloTopology.cc:17
CaloTopologyRecord.h
iEvent
int iEvent
Definition: GenABIO.cc:224
SingleEleCalibSelector::selected_
container selected_
Definition: SingleEleCalibSelector.h:36
edm::EventSetup
Definition: EventSetup.h:57
CaloSubdetectorTopology
Definition: CaloSubdetectorTopology.h:17
SingleEleCalibSelector::findMaxHit
DetId findMaxHit(const std::vector< std::pair< DetId, float > > &v1, const EBRecHitCollection *EBhits, const EERecHitCollection *EEhits)
Definition: SingleEleCalibSelector.cc:113
SingleEleCalibSelector::ESeedOPoutMin_
double ESeedOPoutMin_
Definition: SingleEleCalibSelector.h:46
DetId::Ecal
Definition: DetId.h:27
get
#define get
SingleEleCalibSelector::select
void select(edm::Handle< collection >, const edm::Event &, const edm::EventSetup &)
Definition: SingleEleCalibSelector.cc:47
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
CaloSubdetectorTopology.h
edm::SortedCollection::find
iterator find(key_type k)
Definition: SortedCollection.h:240
DetId.h
CaloGeometry.h
ParameterAdapter.h
SingleEleCalibSelector::~SingleEleCalibSelector
~SingleEleCalibSelector()
dtor
Definition: SingleEleCalibSelector.cc:108
SingleEleCalibSelector::E3x3OPinMax_
double E3x3OPinMax_
Definition: SingleEleCalibSelector.h:47
dummy
Definition: DummySelector.h:38
edm::Event
Definition: Event.h:73
SingleEleCalibSelector::E3x3OE5x5Min_
double E3x3OE5x5Min_
Definition: SingleEleCalibSelector.h:46
edm::InputTag
Definition: InputTag.h:15
SingleEleCalibSelector::ESCOPinMax_
double ESCOPinMax_
Definition: SingleEleCalibSelector.h:47
SingleEleCalibSelector::const_iterator
container::const_iterator const_iterator
Definition: SingleEleCalibSelector.h:23