19 #include "G4SDManager.hh" 22 #include "G4VProcess.hh" 23 #include "G4HCofThisEvent.hh" 24 #include "CLHEP/Units/GlobalSystemOfUnits.h" 25 #include "CLHEP/Units/GlobalPhysicalConstants.h" 26 #include "Randomize.hh" 38 int laygroup = m_Anal.
getParameter<
int>(
"LayerGrouping");
45 edm::LogInfo(
"HcalSim") <<
"HcalTestAnalysis:: Initialised as observer of " 46 <<
"begin/end events and of G4step";
51 for (
unsigned int i=0;
i<
group_.size();
i++)
57 <<
" Longitudinal groups and " <<
nTower_ 65 edm::LogInfo(
"HcalSim") <<
"HcalTestAnalysis: --------> Total number of " 66 <<
"selected entries : " <<
count_;
67 edm::LogInfo(
"HcalSim") <<
"HcalTestAnalysis: Pointers:: HistoClass " 73 std::vector<int>
temp(19);
75 int grp[19] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2};
76 for (
int i=0;
i<19;
i++)
78 }
else if (group == 2) {
79 int grp[19] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19};
80 for (
int i=0;
i<19;
i++)
82 }
else if (group == 3) {
83 int grp[19] = {1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7};
84 for (
int i=0;
i<19;
i++)
86 }
else if (group == 4) {
87 int grp[19] = {1, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 5, 6, 6, 6, 6, 6, 7, 7};
88 for (
int i=0;
i<19;
i++)
91 int grp[19] = {1, 1, 2, 3, 3, 4, 4, 5, 5, 5, 6, 6, 6, 6, 6, 6, 6, 7, 7};
92 for (
int i=0;
i<19;
i++)
96 edm::LogInfo(
"HcalSim") <<
"HcalTestAnalysis:: Layer Grouping ";
97 for (
int i=0;
i<19;
i++)
98 edm::LogInfo(
"HcalSim") <<
"HcalTestAnalysis: Group[" <<
i <<
"] = " 105 int etac = (centre/100)%100;
106 int phic = (centre%100);
124 nbuf = (etamax-etamin+1)*(phimax-phimin+1);
125 std::vector<int>
temp(2*nbuf);
126 for (
int eta=etamin;
eta<=etamax;
eta++) {
128 temp[kount] = (
eta*100 +
phi);
134 edm::LogInfo(
"HcalSim") <<
"HcalTestAnalysis:: Towers to be considered for" 135 <<
" Central " << centre <<
" and " << nadd
136 <<
" on either side";
137 for (
int i=0;
i<nbuf;
i++)
138 edm::LogInfo(
"HcalSim") <<
"HcalTestAnalysis: Tower[" << std::setw(3) <<
i 139 <<
"] " << temp[
i] <<
" " << temp[nbuf+
i];
149 (*job)()->get<HcalSimNumberingRecord>().get(hdc);
151 edm::LogInfo(
"HcalSim") <<
"HcalTestAnalysis:: Initialise " 152 <<
"HcalNumberingFromDDD for " <<
names_[0];
166 int irun = (*run)()->GetRunID();
167 edm::LogInfo(
"HcalSim") <<
"HcalTestAnalysis:: Begin of Run = " << irun;
187 }
else if (idet == static_cast<int>(
HcalBarrel)) {
189 }
else if (idet == static_cast<int>(
HcalEndcap)) {
196 edm::LogInfo(
"HcalSim") <<
"HcalTestAnalysis:: Central Tower " 201 G4SDManager*
sd = G4SDManager::GetSDMpointerIfExist();
203 G4VSensitiveDetector* aSD = sd->FindSensitiveDetector(sdname);
205 edm::LogWarning(
"HcalSim") <<
"HcalTestAnalysis::beginOfRun: No SD with " 206 <<
"name " << sdname <<
" in this Setup";
209 edm::LogInfo(
"HcalSim") <<
"HcalTestAnalysis::beginOfRun: Finds SD with " 210 <<
"name " << theCaloSD->GetName()
214 edm::LogInfo(
"HcalSim") <<
"HcalTestAnalysis::beginOfRun: set a new " 215 <<
"numbering scheme";
219 edm::LogWarning(
"HcalSim") <<
"HcalTestAnalysis::beginOfRun: Could not get" 235 for (i = 0; i < 20; i++)
edepl_[i] = 0.;
236 for (i = 0; i < 20; i++)
mudist_[i] = -1.;
239 << (*evt)()->GetEventID();
245 if (aStep !=
nullptr) {
246 G4VPhysicalVolume* curPV = aStep->GetPreStepPoint()->GetPhysicalVolume();
247 G4String
name = curPV->GetName();
248 name.assign(name,0,3);
249 double edeposit = aStep->GetTotalEnergyDeposit();
253 }
else if (name ==
"EFR") {
255 }
else if (name ==
"HBS") {
256 layer = (curPV->GetCopyNo()/10)%100;
257 if (layer >= 0 && layer < 17) {
261 << curPV->GetName() << curPV->GetCopyNo();
264 }
else if (name ==
"HES") {
265 layer = (curPV->GetCopyNo()/10)%100;
266 if (layer >= 0 && layer < 19) {
270 << curPV->GetName() << curPV->GetCopyNo();
273 }
else if (name ==
"HTS") {
274 layer = (curPV->GetCopyNo()/10)%100;
275 if (layer >= 17 && layer < 20) {
279 << curPV->GetName() << curPV->GetCopyNo();
283 if (layer >= 0 && layer < 20) {
284 edepl_[layer] += edeposit;
287 G4String
part = aStep->GetTrack()->GetDefinition()->GetParticleName();
288 if ((part ==
"mu-" || part ==
"mu+") &&
mudist_[layer] < 0) {
290 aStep->GetPreStepPoint()->GetPosition().y(),
291 aStep->GetPreStepPoint()->GetPosition().z());
301 if (layer >= 0 && layer < 20) {
303 <<
" Layer " << std::setw(3) << layer
304 <<
" Edep " << std::setw(6)
305 << edeposit/
MeV <<
" MeV";
308 edm::LogInfo(
"HcalSim") <<
"HcalTestAnalysis:: G4Step: Null Step";
321 CLHEP::HepRandomEngine* engine = G4Random::getTheEngine();
327 edm::LogVerbatim(
"HcalSim") <<
"HcalTestAnalysis:: --- after LayerAnalysis";
340 << (*evt)()->GetEventID();
343 G4HCofThisEvent* allHC = (*evt)()->GetHCofThisEvent();
345 int nhc = 0, neb = 0, nef = 0, j = 0;
349 int HCHCid = G4SDManager::GetSDMpointer()->GetCollectionID(
names_[0]);
352 <<
names_[0] <<
" of ID " << HCHCid
353 <<
" is obtained at " << theHCHC;
354 if (HCHCid >= 0 && theHCHC !=
nullptr) {
355 for (j = 0; j < theHCHC->entries(); j++) {
363 double theta = pos.theta();
365 double phi = pos.phi();
368 int subdet,
zside, layer, etaIndex, phiIndex, lay;
371 if (jitter<0) jitter = 0;
372 CaloHit hit(subdet,lay,e,eta,phi,jitter,unitID);
379 }
else if (subdet == static_cast<int>(
HcalEndcap)) {
380 if (etaIndex <= 20) {
388 << std::setw(2) << layer <<
" time " 389 << std::setw(6) << time <<
" theta " 390 << std::setw(8) << theta <<
" eta " 391 << std::setw(8) << eta <<
" phi " 392 << std::setw(8) << phi <<
" e " 393 << std::setw(8) <<
e;
399 int EBHCid = G4SDManager::GetSDMpointer()->GetCollectionID(
names_[1]);
402 <<
names_[1] <<
" of ID " << EBHCid
403 <<
" is obtained at " << theEBHC;
404 if (EBHCid >= 0 && theEBHC !=
nullptr) {
405 for (j = 0; j < theEBHC->entries(); j++) {
414 double theta = pos.theta();
416 double phi = pos.phi();
420 int subdet,
zside, layer, ieta, iphi, lay;
425 CaloHit hit(subdet,lay,e,eta,phi,time,unitID);
429 << std::setw(2) << layer <<
" time " 430 << std::setw(6) << time <<
" theta " 431 << std::setw(8) << theta <<
" eta " 432 << std::setw(8) << eta <<
" phi " 433 << std::setw(8) << phi <<
" e " 434 << std::setw(8) <<
e;
440 int EEHCid = G4SDManager::GetSDMpointer()->GetCollectionID(
names_[2]);
443 <<
names_[2] <<
" of ID " << EEHCid
444 <<
" is obtained at " << theEEHC;
445 if (EEHCid >= 0 && theEEHC !=
nullptr) {
446 for (j = 0; j < theEEHC->entries(); j++) {
455 double theta = pos.theta();
457 double phi = pos.phi();
461 int subdet,
zside, layer, ieta, iphi, lay;
466 CaloHit hit(subdet,lay,e,eta,phi,time,unitID);
470 << std::setw(2) << layer <<
" time " 471 << std::setw(6) << time <<
" theta " 472 << std::setw(8) << theta <<
" eta " 473 << std::setw(8) << eta <<
" phi " 474 << std::setw(8) << phi <<
" e " 475 << std::setw(8) <<
e;
491 int subdet,
zside, layer, ieta, iphi, lay;
496 laymax = 4; det =
"HB";
497 }
else if (subdet == static_cast<int>(
HcalEndcap)) {
498 laymax = 2; det =
"HES";
501 << ieta <<
" Phi " << iphi <<
" Laymax " 502 << laymax <<
" Hits " << hittot;
504 if (laymax>0 && hittot>0) {
505 std::vector<CaloHit>
hits(hittot);
506 std::vector<double> eqielay(80,0.0), esimlay(80,0.0), esimtot(4,0.0);
507 std::vector<double> eqietow(200,0.0), esimtow(200,0.0), eqietot(4,0.0);
511 for (
int layr=0; layr<
nGroup_; layr++) {
526 for (
int it=0; it<
nTower_; it++) {
529 for (
int k1 = 0; k1 < hittot; k1++) {
531 int subdetc = hit.
det();
532 int layer = hit.
layer();
534 if (layer > 0 && layer < 20) group =
group_[layer];
535 if (subdetc == subdet && group == layr+1) {
536 int zsidec, ietac, iphic,
idx;
539 if (etac > 0 && phic > 0) {
540 idx = ietac*100 + iphic;
541 }
else if (etac > 0) {
543 }
else if (phic > 0) {
548 if (zsidec==zside && idx==
tower_[it]) {
558 std::vector<int> cd =
myqie_->getCode(nhit, hits, engine);
559 double eqie =
myqie_->getEnergy(cd);
562 << layr <<
" Sim " << esim <<
" After QIE " 564 for (
int i=0;
i<4;
i++) {
568 esimlay[20*
i+layr] += esim;
569 eqielay[20*
i+layr] += eqie;
570 esimtow[50*
i+it] += esim;
571 eqietow[50*
i+it] += eqie;
577 << esimtot[3] <<
" (SimHit) " << eqietot[3]
580 std::vector<double> latphi(10);
582 for (
int it=0; it<
nt; it++)
584 for (
int i=0;
i<4;
i++) {
585 double scals=1, scalq=1;
586 std::vector<double> latfs(10,0.), latfq(10,0.), longs(20), longq(20);
587 if (esimtot[
i]>0) scals = 1./esimtot[
i];
588 if (eqietot[
i]>0) scalq = 1./eqietot[
i];
589 for (
int it=0; it<
nTower_; it++) {
591 latfs[phib] += scals*esimtow[50*
i+it];
592 latfq[phib] += scalq*eqietow[50*
i+it];
594 for (
int layr=0; layr<=
nGroup_; layr++) {
595 longs[layr] = scals*esimlay[20*
i+layr];
596 longq[layr] = scalq*eqielay[20*
i+layr];
599 nt,latphi,latfs,latfq);
608 edm::LogVerbatim(
"HcalSim") <<
"\n ===>>> HcalTestAnalysis: Energy deposit " 609 <<
"\n at EB : " << std::setw(6) <<
edepEB_/
MeV 610 <<
"\n at EE : " << std::setw(6) <<
edepEE_/
MeV 611 <<
"\n at HB : " << std::setw(6) <<
edepHB_/
MeV 612 <<
"\n at HE : " << std::setw(6) <<
edepHE_/
MeV 613 <<
"\n at HO : " << std::setw(6) <<
edepHO_/
MeV 614 <<
"\n ---- HcalTestAnalysis: Energy deposit " 616 for (i = 0; i < 20; i++)
630 const double rLay[19] = {
631 1836.0, 1902.0, 1962.0, 2022.0, 2082.0, 2142.0, 2202.0, 2262.0, 2322.0,
632 2382.0, 2448.0, 2514.0, 2580.0, 2646.0, 2712.0, 2776.0, 2862.5, 3847.0,
634 if (layer>0 && layer<20) dist += rLay[layer-1]*mm/
sin(theta);
636 const double zLay[19] = {
637 4034.0, 4032.0, 4123.0, 4210.0, 4297.0, 4384.0, 4471.0, 4558.0, 4645.0,
638 4732.0, 4819.0, 4906.0, 4993.0, 5080.0, 5167.0, 5254.0, 5341.0, 5428.0,
640 if (layer>0 && layer<20) dist += zLay[layer-1]*mm/
cos(theta);
642 double tmp = dist/c_light/ns;
644 <<
" for det/lay " << det <<
" " << layer
645 <<
" eta/theta " << eta <<
" " << theta/deg
void fillQie(int id, double esimtot, double eqietot, int nGroup, const std::vector< double > &longs, const std::vector< double > &longq, int nTower, const std::vector< double > &latphi, const std::vector< double > &latfs, const std::vector< double > &latfq)
T getParameter(std::string const &) const
HcalTestNumberingScheme * org_
math::XYZPoint getPosition() const
void fillLayers(double el[], double ho, double hbhe, double muxy[])
std::vector< int > layerGrouping(int)
std::unique_ptr< HcalNumberingFromDDD > numberingFromDDD_
Sin< T >::type sin(const T &t)
Geom::Theta< T > theta() const
void fillHits(std::vector< CaloHit > &)
std::vector< std::string > names_
void update(const BeginOfJob *run) override
This routine will be called when the appropriate signal arrives.
HcalCellType::HcalCell cell(const int &det, const int &zside, const int &depth, const int &etaR, const int &iphi) const
void setNumberingScheme(HcalNumberingScheme *)
HcalTestHistoClass * tuples_
std::vector< int > towersToAdd(int centre, int nadd)
double timeOfFlight(int det, int layer, double eta)
void fill(const EndOfEvent *ev)
static uint32_t packHcalIndex(int det, int z, int depth, int eta, int phi, int lay)
std::vector< int > tower_
HcalTestAnalysis(const edm::ParameterSet &p)
const HcalDDDSimConstants * hcons_
Cos< T >::type cos(const T &t)
~HcalTestAnalysis() override
std::unique_ptr< HcalQie > myqie_
Tan< T >::type tan(const T &t)
Abs< T >::type abs(const T &t)
XYZPointD XYZPoint
point in space with cartesian internal representation
std::vector< std::vector< double > > tmp
std::vector< CaloHit > caloHitCache_
G4THitsCollection< CaloG4Hit > CaloG4HitCollection
static void unpackHcalIndex(const uint32_t &idx, int &det, int &z, int &depth, int &eta, int &phi, int &lay)
double getTimeSlice() const
void qieAnalysis(CLHEP::HepRandomEngine *)
uint32_t getUnitID() const
std::vector< int > group_
T const * product() const
std::unique_ptr< HcalTestHistoManager > tuplesManager_
double getEnergyDeposit() const
uint32_t getUnitID(const HcalNumberingFromDDD::HcalID &id) override