1 #include <tracking/modules/trackFinderVXDTests/StudyMaterialEffectsModule.h>
3 #include <framework/pcore/ProcHandler.h>
4 #include <framework/logging/Logger.h>
6 #include <mdst/dataobjects/MCParticle.h>
7 #include <svd/dataobjects/SVDCluster.h>
9 #include <vxd/geometry/SensorInfoBase.h>
23 setDescription(
"StudyMaterialEffects- should be used with single track pGuns and without magnetic field.");
25 setPropertyFlags(c_ParallelProcessingCertified | c_TerminateInAllProcesses);
29 void StudyMaterialEffectsModule::initialize()
31 m_spacePoints.isRequired(
"spacePoints");
33 m_file =
new TFile(
"materialStudy.root",
"RECREATE");
37 m_tree.registerInDataStore();
38 m_tree.construct(
"materialEffectsStudyTree",
"Raw data of two-hit-combinations for a sectorMap");
40 m_tree->get().Branch(
"ResidualPhiL3L3", &(m_PhiL3L3));
41 m_tree->get().Branch(
"ResidualPhiL3L4", &(m_PhiL3L4));
42 m_tree->get().Branch(
"ResidualPhiL3L6", &(m_PhiL3L6));
43 m_tree->get().Branch(
"ResidualThetaL3L3", &(m_ThetaL3L3));
44 m_tree->get().Branch(
"ResidualThetaL3L4", &(m_ThetaL3L4));
45 m_tree->get().Branch(
"ResidualThetaL3L6", &(m_ThetaL3L6));
46 m_tree->get().Branch(
"ResidualScatterAngleL3L3", &(m_ScatterAngleL3L3));
47 m_tree->get().Branch(
"ResidualScatterAngleL3L4", &(m_ScatterAngleL3L4));
48 m_tree->get().Branch(
"ResidualcatterAngleL3L6", &(m_ScatterAngleL3L6));
49 m_tree->get().Branch(
"ResidualScatterAngleV2GradL3L3", &(m_ScatterAngleGradL3L3));
50 m_tree->get().Branch(
"ResidualScatterAngleV2GradL3L4", &(m_ScatterAngleGradL3L4));
51 m_tree->get().Branch(
"ResidualScatterAngleV2GradL3L6", &(m_ScatterAngleGradL3L6));
52 m_tree->get().Branch(
"ResidualScatterAngleV3GradL3L3", &(m_ScatterAngleV3GradL3L3));
53 m_tree->get().Branch(
"ResidualScatterAngleV3GradL3L4", &(m_ScatterAngleV3GradL3L4));
54 m_tree->get().Branch(
"ResidualScatterAngleV3GradL3L6", &(m_ScatterAngleV3GradL3L6));
55 m_tree->get().Branch(
"ResidualcatterAngleL3L6", &(m_ScatterAngleL3L6));
56 m_tree->get().Branch(
"ResidualXYL3L4", &(m_distXY));
57 m_tree->get().Branch(
"ResidualMomentumL3bL3e", &(m_deltaPL3L3));
58 m_tree->get().Branch(
"ResidualMomentumL3bL4b", &(m_deltaPL3L4));
59 m_tree->get().Branch(
"ResidualMomentumL3bL6e", &(m_deltaPL3L6));
61 B2WARNING(
"StudyMaterialEffectsModule::initialize: nBranches: " << m_tree->get().GetNbranches());
66 void StudyMaterialEffectsModule::event()
78 bool wasFoundL3(
false);
79 bool wasFoundL4(
false);
80 bool wasFoundL6(
false);
83 for (
const auto& aSP : m_spacePoints) {
84 VxdID vxdID = aSP.getVxdID();
86 if (trueHit ==
nullptr)
continue;
88 B2Vector3D entryHitPos = getGlobalPosition(trueHit, vxdID,
true);
89 B2Vector3D exitHitPos = getGlobalPosition(trueHit, vxdID,
false);
90 B2Vector3D entryMomentum = getGlobalMomentumVector(trueHit, vxdID,
true);
91 B2Vector3D exitMomentum = getGlobalMomentumVector(trueHit, vxdID,
false);
93 l3HitPosBegin = entryHitPos;
94 l3HitPosEnd = exitHitPos;
95 l3MomentumBegin = entryMomentum;
96 l3MomentumEnd = exitMomentum;
100 l4HitPosBegin = entryHitPos;
101 l4MomentumBegin = entryMomentum;
105 l6HitPosEnd = exitHitPos;
106 l6MomentumEnd = exitMomentum;
111 if (!wasFoundL3 or !wasFoundL4 or !wasFoundL6)
return;
112 m_COUNTERsuccessfullEvents++;
114 m_PhiL3L3 = l3HitPosBegin.
Phi() - l3HitPosEnd.
Phi();
115 m_PhiL3L4 = l3HitPosBegin.
Phi() - l4HitPosBegin.
Phi();
116 m_PhiL3L6 = l3HitPosBegin.
Phi() - l6HitPosEnd.
Phi();
118 m_ThetaL3L3 = l3HitPosBegin.
Theta() - l3HitPosEnd.
Theta();
119 m_ThetaL3L4 = l3HitPosBegin.
Theta() - l4HitPosBegin.
Theta();
120 m_ThetaL3L6 = l3HitPosBegin.
Theta() - l6HitPosEnd.
Theta();
122 m_ScatterAngleL3L3 = sqrt(pow(m_ThetaL3L3, 2) + pow(m_PhiL3L3, 2));
123 m_ScatterAngleL3L4 = sqrt(pow(m_ThetaL3L4, 2) + pow(m_PhiL3L4, 2));
124 m_ScatterAngleL3L6 = sqrt(pow(m_ThetaL3L6, 2) + pow(m_PhiL3L6, 2));
126 m_ScatterAngleGradL3L3 = (l3HitPosEnd - l3HitPosBegin).Angle(l3HitPosBegin) * 180. / TMath::Pi();
127 m_ScatterAngleGradL3L4 = (l4HitPosBegin - l3HitPosBegin).Angle(l3HitPosBegin) * 180. / TMath::Pi();
128 m_ScatterAngleGradL3L6 = (l6HitPosEnd - l3HitPosBegin).Angle(l3HitPosBegin) * 180. / TMath::Pi();
131 m_ScatterAngleV3GradL3L3 = l3MomentumEnd.
Angle(l3MomentumBegin) * 180. / TMath::Pi();
132 m_ScatterAngleV3GradL3L4 = l4MomentumBegin.
Angle(l3MomentumBegin) * 180. / TMath::Pi();
133 m_ScatterAngleV3GradL3L6 = l6MomentumEnd.
Angle(l3MomentumBegin) * 180. / TMath::Pi();
136 m_distXY = (l3HitPosBegin - l4HitPosBegin).Perp();
138 m_deltaPL3L3 = l3MomentumBegin.
Mag() - l3MomentumEnd.
Mag();
139 m_deltaPL3L4 = l3MomentumBegin.
Mag() - l4MomentumBegin.
Mag();
140 m_deltaPL3L6 = l3MomentumBegin.
Mag() - l6MomentumEnd.
Mag();
142 m_tree->get().Fill();
147 void StudyMaterialEffectsModule::terminate()
149 B2WARNING(
"StudyMaterialEffects: there were " << m_COUNTERsuccessfullEvents <<
" events with hits resulting in root output");
152 if (!ProcHandler::parallelProcessingUsed() or ProcHandler::isOutputProcess()) {
154 m_tree->write(m_file);
180 if (aMcParticle.hasStatus(MCParticle::c_PrimaryParticle) ==
false)
continue;