9 #include <reconstruction/modules/CDCDedxElectronCollector/CDCDedxElectronCollectorModule.h>
11 #include <framework/dataobjects/EventMetaData.h>
12 #include <mdst/dataobjects/ECLCluster.h>
31 setDescription(
"A collector module for CDC dE/dx electron calibrations");
34 addParam(
"cleanupCuts", m_cuts,
"Boolean to apply cleanup cuts",
true);
35 addParam(
"maxNumHits", m_maxNumHits,
36 "Maximum number of hits per track. If there is more than this the track will not be collected. ",
int(100));
37 addParam(
"fSetEoverP", fSetEoverP,
"Set E over p Cut values. ",
double(0.25));
38 addParam(
"IsCosth", IsCosth,
"true for adding costh tree branch. ",
false);
39 addParam(
"IsMom", IsMom,
"true for adding momentum tree branch. ",
false);
40 addParam(
"IsCharge", IsCharge,
"true for charge dedx tree branch. ",
false);
41 addParam(
"IsRun", IsRun,
"true for adding run number tree branch. ",
false);
42 addParam(
"IsWire", IsWire,
"true for adding wires tree branch. ",
false);
43 addParam(
"IsLayer", IsLayer,
"true for adding layers tree branch. ",
false);
44 addParam(
"IsDoca", IsDoca,
"true for adding doca tree branch. ",
false);
45 addParam(
"IsEnta", IsEnta,
"true for adding enta tree branch. ",
false);
46 addParam(
"IsDocaRS", IsDocaRS,
"true for adding doca tree branch. ",
false);
47 addParam(
"IsEntaRS", IsEntaRS,
"true for adding enta tree branch. ",
false);
48 addParam(
"Isdedxhit", Isdedxhit,
"true for adding dedxhit tree branch. ",
false);
49 addParam(
"IsBhabhaEvt", IsBhabhaEvt,
"true for bhabha events",
true);
50 addParam(
"IsRadBhabhaEvt", IsRadBhabhaEvt,
"true for radee events",
false);
51 addParam(
"enableTrgSel", enableTrgSel,
"true to enable trigger sel inside module",
false);
66 auto means =
new TH1D(
"means",
"CDC dE/dx truncated means", 250, 0, 2.5);
67 auto ttree =
new TTree(
"tree",
"Tree with dE/dx information");
69 auto hestats =
new TH1I(
"hestats",
"Event Stats", 6, -0.5, 5.5);
70 hestats->SetFillColor(kYellow);
71 hestats->GetXaxis()->SetBinLabel(1,
"all");
72 hestats->GetXaxis()->SetBinLabel(2,
"notrig");
73 hestats->GetXaxis()->SetBinLabel(3,
"noskim");
74 hestats->GetXaxis()->SetBinLabel(4,
"wrongskim");
75 hestats->GetXaxis()->SetBinLabel(5,
"unclean");
76 hestats->GetXaxis()->SetBinLabel(6,
"selected");
78 auto htstats =
new TH1I(
"htstats",
"track Stats", 7, -0.5, 6.5);
79 htstats->SetFillColor(kYellow);
80 htstats->GetXaxis()->SetBinLabel(1,
"alltrk");
81 htstats->GetXaxis()->SetBinLabel(2,
"vtx");
82 htstats->GetXaxis()->SetBinLabel(3,
"inCDC");
83 htstats->GetXaxis()->SetBinLabel(4,
"whits");
84 htstats->GetXaxis()->SetBinLabel(5,
"weop");
85 htstats->GetXaxis()->SetBinLabel(6,
"radee");
86 htstats->GetXaxis()->SetBinLabel(7,
"selected");
88 ttree->Branch<
double>(
"dedx", &
m_dedx);
90 if (
IsMom)ttree->Branch<
double>(
"p", &
m_p);
103 registerObject<TH1D>(
"means", means);
104 registerObject<TTree>(
"tree", ttree);
105 registerObject<TH1I>(
"hestats", hestats);
106 registerObject<TH1I>(
"htstats", htstats);
115 auto hestats = getObjectPtr<TH1I>(
"hestats");
120 B2WARNING(
"SoftwareTriggerResult required to select bhabha/radee event is not found");
126 const std::map<std::string, int>& fresults =
m_TrgResult->getResults();
127 if (fresults.find(
"software_trigger_cut&skim&accept_bhabha") == fresults.end() and
128 fresults.find(
"software_trigger_cut&skim&accept_radee") == fresults.end()) {
129 B2WARNING(
"Can't find required bhabha/radee trigger identifiers");
134 const bool eBhabha = (
m_TrgResult->getResult(
"software_trigger_cut&skim&accept_bhabha") ==
137 const bool eRadBhabha = (
m_TrgResult->getResult(
"software_trigger_cut&skim&accept_radee") ==
141 B2WARNING(
"requested not-supported event type: going back");
145 B2WARNING(
"requested bhabha only but event not found: going back");
149 B2WARNING(
"requested radee only but event not found: going back");
154 hestats->GetXaxis()->SetBinLabel(2,
"inact1");
155 hestats->GetXaxis()->SetBinLabel(3,
"inact2");
156 hestats->GetXaxis()->SetBinLabel(4,
"inact3");
160 int run = eventMetaDataPtr->getRun();
165 B2WARNING(
"too many tracks: unclean bhabha or radee event: " << nTracks);
173 auto tree = getObjectPtr<TTree>(
"tree");
174 auto htstats = getObjectPtr<TH1I>(
"htstats");
175 auto hmeans = getObjectPtr<TH1D>(
"means");
177 for (
int idedx = 0; idedx < nTracks; idedx++) {
181 B2WARNING(
"No dedx track: Going back: " << idedx);
187 B2WARNING(
"No track: Going back: " << idedx);
193 B2WARNING(
"No related fit for this track...");
205 if (fabs(fitResult->
getD0()) >= 1.0)
continue;
206 if (fabs(fitResult->
getZ0()) >= 1.0)
continue;
210 if (
m_costh < TMath::Cos(150.0 * TMath::DegToRad()))
continue;
211 if (
m_costh > TMath::Cos(17.0 * TMath::DegToRad()))
continue;
218 if (m_costh <= -0.62 || m_costh >= 0.880) {
230 if (abs(TrkEoverP - 1.0) >
fSetEoverP)
continue;
236 if (nTracks != 2)
continue;
237 bool goodradee =
false;
240 for (
int jdedx = 0; jdedx < nTracks; jdedx++) {
242 if (!dedxOtherTrack)
continue;
243 if (abs(dedxOtherTrack->
getDedxNoSat() - 1.0) > 0.25)
continue;
247 if (!goodradee)
continue;
267 for (
int i = 0; i <
m_nhits; ++i) {
A collector module for CDC dE/dx electron calibrations.
bool IsWire
flag to write wire number in tree
bool IsEnta
flag to write enta in tree
bool IsBhabhaEvt
flag to select bhabha event
bool IsRadBhabhaEvt
flag to select radee event
double m_dedx
track level information
int m_maxNumHits
module params
std::vector< int > m_wire
hit level information
std::vector< int > m_layer
continuous layer number for the hit
bool m_cuts
Electron collector variables.
StoreArray< TrackFitResult > m_trackFitResults
Required array for TrackFitResults.
std::vector< double > m_dedxhit
dE/dx for the hit
bool IsMom
flag to write momentum in treet
std::vector< double > m_doca
distance of closest approach for the hit
bool IsDocaRS
flag to write rescaled doca in tree
bool IsCosth
flag to write costh in tree
int m_nhits
number of dE/dx hits on the track
virtual void collect() override
Fill ROOT objects.
double fSetEoverP
Cut of E over P value.
StoreArray< Track > m_tracks
Required array for Tracks.
bool enableTrgSel
flag to enable trigger skim selected in the module (off deafult)
bool IsLayer
flag to write layer number in tree
bool IsRun
flag to write run number in tree
virtual void prepare() override
Create and book ROOT objects.
bool IsDoca
flag to write doca in tree
double m_costh
track cos(theta)
bool IsEntaRS
flag to write rescaled enta in tree
std::vector< double > m_entaRS
rescaled entrance angle for the hit
bool IsCharge
flag to write charge in treet
int m_charge
track momentum
std::vector< double > m_enta
entrance angle for the hit
StoreArray< CDCDedxTrack > m_dedxTracks
Required array for CDCDedxTracks.
std::vector< double > m_docaRS
rescaled distance of closest approach for the hit
bool Isdedxhit
flag to write dedxhits in tree
StoreObjPtr< SoftwareTriggerResult > m_TrgResult
required input
Debug output for CDCDedxPID module.
int getHitLayer(int i) const
Return the (global) layer number for a 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.
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 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)
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).
TVector3 getMomentum() const
Getter for vector of momentum at closest approach of track in r/phi projection.
double getD0() const
Getter for d0.
double getZ0() const
Getter for z0.
Class that bundles various TrackFitResults.
#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.