21 #include "G4SDManager.hh" 22 #include "G4VProcess.hh" 23 #include "G4HCofThisEvent.hh" 24 #include "CLHEP/Units/GlobalSystemOfUnits.h" 25 #include "CLHEP/Units/GlobalPhysicalConstants.h" 36 for (
int i = 0;
i < 10000; ++
i) {
72 theTree->Branch(
"x", &
x,
"x[nphot]/F");
73 theTree->Branch(
"y", &
y,
"y[nphot]/F");
74 theTree->Branch(
"z", &
z,
"z[nphot]/F");
75 theTree->Branch(
"t", &
t,
"t[nphot]/F");
94 int irun = (*run)()->GetRunID();
95 edm::LogInfo(
"HcalForwardLib") <<
" =====> Begin of Run = " << irun;
101 evNum = (*evt)()->GetEventID();
103 edm::LogInfo(
"HcalForwardLib") <<
"HcalForwardAnalysis: =====> Begin of event = " <<
evNum;
114 LogDebug(
"HcalForwardLib")<<
"HcalForwardAnalysis::Fill event " 115 << (*evt)()->GetEventID();
118 int iEvt = (*evt)()->GetEventID();
120 edm::LogInfo(
"HcalForwardLib") <<
"HcalForwardAnalysis:: Event " << iEvt;
121 else if ((iEvt < 100) && (iEvt%10 == 0))
122 edm::LogInfo(
"HcalForwardLib") <<
"HcalForwardAnalysis:: Event " << iEvt;
123 else if ((iEvt < 1000) && (iEvt%100 == 0))
124 edm::LogInfo(
"HcalForwardLib") <<
"HcalForwardAnalysis:: Event " << iEvt;
125 else if ((iEvt < 10000) && (iEvt%1000 == 0))
126 edm::LogInfo(
"HcalForwardLib") <<
"HcalForwardAnalysis:: Event " << iEvt;
134 G4HCofThisEvent* allHC = (*evt)()->GetHCofThisEvent();
136 idHC = G4SDManager::GetSDMpointer()->GetCollectionID(sdName);
138 LogDebug(
"HcalForwardLib")<<
"HcalForwardAnalysis::setPhotons() Hit Collection for " << sdName
139 <<
" of ID " << idHC <<
" is obtained at " << theHC;
140 std::vector<HFShowerPhoton> ShortFiberPhotons;
141 std::vector<HFShowerPhoton> LongFiberPhotons;
142 LongFiberPhotons.clear();
143 ShortFiberPhotons.clear();
144 if (idHC >= 0 && theHC !=
nullptr) {
145 std::cout <<
"FiberhitSize " << theHC->entries() << std::endl;
146 for (j = 0; j < theHC->entries(); j++) {
148 std::vector<HFShowerPhoton> thePhotonsFromHit = aHit->
photon();
149 std::cout <<
"Fiberhit " << j <<
" has " << thePhotonsFromHit.size() <<
" photons." << std::endl;
154 for(
unsigned int iph = 0; iph < thePhotonsFromHit.size(); ++iph){
155 if(aHit->
depth() == 1)LongFiberPhotons.push_back(thePhotonsFromHit[iph]);
156 if(aHit->
depth() == 2)ShortFiberPhotons.push_back(thePhotonsFromHit[iph]);
158 LogDebug(
"HcalForwardLib") <<
"HcalForwardAnalysis::setPhotons() NbPhotons " << thePhotonsFromHit.size()
159 <<
" towerId " << fTowerId <<
" cellId " << fCellId <<
" fiberId " << fFiberId <<
" depth " << aHit->
depth();
162 LogDebug(
"HcalForwardLib") <<
"HcalForwardAnalysis::setPhotons(): No Photons!";
165 LogDebug(
"HcalForwardLib") <<
"HcalForwardAnalysis::setPhotons() LongFibPhotons: " 166 << LongFiberPhotons.size() <<
" ShortFibPhotons: " << ShortFiberPhotons.size();
167 std::cout <<
"HcalForwardAnalysis::setPhotons() LongFibPhotons: " 168 << LongFiberPhotons.size() <<
" ShortFibPhotons: " << ShortFiberPhotons.size() << std::endl;
172 G4HCofThisEvent* allChamberHC = (*evt)()->GetHCofThisEvent();
174 idHC = G4SDManager::GetSDMpointer()->GetCollectionID(sdName);
178 float primTimeOnSurf = 0;
182 if(idHC >= 0 && theChamberHC !=
nullptr) {
183 LogDebug(
"HcalForwardLib") <<
"HcalForwardAnalysis::setPhotons() Chamber Hits size: " << theChamberHC->entries();
184 for(j = 0; j < theChamberHC->entries();++j) {
186 LogDebug(
"HcalForwardLib") <<
"HcalForwardAnalysis::setPhotons() Chamber Hit id " << aHit->
hitId()
191 primTimeOnSurf = aHit->
time();
194 LogDebug(
"HcalForwardLib") <<
"HcalForwardAnalysis::setPhotons(): No Chamber hits. Something is wrong!";
197 primX = primPosOnSurf.x();
198 primY = primPosOnSurf.y();
199 primZ = primPosOnSurf.z();
200 primT = primTimeOnSurf;
205 float photonProdX = 0.;
206 float photonProdY = 0.;
207 float photonProdZ = 0.;
208 float photonProdTime = 0.;
210 double theta = primMomDirOnSurf.theta();
211 double phi = primMomDirOnSurf.phi();
213 for(
unsigned int k = 0;
k < LongFiberPhotons.size(); ++
k){
215 photonProdX = aPhoton.
x()*
cos(theta)*
cos(phi) + aPhoton.
y()*
cos(theta)*
sin(phi) - aPhoton.
z()*
sin(theta) - primPosOnSurf.x();
216 photonProdY = -aPhoton.
x()*
sin(phi) + aPhoton.
y()*
cos(phi) - primPosOnSurf.y();
217 photonProdZ = aPhoton.
x()*
sin(theta)*
cos(phi) + aPhoton.
y()*
sin(theta)*
sin(phi) + aPhoton.
z()*
cos(theta) - primPosOnSurf.z();
218 photonProdTime = aPhoton.
t()- primTimeOnSurf;
221 for(
unsigned int k = 0;
k < ShortFiberPhotons.size(); ++
k){
223 photonProdX = aPhoton.
x()*
cos(theta)*
cos(phi) + aPhoton.
y()*
cos(theta)*
sin(phi) - aPhoton.
z()*
sin(theta) - primPosOnSurf.x();
224 photonProdY = -aPhoton.
x()*
sin(phi) + aPhoton.
y()*
cos(phi) - primPosOnSurf.y();
225 photonProdZ = aPhoton.
x()*
sin(theta)*
cos(phi) + aPhoton.
y()*
sin(theta)*
sin(phi) + aPhoton.
z()*
cos(theta) - primPosOnSurf.z();
226 photonProdTime = aPhoton.
t()- primTimeOnSurf;
247 cell =
id / 10 - tower * 10;
248 fiber =
id - tower * 10000 - cell * 10;
253 for (
int i = 0;
i < 10000; ++
i) {
T getParameter(std::string const &) const
G4ThreeVector primaryMomDir() const
Sin< T >::type sin(const T &t)
Geom::Theta< T > theta() const
T * make(const Args &...args) const
make new ROOT object
~HcalForwardAnalysis() override
void setPhotons(const EndOfEvent *evt)
std::vector< Photon > thePhotons
Cos< T >::type cos(const T &t)
std::vector< HFShowerPhoton > photon() const
void update(const BeginOfRun *run) override
This routine will be called when the appropriate signal arrives.
edm::Service< TFileService > theFile
XYZPointD XYZPoint
point in space with cartesian internal representation
std::vector< std::string > theNames
G4THitsCollection< FiberG4Hit > FiberG4HitsCollection
G4ThreeVector globalPosition() const
HcalForwardAnalysis(const edm::ParameterSet &p)
G4THitsCollection< HFShowerG4Hit > HFShowerG4HitsCollection
void parseDetId(int id, int &tower, int &cell, int &fiber)
void produce(edm::Event &, const edm::EventSetup &) override