Jens Wiechula changes.
authormarian <marian@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 2 Oct 2009 14:49:16 +0000 (14:49 +0000)
committermarian <marian@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 2 Oct 2009 14:49:16 +0000 (14:49 +0000)
Mainly for visualization of the OCDB entries.

AliTPCcalibDB.cxx.diff                  Add TPC/Calib/TimeDrift and reference file creation funciton
AliTPCcalibDB.h.diff                    Add TPC/Calib/TimeDrift and reference file creation function
AliTPCcalibDButil.cxx.diff              Add comparison with reference data
AliTPCcalibDButil.h.diff                Add comparison with reference data
AliTPCCalibViewer.cxx.diff              Small fixes
AliTPCCalibViewerGUI.cxx.diff           Small fixes
AliTPCCalibViewerGUItime.cxx.diff       Add support for reference trees, add support for multiple graphs, small fixes
AliTPCCalibViewerGUItime.h.diff         Add support for reference trees, add support for multiple graphs, small fixes
AliTPCCalPad.cxx.diff                   Add sector variable to GlobalSidesFit
AliTPCConfigParser.cxx.diff             Small fix
CalibEnv.C.diff                         Add drift velocity, add comparison with referece, add iroc offset in CE fit
calibVarDescription.txt.diff            Add new variables

13 files changed:
TPC/AliTPCCalPad.cxx
TPC/AliTPCCalibRaw.cxx
TPC/AliTPCCalibViewer.cxx
TPC/AliTPCCalibViewerGUI.cxx
TPC/AliTPCCalibViewerGUItime.cxx
TPC/AliTPCCalibViewerGUItime.h
TPC/AliTPCConfigParser.cxx
TPC/AliTPCcalibDB.cxx
TPC/AliTPCcalibDB.h
TPC/AliTPCcalibDButil.cxx
TPC/AliTPCcalibDButil.h
TPC/CalibMacros/CalibEnv.C
TPC/CalibMacros/calibVarDescription.txt

