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();
93 evNum = (*evt)()->GetEventID();
104 edm::LogVerbatim(
"HcalForwardLib") <<
"HcalForwardAnalysis::Fill event " << (*evt)()->GetEventID();
107 int iEvt = (*evt)()->GetEventID();
109 edm::LogVerbatim(
"HcalForwardLib") <<
"HcalForwardAnalysis:: Event " << iEvt;
110 else if ((iEvt < 100) && (iEvt % 10 == 0))
111 edm::LogVerbatim(
"HcalForwardLib") <<
"HcalForwardAnalysis:: Event " << iEvt;
112 else if ((iEvt < 1000) && (iEvt % 100 == 0))
113 edm::LogVerbatim(
"HcalForwardLib") <<
"HcalForwardAnalysis:: Event " << iEvt;
114 else if ((iEvt < 10000) && (iEvt % 1000 == 0))
115 edm::LogVerbatim(
"HcalForwardLib") <<
"HcalForwardAnalysis:: Event " << iEvt;
122 G4HCofThisEvent* allHC = (*evt)()->GetHCofThisEvent();
123 edm::LogVerbatim(
"HcalForwardLib") <<
"HcalForwardAnalysis:: Has " << allHC->GetNumberOfCollections()
125 for (
int k = 0;
k < allHC->GetNumberOfCollections(); ++
k) {
126 G4String
name = (allHC->GetHC(
k) ==
nullptr) ?
"Unknown" : allHC->GetHC(
k)->GetName();
127 G4String nameSD = (allHC->GetHC(
k) ==
nullptr) ?
"Unknown" : allHC->GetHC(
k)->GetSDname();
128 edm::LogVerbatim(
"HcalForwardLib") <<
"Collecttion[" <<
k <<
"] " << allHC->GetHC(
k) <<
" " <<
name <<
":"
132 idHC = G4SDManager::GetSDMpointer()->GetCollectionID(sdName);
134 edm::LogVerbatim(
"HcalForwardLib") <<
"HcalForwardAnalysis::setPhotons() Hit Collection for " << sdName <<
" of ID "
135 << idHC <<
" is obtained at " << theHC;
136 std::vector<HFShowerPhoton> ShortFiberPhotons;
137 std::vector<HFShowerPhoton> LongFiberPhotons;
138 LongFiberPhotons.clear();
139 ShortFiberPhotons.clear();
140 if (idHC >= 0 && theHC !=
nullptr) {
141 int thehc_entries = theHC->entries();
143 for (
j = 0;
j < thehc_entries;
j++) {
145 std::vector<HFShowerPhoton> thePhotonsFromHit = aHit->
photon();
146 edm::LogVerbatim(
"HcalForwardLib") <<
"Fiberhit " <<
j <<
" has " << thePhotonsFromHit.size() <<
" photons.";
151 for (
unsigned int iph = 0; iph < thePhotonsFromHit.size(); ++iph) {
152 if (aHit->
depth() == 1)
153 LongFiberPhotons.push_back(thePhotonsFromHit[iph]);
154 if (aHit->
depth() == 2)
155 ShortFiberPhotons.push_back(thePhotonsFromHit[iph]);
157 edm::LogVerbatim(
"HcalForwardLib") <<
"HcalForwardAnalysis::setPhotons() NbPhotons " << thePhotonsFromHit.size()
158 <<
" towerId " << fTowerId <<
" cellId " << fCellId <<
" fiberId " << fFiberId
159 <<
" depth " << aHit->
depth();
162 edm::LogVerbatim(
"HcalForwardLib") <<
"HcalForwardAnalysis::setPhotons(): No Photons!";
165 edm::LogVerbatim(
"HcalForwardLib") <<
"HcalForwardAnalysis::setPhotons() LongFibPhotons: " << LongFiberPhotons.size()
166 <<
" ShortFibPhotons: " << ShortFiberPhotons.size();
167 edm::LogVerbatim(
"HcalForwardLib") <<
"HcalForwardAnalysis::setPhotons() LongFibPhotons: " << LongFiberPhotons.size()
168 <<
" ShortFibPhotons: " << ShortFiberPhotons.size();
172 G4HCofThisEvent* allChamberHC = (*evt)()->GetHCofThisEvent();
174 idHC = G4SDManager::GetSDMpointer()->GetCollectionID(sdName);
178 float primTimeOnSurf = 0;
182 if (idHC >= 0 && theChamberHC !=
nullptr) {
183 edm::LogVerbatim(
"HcalForwardLib") <<
"HcalForwardAnalysis::setPhotons() Chamber Hits size: "
184 << theChamberHC->entries();
185 int thec_hc_entries = theChamberHC->entries();
186 for (
j = 0;
j < thec_hc_entries; ++
j) {
188 edm::LogVerbatim(
"HcalForwardLib") <<
"HcalForwardAnalysis::setPhotons() Chamber Hit id " << aHit->
hitId()
193 primTimeOnSurf = aHit->
time();
196 edm::LogVerbatim(
"HcalForwardLib") <<
"HcalForwardAnalysis::setPhotons(): No Chamber hits. Something is wrong!";
199 primX = primPosOnSurf.x();
200 primY = primPosOnSurf.y();
201 primZ = primPosOnSurf.z();
202 primT = primTimeOnSurf;
207 float photonProdX = 0.;
208 float photonProdY = 0.;
209 float photonProdZ = 0.;
210 float photonProdTime = 0.;
212 double theta = primMomDirOnSurf.theta();
213 double phi = primMomDirOnSurf.phi();
215 for (
unsigned int k = 0;
k < LongFiberPhotons.size(); ++
k) {
219 photonProdY = -aPhoton.
x() *
sin(
phi) + aPhoton.
y() *
cos(
phi) - primPosOnSurf.y();
222 photonProdTime = aPhoton.
t() - primTimeOnSurf;
225 for (
unsigned int k = 0;
k < ShortFiberPhotons.size(); ++
k) {
229 photonProdY = -aPhoton.
x() *
sin(
phi) + aPhoton.
y() *
cos(
phi) - primPosOnSurf.y();
232 photonProdTime = aPhoton.
t() - primTimeOnSurf;
253 cell =
id / 10 -
tower * 10;
254 fiber =
id -
tower * 10000 - cell * 10;
259 for (
int i = 0;
i < 10000; ++
i) {