9#include <top/modules/collectors/TOPModuleT0LLCollectorModule.h>
10#include <top/geometry/TOPGeometryPar.h>
11#include <top/reconstruction_cpp/TOPTrack.h>
12#include <top/reconstruction_cpp/PDFConstructor.h>
13#include <top/reconstruction_cpp/TOPRecoManager.h>
16#include <framework/gearbox/Const.h>
17#include <framework/logging/Logger.h>
48 setDescription(
"A collector for module T0 calibration with neg. log likelihood "
49 "minimization (method LL). Aimed for the final (precise) calibration"
50 "after initial one with DeltaT method.");
56 "time range in which to search for the minimum [ns]", 10.0);
58 "sigma in [ns] for additional smearing of PDF", 0.0);
60 "sample type: one of dimuon or bhabha", std::string(
"dimuon"));
62 "c.m.s energy window (half size) if sample is dimuon or bhabha", 0.1);
66 "minimal local z of extrapolated hit", -130.0);
68 "maximal local z of extrapolated hit", 130.0);
70 "PDF option, one of 'rough', 'fine', 'optimal'", std::string(
"rough"));
93 B2ERROR(
"Unknown PDF option '" <<
m_pdfOption <<
"'");
104 B2ERROR(
"Invalid sample type '" <<
m_sample <<
"'");
111 for (
unsigned i = 0; i <
c_numSets; i++) {
115 string name =
"chi2_set" + to_string(i) +
"_slot" + to_string(slot);
116 string title =
"chi2 scan, slot" + to_string(slot) +
"; t0 [ns]; chi2";
117 auto h =
new TH1D(name.c_str(), title.c_str(),
m_numBins, tmin + T0, tmax + T0);
118 registerObject<TH1D>(name, h);
123 auto h1 =
new TH2F(
"tracks_per_slot",
"tracks per slot and sample",
125 h1->SetXTitle(
"slot number");
126 h1->SetYTitle(
"sample number");
127 registerObject<TH2F>(
"tracks_per_slot", h1);
129 auto h2 =
new TH1F(
"numHits",
"Number of photons per slot",
131 h2->SetXTitle(
"slot number");
132 h2->SetYTitle(
"hits per slot");
133 registerObject<TH1F>(
"numHits", h2);
135 auto h3 =
new TH2F(
"timeHits",
"Photon times vs. boardstacks",
137 h3->SetXTitle(
"slot number");
138 h3->SetYTitle(
"time [ns]");
139 registerObject<TH2F>(
"timeHits", h3);
143 auto h4 =
new TH1F(
"offset",
"current offset from input files; offset [ns]",
144 200, -bunchTimeSep / 2, bunchTimeSep / 2);
145 registerObject<TH1F>(
"offset", h4);
155 if (not
m_recBunch->isReconstructed())
return;
164 int slot = digit.getModuleID();
165 if (digit.isModuleT0Calibrated()) digit.subtractT0(-
m_moduleT0->getT0(slot));
166 if (digit.hasStatus(TOPDigit::c_BunchOffsetSubtracted)) digit.subtractT0(-
m_recBunch->getAverageOffset());
172 for (
const auto& track :
m_tracks) {
176 if (not trk.
isValid())
continue;
182 if (not pdfConstructor.
isValid())
continue;
187 if (module >=
m_names[sub].size())
continue;
188 auto h = getObjectPtr<TH1D>(
m_names[sub][module]);
189 for (
int ibin = 0; ibin < h->GetNbinsX(); ibin++) {
190 double t0 = h->GetBinCenter(ibin + 1);
191 double chi = h->GetBinContent(ibin + 1);
193 h->SetBinContent(ibin + 1, chi);
195 auto h1 = getObjectPtr<TH2F>(
"tracks_per_slot");
199 auto h2 = getObjectPtr<TH1F>(
"numHits");
200 auto h3 = getObjectPtr<TH2F>(
"timeHits");
201 for (
const auto& digit :
m_digits) {
202 if (digit.getHitQuality() != TOPDigit::c_Good)
continue;
203 if (digit.getModuleID() != trk.
getModuleID())
continue;
204 if (digit.getTime() < timeMin)
continue;
205 if (digit.getTime() > timeMax)
continue;
206 h2->Fill(digit.getModuleID());
207 int bs = digit.getBoardstackNumber();
208 h3->Fill((digit.getModuleID() * 4 + bs - 1.5) / 4.0, digit.getTime());
216 auto h4 = getObjectPtr<TH1F>(
"offset");
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...
const TOPNominalTDC & getNominalTDC() const
Returns nominal time-to-digit conversion parameters.
StoreObjPtr< TOPRecBunch > m_recBunch
reconstructed bunch
TOP::TrackSelector m_selector
track selection utility
double m_sigmaSmear
additional smearing of PDF in [ns]
double m_dz
cut on POCA in z
int m_numBins
number of bins to which search region is divided
double m_maxZ
maximal local z of extrapolated hit
TOP::PDFConstructor::EPDFOption m_PDFOption
PDF option.
double m_minZ
minimal local z of extrapolated hit
double m_dr
cut on POCA in r
StoreArray< Track > m_tracks
collection of tracks
double m_deltaEcms
c.m.s energy window
double m_timeRange
time range in which to search for the minimum [ns]
StoreArray< TOPDigit > m_digits
collection of digits
StoreArray< ExtHit > m_extHits
collection of extrapolated hits
DBObjPtr< TOPCalModuleT0 > m_moduleT0
module T0 calibration constants
std::vector< std::string > m_names[c_numSets]
histogram names of chi2 scans
std::string m_pdfOption
PDF option name.
@ c_numSets
number of statistically independent subsamples
@ c_numModules
number of modules
std::string m_sample
sample type
double getSyncTimeBase() const
Returns synchonization time base (time width of c_syncWindows)
PDF construction and log likelihood determination for a given track and particle hypothesis.
LogL getLogL() const
Returns extended log likelihood (using the default time window)
bool isValid() const
Checks the object status.
@ c_Optimal
y dependent only where necessary
@ c_Fine
y dependent everywhere
@ c_Rough
no dependence on y
const TOPGeometry * getGeometry() const
Returns pointer to geometry object using basf2 units.
static TOPGeometryPar * Instance()
Static method to obtain the pointer to its instance.
static void setDefaultTimeWindow()
Sets default time window (functions getMinTime(), getMaxTime() will then return default values from D...
static double getMaxTime()
Returns time window upper edge.
static double getMinTime()
Returns time window lower edge.
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.
void setDeltaEcms(double deltaEcms)
Sets cut on c.m.s.
void setCutOnPOCA(double dr, double dz)
Sets cut on point of closest approach to (0, 0, 0)
bool isSelected(const TOPTrack &track) const
Returns selection status.
void setCutOnLocalZ(double minZ, double maxZ)
Sets cut on local z coordinate (module frame) of the track extrapolated to TOP.
const Const::ChargedStable & getChargedStable() const
Returns track hypothesis.
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().
virtual void prepare() final
Replacement for initialize().
TOPModuleT0LLCollectorModule()
Constructor.
Abstract base class for different kinds of events.
double logL
extended log likelihood