9 #include <top/modules/TOPDQM/TOPDQMModule.h>
10 #include <top/geometry/TOPGeometryPar.h>
11 #include <tracking/dataobjects/ExtHit.h>
12 #include <framework/gearbox/Unit.h>
13 #include <framework/gearbox/Const.h>
14 #include <framework/logging/Logger.h>
15 #include "TDirectory.h"
16 #include <boost/format.hpp>
48 "histogram directory in ROOT file",
string(
"TOP"));
50 "momentum cut used to histogram number of photons per track", 0.5);
62 TDirectory* oldDir = gDirectory;
69 double bunchTimeSep = geo->getNominalTDC().getSyncTimeBase() / 24;
73 m_BoolEvtMonitor =
new TH1D(
"BoolEvtMonitor",
"Event synchronization", 2, -0.5, 1.5);
81 m_window_vs_slot =
new TH2F(
"window_vs_slot",
"Asic windows", 16, 0.5, 16.5, 512, 0, 512);
89 double rangeT0 = nbinsT0 * bunchTimeSep;
90 m_eventT0 =
new TH1F(
"eventT0",
"Event T0; event T0 [ns]; events per bin", nbinsT0, -rangeT0 / 2, rangeT0 / 2);
92 m_bunchOffset =
new TH1F(
"bunchOffset",
"Bunch offset", 100, -bunchTimeSep / 2, bunchTimeSep / 2);
97 m_time =
new TH1F(
"goodHitTimes",
"Time distribution of good hits", 1000, -20, 80);
98 m_time->SetXTitle(
"time [ns]");
99 m_time->SetYTitle(
"hits per bin");
101 m_timeBG =
new TH1F(
"goodHitTimesBG",
"Time distribution of good hits (background)", 1000, -20, 80);
103 m_timeBG->SetYTitle(
"hits per bin");
105 m_signalHits =
new TProfile(
"signalHits",
"Number of good hits per track in [0, 50] ns", 16, 0.5, 16.5, 0, 1000);
111 m_backgroundHits =
new TProfile(
"backgroundHits",
"Number of good hits pet track in [-50, 0] ns", 16, 0.5, 16.5, 0, 1000);
117 m_trackHits =
new TH2F(
"trackHits",
"Number of events w/ and w/o track in the slot", 16, 0.5, 16.5, 2, 0, 2);
121 int nbinsHits = 1000;
122 double xmaxHits = 10000;
123 m_goodHitsPerEventAll =
new TH1F(
"goodHitsPerEventAll",
"Number of good hits per event", nbinsHits, 0, xmaxHits);
127 m_badHitsPerEventAll =
new TH1F(
"badHitsPerEventAll",
"Number of junk hits per event", nbinsHits, 0, xmaxHits);
132 double xminTDC = -100;
133 double xmaxTDC = 700;
134 m_goodTDCAll =
new TH1F(
"goodTDCAll",
"Raw time distribution of good hits", nbinsTDC, xminTDC, xmaxTDC);
138 m_badTDCAll =
new TH1F(
"badTDCAll",
"Raw time distribution of junk hits", nbinsTDC, xminTDC, xmaxTDC);
142 m_TOPOccAfterInjLER =
new TH1F(
"TOPOccInjLER",
"TOPOccInjLER/Time;Time in #mus;Nhits/Time (#mus bins)", 4000, 0, 20000);
143 m_TOPOccAfterInjHER =
new TH1F(
"TOPOccInjHER",
"TOPOccInjHER/Time;Time in #mus;Nhits/Time (#mus bins)", 4000, 0, 20000);
144 m_TOPEOccAfterInjLER =
new TH1F(
"TOPEOccInjLER",
"TOPEOccInjLER/Time;Time in #mus;Triggers/Time (#mus bins)", 4000, 0, 20000);
145 m_TOPEOccAfterInjHER =
new TH1F(
"TOPEOccInjHER",
"TOPEOccInjHER/Time;Time in #mus;Triggers/Time (#mus bins)", 4000, 0, 20000);
153 name = str(format(
"window_vs_asic_%1%") % (module));
154 title = str(format(
"Asic windows for slot #%1%") % (module));
155 h2 =
new TH2F(name.c_str(), title.c_str(), 64, 0, 64, 512, 0, 512);
156 h2->SetStats(kFALSE);
157 h2->SetXTitle(
"ASIC number");
158 h2->SetYTitle(
"window number w.r.t reference window");
162 name = str(format(
"good_hits_xy_%1%") % (module));
163 title = str(format(
"Distribution of good hits for slot #%1%") % (module));
164 h2 =
new TH2F(name.c_str(), title.c_str(), 64, 0.5, 64.5, 8, 0.5, 8.5);
165 h2->SetStats(kFALSE);
166 h2->GetXaxis()->SetTitle(
"pixel column");
167 h2->GetYaxis()->SetTitle(
"pixel row");
171 name = str(format(
"bad_hits_xy_%1%") % (module));
172 title = str(format(
"Distribution of junk hits for slot #%1%") % (module));
173 h2 =
new TH2F(name.c_str(), title.c_str(), 64, 0.5, 64.5, 8, 0.5, 8.5);
174 h2->SetStats(kFALSE);
175 h2->GetXaxis()->SetTitle(
"pixel column");
176 h2->GetYaxis()->SetTitle(
"pixel row");
180 name = str(format(
"good_hits_asics_%1%") % (module));
181 title = str(format(
"Distribution of good hits for slot #%1%") % (module));
182 h2 =
new TH2F(name.c_str(), title.c_str(), 64, 0, 64, 8, 0, 8);
183 h2->SetStats(kFALSE);
184 h2->GetXaxis()->SetTitle(
"ASIC number");
185 h2->GetYaxis()->SetTitle(
"ASIC channel");
189 name = str(format(
"bad_hits_asics_%1%") % (module));
190 title = str(format(
"Distribution of junk hits for slot #%1%") % (module));
191 h2 =
new TH2F(name.c_str(), title.c_str(), 64, 0, 64, 8, 0, 8);
192 h2->SetStats(kFALSE);
193 h2->GetXaxis()->SetTitle(
"ASIC number");
194 h2->GetYaxis()->SetTitle(
"ASIC channel");
198 name = str(format(
"good_TDC_%1%") % (module));
199 title = str(format(
"Raw time distribution of good hits for slot #%1%") % (module));
200 h1 =
new TH1F(name.c_str(), title.c_str(), nbinsTDC, xminTDC, xmaxTDC);
201 h1->GetXaxis()->SetTitle(
"raw time [samples]");
202 h1->GetYaxis()->SetTitle(
"hits per sample");
205 name = str(format(
"bad_TDC_%1%") % (module));
206 title = str(format(
"Raw time distribution of junk hits for slot #%1%") % (module));
207 h1 =
new TH1F(name.c_str(), title.c_str(), nbinsTDC, xminTDC, xmaxTDC);
208 h1->GetXaxis()->SetTitle(
"raw time [samples]");
209 h1->GetYaxis()->SetTitle(
"hits per sample");
212 name = str(format(
"good_timing_%1%") % (module));
213 title = str(format(
"Time distribution of good hits for slot #%1%") % (module));
214 h1 =
new TH1F(name.c_str(), title.c_str(), 200, -20, 80);
215 h1->GetXaxis()->SetTitle(
"time [ns]");
216 h1->GetYaxis()->SetTitle(
"hits per time bin");
219 name = str(format(
"good_timing_%1%BG") % (module));
220 title = str(format(
"Time distribution of good hits (background) for slot #%1%") % (module));
221 h1 =
new TH1F(name.c_str(), title.c_str(), 200, -20, 80);
222 h1->GetXaxis()->SetTitle(
"time [ns]");
223 h1->GetYaxis()->SetTitle(
"hits per time bin");
226 name = str(format(
"good_channel_hits_%1%") % (module));
227 title = str(format(
"Distribution of good hits for slot #%1%") % (module));
228 int numPixels = geo->getModule(i + 1).getPMTArray().getNumPixels();
229 h1 =
new TH1F(name.c_str(), title.c_str(), numPixels, 0, numPixels);
230 h1->GetXaxis()->SetTitle(
"channel number");
231 h1->GetYaxis()->SetTitle(
"hits per channel");
235 name = str(format(
"bad_channel_hits_%1%") % (module));
236 title = str(format(
"Distribution of junk hits for slot #%1%") % (module));
237 h1 =
new TH1F(name.c_str(), title.c_str(), numPixels, 0, numPixels);
238 h1->GetXaxis()->SetTitle(
"channel number");
239 h1->GetYaxis()->SetTitle(
"hits per channel");
243 name = str(format(
"pulseHeights_%1%") % (module));
244 title = str(format(
"Average pulse heights for slot #%1%") % (module));
245 auto* prof =
new TProfile(name.c_str(), title.c_str(), 32, 0.5, 32.5, 0, 2000);
246 prof->GetXaxis()->SetTitle(
"PMT number");
247 prof->GetYaxis()->SetTitle(
"pulse height [ADC counts]");
248 prof->SetMarkerStyle(20);
314 bool recBunchValid =
false;
315 bool cosmics =
false;
317 recBunchValid =
m_recBunch->isReconstructed();
334 for (
const auto& digit :
m_digits) {
335 int x = digit.getFirstWindow() !=
m_digits[0]->getFirstWindow() ? 1 : 0 ;
344 for (
const auto& track :
m_tracks) {
345 const auto* fitResult = track.getTrackFitResultWithClosestMass(
Const::pion);
346 if (not fitResult)
continue;
348 if (slot == 0)
continue;
349 numTracks[slot - 1]++;
350 trackMomenta[slot - 1] = std::max(trackMomenta[slot - 1], fitResult->getMomentum().R());
355 if (recBunchValid or cosmics) {
356 for (
size_t i = 0; i < numTracks.size(); i++) {
357 bool hit = numTracks[i] > 0;
365 for (
size_t i = 0; i < selectedSlots.size(); i++) {
366 selectedSlots[i] = (recBunchValid or cosmics) and numTracks[i] == 1 and trackMomenta[i] >
m_momentumCut;
378 for (
const auto& digit :
m_digits) {
379 int slot = digit.getModuleID();
381 B2ERROR(
"Invalid slot ID found in TOPDigits: ID = " << slot);
384 int asic_no = digit.getChannel() / 8;
385 int asic_ch = digit.getChannel() % 8;
390 if (digit.getHitQuality() != TOPDigit::c_Junk) {
391 m_goodHitsXY[slot - 1]->Fill(digit.getPixelCol(), digit.getPixelRow());
393 m_goodTDC[slot - 1]->Fill(digit.getRawTime());
396 m_pulseHeights[slot - 1]->Fill(digit.getPMTNumber(), digit.getPulseHeight());
398 if (digit.hasStatus(TOPDigit::c_EventT0Subtracted)) {
399 double time = digit.getTime();
400 if (cosmics) time += 10;
401 if (numTracks[slot - 1] > 0) {
408 if (selectedSlots[slot - 1] and abs(time) < 50) {
409 if (time > 0) numSignalHits[slot - 1]++;
410 else numBackgroundHits[slot - 1]++;
414 m_badHitsXY[slot - 1]->Fill(digit.getPixelCol(), digit.getPixelRow());
416 m_badTDC[slot - 1]->Fill(digit.getRawTime());
428 if (selectedSlots[slot - 1]) {
437 B2DEBUG(29,
"TTD FTSW : " << hex << it.GetTTUtime(0) <<
" " << it.GetTTCtime(0) <<
" EvtNr " << it.GetEveNo(0) <<
" Type " <<
438 (it.GetTTCtimeTRGType(0) & 0xF) <<
" TimeSincePrev " << it.GetTimeSincePrevTrigger(0) <<
" TimeSinceInj " <<
439 it.GetTimeSinceLastInjection(0) <<
" IsHER " << it.GetIsHER(0) <<
" Bunch " << it.GetBunchNumber(0));
440 auto difference = it.GetTimeSinceLastInjection(0);
441 if (difference != 0x7FFFFFFF) {
442 unsigned int nentries =
m_digits.getEntries();
443 float diff2 = difference / 127.;
444 if (it.GetIsHER(0)) {
463 for (
const auto& extHit : extHits) {
464 if (std::abs(extHit.getPdgCode()) != pdgCode)
continue;
465 if (extHit.getDetectorID() != myDetID)
continue;
466 if (extHit.getCopyID() < 1 or extHit.getCopyID() >
m_numModules)
continue;
EDetector
Enum for identifying the detector components (detector and subdetector).
static const ChargedStable pion
charged pion particle
Store one Ext hit as a ROOT object.
int getCopyID() const
Get detector-element ID of sensitive element within detector.
HistoModule.h is supposed to be used instead of Module.h for the modules with histogram definitions t...
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...
Class for type safe access to objects that are referred to in relations.
std::vector< TH2F * > m_window_vs_asic
Histograms window w.r.t reference vs.
std::vector< TH1F * > m_badChannelHits
Histograms for bad channel hits.
int m_numModules
number of TOP modules
std::vector< TH2F * > m_goodHitsXY
Histograms (2D) for good hits in pixels.
std::vector< TH2F * > m_goodHitsAsics
Histograms (2D) for good hits in asic channels.
StoreObjPtr< TOPRecBunch > m_recBunch
reconstructed bunch and event T0
DBObjPtr< TOPCalCommonT0 > m_commonT0
common T0 calibration constants
double m_momentumCut
momentum cut
std::vector< TH2F * > m_badHitsXY
Histograms (2D) for bad hits in pixels.
TH1F * m_bunchOffset
reconstructed bunch: current offset
TProfile * m_backgroundHits
number of hits in the background time window vs.
std::vector< TH1F * > m_badTDC
Histograms for TDC distribution of bad hits.
std::vector< TH1F * > m_goodChannelHits
Histograms for good channel hits.
TH1F * m_eventT0
reconstructed event T0
StoreArray< RawFTSW > m_rawFTSW
Input array for DAQ Status.
TH2F * m_window_vs_slot
Histogram window w.r.t reference vs.
std::vector< TH1F * > m_goodTDC
Histograms for TDC distribution of good hits.
std::vector< TH1F * > m_goodTimingBG
Histograms for timing distribution of good hits (background)
TH1F * m_timeBG
time distribution of good hits (background)
TH1F * m_TOPEOccAfterInjHER
Histogram for Nr Entries (=Triggrs) for normalization after HER injection.
std::string m_histogramDirectoryName
histogram directory in ROOT file
StoreArray< Track > m_tracks
collection of tracks
TH1F * m_badHitsPerEventAll
Number of bad hits per event (all slots)
TH1F * m_TOPEOccAfterInjLER
Histogram for Nr Entries (=Triggrs) for normalization after LER injection.
std::vector< TH1F * > m_goodTiming
Histograms for timing distribution of good hits.
TH1F * m_time
time distribution of good hits
TH1F * m_goodTDCAll
TDC distribution of good hits (all slots)
TH1F * m_TOPOccAfterInjLER
Histogram Ndigits after LER injection.
StoreArray< TOPDigit > m_digits
collection of digits
std::vector< TProfile * > m_pulseHeights
Pulse heights of good hits.
StoreArray< TOPTimeZero > m_timeZeros
reconstructed event T0 in case of cosmics
TProfile * m_signalHits
number of hits in the signal time window vs.
TH2F * m_trackHits
counting events w/ and w/o track in the slot vs.
TH1D * m_BoolEvtMonitor
Event desynchronization monitoring.
std::vector< TH2F * > m_badHitsAsics
Histograms (2D) for bad hits in asic channels.
TH1F * m_TOPOccAfterInjHER
Histogram Ndigits after HER injection.
TH1F * m_badTDCAll
TDC distribution of bad hits (all slots)
TH1F * m_goodHitsPerEventAll
Number of good hits per event (all slots)
const TOPGeometry * getGeometry() const
Returns pointer to geometry object using basf2 units.
static TOPGeometryPar * Instance()
Static method to obtain the pointer to its instance.
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.
virtual void initialize() override
Initialize the Module.
virtual void event() override
Event processor.
virtual ~TOPDQMModule()
Destructor.
virtual void beginRun() override
Called when entering a new run.
int getModuleID(const Track &track) const
Returns slot ID of the module that is hit by the track.
virtual void defineHisto() override
Histogram definitions such as TH1(), TH2(), TNtuple(), TTree()....
Abstract base class for different kinds of events.