CMS 3D CMS Logo

AlCaElectronsTest.h
Go to the documentation of this file.
1 // system include files
2 #include <memory>
3 #include <string>
4 #include <iostream>
5 #include <algorithm>
6 
7 // user include files
15 //#include "Calibration/EcalAlCaRecoProducers/interface/AlCaElectronsProducer.h"
25 
26 
27 #include "TFile.h"
28 #include "TH1.h"
29 #include "TH2.h"
30 
31 #include <Math/VectorUtil.h>
32 
34  public:
35  explicit AlCaElectronsTest (const edm::ParameterSet&) ;
37  virtual void analyze (const edm::Event& iEvent,
38  const edm::EventSetup& iSetup) ;
39  virtual void beginJob() ;
40  virtual void endJob () ;
41 
42  private:
43 
45  void fillAroundBarrel (const EcalRecHitCollection * recHits, int eta, int phi) ;
46  void fillAroundEndcap (const EcalRecHitCollection * recHits, int ics, int ips) ;
47 
48 
49  private:
50 
54 
75 } ;
76 
77 
78 // ----------------------------------------------------------------
79 
80 
82  m_barrelAlCa (consumes<EBRecHitCollection>(iConfig.getParameter<edm::InputTag> ("alcaBarrelHitCollection"))) ,
83  m_endcapAlCa (consumes<EERecHitCollection>(iConfig.getParameter<edm::InputTag> ("alcaEndcapHitCollection"))) ,
84  m_outputFileName (iConfig.getUntrackedParameter<std::string>
85  ("HistOutFile",std::string ("AlCaElectronsTest.root")))
86 {}
87 
88 
89 // ----------------------------------------------------------------
90 
91 
92 void
94 {
95  m_barrelGlobalCrystalsMap = new TH2F ("m_barrelGlobalCrystalsMap","m_barrelGlobalCrystalsMap",171,-85,86,360,0,360) ;
96  m_barrelLocalCrystalsMap = new TH2F ("m_barrelLocalCrystalsMap","m_barrelLocalCrystalsMap",20,-10,10,20,-10,10) ;
97  m_endcapGlobalCrystalsMap = new TH2F ("m_endcapGlobalCrystalsMap","m_endcapGlobalCrystalsMap",100,0,100,100,0,100) ;
98  m_endcapLocalCrystalsMap = new TH2F ("m_endcapLocalCrystalsMap","m_endcapLocalCrystalsMap",20,-10,10,20,-10,10) ;
99  m_barrelGlobalCrystalsEnergy = new TH2F ("m_barrelGlobalCrystalsEnergy","m_barrelGlobalCrystalsEnergy",171,-85,86,360,0,360) ;
100  m_barrelLocalCrystalsEnergy = new TH2F ("m_barrelLocalCrystalsEnergy","m_barrelLocalCrystalsEnergy",20,-10,10,20,-10,10) ;
101  m_endcapGlobalCrystalsEnergy = new TH2F ("m_endcapGlobalCrystalsEnergy","m_endcapGlobalCrystalsEnergy",100,0,100,100,0,100) ;
102  m_endcapLocalCrystalsEnergy = new TH2F ("m_endcapLocalCrystalsEnergy","m_endcapLocalCrystalsEnergy",20,-10,10,20,-10,10) ;
103  m_barrelGlobalCrystalsEnergyMap = new TH2F ("m_barrelGlobalCrystalsEnergyMap","m_barrelGlobalCrystalsEnergyMap",171,-85,86,360,0,360) ;
104  m_endcapGlobalCrystalsEnergyMap = new TH2F ("m_endcapGlobalCrystalsEnergyMap","m_endcapGlobalCrystalsEnergyMap",100,0,100,100,0,100) ;
105  return ;
106 }
107 
108 
109 // ----------------------------------------------------------------
110 
111 
112 void
114 {
115  TFile output (m_outputFileName.c_str (),"recreate") ;
116  m_barrelGlobalCrystalsMap->Write () ;
117  m_barrelLocalCrystalsMap->Write () ;
118  m_endcapGlobalCrystalsMap->Write () ;
119  m_endcapLocalCrystalsMap->Write () ;
120  m_barrelGlobalCrystalsEnergy->Write () ;
121  m_barrelLocalCrystalsEnergy->Write () ;
122  m_endcapGlobalCrystalsEnergy->Write () ;
123  m_endcapLocalCrystalsEnergy->Write () ;
126  output.Close () ;
127  //PG save root things
128  return ;
129 }
130 
131 
132 // ----------------------------------------------------------------
133 
134 
135 void
137  const edm::EventSetup& iSetup)
138 {
139  //FIXME replace with msg logger
140  std::cout << "[AlCaElectronsTest] analysing event "
141  << iEvent.id () << std::endl ;
142 
143  //PG get the collections
144  // get Barrel RecHits
145  edm::Handle<EBRecHitCollection> barrelRecHitsHandle ;
146  iEvent.getByToken (m_barrelAlCa, barrelRecHitsHandle) ;
147  if (!barrelRecHitsHandle.isValid()) {
150  std::cerr << "[AlCaElectronsTest] caught std::exception "
151  << " in rertieving " << labels.module
152  << std::endl ;
153  return ;
154  } else {
155  const EBRecHitCollection* barrelHitsCollection = barrelRecHitsHandle.product () ;
156  //PG fill the histo with the maximum
157  EcalRecHit barrelMax = getMaximum (barrelHitsCollection) ;
158  EBDetId barrelMaxId (barrelMax.id ()) ;
160  barrelMaxId.ieta () ,
161  barrelMaxId.iphi ()
162  ) ;
164  barrelMaxId.ieta () ,
165  barrelMaxId.iphi () ,
166  barrelMax.energy ()
167  ) ;
169  barrelHitsCollection,
170  barrelMaxId.ieta (),
171  barrelMaxId.iphi ()
172  ) ;
173  }
174 
175  // get Endcap RecHits
176  edm::Handle<EERecHitCollection> endcapRecHitsHandle ;
177  iEvent.getByToken (m_endcapAlCa,endcapRecHitsHandle) ;
178  if (!endcapRecHitsHandle.isValid()) {
181  std::cerr << "[AlCaElectronsTest] caught std::exception "
182  << " in rertieving " << labels.module
183  << std::endl ;
184  return ;
185  } else {
186  const EERecHitCollection* endcapHitsCollection = endcapRecHitsHandle.product () ;
187  //PG fill the histo with the maximum
188  EcalRecHit endcapMax = getMaximum (endcapHitsCollection) ;
189  EEDetId endcapMaxId (endcapMax.id ()) ;
191  endcapMaxId.ix () ,
192  endcapMaxId.iy ()
193  ) ;
195  endcapMaxId.ix () ,
196  endcapMaxId.iy () ,
197  endcapMax.energy ()
198  ) ;
200  endcapHitsCollection,
201  endcapMaxId.ix (),
202  endcapMaxId.iy ()
203  ) ;
204  }
205 }
206 
207 
208 // ----------------------------------------------------------------
209 
210 
213 {
214  double energy = 0. ;
215  EcalRecHit max ;
216  for (EcalRecHitCollection::const_iterator elem = recHits->begin () ;
217  elem != recHits->end () ;
218  ++elem)
219  {
220  if (elem->energy () > energy)
221  {
222  energy = elem->energy () ;
223  max = *elem ;
224  }
225  }
226  return max ;
227 }
228 
229 
230 // ----------------------------------------------------------------
231 
232 
233 void
235 {
236  for (EcalRecHitCollection::const_iterator elem = recHits->begin () ;
237  elem != recHits->end () ;
238  ++elem)
239  {
240  EBDetId elementId = elem->id () ;
242  elementId.ieta () - eta ,
243  elementId.iphi () - phi
244  ) ;
246  elementId.ieta () - eta ,
247  elementId.iphi () - phi ,
248  elem->energy ()
249  ) ;
251  elementId.ieta () ,
252  elementId.iphi () ,
253  elem->energy ()
254  ) ;
255 
256  }
257  return ;
258 }
259 
260 
261 // ----------------------------------------------------------------
262 
263 
264 void
266 {
267  for (EcalRecHitCollection::const_iterator elem = recHits->begin () ;
268  elem != recHits->end () ;
269  ++elem)
270  {
271  EEDetId elementId = elem->id () ;
273  elementId.ix () - ics ,
274  elementId.iy () - ips
275  ) ;
277  elementId.ix () - ics ,
278  elementId.iy () - ips ,
279  elem->energy ()
280  ) ;
282  elementId.ix () ,
283  elementId.iy () ,
284  elem->energy ()
285  ) ;
286  }
287  return ;
288 }
AlCaElectronsTest::fillAroundBarrel
void fillAroundBarrel(const EcalRecHitCollection *recHits, int eta, int phi)
Definition: AlCaElectronsTest.h:234
AlCaElectronsTest::m_barrelLocalCrystalsEnergy
TH2F * m_barrelLocalCrystalsEnergy
local Energy
Definition: AlCaElectronsTest.h:66
SummaryClient_cfi.labels
labels
Definition: SummaryClient_cfi.py:61
EcalRecHit
Definition: EcalRecHit.h:15
EBDetId::ieta
int ieta() const
get the crystal ieta
Definition: EBDetId.h:49
edm::SortedCollection< EcalRecHit >::const_iterator
std::vector< EcalRecHit >::const_iterator const_iterator
Definition: SortedCollection.h:80
MessageLogger.h
AlCaElectronsTest::m_endcapGlobalCrystalsEnergy
TH2F * m_endcapGlobalCrystalsEnergy
ECAL Energy.
Definition: AlCaElectronsTest.h:68
edm::Handle::product
T const * product() const
Definition: Handle.h:70
EcalRecHit::id
DetId id() const
get the id
Definition: EcalRecHit.h:77
convertSQLitetoXML_cfg.output
output
Definition: convertSQLitetoXML_cfg.py:72
AlCaElectronsTest::beginJob
virtual void beginJob()
Definition: AlCaElectronsTest.h:93
BasicCluster.h
edm::EDGetTokenT
Definition: EDGetToken.h:33
AlCaElectronsTest::m_endcapLocalCrystalsMap
TH2F * m_endcapLocalCrystalsMap
local map
Definition: AlCaElectronsTest.h:62
EBDetId
Definition: EBDetId.h:17
edm
HLT enums.
Definition: AlignableModifier.h:19
SiStripElectron.h
gather_cfg.cout
cout
Definition: gather_cfg.py:144
AlCaElectronsTest
Definition: AlCaElectronsTest.h:33
EBDetId.h
EEDetId.h
HLT_FULL_cff.InputTag
InputTag
Definition: HLT_FULL_cff.py:89301
edm::SortedCollection< EcalRecHit >
mathSSE::return
return((rh ^ lh) &mask)
EDAnalyzer.h
AlCaElectronsTest::m_outputFileName
std::string m_outputFileName
Definition: AlCaElectronsTest.h:53
EcalRecHit::energy
float energy() const
Definition: EcalRecHit.h:68
AlCaElectronsTest::m_endcapGlobalCrystalsEnergyMap
TH2F * m_endcapGlobalCrystalsEnergyMap
ECAL EnergyMap.
Definition: AlCaElectronsTest.h:74
EEDetId::ix
int ix() const
Definition: EEDetId.h:77
edm::Handle
Definition: AssociativeIterator.h:50
EcalRecHitCollections.h
edm::EDAnalyzer
Definition: EDAnalyzer.h:28
MakerMacros.h
AlCaElectronsTest::endJob
virtual void endJob()
Definition: AlCaElectronsTest.h:113
PVValHelper::eta
Definition: PVValidationHelpers.h:70
AlCaElectronsTest::m_barrelGlobalCrystalsMap
TH2F * m_barrelGlobalCrystalsMap
ECAL map.
Definition: AlCaElectronsTest.h:56
HCALHighEnergyHPDFilter_cfi.energy
energy
Definition: HCALHighEnergyHPDFilter_cfi.py:5
AlCaElectronsTest::fillAroundEndcap
void fillAroundEndcap(const EcalRecHitCollection *recHits, int ics, int ips)
Definition: AlCaElectronsTest.h:265
EDGetToken.h
AlCaElectronsTest::m_endcapAlCa
edm::EDGetTokenT< EERecHitCollection > m_endcapAlCa
Definition: AlCaElectronsTest.h:52
EEDetId
Definition: EEDetId.h:14
FastTrackerRecHitMaskProducer_cfi.recHits
recHits
Definition: FastTrackerRecHitMaskProducer_cfi.py:8
ElectronFwd.h
edm::ParameterSet
Definition: ParameterSet.h:47
Event.h
PVValHelper::phi
Definition: PVValidationHelpers.h:69
SiStripPI::max
Definition: SiStripPayloadInspectorHelper.h:169
AlCaElectronsTest::m_endcapLocalCrystalsEnergy
TH2F * m_endcapLocalCrystalsEnergy
local Energy
Definition: AlCaElectronsTest.h:70
iEvent
int iEvent
Definition: GenABIO.cc:224
edm::EventSetup
Definition: EventSetup.h:58
EEDetId::iy
int iy() const
Definition: EEDetId.h:83
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::EDConsumerBase::labelsForToken
void labelsForToken(EDGetToken iToken, Labels &oLabels) const
Definition: EDConsumerBase.cc:338
DDAxes::phi
Electron.h
std
Definition: JetResolutionObject.h:76
AlCaElectronsTest::m_barrelLocalCrystalsMap
TH2F * m_barrelLocalCrystalsMap
local map
Definition: AlCaElectronsTest.h:58
AlCaElectronsTest::~AlCaElectronsTest
~AlCaElectronsTest()
Definition: AlCaElectronsTest.h:36
AlCaElectronsTest::getMaximum
EcalRecHit getMaximum(const EcalRecHitCollection *recHits)
Definition: AlCaElectronsTest.h:212
Frameworkfwd.h
SuperCluster.h
EventSetup.h
AlCaElectronsTest::m_barrelGlobalCrystalsEnergy
TH2F * m_barrelGlobalCrystalsEnergy
ECAL Energy.
Definition: AlCaElectronsTest.h:64
Ecal07UnpackerData_cfi.ics
ics
Definition: Ecal07UnpackerData_cfi.py:55
AlCaElectronsTest::m_barrelGlobalCrystalsEnergyMap
TH2F * m_barrelGlobalCrystalsEnergyMap
ECAL EnergyMap.
Definition: AlCaElectronsTest.h:72
EBDetId::iphi
int iphi() const
get the crystal iphi
Definition: EBDetId.h:51
AlCaElectronsTest::analyze
virtual void analyze(const edm::Event &iEvent, const edm::EventSetup &iSetup)
Definition: AlCaElectronsTest.h:136
ParameterSet.h
edm::HandleBase::isValid
bool isValid() const
Definition: HandleBase.h:70
AlCaElectronsTest::m_endcapGlobalCrystalsMap
TH2F * m_endcapGlobalCrystalsMap
ECAL map.
Definition: AlCaElectronsTest.h:60
edm::Event
Definition: Event.h:73
EcnaPython_AdcPeg12_S1_10_R170298_1_0_150_Dee0.cerr
cerr
Definition: EcnaPython_AdcPeg12_S1_10_R170298_1_0_150_Dee0.py:8
AlCaElectronsTest::m_barrelAlCa
edm::EDGetTokenT< EBRecHitCollection > m_barrelAlCa
Definition: AlCaElectronsTest.h:51
edm::ProductLabels
Definition: ProductLabels.h:4
AlCaElectronsTest::AlCaElectronsTest
AlCaElectronsTest(const edm::ParameterSet &)
Definition: AlCaElectronsTest.h:81