9 #include <cdc/modules/cdcCosmicSelector/CDCCosmicSelectorModule.h>
10 #include <framework/logging/Logger.h>
22 setDescription(
"Modify MCParticles for cosmics so that the global time is zero at y=0 assuming a cosmic trajectory is a line. And select cosmics passing through a trigger counter. This module works only for the event with the no. of primary charged MC particles=1. Please place this module after the event-generator and before FullSim.");
23 setPropertyFlags(c_ParallelProcessingCertified);
25 addParam(
"xOfCounter", m_xOfCounter,
"x-position of trigger counter (cm)", -0.6);
26 addParam(
"yOfCounter", m_yOfCounter,
"y-position of trigger counter (cm)", -13.25);
27 addParam(
"zOfCounter", m_zOfCounter,
"z-position of trigger counter (cm)", 17.3);
28 addParam(
"phiOfCounter", m_phiOfCounter,
"phi-angle of trigger counter (deg)", 0.);
29 addParam(
"wOfCounter", m_wOfCounter,
"full-width of trigger counter (cm)", 7.0);
30 addParam(
"lOfCounter", m_lOfCounter,
"full-length of trigger counter (cm)", 12.5);
31 addParam(
"TOF", m_tof,
"Tof=1(2): TOF from production point to trigger counter (IP) is subtracted", 1);
32 addParam(
"TOP", m_top,
"TOP from hit point to pmt in trigger counter is subtracted (assuming PMT is put at -z end of counter",
34 addParam(
"propSpeed", m_propSpeed,
"Light prop. speed in counter (cm/ns)", 14.4);
35 addParam(
"cryGenerator", m_cryGenerator,
"true: CRY generator; false Cosmics generator",
true);
38 void CDCCosmicSelectorModule::initialize()
40 m_mcParticles.isRequired();
44 void CDCCosmicSelectorModule::event()
46 bool returnVal =
false;
48 int nMCPs = m_mcParticles.getEntries();
50 B2ERROR(
"No. of MCParticles=0 in the current event.");
51 setReturnValue(returnVal);
63 const double c = 29.9792458;
64 double mass = 0.1056583715;
65 unsigned nPrimChgds = 0;
67 for (
int iMCPs = 0; iMCPs < nMCPs; ++iMCPs) {
73 unsigned pid = abs(m_P->
getPDG());
76 }
else if (pid == 11) {
78 mass = 0.000510998928;
79 }
else if (pid == 211) {
82 }
else if (pid == 321) {
85 }
else if (pid == 2212) {
93 if (nPrimChgds > 1)
continue;
96 const double vX0 = vertex.X();
97 const double vY0 = vertex.Y();
98 const double cosphi = cos(m_phiOfCounter * M_PI / 180.);
99 const double sinphi = sin(m_phiOfCounter * M_PI / 180.);
101 const double vX = cosphi * vX0 + sinphi * vY0;
102 const double vY = -sinphi * vX0 + cosphi * vY0;
103 const double vZ = vertex.Z();
110 const double pX0 = momentum.X();
111 const double pY0 = momentum.Y();
112 const double pX = cosphi * pX0 + sinphi * pY0;
113 const double pY = -sinphi * pX0 + cosphi * pY0;
114 const double pZ = momentum.Z();
121 const double xOfCounter = cosphi * m_xOfCounter + sinphi * m_yOfCounter;
122 const double yOfCounter = -sinphi * m_xOfCounter + cosphi * m_yOfCounter;
125 xi = (yOfCounter - vY) * (pX / pY) + vX;
127 zi = (yOfCounter - vY) * (pZ / pY) + vZ;
132 zi = -vX * (pZ / pX) + vZ;
137 bool hitCounter = (fabs(xi - xOfCounter) < 0.5 * m_wOfCounter && fabs(zi - m_zOfCounter) < 0.5 * m_lOfCounter) ?
true :
false;
143 const double p = sqrt(pX * pX + pY * pY + pZ * pZ);
144 const double cX = pX / p;
145 const double cY = pY / p;
149 fl = sqrt((xi - vX) * (xi - vX) + (yi - vY) * (yi - vY) + (zi - vZ) * (zi - vZ));
151 }
else if (m_tof == 2) {
152 fl = -(cX * vX + cY * vY) / (cX * cX + cY * cY);
154 B2FATAL(
"invalid tof option !");
161 const double beta = p / sqrt(p * p + mass * mass);
165 if (m_cryGenerator) {
167 double xi4cry = -999.;
169 double zi4cry = -999.;
171 xi4cry = (0. - vY0) * (pX0 / pY0) + vX0;
172 zi4cry = (0. - vY0) * (pZ / pY0) + vZ;
175 zi4cry = -vX0 * (pZ / pX0) + vZ;
178 const double fl4cry = sqrt((xi4cry - vX0) * (xi4cry - vX0) + (yi4cry - vY0) * (yi4cry - vY0) + (zi4cry - vZ) *
182 pTime += fl4cry / (c * beta);
185 const double tofToCounter = fl / (c * beta);
186 const double topToPMT = m_top ? hypot(xi - xOfCounter, zi - (m_zOfCounter - 0.5 * m_lOfCounter)) / m_propSpeed : 0.;
205 setReturnValue(returnVal);
A Class to store the Monte Carlo particle information.
TVector3 getMomentum() const
Return momentum.
int getPDG() const
Return PDG code of particle.
float getProductionTime() const
Return production time in ns.
TVector3 getProductionVertex() const
Return production vertex position.
void setProductionTime(float time)
Set production time.
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
bool isPrimaryParticle() const
Check if particle is a primary particle which was created by the generator (and not,...
Abstract base class for different kinds of events.