9#include <reconstruction/modules/CDCDedxElectronCollector/CDCDedxElectronCollectorModule.h>
29 setDescription(
"A collector module for CDC dE/dx electron calibrations");
33 addParam(
"cleanupCuts",
m_cuts,
"boolean to apply cleanup cuts",
true);
37 addParam(
"isMom",
m_isMom,
"true for adding momentum tree branch. ",
false);
38 addParam(
"isPt",
m_isPt,
"true for adding transverse momentum tree branch. ",
false);
40 addParam(
"isRun",
m_isRun,
"true for adding run number tree branch. ",
false);
67 auto means =
new TH1D(
"means",
"CDC dE/dx truncated means", 250, 0, 2.5);
68 auto ttree =
new TTree(
"tree",
"Tree with dE/dx information");
70 auto hestats =
new TH1I(
"hestats",
"Event Stats", 6, -0.5, 5.5);
71 hestats->SetFillColor(kYellow);
72 hestats->GetXaxis()->SetBinLabel(1,
"all");
73 hestats->GetXaxis()->SetBinLabel(2,
"notrig");
74 hestats->GetXaxis()->SetBinLabel(3,
"noskim");
75 hestats->GetXaxis()->SetBinLabel(4,
"wrongskim");
76 hestats->GetXaxis()->SetBinLabel(5,
"unclean");
77 hestats->GetXaxis()->SetBinLabel(6,
"selected");
79 auto htstats =
new TH1I(
"htstats",
"track Stats", 7, -0.5, 6.5);
80 htstats->SetFillColor(kYellow);
81 htstats->GetXaxis()->SetBinLabel(1,
"alltrk");
82 htstats->GetXaxis()->SetBinLabel(2,
"vtx");
83 htstats->GetXaxis()->SetBinLabel(3,
"inCDC");
84 htstats->GetXaxis()->SetBinLabel(4,
"whits");
85 htstats->GetXaxis()->SetBinLabel(5,
"weop");
86 htstats->GetXaxis()->SetBinLabel(6,
"radee");
87 htstats->GetXaxis()->SetBinLabel(7,
"selected");
90 ttree->Branch<
double>(
"injtime", &
m_injTime);
91 ttree->Branch<
double>(
"injring", &
m_injRing);
92 ttree->Branch<
double>(
"costh", &
m_costh);
93 ttree->Branch<
int>(
"nhits", &
m_nhits);
94 ttree->Branch<
double>(
"p", &
m_p);
97 ttree->Branch<
double>(
"dedx", &
m_dedx);
100 if (
m_isPt)ttree->Branch<
double>(
"pt", &
m_pt);
114 registerObject<TH1D>(
"means", means);
115 registerObject<TTree>(
"tree", ttree);
116 registerObject<TH1I>(
"hestats", hestats);
117 registerObject<TH1I>(
"htstats", htstats);
126 auto hestats = getObjectPtr<TH1I>(
"hestats");
131 B2WARNING(
"SoftwareTriggerResult required to select bhabha/radee event is not found");
137 const std::map<std::string, int>& fresults =
m_trgResult->getResults();
138 if (fresults.find(
"software_trigger_cut&skim&accept_bhabha") == fresults.end() and
139 fresults.find(
"software_trigger_cut&skim&accept_radee") == fresults.end()) {
140 B2WARNING(
"Can't find required bhabha/radee trigger identifiers");
145 const bool eBhabha = (
m_trgResult->getResult(
"software_trigger_cut&skim&accept_bhabha") ==
148 const bool eRadBhabha = (
m_trgResult->getResult(
"software_trigger_cut&skim&accept_radee") ==
152 B2WARNING(
"requested not-supported event type: going back");
156 B2WARNING(
"requested bhabha only but event not found: going back");
160 B2WARNING(
"requested radee only but event not found: going back");
165 hestats->GetXaxis()->SetBinLabel(2,
"inact1");
166 hestats->GetXaxis()->SetBinLabel(3,
"inact2");
167 hestats->GetXaxis()->SetBinLabel(4,
"inact3");
171 int run = eventMetaDataPtr->getRun();
175 B2WARNING(
"too many tracks: unclean bhabha or radee event: " << nTracks);
183 auto tree = getObjectPtr<TTree>(
"tree");
184 auto htstats = getObjectPtr<TH1I>(
"htstats");
185 auto hmeans = getObjectPtr<TH1D>(
"means");
187 for (
int idedx = 0; idedx < nTracks; idedx++) {
191 B2WARNING(
"No dedx track: Going back: " << idedx);
197 B2WARNING(
"No track: Going back: " << idedx);
203 B2WARNING(
"No related fit for this track...");
220 if (fabs(fitResult->
getD0()) >= 1.0)
continue;
221 if (fabs(fitResult->
getZ0()) >= 1.0)
continue;
225 if (
m_costh < TMath::Cos(150.0 * TMath::DegToRad()))
continue;
226 if (
m_costh > TMath::Cos(17.0 * TMath::DegToRad()))
continue;
235 if (m_costh <= -0.62 || m_costh >= 0.880) {
247 if (abs(TrkEoverP - 1.0) >
m_setEoP)
continue;
254 if (nTracks != 2)
continue;
255 bool goodradee =
false;
258 for (
int jdedx = 0; jdedx < nTracks; jdedx++) {
260 if (!dedxOtherTrack)
continue;
261 if (abs(dedxOtherTrack->
getDedxNoSat() - 1.0) > 0.25)
continue;
265 if (!goodradee)
continue;
283 for (
int i = 0; i <
m_nhits; ++i) {
bool m_isEntaRS
flag to write rescaled enta in tree
bool m_isLayer
flag to write layer number in tree
bool m_isEnta
flag to write enta in tree
bool m_isPt
flag to write trans momentum in treet
bool m_isADCcorr
flag to write adc corrected in tree
bool m_isWire
flag to write wire number in tree
int m_maxHits
module params
std::vector< double > m_adccorr
adc corrected for the hit
double m_dedx
dE/dx truncated mean
bool m_isCosth
flag to write costh in tree
bool m_isRadee
flag to select radee event
std::vector< int > m_wire
hit level information
bool m_isMom
flag to write momentum in treet
std::vector< int > m_layer
continuous layer number for the hit
bool m_cuts
Electron collector variables.
bool m_isRun
flag to write run number in tree
StoreArray< TrackFitResult > m_trackFitResults
Required array for TrackFitResults.
bool m_isTrgSel
flag to enable trigger skim selected in the module (off default)
bool m_isCharge
flag to write charge in treet
StoreObjPtr< SoftwareTriggerResult > m_trgResult
required input
std::vector< double > m_dedxhit
dE/dx for the hit
std::vector< double > m_doca
distance of closest approach for the hit
int m_nhits
number of dE/dx hits on the track
virtual void collect() override
Fill ROOT objects.
StoreArray< Track > m_tracks
Required array for Tracks.
bool m_isDedxhit
flag to write dedxhits in tree
bool m_isBhabha
flag to select bhabha event
double m_injRing
event level information
virtual void prepare() override
Create and book ROOT objects.
CDCDedxElectronCollectorModule()
Constructor: Sets the description, the properties and the parameters of the module.
double m_costh
track cos(theta)
std::vector< double > m_entaRS
rescaled entrance angle for the hit
bool m_isInjTime
flag to enable trigger skim (off default)
int m_charge
track momentum
bool m_isDoca
flag to write doca in tree
std::vector< double > m_enta
entrance angle for the hit
StoreArray< CDCDedxTrack > m_dedxTracks
Required array for CDCDedxTracks.
bool m_isDocaRS
flag to write rescaled doca in tree
std::vector< double > m_docaRS
rescaled distance of closest approach for the hit
double m_pt
track level information
double m_setEoP
Cut of E over P value.
double m_injTime
time since last injection
Debug output for CDCDedxPID module.
int getHitLayer(int i) const
Return the (global) layer number for a hit.
int getADCCount(int i) const
Return the adcCount for this hit.
double getDoca(int i) const
Return the distance of closest approach to the sense wire for this hit.
double getDedx() const
Get dE/dx truncated mean for this track.
double getEntaRS(int i) const
Return rescaled enta value for cell height=width assumption.
double getCellHalfWidth(int i) const
Return the half-width of the CDC cell.
int getNLayerHits() const
Return the number of layer hits for this track.
double getCosTheta() const
Return cos(theta) for this track.
double getInjectionRing() const
Return cos(theta) for this track.
int getWire(int i) const
Return the sensor ID for this hit: wire number for CDC (0-14336)
double getDocaRS(int i) const
Return rescaled doca value for cell height=width assumption.
double getEnta(int i) const
Return the entrance angle in the CDC cell for this hit.
double getInjectionTime() const
Return cos(theta) for this track.
double getDedxNoSat() const
Get dE/dx truncated mean without the saturation correction for this track.
int size() const
Return the number of hits for this track.
double getMomentum() const
Return the track momentum valid in the CDC.
Calibration collector module base class.
static const ChargedStable pion
charged pion particle
bool hasHypothesis(EHypothesisBit bitmask) const
Return if specific hypothesis bit is set.
double getEnergy(EHypothesisBit hypothesis) const
Return Energy (GeV).
@ c_nPhotons
CR is split into n photons (N1)
void setDescription(const std::string &description)
Sets the description of the module.
FROM * getRelatedFrom(const std::string &name="", const std::string &namedRelation="") const
Get the object from which this object has a relation.
Type-safe access to single objects in the data store.
Values of the result of a track fit with a given particle hypothesis.
short getChargeSign() const
Return track charge (1 or -1).
double getD0() const
Getter for d0.
double getTransverseMomentum() const
Getter for the absolute value of the transverse momentum at the perigee.
double getZ0() const
Getter for z0.
ROOT::Math::XYZVector getMomentum() const
Getter for vector of momentum at closest approach of track in r/phi projection.
Class that bundles various TrackFitResults.
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.
@ c_accept
Accept this event.
Abstract base class for different kinds of events.