]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
Modification: from the values ahead of SOR (within margin=1month) take
authorshahoian <shahoian@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 26 Apr 2010 19:16:33 +0000 (19:16 +0000)
committershahoian <shahoian@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 26 Apr 2010 19:16:33 +0000 (19:16 +0000)
the latest, from those after EOR take the easliest (margin=15min)

STEER/AliLHCData.cxx
STEER/AliLHCData.h
STEER/AliLHCDipValT.h

index d9b3da3276f37a3dd4d48096759f4a5a37ce2d53..d85a31ee85f972a9f8bfb69d8a85e741d18e6ab2 100755 (executable)
@@ -94,20 +94,16 @@ const Char_t* AliLHCData::fgkDCSColJaws[] = {
   "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
@@ -143,11 +139,9 @@ Bool_t AliLHCData::FillData(double tmin, double tmax)
   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
@@ -227,10 +221,11 @@ Bool_t AliLHCData::FillData(double tmin, double tmax)
 }\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
@@ -248,11 +243,18 @@ TObjArray* AliLHCData::GetDCSEntry(const char* key,int &entry,double tmin,double
     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
@@ -262,6 +264,17 @@ TObjArray* AliLHCData::GetDCSEntry(const char* key,int &entry,double tmin,double
     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
@@ -323,47 +336,39 @@ Int_t AliLHCData::FillScalarRecord(int refs[2], const char* rec, const char* rec
   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
@@ -372,6 +377,7 @@ Int_t AliLHCData::FillScalarRecord(int refs[2], const char* rec, const char* rec
     //\r
     fData.Add(curValF);\r
     refs[kNStor]++;\r
+    if (last) break;\r
   }\r
   //\r
   if (fFile2Process) {\r
@@ -388,24 +394,18 @@ Int_t AliLHCData::FillBunchConfig(int refs[2],const char* rec)
   //\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
@@ -434,24 +434,17 @@ Int_t AliLHCData::FillAcqMode(int refs[2],const char* rec)
   //\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
@@ -476,23 +469,16 @@ Int_t AliLHCData::FillStringRecord(int refs[2],const char* rec)
   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
@@ -517,23 +503,16 @@ Int_t AliLHCData::FillBunchInfo(int refs[2],const char* rec, int ibm, Bool_t inR
   //\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
@@ -575,23 +554,16 @@ Int_t AliLHCData::FillBCLuminosities(int refs[2],const char* rec, const char* re
   //\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
@@ -621,8 +593,7 @@ Int_t AliLHCData::FillBCLuminosities(int refs[2],const char* rec, const char* re
     }\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
@@ -642,17 +613,16 @@ Int_t AliLHCData::FillBCLuminosities(int refs[2],const char* rec, const char* re
     //\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
@@ -744,7 +714,6 @@ void AliLHCData::Print(const Option_t* opt) const
   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
index 6aff32da30329e775efd72bde9b783f2d38ec647..c763af6b4bb5303e29bddd16f68c037128460b87 100755 (executable)
@@ -50,9 +50,8 @@ class AliLHCData : public TObject
   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
@@ -65,22 +64,18 @@ class AliLHCData : public TObject
  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
@@ -166,7 +161,7 @@ class AliLHCData : public TObject
   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
index 18c102e9d1642350040737ca7e3bf766fa231e53..c6ebfbebb499eb0b7fa6d700a28d8c9e8b4b9252 100755 (executable)
@@ -117,7 +117,7 @@ Char_t* AliLHCDipValT<Element>::TimeAsString(double t, Bool_t utc)
   static char buff[22];
   time_t tt = (time_t) t;
   struct tm *time = utc ? gmtime(&tt) : localtime(&tt);
-  sprintf(buff,"%02d:%02d:%02d %02d/%02d/%04d",time->tm_hour,time->tm_min,time->tm_hour,
+  sprintf(buff,"%02d:%02d:%02d %02d/%02d/%04d",time->tm_hour,time->tm_min,time->tm_sec,
          time->tm_mday,time->tm_mon+1,time->tm_year+1900);
   return (char*)buff;
 }