index 4442489..2de44a5 100644 (file)
@@ -513,8 +513,10 @@ AliTPCCalPad* AliTPCCalPad::GlobalFit(const char* padName, AliTPCCalPad* PadOutl
 void AliTPCCalPad::GlobalSidesFit(const AliTPCCalPad* PadOutliers, const char* fitFormula, TVectorD &fitParamSideA, TVectorD &fitParamSideC,TMatrixD &covMatrixSideA, TMatrixD &covMatrixSideC, Float_t & chi2SideA, Float_t & chi2SideC, Double_t pointError, Bool_t robust, Double_t robustFraction){
   //
   // Performs a fit on both sides.
-  // Valid information for the fitFormula are the variables gx, gy, lx ,ly, meaning global x, global y, local x, local y value of the padName
-  //  eg. a formula might look 'gy' or 'gx ++ gy' or 'gx ++ gy ++ lx ++ lx^2' and so on
+  // Valid information for the fitFormula are the variables
+  // - gx, gy, lx ,ly: meaning global x, global y, local x, local y value of the padName
+  // - sector:         the sector number.
+  //  eg. a formula might look 'gy' or '(sector<36) ++ gy' or 'gx ++ gy' or 'gx ++ gy ++ lx ++ lx^2' and so on
   //
   // PadOutliers - pads with value !=0 are not used in fitting procedure
   // chi2Threshold: Threshold for chi2 when EvalRobust is called
@@ -547,6 +549,7 @@ void AliTPCCalPad::GlobalSidesFit(const AliTPCCalPad* PadOutliers, const char* f
     s.ReplaceAll("gy","[1]");
     s.ReplaceAll("lx","[2]");
     s.ReplaceAll("ly","[3]");
+    s.ReplaceAll("sector","[4]");
     arrFitFormulas->AddAt(new TFormula(Form("param%02d",idim),s.Data()),idim);
   }
   //loop over data and add points to the fitter
@@ -569,7 +572,7 @@ void AliTPCCalPad::GlobalSidesFit(const AliTPCCalPad* PadOutliers, const char* f
         //calculate parameter values
         for (Int_t idim=0;idim<ndim;++idim){
           TFormula *f=(TFormula*)arrFitFormulas->At(idim);
-          f->SetParameters(globalXYZ[0],globalXYZ[1],localXYZ[0],localXYZ[1]);
+          f->SetParameters(globalXYZ[0],globalXYZ[1],localXYZ[0],localXYZ[1],isec);
           parValues[idim]=f->Eval(0);
         }
         //get value
index a6fc724..6f8cbae 100644 (file)
@@ -307,7 +307,7 @@ TH2C *AliTPCCalibRaw::MakeHistL1RCUEvents(Int_t type)
   for (Int_t ircu=0; ircu<kNRCU; ++ircu){
     const TVectorF *v=GetALTROL1PhaseEventsRCU(ircu);
     if (!v) continue;
-    if (v->GetNrows()==fNFailL1PhaseEvent){
+    if ((UInt_t)(v->GetNrows())==fNFailL1PhaseEvent){
       newVersion=kTRUE;
       nevents=fNFailL1PhaseEvent;
     }
index 2c7492e..361b47d 100644 (file)
@@ -1807,10 +1807,10 @@ TString* AliTPCCalibViewer::Fit(const char* drawCommand, const char* formula, co
    chi2 = fitter->GetChisquare();
    chi2 = chi2;
    
-   TString *preturnFormula = new TString(Form("( %f+",fitParam[0])), &returnFormula = *preturnFormula; 
+   TString *preturnFormula = new TString(Form("( %e+",fitParam[0])), &returnFormula = *preturnFormula;
    
    for (Int_t iparam = 0; iparam < dim; iparam++) {
-     returnFormula.Append(Form("%s*(%f)",((TObjString*)formulaTokens->At(iparam))->GetName(),fitParam[iparam+1]));
+     returnFormula.Append(Form("%s*(%e)",((TObjString*)formulaTokens->At(iparam))->GetName(),fitParam[iparam+1]));
      if (iparam < dim-1) returnFormula.Append("+");
    }
    returnFormula.Append(" )");
@@ -1983,206 +1983,228 @@ void AliTPCCalibViewer::MakeTree(const char * fileName, TObjArray * array, const
   // 
   // The tree out of this function is the basis for the AliTPCCalibViewer and the AliTPCCalibViewerGUI.
    
-   AliTPCROC* tpcROCinstance = AliTPCROC::Instance();
+  AliTPCROC* tpcROCinstance = AliTPCROC::Instance();
 
-   TObjArray* mapIROCs = 0;
-   TObjArray* mapOROCs = 0;
-   TVectorF *mapIROCArray = 0;
-   TVectorF *mapOROCArray = 0;
-   Int_t mapEntries = 0;
-   TString* mapNames = 0;
-   
-   if (mapFileName) {
-      TFile mapFile(mapFileName, "read");
-      
-      TList* listOfROCs = mapFile.GetListOfKeys();
-      mapEntries = listOfROCs->GetEntries()/2;
-      mapIROCs = new TObjArray(mapEntries*2);
-      mapOROCs = new TObjArray(mapEntries*2);
-      mapIROCArray = new TVectorF[mapEntries];
-      mapOROCArray = new TVectorF[mapEntries];
-      
-      mapNames = new TString[mapEntries];
-      for (Int_t ivalue = 0; ivalue < mapEntries; ivalue++) {
-         TString rocName(((TKey*)(listOfROCs->At(ivalue*2)))->GetName());
-         rocName.Remove(rocName.Length()-4, 4);
-         mapIROCs->AddAt((AliTPCCalROC*)mapFile.Get((rocName + "IROC").Data()), ivalue);
-         mapOROCs->AddAt((AliTPCCalROC*)mapFile.Get((rocName + "OROC").Data()), ivalue);
-         mapNames[ivalue].Append(rocName);
-      }
-      
-      for (Int_t ivalue = 0; ivalue < mapEntries; ivalue++) {
-         mapIROCArray[ivalue].ResizeTo(tpcROCinstance->GetNChannels(0));
-         mapOROCArray[ivalue].ResizeTo(tpcROCinstance->GetNChannels(36));
+  TObjArray* mapIROCs = 0;
+  TObjArray* mapOROCs = 0;
+  TVectorF *mapIROCArray = 0;
+  TVectorF *mapOROCArray = 0;
+  Int_t mapEntries = 0;
+  TString* mapNames = 0;
+  
+  if (mapFileName) {
+    TFile mapFile(mapFileName, "read");
+    
+    TList* listOfROCs = mapFile.GetListOfKeys();
+    mapEntries = listOfROCs->GetEntries()/2;
+    mapIROCs = new TObjArray(mapEntries*2);
+    mapOROCs = new TObjArray(mapEntries*2);
+    mapIROCArray = new TVectorF[mapEntries];
+    mapOROCArray = new TVectorF[mapEntries];
+    
+    mapNames = new TString[mapEntries];
+    for (Int_t ivalue = 0; ivalue < mapEntries; ivalue++) {
+      TString rocName(((TKey*)(listOfROCs->At(ivalue*2)))->GetName());
+      rocName.Remove(rocName.Length()-4, 4);
+      mapIROCs->AddAt((AliTPCCalROC*)mapFile.Get((rocName + "IROC").Data()), ivalue);
+      mapOROCs->AddAt((AliTPCCalROC*)mapFile.Get((rocName + "OROC").Data()), ivalue);
+      mapNames[ivalue].Append(rocName);
+    }
+    
+    for (Int_t ivalue = 0; ivalue < mapEntries; ivalue++) {
+      mapIROCArray[ivalue].ResizeTo(tpcROCinstance->GetNChannels(0));
+      mapOROCArray[ivalue].ResizeTo(tpcROCinstance->GetNChannels(36));
       
-         for (UInt_t ichannel = 0; ichannel < tpcROCinstance->GetNChannels(0); ichannel++)
-            (mapIROCArray[ivalue])[ichannel] = ((AliTPCCalROC*)(mapIROCs->At(ivalue)))->GetValue(ichannel);
-         for (UInt_t ichannel = 0; ichannel < tpcROCinstance->GetNChannels(36); ichannel++)
-            (mapOROCArray[ivalue])[ichannel] = ((AliTPCCalROC*)(mapOROCs->At(ivalue)))->GetValue(ichannel);
-      }
-
-   } //  if (mapFileName)
+      for (UInt_t ichannel = 0; ichannel < tpcROCinstance->GetNChannels(0); ichannel++)
+        (mapIROCArray[ivalue])[ichannel] = ((AliTPCCalROC*)(mapIROCs->At(ivalue)))->GetValue(ichannel);
+      for (UInt_t ichannel = 0; ichannel < tpcROCinstance->GetNChannels(36); ichannel++)
+        (mapOROCArray[ivalue])[ichannel] = ((AliTPCCalROC*)(mapOROCs->At(ivalue)))->GetValue(ichannel);
+    }
+    
+  } //  if (mapFileName)
   
-   TTreeSRedirector cstream(fileName);
-   Int_t arrayEntries = 0;
-   if (array) arrayEntries = array->GetEntries();
-   
-   TString* names = new TString[arrayEntries];
-   for (Int_t ivalue = 0; ivalue < arrayEntries; ivalue++)
-      names[ivalue].Append(((AliTPCCalPad*)array->At(ivalue))->GetName());
-
-   for (UInt_t isector = 0; isector < tpcROCinstance->GetNSectors(); isector++) {
+  TTreeSRedirector cstream(fileName);
+  Int_t arrayEntries = 0;
+  if (array) arrayEntries = array->GetEntries();
+  
+  TString* names = new TString[arrayEntries];
+  for (Int_t ivalue = 0; ivalue < arrayEntries; ivalue++)
+    names[ivalue].Append(((AliTPCCalPad*)array->At(ivalue))->GetName());
+  
+  for (UInt_t isector = 0; isector < tpcROCinstance->GetNSectors(); isector++) {
       //
       // get statistic for given sector
       //
-      TVectorF median(arrayEntries);
-      TVectorF mean(arrayEntries);
-      TVectorF rms(arrayEntries);
-      TVectorF ltm(arrayEntries);
-      TVectorF ltmrms(arrayEntries);
-      TVectorF medianWithOut(arrayEntries);
-      TVectorF meanWithOut(arrayEntries);
-      TVectorF rmsWithOut(arrayEntries);
-      TVectorF ltmWithOut(arrayEntries);
-      TVectorF ltmrmsWithOut(arrayEntries);
-      
-      TVectorF *vectorArray = new TVectorF[arrayEntries];
-      for (Int_t ivalue = 0; ivalue < arrayEntries; ivalue++)
-         vectorArray[ivalue].ResizeTo(tpcROCinstance->GetNChannels(isector));
-      
-      for (Int_t ivalue = 0; ivalue < arrayEntries; ivalue++) {
-         AliTPCCalPad* calPad = (AliTPCCalPad*) array->At(ivalue);
-         AliTPCCalROC* calROC = calPad->GetCalROC(isector);
-         AliTPCCalROC* outlierROC = 0;
-         if (outlierPad) outlierROC = outlierPad->GetCalROC(isector);
-         if (calROC) {
-            median[ivalue] = calROC->GetMedian();
-            mean[ivalue] = calROC->GetMean();
-            rms[ivalue] = calROC->GetRMS();
-            Double_t ltmrmsValue = 0;
-            ltm[ivalue] = calROC->GetLTM(&ltmrmsValue, ltmFraction);
-            ltmrms[ivalue] = ltmrmsValue;
-            if (outlierROC) {
-               medianWithOut[ivalue] = calROC->GetMedian(outlierROC);
-               meanWithOut[ivalue] = calROC->GetMean(outlierROC);
-               rmsWithOut[ivalue] = calROC->GetRMS(outlierROC);
-               ltmrmsValue = 0;
-               ltmWithOut[ivalue] = calROC->GetLTM(&ltmrmsValue, ltmFraction, outlierROC);
-               ltmrmsWithOut[ivalue] = ltmrmsValue;
-            }
-         }
-         else {
-            median[ivalue] = 0.;
-            mean[ivalue] = 0.;
-            rms[ivalue] = 0.;
-            ltm[ivalue] = 0.;
-            ltmrms[ivalue] = 0.;
-            medianWithOut[ivalue] = 0.;
-            meanWithOut[ivalue] = 0.;
-            rmsWithOut[ivalue] = 0.;
-            ltmWithOut[ivalue] = 0.;
-            ltmrmsWithOut[ivalue] = 0.;
-         }
+    TVectorF median(arrayEntries);
+    TVectorF mean(arrayEntries);
+    TVectorF rms(arrayEntries);
+    TVectorF ltm(arrayEntries);
+    TVectorF ltmrms(arrayEntries);
+    TVectorF medianWithOut(arrayEntries);
+    TVectorF meanWithOut(arrayEntries);
+    TVectorF rmsWithOut(arrayEntries);
+    TVectorF ltmWithOut(arrayEntries);
+    TVectorF ltmrmsWithOut(arrayEntries);
+    
+    TVectorF *vectorArray = new TVectorF[arrayEntries];
+    for (Int_t ivalue = 0; ivalue < arrayEntries; ivalue++){
+      vectorArray[ivalue].ResizeTo(tpcROCinstance->GetNChannels(isector));
+      vectorArray[ivalue].SetUniqueID(array->UncheckedAt(ivalue)->GetUniqueID());
+//       printf("UniqueID: %d\n",vectorArray[ivalue].GetUniqueID());
+    }
+    
+    for (Int_t ivalue = 0; ivalue < arrayEntries; ivalue++) {
+      AliTPCCalPad* calPad = (AliTPCCalPad*) array->At(ivalue);
+      AliTPCCalROC* calROC = calPad->GetCalROC(isector);
+      AliTPCCalROC* outlierROC = 0;
+      if (outlierPad) outlierROC = outlierPad->GetCalROC(isector);
+      if (calROC) {
+        median[ivalue] = calROC->GetMedian();
+        mean[ivalue] = calROC->GetMean();
+        rms[ivalue] = calROC->GetRMS();
+        Double_t ltmrmsValue = 0;
+        ltm[ivalue] = calROC->GetLTM(&ltmrmsValue, ltmFraction);
+        ltmrms[ivalue] = ltmrmsValue;
+        if (outlierROC) {
+          medianWithOut[ivalue] = calROC->GetMedian(outlierROC);
+          meanWithOut[ivalue] = calROC->GetMean(outlierROC);
+          rmsWithOut[ivalue] = calROC->GetRMS(outlierROC);
+          ltmrmsValue = 0;
+          ltmWithOut[ivalue] = calROC->GetLTM(&ltmrmsValue, ltmFraction, outlierROC);
+          ltmrmsWithOut[ivalue] = ltmrmsValue;
+        }
       }
-      
+      else {
+        median[ivalue] = 0.;
+        mean[ivalue] = 0.;
+        rms[ivalue] = 0.;
+        ltm[ivalue] = 0.;
+        ltmrms[ivalue] = 0.;
+        medianWithOut[ivalue] = 0.;
+        meanWithOut[ivalue] = 0.;
+        rmsWithOut[ivalue] = 0.;
+        ltmWithOut[ivalue] = 0.;
+        ltmrmsWithOut[ivalue] = 0.;
+      }
+    }
+    
       //
       // fill vectors of variable per pad
       //
-      TVectorF *posArray = new TVectorF[8];
-      for (Int_t ivalue = 0; ivalue < 8; ivalue++)
-         posArray[ivalue].ResizeTo(tpcROCinstance->GetNChannels(isector));
-
-      Float_t posG[3] = {0};
-      Float_t posL[3] = {0};
-      Int_t ichannel = 0;
-      for (UInt_t irow = 0; irow < tpcROCinstance->GetNRows(isector); irow++) {
-         for (UInt_t ipad = 0; ipad < tpcROCinstance->GetNPads(isector, irow); ipad++) {
-            tpcROCinstance->GetPositionLocal(isector, irow, ipad, posL);
-            tpcROCinstance->GetPositionGlobal(isector, irow, ipad, posG);
-            posArray[0][ichannel] = irow;
-            posArray[1][ichannel] = ipad;
-            posArray[2][ichannel] = posL[0];
-            posArray[3][ichannel] = posL[1];
-            posArray[4][ichannel] = posG[0];
-            posArray[5][ichannel] = posG[1];
-            posArray[6][ichannel] = (Int_t)(ipad - (Double_t)(tpcROCinstance->GetNPads(isector, irow))/2);
-            posArray[7][ichannel] = ichannel;
-            
+    TVectorF *posArray = new TVectorF[8];
+    for (Int_t ivalue = 0; ivalue < 8; ivalue++)
+      posArray[ivalue].ResizeTo(tpcROCinstance->GetNChannels(isector));
+    
+    Float_t posG[3] = {0};
+    Float_t posL[3] = {0};
+    Int_t ichannel = 0;
+    for (UInt_t irow = 0; irow < tpcROCinstance->GetNRows(isector); irow++) {
+      for (UInt_t ipad = 0; ipad < tpcROCinstance->GetNPads(isector, irow); ipad++) {
+        tpcROCinstance->GetPositionLocal(isector, irow, ipad, posL);
+        tpcROCinstance->GetPositionGlobal(isector, irow, ipad, posG);
+        posArray[0][ichannel] = irow;
+        posArray[1][ichannel] = ipad;
+        posArray[2][ichannel] = posL[0];
+        posArray[3][ichannel] = posL[1];
+        posArray[4][ichannel] = posG[0];
+        posArray[5][ichannel] = posG[1];
+        posArray[6][ichannel] = (Int_t)(ipad - (Double_t)(tpcROCinstance->GetNPads(isector, irow))/2);
+        posArray[7][ichannel] = ichannel;
+        
             // loop over array containing AliTPCCalPads
-            for (Int_t ivalue = 0; ivalue < arrayEntries; ivalue++) {
-               AliTPCCalPad* calPad = (AliTPCCalPad*) array->At(ivalue);
-               AliTPCCalROC* calROC = calPad->GetCalROC(isector);
-               if (calROC)
+        for (Int_t ivalue = 0; ivalue < arrayEntries; ivalue++) {
+          AliTPCCalPad* calPad = (AliTPCCalPad*) array->At(ivalue);
+          AliTPCCalROC* calROC = calPad->GetCalROC(isector);
+                if (calROC)
                   (vectorArray[ivalue])[ichannel] = calROC->GetValue(irow, ipad);
-               else
-                  (vectorArray[ivalue])[ichannel] = 0;
-            }
-            ichannel++;
-         }
+          else
+            (vectorArray[ivalue])[ichannel] = 0;
+        }
+        ichannel++;
       }
-      
+    }
+    
+    cstream << "calPads" <<
+      "sector=" << isector;
+    
+    for  (Int_t ivalue = 0; ivalue < arrayEntries; ivalue++) {
       cstream << "calPads" <<
-         "sector=" << isector;
-      
-      for  (Int_t ivalue = 0; ivalue < arrayEntries; ivalue++) {
-         cstream << "calPads" <<
-            (Char_t*)((names[ivalue] + "_Median=").Data()) << median[ivalue] <<
-            (Char_t*)((names[ivalue] + "_Mean=").Data()) << mean[ivalue] <<
-            (Char_t*)((names[ivalue] + "_RMS=").Data()) << rms[ivalue] <<
-            (Char_t*)((names[ivalue] + "_LTM=").Data()) << ltm[ivalue] <<
-            (Char_t*)((names[ivalue] + "_RMS_LTM=").Data()) << ltmrms[ivalue];
-         if (outlierPad) {
-            cstream << "calPads" <<
-               (Char_t*)((names[ivalue] + "_Median_OutlierCutted=").Data()) << medianWithOut[ivalue] <<
-               (Char_t*)((names[ivalue] + "_Mean_OutlierCutted=").Data()) << meanWithOut[ivalue] <<
-               (Char_t*)((names[ivalue] + "_RMS_OutlierCutted=").Data()) << rmsWithOut[ivalue] <<
-               (Char_t*)((names[ivalue] + "_LTM_OutlierCutted=").Data()) << ltmWithOut[ivalue] <<
-               (Char_t*)((names[ivalue] + "_RMS_LTM_OutlierCutted=").Data()) << ltmrmsWithOut[ivalue];
-         }
+        (Char_t*)((names[ivalue] + "_Median=").Data()) << median[ivalue] <<
+        (Char_t*)((names[ivalue] + "_Mean=").Data()) << mean[ivalue] <<
+        (Char_t*)((names[ivalue] + "_RMS=").Data()) << rms[ivalue] <<
+        (Char_t*)((names[ivalue] + "_LTM=").Data()) << ltm[ivalue] <<
+        (Char_t*)((names[ivalue] + "_RMS_LTM=").Data()) << ltmrms[ivalue];
+      if (outlierPad) {
+        cstream << "calPads" <<
+          (Char_t*)((names[ivalue] + "_Median_OutlierCutted=").Data()) << medianWithOut[ivalue] <<
+          (Char_t*)((names[ivalue] + "_Mean_OutlierCutted=").Data()) << meanWithOut[ivalue] <<
+          (Char_t*)((names[ivalue] + "_RMS_OutlierCutted=").Data()) << rmsWithOut[ivalue] <<
+          (Char_t*)((names[ivalue] + "_LTM_OutlierCutted=").Data()) << ltmWithOut[ivalue] <<
+          (Char_t*)((names[ivalue] + "_RMS_LTM_OutlierCutted=").Data()) << ltmrmsWithOut[ivalue];
       }
-
-      for  (Int_t ivalue = 0; ivalue < arrayEntries; ivalue++) {
-         cstream << "calPads" <<
-            (Char_t*)((names[ivalue] + ".=").Data()) << &vectorArray[ivalue];
+        //timestamp and run, if given in title
+/*      TString title(((AliTPCCalPad*) array->At(ivalue))->GetTitle());
+      TObjArray *arrtitle=title.Tokenize(",");
+      Int_t run=-1;
+      UInt_t time=0;
+      TIter next(arrtitle);
+      TObject *o=0;
+      while ( (o=next()) ){
+        TString &entry=((TObjString*)o)->GetString();
+        entry.Remove(TString::kBoth,' ');
+        entry.Remove(TString::kBoth,'\t');
+        if (entry.BeginsWith("Run:")) {
+          run=entry(4,entry.Length()).Atoi();
+        } else if (entry.BeginsWith("Time:")) {
+          time=entry(6,entry.Length()).Atoi();
+        }
       }
-
-      if (mapFileName) {
-         for  (Int_t ivalue = 0; ivalue < mapEntries; ivalue++) {
+      delete arrtitle;*/
+      
+    }
+    
+    for  (Int_t ivalue = 0; ivalue < arrayEntries; ivalue++) {
+      cstream << "calPads" <<
+        (Char_t*)((names[ivalue] + ".=").Data()) << &vectorArray[ivalue];
+    }
+    
+    if (mapFileName) {
+          for  (Int_t ivalue = 0; ivalue < mapEntries; ivalue++) {
             if (isector < 36)
-               cstream << "calPads" <<
-                  (Char_t*)((mapNames[ivalue] + ".=").Data()) << &mapIROCArray[ivalue];
+              cstream << "calPads" <<
+              (Char_t*)((mapNames[ivalue] + ".=").Data()) << &mapIROCArray[ivalue];
             else
-               cstream << "calPads" <<
-                  (Char_t*)((mapNames[ivalue] + ".=").Data()) << &mapOROCArray[ivalue];
+                cstream << "calPads" <<
+              (Char_t*)((mapNames[ivalue] + ".=").Data()) << &mapOROCArray[ivalue];
          }
-      }
-
-      cstream << "calPads" <<
-         "row.=" << &posArray[0] <<
-         "pad.=" << &posArray[1] <<
-         "lx.=" << &posArray[2] <<
-         "ly.=" << &posArray[3] <<
-         "gx.=" << &posArray[4] <<
-         "gy.=" << &posArray[5] <<
-         "rpad.=" << &posArray[6] <<
-         "channel.=" << &posArray[7];
-         
-      cstream << "calPads" <<
-         "\n";
-
-      delete[] posArray;
-      delete[] vectorArray;
-   }
-   
-
-   delete[] names;
-   if (mapFileName) {
-      delete mapIROCs;
-      delete mapOROCs;
-      delete[] mapIROCArray;
-      delete[] mapOROCArray;
-      delete[] mapNames;
-   }
+    }
+
+    cstream << "calPads" <<
+      "row.=" << &posArray[0] <<
+      "pad.=" << &posArray[1] <<
+      "lx.=" << &posArray[2] <<
+      "ly.=" << &posArray[3] <<
+      "gx.=" << &posArray[4] <<
+      "gy.=" << &posArray[5] <<
+      "rpad.=" << &posArray[6] <<
+      "channel.=" << &posArray[7];
+    
+    cstream << "calPads" <<
+      "\n";
+    
+    delete[] posArray;
+    delete[] vectorArray;
+  }
+  
+  
+  delete[] names;
+  if (mapFileName) {
+    delete mapIROCs;
+    delete mapOROCs;
+    delete[] mapIROCArray;
+    delete[] mapOROCArray;
+    delete[] mapNames;
+  }
 }
 
 
index 12e7836..ad6a5dc 100644 (file)
@@ -1538,21 +1538,22 @@ void AliTPCCalibViewerGUI::ReplacePlaceHolders(TString &str)
 
     //current draw variable
     TString desiredData("");
-    if (!fListVariables->GetSelectedEntry()) return;
-    desiredData += ((TGTextLBEntry*)(fListVariables->GetSelectedEntry()))->GetTitle();
+    if (fListVariables->GetSelectedEntry()){
+      desiredData += ((TGTextLBEntry*)(fListVariables->GetSelectedEntry()))->GetTitle();
+      str.ReplaceAll(drawPlaceHolder,desiredData);
+    }
 //    desiredData += fViewer->GetAbbreviation();
 
     //current normalisation
     TString normalizationData("");
-    if (!fListNormalization->GetSelectedEntry()) return;
-    normalizationData += ((TGTextLBEntry*)(fListNormalization->GetSelectedEntry()))->GetTitle();
-    if (! (TString(((TGTextLBEntry*)(fListNormalization->GetSelectedEntry()))->GetTitle())).BeginsWith("Fit"))
-       if ( normalizationData.BeginsWith("_") ) normalizationData = desiredData+normalizationData;
-    if ( fListVariables->FindEntry(normalizationData.Data()) )
-       normalizationData+="~";
-
-    str.ReplaceAll(drawPlaceHolder,desiredData);
-    str.ReplaceAll(normPlaceHolder,normalizationData);
+    if (fListNormalization->GetSelectedEntry()){
+      normalizationData += ((TGTextLBEntry*)(fListNormalization->GetSelectedEntry()))->GetTitle();
+      if (! (TString(((TGTextLBEntry*)(fListNormalization->GetSelectedEntry()))->GetTitle())).BeginsWith("Fit"))
+        if ( normalizationData.BeginsWith("_") ) normalizationData = desiredData+normalizationData;
+      if ( fListVariables->FindEntry(normalizationData.Data()) )
+        normalizationData+="~";
+      str.ReplaceAll(normPlaceHolder,normalizationData);
+    }
 }
 
 void AliTPCCalibViewerGUI::DoNewSelection() {
@@ -1810,7 +1811,9 @@ void AliTPCCalibViewerGUI::DoFit() {
       formulaStr = TString(fViewer->AddAbbreviations((char*)formulaStr.Data()));
 
    // ********** call AliTPCCalibViewer's fit-function
-   returnStr = fViewer->Fit(drawStr.Data(), formulaStr.Data(), cutStr.Data(), chi2, fitParam, covMatrix);
+  ReplacePlaceHolders(drawStr);
+  ReplacePlaceHolders(cutStr);
+  returnStr = fViewer->Fit(drawStr.Data(), formulaStr.Data(), cutStr.Data(), chi2, fitParam, covMatrix);
    
    std::cout << std::endl;
    std::cout << "Your fit formula reads as follows:" << std::endl;
index a374bcb..a44c36a 100644 (file)
@@ -44,6 +44,7 @@
 #include <TAxis.h>
 #include <TTimeStamp.h>
 #include <TMath.h>
+#include <TMap.h>
 //
 #include <TGFileDialog.h>
 #include <TGInputDialog.h>
@@ -63,6 +64,7 @@
 //AliRoot includes
 #include <AliLog.h>
 #include "AliTPCCalibViewerGUI.h"
+#include "AliTPCCalibViewer.h"
 #include "AliTPCcalibDB.h"
 #include "AliTPCConfigParser.h"
 
@@ -90,6 +92,7 @@ TGCompositeFrame(p,w,h),
   fValuesY(10),
   fNoGraph(kFALSE),
   fGraphLimitEntries(10000),
+  fMapRefTrees(new TMap),
   //GUI elements
   //main canvas Top part, bottom part
   fContTopBottom(0x0),
@@ -139,6 +142,8 @@ TGCompositeFrame(p,w,h),
   //
   // ctor
   //
+  fMapRefTrees->SetOwnerKeyValue();
+  fTrashBox->SetOwner();
   DrawGUI(p,w,h);
   gStyle->SetMarkerStyle(20);
   gStyle->SetMarkerSize(0.5);
@@ -151,6 +156,7 @@ AliTPCCalibViewerGUItime::~AliTPCCalibViewerGUItime(){
   //
   delete fConfigParser;
   delete fTrashBox;
+  delete fMapRefTrees;
 }
 //______________________________________________________________________________
 void AliTPCCalibViewerGUItime::DrawGUI(const TGWindow */*p*/, UInt_t w, UInt_t h) {
@@ -602,6 +608,15 @@ void AliTPCCalibViewerGUItime::Reload(Int_t first)
   }
 }
 //______________________________________________________________________________
+void AliTPCCalibViewerGUItime::AddReferenceTree(const char* treeFileName, const char* refName)
+{
+  //
+  // map of reference trees that should always be attached to the CalibViewerGUI
+  //
+  fMapRefTrees->Add(new TObjString(refName), new TObjString(treeFileName));
+
+}
+//______________________________________________________________________________
 const char* AliTPCCalibViewerGUItime::GetDrawString(){
   //
   // create draw string for ttree by combining the user requestsa
@@ -733,7 +748,40 @@ void AliTPCCalibViewerGUItime::GetHistogramTitle(TString &title)
   delete arr;
 }
 //______________________________________________________________________________
+void AliTPCCalibViewerGUItime::AdjustYRange()
+{
+  //
+  //
+  //
+  TIter nextGraphicObject(fTrashBox);
+  TObject *o=0x0;
+  Float_t min=0,max=0;
+  while ( (o=nextGraphicObject()) ){
+    if (o->IsA()==TGraph::Class()){
+      TGraph *gr=(TGraph*)o;
+      if (min==max) {
+        min=TMath::MinElement(gr->GetN(),gr->GetY());
+        max=TMath::MaxElement(gr->GetN(),gr->GetY());
+      } else {
+        Float_t currmin=TMath::MinElement(gr->GetN(),gr->GetY());
+        Float_t currmax=TMath::MaxElement(gr->GetN(),gr->GetY());
+        if (currmax>max) max=currmax;
+        if (currmin<min) min=currmin;
+      }
+    }
+  }
+  if (min!=max){
+    if (min!=0) min=min-(max-min)/10;
+    if (max!=0) max=max+(max-min)/10;
+    fCurrentHist->SetMinimum(min);
+    fCurrentHist->SetMaximum(max);
+  }
+}
+//______________________________________________________________________________
 void AliTPCCalibViewerGUItime::DoDraw() {
+  //
+  // Draw graphics
+  //
   TString drawString=fDrawString;
   TString cutString;
   GetCutString(cutString);
@@ -828,15 +876,20 @@ void AliTPCCalibViewerGUItime::DoDraw() {
   }
   
   //Set time axis if choosen as x-variables
-  if (fRadioXtime->GetState()==kButtonDown&&!fIsCustomDraw){
+  if (fRadioXtime->GetState()==kButtonDown&&!fIsCustomDraw&&!drawSame){
     TAxis *xaxis=fCurrentHist->GetXaxis();
     xaxis->SetTimeFormat("#splitline{%d.%m}{%H:%M}");
     xaxis->SetTimeDisplay(1);
     xaxis->SetLabelOffset(xaxis->GetLabelOffset()*3);
     xaxis->SetLabelSize(xaxis->GetLabelSize()/1.3);
   }
+  if (!drawSame) {
   //Set title offset
-  if (!drawSame) fCurrentHist->GetYaxis()->SetTitleOffset(1.5);
+    fCurrentHist->GetYaxis()->SetTitleOffset(1.5);
+  } else {
+    //adjust y-range
+    AdjustYRange();
+  }
   gPad->Modified();
   gPad->Update();
   padsave->cd();
@@ -953,9 +1006,10 @@ void AliTPCCalibViewerGUItime::UpdateParName()
   //
   
   Int_t par = (Int_t)(fNmbPar->GetNumber());
-  TString parName=par;
+  TString parName="";
   Int_t id=fListVariables->GetSelectedEntry()->EntryId();
   if (fConfigParser && (*fConfigParser)(id)) parName=fConfigParser->GetData((*fConfigParser)(id),par+kParamNames);
+  if (parName=="") parName.Form("%d",par);
   fLblPar->SetText(Form("Parameter: %s",parName.Data()));
   fDrawString=GetDrawString();
   fIsCustomDraw=kFALSE;
@@ -1011,7 +1065,7 @@ void AliTPCCalibViewerGUItime::UpdateParLimits()
   }
 //   branch->ResetAddress();
   fTree->SetBranchAddress(selectedVariable.Data(),0x0);
-  fNmbPar->SetNumber(0);
+  if (fNmbPar->GetNumMax()!=maxPar-1) fNmbPar->SetNumber(0);
   fNmbPar->SetLimitValues(0,maxPar-1);
   fNmbPar->SetState(kTRUE);
   UpdateParName();
@@ -1092,24 +1146,25 @@ void AliTPCCalibViewerGUItime::SetGuiTree(Int_t run)
   TString fileName=fOutputCacheDir;
   if (!fileName.EndsWith("/")) fileName+="/";
   fileName+=Form("guiTreeRun_%d.root",run);
+  Bool_t load=kTRUE;
   TFile f(fileName.Data());
-  if (f.IsOpen()){
-    f.Close();
-    fCalibViewerGUI->Initialize(fileName.Data());
-    fCalibViewerGUI->Reload();
-    if (fCalibViewerGUItab) fCalibViewerGUItab->SetText(new TGString(Form("Detail - %05d",run)));
-    return;
+  if (!f.IsOpen()){
+    load=AliTPCcalibDB::CreateGUITree(run,fileName.Data());
+    if (!load){
+      fCalibViewerGUI->Reset();
+      if (fCalibViewerGUItab) fCalibViewerGUItab->SetText(new TGString(Form("Detail - XXXXX")));
+      return;
+    }
   }
   f.Close();
-  Bool_t sucess=AliTPCcalibDB::CreateGUITree(run,fileName.Data());
-  if (sucess){
-    fCalibViewerGUI->Initialize(fileName.Data());
-    fCalibViewerGUI->Reload();
-    if (fCalibViewerGUItab) fCalibViewerGUItab->SetText(new TGString(Form("Detail - %05d",run)));
-  }else{
-    fCalibViewerGUI->Reset();
-    if (fCalibViewerGUItab) fCalibViewerGUItab->SetText(new TGString(Form("Detail - XXXXX")));
+  fCalibViewerGUI->Initialize(fileName.Data());
+  if (fCalibViewerGUItab) fCalibViewerGUItab->SetText(new TGString(Form("Detail - %05d",run)));
+  TIter nextRefTree(fMapRefTrees);
+  TObject *o=0x0;
+  while ( (o=nextRefTree()) ){
+    fCalibViewerGUI->GetViewer()->AddReferenceTree(fMapRefTrees->GetValue(o)->GetName(),"calPads",o->GetName());
   }
+  fCalibViewerGUI->Reload();
 }
 //______________________________________________________________________________
 const char* AliTPCCalibViewerGUItime::SubstituteUnderscores(const char* in)
index f7bdf69..154e237 100644 (file)
@@ -50,6 +50,8 @@ class TChain;
 class TGraph;
 class TObjArray;
 
+class TMap;
+
 class AliTPCCalibViewerGUI;
 class AliTPCConfigParser;
 
@@ -69,6 +71,7 @@ public:
   void UseChain(TChain *chain);
   void UseConfigFile(const char* file="");
   void Reload(Int_t first=1);
+  void AddReferenceTree(const char* treeFileName, const char* refName="R");
 
   
   void SetCalibViewerGUI(AliTPCCalibViewerGUI *gui) {fCalibViewerGUI=gui;}
@@ -91,7 +94,7 @@ public:
   void HandleButtonsDrawSel(Int_t id = -1);              
   void MouseMove(Int_t event, Int_t x, Int_t y, TObject */*selected*/);
   
-private:
+ private:
   TFile*  fFile;                          //file that keeps the tree
   TChain*  fTree;                         //internal tree
   AliTPCCalibViewerGUI *fCalibViewerGUI;  //calib viewer gui used to display verbose information for one run
@@ -111,6 +114,8 @@ private:
   //
   Bool_t  fNoGraph;                       //Whether to create a graph
   Long64_t fGraphLimitEntries;            //limit in number of entries in the chain for producing a graph
+  //
+  TMap *fMapRefTrees;                      //map of reference trees for the CalibViewer
   //GUI elements
   //main canvas Top part, bottom part
   TGCompositeFrame    *fContTopBottom;      // container for all GUI elements, vertical divided
@@ -172,6 +177,7 @@ private:
   void UpdateValueArrays(Bool_t withGraph);
   const char* SubstituteUnderscores(const char* in);
   void GetHistogramTitle(TString &title);
+  void AdjustYRange();
 private:
   AliTPCCalibViewerGUItime(const AliTPCCalibViewerGUItime &v);
   AliTPCCalibViewerGUItime &operator = (const AliTPCCalibViewerGUItime &v);         // assignment operator
index fa6bc6d..caa4c94 100644 (file)
@@ -179,10 +179,10 @@ const char* AliTPCConfigParser::GetData(const char *key, UInt_t position)
   //
   //Get value for the speciefied key
   //
-  TObject *val=((TObjArray*)fConfigMap->FindObject(key))->At(position);
-  if ( !val ) {
-    return "";
-  }
+  TObjArray *arr=((TObjArray*)fConfigMap->FindObject(key));
+  if (position>=arr->GetEntries()) return "";
+  TObject *val=arr->At(position);
+  if ( !val ) return "";
   return (((TObjString*)val)->GetString()).Data();
 }
 //_____________________________________________________________________
@@ -202,10 +202,10 @@ const char* AliTPCConfigParser::GetData(const TObject *key, UInt_t position)
   //
   //Get value for the speciefied key
   //
-  TObject *val=((TObjArray*)fConfigMap->FindObject(key))->At(position);
-  if ( !val ) {
-    return "";
-  }
+  TObjArray *arr=((TObjArray*)fConfigMap->FindObject(key));
+  if (position>=arr->GetEntries()) return "";
+  TObject *val=arr->At(position);
+  if ( !val ) return "";
   return (((TObjString*)val)->GetString()).Data();
 }
 //_____________________________________________________________________
index 49b72e7..65c0f26 100644 (file)
@@ -107,6 +107,7 @@ class AliTPCCalDet;
 #include "TObjArray.h"
 #include "TObjString.h"
 #include "TString.h"
+#include "TDirectory.h"
 #include "AliTPCCalPad.h"
 #include "AliTPCCalibPulser.h"
 #include "AliTPCCalibPedestal.h"
@@ -864,6 +865,15 @@ Float_t AliTPCcalibDB::GetGain(Int_t sector, Int_t row, Int_t pad){
   return calPad->GetCalROC(sector)->GetValue(row,pad);
 }
 
+AliSplineFit* AliTPCcalibDB::GetVdriftSplineFit(const char* name, Int_t run){
+  //
+  //
+  //
+  TObjArray *arr=GetTimeVdriftSplineRun(run);
+  if (!arr) return 0;
+  return dynamic_cast<AliSplineFit*>(arr->FindObject(name));
+}
+
 
 AliGRPObject *AliTPCcalibDB::GetGRP(Int_t run){
   //
@@ -950,6 +960,18 @@ TObjArray * AliTPCcalibDB::GetTimeGainSplinesRun(Int_t run){
   return gainSplines;
 }
 
+TObjArray * AliTPCcalibDB::GetTimeVdriftSplineRun(Int_t run){
+  //
+  // Get drift spline array
+  //
+  TObjArray * driftSplines = (TObjArray *)fDriftCorrectionArray.At(run);
+  if (!driftSplines) {
+    UpdateRunInformations(run);
+    driftSplines = (TObjArray *)fDriftCorrectionArray.At(run);
+  }
+  return driftSplines;
+}
+
 AliDCSSensorArray * AliTPCcalibDB::GetVoltageSensors(Int_t run){
   //
   // Get temperature sensor array
@@ -1059,7 +1081,7 @@ Float_t AliTPCcalibDB::GetDCSSensorValue(AliDCSSensorArray *arr, Int_t timeStamp
     for (Int_t ipoint=0;ipoint<gr->GetN();++ipoint){
       Double_t x,y;
       gr->GetPoint(ipoint,x,y);
-      Int_t time=sensor->GetStartTime()+x*3600; //time in graph is hours
+      Int_t time=TMath::Nint(sensor->GetStartTime()+x*3600); //time in graph is hours
       if (time<timeStamp) continue;
       val=y;
       break;
@@ -1072,14 +1094,14 @@ Float_t AliTPCcalibDB::GetDCSSensorValue(AliDCSSensorArray *arr, Int_t timeStamp
     if (val==0 ){
       Double_t x,y;
       gr->GetPoint(0,x,y);
-      Int_t time=sensor->GetStartTime()+x*3600; //time in graph is hours
+      Int_t time=TMath::Nint(sensor->GetStartTime()+x*3600); //time in graph is hours
       if ((time-timeStamp)<5*60) val=y;
     }
     //last point
     if (val==0 ){
       Double_t x,y;
       gr->GetPoint(gr->GetN()-1,x,y);
-      Int_t time=sensor->GetStartTime()+x*3600; //time in graph is hours
+      Int_t time=TMath::Nint(sensor->GetStartTime()+x*3600); //time in graph is hours
       if ((timeStamp-time)<5*60) val=y;
     }
   } else {
@@ -1323,14 +1345,21 @@ Char_t  AliTPCcalibDB::GetL3Polarity(Int_t run) {
   //
   // get l3 polarity from GRP
   //
-  return AliTPCcalibDB::GetGRP(run)->GetL3Polarity();
+  Char_t pol=-100;
+  AliGRPObject *grp=AliTPCcalibDB::GetGRP(run);
+  if (grp) pol=grp->GetL3Polarity();
+  return pol;
 }
 
 TString AliTPCcalibDB::GetRunType(Int_t run){
   //
   // return run type from grp
   //
-  return AliTPCcalibDB::GetGRP(run)->GetRunType();
+
+//   TString type("UNKNOWN");
+  AliGRPObject *grp=AliTPCcalibDB::GetGRP(run);
+  if (grp) return grp->GetRunType();
+  return "UNKNOWN";
 }
 
 Float_t AliTPCcalibDB::GetValueGoofie(Int_t timeStamp, Int_t run, Int_t type){
@@ -1467,3 +1496,45 @@ Bool_t AliTPCcalibDB::CreateGUITree(Int_t run, const char* filename)
   return kTRUE;
 }
 
+Bool_t AliTPCcalibDB::CreateRefFile(Int_t run, const char* filename)
+{
+  //
+  // Create a gui tree for run number 'run'
+  //
+  
+  if (!AliCDBManager::Instance()->GetDefaultStorage()){
+    AliLog::Message(AliLog::kError, "Default Storage not set. Cannot create Calibration Tree!",
+                    MODULENAME(), "AliTPCcalibDB", FUNCTIONNAME(), __FILE__, __LINE__);
+    return kFALSE;
+  }
+  TString file(filename);
+  if (file.IsNull()) file=Form("RefCalPads_%d.root",run);
+  TDirectory *currDir=gDirectory;
+  //db instance
+  AliTPCcalibDB *db=AliTPCcalibDB::Instance();
+  // retrieve cal pad objects
+  db->SetRun(run);
+  //open file
+  TFile f(file.Data(),"recreate");
+  //noise and pedestals
+  db->GetPedestals()->Write("Pedestals");
+  db->GetPadNoise()->Write("PadNoise");
+  //pulser data
+  db->GetPulserTmean()->Write("PulserTmean");
+  db->GetPulserTrms()->Write("PulserTrms");
+  db->GetPulserQmean()->Write("PulserQmean");
+  //CE data
+  db->GetCETmean()->Write("CETmean");
+  db->GetCETrms()->Write("CETrms");
+  db->GetCEQmean()->Write("CEQmean");
+  //Altro data
+  db->GetALTROAcqStart() ->Write("ALTROAcqStart");
+  db->GetALTROZsThr()    ->Write("ALTROZsThr");
+  db->GetALTROFPED()     ->Write("ALTROFPED");
+  db->GetALTROAcqStop()  ->Write("ALTROAcqStop");
+  db->GetALTROMasked()   ->Write("ALTROMasked");
+  //
+  f.Close();
+  currDir->cd();
+  return kTRUE;
+}
index 6530bab..c7a53ea 100644 (file)
@@ -19,6 +19,7 @@ class AliTPCExB;
 #include "TGraph.h"
 #include "AliTPCCalPad.h"
 #include "TString.h"
+#include "AliSplineFit.h"
 
 class AliTPCSensorTempArray;
 class AliDCSSensorArray;
@@ -123,8 +124,11 @@ class AliTPCcalibDB : public TObject
   AliDCSSensorArray *     GetVoltageSensors(Int_t run);
   AliTPCCalibVdrift *     GetVdrift(Int_t run);
        TObjArray *                                                     GetTimeGainSplinesRun(Int_t run);
+  TObjArray*              GetTimeVdriftSplineRun(Int_t run);
   static Float_t GetGain(Int_t sector, Int_t row, Int_t pad);
   //
+  AliSplineFit* GetVdriftSplineFit(const char* name, Int_t run);
+  //
   static void     CreateObjectList(const Char_t *filename, TObjArray *calibObjects);
   static void MakeTree(const char * fileName, TObjArray * array, const char * mapFileName = 0, AliTPCCalPad* outlierPad = 0, Float_t ltmFraction = 0.9);
   static void RegisterExB(Int_t index, Float_t bz, Bool_t bdelete);
@@ -134,6 +138,7 @@ class AliTPCcalibDB : public TObject
   AliGRPObject * MakeGRPObjectFromMap(TMap *map);
   //Create a tree suited for diplaying with the AliTPCCalibViewerGUI
   static Bool_t CreateGUITree(Int_t run, const char* filename="");
+  static Bool_t CreateRefFile(Int_t run, const char* filename="");
   //
 protected:
   
@@ -173,6 +178,7 @@ protected:
   TObjArray      fTemperatureArray;                    //! array of temperature sensors - per run
   TObjArray      fVdriftArray;                                 //! array of v drift interfaces
   TObjArray      fDriftCorrectionArray;                //! array of drift correction
+  
 
   TArrayI        fRunList;                                                     //! run list - indicates try to get the run param
   //
index 6f184d5..c64bdd2 100644 (file)
@@ -28,6 +28,8 @@
 #include <TVectorT.h>
 #include <TObjArray.h>
 #include <TGraph.h>
+#include <TFile.h>
+#include <TDirectory.h>
 
 #include <AliDCSSensorArray.h>
 #include <AliDCSSensor.h>
@@ -56,10 +58,21 @@ AliTPCcalibDButil::AliTPCcalibDButil() :
   fCEQmean(0x0),
   fALTROMasked(0x0),
   fCalibRaw(0x0),
+  fRefPadNoise(0x0),
+  fRefPedestals(0x0),
+  fRefPulserTmean(0x0),
+  fRefPulserTrms(0x0),
+  fRefPulserQmean(0x0),
+  fRefPulserOutlier(new AliTPCCalPad("RefPulserOutliers","RefPulserOutliers")),
+  fRefCETmean(0x0),
+  fRefCETrms(0x0),
+  fRefCEQmean(0x0),
+  fRefALTROMasked(0x0),
+  fRefCalibRaw(0x0),
   fGoofieArray(0x0),
   fMapper(new AliTPCmapper(0x0)),
   fNpulserOutliers(-1),
-  fIrocTimeOffset(.2),
+  fIrocTimeOffset(0),
   fCETmaxLimitAbs(1.5),
   fPulTmaxLimitAbs(1.5),
   fPulQmaxLimitAbs(5),
@@ -76,7 +89,19 @@ AliTPCcalibDButil::~AliTPCcalibDButil()
   // dtor
   //
   delete fPulserOutlier;
+  delete fRefPulserOutlier;
   delete fMapper;
+  if (fRefPadNoise) delete fRefPadNoise;
+  if (fRefPedestals) delete fRefPedestals;
+  if (fRefPulserTmean) delete fRefPulserTmean;
+  if (fRefPulserTrms) delete fRefPulserTrms;
+  if (fRefPulserQmean) delete fRefPulserQmean;
+  if (fRefCETmean) delete fRefCETmean;
+  if (fRefCETrms) delete fRefCETrms;
+  if (fRefCEQmean) delete fRefCEQmean;
+  if (fRefALTROMasked) delete fRefALTROMasked;
+  if (fRefCalibRaw) delete fRefCalibRaw;
+    
 }
 //_____________________________________________________________________________________
 void AliTPCcalibDButil::UpdateFromCalibDB()
@@ -98,7 +123,8 @@ void AliTPCcalibDButil::UpdateFromCalibDB()
   UpdatePulserOutlierMap();
 }
 //_____________________________________________________________________________________
-void AliTPCcalibDButil::ProcessCEdata(const char* fitFormula, TVectorD &fitResultsA, TVectorD &fitResultsC, Int_t &noutliersCE)
+void AliTPCcalibDButil::ProcessCEdata(const char* fitFormula, TVectorD &fitResultsA, TVectorD &fitResultsC,
+                                      Int_t &noutliersCE, AliTPCCalPad *outCE)
 {
   //
   // Process the CE data for this run
@@ -121,15 +147,18 @@ void AliTPCcalibDButil::ProcessCEdata(const char* fitFormula, TVectorD &fitResul
   }
   noutliersCE=0;
   //create outlier map
-  AliTPCCalPad out("out","out");
+  AliTPCCalPad *out=0;
+  if (outCE) out=outCE;
+  else out=new AliTPCCalPad("outCE","outCE");
   AliTPCCalROC *rocMasked=0x0;
   //loop over all channels
   for (UInt_t iroc=0;iroc<fCETmean->kNsec;++iroc){
     AliTPCCalROC *rocData=fCETmean->GetCalROC(iroc);
     if (fALTROMasked) rocMasked=fALTROMasked->GetCalROC(iroc);
-    AliTPCCalROC *rocOut=out.GetCalROC(iroc);
+    AliTPCCalROC *rocOut=out->GetCalROC(iroc);
     if (!rocData) {
       noutliersCE+=AliTPCROC::Instance()->GetNChannels(iroc);
+      rocOut->Add(1.);
       continue;
     }
     //add time offset to IROCs
@@ -140,22 +169,23 @@ void AliTPCcalibDButil::ProcessCEdata(const char* fitFormula, TVectorD &fitResul
     for (UInt_t irow=0;irow<nrows;++irow){
       UInt_t npads=rocData->GetNPads(irow);
       for (UInt_t ipad=0;ipad<npads;++ipad){
+        rocOut->SetValue(irow,ipad,0);
         //exclude masked pads
         if (rocMasked && rocMasked->GetValue(irow,ipad)) {
-          rocOut->SetValue(iroc,ipad,1);
+          rocOut->SetValue(irow,ipad,1);
           continue;
         }
         //exclude edge pads
-        if (ipad==0||ipad==npads-1) rocOut->SetValue(iroc,ipad,1); 
-        Float_t valTmean=rocData->GetValue(iroc,ipad);
+        if (ipad==0||ipad==npads-1) rocOut->SetValue(irow,ipad,1);
+        Float_t valTmean=rocData->GetValue(irow,ipad);
         //exclude values that are exactly 0
         if (valTmean==0) {
-          rocOut->SetValue(iroc,ipad,1);
+          rocOut->SetValue(irow,ipad,1);
           ++noutliersCE;
         }
         // exclude channels with too large variations
         if (TMath::Abs(valTmean)>fCETmaxLimitAbs) {
-          rocOut->SetValue(iroc,ipad,1);
+          rocOut->SetValue(irow,ipad,1);
           ++noutliersCE;
         }
       }
@@ -164,7 +194,8 @@ void AliTPCcalibDButil::ProcessCEdata(const char* fitFormula, TVectorD &fitResul
   //perform fit
   TMatrixD dummy;
   Float_t chi2A,chi2C;
-  fCETmean->GlobalSidesFit(&out,fitFormula,fitResultsA,fitResultsC,dummy,dummy,chi2A,chi2C);
+  fCETmean->GlobalSidesFit(out,fitFormula,fitResultsA,fitResultsC,dummy,dummy,chi2A,chi2C);
+  if (!outCE) delete out;
 }
 //_____________________________________________________________________________________
 void AliTPCcalibDButil::ProcessCEgraphs(TVectorD &vecTEntries, TVectorD &vecTMean, TVectorD &vecTRMS, TVectorD &vecTMedian,
@@ -519,20 +550,203 @@ void AliTPCcalibDButil::ProcessGoofie(TVectorD & vecEntries, TVectorD & vecMedia
     }
   }
 }
-
+//_____________________________________________________________________________________
+void AliTPCcalibDButil::ProcessPedestalVariations(TVectorF &pedestalDeviations)
+{
+  //
+  // check the variations of the pedestal data to the reference pedestal data
+  // thresholds are 0.5, 1.0, 1.5 and 2 timebins respectively.
+  //
+  const Int_t npar=4;
+  TVectorF vThres(npar); //thresholds
+  Int_t nActive=0;       //number of active channels
+  
+  //reset and set thresholds
+  pedestalDeviations.ResizeTo(npar);
+  for (Int_t i=0;i<npar;++i){
+    pedestalDeviations.GetMatrixArray()[i]=0;
+    vThres.GetMatrixArray()[i]=(i+1)*.5;
+  }
+  //check all needed data is available
+  if (!fRefPedestals || !fPedestals || !fALTROMasked || !fRefALTROMasked) return;
+  //loop over all channels
+  for (UInt_t isec=0;isec<AliTPCCalPad::kNsec;++isec){
+    AliTPCCalROC *pROC=fPedestals->GetCalROC(isec);
+    AliTPCCalROC *pRefROC=fRefPedestals->GetCalROC(isec);
+    AliTPCCalROC *mROC=fALTROMasked->GetCalROC(isec);
+    AliTPCCalROC *mRefROC=fRefALTROMasked->GetCalROC(isec);
+    UInt_t nrows=mROC->GetNrows();
+    for (UInt_t irow=0;irow<nrows;++irow){
+      UInt_t npads=mROC->GetNPads(irow);
+      for (UInt_t ipad=0;ipad<npads;++ipad){
+        //don't use masked channels;
+        if (mROC   ->GetValue(irow,ipad)) continue;
+        if (mRefROC->GetValue(irow,ipad)) continue;
+        Float_t deviation=TMath::Abs(pROC->GetValue(irow,ipad)-pRefROC->GetValue(irow,ipad));
+        for (Int_t i=0;i<npar;++i){
+          if (deviation>vThres[i])
+            ++pedestalDeviations.GetMatrixArray()[i];
+        }
+        ++nActive;
+      }//end ipad
+    }//ind irow
+  }//end isec
+  if (nActive>0){
+    for (Int_t i=0;i<npar;++i){
+      pedestalDeviations.GetMatrixArray()[i]/=nActive;
+    }
+  }
+}
+//_____________________________________________________________________________________
+void AliTPCcalibDButil::ProcessNoiseVariations(TVectorF &noiseDeviations)
+{
+  //
+  // check the variations of the noise data to the reference noise data
+  // thresholds are 5, 10, 15 and 20 percent respectively.
+  //
+  const Int_t npar=4;
+  TVectorF vThres(npar); //thresholds
+  Int_t nActive=0;       //number of active channels
+  
+  //reset and set thresholds
+  noiseDeviations.ResizeTo(npar);
+  for (Int_t i=0;i<npar;++i){
+    noiseDeviations.GetMatrixArray()[i]=0;
+    vThres.GetMatrixArray()[i]=(i+1)*.05;
+  }
+  //check all needed data is available
+  if (!fRefPadNoise || !fPadNoise || !fALTROMasked || !fRefALTROMasked) return;
+  //loop over all channels
+  for (UInt_t isec=0;isec<AliTPCCalPad::kNsec;++isec){
+    AliTPCCalROC *nROC=fPadNoise->GetCalROC(isec);
+    AliTPCCalROC *nRefROC=fRefPadNoise->GetCalROC(isec);
+    AliTPCCalROC *mROC=fALTROMasked->GetCalROC(isec);
+    AliTPCCalROC *mRefROC=fRefALTROMasked->GetCalROC(isec);
+    UInt_t nrows=mROC->GetNrows();
+    for (UInt_t irow=0;irow<nrows;++irow){
+      UInt_t npads=mROC->GetNPads(irow);
+      for (UInt_t ipad=0;ipad<npads;++ipad){
+        //don't use masked channels;
+        if (mROC   ->GetValue(irow,ipad)) continue;
+        if (mRefROC->GetValue(irow,ipad)) continue;
+        Float_t deviation=(nROC->GetValue(irow,ipad)/nRefROC->GetValue(irow,ipad))-1;
+        for (Int_t i=0;i<npar;++i){
+          if (deviation>vThres[i])
+            ++noiseDeviations.GetMatrixArray()[i];
+        }
+        ++nActive;
+      }//end ipad
+    }//ind irow
+  }//end isec
+  if (nActive>0){
+    for (Int_t i=0;i<npar;++i){
+      noiseDeviations.GetMatrixArray()[i]/=nActive;
+    }
+  }
+}
+//_____________________________________________________________________________________
+void AliTPCcalibDButil::ProcessPulserVariations(TVectorF &pulserQdeviations, Float_t &varQMean,
+                                                Int_t &npadsOutOneTB, Int_t &npadsOffAdd)
+{
+  //
+  // check the variations of the pulserQmean data to the reference pulserQmean data: pulserQdeviations
+  // thresholds are .5, 1, 5 and 10 percent respectively.
+  // 
+  //
+  const Int_t npar=4;
+  TVectorF vThres(npar); //thresholds
+  Int_t nActive=0;       //number of active channels
+  
+  //reset and set thresholds
+  pulserQdeviations.ResizeTo(npar);
+  for (Int_t i=0;i<npar;++i){
+    pulserQdeviations.GetMatrixArray()[i]=0;
+  }
+  npadsOutOneTB=0;
+  npadsOffAdd=0;
+  varQMean=0;
+  vThres.GetMatrixArray()[0]=.005;
+  vThres.GetMatrixArray()[1]=.01;
+  vThres.GetMatrixArray()[2]=.05;
+  vThres.GetMatrixArray()[3]=.1;
+  //check all needed data is available
+  if (!fRefPulserTmean || !fPulserTmean || !fPulserQmean || !fRefPulserQmean || !fALTROMasked || !fRefALTROMasked) return;
+  //
+  UpdateRefPulserOutlierMap();
+  //loop over all channels
+  for (UInt_t isec=0;isec<(UInt_t)AliTPCCalPad::kNsec;++isec){
+    AliTPCCalROC *pqROC=fPulserQmean->GetCalROC(isec);
+    AliTPCCalROC *pqRefROC=fRefPulserQmean->GetCalROC(isec);
+    AliTPCCalROC *ptROC=fPulserTmean->GetCalROC(isec);
+    //AliTPCCalROC *ptRefROC=fRefPulserTmean->GetCalROC(isec);
+    AliTPCCalROC *mROC=fALTROMasked->GetCalROC(isec);
+    AliTPCCalROC *mRefROC=fRefALTROMasked->GetCalROC(isec);
+    AliTPCCalROC *oROC=fPulserOutlier->GetCalROC(isec);
+    Float_t pt_mean=ptROC->GetMean(oROC);
+    UInt_t nrows=mROC->GetNrows();
+    for (UInt_t irow=0;irow<nrows;++irow){
+      UInt_t npads=mROC->GetNPads(irow);
+      for (UInt_t ipad=0;ipad<npads;++ipad){
+        //don't use masked channels;
+        if (mROC   ->GetValue(irow,ipad)) continue;
+        if (mRefROC->GetValue(irow,ipad)) continue;
+        //don't user edge pads
+        if (ipad==0||ipad==npads-1) continue;
+        //data
+        Float_t pq=pqROC->GetValue(irow,ipad);
+        Float_t pqRef=pqRefROC->GetValue(irow,ipad);
+        Float_t pt=ptROC->GetValue(irow,ipad);
+//         Float_t ptRef=ptRefROC->GetValue(irow,ipad);
+        //comparisons q
+        Float_t deviation=TMath::Abs(pq/pqRef-1);
+        for (Int_t i=0;i<npar;++i){
+          if (deviation>vThres[i])
+            ++pulserQdeviations.GetMatrixArray()[i];
+        }
+        if (pqRef>11&&pq<11) ++npadsOffAdd;
+        varQMean+=pq-pqRef;
+        //comparisons t
+        if (TMath::Abs(pt-pt_mean)>1) ++npadsOutOneTB;
+        ++nActive;
+      }//end ipad
+    }//ind irow
+  }//end isec
+  if (nActive>0){
+    for (Int_t i=0;i<npar;++i){
+      pulserQdeviations.GetMatrixArray()[i]/=nActive;
+      varQMean/=nActive;
+    }
+  }
+}
 //_____________________________________________________________________________________
 void AliTPCcalibDButil::UpdatePulserOutlierMap()
 {
   //
+  //
+  //
+  PulserOutlierMap(fPulserOutlier,fPulserTmean, fPulserQmean);
+}
+//_____________________________________________________________________________________
+void AliTPCcalibDButil::UpdateRefPulserOutlierMap()
+{
+  //
+  //
+  //
+  PulserOutlierMap(fRefPulserOutlier,fRefPulserTmean, fRefPulserQmean);
+}
+//_____________________________________________________________________________________
+void AliTPCcalibDButil::PulserOutlierMap(AliTPCCalPad *pulOut, const AliTPCCalPad *pulT, const AliTPCCalPad *pulQ)
+{
+  //
   // Create a map that contains outliers from the Pulser calibration data.
   // The outliers include masked channels, edge pads and pads with
   //   too large timing and charge variations.
-  // nonMaskedZero is the number of outliers in the Pulser calibration data.
+  // fNpulserOutliers is the number of outliers in the Pulser calibration data.
   //   those do not contain masked and edge pads
   //
-  if (!fPulserTmean||!fPulserQmean) {
+  if (!pulT||!pulQ) {
     //reset map
-    fPulserOutlier->Multiply(0.);
+    pulOut->Multiply(0.);
     fNpulserOutliers=-1;
     return;
   }
@@ -541,9 +755,9 @@ void AliTPCcalibDButil::UpdatePulserOutlierMap()
   
   //Create Outlier Map
   for (UInt_t isec=0;isec<AliTPCCalPad::kNsec;++isec){
-    AliTPCCalROC *tmeanROC=fPulserTmean->GetCalROC(isec);
-    AliTPCCalROC *qmeanROC=fPulserQmean->GetCalROC(isec);
-    AliTPCCalROC *outROC=fPulserOutlier->GetCalROC(isec);
+    AliTPCCalROC *tmeanROC=pulT->GetCalROC(isec);
+    AliTPCCalROC *qmeanROC=pulQ->GetCalROC(isec);
+    AliTPCCalROC *outROC=pulOut->GetCalROC(isec);
     if (!tmeanROC||!qmeanROC) {
       //reset outliers in this ROC
       outROC->Multiply(0.);
@@ -650,3 +864,31 @@ Float_t AliTPCcalibDButil::GetMeanAltro(const AliTPCCalROC *roc, const Int_t row
   if (n>0) mean/=n;
   return mean;
 }
+//_____________________________________________________________________________________
+void AliTPCcalibDButil::SetRefFile(const char* filename)
+{
+  //
+  // load cal pad objects form the reference file
+  //
+  TDirectory *currDir=gDirectory;
+  TFile f(filename);
+  fRefPedestals=(AliTPCCalPad*)f.Get("Pedestals");
+  fRefPadNoise=(AliTPCCalPad*)f.Get("PadNoise");
+  //pulser data
+  fRefPulserTmean=(AliTPCCalPad*)f.Get("PulserTmean");
+  fRefPulserTrms=(AliTPCCalPad*)f.Get("PulserTrms");
+  fRefPulserQmean=(AliTPCCalPad*)f.Get("PulserQmean");
+  //CE data
+  fRefCETmean=(AliTPCCalPad*)f.Get("CETmean");
+  fRefCETrms=(AliTPCCalPad*)f.Get("CETrms");
+  fRefCEQmean=(AliTPCCalPad*)f.Get("CEQmean");
+  //Altro data
+//   fRefALTROAcqStart=(AliTPCCalPad*)f.Get("ALTROAcqStart");
+//   fRefALTROZsThr=(AliTPCCalPad*)f.Get("ALTROZsThr");
+//   fRefALTROFPED=(AliTPCCalPad*)f.Get("ALTROFPED");
+//   fRefALTROAcqStop=(AliTPCCalPad*)f.Get("ALTROAcqStop");
+  fRefALTROMasked=(AliTPCCalPad*)f.Get("ALTROMasked");
+  f.Close();
+  currDir->cd();
+}
+
index 34754a4..d0f49a5 100644 (file)
@@ -27,7 +27,8 @@ public:
 
   void UpdateFromCalibDB();
   //data processing functions
-  void ProcessCEdata(const char* fitFormula, TVectorD &fitResultsA, TVectorD &fitResultsC, Int_t &noutliersCE);
+  void ProcessCEdata(const char* fitFormula, TVectorD &fitResultsA, TVectorD &fitResultsC,
+                     Int_t &noutliersCE, AliTPCCalPad *outCE=0);
   void ProcessCEgraphs(TVectorD &vecTEntries, TVectorD &vecTMean, TVectorD &vecTRMS, TVectorD &vecTMedian,
                        TVectorD &vecQEntries, TVectorD &vecQMean, TVectorD &vecQRMS, TVectorD &vecQMedian,
                        Float_t &driftTimeA, Float_t &driftTimeC );
@@ -37,6 +38,10 @@ public:
   void ProcessPulser(TVectorD &vMeanTime);
   void ProcessALTROConfig(Int_t &nMasked);
   void ProcessGoofie(TVectorD & vecEntries, TVectorD & vecMedian, TVectorD &vecMean, TVectorD &vecRMS);
+  //processing functions using reference data
+  void ProcessPedestalVariations(TVectorF &pedestalDeviations);
+  void ProcessNoiseVariations(TVectorF &noiseDeviations);
+  void ProcessPulserVariations(TVectorF &pulserQdeviations, Float_t &varQMean, Int_t &npadsOutOneTB, Int_t &npadsOffAdd);
   //getter preprocess information
   Int_t GetNPulserOutliers() const {return fNpulserOutliers;}
   Float_t GetMeanAltro(const AliTPCCalROC *roc, const Int_t row, const Int_t pad, AliTPCCalROC *rocOut=0x0);
@@ -51,10 +56,23 @@ public:
   void SetALTROData(AliTPCCalPad *masked)
                 {fALTROMasked=masked;}
   void SetGoofieArray(AliDCSSensorArray *arr) {fGoofieArray=arr;}
+  //setters for pad by pad information
+  void SetRefFile(const char* filename);
+  void SetRefPulserData(AliTPCCalPad *tmean, AliTPCCalPad *trms=0x0, AliTPCCalPad *qmean=0x0)
+                {fRefPulserTmean=tmean; fRefPulserTrms=trms; fRefPulserQmean=qmean;}
+  void SetRefCEData(AliTPCCalPad *tmean, AliTPCCalPad *trms=0x0, AliTPCCalPad *qmean=0x0)
+                {fRefCETmean=tmean; fRefCETrms=trms; fRefCEQmean=qmean;}
+  void SetRefNoisePedestal(AliTPCCalPad *noise, AliTPCCalPad *pedestal=0x0)
+                {fRefPadNoise=noise; fRefPedestals=pedestal;}
+  void SetRefALTROData(AliTPCCalPad *masked)
+                {fRefALTROMasked=masked;}
+  
   //creation of derived pad by pad calibration data
   AliTPCCalPad *CreatePadTime0(Int_t model=0);
   //
   void UpdatePulserOutlierMap();
+  void UpdateRefPulserOutlierMap();
+  void PulserOutlierMap(AliTPCCalPad *pulOut, const AliTPCCalPad *pulT, const AliTPCCalPad *pulQ);
 private:
   AliTPCcalibDB *fCalibDB;            //pointer to calibDB object
   AliTPCCalPad  *fPadNoise;           //noise information
@@ -69,6 +87,20 @@ private:
   AliTPCCalPad  *fALTROMasked;        //ALTRO masked channels information
   //
   AliTPCCalibRaw *fCalibRaw;          //raw calibration object
+  //reference data
+  AliTPCCalPad  *fRefPadNoise;           //Reference noise information
+  AliTPCCalPad  *fRefPedestals;          //Reference pedestal information
+  AliTPCCalPad  *fRefPulserTmean;        //Reference pulser mean time information
+  AliTPCCalPad  *fRefPulserTrms;         //Reference pulser rms time information
+  AliTPCCalPad  *fRefPulserQmean;        //Reference pulser mean q information
+  AliTPCCalPad  *fRefPulserOutlier;      //Reference pulser outlier map
+  AliTPCCalPad  *fRefCETmean;            //Reference central electrode mean time information
+  AliTPCCalPad  *fRefCETrms;             //Reference central electrode rms time information
+  AliTPCCalPad  *fRefCEQmean;            //Reference central electrode mean q information
+  AliTPCCalPad  *fRefALTROMasked;        //Reference ALTRO masked channels information
+  //
+  AliTPCCalibRaw *fRefCalibRaw;          //Reference raw calibration object
+  
   //
   AliDCSSensorArray* fGoofieArray;    //Goofie Data
   //
index b79de29..c9a52c5 100644 (file)
@@ -1,6 +1,6 @@
 /*
-.x ~/NimStyle.C
-.x ~/rootlogon.C
+// .x ~/NimStyle.C
+// .x ~/rootlogon.C
 
 gSystem->AddIncludePath("-I$ALICE_ROOT/TPC");
 
@@ -57,10 +57,12 @@ if (!gGrid) TGrid::Connect("alien://",0,0,"t");
 #include "TVectorD.h"
 #include "TMatrixD.h"
 #include "AliTPCCalibRaw.h"
+#include "AliSplineFit.h"
 
 
 TTree * dcsTree=0;
-
+TString refFile="/data/Work/data/calib/guiTrees/RefCalPads_83680.root";
+// TString refFile="/lustre/alice/wiechula/calib/guiTrees/RefCalPads_83680.root"
 void GetProductionInfo(Int_t run, Int_t &nalien, Int_t &nRawAlien, Int_t &nlocal, Int_t &nRawLocal);
   
 void Init2008(){
@@ -108,6 +110,13 @@ void CalibEnv(const char * runList){
   Int_t irun=0;
   TTreeSRedirector *pcstream = new TTreeSRedirector("dcsTime.root");
   AliTPCcalibDButil dbutil;
+  dbutil.SetRefFile(refFile.Data());
+  Int_t startTime = 0;
+  Int_t endTime = 0;
+  Int_t startTimeGRP = 0;
+  Int_t stopTimeGRP  = 0;
+
+  AliSplineFit *fitVdrift=0x0;
   //  for (Int_t irun=startRun; irun<stopRun; irun++){
   while(in.good()) {
     in >> irun;
@@ -116,16 +125,29 @@ void CalibEnv(const char * runList){
     printf("Processing run %d ...\n",irun);
     AliTPCcalibDB::Instance()->SetRun(irun);
     dbutil.UpdateFromCalibDB();
-    AliDCSSensor * sensorPressure = AliTPCcalibDB::Instance()->GetPressureSensor(irun);
-    if (!sensorPressure) continue;
+    AliDCSSensorArray *arrHV=calibDB->GetVoltageSensors(irun);
+    if (!arrHV) continue;
+    for  (Int_t isenHV=0; isenHV<arrHV->NumSensors(); ++isenHV){
+      AliDCSSensor *senHV=arrHV->GetSensorNum(isenHV);
+      if (!senHV) continue;
+      startTime=senHV->GetStartTime();
+      endTime  =senHV->GetEndTime();
+      if (startTime>0&&endTime>0) break;
+    }
+    if (calibDB->GetGRP(irun)){
+      startTimeGRP = AliTPCcalibDB::GetGRP(irun)->GetTimeStart();
+      stopTimeGRP  = AliTPCcalibDB::GetGRP(irun)->GetTimeEnd();
+    }
+    //    AliDCSSensor * sensorPressure = AliTPCcalibDB::Instance()->GetPressureSensor(irun);
+//     if (!sensorPressure) continue;
+//     Int_t startTime = sensorPressure->GetStartTime();
+//     Int_t endTime = sensorPressure->GetEndTime();
+//     Int_t startTimeGRP = AliTPCcalibDB::GetGRP(irun)->GetTimeStart();
+//     Int_t stopTimeGRP  = AliTPCcalibDB::GetGRP(irun)->GetTimeEnd();
     AliTPCSensorTempArray * tempArray = AliTPCcalibDB::Instance()->GetTemperatureSensor(irun);
     AliTPCTempMap * tempMap = new AliTPCTempMap(tempArray);
     AliDCSSensorArray* goofieArray = AliTPCcalibDB::Instance()->GetGoofieSensors(irun);
     //
-    Int_t startTime = sensorPressure->GetStartTime();
-    Int_t endTime = sensorPressure->GetEndTime();
-    Int_t startTimeGRP = AliTPCcalibDB::GetGRP(irun)->GetTimeStart();
-    Int_t stopTimeGRP  = AliTPCcalibDB::GetGRP(irun)->GetTimeEnd();
     Int_t dtime = TMath::Max((endTime-startTime)/20,10*60);
     //Goofie statistical data
     TVectorD vecEntries, vecMean, vecMedian,vecRMS;
@@ -133,16 +155,29 @@ void CalibEnv(const char * runList){
     //CE data processing - see ProcessCEdata function for description of the results
     TVectorD fitResultsA, fitResultsC;
     Int_t nmaskedCE;
-    dbutil.ProcessCEdata("gx++gy++lx++lx**2",fitResultsA,fitResultsC,nmaskedCE);
+    dbutil.ProcessCEdata("(sector<36)++gx++gy++lx++lx**2",fitResultsA,fitResultsC,nmaskedCE);
     TVectorD vecTEntries, vecTMean, vecTRMS, vecTMedian, vecQEntries, vecQMean, vecQRMS, vecQMedian;
     Float_t driftTimeA, driftTimeC;
     dbutil.ProcessCEgraphs(vecTEntries, vecTMean, vecTRMS, vecTMedian,
                            vecQEntries, vecQMean, vecQRMS, vecQMedian,
                            driftTimeA, driftTimeC );
+    //drift velocity using tracks
+    fitVdrift=calibDB->GetVdriftSplineFit("ALISPLINEFIT_MEAN_VDRIFT_COSMICS_ALL",irun);
     //noise data Processing - see ProcessNoiseData function for description of the results
     TVectorD vNoiseMean, vNoiseMeanSenRegions, vNoiseRMS, vNoiseRMSSenRegions;
     Int_t nonMaskedZero=0;
     dbutil.ProcessNoiseData(vNoiseMean, vNoiseMeanSenRegions, vNoiseRMS, vNoiseRMSSenRegions, nonMaskedZero);
+    // comparisons
+    TVectorF pedestalDeviations;
+    TVectorF noiseDeviations;
+    TVectorF pulserQdeviations;
+    Float_t varQMean;
+    Int_t npadsOutOneTB;
+    Int_t npadsOffAdd;
+    dbutil.ProcessPedestalVariations(pedestalDeviations);
+    dbutil.ProcessNoiseVariations(noiseDeviations);
+    dbutil.ProcessPulserVariations(pulserQdeviations,varQMean,npadsOutOneTB,npadsOffAdd);
+    
     //L3 data 
     Float_t bz=AliTPCcalibDB::GetBz(irun);
     Char_t  l3pol=AliTPCcalibDB::GetL3Polarity(irun);
@@ -225,7 +260,9 @@ void CalibEnv(const char * runList){
       Float_t  skirtC=AliTPCcalibDB::GetSkirtVoltage(irun,18,itime);
       Float_t  ggOffA=AliTPCcalibDB::GetGGoffsetVoltage(irun,0,itime);
       Float_t  ggOffC=AliTPCcalibDB::GetGGoffsetVoltage(irun,18,itime);
-      
+      //drift velocity
+      Float_t dvCorr=-5;
+      if (fitVdrift) dvCorr=fitVdrift->Eval(itime);
       
       
       //tempMap->GetLinearFitter(0,0,itime);
@@ -310,6 +347,15 @@ void CalibEnv(const char * runList){
         "nRawAlien="<<nRawAlien<<
         "nlocal="<<nlocal<<
         "nRawLocal="<<nRawLocal<<
+        //comparisons with ref data
+        "pedestalDeviations.="<<&pedestalDeviations<<
+        "noiseDeviations.="<<&noiseDeviations<<
+        "pulserQdeviations.="<<&pulserQdeviations<<
+//         "pulserVarQMean="<<varQMean<<
+        "pulserNpadsOutOneTB="<<npadsOutOneTB<<
+        "pulserNpadsOffAdd="<<npadsOffAdd<<
+        "driftCorrCosmAll="<<dvCorr<<
+      
         "\n";
     }
   }
index b1f4675..a3c362f 100644 (file)
@@ -48,12 +48,32 @@ rmsNoise.           1, RMS_Noise, Noise_Pedestals, All_Pads, IROCs, OROCs_small_pads, ORO
 rmsNoiseSen.           1, RMS_Noise_in_sensitive_regions, Noise_Pedestals, All_Pads, IROCs, OROCs_small_pads, OROCs_large_pads
 zeroNoise              1, Pads_with_zero_noise, Noise_Pedestals
 nMasked                1, Number_of_masked_pads, ALTRO
-nOffPulser             1, Pads_without_pulser_signal
-CEfitA.                1, CE_Fit_A-Side, CE, Offset, dt/dgx_[timebins/cm], dt/dgy_[timebins/cm], dt/dlx_[timebins/cm], dt/dlx^{2}_[timebins/cm^{2}]
-CEfitC.                1, CE_Fit_C-Side, CE, Offset, dt/dgx_[timebins/cm], dt/dgy_[timebins/cm], dt/dlx_[timebins/cm], dt/dlx^{2}_[timebins/cm^{2}]
+nOffPulser             1, Pads_without_pulser_signal, Pulser
+timePulser.   1, Pulser_Position_[timebins], Pulser, IROC_A-Side, IROC_C-Side, OROC_A-Side, OROC_C-Side
+CEfitA.                1, CE_Fit_A-Side, CE, Offset_[timebins], IROC/OROC_Offset_[timebins], dt/dgx_[timebins/cm], dt/dgy_[timebins/cm], dt/dlx_[timebins/cm], dt/dlx^{2}_[timebins/cm^{2}]
+CEfitC.                1, CE_Fit_C-Side, CE, Offset_[timebins], IROC/OROC_Offset_[timebins], dt/dgx_[timebins/cm], dt/dgy_[timebins/cm], dt/dlx_[timebins/cm], dt/dlx^{2}_[timebins/cm^{2}]
+nmaskedCE 1, CE_Number_of_outliers, CE
 Bz             1, Magnetic_Field_[T]
 L3polarity             1, L3_polarity, Environment
 nalien         1, Number_of_ESDs_in_alien, reco
 nRawAlien    1, Number_of_Raw_in_alien, reco
 nlocal         1, Number_of_ESDs_local, reco
 nRawLocal 1, Number_of_Raw_local, reco
+nFailL1 1, RCU_synchonisation_failures, ALTRO
+CEgrTEntries.  1, CE_Drift_Time_Entries_ROC, CE,
+CEgrTMean.  1, CE_Drift_Time_Mean_ROC, CE,
+CEgrTRMS.  1, CE_Drift_Time_RMS_ROC, CE,
+CEgrTMedian.  1, CE_Drift_Time_Median_ROC, CE,
+CEgrQEntries.  1, CE_Q_Entries_-_ROC, CE,
+CEgrQMean.  1, CE_Q_Mena_-_ROC, CE,
+CEgrQRMS.  1, CE_Q_RMS_-_ROC, CE,
+CEgrQMedian.  1, CE_Q_Median_-_ROC, CE,
+CEgrDriftA  1, CE_Drift_Time_Mean_A-Side, CE,
+CEgrDriftC  1, CE_Drift_Time_Mean_C-Side, CE,
+pedestalDeviations. 1, Pedestal_var_to_ref_[fraction], Noise_Pedestals, >#pm_0.5_ADC, >#pm_1_ADC, >#pm_1.5_ADC, >#pm_2.0_ADC
+noiseDeviations. 1, Noise_var_to_ref_[fraction], Noise_Pedestals, >5%, >10%, >15%, >20%
+pulserQdeviations. 1, PulserQ_var_to_ref_[fraction], Pulser, >0.5%, >1%, >5%, >10%
+#pulserVarQMean
+pulserNpadsOutOneTB 1, Number_of_pads_with_PulserT_var_>#pm_1_tb_to_ROC_mean, Pulser
+pulserNpadsOffAdd 1, Number_of_pads_without_signal_but_signal_in_ref
+