10 #include <arich/modules/arichBackground/ARICHBackgroundModule.h>
16 #include <simulation/dataobjects/BeamBackHit.h>
17 #include <arich/dataobjects/ARICHSimHit.h>
18 #include <arich/dataobjects/ARICHDigit.h>
20 #include <mdst/dataobjects/MCParticle.h>
23 #include <framework/datastore/StoreArray.h>
24 #include <framework/datastore/RelationIndex.h>
25 #include <framework/datastore/RelationArray.h>
28 #include <framework/logging/Logger.h>
29 #include <framework/gearbox/Const.h>
32 using namespace boost;
52 phVtx(TVector3()), phMmom(TVector3()), phMvtx(TVector3()), phPvtx(TVector3()), phPmom(TVector3()),
53 phGMvtx(TVector3()), phGMmom(TVector3()), modOrig(TVector3()), source(0), phPDG(0), phMPDG(0), phPPDG(0),
54 phGMPDG(0), type(0), edep(0.0), ttime(0.0), moduleID(0), phnw(0.0), trlen(0.0), en(0.0), ff(NULL),
58 setDescription(
"ARICHBackground module. Used to extract information relevant for ARICH background from background files");
61 addParam(
"FileName", m_filename,
"output file name",
string(
"mytree.root"));
62 addParam(
"BkgTag", m_bkgTag,
"background type tag (appended to hits in the output tree", 0);
66 ARICHBackgroundModule::~ARICHBackgroundModule()
71 void ARICHBackgroundModule::initialize()
76 ff =
new TFile(m_filename.c_str(),
"RECREATE");
78 TrHits =
new TTree(
"TrHits",
"tree of arich background hits");
79 TrHits->Branch(
"source", &source,
"source/I");
80 TrHits->Branch(
"phpos",
"TVector3", &phpos);
81 TrHits->Branch(
"phmom",
"TVector3", &phmom);
82 TrHits->Branch(
"phVtx",
"TVector3", &phVtx);
83 TrHits->Branch(
"phMmom",
"TVector3", &phMmom);
84 TrHits->Branch(
"phMvtx",
"TVector3", &phMvtx);
85 TrHits->Branch(
"phPvtx",
"TVector3", &phPvtx);
86 TrHits->Branch(
"phPmom",
"TVector3", &phPmom);
87 TrHits->Branch(
"phGMvtx",
"TVector3", &phGMvtx);
88 TrHits->Branch(
"phGMmom",
"TVector3", &phGMmom);
89 TrHits->Branch(
"modOrig",
"TVector3", &modOrig);
90 TrHits->Branch(
"phPDG", &phPDG,
"phPDG/I");
91 TrHits->Branch(
"phMPDG", &phMPDG,
"phMPDG/I");
92 TrHits->Branch(
"phPPDG", &phPPDG,
"phPPDG/I");
93 TrHits->Branch(
"phGMPDG", &phGMPDG,
"phGMPDG/I");
94 TrHits->Branch(
"type", &type,
"type/I");
95 TrHits->Branch(
"edep", &edep,
"edep/D");
96 TrHits->Branch(
"ttime", &ttime,
"ttime/D");
97 TrHits->Branch(
"moduleID", &moduleID,
"moduleID/I");
98 TrHits->Branch(
"phnw", &phnw,
"phnw/D");
99 TrHits->Branch(
"trlen", &trlen,
"trlen/D");
100 TrHits->Branch(
"en", &en,
"en/D");
105 void ARICHBackgroundModule::beginRun()
108 B2INFO(
"ARICHBackground: Processing. ");
112 void ARICHBackgroundModule::event()
125 for (
int iHit = 0; iHit < nHits; ++iHit) {
129 if (subdet != 4)
continue;
134 phPDG = arichhit->
getPDG();
137 moduleID = m_arichgp->getDetectorPlane().pointSlotID(phpos.X(), phpos.Y());
138 double r = m_arichgp->getDetectorPlane().getSlotR(moduleID);
139 double phi = m_arichgp->getDetectorPlane().getSlotPhi(moduleID);
140 modOrig = TVector3(r * cos(phi), r * sin(phi), 0);
143 if (phPDG == Const::neutron.getPDGCode()) {
147 phVtx = TVector3(0, 0, 0); phMvtx = TVector3(0, 0, 0); phMmom = TVector3(0, 0, 0);
148 phMPDG = -1; phPPDG = -1; phGMPDG = -1;
149 phPvtx = TVector3(0, 0, 0); phPmom = TVector3(0, 0, 0); phGMvtx = TVector3(0, 0, 0); phGMmom = TVector3(0, 0, 0);
159 phMPDG = mother->getPDG();
160 phMvtx = mother->getVertex();
161 phMmom = mother->getMomentum();
164 phGMPDG = mother->getPDG();
165 phGMvtx = mother->getVertex();
166 phGMmom = mother->getMomentum();
168 const MCParticle* pommother = mother->getMother();
170 phPPDG = mother->getPDG();
171 phPvtx = mother->getVertex();
172 phPmom = mother->getMomentum();
184 for (
int iHit = 0; iHit < nHits; ++iHit) {
192 phVtx = TVector3(0, 0, 0); phMvtx = TVector3(0, 0, 0); phMmom = TVector3(0, 0, 0);
193 phMPDG = -1; phPPDG = -1; phGMPDG = -1; phmom = TVector3(0, 0, 0);
194 phPvtx = TVector3(0, 0, 0); phPmom = TVector3(0, 0, 0); phGMvtx = TVector3(0, 0, 0); phGMmom = TVector3(0, 0, 0);
203 phMPDG = mother->getPDG();
204 phMvtx = mother->getVertex();
205 phMmom = mother->getMomentum();
208 phGMPDG = mother->getPDG();
209 phGMvtx = mother->getVertex();
210 phGMmom = mother->getMomentum();
212 const MCParticle* pommother = mother->getMother();
214 phPPDG = mother->getPDG();
215 phPvtx = mother->getVertex();
216 phPmom = mother->getMomentum();
227 void ARICHBackgroundModule::endRun()
231 void ARICHBackgroundModule::terminate()
236 B2INFO(
"ARICHBackground finished.");
244 void ARICHBackgroundModule::printModuleParams()
const
Class ARICHSimHit - Geant4 simulated hit for ARICH.
float getGlobalTime() const override
Get global time of hit.
int getModuleID() const
Get ID number of module that registered hit.
Class BeamBackHit - Stores hits from beam backgound simulation.
double getNeutronWeight() const
get the effective neutron weigth
const TVector3 & getPosition() const
Get global position of the particle hit.
double getEnergy() const
Get energy of the particle.
const TVector3 & getMomentum() const
Get momentum of the particle hit.
double getEnergyDeposit() const
Get particle energy deposit in sensitive volume.
int getPDG() const
Get the lund code of the particle that hit the sensitive area.
double getTrackLength() const
the length of the track in the volume
int getIdentifier() const
Get the identifier of subdetector component in which hit occured.
int getSubDet() const
Det the index of subdetector in which hit occured.
double getTime() const
Get the time at which the hit occured.
A Class to store the Monte Carlo particle information.
TVector3 getVertex() const
Return production vertex position, shorthand for getProductionVertex().
Provides access to fast ( O(log n) ) bi-directional lookups on a specified relation.
const Element * getFirstElementTo(const TO &to) const
Return a pointer to the first relation Element of the given object.
int getEntries() const
Get the number of objects in the array.
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
MCParticle * getMother() const
Returns a pointer to the mother particle.
Abstract base class for different kinds of events.
const FROM * from
pointer of the element from which the relation points.