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.");
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",
46 bool returnVal =
false;
50 B2ERROR(
"No. of MCParticles=0 in the current event.");
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();
101 const double vX = cosphi * vX0 + sinphi * vY0;
102 const double vY = -sinphi * vX0 + cosphi * vY0;
103 const double vZ = vertex.Z();
108 const ROOT::Math::XYZVector momentum = m_P->
getMomentum();
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();
125 xi = (yOfCounter - vY) * (pX / pY) + vX;
127 zi = (yOfCounter - vY) * (pZ / pY) + vZ;
132 zi = -vX * (pZ / pX) + vZ;
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);
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);
double m_propSpeed
Light speed in counter (cm/ns)
void initialize() override
Initialize variables, print info, and start CPU clock.
double m_wOfCounter
full-width of counter (cm)
double m_xOfCounter
x-pos.
void event() override
Actual digitization of all hits in the CDC.
double m_phiOfCounter
phi-angle of counter (deg)
double m_lOfCounter
full-length of counter (cm)
double m_yOfCounter
y-pos.
bool m_cryGenerator
cry or cosmics generator
double m_zOfCounter
z-pos.
CDCCosmicSelectorModule()
Constructor.
StoreArray< MCParticle > m_mcParticles
array of MCParticle
A Class to store the Monte Carlo particle information.
ROOT::Math::XYZVector getProductionVertex() const
Return production vertex position.
int getPDG() const
Return PDG code of particle.
float getProductionTime() const
Return production time in ns.
ROOT::Math::XYZVector getMomentum() const
Return momentum.
void setProductionTime(float time)
Set production time.
void setDescription(const std::string &description)
Sets the description of the module.
void setPropertyFlags(unsigned int propertyFlags)
Sets the flags for the module properties.
void setReturnValue(int value)
Sets the return value for this module as integer.
@ c_ParallelProcessingCertified
This module can be run in parallel processing mode safely (All I/O must be done through the data stor...
bool isRequired(const std::string &name="")
Ensure this array/object has been registered previously.
int getEntries() const
Get the number of objects in the array.
void addParam(const std::string &name, T ¶mVariable, const std::string &description, const T &defaultValue)
Adds a new parameter to the module.
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
double sqrt(double a)
sqrt for double
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.