21 #include "G4SDManager.hh"
22 #include "G4VProcess.hh"
23 #include "G4HCofThisEvent.hh"
24 #include "CLHEP/Units/GlobalSystemOfUnits.h"
25 #include "CLHEP/Units/GlobalPhysicalConstants.h"
35 for (
int i = 0;
i < 10000; ++
i) {
67 theTree->Branch(
"x", &
x,
"x[nphot]/F");
68 theTree->Branch(
"y", &
y,
"y[nphot]/F");
69 theTree->Branch(
"z", &
z,
"z[nphot]/F");
70 theTree->Branch(
"t", &
t,
"t[nphot]/F");
88 int irun = (*run)()->GetRunID();
89 edm::LogInfo(
"HcalForwardLib") <<
" =====> Begin of Run = " << irun;
93 evNum = (*evt)()->GetEventID();
95 edm::LogInfo(
"HcalForwardLib") <<
"HcalForwardAnalysis: =====> Begin of event = " <<
evNum;
104 LogDebug(
"HcalForwardLib") <<
"HcalForwardAnalysis::Fill event " << (*evt)()->GetEventID();
107 int iEvt = (*evt)()->GetEventID();
109 edm::LogInfo(
"HcalForwardLib") <<
"HcalForwardAnalysis:: Event " << iEvt;
110 else if ((iEvt < 100) && (iEvt % 10 == 0))
111 edm::LogInfo(
"HcalForwardLib") <<
"HcalForwardAnalysis:: Event " << iEvt;
112 else if ((iEvt < 1000) && (iEvt % 100 == 0))
113 edm::LogInfo(
"HcalForwardLib") <<
"HcalForwardAnalysis:: Event " << iEvt;
114 else if ((iEvt < 10000) && (iEvt % 1000 == 0))
115 edm::LogInfo(
"HcalForwardLib") <<
"HcalForwardAnalysis:: Event " << iEvt;
122 G4HCofThisEvent* allHC = (*evt)()->GetHCofThisEvent();
124 idHC = G4SDManager::GetSDMpointer()->GetCollectionID(sdName);
126 LogDebug(
"HcalForwardLib") <<
"HcalForwardAnalysis::setPhotons() Hit Collection for " << sdName <<
" of ID " << idHC
127 <<
" is obtained at " << theHC;
128 std::vector<HFShowerPhoton> ShortFiberPhotons;
129 std::vector<HFShowerPhoton> LongFiberPhotons;
130 LongFiberPhotons.clear();
131 ShortFiberPhotons.clear();
132 int thehc_entries = theHC->entries();
133 if (idHC >= 0 && theHC !=
nullptr) {
134 std::cout <<
"FiberhitSize " << thehc_entries << std::endl;
135 for (
j = 0;
j < thehc_entries;
j++) {
137 std::vector<HFShowerPhoton> thePhotonsFromHit = aHit->
photon();
138 std::cout <<
"Fiberhit " <<
j <<
" has " << thePhotonsFromHit.size() <<
" photons." << std::endl;
143 for (
unsigned int iph = 0; iph < thePhotonsFromHit.size(); ++iph) {
144 if (aHit->
depth() == 1)
145 LongFiberPhotons.push_back(thePhotonsFromHit[iph]);
146 if (aHit->
depth() == 2)
147 ShortFiberPhotons.push_back(thePhotonsFromHit[iph]);
149 LogDebug(
"HcalForwardLib") <<
"HcalForwardAnalysis::setPhotons() NbPhotons " << thePhotonsFromHit.size()
150 <<
" towerId " << fTowerId <<
" cellId " << fCellId <<
" fiberId " << fFiberId
151 <<
" depth " << aHit->
depth();
154 LogDebug(
"HcalForwardLib") <<
"HcalForwardAnalysis::setPhotons(): No Photons!";
157 LogDebug(
"HcalForwardLib") <<
"HcalForwardAnalysis::setPhotons() LongFibPhotons: " << LongFiberPhotons.size()
158 <<
" ShortFibPhotons: " << ShortFiberPhotons.size();
159 std::cout <<
"HcalForwardAnalysis::setPhotons() LongFibPhotons: " << LongFiberPhotons.size()
160 <<
" ShortFibPhotons: " << ShortFiberPhotons.size() << std::endl;
164 G4HCofThisEvent* allChamberHC = (*evt)()->GetHCofThisEvent();
166 idHC = G4SDManager::GetSDMpointer()->GetCollectionID(sdName);
170 float primTimeOnSurf = 0;
174 if (idHC >= 0 && theChamberHC !=
nullptr) {
175 LogDebug(
"HcalForwardLib") <<
"HcalForwardAnalysis::setPhotons() Chamber Hits size: " << theChamberHC->entries();
176 int thec_hc_entries = theChamberHC->entries();
177 for (
j = 0;
j < thec_hc_entries; ++
j) {
179 LogDebug(
"HcalForwardLib") <<
"HcalForwardAnalysis::setPhotons() Chamber Hit id " << aHit->
hitId() <<
" track id "
184 primTimeOnSurf = aHit->
time();
187 LogDebug(
"HcalForwardLib") <<
"HcalForwardAnalysis::setPhotons(): No Chamber hits. Something is wrong!";
190 primX = primPosOnSurf.x();
191 primY = primPosOnSurf.y();
192 primZ = primPosOnSurf.z();
193 primT = primTimeOnSurf;
198 float photonProdX = 0.;
199 float photonProdY = 0.;
200 float photonProdZ = 0.;
201 float photonProdTime = 0.;
203 double theta = primMomDirOnSurf.theta();
204 double phi = primMomDirOnSurf.phi();
206 for (
unsigned int k = 0;
k < LongFiberPhotons.size(); ++
k) {
210 photonProdY = -aPhoton.
x() *
sin(
phi) + aPhoton.
y() *
cos(
phi) - primPosOnSurf.y();
213 photonProdTime = aPhoton.
t() - primTimeOnSurf;
216 for (
unsigned int k = 0;
k < ShortFiberPhotons.size(); ++
k) {
220 photonProdY = -aPhoton.
x() *
sin(
phi) + aPhoton.
y() *
cos(
phi) - primPosOnSurf.y();
223 photonProdTime = aPhoton.
t() - primTimeOnSurf;
244 cell =
id / 10 -
tower * 10;
245 fiber =
id -
tower * 10000 - cell * 10;
250 for (
int i = 0;
i < 10000; ++
i) {