9#include <top/modules/collectors/TOPPhotonYieldsCollectorModule.h>
10#include <top/reconstruction_cpp/TOPTrack.h>
11#include <top/geometry/TOPGeometryPar.h>
14#include <framework/gearbox/Unit.h>
15#include <framework/logging/Logger.h>
45 setDescription(
"A collector for photon pixel yields aimed for PMT ageing studies and for finding optically decoupled PMT's");
49 addParam(
"sample",
m_sample,
"sample type: one of dimuon or bhabha", std::string(
"dimuon"));
50 addParam(
"deltaEcms",
m_deltaEcms,
"c.m.s energy window (half size) if sample is dimuon or bhabha", 0.1);
74 B2ERROR(
"Invalid sample type '" <<
m_sample <<
"'");
79 const int numModules = 16;
80 const int numPixels = 512;
83 auto* timeStamp =
new TProfile(
"timeStamp",
"Time stamp; ; unix time", 1, 0, 1, 0, 1.0e10,
"S");
87 auto* numTracks =
new TH1F(
"numTracks",
"Number of tracks per slot; slot number; track count", numModules, 0.5, numModules + 0.5);
91 for (
int slot = 1; slot <= numModules; slot++) {
92 string name = (slot < 10) ?
"signalHits_0" + to_string(slot) :
"signalHits_" + to_string(slot);
93 string title =
"Hits in signal window for slot " + to_string(slot);
94 auto h =
new TH1F(name.c_str(), title.c_str(), numPixels, 0.5, numPixels + 0.5);
95 h->SetXTitle(
"pixel number");
96 h->SetYTitle(
"hit count");
102 for (
int slot = 1; slot <= numModules; slot++) {
103 string name = (slot < 10) ?
"bkgHits_0" + to_string(slot) :
"bkgHits_" + to_string(slot);
104 string title =
"Hits in background window for slot " + to_string(slot);
105 auto h =
new TH1F(name.c_str(), title.c_str(), numPixels, 0.5, numPixels + 0.5);
106 h->SetXTitle(
"pixel number");
107 h->SetYTitle(
"hit count");
113 for (
int slot = 1; slot <= numModules; slot++) {
114 string name = (slot < 10) ?
"activePixels_0" + to_string(slot) :
"activePixels_" + to_string(slot);
115 string title =
"Active pixels for slot " + to_string(slot);
116 auto h =
new TH1F(name.c_str(), title.c_str(), numPixels, 0.5, numPixels + 0.5);
117 h->SetXTitle(
"pixel number");
118 h->SetYTitle(
"track count");
124 for (
int slot = 1; slot <= numModules; slot++) {
125 string name = (slot < 10) ?
"effectiveSignalHits_0" + to_string(slot) :
"effectiveSignalHits_" + to_string(slot);
126 string title =
"Effective signal hits for slot " + to_string(slot);
127 auto h =
new TH1F(name.c_str(), title.c_str(), numPixels, 0.5, numPixels + 0.5);
128 h->SetXTitle(
"pixel number");
129 h->SetYTitle(
"hit count");
135 for (
int slot = 1; slot <= numModules; slot++) {
136 string name = (slot < 10) ?
"alphaLow_0" + to_string(slot) :
"alphaLow_" + to_string(slot);
137 string title =
"Hits w/ low alpha for slot " + to_string(slot);
138 auto h =
new TH1F(name.c_str(), title.c_str(), numPixels, 0.5, numPixels + 0.5);
139 h->SetXTitle(
"pixel number");
140 h->SetYTitle(
"hit count");
146 for (
int slot = 1; slot <= numModules; slot++) {
147 string name = (slot < 10) ?
"alphaHigh_0" + to_string(slot) :
"alphaHigh_" + to_string(slot);
148 string title =
"Hits w/ high alpha for slot " + to_string(slot);
149 auto h =
new TH1F(name.c_str(), title.c_str(), numPixels, 0.5, numPixels + 0.5);
150 h->SetXTitle(
"pixel number");
151 h->SetYTitle(
"hit count");
157 for (
int slot = 1; slot <= numModules; slot++) {
158 string name = (slot < 10) ?
"pulseHeights_0" + to_string(slot) :
"pulseHeights_" + to_string(slot);
159 string title =
"Pulse height distributions for slot " + to_string(slot);
160 auto h =
new TH2F(name.c_str(), title.c_str(), numPixels, 0.5, numPixels + 0.5, 200, 0, 2000);
161 h->SetXTitle(
"pixel number");
162 h->SetYTitle(
"pulse height");
168 for (
int slot = 1; slot <= numModules; slot++) {
169 string name = (slot < 10) ?
"muonZ_0" + to_string(slot) :
"muonZ_" + to_string(slot);
170 string title =
"Track z-distribution for slot " + to_string(slot);
171 auto h =
new TH1F(name.c_str(), title.c_str(), 100,
m_minZ,
m_maxZ);
172 h->SetXTitle(
"local z [cm]");
173 h->SetYTitle(
"track count");
185 if (not
m_recBunch->isReconstructed())
return;
189 for (
const auto& track :
m_tracks) {
192 if (not trk.
isValid())
continue;
201 numTracks->Fill(slot);
204 muonZ->Fill(
m_selector.getLocalPosition().Z());
209 for (
const auto& digit :
m_digits) {
210 if (digit.getModuleID() != slot)
continue;
211 if (digit.getHitQuality() != TOPDigit::c_Good)
continue;
213 if (digit.getTime() > 0) {
214 signalHits->Fill(digit.getPixelID());
215 pulseHeight->Fill(digit.getPixelID(), digit.getPulseHeight());
217 bkgHits->Fill(digit.getPixelID());
223 for (
int pixel = 1; pixel <= activePixels->GetNbinsX(); pixel++) {
224 unsigned channel = chMapper.getChannel(pixel);
231 for (
const auto& digit :
m_digits) {
232 if (digit.getModuleID() != slot)
continue;
233 if (digit.getHitQuality() != TOPDigit::c_Good)
continue;
235 if (not pdf)
continue;
236 const auto* peak = pdf->getSinglePeak();
237 if (not peak)
continue;
238 effectiveSignalHits->Fill(digit.getPixelID());
240 double alpha = acos(std::abs(peak->kzd)) /
Unit::deg;
241 if (alpha > 60)
continue;
242 if (alpha < 30) alphaLow->Fill(digit.getPixelID());
243 else alphaHigh->Fill(digit.getPixelID());
void registerObject(std::string name, T *obj)
Register object with a name, takes ownership, do not access the pointer beyond prepare()
T * getObjectPtr(std::string name)
Calls the CalibObjManager to get the requested stored collector data.
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 to store analytic PDF associated with a photon.
DBObjPtr< TOPCalChannelMask > m_channelMask
masked channels
StoreObjPtr< TOPRecBunch > m_recBunch
reconstructed bunch
TOP::TrackSelector m_selector
track selection utility
std::vector< std::string > m_activeNames
histogram names for active pixels count
std::vector< std::string > m_alphaHighNames
histogram names for counting hits w/ high impact angle on photo cathode
std::vector< std::string > m_pulseHeightNames
histogram names for pulse heights
double m_dz
cut on POCA in z
StoreObjPtr< EventMetaData > m_eventMetaData
event meta data object
std::vector< std::string > m_effectiveSignalNames
histogram names for effective signal hits in pixels
std::vector< std::string > m_muonZNames
histogram names for track z-distribution
double m_dr
cut on POCA in r
std::vector< std::string > m_alphaLowNames
histogram names for counting hits w/ low impact angle on photo cathode
const double m_timeWindow
time window for counting photon hits (half size)
StoreArray< Track > m_tracks
collection of tracks
StoreArray< TOPAssociatedPDF > m_associatedPDFs
collection of PDF's associated to TOP digits
const double m_minZ
minimal local z of extrapolated track
const double m_excludedZ
excluded central region of extrapolated track for photon impact angle counting
const double m_maxZ
maximal local z of extrapolated track
double m_deltaEcms
c.m.s energy window
std::vector< std::string > m_signalNames
histogram names for signal window hit counts
std::vector< std::string > m_bkgNames
histogram names for background window hit counts
StoreArray< TOPDigit > m_digits
collection of TOP digits
StoreArray< ExtHit > m_extHits
collection of extrapolated hits
StoreObjPtr< TOPAsicMask > m_asicMask
online masked Asics
std::string m_sample
sample type
const ChannelMapper & getChannelMapper() const
Returns default channel mapper (mapping of channels to pixels)
static TOPGeometryPar * Instance()
Static method to obtain the pointer to its instance.
Reconstructed track at TOP.
bool isValid() const
Checks if track is successfully constructed.
int getModuleID() const
Returns slot ID.
Utility for the track selection - used in various calibration modules.
static const double deg
degree to radians
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 collect() final
Replacement for event().
TOPPhotonYieldsCollectorModule()
Constructor.
virtual void prepare() final
Replacement for initialize().
Abstract base class for different kinds of events.