CMS 3D CMS Logo

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