Belle II Software development
CDCDedxValidationAlgorithm Class Reference

A validation algorithm for CDC dE/dx electron. More...

#include <CDCDedxValidationAlgorithm.h>

Inheritance diagram for CDCDedxValidationAlgorithm:
CalibrationAlgorithm

Public Types

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

Public Member Functions

 CDCDedxValidationAlgorithm ()
 Constructor: Sets the description, the properties and the parameters of the algorithm.
 
virtual ~CDCDedxValidationAlgorithm ()
 Destructor.
 
void printCanvasRun (std::map< int, TH1D * > &htemp, std::string namesfx)
 Draw dE/dx per run histogram canvas.
 
void printCanvas (std::vector< TH1D * > &htemp, std::string namesfx, std::string svar)
 Draw dE/dx histograms across bins.
 
void fitGaussianWRange (TH1D *&temphist, std::string &status)
 Perform Gaussian fit with range on a histogram.
 
void getExpRunInfo ()
 function to get extract calibration run/exp
 
void defineHisto (std::vector< TH1D * > &htemp, std::string var, std::string stype)
 Define dE/dx histograms for plotting.
 
void wireGain (std::vector< TH1D * > &hdedxhit)
 Validate wire gain data using dE/dx histograms.
 
void printCanvasWire (std::vector< TH1D * > temp, std::string namesfx, const std::vector< double > &vdedx_mean)
 Plot dE/dx vs wire number.
 
void fit (TH1D *&hist, double &mean, double &meanErr, double &sigma, double &sigmaErr)
 Perform full Gaussian fit and extract parameters.
 
void bhabhaValidation ()
 Validate dE/dx using bhabha sample (vs run, cosine)
 
void radeeValidation ()
 Validate dE/dx using radee sample (vs momentum, injection time)
 
void defineTimeBins (std::vector< double > &vtlocaledges)
 Set bin edges for injection time.
 
void printCanvasdEdx (std::array< std::vector< TH1D * >, 2 > &htemp, std::string namesfx, std::string svar)
 Draw dE/dx histograms for momentum and cosine bins.
 
std::string getTimeBinLabel (const double &tedges, const int &it)
 Get time bin label string.
 
void setTestingPayload (const std::string &testingPayloadName)
 Set testing payload name.
 
void setGlobalTag (const std::string &globalTagName)
 Set Global Tag name.
 
void setTextCosmetics (TPaveText pt, Color_t color)
 Set text cosmetics for TPaveText.
 
void plotEventStats ()
 Plot summary statistics of selected events.
 
void DatabaseIN (int experiment, int run)
 Load database payload for given run.
 
WireGainData getwiregain (int experiment, int run)
 Retrieve wire gain data from DB.
 
CosGainData getcosgain (int experiment, int run)
 Retrieve cosine gain data from DB.
 
OnedData getonedgain (int experiment, int run)
 Retrieve 1D gain data from DB.
 
double getrungain (int experiment, int run)
 Retrieve run gain data from DB.
 
void resetDatabase ()
 Clear current DB pointers and state.
 
const std::string & getPrefix () const
 Get the prefix used for getting calibration data.
 
const 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.
 
const 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 () const
 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>.
 

Static Public Member Functions

static bool checkPyExpRun (PyObject *pyObj)
 Checks that a PyObject can be successfully converted to an ExpRun type.
 
static Calibration::ExpRun convertPyExpRun (PyObject *pyObj)
 Performs the conversion of PyObject to ExpRun.
 

Protected Member Functions

virtual EResult calibrate () override
 Main calibration method.
 
