18 : g4InfoLabel(ps.getParameter<
std::
string>(
"moduleLabelG4")),
34 dbe_->showDirStructure();
64 for (
int myStep = 0; myStep < 26; myStep++) {
71 dbe_->setCurrentFolder(
"EcalHitsV/EcalSimHitsValidation");
73 sprintf(histo,
"EB hits multiplicity");
74 menEBHits_ = dbe_->book1D(histo, histo, 50, 0., 5000.);
76 sprintf(histo,
"EB crystals multiplicity");
79 sprintf(histo,
"EB occupancy");
80 meEBOccupancy_ = dbe_->book2D(histo, histo, 360, 0., 360., 170, -85., 85.);
82 sprintf(histo,
"EB longitudinal shower profile");
85 sprintf(histo,
"EB hits energy spectrum");
88 sprintf(histo,
"EB hits log10energy spectrum");
91 sprintf(histo,
"EB hits log10energy spectrum vs normalized energy");
94 sprintf(histo,
"EB hits log10energy spectrum vs normalized energy25");
97 sprintf(histo,
"EB hits energy spectrum 2");
100 sprintf(histo,
"EB crystal energy spectrum");
103 sprintf(histo,
"EB crystal energy spectrum 2");
106 sprintf(histo,
"EB E1");
107 meEBe1_ = dbe_->book1D(histo, histo, 400, 0., 400.);
109 sprintf(histo,
"EB E4");
110 meEBe4_ = dbe_->book1D(histo, histo, 400, 0., 400.);
112 sprintf(histo,
"EB E9");
113 meEBe9_ = dbe_->book1D(histo, histo, 400, 0., 400.);
115 sprintf(histo,
"EB E16");
116 meEBe16_ = dbe_->book1D(histo, histo, 400, 0., 400.);
118 sprintf(histo,
"EB E25");
119 meEBe25_ = dbe_->book1D(histo, histo, 400, 0., 400.);
121 sprintf(histo,
"EB E1oE4");
122 meEBe1oe4_ = dbe_->book1D(histo, histo, 100, 0.4, 1.1);
124 sprintf(histo,
"EB E1oE9");
125 meEBe1oe9_ = dbe_->book1D(histo, histo, 100, 0.4, 1.1);
127 sprintf(histo,
"EB E4oE9");
128 meEBe4oe9_ = dbe_->book1D(histo, histo, 100, 0.4, 1.1);
130 sprintf(histo,
"EB E9oE16");
131 meEBe9oe16_ = dbe_->book1D(histo, histo, 100, 0.4, 1.1);
133 sprintf(histo,
"EB E1oE25");
134 meEBe1oe25_ = dbe_->book1D(histo, histo, 100, 0.4, 1.1);
136 sprintf(histo,
"EB E9oE25");
137 meEBe9oe25_ = dbe_->book1D(histo, histo, 100, 0.4, 1.1);
139 sprintf(histo,
"EB E16oE25");
140 meEBe16oe25_ = dbe_->book1D(histo, histo, 100, 0.4, 1.1);
168 std::vector<PCaloHit> theEBCaloHits;
169 theEBCaloHits.insert(theEBCaloHits.end(), EcalHitsEB->begin(), EcalHitsEB->end());
173 double EBEnergy_ = 0.;
174 std::map<unsigned int, std::vector<PCaloHit *>, std::less<unsigned int>> CaloHitMap;
181 std::vector<double> econtr(140, 0.);
182 std::vector<double> econtr25(140, 0.);
185 uint32_t nEBHits = 0;
187 for (std::vector<PCaloHit>::iterator isim = theEBCaloHits.begin(); isim != theEBCaloHits.end(); ++isim) {
188 if (isim->time() > 500.) {
192 CaloHitMap[isim->id()].push_back(&(*isim));
196 LogDebug(
"HitInfo") <<
" CaloHit " << isim->getName() <<
"\n" 197 <<
" DetID = " << isim->id() <<
" EBDetId = " << ebid.ieta() <<
" " << ebid.iphi() <<
"\n" 198 <<
" Time = " << isim->time() <<
"\n" 199 <<
" Track Id = " << isim->geantTrackId() <<
"\n" 200 <<
" Energy = " << isim->energy();
205 uint32_t crystid = ebid.rawId();
206 ebmap[crystid] += isim->energy();
208 EBEnergy_ += isim->energy();
211 if (isim->energy() > 0) {
213 int log10i =
int((log10(isim->energy()) + 10.) * 10.);
214 if (log10i >= 0 && log10i < 140)
215 econtr[log10i] += isim->energy();
223 for (
std::map<uint32_t,
float, std::less<uint32_t>>::iterator it = ebmap.begin(); it != ebmap.end(); ++it)
227 for (
std::map<uint32_t,
float, std::less<uint32_t>>::iterator it = ebmap.begin(); it != ebmap.end(); ++it)
238 int by = myEBid.
iphi();
239 int bz = myEBid.
zside();
250 std::vector<uint32_t> ids25;
253 for (
unsigned i = 0;
i < 25;
i++) {
254 for (
unsigned int j = 0;
j < CaloHitMap[ids25[
i]].size();
j++) {
255 if (CaloHitMap[ids25[
i]][
j]->
energy() > 0) {
256 int log10i =
int((log10(CaloHitMap[ids25[
i]][
j]->
energy()) + 10.) * 10.);
257 if (log10i >= 0 && log10i < 140)
258 econtr25[log10i] += CaloHitMap[ids25[
i]][
j]->energy();
291 for (
int i = 0;
i < 140;
i++) {
297 for (
int i = 0;
i < 140;
i++) {
303 if (MyPEcalValidInfo.
isValid()) {
304 if (MyPEcalValidInfo->
eb1x1() > 0.) {
305 std::vector<float> BX0 = MyPEcalValidInfo->
bX0();
308 for (
int myStep = 0; myStep < 26; myStep++) {
318 int nCellInEta,
int nCellInPhi,
int centralEta,
int centralPhi,
int centralZ,
MapType &themap) {
320 float totalEnergy = 0.;
322 int goBackInEta = nCellInEta / 2;
323 int goBackInPhi = nCellInPhi / 2;
324 int startEta = centralZ * centralEta - goBackInEta;
325 int startPhi = centralPhi - goBackInPhi;
327 for (
int ieta = startEta;
ieta < startEta + nCellInEta;
ieta++) {
328 for (
int iphi = startPhi;
iphi < startPhi + nCellInPhi;
iphi++) {
335 }
else if (
iphi > 360) {
341 totalEnergy += themap[
index];
346 LogDebug(
"GeomInfo") << nCellInEta <<
" x " << nCellInPhi <<
" EB matrix energy = " << totalEnergy <<
" for " 347 << ncristals <<
" crystals";
352 int nCellInEta,
int nCellInPhi,
int centralEta,
int centralPhi,
int centralZ,
MapType &themap) {
354 std::vector<uint32_t>
ids(nCellInEta * nCellInPhi);
356 int goBackInEta = nCellInEta / 2;
357 int goBackInPhi = nCellInPhi / 2;
358 int startEta = centralZ * centralEta - goBackInEta;
359 int startPhi = centralPhi - goBackInPhi;
361 for (
int ieta = startEta;
ieta < startEta + nCellInEta;
ieta++) {
362 for (
int iphi = startPhi;
iphi < startPhi + nCellInPhi;
iphi++) {
369 }
else if (
iphi > 360) {
374 ids[ncristals] =
index;
383 int nCellInEta,
int nCellInPhi,
int CentralEta,
int CentralPhi,
int CentralZ,
MapType &fillmap,
MapType &themap) {
384 int goBackInEta = nCellInEta / 2;
385 int goBackInPhi = nCellInPhi / 2;
387 int startEta = CentralZ * CentralEta - goBackInEta;
388 int startPhi = CentralPhi - goBackInPhi;
391 for (
int ieta = startEta;
ieta < startEta + nCellInEta;
ieta++) {
392 for (
int iphi = startPhi;
iphi < startPhi + nCellInPhi;
iphi++) {
399 }
else if (
iphi > 360) {
404 fillmap[i++] = themap[
index];
410 if (fillmap[i / 2] == themap[ebcenterid])
418 float e012 = themap[0] + themap[1] + themap[2];
419 float e036 = themap[0] + themap[3] + themap[6];
420 float e678 = themap[6] + themap[7] + themap[8];
421 float e258 = themap[2] + themap[5] + themap[8];
423 if ((e012 > e678 || e012 == e678) && (e036 > e258 || e036 == e258))
424 return E22 = themap[0] + themap[1] + themap[3] + themap[4];
425 else if ((e012 > e678 || e012 == e678) && (e036 < e258 || e036 == e258))
426 return E22 = themap[1] + themap[2] + themap[4] + themap[5];
427 else if ((e012 < e678 || e012 == e678) && (e036 > e258 || e036 == e258))
428 return E22 = themap[3] + themap[4] + themap[6] + themap[7];
429 else if ((e012 < e678 || e012 == e678) && (e036 < e258 || e036 == e258))
430 return E22 = themap[4] + themap[5] + themap[7] + themap[8];
438 float e0_4 = themap[0] + themap[1] + themap[2] + themap[3] + themap[4];
439 float e0_20 = themap[0] + themap[5] + themap[10] + themap[15] + themap[20];
440 float e4_24 = themap[4] + themap[9] + themap[14] + themap[19] + themap[24];
441 float e0_24 = themap[20] + themap[21] + themap[22] + themap[23] + themap[24];
443 if ((e0_4 > e0_24 || e0_4 == e0_24) && (e0_20 > e4_24 || e0_20 == e4_24))
444 return E44 = e33 + themap[0] + themap[1] + themap[2] + themap[3] + themap[5] + themap[10] + themap[15];
445 else if ((e0_4 > e0_24 || e0_4 == e0_24) && (e0_20 < e4_24 || e0_20 == e4_24))
446 return E44 = e33 + themap[1] + themap[2] + themap[3] + themap[4] + themap[9] + themap[14] + themap[19];
447 else if ((e0_4 < e0_24 || e0_4 == e0_24) && (e0_20 > e4_24 || e0_20 == e4_24))
448 return E44 = e33 + themap[5] + themap[10] + themap[15] + themap[20] + themap[21] + themap[22] + themap[23];
449 else if ((e0_4 < e0_24 || e0_4 == e0_24) && (e0_20 < e4_24 || e0_20 == e4_24))
450 return E44 = e33 + themap[21] + themap[22] + themap[23] + themap[24] + themap[9] + themap[14] + themap[19];
458 uint32_t unitWithMaxEnergy = 0;
461 MapType::iterator iter;
462 for (iter = themap.begin(); iter != themap.end(); iter++) {
463 if (maxEnergy < (*iter).second) {
464 maxEnergy = (*iter).second;
465 unitWithMaxEnergy = (*iter).first;
469 LogDebug(
"GeomInfo") <<
" max energy of " << maxEnergy <<
" GeV in Unit id " << unitWithMaxEnergy;
470 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
virtual void Reset()
reset ME (ie. contents, errors, etc)
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
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_