protection against exidental writing
authoralla <alla@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 13 Nov 2009 13:09:36 +0000 (13:09 +0000)
committeralla <alla@f7af4fe6-9843-0410-8265-dc069ae4e863>
Fri, 13 Nov 2009 13:09:36 +0000 (13:09 +0000)
T0/AliT0CalibWalk.cxx
T0/AliT0CalibWalk.h
T0/AliT0Preprocessor.cxx

index e4a40c0..4f42b6b 100644 (file)
@@ -33,7 +33,7 @@
 #include <Riostream.h>
 #include <TSpectrum.h>
 #include <TProfile.h>
-
+#include <TF1.h>
 
 ClassImp(AliT0CalibWalk)
 
@@ -115,7 +115,7 @@ void AliT0CalibWalk::SetWalk(Int_t ipmt)
     i++;
   }
   inFile.close();
-  cout<<" number of data "<<i<<endl;
+  //  cout<<" number of data "<<i<<endl;
  
   TMath::Sort(i, y, index,down);
   Int_t amp=0, iin=0, isum=0, sum=0;
@@ -194,67 +194,84 @@ void AliT0CalibWalk::SetAmpLEDRec(Int_t ipmt)
 void AliT0CalibWalk::MakeWalkCorrGraph(const char *laserFile)
 {
   //make walk corerction for preprocessor
-  
+  Int_t nmips=14;
   gFile = TFile::Open(laserFile);
   if(!gFile) {
     AliError("No input laser data found ");
   }
   else
     {
-      gFile->ls();
-      Float_t x1[10], y1[10]; 
-      Float_t x2[10], y2[10];
-      
-      Float_t xx1[10],yy1[10], xx[10];
-      for (Int_t ii=0; ii<10; ii++)
+      //      gFile->ls();
+
+      Float_t x1[14], y1[14]; 
+      Float_t x2[14], y2[14];
+  
+      Float_t mips[14] = {1.,2,3,4,5,6,7,8,9,10,20,30,40,50};
+     
+      Float_t xx1[14],yy1[14], xx[14];
+      for (Int_t ii=0; ii<14; ii++)
        {      x1[ii]=0; y1[ii]=0; x2[ii]=0; y2[ii]=0; }
       
       
-      TH2F*  hCFDvsQTC[24][10]; TH2F*  hCFDvsLED[24][10];
+      TH2F*  hCFDvsQTC[24][14]; TH2F*  hCFDvsLED[24][14];
       
       for (Int_t i=0; i<24; i++)
        {
-         for (Int_t im=0; im<10; im++)
-           {
-             
+         for (Int_t im=0; im<nmips; im++)
+           {         
              TString qtc = Form("CFDvsQTC%i_%i",i+1,im+1);
              TString led = Form("CFDvsLED%i_%i",i+1,im+1);
-             cout<<qtc<<" "<<led<<endl;
              hCFDvsQTC[i][im] = (TH2F*) gFile->Get(qtc.Data()) ;
              hCFDvsLED[i][im] = (TH2F*) gFile->Get(led.Data());
              
-             //              if(!hCFDvsQTC[i][im] || !hCFDvsLED[i][im]) 
-             //                AliWarning(Form(" no walk correction data in LASER DA for channel %i for amplitude %i MIPs",i,im));
+             if(!hCFDvsQTC[i][im] || !hCFDvsLED[i][im]) 
+               AliWarning(Form(" no walk correction data in LASER DA for channel %i for amplitude %f MIPs",i,mips[im]));
              
-             if(hCFDvsQTC[i][im] && hCFDvsLED[i][im])
+             if(hCFDvsQTC[i][im])
                {         
                  x1[im] = hCFDvsQTC[i][im]->GetMean(1);
                  y1[im] = hCFDvsQTC[i][im]->GetMean(2);
+               }
+             if( hCFDvsLED[i][im]){
                  x2[im] = hCFDvsLED[i][im]->GetMean(1);
                  y2[im] = hCFDvsLED[i][im]->GetMean(2);
                }
-             xx[im]=im+1;
+             xx[im]=mips[im];
            }
-         for (Int_t imi=0; imi<10; imi++)
+         for (Int_t imi=0; imi<nmips; imi++)
            {
-             yy1[imi] = Float_t (10-imi);
-             xx1[imi]=x2[10-imi-1]; 
+             yy1[imi] = Float_t (mips[nmips-imi-1]);
+             xx1[imi] = x2[nmips-imi-1]; 
            }
-         if(i==0){     
-        cout<<"Making graphs..."<<endl;
-         }
-         TGraph *gr1 = new TGraph (10,x1,y1);
-         TGraph *gr2 = new TGraph (10,x2,y2);
-         fWalk.AddAtAndExpand(gr1,i);
-         fAmpLEDRec.AddAtAndExpand(gr2,i);
-         
+         if(i==0) cout<<"Making graphs..."<<endl;
          
-         
-         TGraph *gr4 = new TGraph (10,xx1,yy1);
-         TGraph *gr3 = new TGraph (10,x1,xx);
-         fQTC.AddAtAndExpand(gr3,i);    
-         fAmpLED.AddAtAndExpand(gr4,i);
-         //      for (Int_t im=0; im<10; im++) { x2[im]=0;  y2[im]=0;  xx1[im]=0; xx[im]=0;}
+         TGraph *grwalkqtc = new TGraph (nmips,x1,y1);
+         TGraph *grwalkled = new TGraph (nmips,x2,y2);
+         fWalk.AddAtAndExpand(grwalkqtc,i);
+         fAmpLEDRec.AddAtAndExpand(grwalkled,i);
+        
+         //fit amplitude graphs to make comparison wth new one   
+         TGraph *grampled = new TGraph (nmips,xx1,yy1);
+         TGraph *grqtc = new TGraph (nmips,x1,xx);
+         fQTC.AddAtAndExpand(grqtc,i);  
+         fAmpLED.AddAtAndExpand(grampled,i);
+
+         //fit amplitude graphs
+         Double_t parled [2], parqtc[2];
+
+         TF1 *fuled = new TF1("fuled","expo",x1[0],x1[nmips]);
+         TF1 *fuqtc = new TF1 ("fuqtc","pol1",x1[0],x1[nmips]);
+         grqtc->Fit("fuqtc","Q"," ",x1[0],x1[nmips]);
+         grampled->Fit("fuled","Q"," ",xx1[0],xx1[nmips]);
+         fuled->GetParameters(&parled[0]);
+         fuqtc->GetParameters(&parqtc[0]);
+
+         for(Int_t ipar=0; ipar<2; ipar++) {
+           SetQTCpar(i,ipar,parqtc[ipar]);
+           SetAmpLEDpar(i,ipar,parled[ipar]);
+           //      cout<<" pars :::: "<<i<<" "<<ipar<<" qtc "<<parqtc[ipar]<<" led "<<parled[ipar]<<endl;
+         }
+
          if(i==23){
            cout<<"Graphs created..."<<endl;
          }
index fd63dc4..e96a04e 100644 (file)
@@ -5,7 +5,7 @@
  * See cxx source for full Copyright notice                               */
 
 ////////////////////////////////////////////////
-//  class for T0 calibration                 //
+//  class for T0 amplitude calibration                 //
 ////////////////////////////////////////////////
 
 #include "TNamed.h"
@@ -27,27 +27,35 @@ class AliT0CalibWalk: public TNamed {
   TObjArray* GetfWalk() {return &fWalk;}    
 
   TGraph *GetQTC(Int_t ipmt )  const {return (TGraph*)fQTC.At(ipmt);}
-  // void SetQTC(Int_t ipmt) ;
-  
+  Float_t  GetQTCpar(Int_t channel, Int_t ipar)    const 
+  {return fQTCpar[channel][ ipar ];}
+  void SetQTCpar(Int_t channel,Int_t ipar, Float_t val) 
+  {fQTCpar[channel][ipar]=val;}
   TGraph *GetAmpLED(Int_t ipmt )  const {return (TGraph*)fAmpLED.At(ipmt);}
-  //  void SetAmpLED(Int_t ipmt) ;
+  Float_t  GetLEDpar(Int_t channel, Int_t ipar)    const 
+  {return fAmpLEDpar[channel][ ipar ];}
+  void SetAmpLEDpar(Int_t channel,Int_t ipar, Float_t val)
+  {fAmpLEDpar[channel][ipar]=val;}
  
   void MakeWalkCorrGraph(const char *laserFile);
   
   
 
   TGraph *  GetAmpLEDRec(Int_t ipmt) const   {return (TGraph*)fAmpLEDRec.At(ipmt);}
-  void     SetAmpLEDRec(Int_t ipmt) ;
+  void      SetAmpLEDRec(Int_t ipmt) ;
    
  protected:
    
    TObjArray   fWalk;  //time - amp. walk
-   TObjArray fAmpLEDRec;  //time - amp. LED-CFD for reconstruction
+   TObjArray   fAmpLEDRec;  //time - amp. LED-CFD for reconstruction
    TObjArray   fQTC;  //time - amp. walk
-   TObjArray fAmpLED;  //time - amp. LED-CFD for reconstruction
+   TObjArray   fAmpLED;  //time - amp. LED-CFD for reconstruction
+   Float_t   fQTCpar[24][2]; // fitted parameters QTC amplitude
+   Float_t   fAmpLEDpar[24][2]; // fitted parameters fAmpLEDpar amplitude
   
    //
-   ClassDef(AliT0CalibWalk,2)    // T0 Sensor Calibration data
+   ClassDef(AliT0CalibWalk,4)    // T0 Amplitude Calibration data
      };
 
      typedef AliT0CalibWalk AliSTARTCalibWalk; // for backward compatibility
index fb753ba..c2d3a8f 100644 (file)
@@ -44,6 +44,7 @@ Preliminary test version (T.Malkiewicz)
 
 #include "AliCDBMetaData.h"
 #include "AliDCSValue.h"
+#include "AliCDBEntry.h"
 #include "AliLog.h"
 
 #include <TTimeStamp.h>
@@ -52,6 +53,8 @@ Preliminary test version (T.Malkiewicz)
 #include <TNamed.h>
 #include "AliT0Dqclass.h"
 
+#include "iostream.h"
+
 
 ClassImp(AliT0Preprocessor)
 
@@ -92,8 +95,8 @@ Bool_t AliT0Preprocessor::ProcessDCS(){
        if((runType == "STANDALONE")||
           (runType == "PHYSICS")||
           (runType == "LASER")){
-         //            return kFALSE;
-               return kTRUE;
+         return kFALSE;
+         //    return kTRUE;
        }else{
        return kFALSE;
        }
@@ -140,13 +143,37 @@ UInt_t AliT0Preprocessor::ProcessDCSDataPoints(TMap* dcsAliasMap){
 
 UInt_t AliT0Preprocessor::ProcessLaser(){
        // Processing data from DAQ Standalone run
-       Log("Processing Laser calibration - Walk Correction");
-       
-       Bool_t resultLaser=kFALSE;
-       //processing DAQ
-        TList* list = GetFileSources(kDAQ, "LASER");
-        if (list)
-        {
+  Log("Processing Laser calibration - Walk Correction");
+  
+  //Retrieve the last T0 calibration object
+
+  Float_t parqtcold[24][2], parledold[24][2],parqtcnew[24][2], parlednew[24][2] , goodled[24][2], goodqtc[24][2];
+
+
+  AliT0CalibWalk* clb=0;
+  AliCDBEntry* entryCalib = GetFromOCDB("Calib", "Slewing_Walk");
+  if(!entryCalib)
+    Log(Form("Cannot find any AliCDBEntry for [Calib, SlewingWalk]!"));
+  else {
+    clb = (AliT0CalibWalk*)entryCalib->GetObject();
+
+    for(Int_t i=0; i<24; i++)
+      {
+       for(Int_t ipar=0; ipar<2; ipar++)
+         {
+           parqtcold[i][ipar] = clb->GetQTCpar(i,ipar);
+           parledold[i][ipar] = clb->GetLEDpar(i, ipar);
+           goodqtc[i][ipar] = 999;
+           goodled[i][ipar] = 999;
+           //      cout<<" old "<<i<<" "<<ipar<<" qtc "<< parqtcold[i][ipar]<<" led "<<parledold[i][ipar]<<endl;
+         }
+      }
+  }
+  Bool_t resultLaser=kFALSE;
+  //processing DAQ
+  TList* list = GetFileSources(kDAQ, "LASER");
+  if (list)
+    {
             TIter iter(list);
             TObjString *source;
             while ((source = dynamic_cast<TObjString *> (iter.Next())))
@@ -157,11 +184,40 @@ UInt_t AliT0Preprocessor::ProcessLaser(){
                 Log(Form("File with Id LASER found in source %s!", source->GetName()));
                 AliT0CalibWalk *laser = new AliT0CalibWalk();
                 laser->MakeWalkCorrGraph(laserFile);
-                AliCDBMetaData metaData;
-                metaData.SetBeamPeriod(0);
+               Int_t iStore=0;
+               //check difference with what was before
+               if(laser && clb){
+               iStore = 1;                             
+                 for(Int_t i=0; i<24; i++)
+                   {
+                     for(Int_t ifit=0; ifit<2; ifit++)
+                       {
+                         parqtcnew[i][ifit] = laser->GetQTCpar(i,ifit);
+                         if( parqtcold[i][ifit] != 0 && parqtcnew[i][ifit] !=0) 
+                           {
+                             goodqtc[i][ifit] = 
+                               (parqtcnew[i][ifit] - parqtcold[i][ifit])/parqtcold[i][ifit];
+                             //                              cout<<"qtc "<<i<<" "<<ifit<<" "<< goodqtc[i][ifit]<<endl;
+                           }
+                         parlednew[i][ifit] = laser->GetLEDpar(i,ifit);
+                         if(parledold[i][ifit] != 0 ) 
+                           {
+                             goodled[i][ifit]= 
+                               (parlednew[i][ifit] - parledold[i][ifit])/parledold[i][ifit];   
+                             //                              cout<<"led "<<i<<" "<<ifit<<" "<< goodled[i][ifit]<<endl;
+                           }                   
+                         if(TMath::Abs(goodqtc[i][ifit])>0.1 || 
+                            TMath::Abs(goodled[i][ifit])>0.1) 
+                           iStore = 0;
+                       }
+                   }
+               }
+               AliCDBMetaData metaData;
+               metaData.SetBeamPeriod(0);
                 metaData.SetResponsible("Tomek&Michal");
                 metaData.SetComment("Walk correction from laser runs.");
-               resultLaser=Store("Calib","Slewing_Walk", laser, &metaData, 0, 1);
+               if( iStore>0)
+                 resultLaser=Store("Calib","Slewing_Walk", laser, &metaData, 0, 1);
                 delete laser;
                Log(Form("resultLaser = %d",resultLaser));
               }