11 #include <cdc/modules/cdcCosmicSelector/CDCCosmicSelectorModule.h>
12 #include <framework/logging/Logger.h>
24 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.");
25 setPropertyFlags(c_ParallelProcessingCertified);
27 addParam(
"xOfCounter", m_xOfCounter,
"x-position of trigger counter (cm)", -0.6);
28 addParam(
"yOfCounter", m_yOfCounter,
"y-position of trigger counter (cm)", -13.25);
29 addParam(
"zOfCounter", m_zOfCounter,
"z-position of trigger counter (cm)", 17.3);
30 addParam(
"phiOfCounter", m_phiOfCounter,
"phi-angle of trigger counter (deg)", 0.);
31 addParam(
"wOfCounter", m_wOfCounter,
"full-width of trigger counter (cm)", 7.0);
32 addParam(
"lOfCounter", m_lOfCounter,
"full-length of trigger counter (cm)", 12.5);
33 addParam(
"TOF", m_tof,
"Tof=1(2): TOF from production point to trigger counter (IP) is subtracted", 1);
34 addParam(
"TOP", m_top,
"TOP from hit point to pmt in trigger counter is subtracted (assuming PMT is put at -z end of counter",
36 addParam(
"propSpeed", m_propSpeed,
"Light prop. speed in counter (cm/ns)", 14.4);
37 addParam(
"cryGenerator", m_cryGenerator,
"true: CRY generator; false Cosmics generator",
true);
40 void CDCCosmicSelectorModule::initialize()
42 m_mcParticles.isRequired();
46 void CDCCosmicSelectorModule::event()
48 bool returnVal =
false;
50 int nMCPs = m_mcParticles.getEntries();
52 B2ERROR(
"No. of MCParticles=0 in the current event.");
53 setReturnValue(returnVal);
65 const double c = 29.9792458;
66 double mass = 0.1056583715;
67 unsigned nPrimChgds = 0;
69 for (
int iMCPs = 0; iMCPs < nMCPs; ++iMCPs) {
75 unsigned pid = abs(m_P->
getPDG());
78 }
else if (pid == 11) {
80 mass = 0.000510998928;
81 }
else if (pid == 211) {
84 }
else if (pid == 321) {
87 }
else if (pid == 2212) {
95 if (nPrimChgds > 1)
continue;
98 const double vX0 = vertex.X();
99 const double vY0 = vertex.Y();
100 const double cosphi = cos(m_phiOfCounter * M_PI / 180.);
101 const double sinphi = sin(m_phiOfCounter * M_PI / 180.);
103 const double vX = cosphi * vX0 + sinphi * vY0;
104 const double vY = -sinphi * vX0 + cosphi * vY0;
105 const double vZ = vertex.Z();
112 const double pX0 = momentum.X();
113 const double pY0 = momentum.Y();
114 const double pX = cosphi * pX0 + sinphi * pY0;
115 const double pY = -sinphi * pX0 + cosphi * pY0;
116 const double pZ = momentum.Z();
123 const double xOfCounter = cosphi * m_xOfCounter + sinphi * m_yOfCounter;
124 const double yOfCounter = -sinphi * m_xOfCounter + cosphi * m_yOfCounter;
127 xi = (yOfCounter - vY) * (pX / pY) + vX;
129 zi = (yOfCounter - vY) * (pZ / pY) + vZ;
134 zi = -vX * (pZ / pX) + vZ;
139 bool hitCounter = (fabs(xi - xOfCounter) < 0.5 * m_wOfCounter && fabs(zi - m_zOfCounter) < 0.5 * m_lOfCounter) ?
true :
false;
145 const double p = sqrt(pX * pX + pY * pY + pZ * pZ);
146 const double cX = pX / p;
147 const double cY = pY / p;
151 fl = sqrt((xi - vX) * (xi - vX) + (yi - vY) * (yi - vY) + (zi - vZ) * (zi - vZ));
153 }
else if (m_tof == 2) {
154 fl = -(cX * vX + cY * vY) / (cX * cX + cY * cY);
156 B2FATAL(
"invalid tof option !");
163 const double beta = p / sqrt(p * p + mass * mass);
167 if (m_cryGenerator) {
169 double xi4cry = -999.;
171 double zi4cry = -999.;
173 xi4cry = (0. - vY0) * (pX0 / pY0) + vX0;
174 zi4cry = (0. - vY0) * (pZ / pY0) + vZ;
177 zi4cry = -vX0 * (pZ / pX0) + vZ;
180 const double fl4cry = sqrt((xi4cry - vX0) * (xi4cry - vX0) + (yi4cry - vY0) * (yi4cry - vY0) + (zi4cry - vZ) *
184 pTime += fl4cry / (c * beta);
187 const double tofToCounter = fl / (c * beta);
188 const double topToPMT = m_top ? hypot(xi - xOfCounter, zi - (m_zOfCounter - 0.5 * m_lOfCounter)) / m_propSpeed : 0.;
207 setReturnValue(returnVal);