10#include <cdc/modules/cdcDQM/CDCDQMModule.h>
13#include <framework/database/DBObjPtr.h>
17#include <TDirectory.h>
23#include <cdc/dataobjects/WireID.h>
24#include <cdc/geometry/CDCGeometryPar.h>
40 addParam(
"MinHits",
m_minHits,
"Include only events with more than MinHits hits in CDC", 0);
41 addParam(
"MinNDF",
m_minNdf,
"Include only tracks with more than this NDF", 20);
43 "If true, gets the corrected phi view of the wires in stereo layers",
m_adjustWireShift);
53 TDirectory* oldDir = gDirectory;
56 m_hNEvents =
new TH1F(
"hNEvents",
"hNEvents", 10, 0, 10);
57 m_hNEvents->GetXaxis()->SetBinLabel(1,
"number of events");
58 m_hBit =
new TH2F(
"hBit",
"m_hBit", 7, 0, 7.0, 48, 0, 48.0);
59 m_hBit->SetTitle(
"CDC:Removed Data Bit;CDCRawIndex;Channell Index");
60 m_hOcc =
new TH1F(
"hOcc",
"hOccupancy", 150, 0, 1.5);
61 m_hADCBoard =
new TH2F(
"hADCBoard",
"hADCBoard", 300, 0, 300, 200, 0, 1000);
62 m_hADCBoard->SetTitle(
"ADC vs CDC-Boards;Board index;ADC");
63 m_hADCLayer =
new TH2F(
"hADCLayer",
"hADCLayer", 56, 0, 56, 200, 0, 1000);
64 m_hADCLayer->SetTitle(
"ADC vs CDC-Layers;Layer index;ADC");
65 m_hTDC =
new TH2F(
"hTDC",
"hTDC", 300, 0, 300, 1000, 4200, 5200);
66 m_hTDC->SetTitle(
"TDC vs CDC-Boards;Board index;TDC");
67 m_hHit =
new TH2F(
"hHit",
"hHit", 56, 0, 56, 400, 0, 400);
68 m_hHit->SetTitle(
"CDC-hits;layer index;nhits");
69 m_hPhi =
new TH1F(
"hPhi",
"", 360, -180.0, 180.0);
70 m_hPhi->SetTitle(
"CDC-track-#phi;cdctrack #phi (IP tracks + all events);entries");
71 m_hPhiIndex =
new TH2F(
"hPhiIndex",
"", 360, -180.0, 180.0, 8, 0, 8.0);
72 m_hPhiIndex->SetTitle(
"CDC-track-#phi;cdctrack #phi vs skims;selection-index");
73 m_hPhiEff =
new TH2F(
"hPhiEff",
"", 360, -180.0, 180.0, 100, 0, 100.0);
74 m_hPhiEff->SetTitle(
"CDC-track-#phi;cdctrack #phi vs cdchits;ncdchits");
75 m_hPhiHit =
new TH2F(
"h2HitPhi",
"h2HitPhi", 90, -180.0, 180.0, 56, 0, 56);
76 m_hPhiHit->SetTitle(
"CDC-hits-map (#phi vs layer);Track-#phi;Layer index");
77 m_hPhiNCDC =
new TH2F(
"hPhiNCDC",
"hPhiNCDC", 45, -180.0, 180.0, 61, -0.5, 60.5);
78 m_hPhiNCDC->SetTitle(
"nCDCHits vs #phi;Track-#phi;nCDCHits;Track / bin");
79 m_hTrackingWireEff =
new TH2F(
"hTrackingWireEff",
"title", 400, 0.5, 400 + 0.5, 56 * 2, -0.5, 56 * 2 - 0.5);
80 m_hTrackingWireEff->SetTitle(
"Attached vs Expected wires for all layers (backplate view);wire;layer;Track / bin");
92 B2WARNING(
"Missing Tracks array");
100 B2DEBUG(22,
"Missing recoTracks array in beginRun() ");
122 const int nWires = 14336;
130 B2WARNING(
"SoftwareTriggerResult object not available but require to select bhabha/mumu/hadron events skim");
134 const std::map<std::string, int>& fresults =
m_TrgResult->getResults();
135 if ((fresults.find(
"software_trigger_cut&skim&accept_bhabha") == fresults.end()) ||
136 (fresults.find(
"software_trigger_cut&skim&accept_mumu_tight_or_highm") == fresults.end()) ||
137 (fresults.find(
"software_trigger_cut&skim&accept_hadron") == fresults.end())) {
138 B2WARNING(
"CDCDQMModule: Can't find required bhabha or mumu or hadron trigger identifier");
142 const bool IsBhabha = (
m_TrgResult->getResult(
"software_trigger_cut&skim&accept_bhabha") ==
144 const bool IsHadron = (
m_TrgResult->getResult(
"software_trigger_cut&skim&accept_hadron") ==
146 const bool IsMumu = (
m_TrgResult->getResult(
"software_trigger_cut&skim&accept_mumu_tight_or_highm") ==
158 int lay = hit.getICLayer();
159 int wire = hit.getIWire();
164 const int nEntries =
m_rawCDCs.getEntries();
165 B2DEBUG(99,
"nEntries of RawCDCs : " << nEntries);
166 for (
int i = 0; i < nEntries; ++i) {
167 const int nEntriesRawCDC =
m_rawCDCs[i]->GetNumEntries();
168 B2DEBUG(99,
LogVar(
"nEntries of rawCDC[i]", nEntriesRawCDC));
169 for (
int j = 0; j < nEntriesRawCDC; ++j) {
170 int MaxNumOfCh =
m_rawCDCs[i]->GetMaxNumOfCh(j);
171 if (MaxNumOfCh != 4 && MaxNumOfCh != 48) {
172 B2ERROR(
"CDCDQM: Invalid value of GetMaxNumOfCh");
173 }
else if (MaxNumOfCh == 48) {
174 for (
int k = 0; k < MaxNumOfCh; ++k) {
175 if (
m_rawCDCs[i]->CheckOnlineRemovedDataBit(j, k) ==
true)
m_hBit->SetBinContent(i + 1, k + 1, -0.5);
176 else m_hBit->SetBinContent(i + 1, k + 1, 0.5);
183 double iselect = -1.0;
185 for (
const auto& b2track :
m_Tracks) {
189 B2WARNING(
"No track fit result found.");
195 B2WARNING(
"Can not access RecoTrack of this Belle2::Track");
199 const genfit::FitStatus* fs = track->getTrackFitStatus();
201 B2WARNING(
"Can not access FitStatus of this Track");
206 if (std::fabs(fitresult->
getD0()) < 1.0 && std::fabs(fitresult->
getZ0()) < 1.0) {
207 std::set<int> hitInSLayer;
209 const genfit::TrackPoint* tp = track->getCreatedTrackPoint(track->getRecoHitInformation(hit));
211 hitInSLayer.insert(hit->getICLayer());
213 if (hitInSLayer.empty())
continue;
216 for (
int lay = 0; lay < nSLayers; lay++) {
219 double arcLength = helix.getArcLength2DAtCylindricalR(layerR);
220 if (std::isnan(arcLength))
continue;
221 const auto& result = helix.getPositionAtArcLength2D(arcLength);
227 if (hitInSLayer.count(lay))
233 m_hPhiNCDC->Fill(phiDegree, TMath::Min(
int(track->getNumberOfCDCHits()), 60));
236 int ndf = fs->getNdf();
239 if (fabs(fitresult->
getD0()) > 1.0 || fabs(fitresult->
getZ0()) > 1.0) {
242 if (IsBhabha) iselect = 1.5;
243 if (IsHadron) iselect = 2.5;
244 if (IsMumu) iselect = 3.5;
250 if (IsBhabha) iselect = 5.5;
251 if (IsHadron) iselect = 6.5;
252 if (IsMumu) iselect = 7.5;
259 if (ncdchits >= 100)ncdchits = 99.5;
267 const genfit::TrackPoint* tp = track->getCreatedTrackPoint(track->getRecoHitInformation(hit));
269 B2WARNING(
"Can not access TrackPoint of this hit");
273 UChar_t lay = hit->getICLayer();
274 UShort_t IWire = hit->getIWire();
275 UShort_t adc = hit->getADCCount();
276 unsigned short tdc = hit->getTDCCount();
277 WireID wireid(lay, IWire);
278 unsigned short bid = cdcgeo.
getBoardID(wireid);
301 double offset = cdcgeo.
offset(lay);
302 double shift = (offset - 0.5) * 2 * TMath::Pi() / nWires;
303 double binLow = shift;
304 double binHigh = 2 * TMath::Pi() + shift;
306 if (phi < binLow) phi += 2 * TMath::Pi();
307 else if (phi >= binHigh) phi -= 2 * TMath::Pi();
308 double binWidth = (binHigh - binLow) / nWires;
309 int binIndex = (phi - binLow) / binWidth;
316 double phi = TMath::ATan2(position.Y(), position.X());
319 int nShifts = cdcgeo.
nShifts(lay);
325 double phiSize = 2 * TMath::Pi() / nWires;
326 double phiF = phiSize * 0.5 * nShifts;
327 B2Vector3D f(
R * TMath::Cos(phiF),
R * TMath::Sin(phiF), fZ);
331 double beta = (position.Z() - b.Z()) / u.Z();
333 phi -= TMath::ATan2(p.Y(), p.X());
336 while (phi < 0) phi += (2 * TMath::Pi());
337 while (phi >= 2 * TMath::Pi()) phi -= (2 * TMath::Pi());
B2Vector3< DataType > Unit() const
Unit vector parallel to this.
std::string m_recoTrackArrayName
Belle2::RecoTrack StoreArray name.
StoreArray< RawCDC > m_rawCDCs
Input array for CDC Raw.
TH2F * m_hPhiNCDC
Histogram of track associated nCDCHits vs phi.
TH2F * m_hBit
Histogram of online databit removed.
void initialize() override
Initialize the Module.
int m_minHits
Minimum hits for processing.
TH2F * m_hADCLayer
Histogram of ADC with track associated hits for all layers (0-55)
int m_minNdf
Minimum track NDF for cdc dqm plots.
void event() override
Event processor.
CDCDQMModule()
Constructor.
StoreArray< CDCRawHit > m_cdcRawHits
CDC raw hits.
void endRun() override
End-of-run action.
TH2F * m_hPhiIndex
Histogram of cdc phi of different IP + skims tracks.
StoreObjPtr< TRGSummary > m_trgSummary
Trigger summary.
void terminate() override
Termination action.
double getShiftedPhi(const ROOT::Math::XYZVector &position, const int &lay)
Compute and shift phi if it is stereo layer return [0,2pi].
int findPhiBin(double phi, const int &lay)
Find bin corresponds to a specific phi in a layer phi must be in [0,2pi].
TH1F * m_hNEvents
Histogram of num.
TH2F * m_hTDC
Histogram of TDC with track associated hits for all boards (0-299)
TH2F * m_hADCBoard
Histogram of ADC with track associated hits for all boards (0-299)
TH2F * m_hPhiHit
Histogram of track associated hits in phi vs layer.
void beginRun() override
Called when entering a new run.
TH2F * m_hPhiEff
Histogram of cdc phi of tracking eff.
bool m_adjustWireShift
If true, gets the correct phi view of the boards.
TH1F * m_hPhi
Histogram of cdc phi of IP tracks.
StoreArray< CDCHit > m_cdcHits
CDC hits.
virtual ~CDCDQMModule()
Destructor.
TH1F * m_hOcc
Histogram of occupancy.
StoreArray< RecoTrack > m_RecoTracks
RecoTracks.
StoreArray< Track > m_Tracks
Tracks.
StoreObjPtr< SoftwareTriggerResult > m_TrgResult
Store array for Trigger selection.
TH2F * m_hHit
Histogram of Hits for all layers (0-55)
void defineHisto() override
Histogram definitions.
Long64_t m_nEvents
Number of events processed.
TH2F * m_hTrackingWireEff
Histogram of attached and expected CDC wires in layer.
The Class for CDC Geometry Parameters.
unsigned short getBoardID(const WireID &wID) const
Returns frontend board id. corresponding to the wire id.
int nShifts(int layerId) const
Returns number shift.
double offset(int layerID) const
Return wire offset in phi direction at endplate.
double senseWireBZ(int layerId) const
Returns backward z position of sense wire in each layer.
unsigned nWiresInLayer(int layerId) const
Returns wire numbers in a layer.
double senseWireFZ(int layerId) const
Returns forward z position of sense wire in each layer.
ushort getNumberOfSenseLayers() const
Get the number of sense layers.
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
HistoModule()
Constructor.
unsigned short getNHits() const
Get the total Number of CDC hits in the fit.
unsigned short getNSVDHits() const
Get total number of hits in the SVD.
void setDescription(const std::string &description)
Sets the description of the module.
void setPropertyFlags(unsigned int propertyFlags)
Sets the flags for the module properties.
void setReturnValue(int value)
Sets the return value for this module as integer.
@ c_ParallelProcessingCertified
This module can be run in parallel processing mode safely (All I/O must be done through the data stor...
This is the Reconstruction Event-Data Model Track.
@ TTYP_RAND
random trigger events
Values of the result of a track fit with a given particle hypothesis.
Helix getHelix() const
Conversion to framework Helix (without covariance).
double getPhi() const
Getter for phi0 with CDF naming convention.
double getD0() const
Getter for d0.
double getZ0() const
Getter for z0.
HitPatternCDC getHitPatternCDC() const
Getter for the hit pattern in the CDC;.
HitPatternVXD getHitPatternVXD() const
Getter for the hit pattern in the VXD;.
static const double deg
degree to radians
Class to identify a wire inside the CDC.
Class to store variables with their name which were sent to the logging service.
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.
B2Vector3< double > B2Vector3D
typedef for common usage with double
@ c_accept
Accept this event.
Abstract base class for different kinds of events.