void setInputFileNames (const 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.
 
const 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 setDescription (const std::string &description)
 Set algorithm description (in constructor)
 
void clearCalibrationData ()
 Clear calibration data.
 
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.
 

Static Protected Member Functions

static void updateDBObjPtrs (const unsigned int event, const int run, const int experiment)
 Updates any DBObjPtrs by calling update(event) for DBStore.
 
static Calibration::ExpRun getAllGranularityExpRun ()
 Returns the Exp,Run pair that means 'Everything'. Currently unused.
 

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

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

double m_sigmaR
 fit dedx dist in sigma range
 
int m_dedxBins
 bins for dedx histogram
 
double m_dedxMin
 min range of dedx
 
double m_dedxMax
 max range of dedx
 
int m_cosBins
 bins for cosine
 
double m_cosMin
 min range of cosine
 
double m_cosMax
 max range of cosine
 
int m_momBins
 bins for momentum
 
double m_momMin
 min range of momentum
 
double m_momMax
 max range of momentum
 
double * m_tedges
 internal time array (copy of vtlocaledges)
 
unsigned int m_tbins
 internal time bins
 
int m_eaBin
 
double m_eaMin
 lower edge of entrance angle
 
double m_eaMax
 upper edge of entrance angle
 
std::array< std::string, 2 > m_sring {"ler", "her"}
 injection ring name
 
std::string m_suffix
 suffix string to separate plots
 
DBObjPtr< CDCGeometrym_cdcGeo
 Geometry of CDC.
 
std::string m_testingPayloadName = ""
 Testing payload location.
 
std::string m_GlobalTagName = ""
 Global Tag name.
 
DBObjPtr< CDCDedxInjectionTimem_DBInjectTime
 Injection time DB object.
 
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

A validation algorithm for CDC dE/dx electron.

Definition at line 83 of file CDCDedxValidationAlgorithm.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

◆ CDCDedxValidationAlgorithm()

Constructor: Sets the description, the properties and the parameters of the algorithm.

Definition at line 37 of file CDCDedxValidationAlgorithm.cc.

37 :
38 CalibrationAlgorithm("ElectronValCollector"),
39 m_sigmaR(2.0),
40 m_dedxBins(600),
41 m_dedxMin(0.0),
42 m_dedxMax(5.0),
43 m_cosBins(100),
44 m_cosMin(-1.0),
45 m_cosMax(1.0),
46 m_momBins(80),
47 m_momMin(0.0),
48 m_momMax(8.0),
49 m_eaBin(316),
50 m_eaMin(-TMath::Pi() / 2),
51 m_eaMax(+TMath::Pi() / 2),
52 m_suffix("")
53{
54 // Set module properties
55 setDescription("A validation algorithm for CDC dE/dx electron");
56}
double m_eaMax
upper edge of entrance angle
double m_sigmaR
fit dedx dist in sigma range
std::string m_suffix
suffix string to separate plots
double m_eaMin
lower edge of entrance angle
void setDescription(const std::string &description)
Set algorithm description (in constructor)
CalibrationAlgorithm(const std::string &collectorModuleName)
Constructor - sets the prefix for collected objects (won't be accesses until execute(....

◆ ~CDCDedxValidationAlgorithm()

virtual ~CDCDedxValidationAlgorithm ( )
inlinevirtual

Destructor.

Definition at line 95 of file CDCDedxValidationAlgorithm.h.

95{}

Member Function Documentation

◆ bhabhaValidation()

void bhabhaValidation ( )

Validate dE/dx using bhabha sample (vs run, cosine)

Definition at line 268 of file CDCDedxValidationAlgorithm.cc.

269{
270 auto ttree = getObjectPtr<TTree>("tBhabha");
271
272 double dedx, costh;
273 int run, charge;
274
275 std::vector<int>* wire = 0;
276 ttree->SetBranchAddress("wire", &wire);
277
278 std::vector<double>* dedxhit = 0;
279 ttree->SetBranchAddress("dedxhit", &dedxhit);
280
281 ttree->SetBranchAddress("dedx", &dedx);
282 ttree->SetBranchAddress("run", &run);
283 ttree->SetBranchAddress("charge", &charge);
284 ttree->SetBranchAddress("costh", &costh);
285
286 std::map<int, TH1D*> hdedx_run;
287 std::array<std::vector<TH1D*>, 3> hdedx_cos;
288 std::array<std::vector<TH1D*>, 2> hdedx_cos_peaks;
289 std::vector<TH1D*> hdedxhit(c_nSenseWires);
290
291 const double cosBinWidth = (m_cosMax - m_cosMin) / m_cosBins;
292 const double cosBinW = (m_cosMax - m_cosMin) / 4;
293
294 std::string stype[3] = {"all", "posi", "elec"};
295
296 for (int it = 0; it < 3; ++it) {
297 hdedx_cos[it].resize(m_cosBins);
298 defineHisto(hdedx_cos[it], "costh", stype[it]);
299 }
300
301 for (int ir = 0; ir < 2; ir++) {
302 hdedx_cos_peaks[ir].resize(4);
303 defineHisto(hdedx_cos_peaks[ir], "cos_peaks", Form("%s", stype[ir + 1].data()));
304 }
305
306 defineHisto(hdedxhit, "wire", "wire");
307
308 // Loop over all the entries in the tree
309 for (int i = 0; i < ttree->GetEntries(); ++i) {
310 ttree->GetEvent(i);
311 if (dedx <= 0) continue;
312
313 // Check if a dE/dx histogram for this run number already exists
314 if (hdedx_run.find(run) == hdedx_run.end()) {
315 std::string histName = Form("hist_dedx_run_%d", run);
316 std::string histTitle = Form("dE/dx Histogram for Run %d", run);
317 hdedx_run[run] = new TH1D(histName.data(), histTitle.data(), m_dedxBins, m_dedxMin, m_dedxMax);
318 }
319
320 // Fill run-specific histogram
321 hdedx_run[run]->Fill(dedx);
322
323 // Fill cos(theta) histograms (all charge + by charge sign)
324 int binIndex = static_cast<int>((costh - m_cosMin) / cosBinWidth);
325 if (binIndex >= 0 && binIndex < m_cosBins) {
326 hdedx_cos[0][binIndex]->Fill(dedx); // All charge
327
328 if (charge > 0)
329 hdedx_cos[1][binIndex]->Fill(dedx);
330 else if (charge < 0)
331 hdedx_cos[2][binIndex]->Fill(dedx);
332 }
333
334 // Fill dE/dx for each wire hit
335 for (unsigned int j = 0; j < wire->size(); ++j) {
336 int jwire = wire->at(j);
337 double jhitdedx = dedxhit->at(j);
338 hdedxhit[jwire]->Fill(jhitdedx);
339 }
340
341 // Fill cos(theta) peaks histograms
342 int binI = static_cast<int>((costh - m_cosMin) / cosBinW);
343 if (binI >= 0 && binI < 4) {
344 if (charge > 0)
345 hdedx_cos_peaks[0][binI]->Fill(dedx);
346 else if (charge < 0)
347 hdedx_cos_peaks[1][binI]->Fill(dedx);
348 }
349 }
350
351 printCanvasRun(hdedx_run, Form("plots/run/dedx_vs_run_%s", m_suffix.data()));
352 printCanvas(hdedx_cos[0], Form("plots/costh/dedx_vs_cos_all_%s", m_suffix.data()), "costh");
353 printCanvas(hdedx_cos[1], Form("plots/costh/dedx_vs_cos_positrons_%s", m_suffix.data()), "costh");
354 printCanvas(hdedx_cos[2], Form("plots/costh/dedx_vs_cos_electrons_%s", m_suffix.data()), "costh");
355 printCanvasdEdx(hdedx_cos_peaks, Form("plots/costh/dedxpeaks_vs_cos_%s", m_suffix.data()), "costh");
356 wireGain(hdedxhit);
357}
void wireGain(std::vector< TH1D * > &hdedxhit)
Validate wire gain data using dE/dx histograms.
void printCanvasdEdx(std::array< std::vector< TH1D * >, 2 > &htemp, std::string namesfx, std::string svar)
Draw dE/dx histograms for momentum and cosine bins.
void printCanvasRun(std::map< int, TH1D * > &htemp, std::string namesfx)
Draw dE/dx per run histogram canvas.
void printCanvas(std::vector< TH1D * > &htemp, std::string namesfx, std::string svar)
Draw dE/dx histograms across bins.
void defineHisto(std::vector< TH1D * > &htemp, std::string var, std::string stype)
Define dE/dx histograms for plotting.
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 t...

◆ 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, SVDClusterAbsoluteTimeShifterAlgorithm, 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{};

◆ calibrate()

CalibrationAlgorithm::EResult calibrate ( )
overrideprotectedvirtual

Main calibration method.

Implements CalibrationAlgorithm.

Definition at line 62 of file CDCDedxValidationAlgorithm.cc.

63{
64
66
67 std::vector<std::string> subdirs = {"run", "costh", "mom", "wire", "injection", "oneD"};
68 for (const auto& dir : subdirs) {
69 gSystem->Exec(Form("mkdir -p plots/%s", dir.c_str()));
70 }
71
72 // Get data objects
73 auto tBhabha = getObjectPtr<TTree>("tBhabha");
74
75 // require at least 100 tracks
76 if (tBhabha->GetEntries() < 100) return c_NotEnoughData;
77
78 // Get data objects
79 auto tRadee = getObjectPtr<TTree>("tRadee");
80
81 // require at least 100 tracks
82 if (tRadee->GetEntries() < 100) return c_NotEnoughData;
83
87
88 m_suffix.clear();
89
90 return c_OK;
91}
void bhabhaValidation()
Validate dE/dx using bhabha sample (vs run, cosine)
void radeeValidation()
Validate dE/dx using radee sample (vs momentum, injection time)
void getExpRunInfo()
function to get extract calibration run/exp
void plotEventStats()
Plot summary statistics of selected events.
@ c_OK
Finished successfully =0 in Python.
@ c_NotEnoughData
Needs more data =2 in Python.

◆ checkPyExpRun()

bool checkPyExpRun ( PyObject * pyObj)
staticinherited

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();}

◆ 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:42
bool storeData(const std::string &name, TObject *object, const IntervalOfValidity &iov)
Store an object in the database.
Definition Database.cc:141

◆ commit() [2/2]

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

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

Definition at line 312 of file CalibrationAlgorithm.cc.

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

◆ convertPyExpRun()

ExpRun convertPyExpRun ( PyObject * pyObj)
staticinherited

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}

◆ DatabaseIN()

void DatabaseIN ( int experiment,
int run )

Load database payload for given run.

Parameters
experimentExperiment number
runRun number

Definition at line 851 of file CDCDedxValidationAlgorithm.cc.

852{
853 auto& dbConfiguration = Conditions::Configuration::getInstance();
854
855 dbConfiguration.overrideGlobalTags();
856 dbConfiguration.setGlobalTags({"online"});
857
858 if (!m_testingPayloadName.empty() && m_GlobalTagName.empty()) {
859 dbConfiguration.prependTestingPayloadLocation(m_testingPayloadName);
860 } else if (m_testingPayloadName.empty() && !m_GlobalTagName.empty()) {
861 dbConfiguration.prependGlobalTag(m_GlobalTagName);
862 } else
863 B2FATAL("Setting both testing payload and Global Tag or setting no one of them.");
864
865 StoreObjPtr<EventMetaData> EventMetaData;
866
867 /* Mimic a module initialization. */
869 EventMetaData.registerInDataStore();
871
872 if (!EventMetaData.isValid())
873 EventMetaData.construct(1, run, experiment);
874
875 else {
876 EventMetaData->setEvent(1);
877 EventMetaData->setExperiment(experiment);
878 EventMetaData->setRun(run);
879 }
880
881 /* Database instance and configuration. */
882 DBStore& dbStore = DBStore::Instance();
883 dbStore.update();
884 dbStore.updateEvent();
885}
std::string m_testingPayloadName
Testing payload location.
static Configuration & getInstance()
Get a reference to the instance which will be used when the Database is initialized.
static DataStore & Instance()
Instance of singleton Store.
Definition DataStore.cc:53
void setInitializeActive(bool active)
Setter for m_initializeActive.
Definition DataStore.cc:93
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

◆ defineHisto()

void defineHisto ( std::vector< TH1D * > & htemp,
std::string var,
std::string stype )

Define dE/dx histograms for plotting.

Parameters
htempVector to hold histograms
varVariable name
stypecharge type

Definition at line 360 of file CDCDedxValidationAlgorithm.cc.

