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.
 
const std::list< Database::DBImportQuery > & getPayloadValues () const
 Get constants (in TObjects) for database update from last execution.
 
bool commit ()
 Submit constants from last calibration into database.
 
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.
 
static bool commit (std::list< Database::DBImportQuery > payloads)
 Submit constants from a (potentially previous) set of payloads.
 

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.
 
StoreObjPtr< EventMetaDatam_EventMetaData
 Event metadata.
 
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 88 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 100 of file CDCDedxValidationAlgorithm.h.

100{}

Member Function Documentation

◆ bhabhaValidation()

void bhabhaValidation ( )

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

Definition at line 260 of file CDCDedxValidationAlgorithm.cc.

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

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)
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 842 of file CDCDedxValidationAlgorithm.cc.

843{
844 if (m_EventMetaData.isValid()) {
845 m_EventMetaData->setExperiment(experiment);
846 m_EventMetaData->setRun(run);
847 }
848
849 auto& dbConfiguration = Conditions::Configuration::getInstance();
850 dbConfiguration.overrideGlobalTags();
851 dbConfiguration.setGlobalTags({"online"});
852 if (!m_testingPayloadName.empty() && m_GlobalTagName.empty()) {
853 dbConfiguration.prependTestingPayloadLocation(m_testingPayloadName);
854 } else if (m_testingPayloadName.empty() && !m_GlobalTagName.empty()) {
855 dbConfiguration.prependGlobalTag(m_GlobalTagName);
856 } else
857 B2FATAL("Setting both testing payload and Global Tag or setting no one of them.");
858
859 /* Mimic a module initialization. */
861 m_EventMetaData.registerInDataStore();
863 if (!m_EventMetaData.isValid())
864 m_EventMetaData.construct(1, run, experiment);
865
866 /* Database instance and configuration. */
867 DBStore& dbStore = DBStore::Instance();
868 dbStore.update();
869 dbStore.updateEvent();
870}
std::string m_testingPayloadName
Testing payload location.
StoreObjPtr< EventMetaData > m_EventMetaData
Event metadata.
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 352 of file CDCDedxValidationAlgorithm.cc.

353{
354 int xbins = 0;
355 double xmin = 0.0, xmax = 0.0;
356 double binWidth = 0.0;
357
358 if (var == "mom") {
359 xbins = m_momBins; xmin = m_momMin; xmax = m_momMax;
360 } else if (var == "oned") {
361 xbins = m_eaBin; xmin = m_eaMin; xmax = m_eaMax; m_dedxBins = 250;
362 } else if (var == "costh") {
363 xbins = m_cosBins; xmin = m_cosMin; xmax = m_cosMax;
364 } else if (var == "inj") {
365 xbins = m_tbins;
366 } else if (var == "mom_peaks") {
367 xbins = 4; xmin = m_momMin; xmax = 4.0;
368 } else if (var == "cos_peaks") {
369 xbins = 4; xmin = m_cosMin; xmax = m_cosMax;
370 } else {
371 xbins = c_nSenseWires; m_dedxBins = 250;
372 }
373
374 if (var == "costh" || var == "mom" || var == "mom_peaks" || var == "cos_peaks" || var == "oned") {
375 binWidth = (xmax - xmin) / xbins;
376 }
377
378 for (int ic = 0; ic < xbins; ic++) {
379 std::string title = Form("dedxhit-dist, wire:%d", ic);
380 std::string name = Form("hdedx_%s_%s_%d", m_suffix.data(), var.data(), ic);
381
382 if (var == "costh" || var == "mom" || var == "mom_peaks" || var == "cos_peaks" || var == "oned") {
383 double min = ic * binWidth + xmin;
384 double max = min + binWidth;
385 title = Form("%s: (%0.02f, %0.02f) %s", var.data(), min, max, stype.data());
386 name = Form("hdedx_%s_%s_%s_%d", m_suffix.data(), var.data(), stype.data(), ic);
387 } else if (var == "inj") {
388 std::string label = getTimeBinLabel(m_tedges[ic], ic);
389 title = Form("%s, time(%s)", stype.data(), label.data());
390 name = Form("h%s_%s_%s_t%d", var.data(), m_suffix.data(), stype.data(), ic);
391 }
392 htemp[ic] = new TH1D(name.data(), "", m_dedxBins, m_dedxMin, m_dedxMax);
393 htemp[ic]->SetTitle(Form("%s;dedx;entries", title.data()));
394 }
395}
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 801 of file CDCDedxValidationAlgorithm.cc.

802{
803 double fixedges[69];
804 for (int ib = 0; ib < 69; ib++) {
805 fixedges[ib] = ib * 0.5 * 1e3;
806 if (ib > 40 && ib <= 60) fixedges[ib] = fixedges[ib - 1] + 1.0 * 1e3;
807 else if (ib > 60 && ib <= 64) fixedges[ib] = fixedges[ib - 1] + 10.0 * 1e3;
808 else if (ib > 64 && ib <= 65) fixedges[ib] = fixedges[ib - 1] + 420.0 * 1e3;
809 else if (ib > 65 && ib <= 66) fixedges[ib] = fixedges[ib - 1] + 500.0 * 1e3;
810 else if (ib > 66) fixedges[ib] = fixedges[ib - 1] + 2e6;
811 vtlocaledges.push_back(fixedges[ib]);
812 }
813}

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

