Belle II Software development
TOPLocalCalFitter Class Reference

This module is the fitter for the CAF collector TOPLaserCalibratorCollector. More...

#include <TOPLocalCalFitter.h>

Inheritance diagram for TOPLocalCalFitter:
CalibrationAlgorithm

Public Types

enum  EResult {
  c_OK ,
  c_Iterate ,
  c_NotEnoughData ,
  c_Failure ,
  c_Undefined
}
 The result of calibration. More...
 

Public Member Functions

 TOPLocalCalFitter ()
 Constructor.
 
 ~TOPLocalCalFitter () override
 Destructor.
 
void setMinEntries (int minEntries)
 Sets the minimum number of entries to perform the calibration in one channel.
 
void setOutputFileName (const std::string &output)
 Sets the name of the output root file.
 
void setFitConstraintsFileName (const std::string &fitConstraints)
 Sets the name of the root file containing the laser MC time corrections and the fit constraints.
 
void setTTSFileName (const std::string &TTSData)
 Sets the name of the root file containing the TTS parameters.
 
void setFitMode (const std::string &fitterMode)
 Sets the fitter mode.
 
void fitInAmpliduteBins (bool isFitInAmplitudeBins)
 Enables the fit amplitude bins.
 
std::string getPrefix () const
 Get the prefix used for getting calibration data.
 
bool checkPyExpRun (PyObject *pyObj)
 Checks that a PyObject can be successfully converted to an ExpRun type.
 
Calibration::ExpRun convertPyExpRun (PyObject *pyObj)
 Performs the conversion of PyObject to ExpRun.
 
std::string getCollectorName () const
 Alias for prefix.
 
void setPrefix (const std::string &prefix)
 Set the prefix used to identify datastore objects.
 
void setInputFileNames (PyObject *inputFileNames)
 Set the input file names used for this algorithm from a Python list.
 
PyObject * getInputFileNames ()
 Get the input file names used for this algorithm and pass them out as a Python list of unicode strings.
 
std::vector< Calibration::ExpRun > getRunListFromAllData () const
 Get the complete list of runs from inspection of collected data.
 
RunRange getRunRangeFromAllData () const
 Get the complete RunRange from inspection of collected data.
 
IntervalOfValidity getIovFromAllData () const
 Get the complete IoV from inspection of collected data.
 
void fillRunToInputFilesMap ()
 Fill the mapping of ExpRun -> Files.
 
std::string getGranularity () const
 Get the granularity of collected data.
 
EResult execute (std::vector< Calibration::ExpRun > runs={}, int iteration=0, IntervalOfValidity iov=IntervalOfValidity())
 Runs calibration over vector of runs for a given iteration.
 
EResult execute (PyObject *runs, int iteration=0, IntervalOfValidity iov=IntervalOfValidity())
 Runs calibration over Python list of runs. Converts to C++ and then calls the other execute() function.
 
std::list< Database::DBImportQuery > & getPayloads ()
 Get constants (in TObjects) for database update from last execution.
 
std::list< Database::DBImportQuerygetPayloadValues ()
 Get constants (in TObjects) for database update from last execution but passed by VALUE.
 
bool commit ()
 Submit constants from last calibration into database.
 
bool commit (std::list< Database::DBImportQuery > payloads)
 Submit constants from a (potentially previous) set of payloads.
 
const std::string & getDescription () const
 Get the description of the algorithm (set by developers in constructor)
 
bool loadInputJson (const std::string &jsonString)
 Load the m_inputJson variable from a string (useful from Python interface). The return bool indicates success or failure.
 
const std::string dumpOutputJson () const
 Dump the JSON string of the output JSON object.
 
const std::vector< Calibration::ExpRun > findPayloadBoundaries (std::vector< Calibration::ExpRun > runs, int iteration=0)
 Used to discover the ExpRun boundaries that you want the Python CAF to execute on. This is optional and only used in some.
 
template<>
std::shared_ptr< TTree > getObjectPtr (const std::string &name, const std::vector< Calibration::ExpRun > &requestedRuns)
 Specialization of getObjectPtr<TTree>.
 

Protected Member Functions

void setupOutputTreeAndFile ()
 prepares the output tree
 
void loadMCInfoTrees ()
 loads the TTS parameters and the MC truth info
 
void determineFitStatus ()
 determines if the constant obtained by the fit are good or not
 
void fitChannel (short slot, short channel, TH1 *h)
 Fits the laser light on one channel.
 
void fitChannel (short slot, short channel, TH1 *h, bool inBins, double frac)
 Fit the laser spectrum of a single channel with extra controls for amplitude-bin fits.
 
void fitPulser (TH1 *, TH1 *)
 Fits the two pulsers.
 
void calculateChannelT0 ()
 Calculates the commonT0 calibration after the fits have been done.
 
EResult calibrate () override
 Runs the algorithm on events.
 
void setInputFileNames (std::vector< std::string > inputFileNames)
 Set the input file names used for this algorithm.
 
virtual bool isBoundaryRequired (const Calibration::ExpRun &)
 Given the current collector data, make a decision about whether or not this run should be the start of a payload boundary.
 
virtual void boundaryFindingSetup (std::vector< Calibration::ExpRun >, int)
 If you need to make some changes to your algorithm class before 'findPayloadBoundaries' is run, make them in this function.
 
virtual void boundaryFindingTearDown ()
 Put your algorithm back into a state ready for normal execution if you need to.
 
const std::vector< Calibration::ExpRun > & getRunList () const
 Get the list of runs for which calibration is called.
 
int getIteration () const
 Get current iteration.
 
std::vector< std::string > getVecInputFileNames () const
 Get the input file names used for this algorithm as a STL vector.
 
template<class T>
std::shared_ptr< T > getObjectPtr (const std::string &name, const std::vector< Calibration::ExpRun > &requestedRuns)
 Get calibration data object by name and list of runs, the Merge function will be called to generate the overall object.
 
template<class T>
std::shared_ptr< T > getObjectPtr (std::string name)
 Get calibration data object (for all runs the calibration is requested for) This function will only work during or after execute() has been called once.
 
template<>
shared_ptr< TTree > getObjectPtr (const string &name, const vector< ExpRun > &requestedRuns)
 We cheekily cast the TChain to TTree for the returned pointer so that the user never knows Hopefully this doesn't cause issues if people do low level stuff to the tree...
 
std::string getGranularityFromData () const
 Get the granularity of collected data.
 
void saveCalibration (TClonesArray *data, const std::string &name)
 Store DBArray payload with given name with default IOV.
 
void saveCalibration (TClonesArray *data, const std::string &name, const IntervalOfValidity &iov)
 Store DBArray with given name and custom IOV.
 
void saveCalibration (TObject *data)
 Store DB payload with default name and default IOV.
 
void saveCalibration (TObject *data, const IntervalOfValidity &iov)
 Store DB payload with default name and custom IOV.
 
void saveCalibration (TObject *data, const std::string &name)
 Store DB payload with given name with default IOV.
 
void saveCalibration (TObject *data, const std::string &name, const IntervalOfValidity &iov)
 Store DB payload with given name and custom IOV.
 
void updateDBObjPtrs (const unsigned int event, const int run, const int experiment)
 Updates any DBObjPtrs by calling update(event) for DBStore.
 
void setDescription (const std::string &description)
 Set algorithm description (in constructor)
 
void clearCalibrationData ()
 Clear calibration data.
 
Calibration::ExpRun getAllGranularityExpRun () const
 Returns the Exp,Run pair that means 'Everything'. Currently unused.
 
void resetInputJson ()
 Clears the m_inputJson member variable.
 
void resetOutputJson ()
 Clears the m_outputJson member variable.
 
template<class T>
void setOutputJsonValue (const std::string &key, const T &value)
 Set a key:value pair for the outputJson object, expected to used internally during calibrate()
 
template<class T>
const T getOutputJsonValue (const std::string &key) const
 Get a value using a key from the JSON output object, not sure why you would want to do this.
 
template<class T>
const T getInputJsonValue (const std::string &key) const
 Get an input JSON value using a key. The normal exceptions are raised when the key doesn't exist.
 
const nlohmann::json & getInputJsonObject () const
 Get the entire top level JSON object. We explicitly say this must be of object type so that we might pick.
 
bool inputJsonKeyExists (const std::string &key) const
 Test for a key in the input JSON object.
 

Protected Attributes

std::vector< Calibration::ExpRun > m_boundaries
 When using the boundaries functionality from isBoundaryRequired, this is used to store the boundaries. It is cleared when.
 

Private Member Functions

short rowOf (short slot, short ch) const noexcept
 Row index for (slot,channel), or -1 if out of bounds.
 
short colOf (short slot, short ch) const noexcept
 Column index for (slot,channel), or -1 if out of bounds.
 
bool areNeighbors (short slot, short a, short b, int drMax=1, int dcMax=1) const noexcept
 Return true if channels a and b are neighbors on the same slot in row/col space.
 
void buildChannelMaps ()
 Build (row,col) lookup tables from the TTS tree; call after opening m_treeTTS.
 
std::string getExpRunString (Calibration::ExpRun &expRun) const
 Gets the "exp.run" string repr. of (exp,run)
 
std::string getFullObjectPath (const std::string &name, Calibration::ExpRun expRun) const
 constructs the full TDirectory + Key name of an object in a TFile based on its name and exprun
 

Private Attributes

int m_minEntries = 50
 Minimum number of entries to perform the fit.
 
std::string m_output = "laserFitResult.root"
 Name of the output file.
 
std::string m_fitConstraints
 File with the Fit constraints.
 
std::string m_TTSData
 File with the TTS parametrization.
 
std::string m_fitterMode = "calibration"
 Fit mode.
 
bool m_isFitInAmplitudeBins = false
 Enables the fit in amplitude bins.
 
std::vector< float > m_binEdges = {50, 100, 150, 200, 250, 300, 350, 400, 500, 600, 800, 1000, 1500, 2000}
 Amplitude bins.
 
TFile * m_inputTTS = nullptr
 File containing m_treeTTS.
 
TFile * m_inputConstraints = nullptr
 File containing m_treeConstraints.
 
TTree * m_treeTTS = nullptr
 Input to the fitter.
 
TTree * m_treeConstraints
 Input to the fitter.
 
TFile * m_histFile = nullptr
 Output of the fitter.
 
TTree * m_fitTree = nullptr
 Output of the fitter.
 
TTree * m_timewalkTree
 Output of the fitter.
 
bool m_detectCrosstalk = false
 Enables the crosstalk detection algorithm.
 
TTree * m_crosstalkTree = nullptr
 Output tree for crosstalk candidates.
 
TTree * m_fitTree_noXtalk = nullptr
 Output tree for non-crosstalk candidates.
 
short m_sl0 = -1
 Slot ID (1-16)
 
short m_sl1 = -1
 Slot ID (1-16)
 
short m_ch0 = -1
 Channel number (0-511)
 
short m_ch1 = -1
 Channel number (0-511)
 
float m_ht0 = NAN
 Hit time for channel 0 in pair.
 
float m_ht1 = NAN
 Hit time for channel 1 in pair.
 
float m_a0 = NAN
 Amplitude for channel 0 in pair.
 
float m_a1 = NAN
 Amplitude for channel 1 in pair.
 
float m_w0 = NAN
 Width for channel 0 in pair.
 
float m_w1 = NAN
 Width for channel 1 in pair.
 
float m_q0 = NAN
 Integrated charge for channel 0 in pair.
 
float m_q1 = NAN
 Integrated charge for channel 1 in pair.
 
float m_f_q0 = NAN
 Fraction of charge on channel 0 in pair.
 
float m_mean2 = 0
 Position of the second gaussian of the TTS parametrization with respect to the first one.
 
float m_sigma1 = 0
 Width of the first gaussian on the TTS parametrization.
 
float m_sigma2 = 0
 Width of the second gaussian on the TTS parametrization.
 
float m_f1 = 0
 Fraction of the first gaussian on the TTS parametrization.
 
float m_f2 = 0
 Fraction of the second gaussian on the TTS parametrization.
 
short m_pixelRow = 0
 Pixel row.
 
short m_pixelCol = 0
 Pixel column.
 
float m_peakTimeConstraints = 0
 Time of the main laser peak in the MC simulation (aka MC correction)
 
float m_deltaTConstraints = 0
 Distance between the main and the secondary laser peak.
 
float m_fractionConstraints = 0
 Fraction of the main peak.
 
float m_timeExtraConstraints = 0
 Position of the gaussian used to describe the extra peak on the timing distribution tail.
 
float m_sigmaExtraConstraints = 0
 Width of the gaussian used to describe the extra peak on the timing distribution tail.
 
float m_alphaExtraConstraints = 0.
 alpha parameter of the tail of the extra peak.
 
float m_nExtraConstraints = 0.
 parameter n of the tail of the extra peak
 
float m_timeBackgroundConstraints = 0.
 Position of the gaussian used to describe the background, w/ respect to peakTime.
 
float m_sigmaBackgroundConstraints = 0.
 Sigma of the gaussian used to describe the background.
 
float m_binLowerEdge = 0
 Lower edge of the amplitude bin in which this fit is performed.
 
float m_binUpperEdge = 0
 Upper edge of the amplitude bin in which this fit is performed.
 
short m_channel = 0
 Channel number (0-511)
 
short m_slot = 0
 Slot ID (1-16)
 
short m_row = 0
 Pixel row.
 
short m_col = 0
 Pixel column.
 