361{
362 int xbins = 0;
363 double xmin = 0.0, xmax = 0.0;
364 double binWidth = 0.0;
365 int dedxbins = m_dedxBins;
366
367 if (var == "mom") {
368 xbins = m_momBins; xmin = m_momMin; xmax = m_momMax;
369 } else if (var == "oned") {
370 xbins = m_eaBin; xmin = m_eaMin; xmax = m_eaMax; dedxbins = 250;
371 } else if (var == "costh") {
372 xbins = m_cosBins; xmin = m_cosMin; xmax = m_cosMax;
373 } else if (var == "inj") {
374 xbins = m_tbins;
375 } else if (var == "mom_peaks") {
376 xbins = 4; xmin = m_momMin; xmax = 4.0;
377 } else if (var == "cos_peaks") {
378 xbins = 4; xmin = m_cosMin; xmax = m_cosMax;
379 } else {
380 xbins = c_nSenseWires; dedxbins = 250;
381 }
382
383 if (var == "costh" || var == "mom" || var == "mom_peaks" || var == "cos_peaks" || var == "oned") {
384 binWidth = (xmax - xmin) / xbins;
385 }
386
387 for (int ic = 0; ic < xbins; ic++) {
388 std::string title = Form("dedxhit-dist, wire:%d", ic);
389 std::string name = Form("hdedx_%s_%s_%d", m_suffix.data(), var.data(), ic);
390
391 if (var == "costh" || var == "mom" || var == "mom_peaks" || var == "cos_peaks" || var == "oned") {
392 double min = ic * binWidth + xmin;
393 double max = min + binWidth;
394 title = Form("%s: (%0.02f, %0.02f) %s", var.data(), min, max, stype.data());
395 name = Form("hdedx_%s_%s_%s_%d", m_suffix.data(), var.data(), stype.data(), ic);
396 } else if (var == "inj") {
397 std::string label = getTimeBinLabel(m_tedges[ic], ic);
398 title = Form("%s, time(%s)", stype.data(), label.data());
399 name = Form("h%s_%s_%s_t%d", var.data(), m_suffix.data(), stype.data(), ic);
400 }
401 htemp[ic] = new TH1D(name.data(), "", dedxbins, m_dedxMin, m_dedxMax);
402 htemp[ic]->SetTitle(Form("%s;dedx;entries", title.data()));
403 }
404}
double * m_tedges
internal time array (copy of vtlocaledges)
std::string getTimeBinLabel(const double &tedges, const int &it)
Get time bin label string.

◆ defineTimeBins()

void defineTimeBins ( std::vector< double > & vtlocaledges)

Set bin edges for injection time.

Parameters
vtlocaledgesVector of time bin edges

Definition at line 810 of file CDCDedxValidationAlgorithm.cc.

811{
812 double fixedges[69];
813 for (int ib = 0; ib < 69; ib++) {
814 fixedges[ib] = ib * 0.5 * 1e3;
815 if (ib > 40 && ib <= 60) fixedges[ib] = fixedges[ib - 1] + 1.0 * 1e3;
816 else if (ib > 60 && ib <= 64) fixedges[ib] = fixedges[ib - 1] + 10.0 * 1e3;
817 else if (ib > 64 && ib <= 65) fixedges[ib] = fixedges[ib - 1] + 420.0 * 1e3;
818 else if (ib > 65 && ib <= 66) fixedges[ib] = fixedges[ib - 1] + 500.0 * 1e3;
819 else if (ib > 66) fixedges[ib] = fixedges[ib - 1] + 2e6;
820 vtlocaledges.push_back(fixedges[ib]);
821 }
822}

◆ 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}
static 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.
static 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.
const std::string & getGranularity() const
Get the granularity of collected data.
virtual EResult calibrate()=0
Run algo on data - pure virtual: needs to be implemented.

◆ fillRunToInputFilesMap()

void fillRunToInputFilesMap ( )
inherited

Fill the mapping of ExpRun -> Files.

Definition at line 331 of file CalibrationAlgorithm.cc.

332{
333 m_runsToInputFiles.clear();
334 // Save TDirectory to change back at the end
335 TDirectory* dir = gDirectory;
336 RunRange* runRange;
337 // Construct the TDirectory name where we expect our objects to be
338 string runRangeObjName(getPrefix() + "/" + RUN_RANGE_OBJ_NAME);
339 for (const auto& fileName : m_inputFileNames) {
340 //Open TFile to get the objects
341 unique_ptr<TFile> f;
342 f.reset(TFile::Open(fileName.c_str(), "READ"));
343 runRange = dynamic_cast<RunRange*>(f->Get(runRangeObjName.c_str()));
344 if (runRange) {
345 // Insert or extend the run -> file mapping for this ExpRun
346 auto expRuns = runRange->getExpRunSet();
347 for (const auto& expRun : expRuns) {
348 auto runFiles = m_runsToInputFiles.find(expRun);
349 if (runFiles != m_runsToInputFiles.end()) {
350 (runFiles->second).push_back(fileName);
351 } else {
352 m_runsToInputFiles.insert(std::make_pair(expRun, std::vector<std::string> {fileName}));
353 }
354 }
355 } else {
356 B2WARNING("Missing a RunRange object for file: " << fileName);
357 }
358 }
359 dir->cd();
360}
const 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 521 of file CalibrationAlgorithm.cc.

522{
523 m_boundaries.clear();
524 if (m_inputFileNames.empty()) {
525 B2ERROR("There aren't any input files set. Please use CalibrationAlgorithm::setInputFiles()");
526 return m_boundaries;
527 }
528 // Reset the internal execution data just in case something is hanging around
529 m_data.reset();
530 if (runs.empty()) {
531 // Want to loop over all runs we could possibly know about
532 runs = getRunListFromAllData();
533 }
534 // Let's check that we have some now
535 if (runs.empty()) {
536 B2ERROR("No collected data in input files.");
537 return m_boundaries;
538 }
539 // In order to find run boundaries we must have collected with data granularity == 'run'
540 if (strcmp(getGranularity().c_str(), "all") == 0) {
541 B2ERROR("The data is collected with granularity='all' (exp=-1,run=-1), and we can't use that to find run boundaries.");
542 return m_boundaries;
543 }
544 m_data.setIteration(iteration);
545 // User defined setup function
546 boundaryFindingSetup(runs, iteration);
547 std::vector<ExpRun> runList;
548 // Loop over run list and call derived class "isBoundaryRequired" member function
549 for (auto currentRun : runs) {
550 runList.push_back(currentRun);
551 m_data.setRequestedRuns(runList);
552 // After here, the getObject<...>(...) helpers start to work
553 if (isBoundaryRequired(currentRun)) {
554 m_boundaries.push_back(currentRun);
555 }
556 // Only want run-by-run
557 runList.clear();
558 // Don't want memory hanging around
559 m_data.clearCalibrationData();
560 }
561 m_data.reset();
563 return m_boundaries;
564}
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...

◆ fit()

void fit ( TH1D *& hist,
double & mean,
double & meanErr,
double & sigma,
double & sigmaErr )

Perform full Gaussian fit and extract parameters.

Parameters
histHistogram to fit
meanFitted mean
meanErrError on the mean
sigmaFitted sigma
sigmaErrError on the sigma

Definition at line 583 of file CDCDedxValidationAlgorithm.cc.

584{
585
586 std::string status = "";
587
588 if (hist->Integral() > 100)
589 fitGaussianWRange(hist, status);
590
591 if (status != "fitOK") {
592 hist->SetFillColor(kOrange);
593 mean = 0.0, meanErr = 0.0, sigma = 0.0, sigmaErr = 0.0;
594 } else {
595 mean = hist->GetFunction("gaus")->GetParameter(1);
596 meanErr = hist->GetFunction("gaus")->GetParError(1);
597 sigma = hist->GetFunction("gaus")->GetParameter(2);
598 sigmaErr = hist->GetFunction("gaus")->GetParError(2);
599 hist->SetFillColor(kYellow);
600 }
601}
void fitGaussianWRange(TH1D *&temphist, std::string &status)
Perform Gaussian fit with range on a histogram.

◆ fitGaussianWRange()

void fitGaussianWRange ( TH1D *& temphist,
std::string & status )

Perform Gaussian fit with range on a histogram.

Parameters
temphistHistogram to fit
statusStatus string updated based on fit result

Definition at line 661 of file CDCDedxValidationAlgorithm.cc.

