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 if (idHC >= 0 && theHC !=
nullptr) {
133 std::cout <<
"FiberhitSize " << theHC->entries() << std::endl;
134 for (j = 0; j < theHC->entries(); j++) {
136 std::vector<HFShowerPhoton> thePhotonsFromHit = aHit->
photon();
137 std::cout <<
"Fiberhit " << j <<
" has " << thePhotonsFromHit.size() <<
" photons." << std::endl;
142 for (
unsigned int iph = 0; iph < thePhotonsFromHit.size(); ++iph) {
143 if (aHit->
depth() == 1)
144 LongFiberPhotons.push_back(thePhotonsFromHit[iph]);
145 if (aHit->
depth() == 2)
146 ShortFiberPhotons.push_back(thePhotonsFromHit[iph]);
148 LogDebug(
"HcalForwardLib") <<
"HcalForwardAnalysis::setPhotons() NbPhotons " << thePhotonsFromHit.size()
149 <<
" towerId " << fTowerId <<
" cellId " << fCellId <<
" fiberId " << fFiberId
150 <<
" depth " << aHit->
depth();
153 LogDebug(
"HcalForwardLib") <<
"HcalForwardAnalysis::setPhotons(): No Photons!";
156 LogDebug(
"HcalForwardLib") <<
"HcalForwardAnalysis::setPhotons() LongFibPhotons: " << LongFiberPhotons.size()
157 <<
" ShortFibPhotons: " << ShortFiberPhotons.size();
158 std::cout <<
"HcalForwardAnalysis::setPhotons() LongFibPhotons: " << LongFiberPhotons.size()
159 <<
" ShortFibPhotons: " << ShortFiberPhotons.size() << std::endl;
163 G4HCofThisEvent* allChamberHC = (*evt)()->GetHCofThisEvent();
165 idHC = G4SDManager::GetSDMpointer()->GetCollectionID(sdName);
169 float primTimeOnSurf = 0;
173 if (idHC >= 0 && theChamberHC !=
nullptr) {
174 LogDebug(
"HcalForwardLib") <<
"HcalForwardAnalysis::setPhotons() Chamber Hits size: " << theChamberHC->entries();
175 for (j = 0; j < theChamberHC->entries(); ++
j) {
177 LogDebug(
"HcalForwardLib") <<
"HcalForwardAnalysis::setPhotons() Chamber Hit id " << aHit->
hitId() <<
" track id " 182 primTimeOnSurf = aHit->
time();
185 LogDebug(
"HcalForwardLib") <<
"HcalForwardAnalysis::setPhotons(): No Chamber hits. Something is wrong!";
188 primX = primPosOnSurf.x();
189 primY = primPosOnSurf.y();
190 primZ = primPosOnSurf.z();
191 primT = primTimeOnSurf;
196 float photonProdX = 0.;
197 float photonProdY = 0.;
198 float photonProdZ = 0.;
199 float photonProdTime = 0.;
201 double theta = primMomDirOnSurf.theta();
202 double phi = primMomDirOnSurf.phi();
204 for (
unsigned int k = 0;
k < LongFiberPhotons.size(); ++
k) {
206 photonProdX = aPhoton.
x() *
cos(theta) *
cos(phi) + aPhoton.
y() *
cos(theta) *
sin(phi) - aPhoton.
z() *
sin(theta) -
208 photonProdY = -aPhoton.
x() *
sin(phi) + aPhoton.
y() *
cos(phi) - primPosOnSurf.y();
209 photonProdZ = aPhoton.
x() *
sin(theta) *
cos(phi) + aPhoton.
y() *
sin(theta) *
sin(phi) + aPhoton.
z() *
cos(theta) -
211 photonProdTime = aPhoton.
t() - primTimeOnSurf;
214 for (
unsigned int k = 0;
k < ShortFiberPhotons.size(); ++
k) {
216 photonProdX = aPhoton.
x() *
cos(theta) *
cos(phi) + aPhoton.
y() *
cos(theta) *
sin(phi) - aPhoton.
z() *
sin(theta) -
218 photonProdY = -aPhoton.
x() *
sin(phi) + aPhoton.
y() *
cos(phi) - primPosOnSurf.y();
219 photonProdZ = aPhoton.
x() *
sin(theta) *
cos(phi) + aPhoton.
y() *
sin(theta) *
sin(phi) + aPhoton.
z() *
cos(theta) -
221 photonProdTime = aPhoton.
t() - primTimeOnSurf;
242 cell =
id / 10 - tower * 10;
243 fiber =
id - tower * 10000 - cell * 10;
248 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