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>
32 addParam(
"mmode",
mmode,
"default monitoring mode is basic", std::string(
"basic"));
39 TDirectory* oldDir = gDirectory;
40 oldDir->mkdir(
"CDCDedx");
41 oldDir->cd(
"CDCDedx");
45 double rungain = -99.0;
53 hMeta =
new TH1D(
"hMeta",
"hMeta", 3, 0.5, 3.5);
54 hMeta->GetXaxis()->SetTitle(
"Quantity");
55 hMeta->GetYaxis()->SetTitle(
"Values");
56 hMeta->SetTitle(Form(
"(Exp:%d, Run:%d, RG:%0.03f)", expNum, runNum, rungain));
57 hMeta->GetXaxis()->SetBinLabel(1,
"nevt");
58 hMeta->GetXaxis()->SetBinLabel(2,
"nbhabha");
59 hMeta->GetXaxis()->SetBinLabel(3,
"nhadron");
61 hdEdx =
new TH1D(
"hdEdx",
";CDC dE/dx;Entries", 100, 0., 2.5);
62 hinjtimeHer =
new TH2D(
"hinjtimeHer",
";injection time (#mu s); CDC dE/dx", 40, 0, 80e3, 50, 0, 2.5);
63 hinjtimeLer =
new TH2D(
"hinjtimeLer",
";injection time (#mu s); CDC dE/dx", 40, 0, 80e3, 50, 0, 2.5);
64 hdEdxvsP =
new TH2D(
"hdEdxVsP",
";#it{p}_{CDC} (GeV/c);CDC dE/dx", 100, 0.05, 2.50, 100, 0.35, 10.0);
65 hdEdxvsEvt =
new TH2D(
"hdEdxvsEvt",
";Events(M);CDC dE/dx", 50, 0, 200, 50, 0.00, 2.0);
66 hdEdxvsCosth =
new TH2D(
"hdEdxvsCosth",
";cos#theta (e^{-}e^{+} tracks);CDC dE/dx", 50, -1.00, 1.00, 50, 0.00, 2.5);
67 hdEdxvsPhi =
new TH2D(
"hdEdxvsPhi",
";#phi (e^{-}e^{+} tracks);CDC dE/dx", 50, -3.20, 3.20, 50, 0.00, 2.5);
68 if (
mmode !=
"basic") {
69 hWires =
new TH2F(
"hWires",
"All Wires;", 2400, -1.2, 1.2, 2400, -1.2, 1.2);
70 hWires->GetXaxis()->SetTitle(
"CDC-wire map: counter-clockwise and start from +x");
71 hWireStatus =
new TH2F(
"hWireStatus",
"Wire Status", 2400, -1.2, 1.2, 2400, -1.2, 1.2);
72 hWireStatus->GetXaxis()->SetTitle(
"CDC-wire map: counter-clockwise and start from +x");
84 B2WARNING(
"Missing CDCDedxTracks array, CDCDedxDQM is skipped.");
99 B2WARNING(
"Missing CDCDedxTracks array, CDCDedxDQM is skipped.");
111 if (
mmode !=
"basic") {
125 B2WARNING(
"Required SoftwareTriggerResult object not available: CDCDedxDQM is skipped");
129 const std::map<std::string, int>& fresults =
m_TrgResult->getResults();
130 if (fresults.find(
"software_trigger_cut&skim&accept_bhabha") == fresults.end()
131 and fresults.find(
"software_trigger_cut&skim&accept_hadron") == fresults.end())
return;
133 const bool IsBhabhaEvt = (
m_TrgResult->getResult(
"software_trigger_cut&skim&accept_bhabha") ==
135 const bool IsHadronEvt = (
m_TrgResult->getResult(
"software_trigger_cut&skim&accept_hadron") ==
139 if (!IsBhabhaEvt and !IsHadronEvt)
return;
151 if (!dedxTrack || dedxTrack->
size() == 0)
continue;
157 if (!fitResult)
continue;
161 helix.
passiveMoveBy(ROOT::Math::XYZVector(beamSpotDB->getIPPosition()));
163 double dr = frame.getVertex(ROOT::Math::XYZVector(helix.getPerigee())).Rho();
164 double dz = frame.getVertex(ROOT::Math::XYZVector(helix.getPerigee())).Z();
165 if (dr >= 1.0 || fabs(dz) >= 1.0)
continue;
169 if (costh < TMath::Cos(150.0 * TMath::DegToRad()))
continue;
170 if (costh > TMath::Cos(17.0 * TMath::DegToRad()))
continue;
174 if (costh > -0.55 && costh < 0.820) {
175 if (nhits < 20)
continue;
177 if (costh <= -0.62 || costh >= 0.880) {
178 if (nhits < 8)
continue;
179 if (costh > 0 && nhits < 10)
continue;
181 if (nhits < 15)
continue;
186 if (dedxnosat < 0)
continue;
188 double dedx = dedxTrack->
getDedx();
189 if (dedx < 0)
continue;
192 if (pCDC <= 0)
continue;
195 if (pTrk <= 0)
continue;
202 if (std::abs(TrkEoverP - 1.0) > 0.25)
continue;
206 hdEdx->Fill(dedxnosat);
211 if (
event >= 150e6)
event = 150e6 - 100;
212 event = int(
event / 5e5);
225 if (IsHadronEvt &&
hdEdxvsP->Integral() <= 80000)
hdEdxvsP->Fill(pCDC, dedx);
227 if (
mmode !=
"basic") {
228 for (
int ihit = 0; ihit < dedxTrack->
size(); ++ihit) {
229 int iwire = dedxTrack->
getWire(ihit);
232 if (
m_adc[iwire].size() < 50)
m_adc[iwire].push_back(iadc);
247 if (
hdEdx->GetEntries() > 0) {
248 hdEdx->GetXaxis()->SetRange(
hdEdx->FindFirstBinAbove(0, 1),
hdEdx->FindLastBinAbove(0, 1));
269 B2INFO(
"CDCDedxDQMModule: terminate called");
276 B2INFO(
"Creating CDCGeometryPar object");
282 for (
unsigned int ilay = 0; ilay < c_maxNSenseLayers; ++ilay) {
283 for (
unsigned int iwire = 0; iwire < cdcgeo.
nWiresInLayer(ilay); ++iwire) {
285 double phi = 2.*TMath::Pi() * (iwire / double(cdcgeo.
nWiresInLayer(ilay)));
286 double radius = cdcgeo.
senseWireR(ilay) / 100.;
287 double x = radius * cos(phi);
288 double y = radius * sin(phi);
290 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.