662{
663 double histmean = temphist->GetMean();
664 double histrms = temphist->GetRMS();
665 temphist->GetXaxis()->SetRangeUser(histmean - 5.0 * histrms, histmean + 5.0 * histrms);
666
667 int fs = temphist->Fit("gaus", "Q0");
668 if (fs != 0) {
669 B2INFO(Form("\tFit (round 1) for hist (%s) failed (status = %d)", temphist->GetName(), fs));
670 status = "fitFailed";
671 return;
672 } else {
673 double mean = temphist->GetFunction("gaus")->GetParameter(1);
674 double width = temphist->GetFunction("gaus")->GetParameter(2);
675 temphist->GetXaxis()->SetRangeUser(mean - 5.0 * width, mean + 5.0 * width);
676 fs = temphist->Fit("gaus", "QR", "", mean - m_sigmaR * width, mean + m_sigmaR * width);
677 if (fs != 0) {
678 B2INFO(Form("\tFit (round 2) for hist (%s) failed (status = %d)", temphist->GetName(), fs));
679 status = "fitFailed";
680 return;
681 } else {
682 temphist->GetXaxis()->SetRangeUser(mean - 5.0 * width, mean + 5.0 * width);
683 B2INFO(Form("\tFit for hist (%s) successful (status = %d)", temphist->GetName(), fs));
684 status = "fitOK";
685 }
686 }
687}

◆ getAllGranularityExpRun()

static Calibration::ExpRun getAllGranularityExpRun ( )
inlinestaticprotectedinherited

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

Definition at line 327 of file CalibrationAlgorithm.h.

327{return m_allExpRun;}

◆ getCollectorName()

const 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();}

◆ getcosgain()

CosGainData getcosgain ( int experiment,
int run )

Retrieve cosine gain data from DB.

Parameters
experimentExperiment number
runRun number
Returns
CosGainData structure

Definition at line 925 of file CDCDedxValidationAlgorithm.cc.

926{
927
928 DatabaseIN(experiment, run);
929
930 std::array<std::vector<double>, 3> cosgain;
931 std::vector<double> cos;
932
933 DBObjPtr<CDCDedxCosineCor> DBCosineCor;
934 if (!DBCosineCor.isValid()) {
935 B2FATAL("Cosine gain data are not valid.");
936 }
937
938 // representative layer index for each group
939 const std::array<unsigned int, 3> layerIndex = {1, 9, 17};
940
941 for (int igroup = 0; igroup < 3; ++igroup) {
942 unsigned int nCosBins = DBCosineCor->getSize(layerIndex[igroup]);
943
944 for (unsigned int ibin = 0; ibin < nCosBins; ++ibin) {
945
946 double costh = -1.0 + (ibin + 0.5) * 2.0 / nCosBins;
947 costh += 1e-6;
948
949 if (igroup == 0) {
950 cos.push_back(costh);
951 }
952
953 cosgain[igroup].push_back(DBCosineCor->getMean(layerIndex[igroup], ibin));
954 }
955 }
956
958 return {cosgain, cos};
959}
void resetDatabase()
Clear current DB pointers and state.
void DatabaseIN(int experiment, int run)
Load database payload for given run.
bool isValid() const
Check whether a valid object was obtained from the database.

◆ 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;}

◆ getExpRunInfo()

void getExpRunInfo ( )

function to get extract calibration run/exp

Definition at line 94 of file CDCDedxValidationAlgorithm.cc.

95{
96
97 int cruns = 0;
98 for (auto expRun : getRunList()) {
99 if (cruns == 0) B2INFO("start exp " << expRun.first << " and run " << expRun.second << "");
100 cruns++;
101 }
102
103 const auto erStart = getRunList()[0];
104 int estart = erStart.first;
105 int rstart = erStart.second;
106
107 updateDBObjPtrs(1, rstart, estart);
108
109 if (m_suffix.length() > 0) m_suffix = Form("%s_e%d_r%d", m_suffix.data(), estart, rstart);
110 else m_suffix = Form("e%d_r%d", estart, rstart);
111}
static void updateDBObjPtrs(const unsigned int event, const int run, const int experiment)
Updates any DBObjPtrs by calling update(event) for DBStore.
const std::vector< Calibration::ExpRun > & getRunList() const
Get the list of runs for which calibration is called.

◆ 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()

const 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 384 of file CalibrationAlgorithm.cc.

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

327{
329}
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 }

◆ getonedgain()

OnedData getonedgain ( int experiment,
int run )

Retrieve 1D gain data from DB.

Parameters
experimentExperiment number
runRun number
Returns
OnedData structure

Definition at line 961 of file CDCDedxValidationAlgorithm.cc.

962{
963
964 DatabaseIN(experiment, run);
965
966 std::array<std::vector<double>, 3> oneDcorr;
967 std::vector<double> enta;
968
969 DBObjPtr<CDCDedx1DCell> DBOneDCell;
970 if (!DBOneDCell.isValid()) {
971 B2FATAL("OneD cell gain data are not valid.");
972 }
973
974 // representative layer index for each group
975 const std::array<unsigned int, 3> layerIndex = {1, 9, 17};
976
977 for (int igroup = 0; igroup < 3; igroup++) {
978
979 unsigned int nBins = DBOneDCell->getNBins(layerIndex[igroup]);
980 double binSize = TMath::Pi() / nBins;
981
982 for (unsigned int nbin = 0; nbin < nBins; nbin++) {
983
984 double eta = (-1.0 * TMath::Pi() / 2.0) + binSize * nbin;
985
986 if (igroup == 0) {
987 enta.push_back(eta);
988 }
989
990 oneDcorr[igroup].push_back(DBOneDCell->getMean(layerIndex[igroup], nbin));
991 }
992 }
993
995 return {oneDcorr, enta};
996
997}

◆ 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 ( ) const
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()

const 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;}

◆ getrungain()

double getrungain ( int experiment,
int run )

Retrieve run gain data from DB.

Parameters
experimentExperiment number
runRun number
Returns
double

Definition at line 998 of file CDCDedxValidationAlgorithm.cc.

999{
1000
1001 DatabaseIN(experiment, run);
1002
1003 DBObjPtr<CDCDedxRunGain> RunGain;
1004 if (!RunGain.isValid()) B2FATAL("Run gain data are not valid.");
1005 double gain = RunGain->getRunGain();
1006 return gain;
1007}

◆ 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 319 of file CalibrationAlgorithm.cc.

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

◆ getRunRangeFromAllData()

RunRange getRunRangeFromAllData ( ) const
inherited

Get the complete RunRange from inspection of collected data.

Definition at line 362 of file CalibrationAlgorithm.cc.

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

◆ getTimeBinLabel()

std::string getTimeBinLabel ( const double & tedges,
const int & it )
inline

Get time bin label string.

Parameters
tedgesTime edge
itIndex of the bin
Returns
Formatted time bin label string

Definition at line 186 of file CDCDedxValidationAlgorithm.h.

187 {
188 std::string label = "";
189 if (tedges < 2e4)label = Form("%0.01f-%0.01fK", m_tedges[it] / 1e3, m_tedges[it + 1] / 1e3);
190 else if (tedges < 1e5)label = Form("%0.0f-%0.0fK", m_tedges[it] / 1e3, m_tedges[it + 1] / 1e3);
191 else label = Form("%0.01f-%0.01fM", m_tedges[it] / 1e6, m_tedges[it + 1] / 1e6);
192 return label;
193 }

◆ getVecInputFileNames()

const 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;}

◆ getwiregain()

WireGainData getwiregain ( int experiment,
int run )

Retrieve wire gain data from DB.

Parameters
experimentExperiment number
runRun number
Returns
WireGainData structure

Definition at line 887 of file CDCDedxValidationAlgorithm.cc.

888{
889
890 DatabaseIN(experiment, run);
891
892 std::vector<double> wiregain;
893 std::vector<double> layermean(c_maxNSenseLayers);
894
895 DBObjPtr<CDCDedxWireGain> DBWireGains;
896 if (!DBWireGains.isValid()) B2FATAL("Wire gain data are not valid.");
897
898 CDCGeometryPar& cdcgeo = CDCGeometryPar::Instance(&(*m_cdcGeo));
899
900 int jwire = -1;
901 for (unsigned int il = 0; il < c_maxNSenseLayers; ++il) {
902
903 int activewires = 0;
904 layermean[il] = 0.0;
905
906 for (unsigned int iw = 0; iw < cdcgeo.nWiresInLayer(il); ++iw) {
907 jwire++;
908
909 wiregain.push_back(DBWireGains->getWireGain(jwire));
910
911 if (wiregain.at(jwire) > 0) {
912 layermean[il] += wiregain.at(jwire);
913 activewires++;
914 }
915 }
916
917 if (activewires > 0) layermean[il] /= activewires;
918 else layermean[il] = 1.0;
919 }
920
922 return { wiregain, layermean };
923}
DBObjPtr< CDCGeometry > m_cdcGeo
Geometry of CDC.
unsigned nWiresInLayer(int layerId) const
Returns wire numbers in a layer.
static CDCGeometryPar & Instance(const CDCGeometry *=nullptr)
Static method to get a reference to the CDCGeometryPar instance.

