27 TFile out(
file,
"RECREATE");
30 tree.Branch(
"TPCScaler",
this);
38 scaler.mIonDriftTimeMS = mIonDriftTimeMS;
41 scaler.mTimeStampMS = (startTimeMS <= 0) ? mTimeStampMS : startTimeMS;
42 scaler.mIntegrationTimeMS = mIntegrationTimeMS;
44 const int dataIdx = (startTimeMS <= 0) ? 0 : getDataIdx(startTimeMS);
45 const int idxDataStart = (startTimeMS <= 0) ? 0 : dataIdx;
48 scaler.mScalerA = std::vector<float>(mScalerA.begin() + idxDataStart, mScalerA.begin() + idxDataEndA);
49 scaler.mScalerC = std::vector<float>(mScalerC.begin() + idxDataStart, mScalerC.begin() + idxDataEndC);
56 LOGP(error,
"Number of points stored for A-side and C-side is different");
59 const long marginCCDBMS = marginCCDBMinutes * 60 * 1000;
60 const float msPerObjectTmp = minutesPerObject * 60 * 1000;
61 const int valuesPerSlice =
static_cast<int>(msPerObjectTmp / mIntegrationTimeMS);
62 const int marginPerSlice =
static_cast<int>(marginMS / mIntegrationTimeMS);
65 LOGP(info,
"Producing {} objects with a CCDB margin of {} ms and {} margin per slice", nSlices, marginCCDBMS, marginPerSlice);
70 for (
int i = 0;
i < nSlices; ++
i) {
71 const int idxDataStart = (
i == 0) ? 0 : (
i * valuesPerSlice - marginPerSlice);
72 int idxDataEnd = (
i == nSlices - 1) ?
getNValues(
Side::A) : ((
i + 1) * valuesPerSlice + marginPerSlice);
78 scaler.mIonDriftTimeMS = mIonDriftTimeMS;
80 scaler.mTimeStampMS = (
i == 0) ? mTimeStampMS : (mTimeStampMS + idxDataStart *
static_cast<double>(mIntegrationTimeMS));
82 scaler.mIntegrationTimeMS = mIntegrationTimeMS;
83 scaler.mScalerA = std::vector<float>(mScalerA.begin() + idxDataStart, mScalerA.begin() + idxDataEnd);
84 scaler.mScalerC = std::vector<float>(mScalerC.begin() + idxDataStart, mScalerC.begin() + idxDataEnd);
86 const long timePerSliceMS = valuesPerSlice * mIntegrationTimeMS;
87 const long tsCCDBStart = mTimeStampMS +
i * timePerSliceMS;
88 const long tsCCDBStartMargin = (
i == 0) ? (tsCCDBStart - marginCCDBMS) : tsCCDBStart;
90 const std::string fileOut = fmt::format(
"{}_{}_{}_{}.root",
file,
i, tsCCDBStartMargin, tsCCDBEnd);
97 TFile out(inpf,
"READ");
105 tpcScalerTree.SetBranchAddress(
"TPCScaler", &scalerTmp);
106 const int entries = tpcScalerTree.GetEntries();
108 tpcScalerTree.GetEntry(0);
110 LOGP(error,
"TPCScaler not found in input file");
112 tpcScalerTree.SetBranchAddress(
"TPCScaler",
nullptr);
118 const int idxData = getDataIdx(timestamp);
121 if ((nVals == 0) || (nVals > nValues)) {
123 LOGP(error,
"Empty data provided {}", nValues);
127 const int lastIdx = std::clamp(idxData, nVals, nValues);
128 const int firstIdx = (lastIdx == nValues) ? (nValues - nVals) : std::clamp(idxData - nVals, 0, nValues);
134 for (
int i = firstIdx;
i < lastIdx; ++
i) {
137 const double relTSMS = mTimeStampMS +
i * mIntegrationTimeMS - timestamp;
152 const int idx = idxF;
153 if ((idx < 0) || (idx >
mWeights.size() - 1)) {
159 if ((idxF == idx) || (idx ==
mWeights.size() - 1)) {
166 const float x0 = idx;
167 const float x1 = idx + 1;
168 const float x = idxF;
177 std::transform(std::begin(scaler), std::end(scaler), std::begin(scaler), [minThreshold, maxThreshold](
auto val) {
return std::clamp(
val, minThreshold, maxThreshold); });
Header to collect LHC related constants.
int getNValuesIonDriftTime() const
void dumpToFileSlices(const char *file, const char *name, int minutesPerObject, float marginMS=500, float marginCCDBMinutes=1)
float getScalers(unsigned int idx, o2::tpc::Side side) const
float getMeanScaler(double timestamp, o2::tpc::Side side) const
int getNValues(o2::tpc::Side side) const
void loadFromFile(const char *inpf, const char *name)
void clampScalers(float minThreshold, float maxThreshold, Side side)
double getEndTimeStampMS(o2::tpc::Side side) const
void dumpToFile(const char *file, const char *name)
void useWeights(bool useWeights)
enable usage of weights
void setFromTree(TTree &tpcScalerTree)
set this object from input tree
const auto & getScalerWeights() const
GLuint GLfloat GLfloat GLfloat GLfloat y1
GLuint GLfloat GLfloat GLfloat x1
GLuint const GLchar * name
GLuint GLuint GLfloat weight
GLuint GLfloat GLfloat y0
constexpr double LHCOrbitMUS
Global TPC definitions and constants.
DataT sum(const Vector< DataT, N > &a)
float mSamplingTimeMS
sampling of the stored weights
std::vector< float > mWeights
stored weights
float mFirstTimeStampMS
first timestamp
float getWeight(float deltaTime) const
std::unique_ptr< TTree > tree((TTree *) flIn.Get(std::string(o2::base::NameConf::CTFTREENAME).c_str()))