9#include <cdc/modules/CDCDedxDQM/CDCDedxDQM.h>
11#include <cdc/geometry/CDCGeometryPar.h>
13#include <analysis/utility/ReferenceFrame.h>
14#include <mdst/dataobjects/Track.h>
15#include <mdst/dataobjects/ECLCluster.h>
16#include <mdst/dbobjects/BeamSpot.h>
18#include <TDirectory.h>
30 addParam(
"mmode",
mmode,
"default monitoring mode is basic", std::string(
"basic"));
37 TDirectory* oldDir = gDirectory;
38 oldDir->mkdir(
"CDCDedx");
39 oldDir->cd(
"CDCDedx");
43 double rungain = -99.0;
51 hMeta =
new TH1D(
"hMeta",
"hMeta", 3, 0.5, 3.5);
52 hMeta->GetXaxis()->SetTitle(
"Quantity");
53 hMeta->GetYaxis()->SetTitle(
"Values");
54 hMeta->SetTitle(Form(
"(Exp:%d, Run:%d, RG:%0.03f)", expNum, runNum, rungain));
55 hMeta->GetXaxis()->SetBinLabel(1,
"nevt");
56 hMeta->GetXaxis()->SetBinLabel(2,
"nbhabha");
57 hMeta->GetXaxis()->SetBinLabel(3,
"nhadron");
59 hdEdx =
new TH1D(
"hdEdx",
";CDC dE/dx;Entries", 100, 0., 2.5);
60 hinjtimeHer =
new TH2D(
"hinjtimeHer",
";injection time (#mu s); CDC dE/dx", 40, 0, 80e3, 50, 0, 2.5);
61 hinjtimeLer =
new TH2D(
"hinjtimeLer",
";injection time (#mu s); CDC dE/dx", 40, 0, 80e3, 50, 0, 2.5);
62 hdEdxvsP =
new TH2D(
"hdEdxVsP",
";#it{p}_{CDC} (GeV/c);CDC dE/dx", 100, 0.05, 2.50, 100, 0.35, 10.0);
63 hdEdxvsEvt =
new TH2D(
"hdEdxvsEvt",
";Events(M);CDC dE/dx", 50, 0, 200, 50, 0.00, 2.0);
64 hdEdxvsCosth =
new TH2D(
"hdEdxvsCosth",
";cos#theta (e^{-}e^{+} tracks);CDC dE/dx", 50, -1.00, 1.00, 50, 0.00, 2.5);
65 hdEdxvsPhi =
new TH2D(
"hdEdxvsPhi",
";#phi (e^{-}e^{+} tracks);CDC dE/dx", 50, -3.20, 3.20, 50, 0.00, 2.5);
66 if (
mmode !=
"basic") {
67 hWires =
new TH2F(
"hWires",
"All Wires;", 2400, -1.2, 1.2, 2400, -1.2, 1.2);
68 hWires->GetXaxis()->SetTitle(
"CDC-wire map: counter-clockwise and start from +x");
69 hWireStatus =
new TH2F(
"hWireStatus",
"Wire Status", 2400, -1.2, 1.2, 2400, -1.2, 1.2);
70 hWireStatus->GetXaxis()->SetTitle(
"CDC-wire map: counter-clockwise and start from +x");
82 B2WARNING(
"Missing CDCDedxTracks array, CDCDedxDQM is skipped.");
97 B2WARNING(
"Missing CDCDedxTracks array, CDCDedxDQM is skipped.");
109 if (
mmode !=
"basic") {
123 B2WARNING(
"Required SoftwareTriggerResult object not available: CDCDedxDQM is skipped");
127 const std::map<std::string, int>& fresults =
m_TrgResult->getResults();
128 if (fresults.find(
"software_trigger_cut&skim&accept_bhabha") == fresults.end()
129 and fresults.find(
"software_trigger_cut&skim&accept_hadron") == fresults.end())
return;
131 const bool IsBhabhaEvt = (
m_TrgResult->getResult(
"software_trigger_cut&skim&accept_bhabha") ==
133 const bool IsHadronEvt = (
m_TrgResult->getResult(
"software_trigger_cut&skim&accept_hadron") ==
137 if (!IsBhabhaEvt and !IsHadronEvt)
return;
149 if (!dedxTrack || dedxTrack->
size() == 0)
continue;
155 if (!fitResult)
continue;
159 helix.
passiveMoveBy(ROOT::Math::XYZVector(beamSpotDB->getIPPosition()));
161 double dr = frame.getVertex(ROOT::Math::XYZVector(helix.getPerigee())).Rho();
162 double dz = frame.getVertex(ROOT::Math::XYZVector(helix.getPerigee())).Z();
163 if (dr >= 1.0 || fabs(dz) >= 1.0)
continue;
167 if (costh < TMath::Cos(150.0 * TMath::DegToRad()))
continue;
168 if (costh > TMath::Cos(17.0 * TMath::DegToRad()))
continue;
172 if (costh > -0.55 && costh < 0.820) {
173 if (nhits < 20)
continue;
175 if (costh <= -0.62 || costh >= 0.880) {
176 if (nhits < 8)
continue;
177 if (costh > 0 && nhits < 10)
continue;
179 if (nhits < 15)
continue;
184 if (dedxnosat < 0)
continue;
186 double dedx = dedxTrack->
getDedx();
187 if (dedx < 0)
continue;
190 if (pCDC <= 0)
continue;
193 if (pTrk <= 0)
continue;
200 if (abs(TrkEoverP - 1.0) > 0.25)
continue;
204 hdEdx->Fill(dedxnosat);
209 if (
event >= 150e6)
event = 150e6 - 100;
210 event = int(
event / 5e5);
223 if (IsHadronEvt &&
hdEdxvsP->Integral() <= 80000)
hdEdxvsP->Fill(pCDC, dedx);
225 if (
mmode !=
"basic") {
226 for (
int ihit = 0; ihit < dedxTrack->
size(); ++ihit) {
227 int iwire = dedxTrack->
getWire(ihit);
229 if (
m_adc[iwire].size() < 50)
m_adc[iwire].push_back(iadc);
244 if (
hdEdx->GetEntries() > 0) {
245 hdEdx->GetXaxis()->SetRange(
hdEdx->FindFirstBinAbove(0, 1),
hdEdx->FindLastBinAbove(0, 1));
266 B2INFO(
"CDCDedxDQMModule: terminate called");
273 B2INFO(
"Creating CDCGeometryPar object");
279 for (
unsigned int ilay = 0; ilay < c_maxNSenseLayers; ++ilay) {
280 for (
unsigned int iwire = 0; iwire < cdcgeo.
nWiresInLayer(ilay); ++iwire) {
282 double phi = 2.*TMath::Pi() * (iwire / double(cdcgeo.
nWiresInLayer(ilay)));
283 double radius = cdcgeo.
senseWireR(ilay) / 100.;
284 double x = radius * cos(phi);
285 double y = radius * sin(phi);
287 if (
m_adc[jwire].size() > 0)
continue;
TH2F * hWireStatus
dead wire status
DBObjPtr< CDCDedxRunGain > m_DBRunGain
Run gain DB object.
TH2D * hdEdxvsCosth
dedx vs costh
virtual void initialize() override
Initialize the module.
TH2F * hWires
all wire mapping
virtual void event() override
This method is called for each event.
virtual void endRun() override
This method is called at the end of each run.
virtual void terminate() override
End of the event processing.
StoreObjPtr< EventMetaData > m_MetaDataPtr
Store array for metadata info.
virtual void beginRun() override
This method is called for each run.
StoreArray< CDCDedxTrack > m_cdcDedxTracks
Store array for CDCDedxTrack.
int m_nEvt
accepted events
TH2D * hdEdxvsPhi
dedx vs phi
std::array< std::vector< double >, c_nSenseWires > m_adc
adc per wire for wire status
TH2D * hdEdxvsEvt
dedx vs event
StoreObjPtr< EventLevelTriggerTimeInfo > TTDInfo
Store array for injection time info.
CDCDedxDQMModule()
Default constructor.
TH2D * hinjtimeLer
injection time in LER
TH2D * hinjtimeHer
injection time in HER
void plotWireMap()
function to plot wire status map (all, bad)
std::string mmode
monitoring mode all/basic
StoreObjPtr< SoftwareTriggerResult > m_TrgResult
Store array for Trigger selection.
virtual void defineHisto() override
Definition of histograms.
Debug output for CDCDedxPID module.
int getADCCount(int i) const
Return the adcCount for this hit.
double getDedx() const
Get dE/dx truncated mean for this track.
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 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.
The Class for CDC Geometry Parameters.
unsigned nWiresInLayer(int layerId) const
Returns wire numbers in a layer.
static CDCGeometryPar & Instance(const CDCGeometry *=nullptr)
Static method to get a reference to the CDCGeometryPar instance.
double senseWireR(int layerId) const
Returns radius of sense wire in each layer.
static const ChargedStable pion
charged pion particle
Class for accessing objects in the database.
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)
HistoModule()
Constructor.
void setDescription(const std::string &description)
Sets the description of the module.
void setPropertyFlags(unsigned int propertyFlags)
Sets the flags for the module properties.
@ c_ParallelProcessingCertified
This module can be run in parallel processing mode safely (All I/O must be done through the data stor...
static const ReferenceFrame & GetCurrent()
Get current rest frame.
FROM * getRelatedFrom(const std::string &name="", const std::string &namedRelation="") const
Get the object from which this object has a relation.
Values of the result of a track fit with a given particle hypothesis.
ROOT::Math::XYZVector getMomentum() const
Getter for vector of momentum at closest approach of track in r/phi projection.
UncertainHelix getUncertainHelix() const
Conversion to framework Uncertain Helix (i.e., with covariance).
Class that bundles various TrackFitResults.
This class represents an ideal helix in perigee parameterization including the covariance matrix of t...
double passiveMoveBy(const ROOT::Math::XYZVector &by)
Moves origin of the coordinate system (passive transformation) by the given vector.
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.