◆ 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, SVDClusterAbsoluteTimeShifterAlgorithm, 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 503 of file CalibrationAlgorithm.cc.

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

◆ plotEventStats()

void plotEventStats ( )

Plot summary statistics of selected events.

Definition at line 825 of file CDCDedxValidationAlgorithm.cc.

826{
827
828 TCanvas cstats("cstats", "cstats", 800, 400);
829 cstats.SetBatch(kTRUE);
830 cstats.Divide(2, 1);
831
832 cstats.cd(1);
833 auto hestats = getObjectPtr<TH1I>("hestats");
834 if (hestats) {
835 hestats->SetName(Form("hestats_%s", m_suffix.data()));
836 hestats->SetStats(0);
837 hestats->DrawCopy("");
838 }
839
840 cstats.cd(2);
841 auto htstats = getObjectPtr<TH1I>("htstats");
842 if (htstats) {
843 htstats->SetName(Form("htstats_%s", m_suffix.data()));
844 htstats->SetStats(0);
845 htstats->DrawCopy("");
846 }
847
848 cstats.Print(Form("cdcdedx_stats_%s.pdf", m_suffix.data()));
849}

◆ printCanvas()

void printCanvas ( std::vector< TH1D * > & htemp,
std::string namesfx,
std::string svar )

Draw dE/dx histograms across bins.

Parameters
htempVector of histograms
namesfxSuffix to distinguish output
svarVariable name for binning

Definition at line 493 of file CDCDedxValidationAlgorithm.cc.

494{
495 int xbins = 0;
496 double xmin = 0.0, xmax = 0.0;
497
498 if (svar == "mom") {
499 xbins = m_momBins; xmin = m_momMin; xmax = m_momMax;
500 } else if (svar == "oned") {
501 xbins = m_eaBin; xmin = m_eaMin; xmax = m_eaMax;
502 } else if (svar == "costh") {
503 xbins = m_cosBins; xmin = m_cosMin; xmax = m_cosMax;
504 } else if (svar == "inj") {
505 xbins = m_tbins;
506 } else if (svar == "mom_peaks") {
507 xbins = 4; xmin = m_momMin; xmax = 4.0;
508 } else {
509 B2FATAL("wrong input");
510 }
511
512 // Set up the TCanvas with 4x4 grid
513 TCanvas* ctmp = new TCanvas("tmp", "tmp", 1200, 1200);
514 ctmp->Divide(4, 4); // Divide into 4x4 grid
515
516 // Prepare the PDF output
517 std::stringstream psname;
518 psname << Form("%s.pdf[", namesfx.data());
519 ctmp->Print(psname.str().c_str());
520 psname.str("");
521 psname << Form("%s.pdf", namesfx.data());
522
523 std::ofstream outFile;
524 outFile.open(Form("%s.txt", namesfx.data()));
525 CDCDedxWireGainAlgorithm wireg;
526
527 // Iterate through the histograms and plot them in the canvas
528 for (int i = 0; i < xbins; ++i) {
529
530 ctmp->cd(i % 16 + 1);
531 TPaveText pt(0.6, 0.73, 0.85, 0.89, "NBNDC");
532 setTextCosmetics(pt, kBlack);
533
534 if (svar == "oned") {
535 unsigned int minbin, maxbin;
536 wireg.getTruncatedBins(htemp[i], minbin, maxbin);
537 htemp[i]->SetTitle(Form("dedxhit-dist, entabin: %d ;%d;%d", i, minbin, maxbin));
538
539 double dedxmean = wireg.getTruncationMean(htemp[i], minbin, maxbin);
540
541 const double binWidth = (xmax - xmin) / xbins;
542 double binCenter = xmin + (i + 0.5) * binWidth; // Calculate bin center for cos(theta) or mom
543
544 outFile << binCenter << " " << dedxmean << std::endl;
545 } else {
546 double mean, meanErr, sigma, sigmaErr;
547 fit(htemp[i], mean, meanErr, sigma, sigmaErr);
548
549 if (svar == "mom" || svar == "costh" || svar == "mom_peaks") {
550 const double binWidth = (xmax - xmin) / xbins;
551 double binCenter = xmin + (i + 0.5) * binWidth; // Calculate bin center for cos(theta) or mom
552
553 outFile << binCenter << " " << mean << " " << meanErr << " " << sigma << " " << sigmaErr << std::endl;
554 } else {
555 std::string label = getTimeBinLabel(m_tedges[i], i);
556 outFile << i << " " << label << " " << mean << " " << meanErr << " " << sigma << " " << sigmaErr << std::endl;
557 }
558
559 pt.AddText(Form("#mu_{fit}: %0.03f#pm%0.03f", mean, meanErr));
560 pt.AddText(Form("#sigma_{fit}: %0.03f#pm%0.03f", sigma, sigmaErr));
561 }
562 htemp[i]->SetStats(0);
563 htemp[i]->DrawCopy("");
564 pt.DrawClone("same");
565
566 if ((i + 1) % 16 == 0 || ((i + 1) == xbins)) {
567 ctmp->SetBatch(kTRUE);
568 ctmp->Print(psname.str().c_str());
569 ctmp->Clear("D");
570 }
571 }
572
573 // ctmp->Print(psname.str().c_str());
574 psname.str("");
575 psname << Form("%s.pdf]", namesfx.data());
576 ctmp->Print(psname.str().c_str());
577
578 outFile.close();
579
580 delete ctmp;
581}
void setTextCosmetics(TPaveText pt, Color_t color)
Set text cosmetics for TPaveText.
void fit(TH1D *&hist, double &mean, double &meanErr, double &sigma, double &sigmaErr)
Perform full Gaussian fit and extract parameters.
void getTruncatedBins(TH1D *hdedxhit, unsigned int &binlow, unsigned int &binhigh)
function to get bins of truncation from histogram
double getTruncationMean(TH1D *hdedxhit, int binlow, int binhigh)
function to get mean of truncation from histogram

◆ printCanvasdEdx()

void printCanvasdEdx ( std::array< std::vector< TH1D * >, 2 > & htemp,
std::string namesfx,
std::string svar )

Draw dE/dx histograms for momentum and cosine bins.

Parameters
htempArray of vectors of histograms
namesfxSuffix to distinguish output
svarVariable name ("momentum" or "cosTheta")

Definition at line 406 of file CDCDedxValidationAlgorithm.cc.

