"left_upstream","right_downstream","right_upstream"};\r
\r
//___________________________________________________________________\r
-AliLHCData::AliLHCData(const TMap* dcsMap, double tmin, double tmax, Bool_t ignoreSOR,Bool_t ignoreEOR)\r
+AliLHCData::AliLHCData(const TMap* dcsMap, double tmin, double tmax)\r
: fTMin(0),fTMax(0),fFillNumber(0),fData(0),fFile2Process(0),fMap2Process(0)\r
{\r
- SetIgnoreSOR(ignoreSOR);\r
- SetIgnoreEOR(ignoreEOR);\r
FillData(dcsMap,tmin,tmax);\r
}\r
\r
//___________________________________________________________________\r
-AliLHCData::AliLHCData(const Char_t* dcsFile, double tmin, double tmax, Bool_t ignoreSOR,Bool_t ignoreEOR)\r
+AliLHCData::AliLHCData(const Char_t* dcsFile, double tmin, double tmax)\r
: fTMin(0),fTMax(0),fFillNumber(0),fData(0),fFile2Process(dcsFile),fMap2Process(0)\r
{\r
- SetIgnoreSOR(ignoreSOR);\r
- SetIgnoreEOR(ignoreEOR);\r
FillData(dcsFile,tmin,tmax);\r
}\r
\r
SetTMax(tmax);\r
//\r
// -------------------------- extract Fill Number\r
- int iEntry;\r
- if (IsSORIgnored()) tmin -= kTimeMargin;\r
- if (IsSORIgnored()) tmax += kTimeMargin;\r
- TObjArray* arr = GetDCSEntry(fgkDCSNames[kFillNum],iEntry,tmin,tmax);\r
- if (arr) SetFillNumber( ExtractInt( (AliDCSArray*)arr->At(iEntry), 0) );\r
+ int iFirst=0,iLast=0;\r
+ TObjArray* arr = GetDCSEntry(fgkDCSNames[kFillNum],iFirst,iLast,fTMin,fTMax);\r
+ if (arr) SetFillNumber( ExtractInt( (AliDCSArray*)arr->At(iFirst), 0) );\r
if (fFile2Process) delete arr; // array was created on demand\r
//\r
for (int ibm=0;ibm<2;ibm++) {\r
}\r
\r
//___________________________________________________________________\r
-TObjArray* AliLHCData::GetDCSEntry(const char* key,int &entry,double tmin,double tmax) const\r
+TObjArray* AliLHCData::GetDCSEntry(const char* key,int &entry,int &last,double tmin,double tmax) const\r
{\r
// extract array from the DCS map or file and find the first entry within the time limits\r
entry = -1;\r
+ last = -2;\r
TObjArray* arr;\r
if (fMap2Process) arr = (TObjArray*)fMap2Process->GetValue(key);\r
else if (fFile2Process) {\r
return 0;\r
}\r
int ntot = arr->GetEntriesFast();\r
+ //\r
+ // search 1st entry before or at tmin\r
+ AliDCSArray* ent = 0;\r
+ Bool_t found = kFALSE;\r
for (entry=0;entry<ntot;entry++) {\r
- AliDCSArray* ent = (AliDCSArray*)arr->At(entry);\r
- if (ent->GetTimeStamp()>=tmin && ent->GetTimeStamp()<=tmax) break;\r
+ ent = (AliDCSArray*)arr->At(entry);\r
+ if (ent->GetTimeStamp()>=tmin-kMarginSOR && ent->GetTimeStamp()<=tmax+kMarginEOR) {\r
+ found = kTRUE;\r
+ if (ent->GetTimeStamp()>tmin) break;\r
+ }\r
}\r
- if (entry==ntot) {\r
+ if (!found) {\r
entry = -1;\r
TString str;\r
str += AliLHCDipValD::TimeAsString(tmin);\r
if (fMap2Process) delete arr; // created on demand\r
return 0;\r
}\r
+ if (entry>0) entry--;\r
+ //\r
+ // search last entry at or after tmin\r
+ ent = 0;\r
+ for (last=entry;last<ntot;last++) {\r
+ ent = (AliDCSArray*)arr->At(last);\r
+ if (ent->GetTimeStamp()>tmax) break;\r
+ }\r
+ if (last == ntot) last--;\r
+ else if (ent->GetTimeStamp()>tmax+kMarginEOR) last--;\r
+ //\r
return arr;\r
}\r
\r
AliInfo(Form("Acquiring record: %s",rec));\r
//\r
TObjArray *arr=0,*arrE=0;\r
- Int_t nEntries=0,nEntriesE=0,iEntry=0,iEntryE=0;\r
+ Int_t iLast=0,iLastE=0,iFirst=0,iFirstE=0;\r
//\r
refs[kStart] = fData.GetEntriesFast();\r
refs[kNStor] = 0;\r
//\r
- double tmin = fTMin;\r
- double tmax = fTMax;\r
- if (IsSORIgnored()) tmin -= kTimeMargin;\r
- if (IsSORIgnored()) tmax += kTimeMargin;\r
- //\r
- if ( !(arr=GetDCSEntry(rec,iEntry,tmin,tmax)) ) return -1;\r
- nEntries = arr->GetEntriesFast();\r
+ if ( !(arr=GetDCSEntry(rec,iFirst,iLast,fTMin,fTMax)) ) return -1;\r
//\r
int dim = 1;\r
if (recErr) {\r
- if ( !(arrE=GetDCSEntry(recErr,iEntryE,tmin,tmax)) ) nEntriesE = -999;\r
- else nEntriesE = arrE->GetEntriesFast();\r
+ arrE = GetDCSEntry(recErr,iFirstE,iLastE,fTMin,fTMax);\r
dim += 1;\r
}\r
//\r
- while (iEntry<nEntries) {\r
- AliDCSArray *dcsVal = (AliDCSArray*) arr->At(iEntry++);\r
+ Bool_t last = kFALSE;\r
+ while (iFirst<=iLast) {\r
+ AliDCSArray *dcsVal = (AliDCSArray*) arr->At(iFirst++);\r
double tstamp = dcsVal->GetTimeStamp();\r
- if (tstamp>fTMax) break;\r
//\r
AliLHCDipValF* curValF = new AliLHCDipValF(dim,tstamp); // start new period\r
(*curValF)[0] = ExtractDouble(dcsVal,0); // value\r
//\r
if (recErr) {\r
double errVal = -1;\r
- while (iEntryE<nEntriesE) { // try to find corresponding error\r
- AliDCSArray *dcsValE = (AliDCSArray*) arrE->At(iEntryE);\r
+ while (iFirstE<=iLastE) { // try to find corresponding error\r
+ AliDCSArray *dcsValE = (AliDCSArray*) arrE->At(iFirstE);\r
double tstampE = dcsValE->GetTimeStamp();\r
- if (tstampE>fTMax) break;\r
int tdif = TimeDifference(tstamp,tstampE);\r
if (!tdif) { // error matches to value\r
errVal = ExtractDouble(dcsValE,0);\r
- iEntryE++; \r
+ iFirstE++; \r
break;\r
}\r
- else if (tdif>0) iEntryE++; // error time lags behind, read the next one\r
+ else if (tdif>0) iFirstE++; // error time lags behind, read the next one\r
else break; // error time is ahead of value, no error associated\r
}\r
(*curValF)[dim-1] = errVal; // error\r
//\r
fData.Add(curValF);\r
refs[kNStor]++;\r
+ if (last) break;\r
}\r
//\r
if (fFile2Process) {\r
//\r
AliInfo(Form("Acquiring record: %s",rec));\r
TObjArray *arr;\r
- Int_t nEntries,iEntry;\r
+ Int_t iLast,iFirst;\r
//\r
refs[kStart] = fData.GetEntriesFast();\r
refs[kNStor] = 0;\r
//\r
- double tmin = fTMin;\r
- double tmax = fTMax;\r
- if (IsSORIgnored()) tmin -= kTimeMargin;\r
- if (IsSORIgnored()) tmax += kTimeMargin;\r
- //\r
- if ( !(arr=GetDCSEntry(rec,iEntry,tmin,tmax)) ) return -1;\r
- nEntries = arr->GetEntriesFast();\r
+ if ( !(arr=GetDCSEntry(rec,iFirst,iLast,fTMin,fTMax)) ) return -1;\r
//\r
AliLHCDipValI* prevRecI=0;\r
- while (iEntry<nEntries) {\r
- AliDCSArray *dcsVal = (AliDCSArray*) arr->At(iEntry++);\r
+ // \r
+ while (iFirst<=iLast) {\r
+ AliDCSArray *dcsVal = (AliDCSArray*) arr->At(iFirst++);\r
double tstamp = dcsVal->GetTimeStamp();\r
- if (tstamp>fTMax) break;\r
//\r
int bucket=0, nbunch=0, ndiff=0;\r
int nSlots = dcsVal->GetNEntries(); // count number of actual bunches (non-zeros)\r
//\r
AliInfo(Form("Acquiring record: %s",rec));\r
TObjArray *arr;\r
- Int_t nEntries,iEntry;\r
+ Int_t iLast,iFirst;\r
//\r
refs[kStart] = fData.GetEntriesFast();\r
refs[kNStor] = 0;\r
//\r
- double tmin = fTMin;\r
- double tmax = fTMax;\r
- if (IsSORIgnored()) tmin -= kTimeMargin;\r
- if (IsSORIgnored()) tmax += kTimeMargin;\r
- //\r
- if ( !(arr=GetDCSEntry(rec,iEntry,tmin,tmax)) ) return -1;\r
- nEntries = arr->GetEntriesFast();\r
+ if ( !(arr=GetDCSEntry(rec,iFirst,iLast,fTMin,fTMax)) ) return -1;\r
//\r
AliLHCDipValI* prevRecI=0;\r
- while (iEntry<nEntries) {\r
- AliDCSArray *dcsVal = (AliDCSArray*) arr->At(iEntry++);\r
+ while (iFirst<=iLast) {\r
+ AliDCSArray *dcsVal = (AliDCSArray*) arr->At(iFirst++);\r
double tstamp = dcsVal->GetTimeStamp();\r
- if (tstamp>fTMax) break;\r
//\r
int nSlots = dcsVal->GetNEntries();\r
if (nSlots<1) continue;\r
AliInfo(Form("Acquiring record: %s",rec));\r
TString prevRec;\r
TObjArray *arr;\r
- Int_t nEntries,iEntry;\r
+ Int_t iLast,iFirst;\r
//\r
refs[kStart] = fData.GetEntriesFast();\r
refs[kNStor] = 0;\r
//\r
- double tmin = fTMin;\r
- double tmax = fTMax;\r
- if (IsSORIgnored()) tmin -= kTimeMargin;\r
- if (IsSORIgnored()) tmax += kTimeMargin;\r
- //\r
- if ( !(arr=GetDCSEntry(rec,iEntry,tmin,tmax)) ) return -1;\r
- nEntries = arr->GetEntriesFast();\r
+ if ( !(arr=GetDCSEntry(rec,iFirst,iLast,fTMin,fTMax)) ) return -1;\r
//\r
- while (iEntry<nEntries) {\r
- AliDCSArray *dcsVal = (AliDCSArray*) arr->At(iEntry++);\r
+ while (iFirst<=iLast) {\r
+ AliDCSArray *dcsVal = (AliDCSArray*) arr->At(iFirst++);\r
double tstamp = dcsVal->GetTimeStamp();\r
- if (tstamp>fTMax) break;\r
//\r
TString &str = ExtractString(dcsVal);\r
if (!prevRec.IsNull()) {if (str == prevRec) continue;} // skip similar record\r
//\r
AliInfo(Form("Acquiring record: %s",rec));\r
TObjArray *arr;\r
- Int_t nEntries,iEntry;\r
+ Int_t iLast,iFirst;\r
//\r
refs[kStart] = fData.GetEntriesFast();\r
refs[kNStor] = 0;\r
//\r
- double tmin = fTMin;\r
- double tmax = fTMax;\r
- if (IsSORIgnored()) tmin -= kTimeMargin;\r
- if (IsSORIgnored()) tmax += kTimeMargin;\r
+ if ( !(arr=GetDCSEntry(rec,iFirst,iLast,fTMin,fTMax)) ) return -1;\r
//\r
- if ( !(arr=GetDCSEntry(rec,iEntry,tmin,tmax)) ) return -1;\r
- nEntries = arr->GetEntriesFast();\r
- //\r
- while (iEntry<nEntries) {\r
- AliDCSArray *dcsVal = (AliDCSArray*) arr->At(iEntry++);\r
+ while (iFirst<=iLast) {\r
+ AliDCSArray *dcsVal = (AliDCSArray*) arr->At(iFirst++);\r
double tstamp = dcsVal->GetTimeStamp();\r
- if (tstamp>fTMax) break;\r
//\r
AliLHCDipValI *bconf = GetBunchConfigMeasured(ibm,tstamp);\r
if (!bconf) {\r
//\r
AliInfo(Form("Acquiring record: %s",rec));\r
TObjArray *arr,*arrE=0;\r
- Int_t nEntries=0,nEntriesE=0,iEntry=0,iEntryE=0;\r
+ Int_t iLast=0,iLastE=0,iFirst=0,iFirstE=0;\r
//\r
refs[kStart] = fData.GetEntriesFast();\r
refs[kNStor] = 0;\r
//\r
- double tmin = fTMin;\r
- double tmax = fTMax;\r
- if (IsSORIgnored()) tmin -= kTimeMargin;\r
- if (IsSORIgnored()) tmax += kTimeMargin;\r
- //\r
- if ( !(arr=GetDCSEntry(rec,iEntry,tmin,tmax)) ) return -1;\r
- nEntries = arr->GetEntriesFast();\r
+ if ( !(arr=GetDCSEntry(rec,iFirst,iLast,fTMin,fTMax)) ) return -1;\r
//\r
- while (iEntry<nEntries) {\r
- AliDCSArray *dcsVal = (AliDCSArray*) arr->At(iEntry++);\r
+ while (iFirst<=iLast) {\r
+ AliDCSArray *dcsVal = (AliDCSArray*) arr->At(iFirst++);\r
double tstamp = dcsVal->GetTimeStamp();\r
- if (tstamp>fTMax) break;\r
//\r
AliLHCDipValI *bconf;\r
bconf = GetBunchConfigMeasured(useBeam,tstamp); // luminosities are stored according to beam bunches\r
}\r
//\r
if (recErr) {\r
- if ( !(arrE=GetDCSEntry(recErr,iEntryE,tmin,tmax)) || iEntryE<0 ) nEntriesE = -999;\r
- else nEntriesE = arrE->GetEntriesFast();\r
+ arrE=GetDCSEntry(recErr,iFirstE,iLastE,fTMin,fTMax);\r
dim += 1;\r
}\r
AliLHCDipValF* curValF = new AliLHCDipValF(dim,tstamp);\r
//\r
if (recErr) {\r
double errVal = -1;\r
- while (iEntryE<nEntriesE) { // try to find corresponding error\r
- AliDCSArray *dcsValE = (AliDCSArray*) arrE->At(iEntryE);\r
+ while (iFirstE<=iLastE) { // try to find corresponding error\r
+ AliDCSArray *dcsValE = (AliDCSArray*) arrE->At(iFirstE);\r
double tstamp1 = dcsValE->GetTimeStamp();\r
- if (tstamp1>fTMax) break;\r
int tdif = TimeDifference(tstamp,tstamp1);\r
if (!tdif) { // error matches to value\r
errVal = dcsValE->GetDouble()[0];\r
- iEntryE++; \r
+ iFirstE++; \r
break;\r
}\r
- else if (tdif>0) iEntryE++; // error time lags behind, read the next one\r
+ else if (tdif>0) iFirstE++; // error time lags behind, read the next one\r
else break; // error time is ahead of value, no error associated\r
}\r
(*curValF)[dim-1] = errVal; // error\r
if (!opts.Contains("f")) {\r
printf("Use Print(\"f\") to print full info\n");\r
printf("Printing short info:\n<RecordType>(number of records): <TimeStamp, value> for 1st record only\n");\r
- printf("Ignoring strict time of SOR: %s, EOR: %s\n",IsSORIgnored()?"ON":"OFF",IsEORIgnored()?"ON":"OFF");\r
full = kFALSE;\r
}\r
TString sdtmn = AliLHCDipValI::TimeAsString(fTMin,utcTime);\r
enum Collim_t {kTCTVB4L2, kTCTVB4R2, kTCLIA4R2, kNCollimators};\r
enum ColJaw_t {kGapDn,kGapUp,kLeftDn,kLeftUp,kRightDn,kRightUp,kNJaws};\r
enum {kMaxBSlots = 3564};\r
- enum {kIgnoreSOR = BIT(14), // if set: take all values with t>=SOR - margin, otherwise t>=SOR\r
- kIgnoreEOR = BIT(15), // if set: take all values with t>=EOR + margin, otherwise t<=EOR\r
- kTimeMargin = 60*60*24*30}; // use margin of 30 days\r
+ enum {kMarginSOR = 60*60*24*30, // use margin of 30 days for SOR, when looking for the 1st record\r
+ kMarginEOR = 60*15}; // use margin of 15 min for EOR, when looking for the last record\r
//\r
enum {kIntTot,kIntTotAv,kIntBunchAv,\r
kLumAcqMode,kLumTot,kLumTotErr,kLumBunch,kLumBunchErr,kLumCrossAng,kLumCrossAngErr,\r
public:\r
//\r
AliLHCData() : fTMin(0),fTMax(1e10),fFillNumber(0),fData(0),fFile2Process(0),fMap2Process(0) {Clear();}\r
- AliLHCData(const TMap* dcsMap, double tmin=0, double tmax=1.e10, Bool_t ignoreSOR=kTRUE,Bool_t ignoreEOR=kTRUE);\r
- AliLHCData(const Char_t* dcsFile, double tmin=0, double tmax=1.e10, Bool_t ignoreSOR=kTRUE,Bool_t ignoreEOR=kTRUE);\r
+ AliLHCData(const TMap* dcsMap, double tmin=0, double tmax=1.e10);\r
+ AliLHCData(const Char_t* dcsFile, double tmin=0, double tmax=1.e10);\r
virtual ~AliLHCData() {}\r
//\r
Bool_t FillData(const TMap* dcsMap, double tmin=0, double tmax=1.e20);\r
Bool_t FillData(const Char_t* dcsFile, double tmin=0, double tmax=1.e20);\r
Double_t GetTMin() const {return fTMin;}\r
Double_t GetTMax() const {return fTMax;}\r
- Bool_t IsSORIgnored() const {return TestBit(kIgnoreSOR);}\r
- Bool_t IsEORIgnored() const {return TestBit(kIgnoreEOR);}\r
Int_t GetFillNumber() const {return fFillNumber;}\r
void SetFillNumber(Int_t fill) {fFillNumber = fill;}\r
void SetTMin(Double_t t) {fTMin = t<0?0:(t>1e10?1e10:t);}\r
void SetTMax(Double_t t) {fTMax = t<0?0:(t>1e10?1e10:t);}\r
- void SetIgnoreSOR(Bool_t v=kTRUE) {SetBit(kIgnoreSOR,v);}\r
- void SetIgnoreEOR(Bool_t v=kTRUE) {SetBit(kIgnoreEOR,v);}\r
//\r
virtual void Print(const Option_t *opt="") const;\r
//\r
Bool_t FillData(double tmin=0, double tmax=1.e20);\r
virtual void Clear(const Option_t *opt="");\r
void PrintAux(Bool_t full,const Int_t refs[2],const Option_t *opt="") const;\r
- TObjArray* GetDCSEntry(const char* key,int &entry,double tmin,double tmax) const;\r
+ TObjArray* GetDCSEntry(const char* key,int &entry,int &last,double tmin,double tmax) const;\r
Int_t FillScalarRecord( int refs[2], const char* rec, const char* recErr=0);\r
Int_t FillBunchConfig( int refs[2], const char* rec);\r
Int_t FillStringRecord( int refs[2], const char* rec);\r