24 #include "G4HCofThisEvent.hh" 25 #include "G4SDManager.hh" 28 #include "G4ThreeVector.hh" 29 #include "G4VProcess.hh" 31 #include <CLHEP/Units/GlobalSystemOfUnits.h> 32 #include <CLHEP/Units/GlobalPhysicalConstants.h> 41 public Observer<const BeginOfEvent*>,
84 float x[10000],
y[10000],
z[10000],
t[10000],
lambda[10000];
102 for (
int i = 0;
i < 10000; ++
i) {
127 theTree =
theFile->make<TTree>(
"CherenkovPhotons",
"Cherenkov Photons");
129 theTree->Branch(
"x", &
x,
"x[nphot]/F");
130 theTree->Branch(
"y", &
y,
"y[nphot]/F");
131 theTree->Branch(
"z", &
z,
"z[nphot]/F");
132 theTree->Branch(
"t", &
t,
"t[nphot]/F");
150 int irun = (*run)()->GetRunID();
155 evNum = (*evt)()->GetEventID();
169 edm::LogVerbatim(
"HcalForwardLib") <<
"HcalForwardAnalysis::Fill event " << (*evt)()->GetEventID();
173 int iEvt = (*evt)()->GetEventID();
175 edm::LogVerbatim(
"HcalForwardLib") <<
"HcalForwardAnalysis:: Event " << iEvt;
176 else if ((iEvt < 100) && (iEvt % 10 == 0))
177 edm::LogVerbatim(
"HcalForwardLib") <<
"HcalForwardAnalysis:: Event " << iEvt;
178 else if ((iEvt < 1000) && (iEvt % 100 == 0))
179 edm::LogVerbatim(
"HcalForwardLib") <<
"HcalForwardAnalysis:: Event " << iEvt;
180 else if ((iEvt < 10000) && (iEvt % 1000 == 0))
181 edm::LogVerbatim(
"HcalForwardLib") <<
"HcalForwardAnalysis:: Event " << iEvt;
189 G4HCofThisEvent* allHC = (*evt)()->GetHCofThisEvent();
191 edm::LogVerbatim(
"HcalForwardLib") <<
"HcalForwardAnalysis:: Has " << allHC->GetNumberOfCollections()
193 for (
int k = 0;
k < allHC->GetNumberOfCollections(); ++
k) {
194 G4String
name = (allHC->GetHC(
k) ==
nullptr) ?
"Unknown" : allHC->GetHC(
k)->GetName();
195 G4String nameSD = (allHC->GetHC(
k) ==
nullptr) ?
"Unknown" : allHC->GetHC(
k)->GetSDname();
196 edm::LogVerbatim(
"HcalForwardLib") <<
"Collecttion[" <<
k <<
"] " << allHC->GetHC(
k) <<
" " <<
name <<
":" 201 idHC = G4SDManager::GetSDMpointer()->GetCollectionID(
sdName);
204 edm::LogVerbatim(
"HcalForwardLib") <<
"HcalForwardAnalysis::setPhotons() Hit Collection for " <<
sdName <<
" of ID " 205 << idHC <<
" is obtained at " << theHC;
207 std::vector<HFShowerPhoton> ShortFiberPhotons;
208 std::vector<HFShowerPhoton> LongFiberPhotons;
209 LongFiberPhotons.clear();
210 ShortFiberPhotons.clear();
211 if (idHC >= 0 && theHC !=
nullptr) {
212 int thehc_entries = theHC->entries();
216 for (
j = 0;
j < thehc_entries;
j++) {
218 std::vector<HFShowerPhoton> thePhotonsFromHit = aHit->
photon();
220 edm::LogVerbatim(
"HcalForwardLib") <<
"Fiberhit " <<
j <<
" has " << thePhotonsFromHit.size() <<
" photons.";
226 for (
unsigned int iph = 0; iph < thePhotonsFromHit.size(); ++iph) {
227 if (aHit->
depth() == 1)
228 LongFiberPhotons.push_back(thePhotonsFromHit[iph]);
229 if (aHit->
depth() == 2)
230 ShortFiberPhotons.push_back(thePhotonsFromHit[iph]);
233 edm::LogVerbatim(
"HcalForwardLib") <<
"HcalForwardAnalysis::setPhotons() NbPhotons " << thePhotonsFromHit.size()
234 <<
" towerId " << fTowerId <<
" cellId " << fCellId <<
" fiberId " << fFiberId
235 <<
" depth " << aHit->
depth();
241 edm::LogVerbatim(
"HcalForwardLib") <<
"HcalForwardAnalysis::setPhotons(): No Photons!";
245 edm::LogVerbatim(
"HcalForwardLib") <<
"HcalForwardAnalysis::setPhotons() LongFibPhotons: " << LongFiberPhotons.size()
246 <<
" ShortFibPhotons: " << ShortFiberPhotons.size();
247 edm::LogVerbatim(
"HcalForwardLib") <<
"HcalForwardAnalysis::setPhotons() LongFibPhotons: " << LongFiberPhotons.size()
248 <<
" ShortFibPhotons: " << ShortFiberPhotons.size();
252 G4HCofThisEvent* allChamberHC = (*evt)()->GetHCofThisEvent();
254 idHC = G4SDManager::GetSDMpointer()->GetCollectionID(
sdName);
258 float primTimeOnSurf = 0;
263 if (idHC >= 0 && theChamberHC !=
nullptr) {
264 edm::LogVerbatim(
"HcalForwardLib") <<
"HcalForwardAnalysis::setPhotons() Chamber Hits size: " 265 << theChamberHC->entries();
266 int thec_hc_entries = theChamberHC->entries();
267 for (
j = 0;
j < thec_hc_entries; ++
j) {
270 edm::LogVerbatim(
"HcalForwardLib") <<
"HcalForwardAnalysis::setPhotons() Chamber Hit id " << aHit->
hitId()
276 primTimeOnSurf = aHit->
time();
279 edm::LogVerbatim(
"HcalForwardLib") <<
"HcalForwardAnalysis::setPhotons(): No Chamber hits are stored";
283 primX = primPosOnSurf.x();
284 primY = primPosOnSurf.y();
285 primZ = primPosOnSurf.z();
287 edm::LogVerbatim(
"HcalForwardLib") <<
"HcalForwardAnalysis::setPhotons(): First interaction before HF";
291 primT = primTimeOnSurf;
296 double theta = primMomDirOnSurf.theta();
297 double phi = primMomDirOnSurf.phi();
305 double pex = 0, pey = 0,
zv = 0;
308 for (
unsigned int k = 0;
k < LongFiberPhotons.size(); ++
k) {
316 pex =
xx * ctheta * cphi +
yy * ctheta * sphi -
zz * stheta;
317 pey = -
xx * sphi +
yy * cphi;
318 zv =
xx * stheta * cphi +
yy * stheta * sphi +
zz * ctheta -
primZ / ctheta;
320 double photonProdTime = aPhoton.
t() - primTimeOnSurf;
323 for (
unsigned int k = 0;
k < ShortFiberPhotons.size(); ++
k) {
331 pex =
xx * ctheta * cphi +
yy * ctheta * sphi -
zz * stheta;
332 pey = -
xx * sphi +
yy * cphi;
333 zv =
xx * stheta * cphi +
yy * stheta * sphi +
zz * ctheta -
primZ / ctheta;
335 double photonProdTime = aPhoton.
t() - primTimeOnSurf;
342 edm::LogVerbatim(
"HcalForwardLib") <<
"HcalForwardAnalysis: =====> filledEvent";
358 cell =
id / 10 -
tower * 10;
364 for (
int i = 0;
i < 10000; ++
i) {
Log< level::Info, true > LogVerbatim
#define DEFINE_SIMWATCHER(type)
T getParameter(std::string const &) const
G4ThreeVector globalPosition() const
Sin< T >::type sin(const T &t)
~HcalForwardAnalysis() override
void setPhotons(const EndOfEvent *evt)
Photon(int id, float X, float Y, float Z, float T, float Lambda)
std::vector< Photon > thePhotons
const HcalForwardAnalysis & operator=(const HcalForwardAnalysis &)=delete
Cos< T >::type cos(const T &t)
std::vector< HFShowerPhoton > photon() const
G4ThreeVector primaryMomDir() const
void update(const BeginOfRun *run) override
This routine will be called when the appropriate signal arrives.
XYZPointD XYZPoint
point in space with cartesian internal representation
std::vector< std::string > theNames
G4THitsCollection< FiberG4Hit > FiberG4HitsCollection
HcalForwardAnalysis(const edm::ParameterSet &p)
Geom::Theta< T > theta() const
G4THitsCollection< HFShowerG4Hit > HFShowerG4HitsCollection
void parseDetId(int id, int &tower, int &cell, int &fiber)
void produce(edm::Event &, const edm::EventSetup &) override