407{
408 int xbins = 4;
409 double xmin, xmax;
410
411 if (svar == "mom") {
412 xmin = m_momMin; xmax = 4.0;
413 } else if (svar == "costh") {
414 xmin = m_cosMin; xmax = m_cosMax;
415 } else {
416 B2FATAL("wrong input");
417 }
418 double binWidth = (xmax - xmin) / xbins;
419
420 // Set up the TCanvas with 2x2 grid
421 TCanvas* ctmp = new TCanvas("tmp", "tmp", 1200, 1200);
422 ctmp->Divide(2, 2); // Divide into 2x2 grid
423
424 // Prepare the PDF output
425 std::stringstream psname;
426 psname << Form("%s.pdf[", namesfx.data());
427 ctmp->Print(psname.str().c_str());
428 psname.str("");
429 psname << Form("%s.pdf", namesfx.data());
430
431 // Iterate through the histograms and plot them in the canvas
432 for (int i = 0; i < xbins; ++i) {
433
434 ctmp->cd(i % 4 + 1);
435
436 double emean, emeanErr, esigma, esigmaErr;
437 double pmean, pmeanErr, psigma, psigmaErr;
438
439 fit(htemp[0][i], emean, emeanErr, esigma, esigmaErr);
440 fit(htemp[1][i], pmean, pmeanErr, psigma, psigmaErr);
441
442 double min = i * binWidth + xmin;
443 double max = min + binWidth;
444
445 TPaveText pt(0.6, 0.63, 0.85, 0.89, "NBNDC");
446 setTextCosmetics(pt, kBlack);
447 pt.AddText("e+");
448 pt.AddText(Form("#mu_{fit}: %0.03f#pm%0.03f", emean, emeanErr));
449 pt.AddText(Form("#sigma_{fit}: %0.03f#pm%0.03f", esigma, esigmaErr));
450
451 pt.AddText("e-");
452 pt.AddText(Form("#mu_{fit}: %0.03f#pm%0.03f", pmean, pmeanErr));
453 pt.AddText(Form("#sigma_{fit}: %0.03f#pm%0.03f", psigma, psigmaErr));
454
455 htemp[0][i]->SetStats(0);
456 htemp[1][i]->SetStats(0);
457 htemp[0][i]->SetFillColor(0);
458 htemp[1][i]->SetFillColor(0);
459 htemp[0][i]->SetLineColor(8);
460 htemp[1][i]->SetLineColor(9);
461 htemp[0][i]->SetTitle(Form("%s: (%0.02f, %0.02f)", svar.data(), min, max));
462 if (htemp[0][i]->GetEntries() > 0)
463 htemp[0][i]->Scale(1.0 / htemp[0][i]->GetEntries());
464 if (htemp[1][i]->GetEntries() > 0)
465 htemp[1][i]->Scale(1.0 / htemp[1][i]->GetEntries());
466
467 if (htemp[1][i]->GetMaximum() > htemp[0][i]->GetMaximum())
468 htemp[0][i]->SetMaximum(htemp[1][i]->GetMaximum());
469
470 htemp[0][i]->DrawCopy("HIST");
471 htemp[1][i]->DrawCopy("same HIST");
472 pt.DrawClone("same");
473
474 TLegend* lego = new TLegend(0.15, 0.67, 0.3, 0.8);
475 lego->AddEntry(htemp[0][i], "e+", "l");
476 lego->AddEntry(htemp[1][i], "e-", "l");
477 lego->Draw("same");
478
479 if ((i + 1) % 4 == 0 || i == xbins - 1) {
480 ctmp->SetBatch(kTRUE);
481 ctmp->Print(psname.str().c_str());
482 if ((i + 1) % 4 == 0) ctmp->Clear("D");
483 }
484 }
485
486 psname.str("");
487 psname << Form("%s.pdf]", namesfx.data());
488 ctmp->Print(psname.str().c_str());
489
490 delete ctmp;
491}

◆ printCanvasRun()

void printCanvasRun ( std::map< int, TH1D * > & htemp,
std::string namesfx )

Draw dE/dx per run histogram canvas.

Parameters
htempHistogram map (run number -> TH1D pointer)
namesfxSuffix to distinguish output

Definition at line 603 of file CDCDedxValidationAlgorithm.cc.

604{
605 // Set up the TCanvas with 4x4 grid
606 TCanvas* ctmp = new TCanvas("tmp", "tmp", 1200, 1200);
607 ctmp->Divide(4, 4); // Divide into 4x4 grid
608
609 // Prepare the PDF output
610 std::stringstream psname;
611 psname << Form("%s.pdf[", namesfx.data());
612 ctmp->Print(psname.str().c_str());
613 psname.str("");
614 psname << Form("%s.pdf", namesfx.data());
615
616 std::ofstream outFile;
617 outFile.open(Form("%s.txt", namesfx.data()));
618
619 // Iterate through the histograms and plot them in the canvas
620 int irun = 0;
621 for (const auto& entry : htemp) {
622 int run = entry.first;
623 TH1D* hist = entry.second;
624
625 ctmp->cd(irun % 16 + 1);
626
627 TPaveText pt(0.6, 0.73, 0.85, 0.89, "NBNDC");
628 setTextCosmetics(pt, kBlack);
629
630 double mean, meanErr, sigma, sigmaErr;
631 fit(hist, mean, meanErr, sigma, sigmaErr);
632
633 outFile << run << " " << mean << " " << meanErr << " " << sigma << " " << sigmaErr << std::endl;
634
635 pt.AddText(Form("#mu_{fit}: %0.03f#pm%0.03f", mean, meanErr));
636 pt.AddText(Form("#sigma_{fit}: %0.03f#pm%0.03f", sigma, sigmaErr));
637
638 hist->SetStats(0);
639 hist->DrawCopy("");
640 pt.DrawClone("same");
641
642 if ((irun + 1) % 16 == 0 || irun == int(htemp.size() - 1)) {
643 ctmp->SetBatch(kTRUE);
644 ctmp->Print(psname.str().c_str());
645 ctmp->Clear("D");
646 }
647 irun++;
648 }
649
650 ctmp->Print(psname.str().c_str());
651 psname.str("");
652 psname << Form("%s.pdf]", namesfx.data());
653 ctmp->Print(psname.str().c_str());
654
655 outFile.close();
656
657 delete ctmp;
658}

◆ printCanvasWire()

void printCanvasWire ( std::vector< TH1D * > temp,
std::string namesfx,
const std::vector< double > & vdedx_mean )

Plot dE/dx vs wire number.

Parameters
tempVector of histograms
namesfxSuffix to distinguish output
vdedx_meanVector of mean dE/dx values

Definition at line 768 of file CDCDedxValidationAlgorithm.cc.

770{
771 TCanvas* ctmp = new TCanvas("tmp", "tmp", 900, 900);
772 ctmp->Divide(4, 4);
773
774 std::stringstream psname;
775 psname << Form("%s.pdf[", namesfx.data());
776 ctmp->Print(psname.str().c_str());
777 psname.str("");
778 psname << Form("%s.pdf", namesfx.data());
779
780 for (unsigned int ip = 0; ip < c_nwireCDC; ip++) {
781 int minbin = std::stoi(temp[ip]->GetXaxis()->GetTitle());
782 int maxbin = std::stoi(temp[ip]->GetYaxis()->GetTitle());
783 temp[ip]->SetFillColor(kYellow - 9);
784 temp[ip]->SetTitle(Form("%s, #mu_{trunc} %0.03f;dedxhit;entries", temp[ip]->GetTitle(), vdedx_mean.at(ip)));
785
786 ctmp->cd(ip % 16 + 1);
787 gPad->cd();
788 temp[ip]->DrawCopy("hist");
789 TH1D* hdedxhitC = (TH1D*)temp[ip]->Clone(Form("%sC", temp[ip]->GetName()));
790 hdedxhitC->GetXaxis()->SetRange(minbin, maxbin);
791 hdedxhitC->SetFillColor(kAzure + 1);
792 hdedxhitC->DrawCopy("same histo");
793
794 if ((ip + 1) % 16 == 0) {
795 ctmp->SetBatch(kTRUE);
796 ctmp->Print(psname.str().c_str());
797 ctmp->Clear("D");
798 }
799 delete temp[ip];
800 delete hdedxhitC;
801
802 }
803
804 psname.str("");
805 psname << Form("%s.pdf]", namesfx.data());
806 ctmp->Print(psname.str().c_str());
807 delete ctmp;
808}

◆ radeeValidation()

void radeeValidation ( )

Validate dE/dx using radee sample (vs momentum, injection time)

Definition at line 114 of file CDCDedxValidationAlgorithm.cc.

