18 : g4InfoLabel(ps.getParameter<
std::
string>(
"moduleLabelG4")),
41 dbe_->showDirStructure();
71 for (
int myStep = 0; myStep < 26; myStep++) {
78 dbe_->setCurrentFolder(
"EcalHitsV/EcalSimHitsValidation");
80 sprintf(histo,
"EB hits multiplicity");
81 menEBHits_ = dbe_->book1D(histo, histo, 50, 0., 5000.);
83 sprintf(histo,
"EB crystals multiplicity");
86 sprintf(histo,
"EB occupancy");
87 meEBOccupancy_ = dbe_->book2D(histo, histo, 360, 0., 360., 170, -85., 85.);
89 sprintf(histo,
"EB longitudinal shower profile");
92 sprintf(histo,
"EB hits energy spectrum");
95 sprintf(histo,
"EB hits log10energy spectrum");
98 sprintf(histo,
"EB hits log10energy spectrum vs normalized energy");
101 sprintf(histo,
"EB hits log10energy spectrum vs normalized energy25");
104 sprintf(histo,
"EB hits energy spectrum 2");
107 sprintf(histo,
"EB crystal energy spectrum");
110 sprintf(histo,
"EB crystal energy spectrum 2");
113 sprintf(histo,
"EB E1");
114 meEBe1_ = dbe_->book1D(histo, histo, 400, 0., 400.);
116 sprintf(histo,
"EB E4");
117 meEBe4_ = dbe_->book1D(histo, histo, 400, 0., 400.);
119 sprintf(histo,
"EB E9");
120 meEBe9_ = dbe_->book1D(histo, histo, 400, 0., 400.);
122 sprintf(histo,
"EB E16");
123 meEBe16_ = dbe_->book1D(histo, histo, 400, 0., 400.);
125 sprintf(histo,
"EB E25");
126 meEBe25_ = dbe_->book1D(histo, histo, 400, 0., 400.);
128 sprintf(histo,
"EB E1oE4");
129 meEBe1oe4_ = dbe_->book1D(histo, histo, 100, 0.4, 1.1);
131 sprintf(histo,
"EB E1oE9");
132 meEBe1oe9_ = dbe_->book1D(histo, histo, 100, 0.4, 1.1);
134 sprintf(histo,
"EB E4oE9");
135 meEBe4oe9_ = dbe_->book1D(histo, histo, 100, 0.4, 1.1);
137 sprintf(histo,
"EB E9oE16");
138 meEBe9oe16_ = dbe_->book1D(histo, histo, 100, 0.4, 1.1);
140 sprintf(histo,
"EB E1oE25");
141 meEBe1oe25_ = dbe_->book1D(histo, histo, 100, 0.4, 1.1);
143 sprintf(histo,
"EB E9oE25");
144 meEBe9oe25_ = dbe_->book1D(histo, histo, 100, 0.4, 1.1);
146 sprintf(histo,
"EB E16oE25");
147 meEBe16oe25_ = dbe_->book1D(histo, histo, 100, 0.4, 1.1);
175 std::vector<PCaloHit> theEBCaloHits;
176 theEBCaloHits.insert(theEBCaloHits.end(), EcalHitsEB->begin(), EcalHitsEB->end());
180 double EBEnergy_ = 0.;
181 std::map<unsigned int, std::vector<PCaloHit *>, std::less<unsigned int>> CaloHitMap;
188 std::vector<double> econtr(140, 0.);
189 std::vector<double> econtr25(140, 0.);
192 uint32_t nEBHits = 0;
194 for (std::vector<PCaloHit>::iterator isim = theEBCaloHits.begin(); isim != theEBCaloHits.end(); ++isim) {
195 if (isim->time() > 500.) {
199 CaloHitMap[isim->id()].push_back(&(*isim));
203 LogDebug(
"HitInfo") <<
" CaloHit " << isim->getName() <<
"\n" 204 <<
" DetID = " << isim->id() <<
" EBDetId = " << ebid.ieta() <<
" " << ebid.iphi() <<
"\n" 205 <<
" Time = " << isim->time() <<
"\n" 206 <<
" Track Id = " << isim->geantTrackId() <<
"\n" 207 <<
" Energy = " << isim->energy();
212 uint32_t crystid = ebid.rawId();
213 ebmap[crystid] += isim->energy();
215 EBEnergy_ += isim->energy();
218 if (isim->energy() > 0) {
220 int log10i =
int((log10(isim->energy()) + 10.) * 10.);
221 if (log10i >= 0 && log10i < 140)
222 econtr[log10i] += isim->energy();
230 for (
std::map<uint32_t,
float, std::less<uint32_t>>::iterator it = ebmap.begin(); it != ebmap.end(); ++it)
234 for (
std::map<uint32_t,
float, std::less<uint32_t>>::iterator it = ebmap.begin(); it != ebmap.end(); ++it)
245 int by = myEBid.
iphi();
246 int bz = myEBid.
zside();
257 std::vector<uint32_t> ids25;
260 for (
unsigned i = 0;
i < 25;
i++) {
261 for (
unsigned int j = 0; j < CaloHitMap[ids25[
i]].size(); j++) {
262 if (CaloHitMap[ids25[
i]][j]->
energy() > 0) {
263 int log10i =
int((log10(CaloHitMap[ids25[
i]][j]->
energy()) + 10.) * 10.);
264 if (log10i >= 0 && log10i < 140)
265 econtr25[log10i] += CaloHitMap[ids25[
i]][j]->energy();
298 for (
int i = 0;
i < 140;
i++) {
304 for (
int i = 0;
i < 140;
i++) {
310 if (MyPEcalValidInfo.
isValid()) {
311 if (MyPEcalValidInfo->
eb1x1() > 0.) {
312 std::vector<float> BX0 = MyPEcalValidInfo->
bX0();
315 for (
int myStep = 0; myStep < 26; myStep++) {
325 int nCellInEta,
int nCellInPhi,
int centralEta,
int centralPhi,
int centralZ,
MapType &themap) {
327 float totalEnergy = 0.;
329 int goBackInEta = nCellInEta / 2;
330 int goBackInPhi = nCellInPhi / 2;
331 int startEta = centralZ * centralEta - goBackInEta;
332 int startPhi = centralPhi - goBackInPhi;
334 for (
int ieta = startEta; ieta < startEta + nCellInEta; ieta++) {
335 for (
int iphi = startPhi; iphi < startPhi + nCellInPhi; iphi++) {
337 if (
abs(ieta) > 85 ||
abs(ieta) < 1) {
342 }
else if (iphi > 360) {
348 totalEnergy += themap[
index];
353 LogDebug(
"GeomInfo") << nCellInEta <<
" x " << nCellInPhi <<
" EB matrix energy = " << totalEnergy <<
" for " 354 << ncristals <<
" crystals";
359 int nCellInEta,
int nCellInPhi,
int centralEta,
int centralPhi,
int centralZ,
MapType &themap) {
361 std::vector<uint32_t>
ids(nCellInEta * nCellInPhi);
363 int goBackInEta = nCellInEta / 2;
364 int goBackInPhi = nCellInPhi / 2;
365 int startEta = centralZ * centralEta - goBackInEta;
366 int startPhi = centralPhi - goBackInPhi;
368 for (
int ieta = startEta; ieta < startEta + nCellInEta; ieta++) {
369 for (
int iphi = startPhi; iphi < startPhi + nCellInPhi; iphi++) {
371 if (
abs(ieta) > 85 ||
abs(ieta) < 1) {
376 }
else if (iphi > 360) {
381 ids[ncristals] =
index;
390 int nCellInEta,
int nCellInPhi,
int CentralEta,
int CentralPhi,
int CentralZ,
MapType &fillmap,
MapType &themap) {
391 int goBackInEta = nCellInEta / 2;
392 int goBackInPhi = nCellInPhi / 2;
394 int startEta = CentralZ * CentralEta - goBackInEta;
395 int startPhi = CentralPhi - goBackInPhi;
398 for (
int ieta = startEta; ieta < startEta + nCellInEta; ieta++) {
399 for (
int iphi = startPhi; iphi < startPhi + nCellInPhi; iphi++) {
401 if (
abs(ieta) > 85 ||
abs(ieta) < 1) {
406 }
else if (iphi > 360) {
411 fillmap[i++] = themap[
index];
417 if (fillmap[i / 2] == themap[ebcenterid])
425 float e012 = themap[0] + themap[1] + themap[2];
426 float e036 = themap[0] + themap[3] + themap[6];
427 float e678 = themap[6] + themap[7] + themap[8];
428 float e258 = themap[2] + themap[5] + themap[8];
430 if ((e012 > e678 || e012 == e678) && (e036 > e258 || e036 == e258))
431 return E22 = themap[0] + themap[1] + themap[3] + themap[4];
432 else if ((e012 > e678 || e012 == e678) && (e036 < e258 || e036 == e258))
433 return E22 = themap[1] + themap[2] + themap[4] + themap[5];
434 else if ((e012 < e678 || e012 == e678) && (e036 > e258 || e036 == e258))
435 return E22 = themap[3] + themap[4] + themap[6] + themap[7];
436 else if ((e012 < e678 || e012 == e678) && (e036 < e258 || e036 == e258))
437 return E22 = themap[4] + themap[5] + themap[7] + themap[8];
445 float e0_4 = themap[0] + themap[1] + themap[2] + themap[3] + themap[4];
446 float e0_20 = themap[0] + themap[5] + themap[10] + themap[15] + themap[20];
447 float e4_24 = themap[4] + themap[9] + themap[14] + themap[19] + themap[24];
448 float e0_24 = themap[20] + themap[21] + themap[22] + themap[23] + themap[24];
450 if ((e0_4 > e0_24 || e0_4 == e0_24) && (e0_20 > e4_24 || e0_20 == e4_24))
451 return E44 = e33 + themap[0] + themap[1] + themap[2] + themap[3] + themap[5] + themap[10] + themap[15];
452 else if ((e0_4 > e0_24 || e0_4 == e0_24) && (e0_20 < e4_24 || e0_20 == e4_24))
453 return E44 = e33 + themap[1] + themap[2] + themap[3] + themap[4] + themap[9] + themap[14] + themap[19];
454 else if ((e0_4 < e0_24 || e0_4 == e0_24) && (e0_20 > e4_24 || e0_20 == e4_24))
455 return E44 = e33 + themap[5] + themap[10] + themap[15] + themap[20] + themap[21] + themap[22] + themap[23];
456 else if ((e0_4 < e0_24 || e0_4 == e0_24) && (e0_20 < e4_24 || e0_20 == e4_24))
457 return E44 = e33 + themap[21] + themap[22] + themap[23] + themap[24] + themap[9] + themap[14] + themap[19];
465 uint32_t unitWithMaxEnergy = 0;
468 MapType::iterator iter;
469 for (iter = themap.begin(); iter != themap.end(); iter++) {
470 if (maxEnergy < (*iter).second) {
471 maxEnergy = (*iter).second;
472 unitWithMaxEnergy = (*iter).first;
476 LogDebug(
"GeomInfo") <<
" max energy of " << maxEnergy <<
" GeV in Unit id " << unitWithMaxEnergy;
477 return unitWithMaxEnergy;
EventNumber_t event() const
T getUntrackedParameter(std::string const &, T const &) const
std::vector< uint32_t > getIdsAroundMax(int nCellInEta, int nCellInPhi, int centralEta, int centralPhi, int centralZ, MapType &themap)
MonitorElement * meEBhitLog10Energy_
MonitorElement * meEBe16oe25_
MonitorElement * meEBe16_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
void endJob(void) override
MonitorElement * meEBe9oe16_
MonitorElement * meEBe1oe9_
constexpr uint32_t rawId() const
get the raw id
MonitorElement * meEBhitLog10EnergyNorm_
MonitorElement * meEBe9oe25_
MonitorElement * menEBCrystals_
MonitorElement * meEBe25_
MonitorElement * meEBhitLog10Energy25Norm_
MonitorElement * menEBHits_
int iphi() const
get the crystal iphi
float eCluster4x4(float e33, MapType &themap)
MonitorElement * meEBe1oe4_
std::string ValidationCollection
MonitorElement * meEBLongitudinalShower_
~EcalBarrelSimHitsValidation() override
Destructor.
std::map< uint32_t, float, std::less< uint32_t > > MapType
Abs< T >::type abs(const T &t)
edm::EDGetTokenT< edm::PCaloHitContainer > EBHitsToken
void Reset()
reset ME (ie. contents, errors, etc)
edm::EDGetTokenT< PEcalValidInfo > ValidationCollectionToken
MonitorElement * meEBe4oe9_
uint32_t getUnitWithMaxEnergy(MapType &themap)
Namespace of DDCMS conversion namespace.
virtual float energyInMatrixEB(int nCellInEta, int nCellInPhi, int centralEta, int centralPhi, int centralZ, MapType &themap)
MonitorElement * meEBcrystalEnergy2_
std::string EBHitsCollection
MonitorElement * meEBhitEnergy2_
float eCluster2x2(MapType &themap)
bool fillEBMatrix(int nCellInEta, int nCellInPhi, int CentralEta, int CentralPhi, int CentralZ, MapType &fillmap, MapType &themap)
MonitorElement * meEBOccupancy_
int ietaAbs() const
get the absolute value of the crystal ieta
void analyze(const edm::Event &e, const edm::EventSetup &c) override
Analyze.
MonitorElement * meEBcrystalEnergy_
MonitorElement * meEBhitEnergy_
int zside() const
get the z-side of the crystal (1/-1)
EcalBarrelSimHitsValidation(const edm::ParameterSet &ps)
Constructor.
MonitorElement * meEBe1oe25_