22#define MAX_NUM_EVENT_AUTODETECT 10000
28std::vector<int> Utils::mFillScheme;
29int Utils::mBCmult[o2::constants::lhc::LHCMaxBunches];
30int Utils::mNautodet = 0;
32bool Utils::mIsInit =
false;
37int Utils::mNCalibTracks = 0;
39int Utils::mNsample = 0;
40int Utils::mIsample = 0;
41float Utils::mPhases[100];
46TChain* Utils::mTreeFit =
nullptr;
47std::vector<o2::dataformats::CalibInfoTOF> Utils::mVectC;
48std::vector<o2::dataformats::CalibInfoTOF>* Utils::mPvectC = &mVectC;
54 if (fromCollisonCotext) {
63 mFillScheme.push_back(
bc);
69 memset(mBCmult, 0, o2::constants::lhc::LHCMaxBunches *
sizeof(mBCmult[0]));
78 if (mNCalibTracks >= NTRACKS_REQUESTED) {
86 static std::vector<o2::dataformats::CalibInfoTOF>
tracks;
88 for (
int i = 0;
i < NTRACKS_REQUESTED;
i++) {
89 tracks.push_back(mCalibTracks[
i]);
94 if (evtime.mEventTimeError < 100) {
95 mPhases[mIsample] = evtime.mEventTime;
96 mIsample = (mIsample + 1) % 100;
103 for (
int i = 0;
i < mNsample;
i++) {
111 printf(
"FILL SCHEME\n");
119 return mFillScheme.size();
137 int bcOrbit =
bc % o2::constants::lhc::LHCMaxBunches;
139 int dbc = o2::constants::lhc::LHCMaxBunches, bcc =
bc;
140 int dbcSigned = 1000;
143 if (deltaCBC >= -8 && deltaCBC < 8) {
144 mask += (1 << (deltaCBC + 8));
146 if (std::abs(deltaCBC) < dbc) {
148 dbcSigned = deltaCBC;
149 dbc = std::abs(dbcSigned);
151 if (std::abs(deltaCBC + o2::constants::lhc::LHCMaxBunches) < dbc) {
152 bcc =
bc - deltaCBC - o2::constants::lhc::LHCMaxBunches;
153 dbcSigned = deltaCBC + o2::constants::lhc::LHCMaxBunches;
154 dbc = std::abs(dbcSigned);
156 if (std::abs(deltaCBC - o2::constants::lhc::LHCMaxBunches) < dbc) {
157 bcc =
bc - deltaCBC + o2::constants::lhc::LHCMaxBunches;
158 dbcSigned = deltaCBC - o2::constants::lhc::LHCMaxBunches;
159 dbc = std::abs(dbcSigned);
162 if (dbcSigned >= -8 && dbcSigned < 8) {
163 mask += (1 << (dbcSigned + 24));
186 int bcOrbit =
bc % o2::constants::lhc::LHCMaxBunches;
188 int dbc = o2::constants::lhc::LHCMaxBunches, bcc =
bc;
189 int dbcSigned = 1000;
192 if (deltaCBC >= -8 && deltaCBC < 8) {
193 mask += (1 << (deltaCBC + 8));
195 if (std::abs(deltaCBC) < dbc) {
197 dbcSigned = deltaCBC;
198 dbc = std::abs(dbcSigned);
200 if (std::abs(deltaCBC + o2::constants::lhc::LHCMaxBunches) < dbc) {
201 bcc =
bc - deltaCBC - o2::constants::lhc::LHCMaxBunches;
202 dbcSigned = deltaCBC + o2::constants::lhc::LHCMaxBunches;
203 dbc = std::abs(dbcSigned);
205 if (std::abs(deltaCBC - o2::constants::lhc::LHCMaxBunches) < dbc) {
206 bcc =
bc - deltaCBC + o2::constants::lhc::LHCMaxBunches;
207 dbcSigned = deltaCBC - o2::constants::lhc::LHCMaxBunches;
208 dbc = std::abs(dbcSigned);
211 if (dbcSigned >= -8 && dbcSigned < 8) {
212 mask += (1 << (dbcSigned + 24));
229 int thres = mMaxBC / 2;
230 for (
int i = 0;
i < o2::constants::lhc::LHCMaxBunches;
i++) {
231 if (mBCmult[
i] > thres) {
255 if (mBCmult[
bc] > mMaxBC) {
256 mMaxBC = mBCmult[
bc];
272 int mask2 = (
mask >> 16);
277 for (
int ibit = 0; ibit < 16; ibit++) {
289 for (
int ibit = 0; ibit < 16; ibit++) {
291 mMaskBCchan[channel][ibit] +=
weight;
295 mMaskBCchanUsed[channel][ibit] +=
weight;
296 mMaskBCUsed[ibit] +=
weight;
308 for (
int ibit = 0; ibit < 16; ibit++) {
309 if (mMaskBC[ibit] >
val) {
321 for (
int ibit = 0; ibit < 16; ibit++) {
322 if (mMaskBCchan[channel][ibit] >
val) {
323 val = mMaskBCchan[channel][ibit];
332 if (!oldTS || !newTS) {
337 static auto fitFunc =
new TF1(
"fTOFfit",
"gaus", -5000, 5000);
339 fitFunc->SetParameter(0, 100);
340 fitFunc->SetParameter(1, 0);
341 fitFunc->SetParameter(2, 200);
347 mTreeFit =
new TChain(
"treeCollectedCalibInfo",
"treeCollectedCalibInfo");
349 auto retval = system(
"ls *collTOF*.root >listaCal");
351 FILE*
f = fopen(
"listaCal",
"r");
358 while (fscanf(
f,
"%s", namefile) == 1) {
359 mTreeFit->AddFile(namefile);
362 if (!mTreeFit->GetEntries()) {
366 mTreeFit->SetBranchAddress(
"TOFCollectedCalibInfo", &mPvectC);
368 for (
int isec = 0; isec < 18; isec++) {
378 for (
int i =
sector * nchPerSect;
i < (
sector + 1) * nchPerSect;
i += NCHPERBUNCH) {
386 TH2F*
h[NCHPERBUNCH];
389 int bcSel[NCHPERBUNCH];
391 for (
int ii = 0; ii < NCHPERBUNCH; ii++) {
392 h[ii] =
new TH2F(Form(
"h%d", chStart + ii),
"", 1000, 0, 100, 100, -5000, 5000);
396 for (
int i = chStart;
i + NCHPERBUNCH < mTreeFit->GetEntries();
i += 157248) {
397 for (
int ii = 0; ii < NCHPERBUNCH; ii++) {
398 int ch = chStart + ii;
399 mTreeFit->GetEvent(
i + ii);
402 for (
auto& obj : mVectC) {
403 if (obj.getTOFChIndex() != ch || skip) {
406 time = obj.getDeltaTimePi();
408 mask = obj.getMask();
410 if (time < -5000 || time > 20000) {
414 if (tscorr < -1000000 || tscorr > 1000000) {
420 if (bcSel[ii] > -9000) {
425 while (
time < -5000) {
429 while (
time > 20000) {
437 }
else if (
time < -12500) {
441 h[ii]->Fill(tot,
time);
446 for (
int ii = 0; ii < NCHPERBUNCH; ii++) {
458 int sec = ch / nchPerSect;
459 int chInSec = ch % nchPerSect;
462 int nbinPrev = istop - istart;
465 unsigned short oldtot[10000];
466 short oldcorr[10000];
467 unsigned short newtot[10000];
468 short newcorr[10000];
472 const std::vector<std::pair<unsigned short, short>>& vect = oldTS->
getVector(sec);
473 for (
int i = istart;
i < istop;
i++) {
474 oldtot[
count] = vect[
i].first;
475 oldcorr[
count] = vect[
i].second;
479 TH1D* hpro =
h->ProjectionX(
"hpro");
482 int nbin =
h->GetXaxis()->GetNbins();
483 float integralToEnd =
h->Integral();
501 if (integralToEnd < NMINTOFIT) {
512 float totHalfWidth =
h->GetXaxis()->GetBinWidth(1) * 0.5;
514 static TF1* fitFunc =
new TF1(
"fTOFfit",
"gaus", -5000, 5000);
517 float x[10000],
y[10000];
518 for (
int i = 1;
i <= nbin;
i++) {
519 integral += hpro->GetBinContent(
i);
520 integralToEnd -= hpro->GetBinContent(
i);
522 if (integral < NMINTOFIT || (integralToEnd < NMINTOFIT &&
i < nbin)) {
527 float xmin =
h->GetXaxis()->GetBinCenter(ibin) - totHalfWidth;
528 float xmax =
h->GetXaxis()->GetBinCenter(
i) + totHalfWidth;
529 TH1D* hfit =
h->ProjectionY(Form(
"mypro"), ibin,
i);
530 float xref = hfit->GetBinCenter(hfit->GetMaximumBin());
532 hfit->Fit(fitFunc,
"QN0",
"", xref - 500, xref + 500);
535 x[np] = (xmin + xmax) * 0.5;
536 y[np] = fitFunc->GetParameter(1);
537 if (
x[np] > 65.534) {
540 newtot[np] =
x[np] * 1000;
#define MAX_NUM_EVENT_AUTODETECT
configStandalone Light OpenGL display display_light Apply smoothing to points Enable Z buffer Highlight links Highlight seeds Highlight sector tracks Highlight final tracks Show individual sector
Timeframe settings Average distance in cm of events merged into Randomize distance around average distance of merged events Simulate correct bunch interactions instead of placing only the average number of events A value[n] sets TFlen for[n] collisions in Number of bunches per trainsort Number of bunch trains Instantaneous interaction rate Do not simulate border Total number of collisions to be placed in the interior of all time Do not select random but walk over array of events in stride steps h Event generator settings h configStandalone Use CPU for GPU Force usage of the specified GPU device no CPU fallback Continue processing after an error First event to Number of events to Number of iterations to Number of iterations to Number of initial iterations excluded from const char Directory with events to Events directory is and not inside events Show standalone event Run event generator maximum time bin of continuous for triggered for automatic continuous for automatic continuous triggered uint64_t
std::vector< o2::its::TrackITS > tracks
Class for time synchronization of RawReader instances.
static constexpr Int_t NSECTORS
static constexpr Double_t BC_TIME_INPS
static constexpr Double_t BC_TIME_INPS_INV
static constexpr Int_t LATENCYWINDOW_IN_BC
static constexpr Int_t LATENCY_ADJ_LHC_IN_BC
static constexpr int NCHANNELS
static constexpr int BC_IN_ORBIT
static double subtractInteractionBC(double time, int &mask, bool subLatency=false)
static void fitTimeSlewing(int sector, const dataformats::CalibTimeSlewingParamTOF *oldTS, dataformats::CalibTimeSlewingParamTOF *newTS)
static void addBC(float toftime, bool subLatency=false)
static int extractNewTimeSlewing(const dataformats::CalibTimeSlewingParamTOF *oldTS, dataformats::CalibTimeSlewingParamTOF *newTS)
static void addCalibTrack(float time)
static int addMaskBC(int mask, int channel)
static void addInteractionBC(int bc, bool fromCollisonCotext=false)
static void fitChannelsTS(int chStart, const dataformats::CalibTimeSlewingParamTOF *oldTS, dataformats::CalibTimeSlewingParamTOF *newTS)
static void computeLHCphase()
static int getMaxUsedChannel(int channel)
static int getNinteractionBC()
static float mEventTimeSpread
static void printFillScheme()
static bool hasFillScheme()
static int getInteractionBC(int ibc)
static int fitSingleChannel(int ch, TH2F *h, const dataformats::CalibTimeSlewingParamTOF *oldTS, dataformats::CalibTimeSlewingParamTOF *newTS)
GLuint GLuint GLfloat weight
typedef void(APIENTRYP PFNGLCULLFACEPROC)(GLenum mode)