◆ 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 574 of file CDCDedxValidationAlgorithm.cc.

575{
576
577 std::string status = "";
578
579 if (hist->Integral() > 100)
580 fitGaussianWRange(hist, status);
581
582 if (status != "fitOK") {
583 hist->SetFillColor(kOrange);
584 mean = 0.0, meanErr = 0.0, sigma = 0.0, sigmaErr = 0.0;
585 } else {
586 mean = hist->GetFunction("gaus")->GetParameter(1);
587 meanErr = hist->GetFunction("gaus")->GetParError(1);
588 sigma = hist->GetFunction("gaus")->GetParameter(2);
589 sigmaErr = hist->GetFunction("gaus")->GetParError(2);
590 hist->SetFillColor(kYellow);
591 }
592}
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 652 of file CDCDedxValidationAlgorithm.cc.

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

◆ 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 910 of file CDCDedxValidationAlgorithm.cc.

911{
912
913 DatabaseIN(experiment, run);
914
915 std::vector<double> cosgain, cos;
916
917 DBObjPtr<CDCDedxCosineCor> DBCosineCor;
918 if (!DBCosineCor.isValid()) B2FATAL("Cosine gain data are not valid.");
919
920 unsigned int nCosBins = DBCosineCor->getSize();
921
922 for (unsigned int il = 0; il < nCosBins; ++il) {
923 double costh = -1.0 + (il + 0.5) * 2.0 / nCosBins;
924 costh += .000001;
925 cosgain.push_back(DBCosineCor->getMean(il));
926 cos.push_back(costh);
927 }
928
930 return {cosgain, cos};
931}
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 383 of file CalibrationAlgorithm.cc.

384{
385 // Save TDirectory to change back at the end
386 TDirectory* dir = gDirectory;
387 const 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}
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 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 }

◆ getonedgain()

OnedData getonedgain ( int experiment,
int run )

Retrieve 1D gain data from DB.

Parameters
experimentExperiment number
runRun number
Returns
OnedData structure

Definition at line 933 of file CDCDedxValidationAlgorithm.cc.

934{
935
936 DatabaseIN(experiment, run);
937
938 std::vector<double> inner1D, outer1D, Enta;
939
940 DBObjPtr<CDCDedx1DCell> DBOneDCell;
941 if (!DBOneDCell.isValid()) B2FATAL("OneD cell gain data are not valid.");
942
943 for (int i = 0; i < 2; i++) {
944
945 unsigned int nBins = DBOneDCell->getNBins(i);
946 double binSize = TMath::Pi() / nBins;
947
948 for (unsigned int nbin = 0; nbin < nBins; nbin++) {
949
950 double enta = (-1 * TMath::Pi() / 2.0) + binSize * nbin;
951 if (i == 0) {
952 Enta.push_back(enta);
953 inner1D.push_back(DBOneDCell->getMean(0, nbin));
954 } else
955 outer1D.push_back(DBOneDCell->getMean(17, nbin));
956 }
957 }
959 return {inner1D, outer1D, Enta};
960
961}

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

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

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

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 963 of file CDCDedxValidationAlgorithm.cc.

964{
965
966 DatabaseIN(experiment, run);
967
968 DBObjPtr<CDCDedxRunGain> RunGain;
969 if (!RunGain.isValid()) B2FATAL("Run gain data are not valid.");
970 double gain = RunGain->getRunGain();
971 return gain;
972}

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

◆ 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 191 of file CDCDedxValidationAlgorithm.h.

192 {
193 std::string label = "";
194 if (tedges < 2e4)label = Form("%0.01f-%0.01fK", m_tedges[it] / 1e3, m_tedges[it + 1] / 1e3);
195 else if (tedges < 1e5)label = Form("%0.0f-%0.0fK", m_tedges[it] / 1e3, m_tedges[it + 1] / 1e3);
196 else label = Form("%0.01f-%0.01fM", m_tedges[it] / 1e6, m_tedges[it + 1] / 1e6);
197 return label;
198 }

◆ 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 872 of file CDCDedxValidationAlgorithm.cc.

873{
874
875 DatabaseIN(experiment, run);
876
877 std::vector<double> wiregain;
878 std::vector<double> layermean(c_maxNSenseLayers);
879
880 DBObjPtr<CDCDedxWireGain> DBWireGains;
881 if (!DBWireGains.isValid()) B2FATAL("Wire gain data are not valid.");
882
883 CDCGeometryPar& cdcgeo = CDCGeometryPar::Instance(&(*m_cdcGeo));
884
885 int jwire = -1;
886 for (unsigned int il = 0; il < c_maxNSenseLayers; ++il) {
887
888 int activewires = 0;
889 layermean[il] = 0.0;
890
891 for (unsigned int iw = 0; iw < cdcgeo.nWiresInLayer(il); ++iw) {
892 jwire++;
893
894 wiregain.push_back(DBWireGains->getWireGain(jwire));
895
896 if (wiregain.at(jwire) > 0) {
897 layermean[il] += wiregain.at(jwire);
898 activewires++;
899 }
900 }
901
902 if (activewires > 0) layermean[il] /= activewires;
903 else layermean[il] = 1.0;
904 }
905
907 return { wiregain, layermean };
908}
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, 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.