115{
116 auto ttree = getObjectPtr<TTree>("tRadee");
117
118 double dedx, costh, p, injtime = 0.0, injring = 1.0;
119 int charge;
120
121 std::vector<double>* dedxhit = 0, *enta = 0;
122 std::vector<int>* layer = 0;
123
124 ttree->SetBranchAddress("dedx", &dedx);
125 ttree->SetBranchAddress("p", &p);
126 ttree->SetBranchAddress("costh", &costh);
127 ttree->SetBranchAddress("charge", &charge);
128 ttree->SetBranchAddress("injtime", &injtime);
129 ttree->SetBranchAddress("injring", &injring);
130 ttree->SetBranchAddress("dedxhit", &dedxhit);
131 ttree->SetBranchAddress("entaRS", &enta);
132 ttree->SetBranchAddress("layer", &layer);
133
134 std::vector<double> vtlocaledges;
135 defineTimeBins(vtlocaledges);
136 m_tbins = vtlocaledges.size() - 1;
137 m_tedges = &vtlocaledges[0];
138
139 std::array<std::array<std::vector<TH1D*>, 2>, 13> hdedx_mom;
140 std::array<std::vector<TH1D*>, 2> hdedx_mom_peaks, hdedx_inj, hdedx_inj_nocor;
141 std::array<std::vector<TH1D*>, 3> hdedx_oned;
142
143 TH1D* htimes = new TH1D(Form("htimes_%s", m_suffix.data()), "", m_tbins, m_tedges);
144
145 const double momBinWidth = (m_momMax - m_momMin) / m_momBins;
146 const double momBinW = (4.0 - m_momMin) / 4;
147
148 std::string scos[13] = {"acos", "cos#theta > 0.0", "cos#theta < 0.0", "cos#theta <= -0.8",
149 "cos#theta > -0.8 and cos#theta <= -0.6",
150 "cos#theta > -0.6 and cos#theta <= -0.4", "cos#theta > -0.4 and cos#theta <= -0.2",
151 "cos#theta > -0.2 and cos#theta <= 0", "cos#theta > 0 and cos#theta <= 0.2",
152 "cos#theta > 0.2 and cos#theta <= 0.4", "cos#theta > 0.4 and cos#theta <= 0.6",
153 "cos#theta > 0.6 and cos#theta <= 0.8", "cos#theta > 0.8"
154 };
155 std::string stype[2] = {"posi", "elec"};
156 std::string sLayer[3] = {"SL0", "SL1", "SL2-8"};
157
158 // Define histograms for momentum bins and charge types
159 for (int ic = 0; ic < 13; ic++) {
160 for (int it = 0; it < 2; ++it) {
161 hdedx_mom[ic][it].resize(m_momBins);
162 defineHisto(hdedx_mom[ic][it], "mom", Form("%d_%s", ic, stype[it].data()));
163 }
164 }
165
166 // Define histograms for injection time bins and rings
167 for (unsigned int ir = 0; ir < 2; ir++) {
168 hdedx_inj[ir].resize(m_tbins);
169 hdedx_inj_nocor[ir].resize(m_tbins);
170 hdedx_mom_peaks[ir].resize(4);
171
172 defineHisto(hdedx_inj[ir], "inj", m_sring[ir].data());
173 defineHisto(hdedx_inj_nocor[ir], "inj", Form("nocor_%s", m_sring[ir].data()));
174 defineHisto(hdedx_mom_peaks[ir], "mom_peaks", Form("%s", stype[ir].data()));
175
176 }
177
178 for (unsigned int ir = 0; ir < 3; ir++) {
179 hdedx_oned[ir].resize(m_eaBin);
180 defineHisto(hdedx_oned[ir], "oned", Form("%s", sLayer[ir].data()));
181 }
182
183 double eaBW = (m_eaMax - m_eaMin) / m_eaBin;
184 double icos[3] = {0, -1, -1};
185 double chgtype;
186
187 // Loop over all the entries in the tree
188 for (int i = 0; i < ttree->GetEntries(); ++i) {
189 ttree->GetEvent(i);
190
191 // Skip invalid events
192 if (dedx <= 0 || injtime < 0 || injring < 0) continue;
193
194 // Calculate momentum bin index for hdedx_mom
195 int binIndex = static_cast<int>((abs(p) - m_momMin) / momBinWidth);
196
197 // Determine cos(theta) category
198
199 icos[1] = (costh > 0) ? 1 : 2;
200 icos[2] = int((costh + 1.0) / 0.2) + 3;
201 if (icos[2] < 3) icos[2] = 3;
202 if (icos[2] > 12) icos[2] = 12;
203
204 // Determine charge type
205 chgtype = (charge > 0) ? 0 : 1;
206
207 // Fill momentum histograms (only if binIndex is valid)
208 if (binIndex >= 0 && binIndex < m_momBins) {
209 hdedx_mom[icos[0]][chgtype][binIndex]->Fill(dedx);
210 hdedx_mom[icos[1]][chgtype][binIndex]->Fill(dedx);
211 hdedx_mom[icos[2]][chgtype][binIndex]->Fill(dedx);
212 }
213
214 // Add larger times to the last bin
215 if (injtime > m_tedges[m_tbins]) injtime = m_tedges[m_tbins] - 10.0;
216
217 // Injection ring type
218 int wr = (injring > 0.5) ? 1 : 0;
219
220 double timeGain = m_DBInjectTime->getCorrection("mean", injring, injtime);
221
222 // Injection time bin
223 unsigned int tb = htimes->GetXaxis()->FindBin(injtime);
224 tb = std::min(tb, static_cast<unsigned int>(m_tbins)) - 1;
225
226 // Fill injection time and dE/dx histograms
227 htimes->Fill(injtime);
228 hdedx_inj[wr][tb]->Fill(dedx);
229 hdedx_inj_nocor[wr][tb]->Fill(dedx * timeGain);
230
231 // Fill hdedx_mom_peaks with its own binning
232 int binI = static_cast<int>((abs(p) - m_momMin) / momBinW);
233 if (binI >= 0 && binI < 4) {
234 hdedx_mom_peaks[chgtype][binI]->Fill(dedx);
235 }
236
237 // Fill dE/dx in enta bins from hits
238 for (unsigned int j = 0; j < dedxhit->size(); ++j) {
239 if (dedxhit->at(j) == 0) continue;
240
241 double entaval = enta->at(j);
242 int ibin = std::floor((entaval - m_eaMin) / eaBW);
243 if (ibin < 0 || ibin >= m_eaBin) continue;
244
245 int lay = layer->at(j);
246 int mL = (lay < 8) ? 0 : ((lay < 14) ? 1 : 2);
247 hdedx_oned[mL][ibin]->Fill(dedxhit->at(j));
248 }
249 }
250
251
252 for (int ic = 0; ic < 13; ic++) {
253 for (int it = 0; it < 2; ++it) {
254 printCanvas(hdedx_mom[ic][it], Form("plots/mom/dedx_vs_mom_%d_%s_%s", ic, stype[it].data(), m_suffix.data()), "mom");
255 }
256 }
257 for (int it = 0; it < 2; ++it) {
258 printCanvas(hdedx_inj[it], Form("plots/injection/dedx_vs_inj_%s_%s", m_sring[it].data(), m_suffix.data()), "inj");
259 printCanvas(hdedx_inj_nocor[it], Form("plots/injection/dedx_vs_inj_nocor_%s_%s", m_sring[it].data(), m_suffix.data()), "inj");
260 }
261 for (int it = 0; it < 3; ++it)
262 printCanvas(hdedx_oned[it], Form("plots/oneD/dedx_vs_1D_%s_%s", sLayer[it].data(), m_suffix.data()), "oned");
263
264 printCanvasdEdx(hdedx_mom_peaks, Form("plots/mom/dedxpeaks_vs_mom_%s", m_suffix.data()), "mom");
265
266}
void defineTimeBins(std::vector< double > &vtlocaledges)
Set bin edges for injection time.
std::array< std::string, 2 > m_sring
injection ring name
DBObjPtr< CDCDedxInjectionTime > m_DBInjectTime
Injection time DB object.

◆ resetDatabase()

void resetDatabase ( )

Clear current DB pointers and state.

Definition at line 1009 of file CDCDedxValidationAlgorithm.cc.

1010{
1011 /* Reset both DataStore and Database. */
1013 Database::Instance().reset(false);
1014 DBStore::Instance().reset(false);
1015}
void reset(EDurability durability)
Frees memory occupied by data store items and removes all objects from the map.
Definition DataStore.cc:85
void reset(bool keepEntries=false)
Invalidate all payloads.
Definition DBStore.cc:175
static void reset(bool keepConfig=false)
Reset the database instance.
Definition Database.cc:50

◆ 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();}

◆ 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;}

◆ setGlobalTag()

void setGlobalTag ( const std::string & globalTagName)
inline

Set Global Tag name.

Parameters
globalTagNameName of the global tag

Definition at line 208 of file CDCDedxValidationAlgorithm.h.

209 {
210 m_GlobalTagName = globalTagName;
211 }

◆ setInputFileNames() [1/2]

void setInputFileNames ( const 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...
void setInputFileNames(PyObject *inputFileNames)
Set the input file names used for this algorithm from a Python list.
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.

◆ setInputFileNames() [2/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}
Scalar convertPythonObject(const boost::python::object &pyObject, Scalar)
Convert from Python to given type.

◆ 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;}

◆ setTestingPayload()

void setTestingPayload ( const std::string & testingPayloadName)
inline

Set testing payload name.

Parameters
testingPayloadNameName of the payload

