9#include <cdc/modules/CDCDedxElectronCollector/CDCDedxElectronCollectorModule.h>
11#include <mdst/dataobjects/ECLCluster.h>
31 setDescription(
"A collector module for CDC dE/dx electron calibrations");
35 addParam(
"cleanupCuts",
m_cuts,
"boolean to apply cleanup cuts",
true);
39 addParam(
"isMom",
m_isMom,
"true for adding momentum tree branch. ",
false);
40 addParam(
"isPt",
m_isPt,
"true for adding transverse momentum tree branch. ",
false);
42 addParam(
"isRun",
m_isRun,
"true for adding run number tree branch. ",
false);
52 addParam(
"islLayer",
m_islLayer,
"true for adding layers for ldedx tree branch. ",
false);
53 addParam(
"islDedx",
m_islDedx,
"true for adding layer dedx tree branch. ",
false);
71 auto means =
new TH1D(
"means",
"CDC dE/dx truncated means", 250, 0, 2.5);
72 auto ttree =
new TTree(
"tree",
"Tree with dE/dx information");
74 auto hestats =
new TH1I(
"hestats",
"Event Stats", 6, -0.5, 5.5);
75 hestats->SetFillColor(kYellow);
76 hestats->GetXaxis()->SetBinLabel(1,
"all");
77 hestats->GetXaxis()->SetBinLabel(2,
"notrig");
78 hestats->GetXaxis()->SetBinLabel(3,
"noskim");
79 hestats->GetXaxis()->SetBinLabel(4,
"wrongskim");
80 hestats->GetXaxis()->SetBinLabel(5,
"unclean");
81 hestats->GetXaxis()->SetBinLabel(6,
"selected");
83 auto htstats =
new TH1I(
"htstats",
"track Stats", 7, -0.5, 6.5);
84 htstats->SetFillColor(kYellow);
85 htstats->GetXaxis()->SetBinLabel(1,
"alltrk");
86 htstats->GetXaxis()->SetBinLabel(2,
"vtx");
87 htstats->GetXaxis()->SetBinLabel(3,
"inCDC");
88 htstats->GetXaxis()->SetBinLabel(4,
"whits");
89 htstats->GetXaxis()->SetBinLabel(5,
"weop");
90 htstats->GetXaxis()->SetBinLabel(6,
"radee");
91 htstats->GetXaxis()->SetBinLabel(7,
"selected");
94 ttree->Branch<
double>(
"injtime", &
m_injTime);
95 ttree->Branch<
double>(
"injring", &
m_injRing);
96 ttree->Branch<
double>(
"costh", &
m_costh);
97 ttree->Branch<
int>(
"nhits", &
m_nhits);
98 ttree->Branch<
double>(
"p", &
m_p);
101 ttree->Branch<
double>(
"dedx", &
m_dedx);
104 if (
m_isPt)ttree->Branch<
double>(
"pt", &
m_pt);
138 B2WARNING(
"SoftwareTriggerResult required to select bhabha/radee event is not found");
144 const std::map<std::string, int>& fresults =
m_trgResult->getResults();
145 if (fresults.find(
"software_trigger_cut&skim&accept_bhabha") == fresults.end() and
146 fresults.find(
"software_trigger_cut&skim&accept_bhabha_cdc") == fresults.end()) {
147 B2WARNING(
"Can't find required bhabha/radee trigger identifiers");
152 const bool eBhabha = (
m_trgResult->getResult(
"software_trigger_cut&skim&accept_bhabha") ==
155 const bool eRadBhabha = (
m_trgResult->getResult(
"software_trigger_cut&skim&accept_bhabha_cdc") ==
159 B2WARNING(
"requested not-supported event type: going back");
163 B2WARNING(
"requested bhabha only but event not found: going back");
167 B2WARNING(
"requested radee only but event not found: going back");
172 hestats->GetXaxis()->SetBinLabel(2,
"inact1");
173 hestats->GetXaxis()->SetBinLabel(3,
"inact2");
174 hestats->GetXaxis()->SetBinLabel(4,
"inact3");
178 int run = eventMetaDataPtr->getRun();
182 B2WARNING(
"too many tracks: unclean bhabha or radee event: " << nTracks);
194 for (
int idedx = 0; idedx < nTracks; idedx++) {
198 B2WARNING(
"No dedx track: Going back: " << idedx);
204 B2WARNING(
"No track: Going back: " << idedx);
210 B2WARNING(
"No related fit for this track...");
228 if (std::abs(fitResult->
getD0()) >= 1.0)
continue;
229 if (std::abs(fitResult->
getZ0()) >= 1.0)
continue;
233 if (
m_costh < TMath::Cos(150.0 * TMath::DegToRad()))
continue;
234 if (
m_costh > TMath::Cos(17.0 * TMath::DegToRad()))
continue;
255 if (std::abs(TrkEoverP - 1.0) >
m_setEoP)
continue;
262 if (nTracks != 2)
continue;
263 bool goodradee =
false;
266 for (
int jdedx = 0; jdedx < nTracks; jdedx++) {
268 if (!dedxOtherTrack)
continue;
269 if (std::abs(dedxOtherTrack->
getDedxNoSat() - 1.0) > 0.25)
continue;
273 if (!goodradee)
continue;
291 for (
int i = 0; i <
m_nhits; ++i) {
307 for (
int i = 0; i <
m_nlhits; ++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
int m_nlhits
number of layer dE/dx hits on the track
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.
bool m_islDedx
flag to write layer dedx in tree
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)
std::vector< double > m_ldedx
dE/dx for the layer
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
bool m_islLayer
flag to write layer number for layer dedx in tree
double m_pt
track level information
double m_setEoP
Cut of E over P value.
double m_injTime
time since last injection
std::vector< int > m_lLayer
continuous layer number for the layerdE/dx
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.
int getLayer(int i) const
Return the (global) layer number for a layer 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 getLayerDedx(int i) const
Return the total dE/dx for this layer.
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(const std::string &name, T *obj)
Register object with a name, takes ownership, do not access the pointer beyond prepare()
T * getObjectPtr(const std::string &name)
Calls the CalibObjManager to get the requested stored collector data.
CalibrationCollectorModule()
Constructor. Sets the default prefix for calibration dataobjects.
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.