CMS 3D CMS Logo

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