18 : g4InfoLabel(ps.getParameter<
std::
string>(
"moduleLabelG4")),
34 dbe_->showDirStructure();
67 for (
int myStep = 0; myStep < 26; myStep++) {
74 dbe_->setCurrentFolder(
"EcalHitsV/EcalSimHitsValidation");
76 sprintf(histo,
"EE+ hits multiplicity");
77 meEEzpHits_ = dbe_->book1D(histo, histo, 50, 0., 5000.);
79 sprintf(histo,
"EE- hits multiplicity");
80 meEEzmHits_ = dbe_->book1D(histo, histo, 50, 0., 5000.);
82 sprintf(histo,
"EE+ crystals multiplicity");
85 sprintf(histo,
"EE- crystals multiplicity");
88 sprintf(histo,
"EE+ occupancy");
91 sprintf(histo,
"EE- occupancy");
94 sprintf(histo,
"EE longitudinal shower profile");
97 sprintf(histo,
"EE hits energy spectrum");
100 sprintf(histo,
"EE hits log10energy spectrum");
103 sprintf(histo,
"EE hits log10energy spectrum vs normalized energy");
106 sprintf(histo,
"EE hits log10energy spectrum vs normalized energy25");
109 sprintf(histo,
"EE hits energy spectrum 2");
112 sprintf(histo,
"EE crystal energy spectrum");
115 sprintf(histo,
"EE crystal energy spectrum 2");
118 sprintf(histo,
"EE E1");
119 meEEe1_ = dbe_->book1D(histo, histo, 400, 0., 400.);
121 sprintf(histo,
"EE E4");
122 meEEe4_ = dbe_->book1D(histo, histo, 400, 0., 400.);
124 sprintf(histo,
"EE E9");
125 meEEe9_ = dbe_->book1D(histo, histo, 400, 0., 400.);
127 sprintf(histo,
"EE E16");
128 meEEe16_ = dbe_->book1D(histo, histo, 400, 0., 400.);
130 sprintf(histo,
"EE E25");
131 meEEe25_ = dbe_->book1D(histo, histo, 400, 0., 400.);
133 sprintf(histo,
"EE E1oE4");
134 meEEe1oe4_ = dbe_->book1D(histo, histo, 100, 0.4, 1.1);
136 sprintf(histo,
"EE E1oE9");
137 meEEe1oe9_ = dbe_->book1D(histo, histo, 100, 0.4, 1.1);
139 sprintf(histo,
"EE E4oE9");
140 meEEe4oe9_ = dbe_->book1D(histo, histo, 100, 0.4, 1.1);
142 sprintf(histo,
"EE E9oE16");
143 meEEe9oe16_ = dbe_->book1D(histo, histo, 100, 0.4, 1.1);
145 sprintf(histo,
"EE E1oE25");
146 meEEe1oe25_ = dbe_->book1D(histo, histo, 100, 0.4, 1.1);
148 sprintf(histo,
"EE E9oE25");
149 meEEe9oe25_ = dbe_->book1D(histo, histo, 100, 0.4, 1.1);
151 sprintf(histo,
"EE E16oE25");
152 meEEe16oe25_ = dbe_->book1D(histo, histo, 100, 0.4, 1.1);
180 std::vector<PCaloHit> theEECaloHits;
181 theEECaloHits.insert(theEECaloHits.end(), EcalHitsEE->begin(), EcalHitsEE->end());
185 std::map<unsigned int, std::vector<PCaloHit *>, std::less<unsigned int>> CaloHitMap;
195 std::vector<double> econtr(140, 0.);
196 std::vector<double> econtr25(140, 0.);
201 uint32_t nEEzpHits = 0;
202 uint32_t nEEzmHits = 0;
204 for (std::vector<PCaloHit>::iterator isim = theEECaloHits.begin(); isim != theEECaloHits.end(); ++isim) {
205 if (isim->time() > 500.) {
209 CaloHitMap[isim->id()].push_back(&(*isim));
213 LogDebug(
"HitInfo") <<
" CaloHit " << isim->getName() <<
"\n" 214 <<
" DetID = " << isim->id() <<
" EEDetId = " << eeid.ix() <<
" " << eeid.iy() <<
"\n" 215 <<
" Time = " << isim->time() <<
"\n" 216 <<
" Track Id = " << isim->geantTrackId() <<
"\n" 217 <<
" Energy = " << isim->energy();
219 uint32_t crystid = eeid.rawId();
221 if (eeid.zside() > 0) {
223 EEetzp_ += isim->energy();
224 eemapzp[crystid] += isim->energy();
227 }
else if (eeid.zside() < 0) {
229 EEetzm_ += isim->energy();
230 eemapzm[crystid] += isim->energy();
237 if (isim->energy() > 0) {
240 int log10i =
int((log10(isim->energy()) + 10.) * 10.);
241 if (log10i >= 0 && log10i < 140)
242 econtr[log10i] += isim->energy();
246 eemap[crystid] += isim->energy();
255 for (
std::map<uint32_t,
float, std::less<uint32_t>>::iterator it = eemap.begin(); it != eemap.end(); ++it)
259 for (
std::map<uint32_t,
float, std::less<uint32_t>>::iterator it = eemap.begin(); it != eemap.end(); ++it)
268 int nEEHits = nEEzmHits + nEEzpHits;
272 int bx = myEEid.
ix();
273 int by = myEEid.
iy();
274 int bz = myEEid.
zside();
285 std::vector<uint32_t> ids25;
288 for (
unsigned i = 0;
i < 25;
i++) {
289 for (
unsigned int j = 0;
j < CaloHitMap[ids25[
i]].size();
j++) {
290 if (CaloHitMap[ids25[
i]][
j]->
energy() > 0) {
291 int log10i =
int((log10(CaloHitMap[ids25[
i]][
j]->
energy()) + 10.) * 10.);
292 if (log10i >= 0 && log10i < 140)
293 econtr25[log10i] += CaloHitMap[ids25[
i]][
j]->energy();
326 for (
int i = 0;
i < 140;
i++) {
332 for (
int i = 0;
i < 140;
i++) {
338 if (MyPEcalValidInfo.
isValid()) {
339 if (MyPEcalValidInfo->
ee1x1() > 0.) {
340 std::vector<float> EX0 = MyPEcalValidInfo->
eX0();
343 for (
int myStep = 0; myStep < 26; myStep++) {
353 int nCellInX,
int nCellInY,
int centralX,
int centralY,
int centralZ,
MapType &themap) {
355 float totalEnergy = 0.;
357 int goBackInX = nCellInX / 2;
358 int goBackInY = nCellInY / 2;
359 int startX = centralX - goBackInX;
360 int startY = centralY - goBackInY;
362 for (
int ix = startX; ix < startX + nCellInX; ix++) {
363 for (
int iy = startY; iy < startY + nCellInY; iy++) {
372 totalEnergy += themap[
index];
377 LogDebug(
"GeomInfo") << nCellInX <<
" x " << nCellInY <<
" EE matrix energy = " << totalEnergy <<
" for " << ncristals
383 int nCellInX,
int nCellInY,
int centralX,
int centralY,
int centralZ,
MapType &themap) {
385 std::vector<uint32_t>
ids(nCellInX * nCellInY);
387 int goBackInX = nCellInX / 2;
388 int goBackInY = nCellInY / 2;
389 int startX = centralX - goBackInX;
390 int startY = centralY - goBackInY;
392 for (
int ix = startX; ix < startX + nCellInX; ix++) {
393 for (
int iy = startY; iy < startY + nCellInY; iy++) {
402 ids[ncristals] =
index;
411 int nCellInX,
int nCellInY,
int CentralX,
int CentralY,
int CentralZ,
MapType &fillmap,
MapType &themap) {
412 int goBackInX = nCellInX / 2;
413 int goBackInY = nCellInY / 2;
415 int startX = CentralX - goBackInX;
416 int startY = CentralY - goBackInY;
419 for (
int ix = startX; ix < startX + nCellInX; ix++) {
420 for (
int iy = startY; iy < startY + nCellInY; iy++) {
428 fillmap[i++] = themap[
index];
433 if (fillmap[i / 2] == themap[centerid])
441 float e012 = themap[0] + themap[1] + themap[2];
442 float e036 = themap[0] + themap[3] + themap[6];
443 float e678 = themap[6] + themap[7] + themap[8];
444 float e258 = themap[2] + themap[5] + themap[8];
446 if ((e012 > e678 || e012 == e678) && (e036 > e258 || e036 == e258))
447 return E22 = themap[0] + themap[1] + themap[3] + themap[4];
448 else if ((e012 > e678 || e012 == e678) && (e036 < e258 || e036 == e258))
449 return E22 = themap[1] + themap[2] + themap[4] + themap[5];
450 else if ((e012 < e678 || e012 == e678) && (e036 > e258 || e036 == e258))
451 return E22 = themap[3] + themap[4] + themap[6] + themap[7];
452 else if ((e012 < e678 || e012 == e678) && (e036 < e258 || e036 == e258))
453 return E22 = themap[4] + themap[5] + themap[7] + themap[8];
461 float e0_4 = themap[0] + themap[1] + themap[2] + themap[3] + themap[4];
462 float e0_20 = themap[0] + themap[5] + themap[10] + themap[15] + themap[20];
463 float e4_24 = themap[4] + themap[9] + themap[14] + themap[19] + themap[24];
464 float e0_24 = themap[20] + themap[21] + themap[22] + themap[23] + themap[24];
466 if ((e0_4 > e0_24 || e0_4 == e0_24) && (e0_20 > e4_24 || e0_20 == e4_24))
467 return E44 = e33 + themap[0] + themap[1] + themap[2] + themap[3] + themap[5] + themap[10] + themap[15];
468 else if ((e0_4 > e0_24 || e0_4 == e0_24) && (e0_20 < e4_24 || e0_20 == e4_24))
469 return E44 = e33 + themap[1] + themap[2] + themap[3] + themap[4] + themap[9] + themap[14] + themap[19];
470 else if ((e0_4 < e0_24 || e0_4 == e0_24) && (e0_20 > e4_24 || e0_20 == e4_24))
471 return E44 = e33 + themap[5] + themap[10] + themap[15] + themap[20] + themap[21] + themap[22] + themap[23];
472 else if ((e0_4 < e0_24 || e0_4 == e0_24) && (e0_20 < e4_24 || e0_20 == e4_24))
473 return E44 = e33 + themap[21] + themap[22] + themap[23] + themap[24] + themap[9] + themap[14] + themap[19];
481 uint32_t unitWithMaxEnergy = 0;
484 MapType::iterator iter;
485 for (iter = themap.begin(); iter != themap.end(); iter++) {
486 if (maxEnergy < (*iter).second) {
487 maxEnergy = (*iter).second;
488 unitWithMaxEnergy = (*iter).first;
492 LogDebug(
"GeomInfo") <<
" max energy of " << maxEnergy <<
" GeV in Unit id " << unitWithMaxEnergy;
493 return unitWithMaxEnergy;
EventNumber_t event() const
MonitorElement * meEEe9oe16_
T getUntrackedParameter(std::string const &, T const &) const
MonitorElement * meEEzpCrystals_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
~EcalEndcapSimHitsValidation() override
Destructor.
constexpr uint32_t rawId() const
get the raw id
edm::EDGetTokenT< PEcalValidInfo > ValidationCollectionToken
virtual float energyInMatrixEE(int nCellInX, int nCellInY, int centralX, int centralY, int centralZ, MapType &themap)
MonitorElement * meEEe16_
MonitorElement * meEEzmHits_
MonitorElement * meEEe1oe4_
MonitorElement * meEEzmOccupancy_
MonitorElement * meEEHitEnergy2_
std::map< uint32_t, float, std::less< uint32_t > > MapType
virtual void Reset()
reset ME (ie. contents, errors, etc)
MonitorElement * meEEcrystalEnergy_
MonitorElement * meEEe4oe9_
MonitorElement * meEEzpOccupancy_
MonitorElement * meEEe16oe25_
float eCluster4x4(float e33, MapType &themap)
std::string EEHitsCollection
MonitorElement * meEELongitudinalShower_
std::string ValidationCollection
MonitorElement * meEEe9oe25_
MonitorElement * meEEzmCrystals_
MonitorElement * meEEhitLog10Energy25Norm_
bool fillEEMatrix(int nCellInX, int nCellInY, int CentralX, int CentralY, int CentralZ, MapType &fillmap, MapType &themap)
MonitorElement * meEEcrystalEnergy2_
MonitorElement * meEEHitEnergy_
Namespace of DDCMS conversion namespace.
MonitorElement * meEEzpHits_
MonitorElement * meEEe1oe9_
static bool validDetId(int crystal_ix, int crystal_iy, int iz)
MonitorElement * meEEe1oe25_
edm::EDGetTokenT< edm::PCaloHitContainer > EEHitsToken
void endJob(void) override
uint32_t getUnitWithMaxEnergy(MapType &themap)
MonitorElement * meEEe25_
MonitorElement * meEEhitLog10Energy_
void analyze(const edm::Event &e, const edm::EventSetup &c) override
Analyze.
MonitorElement * meEEhitLog10EnergyNorm_
std::vector< uint32_t > getIdsAroundMax(int nCellInX, int nCellInY, int centralX, int centralY, int centralZ, MapType &themap)
float eCluster2x2(MapType &themap)
EcalEndcapSimHitsValidation(const edm::ParameterSet &ps)
Constructor.