float m_peakTime = 0
 Fitted time of the main (i.e.
 
float m_deltaT
 Time difference between the main peak and the secondary peak.
 
float m_sigma = 0.
 Gaussian time resolution, fitted.
 
float m_fraction = 0.
 Fraction of events in the secondary peak.
 
float m_yieldLaser = 0.
 Total number of laser hits from the fitting function integral.
 
float m_histoIntegral = 0.
 Integral of the fitted histogram.
 
float m_peakTimeErr = 0
 Statistical error on peakTime.
 
float m_deltaTErr = 0
 Statistical error on deltaT.
 
float m_sigmaErr = 0.
 Statistical error on sigma.
 
float m_fractionErr = 0.
 Statistical error on fraction.
 
float m_yieldLaserErr = 0.
 Statistical error on yield.
 
float m_timeExtra = 0.
 Position of the extra peak seen in the timing tail, w/ respect to peakTime.
 
float m_sigmaExtra = 0.
 Gaussian sigma of the extra peak in the timing tail.
 
float m_yieldLaserExtra = 0.
 Integral of the extra peak.
 
float m_alphaExtra = 0.
 alpha parameter of the tail of the extra peak.
 
float m_nExtra = 0.
 parameter n of the tail of the extra peak
 
float m_timeBackground = 0.
 Position of the gaussian used to describe the background, w/ respect to peakTime.
 
float m_sigmaBackground = 0.
 Sigma of the gaussian used to describe the background.
 
float m_yieldLaserBackground = 0.
 Integral of the background gaussian.
 
float m_fractionMC = 0.
 Fraction of events in the secondary peak form the MC simulation.
 
float m_deltaTMC = 0.
 Time difference between the main peak and the secondary peak in the MC simulation.
 
float m_peakTimeMC
 Time of the main peak in the MC simulation, i.e.
 
float m_chi2 = 0
 Reduced chi2 of the fit.
 
float m_rms = 0
 RMS of the histogram used for the fit.
 
float m_channelT0
 Raw, channelT0 calibration, defined as peakTime-peakTimeMC.
 
float m_channelT0Err = 0.
 Statistical error on channelT0.
 
float m_firstPulserTime = 0.
 Average time of the first electronic pulse respect to the reference pulse, from a Gaussian fit.
 
float m_firstPulserSigma = 0.
 Time resolution from the fit of the first electronic pulse, from a Gaussian fit.
 
float m_secondPulserTime
 Average time of the second electronic pulse respect to the reference pulse, from a gaussian fit.
 
float m_secondPulserSigma = 0.
 Time resolution from the fit of the first electronic pulse, from a Gaussian fit.
 
short m_fitStatus = 1
 Fit quality flag, propagated to the constants.
 
double m_width = 0
 Pulse width.
 
double m_amplitude = 0
 Pulse height.
 
std::array< std::array< short, 512 >, 16 > m_rowOf {}
 Row index for (slot,channel), or -1 if out of bounds.
 
std::array< std::array< short, 512 >, 16 > m_colOf {}
 Column index for (slot,channel), or -1 if out of bounds.
 
bool m_hasChannelMaps {false}
 Flag indicating if channel->(row,col) maps have been built.
 
std::vector< std::string > m_inputFileNames
 List of input files to the Algorithm, will initially be user defined but then gets the wildcards expanded during execute()
 
std::map< Calibration::ExpRun, std::vector< std::string > > m_runsToInputFiles
 Map of Runs to input files. Gets filled when you call getRunRangeFromAllData, gets cleared when setting input files again.
 
std::string m_granularityOfData
 Granularity of input data. This only changes when the input files change so it isn't specific to an execution.
 
ExecutionData m_data
 Data specific to a SINGLE execution of the algorithm. Gets reset at the beginning of execution.
 
std::string m_description {""}
 Description of the algorithm.
 
std::string m_prefix {""}
 The name of the TDirectory the collector objects are contained within.
 
nlohmann::json m_jsonExecutionInput = nlohmann::json::object()
 Optional input JSON object used to make decisions about how to execute the algorithm code.
 
nlohmann::json m_jsonExecutionOutput = nlohmann::json::object()
 Optional output JSON object that can be set during the execution by the underlying algorithm code.
 

Static Private Attributes

static const Calibration::ExpRun m_allExpRun = make_pair(-1, -1)
 allExpRun
 

Detailed Description

This module is the fitter for the CAF collector TOPLaserCalibratorCollector.

It analyzes the tree containing the timing of the laser and pulser hits produced by the collector, returning a tree with the fit results and the histograms for each channel. It can be used to produce both channelT0 calibrations and to analyze the daily, low statistics laser runs

Definition at line 30 of file TOPLocalCalFitter.h.

Member Enumeration Documentation

◆ EResult

enum EResult
inherited

The result of calibration.

Enumerator
c_OK 

Finished successfully =0 in Python.

c_Iterate 

Needs iteration =1 in Python.

c_NotEnoughData 

Needs more data =2 in Python.

c_Failure 

Failed =3 in Python.

c_Undefined 

Not yet known (before execution) =4 in Python.

Definition at line 40 of file CalibrationAlgorithm.h.

40 {
41 c_OK,
42 c_Iterate,
43 c_NotEnoughData,
44 c_Failure,
45 c_Undefined
46 };

Constructor & Destructor Documentation

◆ TOPLocalCalFitter()

Constructor.

Definition at line 165 of file TOPLocalCalFitter.cc.

165 : CalibrationAlgorithm("TOPLaserCalibratorCollector")
166{
167 setDescription(
168 "Perform the fit of the laser and pulser runs"
169 );
170
171}

◆ ~TOPLocalCalFitter()

~TOPLocalCalFitter ( )
override

Destructor.

Definition at line 54 of file TOPLocalCalFitter.cc.

55{
56 // Close & delete input files
57 if (m_inputTTS) {
58 m_inputTTS->Close();
59 delete m_inputTTS;
60 m_inputTTS = nullptr;
61 }
62 if (m_inputConstraints) {
63 m_inputConstraints->Close();
64 delete m_inputConstraints;
65 m_inputConstraints = nullptr;
66 }
67
68 // Delete trees if still around (ROOT does not auto-delete in-memory TTrees)
69 if (m_fitTree) {
70 delete m_fitTree;
71 m_fitTree = nullptr;
72 }
73 if (m_timewalkTree) {
74 delete m_timewalkTree;
75 m_timewalkTree = nullptr;
76 }
77 if (m_crosstalkTree) {
78 delete m_crosstalkTree;
79 m_crosstalkTree = nullptr;
80 }
81 if (m_fitTree_noXtalk) {
82 delete m_fitTree_noXtalk;
83 m_fitTree_noXtalk = nullptr;
84 }
85
86 // Close & delete output file last
87 if (m_histFile) {
88 m_histFile->Close();
89 delete m_histFile;
90 m_histFile = nullptr;
91 }
92}

Member Function Documentation

◆ areNeighbors()

bool areNeighbors ( short slot,
short a,
short b,
int drMax = 1,
int dcMax = 1 ) const
inlineprivatenoexcept

Return true if channels a and b are neighbors on the same slot in row/col space.

Uses |Delta_row| ≤ drMax and |Delta_col| ≤ dcMax (default 1). Returns false for identical channels.

Definition at line 270 of file TOPLocalCalFitter.h.

271 {
272 const int dr = std::abs(rowOf(slot, a) - rowOf(slot, b));
273 const int dc = std::abs(colOf(slot, a) - colOf(slot, b));
274 return (dr + dc > 0) && (dr <= drMax) && (dc <= dcMax);
275 }

◆ boundaryFindingSetup()

virtual void boundaryFindingSetup ( std::vector< Calibration::ExpRun > ,
int  )
inlineprotectedvirtualinherited

If you need to make some changes to your algorithm class before 'findPayloadBoundaries' is run, make them in this function.

Reimplemented in PXDAnalyticGainCalibrationAlgorithm, PXDValidationAlgorithm, SVD3SampleCoGTimeCalibrationAlgorithm, SVD3SampleELSTimeCalibrationAlgorithm, SVDCoGTimeCalibrationAlgorithm, TestBoundarySettingAlgorithm, and TestCalibrationAlgorithm.

Definition at line 252 of file CalibrationAlgorithm.h.

252{};

◆ boundaryFindingTearDown()

virtual void boundaryFindingTearDown ( )
inlineprotectedvirtualinherited

Put your algorithm back into a state ready for normal execution if you need to.

Definition at line 257 of file CalibrationAlgorithm.h.

257{};

◆ buildChannelMaps()

void buildChannelMaps ( )
private

Build (row,col) lookup tables from the TTS tree; call after opening m_treeTTS.

Definition at line 34 of file TOPLocalCalFitter.cc.

35{
36 if (!m_treeTTS) {
37 B2ERROR("TOPLocalCalFitter::buildChannelMaps called with null m_treeTTS.");
38 return;
39 }
40
41 // The TTS tree is indexed as (channel + 512 * slot), 0-based for both.
42 for (short slot = 0; slot < 16; ++slot) {
43 for (short ch = 0; ch < 512; ++ch) {
44 const Long64_t idx = static_cast<Long64_t>(ch) + 512LL * slot;
45 m_treeTTS->GetEntry(idx);
46 m_rowOf[slot][ch] = static_cast<short>(m_pixelRow);
47 m_colOf[slot][ch] = static_cast<short>(m_pixelCol);
48 }
49 }
50 m_hasChannelMaps = true;
51}

◆ calculateChannelT0()

void calculateChannelT0 ( )
protected

Calculates the commonT0 calibration after the fits have been done.

It also saves the constants in a localDB and in the output tree

Definition at line 580 of file TOPLocalCalFitter.cc.

581{
582 Long64_t nEntries = m_fitTree->GetEntries();
583 if (nEntries != 8192) {
584 B2ERROR("fitTree does not contain an entry with a fit result for each channel. Found " << nEntries <<
585 " instead of 8192. Perhaps you tried to run the commonT0 calculation before finishing the fitting?");
586 return;
587 }
588
589 // Create and fill the TOPCalChannelT0 object
590 auto* channelT0 = new TOPCalChannelT0();
591 short nCal[16] = {0};
592 for (Long64_t i = 0; i < nEntries; i++) {
593 m_fitTree->GetEntry(i);
594 channelT0->setT0(m_slot, m_channel, m_peakTime - m_peakTimeMC, m_peakTimeErr);
595 if (m_fitStatus == 0) {
596 nCal[m_slot - 1]++;
597 } else {
598 channelT0->setUnusable(m_slot, m_channel);
599 }
600 }
601
602 // Normalize the constants
603 channelT0->suppressAverage();
604
605 // create the localDB
606 saveCalibration(channelT0);
607
608 short nCalTot = 0;
609 B2INFO("Summary: ");
610 for (int iSlot = 1; iSlot < 17; iSlot++) {
611 B2INFO("--> Number of calibrated channels on Slot " << iSlot << " : " << nCal[iSlot - 1] << "/512");
612 B2INFO("--> Cal on ch 1, 256 and 511: " << channelT0->getT0(iSlot, 0) << ", " << channelT0->getT0(iSlot,
613 257) << ", " << channelT0->getT0(iSlot, 511));
614 nCalTot += nCal[iSlot - 1];
615 }
616
617 B2RESULT("Channel T0 calibration constants imported to database, calibrated channels: " << nCalTot << "/ 8192");
618
619 // Loop again on the output tree to save the constants there too, adding two more branches.
620 TBranch* channelT0Branch = m_fitTree->Branch<float>("channelT0", &m_channelT0);
621 TBranch* channelT0ErrBranch = m_fitTree->Branch<float>("channelT0Err", &m_channelT0Err);
622
623 for (int i = 0; i < nEntries; i++) {
624 m_fitTree->GetEntry(i);
625 m_channelT0 = channelT0->getT0(m_slot, m_channel);
626 m_channelT0Err = channelT0->getT0Error(m_slot, m_channel);
627 channelT0Branch->Fill();
628 channelT0ErrBranch->Fill();
629 }
630
631 return;
632
633}

◆ calibrate()

Belle2::CalibrationAlgorithm::EResult calibrate ( )
overrideprotectedvirtual

Runs the algorithm on events.

Currently, it always returns c_OK despite of the actual result of the fitting procedure. This is not an issue since this moduleis not intended to be used in the automatic calibration.

Implements CalibrationAlgorithm.

Definition at line 636 of file TOPLocalCalFitter.cc.

637{
638
639 gROOT->SetBatch();
640
641 // Load MC constraints
642 loadMCInfoTrees();
643
644 // Prepare output
645 setupOutputTreeAndFile();
646
647 // Load the tree with the hits (output of TOPLaserCalibratorCollector)
648 auto hitTree = getObjectPtr<TTree>("hitTree");
649 int event;
650 float amplitude, width, hitTime;
651 short channel, slot; //, row, col;
652 bool refTimeValid;
653 hitTree->SetBranchAddress("event", &event);
654 hitTree->SetBranchAddress("amplitude", &amplitude);
655 hitTree->SetBranchAddress("width", &width);
656 hitTree->SetBranchAddress("hitTime", &hitTime);
657 hitTree->SetBranchAddress("channel", &channel);
658 //hitTree->SetBranchAddress("row", &row);
659 //hitTree->SetBranchAddress("col", &col);
660 hitTree->SetBranchAddress("slot", &slot);
661 hitTree->SetBranchAddress("refTimeValid", &refTimeValid);
662
663 // Prepare histogram to save interesting features of each channel
664 TH2F* h_hitTime = new TH2F("h_hitTime", " ", 512 * 16, 0., 512 * 16, 22000, -70, 40.); // 5 ps bins
665 TH2F* h_amplitude2D = new TH2F("h_amplitude", " ", 512 * 16, 0., 512 * 16, 600, 0, 2200.);
666 TH2F* h_width2D = new TH2F("h_width", " ", 512 * 16, 0., 512 * 16, 1000, 0, 2.);
667
668 // Prepare vector of hitTime vs channel histograms for fits in amplitude bins
669 // (attempt to speed things up looping over the hitTree only once).
670
671 std::vector<TH2F*> h_hitTimeLaserHistos = {};
672 for (int iLowerEdge = 0; iLowerEdge < (int)m_binEdges.size() - 1; iLowerEdge++) {
673 TH2F* h_hitTimeLaser = new TH2F(("h_hitTimeLaser_" + std::to_string(iLowerEdge + 1)).c_str(), " ",
674 512 * 16, 0., 512 * 16, 14000, -70, 0.); // 5 ps bins
675 h_hitTimeLaserHistos.push_back(h_hitTimeLaser);
676 }
677
678 // Per-event accumulator for crosstalk logic
679 struct Hit {
680 short slot;
681 short ch;
682 float t; // hitTime
683 float a; // amplitude
684 float w; // width
685 float q; // charge proxy = conv * a * w
686 };
687 std::vector<Hit> evtHits;
688 //evtHits.reserve(64); // typical multiplicity in laser runs?
689
690 // Track current event id we are accumulating
691 int prev_evt = std::numeric_limits<int>::min();
692
693 // Conversion factor to compute approximate integrated charge (ADC·ns)
694 const float conv = 1.f / (0.3989f * 2.35f);
695
696 // Crosstalk tunables (consider moving to members with setters)
697 const float fracMin = 0.25f; // f_q0 < fracMin or > 1-fracMin => crosstalk
698 const float dtMax = 0.30f; // ns, time-coincidence window for pair
699 const float epsQ = 1e-6f; // guard against zero-sum charges
700
701 // Prepares histogram to store features of each channel (if no crosstalk detected)
702 // which will be fit later
703 TH2F* h_hitTime_noXtalk = new TH2F("h_hitTime_noXtalk", " ", 512 * 16, 0., 512 * 16, 22000, -70, 40.); // 5 ps bins
704 TH2F* h_amplitude2D_noXtalk = new TH2F("h_amplitude2D_noXtalk", " ", 512 * 16, 0., 512 * 16, 600, 0, 2200.);
705 TH2F* h_width2D_noXtalk = new TH2F("h_width2D_noXtalk", " ", 512 * 16, 0., 512 * 16, 1000, 0, 2.);
706
707 // Get number of entries in hitTree
708 Long64_t nhits = hitTree->GetEntries();
709 const Long64_t step = std::max<Long64_t>(1, nhits / 100); // for progress bar
710
711 // Loop on all hits to retrieve information
712 for (Long64_t i = 0; i < nhits; i++) {
713
714 // Print percentage of completion
715 if (i % step == 0) {
716 std::cout << "Processing hit " << i << " of " << nhits << " ("
717 << std::setprecision(3) << (100. * i) / nhits << " %)" << std::endl;
718 }
719
720 // Process entry
721 hitTree->GetEntry(i);
722
723 // Fill hit time histograms for each bin of pulse heigth (if activated)
724 if (m_isFitInAmplitudeBins) {
725 auto it = std::lower_bound(m_binEdges.cbegin(), m_binEdges.cend(), amplitude); // std::vector iterator
726 int iLowerEdge = std::distance(m_binEdges.cbegin(), it) - 1;
727 if (iLowerEdge >= 0 && iLowerEdge < static_cast<int>(m_binEdges.size()) - 1 && refTimeValid)
728 h_hitTimeLaserHistos[iLowerEdge]->Fill(channel + (slot - 1) * 512, hitTime);
729 }
730
731 // Check if pulse is at least 80 ADC and has valid reference time (suppress noise)
732 if (amplitude > 80. && refTimeValid) {
733
734 // Fill the hitTime vs channel histogram
735 h_hitTime->Fill(channel + (slot - 1) * 512, hitTime);
736
737 // If entry is found with -65 < hitTime < -10 (laser pulse), fill amplitude and width histograms
738 if ((hitTime > -65) && (hitTime < -10)) { // use logical &&
739
740 // Fill amplitude and width histograms
741 h_amplitude2D->Fill(channel + (slot - 1) * 512, amplitude);
742 h_width2D->Fill(channel + (slot - 1) * 512, width);
743
744 // Crosstalk finder algorithm (only on laser pulses)
745 if (m_detectCrosstalk) {
746
747 const int curr_evt = event;
748
749 // If this entry belongs to a NEW event, process the accumulated previous event
750 if (curr_evt != prev_evt && !evtHits.empty()) {
751
752 // ---- step 1: find crosstalk pairs and mark involved hits ----
753 std::vector<char> isXtalk(evtHits.size(), 0);
754 for (size_t ii = 0; ii + 1 < evtHits.size(); ++ii) {
755 const auto& hi = evtHits[ii];
756 for (size_t jj = ii + 1; jj < evtHits.size(); ++jj) {
757 const auto& hj = evtHits[jj];
758
759 // same slot and neighboring pixels
760 if (hi.slot != hj.slot) continue;
761 if (!areNeighbors(hi.slot, hi.ch, hj.ch)) continue;
762
763 // near-coincident in time (laser)
764 if (std::fabs(hi.t - hj.t) > dtMax) continue;
765
766 // robust fraction of shared charge
767 const float qsum = hi.q + hj.q;
768 if (qsum <= epsQ) continue;
769 const float f_q0 = hi.q / qsum;
770
771 if (f_q0 < fracMin || f_q0 > (1.f - fracMin)) {
772 isXtalk[ii] = 1;
773 isXtalk[jj] = 1;
774
775 // save diagnostics once per pair
776 if (m_crosstalkTree) {
777 m_sl0 = hi.slot; m_sl1 = hj.slot;
778 m_ch0 = hi.ch; m_ch1 = hj.ch;
779 m_ht0 = hi.t; m_ht1 = hj.t;
780 m_a0 = hi.a; m_a1 = hj.a;
781 m_w0 = hi.w; m_w1 = hj.w;
782 m_q0 = hi.q; m_q1 = hj.q;
783 m_f_q0 = f_q0;
784 m_crosstalkTree->Fill();
785 }
786 }
787 }
788 }
789
790 // ---- step 2: fill "no-crosstalk" histograms exactly once per clean hit ----
791 for (size_t kk = 0; kk < evtHits.size(); ++kk) {
792 if (isXtalk[kk]) continue;
793 const auto& h = evtHits[kk];
794 const int gch = h.ch + (h.slot - 1) * 512;
795 h_hitTime_noXtalk->Fill(gch, h.t);
796 h_amplitude2D_noXtalk->Fill(gch, h.a);
797 h_width2D_noXtalk->Fill(gch, h.w);
798 }
799
800 // clear for next event
801 evtHits.clear();
802 }
803 // accumulate the current hit for the (possibly new) event
804 evtHits.push_back(Hit{slot, channel, hitTime, amplitude, width, conv* amplitude * width});
805
806 // update current event id
807 prev_evt = curr_evt;
808 }
809 }
810 }
811 }
812
813 // Final flush for the last accumulated event (if any)
814 if (m_detectCrosstalk && !evtHits.empty()) {
815 std::vector<char> isXtalk(evtHits.size(), 0);
816 for (size_t ll = 0; ll + 1 < evtHits.size(); ++ll) {
817 const auto& hi = evtHits[ll];
818 for (size_t mm = ll + 1; mm < evtHits.size(); ++mm) {
819 const auto& hj = evtHits[mm];
820 if (hi.slot != hj.slot) continue;
821 if (!areNeighbors(hi.slot, hi.ch, hj.ch)) continue;
822 if (std::fabs(hi.t - hj.t) > dtMax) continue;
823 const float qsum = hi.q + hj.q;
824 if (qsum <= epsQ) continue;
825 const float f_q0 = hi.q / qsum;
826 if (f_q0 < fracMin || f_q0 > (1.f - fracMin)) {
827 isXtalk[ll] = 1;
828 isXtalk[mm] = 1;
829 if (m_crosstalkTree) {
830 m_sl0 = hi.slot; m_sl1 = hj.slot;
831 m_ch0 = hi.ch; m_ch1 = hj.ch;
832 m_ht0 = hi.t; m_ht1 = hj.t;
833 m_a0 = hi.a; m_a1 = hj.a;
834 m_w0 = hi.w; m_w1 = hj.w;
835 m_q0 = hi.q; m_q1 = hj.q;
836 m_f_q0 = f_q0;
837 m_crosstalkTree->Fill();
838 }
839 }
840 }
841 }
842 for (size_t nn = 0; nn < evtHits.size(); ++nn) {
843 if (isXtalk[nn]) continue;
844 const auto& h = evtHits[nn];
845 const int gch = h.ch + (h.slot - 1) * 512;
846 h_hitTime_noXtalk->Fill(gch, h.t);
847 h_amplitude2D_noXtalk->Fill(gch, h.a);
848 h_width2D_noXtalk->Fill(gch, h.w);
849 }
850 evtHits.clear();
851 }
852
853 // Save tree filled with candidate crosstalks => useful for further studies
854 if (m_detectCrosstalk) {
855 std::cout << "Writing crosstalkTree (candidate crosstalk channel pairs) to output file" << std::endl;
856 m_histFile->cd();
857 m_crosstalkTree->Write();
858 }
859
860 // Write hitTime histograms to file
861 m_histFile->cd();
862 h_hitTime->Write();
863
864 // After filling hitTime, amplitude, width vs. channel histograms,
865 // loop on each slot and channel to perform channelT0 fits on hitTime profiles
866 for (short iSlot = 0; iSlot < 16; iSlot++) {
867 std::cout << "fitting slot " << iSlot + 1 << std::endl;
868 for (short iChannel = 0; iChannel < 512; iChannel++) {
869
870 // Project to 1-d hitTime distribution
871 TH1D* h_profile = h_hitTime->ProjectionY(
872 ("profile_" + std::to_string(iSlot + 1) + "_" + std::to_string(iChannel)).c_str(),
873 iSlot * 512 + iChannel + 1, iSlot * 512 + iChannel + 1
874 );
875
876 // Set hitTime range based on fitter mode
877 if (m_fitterMode == "MC")
878 //h_profile->GetXaxis()->SetRangeUser(-10, -10);
879 h_profile->GetXaxis()->SetRangeUser(-65, -1);
880 else // if you will even change the limits, make sure not to include the h_hitTime overflow bins in this range
881 h_profile->GetXaxis()->SetRangeUser(-65, -5);
882
883 // Run fit and determine status
884 fitChannel(iSlot, iChannel, h_profile);
885 determineFitStatus();
886
887 // Now let's fit the pulser
888 TH1D* h_profileFirstPulser = h_hitTime->ProjectionY(
889 ("profileFirstPulser_" + std::to_string(iSlot + 1) + "_" + std::to_string(
890 iChannel)).c_str(), iSlot * 512 + iChannel + 1, iSlot * 512 + iChannel + 1
891 );
892 TH1D* h_profileSecondPulser = h_hitTime->ProjectionY(
893 ("profileSecondPulser_" + std::to_string(iSlot + 1) + "_" + std::to_string(
894 iChannel)).c_str(), iSlot * 512 + iChannel + 1, iSlot * 512 + iChannel + 1
895 );
896 h_profileFirstPulser->GetXaxis()->SetRangeUser(-10, 10);
897 h_profileSecondPulser->GetXaxis()->SetRangeUser(10, 40);
898 fitPulser(h_profileFirstPulser, h_profileSecondPulser);
899
900
901 // Get pulse heigth [ADC] and width [ns]
902 TH1D* h_amplitude = h_amplitude2D->ProjectionY(
903 ("AmpProfile_" + std::to_string(iSlot + 1) + "_" + std::to_string(iChannel)).c_str(),
904 iSlot * 512 + iChannel + 1, iSlot * 512 + iChannel + 1
905 );
906 TH1D* h_width = h_width2D->ProjectionY(
907 ("WidthProfile_" + std::to_string(iSlot + 1) + "_" + std::to_string(iChannel)).c_str(),
908 iSlot * 512 + iChannel + 1, iSlot * 512 + iChannel + 1
909 );
910
911 // Set values for pulse amplitude and width (mean)
912 Double_t q = 0.5; // quantile for median
913 h_amplitude->GetQuantiles(1, &m_amplitude, &q);
914 h_width->GetQuantiles(1, &m_width, &q);
915
916 m_fitTree->Fill();
917 h_profile->Write();
918 h_profileFirstPulser->Write();
919 h_profileSecondPulser->Write();
920 h_amplitude->Write();
921 h_width->Write();
922
923 // Free memory: TH2D::ProjectionY allocates memory dynamically
924 delete h_profile;
925 delete h_profileFirstPulser;
926 delete h_profileSecondPulser;
927 delete h_amplitude;
928 delete h_width;
929
930 }
931
932 // Write hitTime histogram to output tree
933 h_hitTime->Write();
934
935 }
936
937 // Compute calibration constants (w/ error) and add corresponding branches to output fitTree
938 calculateChannelT0();
939
940 // Write fit results to tree
941 m_fitTree->Write();
942
943 // ChannelT0 fits in bins of pulse heigth
944 if (m_isFitInAmplitudeBins) {
945
946 std::cout << "Fitting in bins of pulse heigth" << std::endl;
947
948 for (short iSlot = 0; iSlot < 16; iSlot++) {
949 std::cout << " Fitting slot " << iSlot + 1 << std::endl;
950 for (short iChannel = 0; iChannel < 512; iChannel++) {
951
952 // The fraction parameter should not depend on amplitude ==> let's fix it
953 // to the value we get from the fit integrated on all amplitudes
954 TH1D* h_profile_full = h_hitTime->ProjectionY(
955 ("profile_" + std::to_string(iSlot + 1) + "_" + std::to_string(iChannel)).c_str(),
956 iSlot * 512 + iChannel + 1, iSlot * 512 + iChannel + 1
957 );
958 fitChannel(iSlot, iChannel, h_profile_full);
959 float ff = m_fraction;
960 // Fit done, free the memory
961 delete h_profile_full;
962
963 // Loop on the amplitude bins
964 for (int iLowerEdge = 0; iLowerEdge < (int)m_binEdges.size() - 1; iLowerEdge++) {
965
966 // Get current bin edges
967 m_binLowerEdge = m_binEdges[iLowerEdge];
968 m_binUpperEdge = m_binEdges[iLowerEdge + 1];
969 std::cout << "Fitting the amplitude interval (" << m_binLowerEdge << ", " << m_binUpperEdge << " )" << std::endl;
970
971 // Get profile for current amplitude bin
972 TH1D* h_profile = h_hitTimeLaserHistos[iLowerEdge]->ProjectionY(
973 ("profile_" + std::to_string(iSlot + 1) + "_" + std::to_string(
974 iChannel) + "_" + std::to_string(iLowerEdge)).c_str(),
975 iSlot * 512 + iChannel + 1, iSlot * 512 + iChannel + 1
976 );
977 // Set range of fit based on fitter mode
978 if (m_fitterMode == "MC")
979 h_profile->GetXaxis()->SetRangeUser(-10, -10);
980 else // if you will even change it, make sure not to include the h_hitTime overflow bins in this range
981 h_profile->GetXaxis()->SetRangeUser(-65, -5);
982
983
984 // Fit the hitTime distribution
985 fitChannel(iSlot, iChannel, h_profile, true, ff);
986 m_histoIntegral = h_profile->Integral();
987 determineFitStatus();
988
989 // Get amplitude and width profiles in order to get median amp and width of the channel
990 TH1D* h_amplitude = h_amplitude2D->ProjectionY(
991 ("AmpProfile_" + std::to_string(iSlot + 1) +
992 "_" + std::to_string(iChannel) +
993 "_" + std::to_string(iLowerEdge)).c_str(),
994 iSlot * 512 + iChannel + 1, iSlot * 512 + iChannel + 1
995 );
996 TH1D* h_width = h_width2D->ProjectionY(
997 ("WidthProfile_" + std::to_string(iSlot + 1) +
998 "_" + std::to_string(iChannel) +
999 "_" + std::to_string(iLowerEdge)).c_str(),
1000 iSlot * 512 + iChannel + 1, iSlot * 512 + iChannel + 1
1001 );
1002
1003 // Measure the *median* amplitude and widths => less sensitive to outliers
1004 Double_t q = 0.5; // quantile for median
1005 h_amplitude->GetQuantiles(1, &m_amplitude, &q);
1006 h_width->GetQuantiles(1, &m_width, &q);
1007
1008 // Fill tree and write histograms to output file
1009 m_timewalkTree->Fill();
1010 h_profile->Write();
1011 h_amplitude->Write();
1012 h_width->Write();
1013
1014 // Try to avoid memory leaks
1015 delete h_profile;
1016 delete h_amplitude;
1017 delete h_width;
1018
1019 }
1020 }
1021 }
1022 m_timewalkTree->Write();
1023 }
1024
1025 // Run fits on channels that didn't have cross-talk
1026 if (m_detectCrosstalk) {
1027 std::cout << "Fitting channels with no crosstalk detected" << std::endl;
1028 for (short iSlot = 0; iSlot < 16; iSlot++) {
1029 std::cout << " Fitting slot " << iSlot + 1 << std::endl;
1030 for (short iChannel = 0; iChannel < 512; iChannel++) {
1031 // Project to 1-d hitTime distribution
1032 TH1D* h_profile = h_hitTime_noXtalk->ProjectionY(
1033 ("profile_" + std::to_string(iSlot + 1) + "_" + std::to_string(iChannel)).c_str(),
1034 iSlot * 512 + iChannel + 1, iSlot * 512 + iChannel + 1
1035 );
1036
1037 // Set hitTime range based on fitter mode
1038 if (m_fitterMode == "MC")
1039 //h_profile->GetXaxis()->SetRangeUser(-10, -10);
1040 h_profile->GetXaxis()->SetRangeUser(-65, -1);
1041 else // if you will even change the limits, make sure not to include the h_hitTime overflow bins in this range
1042 h_profile->GetXaxis()->SetRangeUser(-65, -5);
1043
1044 // Run fit and determine status
1045 fitChannel(iSlot, iChannel, h_profile);
1046 determineFitStatus();
1047
1048 // Get pulse heigth [ADC] and width [ns]
1049 TH1D* h_amplitude = h_amplitude2D_noXtalk->ProjectionY(
1050 ("AmpProfile_" + std::to_string(iSlot + 1) + "_" + std::to_string(iChannel)).c_str(),
1051 iSlot * 512 + iChannel + 1, iSlot * 512 + iChannel + 1
1052 );
1053 TH1D* h_width = h_width2D_noXtalk->ProjectionY(
1054 ("WidthProfile_" + std::to_string(iSlot + 1) + "_" + std::to_string(iChannel)).c_str(),
1055 iSlot * 512 + iChannel + 1, iSlot * 512 + iChannel + 1
1056 );
1057
1058 // Set values for pulse amplitude and width (mean)
1059 Double_t q = 0.5; // quantile for median
1060 h_amplitude->GetQuantiles(1, &m_amplitude, &q);
1061 h_width->GetQuantiles(1, &m_width, &q);
1062
1063 m_fitTree_noXtalk->Fill();
1064 h_profile->Write();
1065 h_amplitude->Write();
1066 h_width->Write();
1067
1068 // Free memory: TH2D::ProjectionY allocates memory dynamically
1069 delete h_profile;
1070 delete h_amplitude;
1071 delete h_width;
1072 }
1073 }
1074 // Write fitTree with no crosstalk (after computing calibration constants)
1075 calculateChannelT0();
1076 m_fitTree_noXtalk->Write();
1077 }
1078
1079 m_histFile->Close();
1080
1081 return c_OK;
1082}

◆ checkPyExpRun()

bool checkPyExpRun ( PyObject * pyObj)
inherited

Checks that a PyObject can be successfully converted to an ExpRun type.

Checks if the PyObject can be converted to ExpRun.

Definition at line 28 of file CalibrationAlgorithm.cc.

29{
30 // Is it a sequence?
31 if (PySequence_Check(pyObj)) {
32 Py_ssize_t nObj = PySequence_Length(pyObj);
33 // Does it have 2 objects in it?
34 if (nObj != 2) {
35 B2DEBUG(29, "ExpRun was a Python sequence which didn't have exactly 2 entries!");
36 return false;
37 }
38 PyObject* item1, *item2;
39 item1 = PySequence_GetItem(pyObj, 0);
40 item2 = PySequence_GetItem(pyObj, 1);
41 // Did the GetItem work?
42 if ((item1 == NULL) || (item2 == NULL)) {
43 B2DEBUG(29, "A PyObject pointer was NULL in the sequence");
44 return false;
45 }
46 // Are they longs?
47 if (PyLong_Check(item1) && PyLong_Check(item2)) {
48 long value1, value2;
49 value1 = PyLong_AsLong(item1);
50 value2 = PyLong_AsLong(item2);
51 if (((value1 == -1) || (value2 == -1)) && PyErr_Occurred()) {
52 B2DEBUG(29, "An error occurred while converting the PyLong to long");
53 return false;
54 }
55 } else {
56 B2DEBUG(29, "One or more of the PyObjects in the ExpRun wasn't a long");
57 return false;
58 }
59 // Make sure to kill off the reference GetItem gave us responsibility for
60 Py_DECREF(item1);
61 Py_DECREF(item2);
62 } else {
63 B2DEBUG(29, "ExpRun was not a Python sequence.");
64 return false;
65 }
66 return true;
67}

◆ clearCalibrationData()

void clearCalibrationData ( )
inlineprotectedinherited

Clear calibration data.

Definition at line 324 of file CalibrationAlgorithm.h.

324{m_data.clearCalibrationData();}

◆ colOf()

short colOf ( short slot,
short ch ) const
inlineprivatenoexcept

Column index for (slot,channel), or -1 if out of bounds.

Definition at line 261 of file TOPLocalCalFitter.h.

262 {
263 return (slot >= 0 && slot < 16 && ch >= 0 && ch < 512) ? m_colOf[slot][ch] : short(-1);
264 }

◆ commit() [1/2]

bool commit ( )
inherited

Submit constants from last calibration into database.

Definition at line 302 of file CalibrationAlgorithm.cc.

303{
304 if (getPayloads().empty())
305 return false;
306 list<Database::DBImportQuery> payloads = getPayloads();
307 B2INFO("Committing " << payloads.size() << " payloads to database.");
308 return Database::Instance().storeData(payloads);
309}
std::list< Database::DBImportQuery > & getPayloads()
Get constants (in TObjects) for database update from last execution.
static Database & Instance()
Instance of a singleton Database.
Definition Database.cc:41
bool storeData(const std::string &name, TObject *object, const IntervalOfValidity &iov)
Store an object in the database.
Definition Database.cc:140

◆ commit() [2/2]

bool commit ( std::list< Database::DBImportQuery > payloads)
inherited

Submit constants from a (potentially previous) set of payloads.

Definition at line 311 of file CalibrationAlgorithm.cc.

312{
313 if (payloads.empty())
314 return false;
315 return Database::Instance().storeData(payloads);
316}

◆ convertPyExpRun()

ExpRun convertPyExpRun ( PyObject * pyObj)
inherited

Performs the conversion of PyObject to ExpRun.

Converts the PyObject to an ExpRun. We've preoviously checked the object so this assumes a lot about the PyObject.

Definition at line 70 of file CalibrationAlgorithm.cc.

71{
72 ExpRun expRun;
73 PyObject* itemExp, *itemRun;
74 itemExp = PySequence_GetItem(pyObj, 0);
75 itemRun = PySequence_GetItem(pyObj, 1);
76 expRun.first = PyLong_AsLong(itemExp);
77 Py_DECREF(itemExp);
78 expRun.second = PyLong_AsLong(itemRun);
79 Py_DECREF(itemRun);
80 return expRun;
81}

◆ determineFitStatus()

void determineFitStatus ( )
protected

determines if the constant obtained by the fit are good or not

Definition at line 570 of file TOPLocalCalFitter.cc.

571{
572 if (m_chi2 < 4 && m_sigma < 0.2 && m_yieldLaser > 1000) {
573 m_fitStatus = 0;
574 } else {
575 m_fitStatus = 1;
576 }
577 return;
578}

◆ dumpOutputJson()

const std::string dumpOutputJson ( ) const
inlineinherited

Dump the JSON string of the output JSON object.

Definition at line 223 of file CalibrationAlgorithm.h.

223{return m_jsonExecutionOutput.dump();}

◆ execute() [1/2]

CalibrationAlgorithm::EResult execute ( PyObject * runs,
int iteration = 0,
IntervalOfValidity iov = IntervalOfValidity() )
inherited

Runs calibration over Python list of runs. Converts to C++ and then calls the other execute() function.

Definition at line 83 of file CalibrationAlgorithm.cc.

84{
85 B2DEBUG(29, "Running execute() using Python Object as input argument");
86 // Reset the execution specific data in case the algorithm was previously called
87 m_data.reset();
88 m_data.setIteration(iteration);
89 vector<ExpRun> vecRuns;
90 // Is it a list?
91 if (PySequence_Check(runs)) {
92 boost::python::handle<> handle(boost::python::borrowed(runs));
93 boost::python::list listRuns(handle);
94
95 int nList = boost::python::len(listRuns);
96 for (int iList = 0; iList < nList; ++iList) {
97 boost::python::object pyExpRun(listRuns[iList]);
98 if (!checkPyExpRun(pyExpRun.ptr())) {
99 B2ERROR("Received Python ExpRuns couldn't be converted to C++");
100 m_data.setResult(c_Failure);
101 return c_Failure;
102 } else {
103 vecRuns.push_back(convertPyExpRun(pyExpRun.ptr()));
104 }
105 }
106 } else {
107 B2ERROR("Tried to set the input runs but we didn't receive a Python sequence object (list,tuple).");
108 m_data.setResult(c_Failure);
109 return c_Failure;
110 }
111 return execute(vecRuns, iteration, iov);
112}
bool checkPyExpRun(PyObject *pyObj)
Checks that a PyObject can be successfully converted to an ExpRun type.
EResult execute(std::vector< Calibration::ExpRun > runs={}, int iteration=0, IntervalOfValidity iov=IntervalOfValidity())
Runs calibration over vector of runs for a given iteration.
Calibration::ExpRun convertPyExpRun(PyObject *pyObj)
Performs the conversion of PyObject to ExpRun.
ExecutionData m_data
Data specific to a SINGLE execution of the algorithm. Gets reset at the beginning of execution.

◆ execute() [2/2]

CalibrationAlgorithm::EResult execute ( std::vector< Calibration::ExpRun > runs = {},
int iteration = 0,
IntervalOfValidity iov = IntervalOfValidity() )
inherited

Runs calibration over vector of runs for a given iteration.

You can also specify the IoV to save the database payload as. By default the Algorithm will create an IoV from your requested ExpRuns, or from the overall ExpRuns of the input data if you haven't specified ExpRuns in this function.

No checks are performed to make sure that a IoV you specify matches the data you ran over, it simply labels the IoV to commit to the database later.

Definition at line 114 of file CalibrationAlgorithm.cc.

115{
116 // Check if we are calling this function directly and need to reset, or through Python where it was already done.
117 if (m_data.getResult() != c_Undefined) {
118 m_data.reset();
119 m_data.setIteration(iteration);
120 }
121
122 if (m_inputFileNames.empty()) {
123 B2ERROR("There aren't any input files set. Please use CalibrationAlgorithm::setInputFiles()");
124 m_data.setResult(c_Failure);
125 return c_Failure;
126 }
127
128 // Did we receive runs to execute over explicitly?
129 if (!(runs.empty())) {
130 for (auto expRun : runs) {
131 B2DEBUG(29, "ExpRun requested = (" << expRun.first << ", " << expRun.second << ")");
132 }
133 // We've asked explicitly for certain runs, but we should check if the data granularity is 'run'
134 if (strcmp(getGranularity().c_str(), "all") == 0) {
135 B2ERROR(("The data is collected with granularity=all (exp=-1,run=-1), but you seem to request calibration for specific runs."
136 " We'll continue but using ALL the input data given instead of the specific runs requested."));
137 }
138 } else {
139 // If no runs are provided, infer the runs from all collected data
140 runs = getRunListFromAllData();
141 // Let's check that we have some now
142 if (runs.empty()) {
143 B2ERROR("No collected data in input files.");
144 m_data.setResult(c_Failure);
145 return c_Failure;
146 }
147 for (auto expRun : runs) {
148 B2DEBUG(29, "ExpRun requested = (" << expRun.first << ", " << expRun.second << ")");
149 }
150 }
151
152 m_data.setRequestedRuns(runs);
153 if (iov.empty()) {
154 // If no user specified IoV we use the IoV from the executed run list
155 iov = IntervalOfValidity(runs[0].first, runs[0].second, runs[runs.size() - 1].first, runs[runs.size() - 1].second);
156 }
157 m_data.setRequestedIov(iov);
158 // After here, the getObject<...>(...) helpers start to work
159
161 m_data.setResult(result);
162 return result;
163}
std::vector< Calibration::ExpRun > getRunListFromAllData() const
Get the complete list of runs from inspection of collected data.
std::vector< std::string > m_inputFileNames
List of input files to the Algorithm, will initially be user defined but then gets the wildcards expa...
EResult
The result of calibration.
@ c_Undefined
Not yet known (before execution) =4 in Python.
virtual EResult calibrate()=0
Run algo on data - pure virtual: needs to be implemented.
std::string getGranularity() const
Get the granularity of collected data.

◆ fillRunToInputFilesMap()

void fillRunToInputFilesMap ( )
inherited

Fill the mapping of ExpRun -> Files.

Definition at line 330 of file CalibrationAlgorithm.cc.

331{
332 m_runsToInputFiles.clear();
333 // Save TDirectory to change back at the end
334 TDirectory* dir = gDirectory;
335 RunRange* runRange;
336 // Construct the TDirectory name where we expect our objects to be
337 string runRangeObjName(getPrefix() + "/" + RUN_RANGE_OBJ_NAME);
338 for (const auto& fileName : m_inputFileNames) {
339 //Open TFile to get the objects
340 unique_ptr<TFile> f;
341 f.reset(TFile::Open(fileName.c_str(), "READ"));
342 runRange = dynamic_cast<RunRange*>(f->Get(runRangeObjName.c_str()));
343 if (runRange) {
344 // Insert or extend the run -> file mapping for this ExpRun
345 auto expRuns = runRange->getExpRunSet();
346 for (const auto& expRun : expRuns) {
347 auto runFiles = m_runsToInputFiles.find(expRun);
348 if (runFiles != m_runsToInputFiles.end()) {
349 (runFiles->second).push_back(fileName);
350 } else {
351 m_runsToInputFiles.insert(std::make_pair(expRun, std::vector<std::string> {fileName}));
352 }
353 }
354 } else {
355 B2WARNING("Missing a RunRange object for file: " << fileName);
356 }
357 }
358 dir->cd();
359}
std::string getPrefix() const
Get the prefix used for getting calibration data.
std::map< Calibration::ExpRun, std::vector< std::string > > m_runsToInputFiles
Map of Runs to input files. Gets filled when you call getRunRangeFromAllData, gets cleared when setti...
const std::set< Calibration::ExpRun > & getExpRunSet()
Get access to the stored set.
Definition RunRange.h:64

◆ findPayloadBoundaries()

const std::vector< ExpRun > findPayloadBoundaries ( std::vector< Calibration::ExpRun > runs,
int iteration = 0 )
inherited

Used to discover the ExpRun boundaries that you want the Python CAF to execute on. This is optional and only used in some.

Definition at line 520 of file CalibrationAlgorithm.cc.

521{
522 m_boundaries.clear();
523 if (m_inputFileNames.empty()) {
524 B2ERROR("There aren't any input files set. Please use CalibrationAlgorithm::setInputFiles()");
525 return m_boundaries;
526 }
527 // Reset the internal execution data just in case something is hanging around
528 m_data.reset();
529 if (runs.empty()) {
530 // Want to loop over all runs we could possibly know about
531 runs = getRunListFromAllData();
532 }
533 // Let's check that we have some now
534 if (runs.empty()) {
535 B2ERROR("No collected data in input files.");
536 return m_boundaries;
537 }
538 // In order to find run boundaries we must have collected with data granularity == 'run'
539 if (strcmp(getGranularity().c_str(), "all") == 0) {
540 B2ERROR("The data is collected with granularity='all' (exp=-1,run=-1), and we can't use that to find run boundaries.");
541 return m_boundaries;
542 }
543 m_data.setIteration(iteration);
544 // User defined setup function
545 boundaryFindingSetup(runs, iteration);
546 std::vector<ExpRun> runList;
547 // Loop over run list and call derived class "isBoundaryRequired" member function
548 for (auto currentRun : runs) {
549 runList.push_back(currentRun);
550 m_data.setRequestedRuns(runList);
551 // After here, the getObject<...>(...) helpers start to work
552 if (isBoundaryRequired(currentRun)) {
553 m_boundaries.push_back(currentRun);
554 }
555 // Only want run-by-run
556 runList.clear();
557 // Don't want memory hanging around
558 m_data.clearCalibrationData();
559 }
560 m_data.reset();
562 return m_boundaries;
563}
std::vector< Calibration::ExpRun > m_boundaries
When using the boundaries functionality from isBoundaryRequired, this is used to store the boundaries...
virtual void boundaryFindingTearDown()
Put your algorithm back into a state ready for normal execution if you need to.
virtual void boundaryFindingSetup(std::vector< Calibration::ExpRun >, int)
If you need to make some changes to your algorithm class before 'findPayloadBoundaries' is run,...
virtual bool isBoundaryRequired(const Calibration::ExpRun &)
Given the current collector data, make a decision about whether or not this run should be the start o...

◆ fitChannel() [1/2]

void fitChannel ( short slot,
short channel,
TH1 * h )
protected

Fits the laser light on one channel.

Definition at line 29 of file TOPLocalCalFitter.cc.

30{
31 fitChannel(iSlot, iChannel, h_profile, /*inBins=*/false, /*frac=*/0.0);
32}

◆ fitChannel() [2/2]

void fitChannel ( short slot,
short channel,
TH1 * h,
bool inBins,
double frac )
protected

Fit the laser spectrum of a single channel with extra controls for amplitude-bin fits.

slot 0-based slot index (0..15). channel 0-based channel index (0..511). h Input time profile histogram. inBins If true, fix the light-path fraction parameter. frac Fraction value used when inBins is true.

Definition at line 355 of file TOPLocalCalFitter.cc.

356{
357 // loads the TTS infos and the fit constraint for the given channel and slot
358 if (m_fitterMode == "monitoring")
359 m_treeConstraints->GetEntry(iChannel + 512 * iSlot);
360 else if (m_fitterMode == "calibration") // The MC-based constraint file has only slot 1 at the moment
361 m_treeConstraints->GetEntry(iChannel);
362
363 m_treeTTS->GetEntry(iChannel + 512 * iSlot);
364 // finds the maximum of the hit timing histogram and adjust the histogram range around it (3 ns window)
365 double maxpos = h_profile->GetBinCenter(h_profile->GetMaximumBin());
366 h_profile->GetXaxis()->SetRangeUser(maxpos - 1, maxpos + 2.);
367
368 // gets the histogram integral to give a starting value to the fitter
369 double integral = h_profile->Integral();
370
371 // creates the fit function
372 TF1 laser = TF1("laser", laserPDF, maxpos - 1, maxpos + 2., 16);
373
374 // par[0] = peakTime
375 laser.SetParameter(0, maxpos);
376 laser.SetParLimits(0, maxpos - 0.06, maxpos + 0.06);
377
378 // par[1] = sigma
379 laser.SetParameter(1, 0.1);
380 laser.SetParLimits(1, 0.05, 0.25);
381 if (m_fitterMode == "MC") {
382 laser.SetParameter(1, 0.02);
383 laser.SetParLimits(1, 0., 0.04);
384 }
385
386 // par[2] = fraction of the main peak respect to the total
387 laser.SetParameter(2, m_fractionConstraints);
388 laser.SetParLimits(2, 0.5, 1.);
389 if (inBins) {
390 laser.FixParameter(2, frac);
391 }
392
393 // par[3]= time difference between the main and secondary path. fixed to the MC value
394 laser.FixParameter(3, m_deltaTConstraints);
395
396 // This is an hack: in some channels the MC sees one peak only, while in the data there are clearly
397 // two well distinguished peaks. This will disappear if we'll ever get a better laser simulation.
398 if (m_deltaTConstraints > -0.001) {
399 laser.SetParameter(3, -0.3);
400 laser.SetParLimits(3, -0.4, -0.2);
401 }
402
403 // par[4] is the quadratic difference of the sigmas of the two TTS gaussians (tail - core)
404 laser.FixParameter(4, TMath::Sqrt(m_sigma2 * m_sigma2 - m_sigma1 * m_sigma1));
405 // par[5] is the position of the second TTS gaussian w/ respect to the first one
406 laser.FixParameter(5, m_mean2);
407 // par[6] is the relative contribution of the second TTS gaussian
408 laser.FixParameter(6, m_f1);
409 if (m_fitterMode == "MC")
410 laser.FixParameter(6, 0);
411
412 // par[7] is the PDF normalization, = integral*bin width
413 const double binw = h_profile->GetXaxis()->GetBinWidth(1);
414 laser.SetParameter(7, integral * binw);
415 laser.SetParLimits(7, 0.2 * integral * binw, 2.*integral * binw);
416
417 // par[8-10] are the relative position, the sigma and the integral of the extra peak
418 laser.SetParameter(8, 1.);
419 laser.SetParLimits(8, 0.3, 2.);
420 laser.SetParameter(9, 0.2);
421 laser.SetParLimits(9, 0.08, 1.);
422 laser.SetParameter(10, 0.1 * integral * binw);
423 laser.SetParLimits(10, 0., 0.2 * integral * binw);
424 // par[14-15] are the tail parameters of the crystal ball function used to describe the extra peak
425 laser.SetParameter(14, -2.);
426 laser.SetParameter(15, 2.);
427 laser.SetParLimits(15, 1.01, 20.);
428
429 // par[11-13] are relative position, sigma and integral of the broad gaussian added to better describe the tail at high times
430 laser.SetParameter(11, 1.);
431 laser.SetParLimits(11, 0.1, 5.);
432 laser.SetParameter(12, 0.8);
433 laser.SetParLimits(12, 0., 5.);
434 laser.SetParameter(13, 0.01 * integral * binw);
435 laser.SetParLimits(13, 0., 0.2 * integral * binw);
436
437 // if it's a monitoring fit, fix a buch more parameters.
438 if (m_fitterMode == "monitoring") {
439 laser.FixParameter(2, m_fractionConstraints);
440 laser.FixParameter(3, m_deltaTConstraints);
441 laser.FixParameter(8, m_timeExtraConstraints);
442 laser.FixParameter(9, m_sigmaExtraConstraints);
443 laser.FixParameter(14, m_alphaExtraConstraints);
444 laser.FixParameter(15, m_nExtraConstraints);
445 laser.FixParameter(11, m_timeBackgroundConstraints);
446 laser.FixParameter(12, m_sigmaBackgroundConstraints);
447 }
448
449 // if it's a MC fit, fix a buch more parameters.
450 if (m_fitterMode == "MC") {
451 laser.SetParameter(2, 0.8);
452 laser.SetParLimits(2, 0., 1.);
453 laser.SetParameter(3, -0.1);
454 laser.SetParLimits(3, -0.4, -0.);
455 // The following are just random reasonable number, only to pin-point the tail components to some value and remove them form the fit
456 laser.FixParameter(8, 0);
457 laser.FixParameter(9, 0.1);
458 laser.FixParameter(14, -2.);
459 laser.FixParameter(15, 2);
460 laser.FixParameter(11, 1.);
461 laser.FixParameter(12, 0.1);
462 laser.FixParameter(13, 0.);
463 laser.FixParameter(10, 0.);
464 }
465
466 // make the plot of the fit function nice setting 2000 sampling points
467 laser.SetNpx(2000);
468
469 // do the fit!
470 h_profile->Fit("laser", "R L Q");
471
472 // Add by hand the different fit components to the histogram, mostly for debugging/presentation purposes
473 TF1* peak1 = new TF1("peak1", laserPDF, maxpos - 1, maxpos + 2., 16);
474 TF1* peak2 = new TF1("peak2", laserPDF, maxpos - 1, maxpos + 2., 16);
475 TF1* extra = new TF1("extra", laserPDF, maxpos - 1, maxpos + 2., 16);
476 TF1* background = new TF1("background", laserPDF, maxpos - 1, maxpos + 2., 16);
477 for (int iPar = 0; iPar < 16; iPar++) {
478 peak1->FixParameter(iPar, laser.GetParameter(iPar));
479 peak2->FixParameter(iPar, laser.GetParameter(iPar));
480 extra->FixParameter(iPar, laser.GetParameter(iPar));
481 background->FixParameter(iPar, laser.GetParameter(iPar));
482 }
483 peak1->FixParameter(2, 0.);
484 peak1->FixParameter(7, (1 - laser.GetParameter(2))*laser.GetParameter(7));
485 peak1->FixParameter(10, 0.);
486 peak1->FixParameter(13, 0.);
487 peak2->FixParameter(2, 1.);
488 peak2->FixParameter(7, laser.GetParameter(2)*laser.GetParameter(7));
489 peak2->FixParameter(10, 0.);
490 peak2->FixParameter(13, 0.);
491 extra->FixParameter(7, 0.);
492 extra->FixParameter(13, 0.);
493 background->FixParameter(7, 0.);
494 background->FixParameter(10, 0.);
495
496 h_profile->GetListOfFunctions()->Add(peak1);
497 h_profile->GetListOfFunctions()->Add(peak2);
498 h_profile->GetListOfFunctions()->Add(extra);
499 h_profile->GetListOfFunctions()->Add(background);
500
501 // save the results in the variables linked to the tree branches
502 m_channel = iChannel;
503 m_row = rowOf(iSlot, iChannel);
504 m_col = colOf(iSlot, iChannel);
505 m_slot = iSlot + 1;
506 m_peakTime = laser.GetParameter(0);
507 m_peakTimeErr = laser.GetParError(0);
508 m_deltaT = laser.GetParameter(3);
509 m_deltaTErr = laser.GetParError(3);
510 m_sigma = laser.GetParameter(1);
511 m_sigmaErr = laser.GetParError(1);
512 m_fraction = laser.GetParameter(2);
513 m_fractionErr = laser.GetParError(2);
514 m_yieldLaser = laser.GetParameter(7) / binw;
515 m_yieldLaserErr = laser.GetParError(7) / binw;
516 m_timeExtra = laser.GetParameter(8);
517 m_sigmaExtra = laser.GetParameter(9);
518 m_yieldLaserExtra = laser.GetParameter(10) / binw;
519 m_alphaExtra = laser.GetParameter(14);
520 m_nExtra = laser.GetParameter(15);
521 m_timeBackground = laser.GetParameter(11);
522 m_sigmaBackground = laser.GetParameter(12);
523 m_yieldLaserBackground = laser.GetParameter(13) / binw;
524 m_chi2 = laser.GetChisquare() / laser.GetNDF();
525
526 // copy some MC information to the output tree
527 m_fractionMC = m_fractionConstraints;
528 m_deltaTMC = m_deltaTConstraints;
529 m_peakTimeMC = m_peakTimeConstraints;
530
531 return;
532}

◆ fitInAmpliduteBins()

void fitInAmpliduteBins ( bool isFitInAmplitudeBins)
inline

Enables the fit amplitude bins.

Definition at line 88 of file TOPLocalCalFitter.h.

89 {
90 m_isFitInAmplitudeBins = isFitInAmplitudeBins;
91 }

◆ fitPulser()

void fitPulser ( TH1 * h_profileFirstPulser,
TH1 * h_profileSecondPulser )
protected

Fits the two pulsers.

Definition at line 534 of file TOPLocalCalFitter.cc.

535{
536 float maxpos = h_profileFirstPulser->GetBinCenter(h_profileFirstPulser->GetMaximumBin());
537 h_profileFirstPulser->GetXaxis()->SetRangeUser(maxpos - 1, maxpos + 1.);
538 if (h_profileFirstPulser->Integral() > 1000) {
539 TF1 pulser1 = TF1("pulser1", "[0]*TMath::Gaus(x, [1], [2], kTRUE)", maxpos - 1, maxpos + 1.);
540 pulser1.SetParameter(0, 1.);
541 pulser1.SetParameter(1, maxpos);
542 pulser1.SetParameter(2, 0.05);
543 h_profileFirstPulser->Fit("pulser1", "R Q");
544 m_firstPulserTime = pulser1.GetParameter(1);
545 m_firstPulserSigma = pulser1.GetParameter(2);
546 h_profileFirstPulser->Write();
547 } else {
548 m_firstPulserTime = -999;
549 m_firstPulserSigma = -999;
550 }
551
552 maxpos = h_profileSecondPulser->GetBinCenter(h_profileSecondPulser->GetMaximumBin());
553 h_profileSecondPulser->GetXaxis()->SetRangeUser(maxpos - 1, maxpos + 1.);
554 if (h_profileSecondPulser->Integral() > 1000) {
555 TF1 pulser2 = TF1("pulser2", "[0]*TMath::Gaus(x, [1], [2], kTRUE)", maxpos - 1, maxpos + 1.);
556 pulser2.SetParameter(0, 1.);
557 pulser2.SetParameter(1, maxpos);
558 pulser2.SetParameter(2, 0.05);
559 h_profileSecondPulser->Fit("pulser2", "R Q");
560 m_secondPulserTime = pulser2.GetParameter(1);
561 m_secondPulserSigma = pulser2.GetParameter(2);
562 h_profileSecondPulser->Write();
563 } else {
564 m_secondPulserTime = -999;
565 m_secondPulserSigma = -999;
566 }
567 return;
568}

◆ getAllGranularityExpRun()

Calibration::ExpRun getAllGranularityExpRun ( ) const
inlineprotectedinherited

Returns the Exp,Run pair that means 'Everything'. Currently unused.

Definition at line 327 of file CalibrationAlgorithm.h.

327{return m_allExpRun;}

◆ getCollectorName()

std::string getCollectorName ( ) const
inlineinherited

Alias for prefix.

For convenience and less writing, we say developers to set this to default collector module name in constructor of base class. One can however use the dublets of collector+algorithm multiple times with different settings. To bind these together correctly, the prefix has to be set the same for algo and collector. So we call the setter setPrefix rather than setModuleName or whatever. This getter will work out of the box for default cases -> return the name of module you have to add to your path to collect data for this algorithm.

Definition at line 164 of file CalibrationAlgorithm.h.

164{return getPrefix();}

◆ getDescription()

const std::string & getDescription ( ) const
inlineinherited

Get the description of the algorithm (set by developers in constructor)

Definition at line 216 of file CalibrationAlgorithm.h.

216{return m_description;}

◆ getExpRunString()

string getExpRunString ( Calibration::ExpRun & expRun) const
privateinherited

Gets the "exp.run" string repr. of (exp,run)

Definition at line 254 of file CalibrationAlgorithm.cc.

255{
256 string expRunString;
257 expRunString += to_string(expRun.first);
258 expRunString += ".";
259 expRunString += to_string(expRun.second);
260 return expRunString;
261}

◆ getFullObjectPath()

string getFullObjectPath ( const std::string & name,
Calibration::ExpRun expRun ) const
privateinherited

constructs the full TDirectory + Key name of an object in a TFile based on its name and exprun

Definition at line 263 of file CalibrationAlgorithm.cc.

264{
265 string dirName = getPrefix() + "/" + name;
266 string objName = name + "_" + getExpRunString(expRun);
267 return dirName + "/" + objName;
268}
std::string getExpRunString(Calibration::ExpRun &expRun) const
Gets the "exp.run" string repr. of (exp,run)

◆ getGranularity()

std::string getGranularity ( ) const
inlineinherited

Get the granularity of collected data.

Definition at line 188 of file CalibrationAlgorithm.h.

188{return m_granularityOfData;};

◆ getGranularityFromData()

string getGranularityFromData ( ) const
protectedinherited

Get the granularity of collected data.

Definition at line 383 of file CalibrationAlgorithm.cc.

384{
385 // Save TDirectory to change back at the end
386 TDirectory* dir = gDirectory;
387 RunRange* runRange;
388 string runRangeObjName(getPrefix() + "/" + RUN_RANGE_OBJ_NAME);
389 // We only check the first file
390 string fileName = m_inputFileNames[0];
391 unique_ptr<TFile> f;
392 f.reset(TFile::Open(fileName.c_str(), "READ"));
393 runRange = dynamic_cast<RunRange*>(f->Get(runRangeObjName.c_str()));
394 if (!runRange) {
395 B2FATAL("The input file " << fileName << " does not contain a RunRange object at "
396 << runRangeObjName << ". Please set your input files to exclude it.");
397 return "";
398 }
399 string granularity = runRange->getGranularity();
400 dir->cd();
401 return granularity;
402}
std::string getGranularity() const
Gets the m_granularity.
Definition RunRange.h:110

◆ getInputFileNames()

PyObject * getInputFileNames ( )
inherited

Get the input file names used for this algorithm and pass them out as a Python list of unicode strings.

Definition at line 245 of file CalibrationAlgorithm.cc.

246{
247 PyObject* objInputFileNames = PyList_New(m_inputFileNames.size());
248 for (size_t i = 0; i < m_inputFileNames.size(); ++i) {
249 PyList_SetItem(objInputFileNames, i, Py_BuildValue("s", m_inputFileNames[i].c_str()));
250 }
251 return objInputFileNames;
252}

◆ getInputJsonObject()

const nlohmann::json & getInputJsonObject ( ) const
inlineprotectedinherited

Get the entire top level JSON object. We explicitly say this must be of object type so that we might pick.

Definition at line 357 of file CalibrationAlgorithm.h.

357{return m_jsonExecutionInput;}

◆ getInputJsonValue()

template<class T>
const T getInputJsonValue ( const std::string & key) const
inlineprotectedinherited

Get an input JSON value using a key. The normal exceptions are raised when the key doesn't exist.

Definition at line 350 of file CalibrationAlgorithm.h.

351 {
352 return m_jsonExecutionInput.at(key);
353 }

◆ getIovFromAllData()

IntervalOfValidity getIovFromAllData ( ) const
inherited

Get the complete IoV from inspection of collected data.

Definition at line 325 of file CalibrationAlgorithm.cc.

326{
328}
RunRange getRunRangeFromAllData() const
Get the complete RunRange from inspection of collected data.
IntervalOfValidity getIntervalOfValidity()
Make IntervalOfValidity from the set, spanning all runs. Works because sets are sorted by default.
Definition RunRange.h:70

◆ getIteration()

int getIteration ( ) const
inlineprotectedinherited

Get current iteration.

Definition at line 269 of file CalibrationAlgorithm.h.

269{ return m_data.getIteration(); }

◆ getObjectPtr()

template<class T>
std::shared_ptr< T > getObjectPtr ( std::string name)
inlineprotectedinherited

Get calibration data object (for all runs the calibration is requested for) This function will only work during or after execute() has been called once.

Definition at line 285 of file CalibrationAlgorithm.h.

286 {
287 if (m_runsToInputFiles.size() == 0)
288 fillRunToInputFilesMap();
289 return getObjectPtr<T>(name, m_data.getRequestedRuns());
290 }

◆ getOutputJsonValue()

template<class T>
const T getOutputJsonValue ( const std::string & key) const
inlineprotectedinherited

Get a value using a key from the JSON output object, not sure why you would want to do this.

Definition at line 342 of file CalibrationAlgorithm.h.

343 {
344 return m_jsonExecutionOutput.at(key);
345 }

◆ getPayloads()

std::list< Database::DBImportQuery > & getPayloads ( )
inlineinherited

Get constants (in TObjects) for database update from last execution.

Definition at line 204 of file CalibrationAlgorithm.h.

204{return m_data.getPayloads();}

◆ getPayloadValues()

std::list< Database::DBImportQuery > getPayloadValues ( )
inlineinherited

Get constants (in TObjects) for database update from last execution but passed by VALUE.

Definition at line 207 of file CalibrationAlgorithm.h.

207{return m_data.getPayloadValues();}

◆ getPrefix()

std::string getPrefix ( ) const
inlineinherited

Get the prefix used for getting calibration data.

Definition at line 146 of file CalibrationAlgorithm.h.

146{return m_prefix;}

◆ getRunList()

const std::vector< Calibration::ExpRun > & getRunList ( ) const
inlineprotectedinherited

Get the list of runs for which calibration is called.

Definition at line 266 of file CalibrationAlgorithm.h.

266{return m_data.getRequestedRuns();}

◆ getRunListFromAllData()

vector< ExpRun > getRunListFromAllData ( ) const
inherited

Get the complete list of runs from inspection of collected data.

Definition at line 318 of file CalibrationAlgorithm.cc.

319{
320 RunRange runRange = getRunRangeFromAllData();
321 set<ExpRun> expRunSet = runRange.getExpRunSet();
322 return vector<ExpRun>(expRunSet.begin(), expRunSet.end());
323}

◆ getRunRangeFromAllData()

RunRange getRunRangeFromAllData ( ) const
inherited

Get the complete RunRange from inspection of collected data.

Definition at line 361 of file CalibrationAlgorithm.cc.

362{
363 // Save TDirectory to change back at the end
364 TDirectory* dir = gDirectory;
365 RunRange runRange;
366 // Construct the TDirectory name where we expect our objects to be
367 string runRangeObjName(getPrefix() + "/" + RUN_RANGE_OBJ_NAME);
368 for (const auto& fileName : m_inputFileNames) {
369 //Open TFile to get the objects
370 unique_ptr<TFile> f;
371 f.reset(TFile::Open(fileName.c_str(), "READ"));
372 RunRange* runRangeOther = dynamic_cast<RunRange*>(f->Get(runRangeObjName.c_str()));
373 if (runRangeOther) {
374 runRange.merge(runRangeOther);
375 } else {
376 B2WARNING("Missing a RunRange object for file: " << fileName);
377 }
378 }
379 dir->cd();
380 return runRange;
381}
virtual void merge(const RunRange *other)
Implementation of merging - other is added to the set (union)
Definition RunRange.h:52

◆ getVecInputFileNames()

std::vector< std::string > getVecInputFileNames ( ) const
inlineprotectedinherited

Get the input file names used for this algorithm as a STL vector.

Definition at line 275 of file CalibrationAlgorithm.h.

275{return m_inputFileNames;}

◆ inputJsonKeyExists()

bool inputJsonKeyExists ( const std::string & key) const
inlineprotectedinherited

Test for a key in the input JSON object.

Definition at line 360 of file CalibrationAlgorithm.h.

360{return m_jsonExecutionInput.count(key);}

◆ isBoundaryRequired()

virtual bool isBoundaryRequired ( const Calibration::ExpRun & )
inlineprotectedvirtualinherited

Given the current collector data, make a decision about whether or not this run should be the start of a payload boundary.

Reimplemented in PXDAnalyticGainCalibrationAlgorithm, PXDValidationAlgorithm, SVD3SampleCoGTimeCalibrationAlgorithm, SVD3SampleELSTimeCalibrationAlgorithm, SVDCoGTimeCalibrationAlgorithm, TestBoundarySettingAlgorithm, and TestCalibrationAlgorithm.

Definition at line 243 of file CalibrationAlgorithm.h.

244 {
245 B2ERROR("You didn't implement a isBoundaryRequired() member function in your CalibrationAlgorithm but you are calling it!");
246 return false;
247 }

◆ loadInputJson()

bool loadInputJson ( const std::string & jsonString)
inherited

Load the m_inputJson variable from a string (useful from Python interface). The return bool indicates success or failure.

Definition at line 502 of file CalibrationAlgorithm.cc.

503{
504 try {
505 auto jsonInput = nlohmann::json::parse(jsonString);
506 // Input string has an object (dict) as the top level object?
507 if (jsonInput.is_object()) {
508 m_jsonExecutionInput = jsonInput;
509 return true;
510 } else {
511 B2ERROR("JSON input string isn't an object type i.e. not a '{}' at the top level.");
512 return false;
513 }
514 } catch (nlohmann::json::parse_error&) {
515 B2ERROR("Parsing of JSON input string failed");
516 return false;
517 }
518}
nlohmann::json m_jsonExecutionInput
Optional input JSON object used to make decisions about how to execute the algorithm code.

◆ loadMCInfoTrees()

void loadMCInfoTrees ( )
protected

loads the TTS parameters and the MC truth info

Definition at line 173 of file TOPLocalCalFitter.cc.

174{
175 m_inputTTS = TFile::Open(m_TTSData.c_str());
176 m_inputConstraints = TFile::Open(m_fitConstraints.c_str());
177
178 B2INFO("Getting the TTS parameters from " << m_TTSData);
179 m_inputTTS->cd();
180 m_inputTTS->GetObject("tree", m_treeTTS);
181 m_treeTTS->SetBranchAddress("mean2", &m_mean2);
182 m_treeTTS->SetBranchAddress("sigma1", &m_sigma1);
183 m_treeTTS->SetBranchAddress("sigma2", &m_sigma2);
184 m_treeTTS->SetBranchAddress("fraction1", &m_f1);
185 m_treeTTS->SetBranchAddress("fraction2", &m_f2);
186 m_treeTTS->SetBranchAddress("pixelRow", &m_pixelRow);
187 m_treeTTS->SetBranchAddress("pixelCol", &m_pixelCol);
188
189 buildChannelMaps(); // build the maps rowOf[slot][channel], colOf[slot][channel]
190
191 if (m_fitterMode == "MC")
192 std::cout << "Running in MC mode, not constraints will be set" << std::endl;
193 else {
194 B2INFO("Getting the laser fit parameters from " << m_fitConstraints);
195 m_inputConstraints->cd();
196 m_inputConstraints->GetObject("fitTree", m_treeConstraints);
197 m_treeConstraints->SetBranchAddress("peakTime", &m_peakTimeConstraints);
198 m_treeConstraints->SetBranchAddress("deltaT", &m_deltaTConstraints);
199 m_treeConstraints->SetBranchAddress("fraction", &m_fractionConstraints);
200 if (m_fitterMode == "monitoring") {
201 m_treeConstraints->SetBranchAddress("timeExtra", &m_timeExtraConstraints);
202 m_treeConstraints->SetBranchAddress("sigmaExtra", &m_sigmaExtraConstraints);
203 m_treeConstraints->SetBranchAddress("alphaExtra", &m_alphaExtraConstraints);
204 m_treeConstraints->SetBranchAddress("nExtra", &m_nExtraConstraints);
205 m_treeConstraints->SetBranchAddress("timeBackground", &m_timeBackgroundConstraints);
206 m_treeConstraints->SetBranchAddress("sigmaBackground", &m_sigmaBackgroundConstraints);
207 }
208 }
209 return;
210}

◆ resetInputJson()

void resetInputJson ( )
inlineprotectedinherited

Clears the m_inputJson member variable.

Definition at line 330 of file CalibrationAlgorithm.h.

330{m_jsonExecutionInput.clear();}

◆ resetOutputJson()

void resetOutputJson ( )
inlineprotectedinherited

Clears the m_outputJson member variable.

Definition at line 333 of file CalibrationAlgorithm.h.

333{m_jsonExecutionOutput.clear();}

◆ rowOf()

short rowOf ( short slot,
short ch ) const
inlineprivatenoexcept

Row index for (slot,channel), or -1 if out of bounds.

Definition at line 256 of file TOPLocalCalFitter.h.

257 {
258 return (slot >= 0 && slot < 16 && ch >= 0 && ch < 512) ? m_rowOf[slot][ch] : short(-1);
259 }

◆ saveCalibration() [1/6]

void saveCalibration ( TClonesArray * data,
const std::string & name )
protectedinherited

Store DBArray payload with given name with default IOV.

Definition at line 297 of file CalibrationAlgorithm.cc.

298{
299 saveCalibration(data, name, m_data.getRequestedIov());
300}
void saveCalibration(TClonesArray *data, const std::string &name)
Store DBArray payload with given name with default IOV.

◆ saveCalibration() [2/6]

void saveCalibration ( TClonesArray * data,
const std::string & name,
const IntervalOfValidity & iov )
protectedinherited

Store DBArray with given name and custom IOV.

Definition at line 276 of file CalibrationAlgorithm.cc.

277{
278 B2DEBUG(29, "Saving calibration TClonesArray '" << name << "' to payloads list.");
279 getPayloads().emplace_back(name, data, iov);
280}

◆ saveCalibration() [3/6]

void saveCalibration ( TObject * data)
protectedinherited

Store DB payload with default name and default IOV.

Definition at line 287 of file CalibrationAlgorithm.cc.

288{
289 saveCalibration(data, DataStore::objectName(data->IsA(), ""));
290}
static std::string objectName(const TClass *t, const std::string &name)
Return the storage name for an object of the given TClass and name.
Definition DataStore.cc:150

◆ saveCalibration() [4/6]

void saveCalibration ( TObject * data,
const IntervalOfValidity & iov )
protectedinherited

Store DB payload with default name and custom IOV.

Definition at line 282 of file CalibrationAlgorithm.cc.

283{
284 saveCalibration(data, DataStore::objectName(data->IsA(), ""), iov);
285}

◆ saveCalibration() [5/6]

void saveCalibration ( TObject * data,
const std::string & name )
protectedinherited

Store DB payload with given name with default IOV.

Definition at line 292 of file CalibrationAlgorithm.cc.

293{
294 saveCalibration(data, name, m_data.getRequestedIov());
295}

◆ saveCalibration() [6/6]

void saveCalibration ( TObject * data,
const std::string & name,
const IntervalOfValidity & iov )
protectedinherited

Store DB payload with given name and custom IOV.

Definition at line 270 of file CalibrationAlgorithm.cc.

271{
272 B2DEBUG(29, "Saving calibration TObject = '" << name << "' to payloads list.");
273 getPayloads().emplace_back(name, data, iov);
274}

◆ setDescription()

void setDescription ( const std::string & description)
inlineprotectedinherited

Set algorithm description (in constructor)

Definition at line 321 of file CalibrationAlgorithm.h.

321{m_description = description;}

◆ setFitConstraintsFileName()

void setFitConstraintsFileName ( const std::string & fitConstraints)
inline

Sets the name of the root file containing the laser MC time corrections and the fit constraints.

If the monitoringFit option is used (low statistics sample), this file must be the result of an high-statistics fit.

Definition at line 54 of file TOPLocalCalFitter.h.

55 {
56 m_fitConstraints = fitConstraints;
57 }

◆ setFitMode()

void setFitMode ( const std::string & fitterMode)
inline

Sets the fitter mode.

The options are 'calibration' (default), 'monitoring' or 'MC'. The mode affects the number of parameters that are fixed. Use calibration if you are fitting a large sample (1 M events or more) to derive a set of channelT0 calibrations. Use monitoring if you are fitting a smaller sample. The light path fractions and the tail parameters will be constrained according to the constraint file you passed to the fitter (usually the result of a high-statistics fit). Use MC to fit the MC sample and calculate a new set of prism corrections. No parameter is fixed, but the tail components are removed form the fit.

Definition at line 73 of file TOPLocalCalFitter.h.

74 {
75 if (fitterMode == "calibration")
76 B2INFO("Fitter set to calibration mode");
77 else if (fitterMode == "monitoring")
78 B2INFO("Fitter set to monitoring mode");
79 else if (fitterMode == "MC")
80 B2INFO("Fitter set to MC mode");
81 else
82 B2ERROR("Unknown fitter type " << fitterMode << ". The valid options are calibration, monitoring or MC");
83
84 m_fitterMode = fitterMode;
85 }

◆ setInputFileNames() [1/2]

void setInputFileNames ( PyObject * inputFileNames)
inherited

Set the input file names used for this algorithm from a Python list.

Set the input file names used for this algorithm and resolve the wildcards.

Definition at line 166 of file CalibrationAlgorithm.cc.

167{
168 // The reasoning for this very 'manual' approach to extending the Python interface
169 // (instead of using boost::python) is down to my fear of putting off final users with
170 // complexity on their side.
171 //
172 // I didn't want users that inherit from this class to be forced to use boost and
173 // to have to define a new python module just to use the CAF. A derived class from
174 // from a boost exposed class would need to have its own boost python module definition
175 // to allow access from a steering file and to the base class functions (I think).
176 // I also couldn't be bothered to write a full framework to get around the issue in a similar
177 // way to Module()...maybe there's an easy way.
178 //
179 // But this way we can allow people to continue using their ROOT implemented classes and inherit
180 // easily from this one. But add in a few helper functions that work with Python objects
181 // created in their steering file i.e. instead of being forced to use STL objects as input
182 // to the algorithm.
183 if (PyList_Check(inputFileNames)) {
184 boost::python::handle<> handle(boost::python::borrowed(inputFileNames));
185 boost::python::list listInputFileNames(handle);
186 auto vecInputFileNames = PyObjConvUtils::convertPythonObject(listInputFileNames, vector<string>());
187 setInputFileNames(vecInputFileNames);
188 } else {
189 B2ERROR("Tried to set the input files but we didn't receive a Python list.");
190 }
191}
void setInputFileNames(PyObject *inputFileNames)
Set the input file names used for this algorithm from a Python list.
Scalar convertPythonObject(const boost::python::object &pyObject, Scalar)
Convert from Python to given type.

◆ setInputFileNames() [2/2]

void setInputFileNames ( std::vector< std::string > inputFileNames)
protectedinherited

Set the input file names used for this algorithm.

Set the input file names used for this algorithm and resolve the wildcards.

Definition at line 194 of file CalibrationAlgorithm.cc.

195{
196 // A lot of code below is tweaked from RootInputModule::initialize,
197 // since we're basically copying the functionality anyway.
198 if (inputFileNames.empty()) {
199 B2WARNING("You have called setInputFileNames() with an empty list. Did you mean to do that?");
200 return;
201 }
202 auto tmpInputFileNames = RootIOUtilities::expandWordExpansions(inputFileNames);
203
204 // We'll use a set to enforce sorted unique file paths as we check them
205 set<string> setInputFileNames;
206 // Check that files exist and convert to absolute paths
207 for (auto path : tmpInputFileNames) {
208 string fullPath = fs::absolute(path).string();
209 if (fs::exists(fullPath)) {
210 setInputFileNames.insert(fs::canonical(fullPath).string());
211 } else {
212 B2WARNING("Couldn't find the file " << path);
213 }
214 }
215
216 if (setInputFileNames.empty()) {
217 B2WARNING("No valid files specified!");
218 return;
219 } else {
220 // Reset the run -> files map as our files are likely different
221 m_runsToInputFiles.clear();
222 }
223
224 // Open TFile to check they can be accessed by ROOT
225 TDirectory* dir = gDirectory;
226 for (const string& fileName : setInputFileNames) {
227 unique_ptr<TFile> f;
228 try {
229 f.reset(TFile::Open(fileName.c_str(), "READ"));
230 } catch (logic_error&) {
231 //this might happen for ~invaliduser/foo.root
232 //actually undefined behaviour per standard, reported as ROOT-8490 in JIRA
233 }
234 if (!f || !f->IsOpen()) {
235 B2FATAL("Couldn't open input file " + fileName);
236 }
237 }
238 dir->cd();
239
240 // Copy the entries of the set to a vector
241 m_inputFileNames = vector<string>(setInputFileNames.begin(), setInputFileNames.end());
243}
std::string m_granularityOfData
Granularity of input data. This only changes when the input files change so it isn't specific to an e...
std::string getGranularityFromData() const
Get the granularity of collected data.
std::vector< std::string > expandWordExpansions(const std::vector< std::string > &filenames)
Performs wildcard expansion using wordexp(), returns matches.

◆ setMinEntries()

void setMinEntries ( int minEntries)
inline

Sets the minimum number of entries to perform the calibration in one channel.

Definition at line 40 of file TOPLocalCalFitter.h.

41 {
42 m_minEntries = minEntries;
43 }

◆ setOutputFileName()

void setOutputFileName ( const std::string & output)
inline

Sets the name of the output root file.

Definition at line 46 of file TOPLocalCalFitter.h.

47 {
48 m_output = output;
49 }

◆ setOutputJsonValue()

template<class T>
void setOutputJsonValue ( const std::string & key,
const T & value )
inlineprotectedinherited

Set a key:value pair for the outputJson object, expected to used internally during calibrate()

Definition at line 337 of file CalibrationAlgorithm.h.

337{m_jsonExecutionOutput[key] = value;}

◆ setPrefix()

void setPrefix ( const std::string & prefix)
inlineinherited

Set the prefix used to identify datastore objects.

Definition at line 167 of file CalibrationAlgorithm.h.

167{m_prefix = prefix;}

◆ setTTSFileName()

void setTTSFileName ( const std::string & TTSData)
inline

Sets the name of the root file containing the TTS parameters.

Definition at line 60 of file TOPLocalCalFitter.h.

61 {
62 m_TTSData = TTSData;
63 }

◆ setupOutputTreeAndFile()

void setupOutputTreeAndFile ( )
protected

prepares the output tree

Definition at line 212 of file TOPLocalCalFitter.cc.

213{
214 m_histFile = new TFile(m_output.c_str(), "recreate");
215 m_histFile->cd();
216 m_fitTree = new TTree("fitTree", "fitTree");
217 m_fitTree->Branch<short>("channel", &m_channel);
218 m_fitTree->Branch<short>("slot", &m_slot);
219 m_fitTree->Branch<short>("row", &m_row);
220 m_fitTree->Branch<short>("col", &m_col);
221 m_fitTree->Branch<float>("peakTime", &m_peakTime);
222 m_fitTree->Branch<float>("peakTimeErr", &m_peakTimeErr);
223 m_fitTree->Branch<float>("deltaT", &m_deltaT);
224 m_fitTree->Branch<float>("deltaTErr", &m_deltaTErr);
225 m_fitTree->Branch<float>("sigma", &m_sigma);
226 m_fitTree->Branch<float>("sigmaErr", &m_sigmaErr);
227 m_fitTree->Branch<float>("fraction", &m_fraction);
228 m_fitTree->Branch<float>("fractionErr", &m_fractionErr);
229 m_fitTree->Branch<float>("yieldLaser", &m_yieldLaser);
230 m_fitTree->Branch<float>("yieldLaserErr", &m_yieldLaserErr);
231 m_fitTree->Branch<float>("timeExtra", &m_timeExtra);
232 m_fitTree->Branch<float>("sigmaExtra", &m_sigmaExtra);
233 m_fitTree->Branch<float>("nExtra", &m_nExtra);
234 m_fitTree->Branch<float>("alphaExtra", &m_alphaExtra);
235 m_fitTree->Branch<float>("yieldLaserExtra", &m_yieldLaserExtra);
236 m_fitTree->Branch<float>("timeBackground", &m_timeBackground);
237 m_fitTree->Branch<float>("sigmaBackground", &m_sigmaBackground);
238 m_fitTree->Branch<float>("yieldLaserBackground", &m_yieldLaserBackground);
239 m_fitTree->Branch<float>("fractionMC", &m_fractionMC);
240 m_fitTree->Branch<float>("deltaTMC", &m_deltaTMC);
241 m_fitTree->Branch<float>("peakTimeMC", &m_peakTimeMC);
242 m_fitTree->Branch<float>("firstPulserTime", &m_firstPulserTime);
243 m_fitTree->Branch<float>("firstPulserSigma", &m_firstPulserSigma);
244 m_fitTree->Branch<float>("secondPulserTime", &m_secondPulserTime);
245 m_fitTree->Branch<float>("secondPulserSigma", &m_secondPulserSigma);
246 m_fitTree->Branch<short>("fitStatus", &m_fitStatus);
247 m_fitTree->Branch<double>("width", &m_width);
248 m_fitTree->Branch<double>("amplitude", &m_amplitude);
249 m_fitTree->Branch<float>("chi2", &m_chi2);
250 m_fitTree->Branch<float>("rms", &m_rms);
251
252
253 if (m_isFitInAmplitudeBins) {
254 m_timewalkTree = new TTree("timewalkTree", "timewalkTree");
255 m_timewalkTree->Branch<float>("binLowerEdge", &m_binLowerEdge);
256 m_timewalkTree->Branch<float>("binUpperEdge", &m_binUpperEdge);
257 m_timewalkTree->Branch<short>("channel", &m_channel);
258 m_timewalkTree->Branch<short>("slot", &m_slot);
259 m_timewalkTree->Branch<short>("row", &m_row);
260 m_timewalkTree->Branch<short>("col", &m_col);
261 m_timewalkTree->Branch<float>("histoIntegral", &m_histoIntegral);
262 m_timewalkTree->Branch<float>("peakTime", &m_peakTime);
263 m_timewalkTree->Branch<float>("peakTimeErr", &m_peakTimeErr);
264 m_timewalkTree->Branch<float>("deltaT", &m_deltaT);
265 m_timewalkTree->Branch<float>("deltaTErr", &m_deltaTErr);
266 m_timewalkTree->Branch<float>("sigma", &m_sigma);
267 m_timewalkTree->Branch<float>("sigmaErr", &m_sigmaErr);
268 m_timewalkTree->Branch<float>("fraction", &m_fraction);
269 m_timewalkTree->Branch<float>("fractionErr", &m_fractionErr);
270 m_timewalkTree->Branch<float>("yieldLaser", &m_yieldLaser);
271 m_timewalkTree->Branch<float>("yieldLaserErr", &m_yieldLaserErr);
272 m_timewalkTree->Branch<float>("timeExtra", &m_timeExtra);
273 m_timewalkTree->Branch<float>("sigmaExtra", &m_sigmaExtra);
274 m_timewalkTree->Branch<float>("nExtra", &m_nExtra);
275 m_timewalkTree->Branch<float>("alphaExtra", &m_alphaExtra);
276 m_timewalkTree->Branch<float>("yieldLaserExtra", &m_yieldLaserExtra);
277 m_timewalkTree->Branch<float>("timeBackground", &m_timeBackground);
278 m_timewalkTree->Branch<float>("sigmaBackground", &m_sigmaBackground);
279 m_timewalkTree->Branch<float>("yieldLaserBackground", &m_yieldLaserBackground);
280 m_timewalkTree->Branch<float>("fractionMC", &m_fractionMC);
281 m_timewalkTree->Branch<float>("deltaTMC", &m_deltaTMC);
282 m_timewalkTree->Branch<float>("peakTimeMC", &m_peakTimeMC);
283 m_timewalkTree->Branch<float>("firstPulserTime", &m_firstPulserTime);
284 m_timewalkTree->Branch<float>("firstPulserSigma", &m_firstPulserSigma);
285 m_timewalkTree->Branch<float>("secondPulserTime", &m_secondPulserTime);
286 m_timewalkTree->Branch<float>("secondPulserSigma", &m_secondPulserSigma);
287 m_timewalkTree->Branch<short>("fitStatus", &m_fitStatus);
288 m_timewalkTree->Branch<double>("width", &m_width);
289 m_timewalkTree->Branch<double>("amplitude", &m_amplitude);
290 m_timewalkTree->Branch<float>("chi2", &m_chi2);
291 m_timewalkTree->Branch<float>("rms", &m_rms);
292 }
293
294 if (m_detectCrosstalk) {
295
296 // Create tree that stores candidate crosstalk events
297 m_crosstalkTree = new TTree("crosstalkTree", "Tree containing candidate crosstalks");
298 m_crosstalkTree->Branch<short>("sl0", &m_sl0);
299 m_crosstalkTree->Branch<short>("sl1", &m_sl1); // slot numbers (they will be the same, including them for checks)
300 m_crosstalkTree->Branch<short>("ch0", &m_ch0);
301 m_crosstalkTree->Branch<short>("ch1", &m_ch1); // channel numbers
302 m_crosstalkTree->Branch<float>("ht0", &m_ht0);
303 m_crosstalkTree->Branch<float>("ht1", &m_ht1); // hit times
304 m_crosstalkTree->Branch<float>("a0", &m_a0);
305 m_crosstalkTree->Branch<float>("a1", &m_a1); // amplitudes
306 m_crosstalkTree->Branch<float>("w0", &m_w0);
307 m_crosstalkTree->Branch<float>("w1", &m_w1); // widths
308 m_crosstalkTree->Branch<float>("q0", &m_q0);
309 m_crosstalkTree->Branch<float>("q1", &m_q1); // integrated charges
310 m_crosstalkTree->Branch<float>("f_q0", &m_f_q0); // fraction of charge on channel 0
311
312 // Create tree that stores fit results of hits without associated crosstalk
313 // Unlike the "vanilla" fitTree, this doesn't contain the results of the fits to the calibration pulses
314 m_fitTree_noXtalk = new TTree("fitTreeNoXTalk", "Fits to channels with no detected crosstalk");
315 m_fitTree_noXtalk->Branch<short>("channel", &m_channel);
316 m_fitTree_noXtalk->Branch<short>("slot", &m_slot);
317 m_fitTree_noXtalk->Branch<short>("row", &m_row);
318 m_fitTree_noXtalk->Branch<short>("col", &m_col);
319 m_fitTree_noXtalk->Branch<float>("peakTime", &m_peakTime);
320 m_fitTree_noXtalk->Branch<float>("peakTimeErr", &m_peakTimeErr);
321 m_fitTree_noXtalk->Branch<float>("deltaT", &m_deltaT);
322 m_fitTree_noXtalk->Branch<float>("deltaTErr", &m_deltaTErr);
323 m_fitTree_noXtalk->Branch<float>("sigma", &m_sigma);
324 m_fitTree_noXtalk->Branch<float>("sigmaErr", &m_sigmaErr);
325 m_fitTree_noXtalk->Branch<float>("fraction", &m_fraction);
326 m_fitTree_noXtalk->Branch<float>("fractionErr", &m_fractionErr);
327 m_fitTree_noXtalk->Branch<float>("yieldLaser", &m_yieldLaser);
328 m_fitTree_noXtalk->Branch<float>("yieldLaserErr", &m_yieldLaserErr);
329 m_fitTree_noXtalk->Branch<float>("timeExtra", &m_timeExtra);
330 m_fitTree_noXtalk->Branch<float>("sigmaExtra", &m_sigmaExtra);
331 m_fitTree_noXtalk->Branch<float>("nExtra", &m_nExtra);
332 m_fitTree_noXtalk->Branch<float>("alphaExtra", &m_alphaExtra);
333 m_fitTree_noXtalk->Branch<float>("yieldLaserExtra", &m_yieldLaserExtra);
334 m_fitTree_noXtalk->Branch<float>("timeBackground", &m_timeBackground);
335 m_fitTree_noXtalk->Branch<float>("sigmaBackground", &m_sigmaBackground);
336 m_fitTree_noXtalk->Branch<float>("yieldLaserBackground", &m_yieldLaserBackground);
337 m_fitTree_noXtalk->Branch<float>("fractionMC", &m_fractionMC);
338 m_fitTree_noXtalk->Branch<float>("deltaTMC", &m_deltaTMC);
339 m_fitTree_noXtalk->Branch<float>("peakTimeMC", &m_peakTimeMC);
340 m_fitTree_noXtalk->Branch<float>("firstPulserTime", &m_firstPulserTime);
341 m_fitTree_noXtalk->Branch<float>("firstPulserSigma", &m_firstPulserSigma);
342 m_fitTree_noXtalk->Branch<float>("secondPulserTime", &m_secondPulserTime);
343 m_fitTree_noXtalk->Branch<float>("secondPulserSigma", &m_secondPulserSigma);
344 m_fitTree_noXtalk->Branch<short>("fitStatus", &m_fitStatus);
345 m_fitTree_noXtalk->Branch<double>("width", &m_width);
346 m_fitTree_noXtalk->Branch<double>("amplitude", &m_amplitude);
347 m_fitTree_noXtalk->Branch<float>("chi2", &m_chi2);
348 m_fitTree_noXtalk->Branch<float>("rms", &m_rms);
349
350 }
351
352 return;
353}

◆ updateDBObjPtrs()

void updateDBObjPtrs ( const unsigned int event = 1,
const int run = 0,
const int experiment = 0 )
protectedinherited

Updates any DBObjPtrs by calling update(event) for DBStore.

Definition at line 404 of file CalibrationAlgorithm.cc.

405{
406 // Construct an EventMetaData object but NOT in the Datastore
407 EventMetaData emd(event, run, experiment);
408 // Explicitly update while avoiding registering a Datastore object
410 // Also update the intra-run objects to the event at the same time (maybe unnecessary...)
412}
static DBStore & Instance()
Instance of a singleton DBStore.
Definition DBStore.cc:26
void updateEvent()
Updates all intra-run dependent objects.
Definition DBStore.cc:140
void update()
Updates all objects that are outside their interval of validity.
Definition DBStore.cc:77

Member Data Documentation

◆ m_a0

float m_a0 = NAN
private

Amplitude for channel 0 in pair.

Definition at line 162 of file TOPLocalCalFitter.h.

◆ m_a1

float m_a1 = NAN
private

Amplitude for channel 1 in pair.

Definition at line 163 of file TOPLocalCalFitter.h.

◆ m_allExpRun

const ExpRun m_allExpRun = make_pair(-1, -1)
staticprivateinherited

allExpRun

Definition at line 364 of file CalibrationAlgorithm.h.

◆ m_alphaExtra

float m_alphaExtra = 0.
private

alpha parameter of the tail of the extra peak.

Definition at line 215 of file TOPLocalCalFitter.h.

◆ m_alphaExtraConstraints

float m_alphaExtraConstraints = 0.
private

alpha parameter of the tail of the extra peak.

Definition at line 185 of file TOPLocalCalFitter.h.

◆ m_amplitude

double m_amplitude = 0
private

Pulse height.

For each pixel, it is calculated as the mean over each hit.

Definition at line 248 of file TOPLocalCalFitter.h.

◆ m_binEdges

std::vector<float> m_binEdges = {50, 100, 150, 200, 250, 300, 350, 400, 500, 600, 800, 1000, 1500, 2000}
private

Amplitude bins.

Definition at line 138 of file TOPLocalCalFitter.h.

138{50, 100, 150, 200, 250, 300, 350, 400, 500, 600, 800, 1000, 1500, 2000};

◆ m_binLowerEdge

float m_binLowerEdge = 0
private

Lower edge of the amplitude bin in which this fit is performed.

Definition at line 192 of file TOPLocalCalFitter.h.

◆ m_binUpperEdge

float m_binUpperEdge = 0
private

Upper edge of the amplitude bin in which this fit is performed.

Definition at line 193 of file TOPLocalCalFitter.h.

◆ m_boundaries

std::vector<Calibration::ExpRun> m_boundaries
protectedinherited

When using the boundaries functionality from isBoundaryRequired, this is used to store the boundaries. It is cleared when.

Definition at line 261 of file CalibrationAlgorithm.h.

◆ m_ch0

short m_ch0 = -1
private

Channel number (0-511)

Definition at line 158 of file TOPLocalCalFitter.h.

◆ m_ch1

short m_ch1 = -1
private

Channel number (0-511)

Definition at line 159 of file TOPLocalCalFitter.h.

◆ m_channel

short m_channel = 0
private

Channel number (0-511)

Definition at line 194 of file TOPLocalCalFitter.h.

◆ m_channelT0

float m_channelT0
private
Initial value:
=
0.

Raw, channelT0 calibration, defined as peakTime-peakTimeMC.

This constant is not yet normalized to the average constant in the slot, since that part is currently done by the DB importer. When the DB import functionalities will be added to this module, it will be set to the proper channeT0

Definition at line 231 of file TOPLocalCalFitter.h.

◆ m_channelT0Err

float m_channelT0Err = 0.
private

Statistical error on channelT0.

Definition at line 236 of file TOPLocalCalFitter.h.

◆ m_chi2

float m_chi2 = 0
private

Reduced chi2 of the fit.

Definition at line 228 of file TOPLocalCalFitter.h.

◆ m_col

short m_col = 0
private

Pixel column.

Definition at line 197 of file TOPLocalCalFitter.h.

◆ m_colOf

std::array<std::array<short, 512>, 16> m_colOf {}
private

Column index for (slot,channel), or -1 if out of bounds.

Definition at line 252 of file TOPLocalCalFitter.h.

252{};

◆ m_crosstalkTree

TTree* m_crosstalkTree = nullptr
private

Output tree for crosstalk candidates.

Definition at line 152 of file TOPLocalCalFitter.h.

◆ m_data

ExecutionData m_data
privateinherited

Data specific to a SINGLE execution of the algorithm. Gets reset at the beginning of execution.

Definition at line 382 of file CalibrationAlgorithm.h.

◆ m_deltaT

float m_deltaT
private
Initial value:
=
0

Time difference between the main peak and the secondary peak.

Can be either fixed to the MC value or fitted.

Definition at line 199 of file TOPLocalCalFitter.h.

◆ m_deltaTConstraints

float m_deltaTConstraints = 0
private

Distance between the main and the secondary laser peak.

Definition at line 181 of file TOPLocalCalFitter.h.

◆ m_deltaTErr

float m_deltaTErr = 0
private

Statistical error on deltaT.

Definition at line 207 of file TOPLocalCalFitter.h.

◆ m_deltaTMC

float m_deltaTMC = 0.
private

Time difference between the main peak and the secondary peak in the MC simulation.

Definition at line 223 of file TOPLocalCalFitter.h.

◆ m_description

std::string m_description {""}
privateinherited

Description of the algorithm.

Definition at line 385 of file CalibrationAlgorithm.h.

385{""};

◆ m_detectCrosstalk

bool m_detectCrosstalk = false
private

Enables the crosstalk detection algorithm.

Definition at line 150 of file TOPLocalCalFitter.h.

◆ m_f1

float m_f1 = 0
private

Fraction of the first gaussian on the TTS parametrization.

Definition at line 174 of file TOPLocalCalFitter.h.

◆ m_f2

float m_f2 = 0
private

Fraction of the second gaussian on the TTS parametrization.

Definition at line 175 of file TOPLocalCalFitter.h.

◆ m_f_q0

float m_f_q0 = NAN
private

Fraction of charge on channel 0 in pair.

Definition at line 168 of file TOPLocalCalFitter.h.

◆ m_firstPulserSigma

float m_firstPulserSigma = 0.
private

Time resolution from the fit of the first electronic pulse, from a Gaussian fit.

Definition at line 239 of file TOPLocalCalFitter.h.

◆ m_firstPulserTime

float m_firstPulserTime = 0.
private

Average time of the first electronic pulse respect to the reference pulse, from a Gaussian fit.

Definition at line 238 of file TOPLocalCalFitter.h.

◆ m_fitConstraints

std::string m_fitConstraints
private
Initial value:
=
"/group/belle2/group/detector/TOP/calibration/MCreferences/LaserMCParameters.root"

File with the Fit constraints.

Definition at line 132 of file TOPLocalCalFitter.h.

◆ m_fitStatus

short m_fitStatus = 1
private

Fit quality flag, propagated to the constants.

1 if fit did not converge, 0 if it is fine.

Definition at line 245 of file TOPLocalCalFitter.h.

◆ m_fitterMode

std::string m_fitterMode = "calibration"
private

Fit mode.

Can be 'calibration', 'monitoring' or 'MC'

Definition at line 136 of file TOPLocalCalFitter.h.

◆ m_fitTree

TTree* m_fitTree = nullptr
private

Output of the fitter.

The tree containing the fit results.

Definition at line 145 of file TOPLocalCalFitter.h.

◆ m_fitTree_noXtalk

TTree* m_fitTree_noXtalk = nullptr
private

Output tree for non-crosstalk candidates.

Definition at line 153 of file TOPLocalCalFitter.h.

◆ m_fraction

float m_fraction = 0.
private

Fraction of events in the secondary peak.

Definition at line 202 of file TOPLocalCalFitter.h.

◆ m_fractionConstraints

float m_fractionConstraints = 0
private

Fraction of the main peak.

Definition at line 182 of file TOPLocalCalFitter.h.

◆ m_fractionErr

float m_fractionErr = 0.
private

Statistical error on fraction.

Definition at line 209 of file TOPLocalCalFitter.h.

◆ m_fractionMC

float m_fractionMC = 0.
private

Fraction of events in the secondary peak form the MC simulation.

Definition at line 222 of file TOPLocalCalFitter.h.

◆ m_granularityOfData

std::string m_granularityOfData
privateinherited

Granularity of input data. This only changes when the input files change so it isn't specific to an execution.

Definition at line 379 of file CalibrationAlgorithm.h.

◆ m_hasChannelMaps

bool m_hasChannelMaps {false}
private

Flag indicating if channel->(row,col) maps have been built.

True after m_rowOf/m_colOf have been built.

Definition at line 253 of file TOPLocalCalFitter.h.

253{false};

◆ m_histFile

TFile* m_histFile = nullptr
private

Output of the fitter.

The file containing the output trees and histograms

Definition at line 144 of file TOPLocalCalFitter.h.

◆ m_histoIntegral

float m_histoIntegral = 0.
private

Integral of the fitted histogram.

Definition at line 204 of file TOPLocalCalFitter.h.

◆ m_ht0

float m_ht0 = NAN
private

Hit time for channel 0 in pair.

Definition at line 160 of file TOPLocalCalFitter.h.

◆ m_ht1

float m_ht1 = NAN
private

Hit time for channel 1 in pair.

Definition at line 161 of file TOPLocalCalFitter.h.

◆ m_inputConstraints

TFile* m_inputConstraints = nullptr
private

File containing m_treeConstraints.

Definition at line 140 of file TOPLocalCalFitter.h.

◆ m_inputFileNames

std::vector<std::string> m_inputFileNames
privateinherited

List of input files to the Algorithm, will initially be user defined but then gets the wildcards expanded during execute()

Definition at line 373 of file CalibrationAlgorithm.h.

◆ m_inputTTS

TFile* m_inputTTS = nullptr
private

File containing m_treeTTS.

Definition at line 139 of file TOPLocalCalFitter.h.

◆ m_isFitInAmplitudeBins

bool m_isFitInAmplitudeBins = false
private

Enables the fit in amplitude bins.

Definition at line 137 of file TOPLocalCalFitter.h.

◆ m_jsonExecutionInput

nlohmann::json m_jsonExecutionInput = nlohmann::json::object()
privateinherited

Optional input JSON object used to make decisions about how to execute the algorithm code.

Definition at line 397 of file CalibrationAlgorithm.h.

◆ m_jsonExecutionOutput

nlohmann::json m_jsonExecutionOutput = nlohmann::json::object()
privateinherited

Optional output JSON object that can be set during the execution by the underlying algorithm code.

Definition at line 403 of file CalibrationAlgorithm.h.

◆ m_mean2

float m_mean2 = 0
private

Position of the second gaussian of the TTS parametrization with respect to the first one.

Definition at line 171 of file TOPLocalCalFitter.h.

◆ m_minEntries

int m_minEntries = 50
private

Minimum number of entries to perform the fit.

Currently not used

Definition at line 130 of file TOPLocalCalFitter.h.

◆ m_nExtra

float m_nExtra = 0.
private

parameter n of the tail of the extra peak

Definition at line 216 of file TOPLocalCalFitter.h.

◆ m_nExtraConstraints

float m_nExtraConstraints = 0.
private

parameter n of the tail of the extra peak

Definition at line 186 of file TOPLocalCalFitter.h.

◆ m_output

std::string m_output = "laserFitResult.root"
private

Name of the output file.

Definition at line 131 of file TOPLocalCalFitter.h.

◆ m_peakTime

float m_peakTime = 0
private

Fitted time of the main (i.e.

latest) peak

Definition at line 198 of file TOPLocalCalFitter.h.

◆ m_peakTimeConstraints

float m_peakTimeConstraints = 0
private

Time of the main laser peak in the MC simulation (aka MC correction)

Definition at line 180 of file TOPLocalCalFitter.h.

◆ m_peakTimeErr

float m_peakTimeErr = 0
private

Statistical error on peakTime.

Definition at line 206 of file TOPLocalCalFitter.h.

◆ m_peakTimeMC

float m_peakTimeMC
private
Initial value:
=
0.

Time of the main peak in the MC simulation, i.e.

time of propagation of the light in the prism. This factor is used to get the channelT0 calibration

Definition at line 224 of file TOPLocalCalFitter.h.

◆ m_pixelCol

short m_pixelCol = 0
private

Pixel column.

Definition at line 177 of file TOPLocalCalFitter.h.

◆ m_pixelRow

short m_pixelRow = 0
private

Pixel row.

Definition at line 176 of file TOPLocalCalFitter.h.

◆ m_prefix

std::string m_prefix {""}
privateinherited

The name of the TDirectory the collector objects are contained within.

Definition at line 388 of file CalibrationAlgorithm.h.

388{""};

◆ m_q0

float m_q0 = NAN
private

Integrated charge for channel 0 in pair.

Definition at line 166 of file TOPLocalCalFitter.h.

◆ m_q1

float m_q1 = NAN
private

Integrated charge for channel 1 in pair.

Definition at line 167 of file TOPLocalCalFitter.h.

◆ m_rms

float m_rms = 0
private

RMS of the histogram used for the fit.

Definition at line 229 of file TOPLocalCalFitter.h.

◆ m_row

short m_row = 0
private

Pixel row.

Definition at line 196 of file TOPLocalCalFitter.h.

◆ m_rowOf

std::array<std::array<short, 512>, 16> m_rowOf {}
private

Row index for (slot,channel), or -1 if out of bounds.

Definition at line 251 of file TOPLocalCalFitter.h.

251{};

◆ m_runsToInputFiles

std::map<Calibration::ExpRun, std::vector<std::string> > m_runsToInputFiles
privateinherited

Map of Runs to input files. Gets filled when you call getRunRangeFromAllData, gets cleared when setting input files again.

Definition at line 376 of file CalibrationAlgorithm.h.

◆ m_secondPulserSigma

float m_secondPulserSigma = 0.
private

Time resolution from the fit of the first electronic pulse, from a Gaussian fit.

Definition at line 243 of file TOPLocalCalFitter.h.

◆ m_secondPulserTime

float m_secondPulserTime
private
Initial value:
=
0.

Average time of the second electronic pulse respect to the reference pulse, from a gaussian fit.

Definition at line 241 of file TOPLocalCalFitter.h.

◆ m_sigma

float m_sigma = 0.
private

Gaussian time resolution, fitted.

Definition at line 201 of file TOPLocalCalFitter.h.

◆ m_sigma1

float m_sigma1 = 0
private

Width of the first gaussian on the TTS parametrization.

Definition at line 172 of file TOPLocalCalFitter.h.

◆ m_sigma2

float m_sigma2 = 0
private

Width of the second gaussian on the TTS parametrization.

Definition at line 173 of file TOPLocalCalFitter.h.

◆ m_sigmaBackground

float m_sigmaBackground = 0.
private

Sigma of the gaussian used to describe the background.

Definition at line 219 of file TOPLocalCalFitter.h.

◆ m_sigmaBackgroundConstraints

float m_sigmaBackgroundConstraints = 0.
private

Sigma of the gaussian used to describe the background.

Definition at line 188 of file TOPLocalCalFitter.h.

◆ m_sigmaErr

float m_sigmaErr = 0.
private

Statistical error on sigma.

Definition at line 208 of file TOPLocalCalFitter.h.

◆ m_sigmaExtra

float m_sigmaExtra = 0.
private

Gaussian sigma of the extra peak in the timing tail.

Definition at line 213 of file TOPLocalCalFitter.h.

◆ m_sigmaExtraConstraints

float m_sigmaExtraConstraints = 0
private

Width of the gaussian used to describe the extra peak on the timing distribution tail.

Definition at line 184 of file TOPLocalCalFitter.h.

◆ m_sl0

short m_sl0 = -1
private

Slot ID (1-16)

Definition at line 156 of file TOPLocalCalFitter.h.

◆ m_sl1

short m_sl1 = -1
private

Slot ID (1-16)

Definition at line 157 of file TOPLocalCalFitter.h.

◆ m_slot

short m_slot = 0
private

Slot ID (1-16)

Definition at line 195 of file TOPLocalCalFitter.h.

◆ m_timeBackground

float m_timeBackground = 0.
private

Position of the gaussian used to describe the background, w/ respect to peakTime.

Definition at line 218 of file TOPLocalCalFitter.h.

◆ m_timeBackgroundConstraints

float m_timeBackgroundConstraints = 0.
private

Position of the gaussian used to describe the background, w/ respect to peakTime.

Definition at line 187 of file TOPLocalCalFitter.h.

◆ m_timeExtra

float m_timeExtra = 0.
private

Position of the extra peak seen in the timing tail, w/ respect to peakTime.

Definition at line 212 of file TOPLocalCalFitter.h.

◆ m_timeExtraConstraints

float m_timeExtraConstraints = 0
private

Position of the gaussian used to describe the extra peak on the timing distribution tail.

Definition at line 183 of file TOPLocalCalFitter.h.

◆ m_timewalkTree

TTree* m_timewalkTree
private
Initial value:
=
nullptr

Output of the fitter.

The tree containing the fit results to be used to study timewalk and asymptotic time resolution.

Definition at line 146 of file TOPLocalCalFitter.h.

◆ m_treeConstraints

TTree* m_treeConstraints
private
Initial value:
=
nullptr

Input to the fitter.

A tree containing the laser MC corrections and all the parameters to be fixed in the fit

Definition at line 142 of file TOPLocalCalFitter.h.

◆ m_treeTTS

TTree* m_treeTTS = nullptr
private

Input to the fitter.

A tree containing the TTS parametrization for each channel

Definition at line 141 of file TOPLocalCalFitter.h.

◆ m_TTSData

std::string m_TTSData
private
Initial value:
=
"/group/belle2/group/detector/TOP/calibration/MCreferences/TTSParametrization.root"

File with the TTS parametrization.

Definition at line 134 of file TOPLocalCalFitter.h.

◆ m_w0

float m_w0 = NAN
private

Width for channel 0 in pair.

Definition at line 164 of file TOPLocalCalFitter.h.

◆ m_w1

float m_w1 = NAN
private

Width for channel 1 in pair.

Definition at line 165 of file TOPLocalCalFitter.h.

◆ m_width

double m_width = 0
private

Pulse width.

For each pixel, it is calculated as the mean over each hit.

Definition at line 247 of file TOPLocalCalFitter.h.

◆ m_yieldLaser

float m_yieldLaser = 0.
private

Total number of laser hits from the fitting function integral.

Definition at line 203 of file TOPLocalCalFitter.h.

◆ m_yieldLaserBackground

float m_yieldLaserBackground = 0.
private

Integral of the background gaussian.

Definition at line 220 of file TOPLocalCalFitter.h.

◆ m_yieldLaserErr

float m_yieldLaserErr = 0.
private

Statistical error on yield.

Definition at line 210 of file TOPLocalCalFitter.h.

◆ m_yieldLaserExtra

float m_yieldLaserExtra = 0.
private

Integral of the extra peak.

Definition at line 214 of file TOPLocalCalFitter.h.


The documentation for this class was generated from the following files: