12 #include <arich/modules/arichBackground/ARICHBackgroundModule.h>
18 #include <simulation/dataobjects/BeamBackHit.h>
19 #include <arich/dataobjects/ARICHSimHit.h>
20 #include <arich/dataobjects/ARICHDigit.h>
22 #include <mdst/dataobjects/MCParticle.h>
25 #include <framework/datastore/StoreArray.h>
26 #include <framework/datastore/RelationIndex.h>
27 #include <framework/datastore/RelationArray.h>
30 #include <framework/logging/Logger.h>
33 using namespace boost;
53 phVtx(TVector3()), phMmom(TVector3()), phMvtx(TVector3()), phPvtx(TVector3()), phPmom(TVector3()),
54 phGMvtx(TVector3()), phGMmom(TVector3()), modOrig(TVector3()), source(0), phPDG(0), phMPDG(0), phPPDG(0),
55 phGMPDG(0), type(0), edep(0.0), ttime(0.0), moduleID(0), phnw(0.0), trlen(0.0), en(0.0), ff(NULL),
59 setDescription(
"ARICHBackground module. Used to extract information relevant for ARICH background from background files");
62 addParam(
"FileName", m_filename,
"output file name",
string(
"mytree.root"));
63 addParam(
"BkgTag", m_bkgTag,
"background type tag (appended to hits in the output tree", 0);
67 ARICHBackgroundModule::~ARICHBackgroundModule()
72 void ARICHBackgroundModule::initialize()
77 ff =
new TFile(m_filename.c_str(),
"RECREATE");
79 TrHits =
new TTree(
"TrHits",
"tree of arich background hits");
80 TrHits->Branch(
"source", &source,
"source/I");
81 TrHits->Branch(
"phpos",
"TVector3", &phpos);
82 TrHits->Branch(
"phmom",
"TVector3", &phmom);
83 TrHits->Branch(
"phVtx",
"TVector3", &phVtx);
84 TrHits->Branch(
"phMmom",
"TVector3", &phMmom);
85 TrHits->Branch(
"phMvtx",
"TVector3", &phMvtx);
86 TrHits->Branch(
"phPvtx",
"TVector3", &phPvtx);
87 TrHits->Branch(
"phPmom",
"TVector3", &phPmom);
88 TrHits->Branch(
"phGMvtx",
"TVector3", &phGMvtx);
89 TrHits->Branch(
"phGMmom",
"TVector3", &phGMmom);
90 TrHits->Branch(
"modOrig",
"TVector3", &modOrig);
91 TrHits->Branch(
"phPDG", &phPDG,
"phPDG/I");
92 TrHits->Branch(
"phMPDG", &phMPDG,
"phMPDG/I");
93 TrHits->Branch(
"phPPDG", &phPPDG,
"phPPDG/I");
94 TrHits->Branch(
"phGMPDG", &phGMPDG,
"phGMPDG/I");
95 TrHits->Branch(
"type", &type,
"type/I");
96 TrHits->Branch(
"edep", &edep,
"edep/D");
97 TrHits->Branch(
"ttime", &ttime,
"ttime/D");
98 TrHits->Branch(
"moduleID", &moduleID,
"moduleID/I");
99 TrHits->Branch(
"phnw", &phnw,
"phnw/D");
100 TrHits->Branch(
"trlen", &trlen,
"trlen/D");
101 TrHits->Branch(
"en", &en,
"en/D");
106 void ARICHBackgroundModule::beginRun()
109 B2INFO(
"ARICHBackground: Processing. ");
113 void ARICHBackgroundModule::event()
126 for (
int iHit = 0; iHit < nHits; ++iHit) {
130 if (subdet != 4)
continue;
135 phPDG = arichhit->
getPDG();
138 moduleID = m_arichgp->getDetectorPlane().pointSlotID(phpos.X(), phpos.Y());
139 double r = m_arichgp->getDetectorPlane().getSlotR(moduleID);
140 double phi = m_arichgp->getDetectorPlane().getSlotPhi(moduleID);
141 modOrig = TVector3(r * cos(phi), r * sin(phi), 0);
148 phVtx = TVector3(0, 0, 0); phMvtx = TVector3(0, 0, 0); phMmom = TVector3(0, 0, 0);
149 phMPDG = -1; phPPDG = -1; phGMPDG = -1;
150 phPvtx = TVector3(0, 0, 0); phPmom = TVector3(0, 0, 0); phGMvtx = TVector3(0, 0, 0); phGMmom = TVector3(0, 0, 0);
160 phMPDG = mother->getPDG();
161 phMvtx = mother->getVertex();
162 phMmom = mother->getMomentum();
165 phGMPDG = mother->getPDG();
166 phGMvtx = mother->getVertex();
167 phGMmom = mother->getMomentum();
169 const MCParticle* pommother = mother->getMother();
171 phPPDG = mother->getPDG();
172 phPvtx = mother->getVertex();
173 phPmom = mother->getMomentum();
185 for (
int iHit = 0; iHit < nHits; ++iHit) {
193 phVtx = TVector3(0, 0, 0); phMvtx = TVector3(0, 0, 0); phMmom = TVector3(0, 0, 0);
194 phMPDG = -1; phPPDG = -1; phGMPDG = -1; phmom = TVector3(0, 0, 0);
195 phPvtx = TVector3(0, 0, 0); phPmom = TVector3(0, 0, 0); phGMvtx = TVector3(0, 0, 0); phGMmom = TVector3(0, 0, 0);
204 phMPDG = mother->getPDG();
205 phMvtx = mother->getVertex();
206 phMmom = mother->getMomentum();
209 phGMPDG = mother->getPDG();
210 phGMvtx = mother->getVertex();
211 phGMmom = mother->getMomentum();
213 const MCParticle* pommother = mother->getMother();
215 phPPDG = mother->getPDG();
216 phPvtx = mother->getVertex();
217 phPmom = mother->getMomentum();
228 void ARICHBackgroundModule::endRun()
232 void ARICHBackgroundModule::terminate()
237 B2INFO(
"ARICHBackground finished.");
245 void ARICHBackgroundModule::printModuleParams()
const