9#include <cdc/modules/CDCDedxElectronCollector/CDCDedxElectronCollectorModule.h>
30 setDescription(
"A collector module for CDC dE/dx electron calibrations");
34 addParam(
"cleanupCuts",
m_cuts,
"boolean to apply cleanup cuts",
true);
38 addParam(
"isMom",
m_isMom,
"true for adding momentum tree branch. ",
false);
39 addParam(
"isPt",
m_isPt,
"true for adding transverse momentum tree branch. ",
false);
41 addParam(
"isRun",
m_isRun,
"true for adding run number tree branch. ",
false);
68 auto means =
new TH1D(
"means",
"CDC dE/dx truncated means", 250, 0, 2.5);
69 auto ttree =
new TTree(
"tree",
"Tree with dE/dx information");
71 auto hestats =
new TH1I(
"hestats",
"Event Stats", 6, -0.5, 5.5);
72 hestats->SetFillColor(kYellow);
73 hestats->GetXaxis()->SetBinLabel(1,
"all");
74 hestats->GetXaxis()->SetBinLabel(2,
"notrig");
75 hestats->GetXaxis()->SetBinLabel(3,
"noskim");
76 hestats->GetXaxis()->SetBinLabel(4,
"wrongskim");
77 hestats->GetXaxis()->SetBinLabel(5,
"unclean");
78 hestats->GetXaxis()->SetBinLabel(6,
"selected");
80 auto htstats =
new TH1I(
"htstats",
"track Stats", 7, -0.5, 6.5);
81 htstats->SetFillColor(kYellow);
82 htstats->GetXaxis()->SetBinLabel(1,
"alltrk");
83 htstats->GetXaxis()->SetBinLabel(2,
"vtx");
84 htstats->GetXaxis()->SetBinLabel(3,
"inCDC");
85 htstats->GetXaxis()->SetBinLabel(4,
"whits");
86 htstats->GetXaxis()->SetBinLabel(5,
"weop");
87 htstats->GetXaxis()->SetBinLabel(6,
"radee");
88 htstats->GetXaxis()->SetBinLabel(7,
"selected");
91 ttree->Branch<
double>(
"injtime", &
m_injTime);
92 ttree->Branch<
double>(
"injring", &
m_injRing);
93 ttree->Branch<
double>(
"costh", &
m_costh);
94 ttree->Branch<
int>(
"nhits", &
m_nhits);
95 ttree->Branch<
double>(
"p", &
m_p);
98 ttree->Branch<
double>(
"dedx", &
m_dedx);
101 if (
m_isPt)ttree->Branch<
double>(
"pt", &
m_pt);
132 B2WARNING(
"SoftwareTriggerResult required to select bhabha/radee event is not found");
138 const std::map<std::string, int>& fresults =
m_trgResult->getResults();
139 if (fresults.find(
"software_trigger_cut&skim&accept_bhabha") == fresults.end() and
140 fresults.find(
"software_trigger_cut&skim&accept_radee") == fresults.end()) {
141 B2WARNING(
"Can't find required bhabha/radee trigger identifiers");
146 const bool eBhabha = (
m_trgResult->getResult(
"software_trigger_cut&skim&accept_bhabha") ==
149 const bool eRadBhabha = (
m_trgResult->getResult(
"software_trigger_cut&skim&accept_radee") ==
153 B2WARNING(
"requested not-supported event type: going back");
157 B2WARNING(
"requested bhabha only but event not found: going back");
161 B2WARNING(
"requested radee only but event not found: going back");
166 hestats->GetXaxis()->SetBinLabel(2,
"inact1");
167 hestats->GetXaxis()->SetBinLabel(3,
"inact2");
168 hestats->GetXaxis()->SetBinLabel(4,
"inact3");
172 int run = eventMetaDataPtr->getRun();
176 B2WARNING(
"too many tracks: unclean bhabha or radee event: " << nTracks);
188 for (
int idedx = 0; idedx < nTracks; idedx++) {
192 B2WARNING(
"No dedx track: Going back: " << idedx);
198 B2WARNING(
"No track: Going back: " << idedx);
204 B2WARNING(
"No related fit for this track...");
221 if (std::abs(fitResult->
getD0()) >= 1.0)
continue;
222 if (std::abs(fitResult->
getZ0()) >= 1.0)
continue;
226 if (
m_costh < TMath::Cos(150.0 * TMath::DegToRad()))
continue;
227 if (
m_costh > TMath::Cos(17.0 * TMath::DegToRad()))
continue;
248 if (std::abs(TrkEoverP - 1.0) >
m_setEoP)
continue;
255 if (nTracks != 2)
continue;
256 bool goodradee =
false;
259 for (
int jdedx = 0; jdedx < nTracks; jdedx++) {
261 if (!dedxOtherTrack)
continue;
262 if (std::abs(dedxOtherTrack->
getDedxNoSat() - 1.0) > 0.25)
continue;
266 if (!goodradee)
continue;
284 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.
void registerObject(std::string name, T *obj)
Register object with a name, takes ownership, do not access the pointer beyond prepare()
CalibrationCollectorModule()
Constructor. Sets the default prefix for calibration dataobjects.
T * getObjectPtr(std::string name)
Calls the CalibObjManager to get the requested stored collector data.
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.