◆ plotEventStats()

void plotEventStats ( )

Plot summary statistics of selected events.

Definition at line 816 of file CDCDedxValidationAlgorithm.cc.

817{
818
819 TCanvas cstats("cstats", "cstats", 800, 400);
820 cstats.SetBatch(kTRUE);
821 cstats.Divide(2, 1);
822
823 cstats.cd(1);
824 auto hestats = getObjectPtr<TH1I>("hestats");
825 if (hestats) {
826 hestats->SetName(Form("hestats_%s", m_suffix.data()));
827 hestats->SetStats(0);
828 hestats->DrawCopy("");
829 }
830
831 cstats.cd(2);
832 auto htstats = getObjectPtr<TH1I>("htstats");
833 if (htstats) {
834 htstats->SetName(Form("htstats_%s", m_suffix.data()));
835 htstats->SetStats(0);
836 htstats->DrawCopy("");
837 }
838
839 cstats.Print(Form("cdcdedx_stats_%s.pdf", m_suffix.data()));
840}

◆ 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 484 of file CDCDedxValidationAlgorithm.cc.

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

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

◆ 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 594 of file CDCDedxValidationAlgorithm.cc.

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

◆ 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 759 of file CDCDedxValidationAlgorithm.cc.

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

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

975{
976 /* Reset both DataStore and Database. */
978 Database::Instance().reset(false);
979 DBStore::Instance().reset(false);
980}
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:49

◆ 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 213 of file CDCDedxValidationAlgorithm.h.

214 {
215 m_GlobalTagName = globalTagName;
216 }

◆ 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 204 of file CDCDedxValidationAlgorithm.h.

205 {
206 m_testingPayloadName = testingPayloadName;
207 }

◆ setTextCosmetics()

void setTextCosmetics ( TPaveText pt,
Color_t color )
inline

Set text cosmetics for TPaveText.

Parameters
ptTPaveText object
colorColor to apply

Definition at line 223 of file CDCDedxValidationAlgorithm.h.

224 {
225 pt.SetBorderSize(0);
226 pt.SetShadowColor(kWhite);
227 pt.SetTextColor(color);
228 }

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

◆ 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 680 of file CDCDedxValidationAlgorithm.cc.

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

◆ m_cosBins

int m_cosBins
private

bins for cosine

Definition at line 293 of file CDCDedxValidationAlgorithm.h.

◆ m_cosMax

double m_cosMax
private

max range of cosine

Definition at line 295 of file CDCDedxValidationAlgorithm.h.

◆ m_cosMin

double m_cosMin
private

min range of cosine

Definition at line 294 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 323 of file CDCDedxValidationAlgorithm.h.

◆ m_dedxBins

int m_dedxBins
private

bins for dedx histogram

Definition at line 289 of file CDCDedxValidationAlgorithm.h.

◆ m_dedxMax

double m_dedxMax
private

max range of dedx

Definition at line 291 of file CDCDedxValidationAlgorithm.h.

◆ m_dedxMin

double m_dedxMin
private

min range of dedx

Definition at line 290 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 304 of file CDCDedxValidationAlgorithm.h.

◆ m_eaMax

double m_eaMax
private

upper edge of entrance angle

Definition at line 306 of file CDCDedxValidationAlgorithm.h.

◆ m_eaMin

double m_eaMin
private

lower edge of entrance angle

Definition at line 305 of file CDCDedxValidationAlgorithm.h.

◆ m_EventMetaData

StoreObjPtr<EventMetaData> m_EventMetaData
private

Event metadata.

Definition at line 321 of file CDCDedxValidationAlgorithm.h.

◆ m_GlobalTagName

std::string m_GlobalTagName = ""
private

Global Tag name.

Definition at line 318 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 297 of file CDCDedxValidationAlgorithm.h.

◆ m_momMax

double m_momMax
private

max range of momentum

Definition at line 299 of file CDCDedxValidationAlgorithm.h.

◆ m_momMin

double m_momMin
private

min range of momentum

Definition at line 298 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 287 of file CDCDedxValidationAlgorithm.h.

◆ m_sring

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

injection ring name

Definition at line 308 of file CDCDedxValidationAlgorithm.h.

308{"ler", "her"};

◆ m_suffix

std::string m_suffix
private

suffix string to separate plots

Definition at line 310 of file CDCDedxValidationAlgorithm.h.

◆ m_tbins

unsigned int m_tbins
private

internal time bins

Definition at line 302 of file CDCDedxValidationAlgorithm.h.

◆ m_tedges

double* m_tedges
private

internal time array (copy of vtlocaledges)

Definition at line 301 of file CDCDedxValidationAlgorithm.h.

◆ m_testingPayloadName

std::string m_testingPayloadName = ""
private

Testing payload location.

Definition at line 315 of file CDCDedxValidationAlgorithm.h.


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