3030#include <iostream>
3131#endif
3232using namespace o2 ::ctp ;
33- void PlotPbLumi (int runNumber = 567905 , bool qc = 0 )
33+ void PlotPbLumi (int runNumber = 567905 , bool sum = 0 , bool qc = 0 , Double_t t0 = 0. , Double_t tlast = 0. )
3434{ //
3535 // PLots in one canvas
3636 // znc rate/28
@@ -48,7 +48,7 @@ void PlotPbLumi(int runNumber = 567905, bool qc = 0)
4848 std ::cout << "Timestamp:" << timeStamp << std ::endl ;
4949 // Filling
5050 auto lhcifdata = ccdbMgr .getForRun < o2 ::parameters ::GRPLHCIFData > ("GLO/Config/GRPLHCIF" , runNumber );
51- // auto lhcifdata = ccdbMgr.getSpecific<o2::parameters::GRPLHCIFData>("GLO/Config/GRPLHCIF", timeStamp, metadata);
51+ //auto lhcifdata = ccdbMgr.getSpecific<o2::parameters::GRPLHCIFData>("GLO/Config/GRPLHCIF", timeStamp, metadata);
5252 if (!lhcifdata ) {
5353 throw std ::runtime_error ("No GRPLHCIFData for run " + std ::to_string (runNumber ));
5454 }
@@ -61,7 +61,7 @@ void PlotPbLumi(int runNumber = 567905, bool qc = 0)
6161 std ::map < string , string > metadata ;
6262 metadata ["runNumber" ] = srun ;
6363 CTPRunScalers * scl = nullptr ;
64- if (qc ) {
64+ if (qc ) {
6565 ccdbMgr .setURL ("http://ali-qcdb-gpn.cern.ch:8083" );
6666 scl = ccdbMgr .getSpecific < CTPRunScalers > (mCCDBPathCTPScalersQC , timeStamp , metadata );
6767 } else {
@@ -138,21 +138,39 @@ void PlotPbLumi(int runNumber = 567905, bool qc = 0)
138138 double_t orbit0 = recs [0 ].intRecord .orbit ;
139139 int n = recs .size () - 1 ;
140140 std ::cout << " Run duration:" << Trun << " Scalers size:" << n + 1 << std ::endl ;
141- // Double_t x[n], znc[n], zncpp[n];
141+ //
142+ int i0 = 0 ;
143+ int ilast = 0 ;
144+ if (t0 != 0. || tlast != 0. ) {
145+ for (int i = 0 ; i < n ; i ++ ){
146+ double_t ttime = recs [i ].epochTime - time0 ;
147+ if (!i0 && t0 < ttime ) {
148+ i0 = i ;
149+ }
150+ if (!ilast && tlast < ttime ) {
151+ ilast = i ;
152+ }
153+ }
154+ } else {
155+ ilast = n ;
156+ }
157+ n = ilast - i0 ;
158+ std ::cout << "i0:" << i0 << " ilast:" << ilast << std ::endl ;
159+ //Double_t x[n], znc[n], zncpp[n];
142160 std ::vector < Double_t > xvec (n ), zncvec (n ), zncppvec (n ), zncclassvec (n );
143- Double_t * x = xvec .data ();
144- Double_t * znc = zncvec .data ();
145- Double_t * zncpp = zncppvec .data ();
146- Double_t * zncclass = zncclassvec .data ();
147- // Double_t tcetsctoznc[n], tcetoznc[n], vchtoznc[n];
161+ Double_t * x = xvec .data ();
162+ Double_t * znc = zncvec .data ();
163+ Double_t * zncpp = zncppvec .data ();
164+ Double_t * zncclass = zncclassvec .data ();
165+ //Double_t tcetsctoznc[n], tcetoznc[n], vchtoznc[n];
148166 std ::vector < Double_t > tcetsctozncvec (n ), tcetozncvec (n ), vchtozncvec (n );
149- Double_t * tcetsctoznc = tcetsctozncvec .data ();
150- Double_t * tcetoznc = tcetozncvec .data ();
151- Double_t * vchtoznc = vchtozncvec .data ();
152- bool sum = 0 ;
153- for ( int i = 0 ; i < n ; i ++ ) {
154- x [i ] = (double_t )(recs [i + 1 ].intRecord .orbit + recs [i ].intRecord .orbit ) / 2. - orbit0 ;
155- x [i ] *= 88e-6 ;
167+ Double_t * tcetsctoznc = tcetsctozncvec .data ();
168+ Double_t * tcetoznc = tcetozncvec .data ();
169+ Double_t * vchtoznc = vchtozncvec .data ();
170+ for ( int i = i0 ; i < ilast ; i ++ ) {
171+ int iv = i - i0 ;
172+ x [iv ] = (double_t )(recs [i + 1 ].intRecord .orbit + recs [i ].intRecord .orbit ) / 2. - orbit0 ;
173+ x [iv ] *= 88e-6 ;
156174 // x[i] = (double_t)(recs[i+1].epochTime + recs[i].epochTime)/2.;
157175 double_t tt = (double_t )(recs [i + 1 ].intRecord .orbit - recs [i ].intRecord .orbit );
158176 tt = tt * 88e-6 ;
@@ -161,37 +179,37 @@ void PlotPbLumi(int runNumber = 567905, bool qc = 0)
161179 double_t znci = (double_t )(recs [i + 1 ].scalersInps [25 ] - recs [i ].scalersInps [25 ]);
162180 double_t mu = - TMath ::Log (1. - znci / tt / nbc / frev );
163181 double_t zncipp = mu * nbc * frev ;
164- zncpp [i ] = zncipp / 28. ;
165- znc [i ] = znci / 28. / tt ;
182+ zncpp [iv ] = zncipp / 28. ;
183+ znc [iv ] = znci / 28. / tt ;
166184 // znc class
167185 znci = recs [i + 1 ].scalers [zncclsi ].l1Before - recs [i ].scalers [zncclsi ].l1Before ;
168- zncclass [i ] = znci / 28. / tt ;
169- // std::cout << znc[i]/zncclass[i] << std::endl;
186+ zncclass [iv ] = znci / 28. /tt ;
187+ //std::cout << znc[i]/zncclass[i] << std::endl;
170188 //
171189 double_t had = 0 ;
172- if (sum ) {
190+ if (sum ) {
173191 had += recs [i + 1 ].scalers [tce ].lmBefore - recs [i ].scalers [tce ].lmBefore ;
174192 }
175193 double_t mutce = - TMath ::Log (1. - had / tt / nbc / frev );
176194 // std::cout << recs[i+1].scalers[tce].lmBefore << std::endl;
177195 had += recs [i + 1 ].scalers [tsc ].lmBefore - recs [i ].scalers [tsc ].lmBefore ;
178196 // rat = (double_t)(had)/double_t(recs[i+1].scalersInps[25] - recs[i].scalersInps[25])*28;
179- tcetsctoznc [i ] = (double_t )(had ) / zncpp [i ] / tt ;
197+ tcetsctoznc [iv ] = (double_t )(had ) / zncpp [iv ] / tt ;
180198 had = recs [i + 1 ].scalers [tce ].lmBefore - recs [i ].scalers [tce ].lmBefore ;
181199 // rat = (double_t)(had)/double_t(recs[i+1].scalersInps[25] - recs[i].scalersInps[25])*28;
182- tcetoznc [i ] = (double_t )(had ) / zncpp [i ] / tt ;
200+ tcetoznc [iv ] = (double_t )(had ) / zncpp [iv ] / tt ;
183201 had = recs [i + 1 ].scalers [vch ].lmBefore - recs [i ].scalers [vch ].lmBefore ;
184202 double_t muvch = - TMath ::Log (1. - had / tt / nbc / frev );
185203
186204 // rat = (double_t)(had)/double_t(recs[i+1].scalersInps[25] - recs[i].scalersInps[25])*28;
187- vchtoznc [i ] = (double_t )(had ) / zncpp [i ] / tt ;
188- // std::cout << "muzdc:" << mu << " mu tce:" << mutce << " muvch:" << muvch << std::endl;
205+ vchtoznc [iv ] = (double_t )(had ) / zncpp [iv ] / tt ;
206+ //std::cout << "muzdc:" << mu << " mu tce:" << mutce << " muvch:" << muvch << std::endl;
189207 }
190208 //
191209 gStyle -> SetMarkerSize (0.5 );
192210 TGraph * gr1 = new TGraph (n , x , znc );
193- TGraph * gr11 = new TGraph (n , x , zncpp ); // PileuP corrected
194- TGraph * gr12 = new TGraph (n , x , zncclass ); // NOT PileuP corrected
211+ TGraph * gr11 = new TGraph (n , x , zncpp ); // PileuP corrected
212+ TGraph * gr12 = new TGraph (n , x , zncclass ); // NOT PileuP corrected
195213 TGraph * gr2 = new TGraph (n , x , tcetsctoznc );
196214 TGraph * gr3 = new TGraph (n , x , tcetoznc );
197215 TGraph * gr4 = new TGraph (n , x , vchtoznc );
@@ -204,7 +222,7 @@ void PlotPbLumi(int runNumber = 567905, bool qc = 0)
204222 gr3 -> SetMarkerStyle (23 );
205223 gr4 -> SetMarkerStyle (23 );
206224 gr11 -> SetTitle ("R=ZNC/28 rate [Hz] (red=PilUp Corrected); time[sec]; R" );
207- if (sum ) {
225+ if (sum ) {
208226 gr2 -> SetTitle ("R=(TSC+TCE)*TVTX*B*28/ZNC; time[sec]; R" );
209227 } else {
210228 gr2 -> SetTitle ("R=(TSC)*TVTX*B*28/ZNC; time[sec]; R" );
@@ -218,6 +236,8 @@ void PlotPbLumi(int runNumber = 567905, bool qc = 0)
218236 // gr4->GetHistogram()->SetMaximum(0.6);
219237 // gr4->GetHistogram()->SetMinimum(0.4);
220238 TCanvas * c1 = new TCanvas ("c1" , srun .c_str (), 200 , 10 , 800 , 500 );
239+ std ::string title = "RUN " + std ::to_string (runNumber );
240+ c1 -> SetTitle (title .c_str ());
221241 c1 -> Divide (2 , 2 );
222242 c1 -> cd (1 );
223243 gr11 -> Draw ("AP" );
0 commit comments