20 #include "G4SDManager.hh"
21 #include "G4VProcess.hh"
22 #include "G4HCofThisEvent.hh"
23 #include "CLHEP/Units/GlobalSystemOfUnits.h"
24 #include "CLHEP/Units/GlobalPhysicalConstants.h"
34 for (
int i = 0;
i < 10000; ++
i) {
60 theTree->Branch(
"x", &
x,
"x[nphot]/F");
61 theTree->Branch(
"y", &
y,
"y[nphot]/F");
62 theTree->Branch(
"z", &
z,
"z[nphot]/F");
63 theTree->Branch(
"t", &
t,
"t[nphot]/F");
81 int irun = (*run)()->GetRunID();
86 evNum = (*evt)()->GetEventID();
97 edm::LogVerbatim(
"HcalForwardLib") <<
"HcalForwardAnalysis::Fill event " << (*evt)()->GetEventID();
100 int iEvt = (*evt)()->GetEventID();
102 edm::LogVerbatim(
"HcalForwardLib") <<
"HcalForwardAnalysis:: Event " << iEvt;
103 else if ((iEvt < 100) && (iEvt % 10 == 0))
104 edm::LogVerbatim(
"HcalForwardLib") <<
"HcalForwardAnalysis:: Event " << iEvt;
105 else if ((iEvt < 1000) && (iEvt % 100 == 0))
106 edm::LogVerbatim(
"HcalForwardLib") <<
"HcalForwardAnalysis:: Event " << iEvt;
107 else if ((iEvt < 10000) && (iEvt % 1000 == 0))
108 edm::LogVerbatim(
"HcalForwardLib") <<
"HcalForwardAnalysis:: Event " << iEvt;
116 G4HCofThisEvent* allHC = (*evt)()->GetHCofThisEvent();
117 edm::LogVerbatim(
"HcalForwardLib") <<
"HcalForwardAnalysis:: Has " << allHC->GetNumberOfCollections()
119 for (
int k = 0;
k < allHC->GetNumberOfCollections(); ++
k) {
120 G4String
name = (allHC->GetHC(
k) ==
nullptr) ?
"Unknown" : allHC->GetHC(
k)->GetName();
121 G4String nameSD = (allHC->GetHC(
k) ==
nullptr) ?
"Unknown" : allHC->GetHC(
k)->GetSDname();
122 edm::LogVerbatim(
"HcalForwardLib") <<
"Collecttion[" <<
k <<
"] " << allHC->GetHC(
k) <<
" " <<
name <<
":"
126 idHC = G4SDManager::GetSDMpointer()->GetCollectionID(sdName);
128 edm::LogVerbatim(
"HcalForwardLib") <<
"HcalForwardAnalysis::setPhotons() Hit Collection for " << sdName <<
" of ID "
129 << idHC <<
" is obtained at " << theHC;
130 std::vector<HFShowerPhoton> ShortFiberPhotons;
131 std::vector<HFShowerPhoton> LongFiberPhotons;
132 LongFiberPhotons.clear();
133 ShortFiberPhotons.clear();
134 if (idHC >= 0 && theHC !=
nullptr) {
135 int thehc_entries = theHC->entries();
137 for (
j = 0;
j < thehc_entries;
j++) {
139 std::vector<HFShowerPhoton> thePhotonsFromHit = aHit->
photon();
140 edm::LogVerbatim(
"HcalForwardLib") <<
"Fiberhit " <<
j <<
" has " << thePhotonsFromHit.size() <<
" photons.";
145 for (
unsigned int iph = 0; iph < thePhotonsFromHit.size(); ++iph) {
146 if (aHit->
depth() == 1)
147 LongFiberPhotons.push_back(thePhotonsFromHit[iph]);
148 if (aHit->
depth() == 2)
149 ShortFiberPhotons.push_back(thePhotonsFromHit[iph]);
151 edm::LogVerbatim(
"HcalForwardLib") <<
"HcalForwardAnalysis::setPhotons() NbPhotons " << thePhotonsFromHit.size()
152 <<
" towerId " << fTowerId <<
" cellId " << fCellId <<
" fiberId " << fFiberId
153 <<
" depth " << aHit->
depth();
157 edm::LogVerbatim(
"HcalForwardLib") <<
"HcalForwardAnalysis::setPhotons(): No Photons!";
160 edm::LogVerbatim(
"HcalForwardLib") <<
"HcalForwardAnalysis::setPhotons() LongFibPhotons: " << LongFiberPhotons.size()
161 <<
" ShortFibPhotons: " << ShortFiberPhotons.size();
162 edm::LogVerbatim(
"HcalForwardLib") <<
"HcalForwardAnalysis::setPhotons() LongFibPhotons: " << LongFiberPhotons.size()
163 <<
" ShortFibPhotons: " << ShortFiberPhotons.size();
167 G4HCofThisEvent* allChamberHC = (*evt)()->GetHCofThisEvent();
169 idHC = G4SDManager::GetSDMpointer()->GetCollectionID(sdName);
173 float primTimeOnSurf = 0;
178 if (idHC >= 0 && theChamberHC !=
nullptr) {
179 edm::LogVerbatim(
"HcalForwardLib") <<
"HcalForwardAnalysis::setPhotons() Chamber Hits size: "
180 << theChamberHC->entries();
181 int thec_hc_entries = theChamberHC->entries();
182 for (
j = 0;
j < thec_hc_entries; ++
j) {
184 edm::LogVerbatim(
"HcalForwardLib") <<
"HcalForwardAnalysis::setPhotons() Chamber Hit id " << aHit->
hitId()
189 primTimeOnSurf = aHit->
time();
192 edm::LogVerbatim(
"HcalForwardLib") <<
"HcalForwardAnalysis::setPhotons(): No Chamber hits are stored";
196 primX = primPosOnSurf.x();
197 primY = primPosOnSurf.y();
198 primZ = primPosOnSurf.z();
200 edm::LogVerbatim(
"HcalForwardLib") <<
"HcalForwardAnalysis::setPhotons(): First interaction before HF";
204 primT = primTimeOnSurf;
209 double theta = primMomDirOnSurf.theta();
210 double phi = primMomDirOnSurf.phi();
218 double pex = 0, pey = 0,
zv = 0;
221 for (
unsigned int k = 0;
k < LongFiberPhotons.size(); ++
k) {
229 pex =
xx * ctheta * cphi +
yy * ctheta * sphi -
zz * stheta;
230 pey = -
xx * sphi +
yy * cphi;
231 zv =
xx * stheta * cphi +
yy * stheta * sphi +
zz * ctheta -
primZ / ctheta;
233 double photonProdTime = aPhoton.
t() - primTimeOnSurf;
236 for (
unsigned int k = 0;
k < ShortFiberPhotons.size(); ++
k) {
244 pex =
xx * ctheta * cphi +
yy * ctheta * sphi -
zz * stheta;
245 pey = -
xx * sphi +
yy * cphi;
246 zv =
xx * stheta * cphi +
yy * stheta * sphi +
zz * ctheta -
primZ / ctheta;
248 double photonProdTime = aPhoton.
t() - primTimeOnSurf;
271 cell =
id / 10 -
tower * 10;
272 fiber =
id -
tower * 10000 - cell * 10;
277 for (
int i = 0;
i < 10000; ++
i) {