Definition at line 199 of file CDCDedxValidationAlgorithm.h.

200 {
201 m_testingPayloadName = testingPayloadName;
202 }

◆ setTextCosmetics()

void setTextCosmetics ( TPaveText pt,
Color_t color )
inline

Set text cosmetics for TPaveText.

Parameters
ptTPaveText object
colorColor to apply

Definition at line 218 of file CDCDedxValidationAlgorithm.h.

219 {
220 pt.SetBorderSize(0);
221 pt.SetShadowColor(kWhite);
222 pt.SetTextColor(color);
223 }

◆ updateDBObjPtrs()

void updateDBObjPtrs ( const unsigned int event,
const int run,
const int experiment )
staticprotectedinherited

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

Definition at line 405 of file CalibrationAlgorithm.cc.

406{
407 // Construct an EventMetaData object but NOT in the Datastore
408 EventMetaData emd(event, run, experiment);
409 // Explicitly update while avoiding registering a Datastore object
411 // Also update the intra-run objects to the event at the same time (maybe unnecessary...)
413}

◆ wireGain()

void wireGain ( std::vector< TH1D * > & hdedxhit)

Validate wire gain data using dE/dx histograms.

Parameters
hdedxhitVector of dE/dx hit histograms

Definition at line 689 of file CDCDedxValidationAlgorithm.cc.

690{
691
692 std::vector<double> vdedx_means;
693 std::vector<double> layermean(c_maxNSenseLayers);
694 std::vector<double> lgmean(c_maxNSenseLayers);
695
696 std::ofstream outFile, outFileLayer, outFileAvg, outFilebdwire;
697 outFile.open(Form("plots/wire/dedx_mean_gwire_%s.txt", m_suffix.data()));
698 outFilebdwire.open(Form("plots/wire/dedx_mean_badwire_%s.txt", m_suffix.data()));
699 outFileLayer.open(Form("plots/wire/dedx_mean_layer_%s.txt", m_suffix.data()));
700 outFileAvg.open(Form("plots/wire/dedx_mean_layer_avg_%s.txt", m_suffix.data()));
701
702 int activelayers = 0;
703 double layeravg = 0.0;
704
705 CDCGeometryPar& cdcgeo = CDCGeometryPar::Instance(&(*m_cdcGeo));
706 CDCDedxWireGainAlgorithm wireg;
707
708 DBObjPtr<CDCDedxBadWires> Badwire;
709
710 int jwire = -1;
711 for (unsigned int il = 0; il < c_maxNSenseLayers; ++il) {
712
713 int activewires = 0, goodwires = 0;
714 layermean[il] = 0.0;
715 lgmean[il] = 0.0;
716
717 for (unsigned int iw = 0; iw < cdcgeo.nWiresInLayer(il); ++iw) {
718 jwire++;
719
720 unsigned int minbin, maxbin;
721 wireg.getTruncatedBins(hdedxhit[jwire], minbin, maxbin);
722 hdedxhit[jwire]->SetTitle(Form("dedxhit-dist, wire: %d ;%d;%d", jwire, minbin, maxbin));
723
724 double dedxmean = wireg.getTruncationMean(hdedxhit[jwire], minbin, maxbin);
725 vdedx_means.push_back(dedxmean);
726
727 if (Badwire->getBadWireStatus(jwire) == kTRUE)
728 outFilebdwire << jwire << " " << dedxmean << std::endl;
729 else
730 outFile << jwire << " " << dedxmean << std::endl;
731
732 if (vdedx_means.at(jwire) > 0) {
733 layermean[il] += vdedx_means.at(jwire);
734 activewires++;
735 if (Badwire->getBadWireStatus(jwire) != kTRUE) {
736 lgmean[il] += vdedx_means.at(jwire);
737 goodwires++;
738 }
739 }
740 }
741
742 if (activewires > 0) layermean[il] /= activewires;
743 else layermean[il] = 1.0;
744
745 if (goodwires > 0) lgmean[il] /= goodwires;
746 else lgmean[il] = 1.0;
747
748 outFileLayer << il << " " << layermean[il] << " " << lgmean[il] << std::endl;
749
750 //calculate outer layer average for active layer
751 if (il >= 8 && layermean[il] > 0) {
752 layeravg += layermean[il];
753 activelayers++;
754 }
755 }
756
757 //normalisation of wiregains to get outergain ~1.0
758 if (activelayers > 0) layeravg /= activelayers;
759 outFileAvg << layeravg << std::endl;
760
761 outFile.close();
762 outFilebdwire.close();
763 outFileLayer.close();
764 outFileAvg.close();
765 printCanvasWire(hdedxhit, Form("plots/wire/dedx_vs_wire_%s", m_suffix.data()), vdedx_means);
766}
void printCanvasWire(std::vector< TH1D * > temp, std::string namesfx, const std::vector< double > &vdedx_mean)
Plot dE/dx vs wire number.

Member Data Documentation

◆ m_allExpRun

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

allExpRun

Definition at line 364 of file CalibrationAlgorithm.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_cdcGeo

DBObjPtr<CDCGeometry> m_cdcGeo
private

Geometry of CDC.

Definition at line 307 of file CDCDedxValidationAlgorithm.h.

◆ m_cosBins

int m_cosBins
private

bins for cosine

Definition at line 288 of file CDCDedxValidationAlgorithm.h.

◆ m_cosMax

double m_cosMax
private

max range of cosine

Definition at line 290 of file CDCDedxValidationAlgorithm.h.

◆ m_cosMin

double m_cosMin
private

min range of cosine

Definition at line 289 of file CDCDedxValidationAlgorithm.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_DBInjectTime

DBObjPtr<CDCDedxInjectionTime> m_DBInjectTime
private

Injection time DB object.

Definition at line 315 of file CDCDedxValidationAlgorithm.h.

◆ m_dedxBins

int m_dedxBins
private

bins for dedx histogram

Definition at line 284 of file CDCDedxValidationAlgorithm.h.

◆ m_dedxMax

double m_dedxMax
private

max range of dedx

Definition at line 286 of file CDCDedxValidationAlgorithm.h.

◆ m_dedxMin

double m_dedxMin
private

min range of dedx

Definition at line 285 of file CDCDedxValidationAlgorithm.h.

◆ m_description

std::string m_description {""}
privateinherited

Description of the algorithm.

Definition at line 385 of file CalibrationAlgorithm.h.

385{""};

◆ m_eaBin

int m_eaBin
private

of bins for entrance angle

Definition at line 299 of file CDCDedxValidationAlgorithm.h.

◆ m_eaMax

double m_eaMax
private

upper edge of entrance angle

Definition at line 301 of file CDCDedxValidationAlgorithm.h.

◆ m_eaMin

double m_eaMin
private

lower edge of entrance angle

Definition at line 300 of file CDCDedxValidationAlgorithm.h.

◆ m_GlobalTagName

std::string m_GlobalTagName = ""
private

Global Tag name.

Definition at line 313 of file CDCDedxValidationAlgorithm.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_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_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_momBins

int m_momBins
private

bins for momentum

Definition at line 292 of file CDCDedxValidationAlgorithm.h.

◆ m_momMax

double m_momMax
private

max range of momentum

Definition at line 294 of file CDCDedxValidationAlgorithm.h.

◆ m_momMin

double m_momMin
private

min range of momentum

Definition at line 293 of file CDCDedxValidationAlgorithm.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_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_sigmaR

double m_sigmaR
private

fit dedx dist in sigma range

Definition at line 282 of file CDCDedxValidationAlgorithm.h.

◆ m_sring

std::array<std::string, 2> m_sring {"ler", "her"}
private

injection ring name

Definition at line 303 of file CDCDedxValidationAlgorithm.h.

303{"ler", "her"};

◆ m_suffix

std::string m_suffix
private

suffix string to separate plots

Definition at line 305 of file CDCDedxValidationAlgorithm.h.

◆ m_tbins

unsigned int m_tbins
private

internal time bins

Definition at line 297 of file CDCDedxValidationAlgorithm.h.

◆ m_tedges

double* m_tedges
private

internal time array (copy of vtlocaledges)

Definition at line 296 of file CDCDedxValidationAlgorithm.h.

◆ m_testingPayloadName

std::string m_testingPayloadName = ""
private

Testing payload location.

Definition at line 310 of file CDCDedxValidationAlgorithm.h.


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