Reconstruction with measused calibration
authoralla <alla@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 19 Feb 2008 18:51:09 +0000 (18:51 +0000)
committeralla <alla@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 19 Feb 2008 18:51:09 +0000 (18:51 +0000)
T0/AliT0CalibTimeEq.cxx
T0/AliT0CalibTimeEq.h
T0/AliT0CalibWalk.cxx
T0/AliT0Parameters.cxx
T0/AliT0RawReader.cxx
T0/AliT0RawReader.h
T0/AliT0Reconstructor.cxx

index 520dee9..d950d5b 100644 (file)
@@ -29,6 +29,7 @@
 #include <TF1.h>
 #include <TSpectrum.h>
 #include <TProfile.h>
+#include "iostream.h"
 
 ClassImp(AliT0CalibTimeEq)
 
@@ -97,9 +98,11 @@ void  AliT0CalibTimeEq::Print(Option_t*) const
 
 
 //________________________________________________________________
-void AliT0CalibTimeEq::ComputeOnlineParams(char* name1, Int_t npeaks, Double_t sigma, const char* filePhys)
+void AliT0CalibTimeEq::ComputeOnlineParams(const char* filePhys)
 {
   // compute online equalized time
+  Int_t npeaks = 20;
+  Double_t sigma = 4.;
 
   TFile *gFile = TFile::Open(filePhys);
   Bool_t down=false;
@@ -109,12 +112,14 @@ void AliT0CalibTimeEq::ComputeOnlineParams(char* name1, Int_t npeaks, Double_t s
   Float_t p[24][3]={0.,0.,0.};
   for (Int_t i=0; i<24; i++)
   {
-    sprintf(buf1,name1);
-    sprintf(temp,"%i",i+1);
-    strcat (buf1,temp);
-    //strcat (buf1,name2);
+    sprintf(buf1,"CFD1-CFD%i",i+1);
     TH1F *cfd = (TH1F*) gFile->Get(buf1);
     printf(" i = %d buf1 = %s\n", i, buf1);
+    Double_t mean=cfd->GetMean();
+    SetTimeEq(i,mean);
+  }
+    /*
+
     TSpectrum *s = new TSpectrum(2*npeaks,1.);
     printf(" buf1 = %s cfd = %x\n", buf1, cfd);
     Int_t nfound = s->Search(cfd,sigma,"goff",0.2);
@@ -132,9 +137,12 @@ void AliT0CalibTimeEq::ComputeOnlineParams(char* name1, Int_t npeaks, Double_t s
       for(Int_t j =0; j<3; j++)
       {
         p[i][j] = g1->GetParameter(j);
-        SetCFDvalue(i, j, p[i][j]);
+       //      SetCFDvalue(i, j, p[i][j]);
       }
-
+        SetTimeEq(i,(p[i][2]));
+       cout<<" mean "<<p[i][2]<<endl;
+    */
+      /*
       SetCFDvalue(i, 3, hmin);
       SetCFDvalue(i, 4, hmax);
 
@@ -146,19 +154,12 @@ void AliT0CalibTimeEq::ComputeOnlineParams(char* name1, Int_t npeaks, Double_t s
       {
        SetTimeEq(i,(p[i][2]-p[12][2]));
       }        
+      
     } 
   }
-  
+      */  
    gFile->Close();
    delete gFile;
-
-   for(int i=0;i<5;i++)
-     {
-      for(int j=0;j<24;j++)
-       {
-                printf("fCFDvalue[%d][%d]=%f\n",j,i,fCFDvalue[j][i]);
-        }
-     }
    printf("\n\n");
    for(int j=0;j<24;j++)
    {
index 2638a12..5056503 100644 (file)
@@ -22,7 +22,7 @@ class AliT0CalibTimeEq: public TNamed {
   
   virtual void  Print(Option_t* option= "") const; 
   
-  void ComputeOnlineParams(char* name1, Int_t npeaks, Double_t sigma, const char* filePhys);
+  void ComputeOnlineParams(const char* filePhys);
   Float_t  GetCFDvalue(Int_t channel,Int_t number)        const {return fCFDvalue[channel][number];}
   Float_t* GetCFDvalue()          const {return (float*)fCFDvalue;}
   Float_t  GetTimeEq(Int_t channel)        const {return fTimeEq[channel];}
index c12505f..130b3ca 100644 (file)
@@ -180,144 +180,121 @@ void AliT0CalibWalk::MakeWalkCorrGraph(const char *laserFile)
 
   TFile *gFile = TFile::Open(laserFile);
   //gSystem->Load("libSpectrum");
-  TGraph *gr[24];
-  TGraph *grLED[24];
   Int_t npeaks = 20;
-  Int_t sigma=3;
-  Bool_t down=false;
+  Int_t sigma=3.;
+  Bool_t down = false;
 
   Int_t index[20];
-  Char_t buf1[10], buf2[10], buf3[10], title[10], title2[10], titleLED[10], title2LED[10];
-  TSpectrum *s = new TSpectrum(2*npeaks,1.);
-
-  for (Int_t d=0; d<2; d++)
-  {
-    for (Int_t i=0; i<12; i++)
+  Char_t buf1[10], buf2[10],buf3[20];
+  
+  
+  for (Int_t i=0; i<24; i++)
     {
-      sprintf(buf1,"T0_C_%i_CFD",i+1);
-      if (d==0)
-      {                
-        sprintf(buf2,"CFD_QTC%i",i+1);
-      }
-      else
-      {
-       sprintf(buf3,"CFD_LED%i",i+1);
-      }
-      TH2F *qtccfd = (TH2F*) gFile->Get(buf2);
-      TH2F *ledcfd = (TH2F*) gFile->Get(buf3);
-      // cout<<buf1<<" "<<buf2<<endl;
-      TH1F *cfd = (TH1F*) gFile->Get(buf1);
-      Int_t nfound = s->Search(cfd,sigma,"goff",0.05);
-      // cout<<"Found "<<nfound<<" peaks sigma "<<sigma<<endl;
-      if(nfound!=0)
-      {
-        Float_t *xpeak = s->GetPositionX();
-        TMath::Sort(nfound, xpeak, index,down);
-        Float_t xp = xpeak[index[0]];
-        Float_t hmax = xp+10*sigma;
-        Float_t hmin = xp-10*sigma;
-       if (d==0)
-       {
-          Int_t nbins= qtccfd->GetXaxis()->GetNbins();
-          TProfile *prY = qtccfd->ProfileX();
-          prY->SetMaximum(hmax);
-          prY->SetMinimum(hmin);
-          Int_t np=nbins/20;
-          Double_t *xx = new Double_t[np];
-          Double_t *yy = new Double_t[np];
-          Int_t ng=0;
-          Double_t yg=0;
-          for (Int_t ip=1; ip<nbins; ip++)
-          {
-            if(ip%20 != 0 )
-            {
-              if (prY->GetBinContent(ip) !=0)
-              {
-                yg +=prY->GetBinContent(ip);
-              }
-              ng++;
-            }
-            else
-            {
-              xx[ip/20] = Float_t (prY->GetBinCenter(ip));
-              yy[ip/20] = yg/ng;
-              yg=0;
-              ng=0;
-            }
-          }
-          sprintf(title,"Walk %i",i+1);
-          gr[i] = new TGraph(np,xx,yy);
-          gr[i]->SetTitle(title);
-          gr[i]->SetMinimum(hmin);
-          gr[i]->SetMaximum(hmax);
-          gr[i]->SetMarkerStyle(7);
-          sprintf(title2,"Walk %i",i+13);
-          gr[i+12] = new TGraph(np,xx,yy);
-          gr[i+12]->SetTitle(title2);
-          gr[i+12]->SetMinimum(hmin);
-          gr[i+12]->SetMaximum(hmax);
-          gr[i+12]->SetMarkerStyle(7);
+      if(i>11) {  sprintf(buf1,"T0_A_%i_CFD",i+1-12); }
 
-          fWalk.AddAtAndExpand(gr[i],i);         
-          fWalk.AddAtAndExpand(gr[i+12],i+12);
-          delete [] xx;
-          delete [] yy;
-         delete prY;
-       }
-       else
-       {
-         Int_t nbinsLED= ledcfd->GetXaxis()->GetNbins();
-          TProfile *prYLED = ledcfd->ProfileX();
-          prYLED->SetMaximum(hmax);
-          prYLED->SetMinimum(hmin);
-          Int_t npLED=nbinsLED/20;
-          Double_t *xxLED = new Double_t[npLED];
-          Double_t *yyLED = new Double_t[npLED];
-          Int_t ngLED=0;
-          Double_t ygLED=0;
-          for (Int_t ip=1; ip<nbinsLED; ip++)
-          {
-            if(ip%20 != 0 )
-            {
-              if (prYLED->GetBinContent(ip) !=0)
-              {
-                ygLED +=prYLED->GetBinContent(ip);
-              }
-              ngLED++;
-            }
-            else
-            {
-              xxLED[ip/20] = Float_t (prYLED->GetBinCenter(ip));
-              yyLED[ip/20] = ygLED/ngLED;
-              ygLED=0;
-              ngLED=0;
-            }
-          }
-          sprintf(titleLED,"Walk LED %i",i+1);
-          grLED[i] = new TGraph(npLED,xxLED,yyLED);
-          grLED[i]->SetTitle(titleLED);
-          grLED[i]->SetMinimum(hmin);
-          grLED[i]->SetMaximum(hmax);
-          grLED[i]->SetMarkerStyle(7);
-          sprintf(title2LED,"Walk LED%i",i+13);
-          grLED[i+12] = new TGraph(npLED,xxLED,yyLED);
-          grLED[i+12]->SetTitle(title2LED);
-          grLED[i+12]->SetMinimum(hmin);
-          grLED[i+12]->SetMaximum(hmax);
-          grLED[i+12]->SetMarkerStyle(7);
+      if(i<12) { sprintf(buf1,"T0_C_%i_CFD",i+1); }
 
-          fAmpLEDRec.AddAtAndExpand(grLED[i],i);
-          fAmpLEDRec.AddAtAndExpand(grLED[i+12],i+12);
-          delete [] xxLED;
-          delete [] yyLED;
-         delete prYLED;
-       }
+      sprintf(buf2,"CFD_QTC%i",i+1);
+      sprintf(buf3,"CFD_LED%i",i+1);
+      cout<<buf1<<" "<<buf2<<" "<<buf3<<endl;
+      TH2F *qtc_cfd = (TH2F*) gFile->Get(buf2);
+      TH2F *led_cfd = (TH2F*) gFile->Get(buf3);
+      TH1F *cfd = (TH1F*) gFile->Get(buf1);
+      //       cfd->Draw();
+      TSpectrum *s = new TSpectrum(2*npeaks,1);
+      Int_t nfound = s->Search(cfd,sigma," ",0.05);
+      cout<<"Found "<<nfound<<" peaks sigma "<<sigma<<endl;;
+      if(nfound!=0){
+       Float_t *xpeak = s->GetPositionX();
+       TMath::Sort(nfound, xpeak, index,down);
+       Float_t xp = xpeak[index[0]];
+       Int_t xbin = cfd->GetXaxis()->FindBin(xp);
+       Float_t yp = cfd->GetBinContent(xbin);
+       cout<<"xbin = "<<xbin<<"\txpeak = "<<xpeak[1]<<"\typeak = "<<yp<<endl;
+       Float_t hmax = xp+10*sigma;
+       Float_t hmin = xp-10*sigma;
+       cout<<hmin<< " "<<hmax<<endl;
+       //          cfd->GetXaxis()->SetRange(hmin,hmax);
+       //          TF1 *g1 = new TF1("g1", "gaus", hmin, hmax);
+       // cfd->Fit("g1","R");
+       //      Int_t hminbin=  qtc_cfd->GetXaxis()->GetFirst();
+       //      Int_t hmaxbin=  qtc_cfd->GetXaxis()->GetLast();
+       Int_t nbins= qtc_cfd->GetXaxis()->GetNbins();
+       cout<<" nbins "<<nbins<<endl;
+       //      cout<<"  qtc_cfd "<<hminbin<<" "<<hmaxbin<<" "<<nbins<<endl;
+       //  qtc_cfd->Draw();
+       TProfile *pr_y = qtc_cfd->ProfileX();
+       //      Float_t maxHr=pr_y->GetBinCenter(hmaxbin);
+       
+       pr_y->SetMaximum(hmax);
+       pr_y->SetMinimum(hmin);
+       Int_t np=nbins/20;
+       Double_t *xx = new Double_t[np];
+       Double_t *yy = new Double_t[np];
+       Int_t ng=0;
+       Double_t yg=0;
+       for (Int_t ip=1; ip<nbins; ip++)
+         {
+           if(ip%20 != 0 ) {
+             if (pr_y->GetBinContent(ip) !=0)
+               yg +=pr_y->GetBinContent(ip);
+             //        cout<<ng<<" "<<pr_y->GetBinContent(ip)<<" "<<yg<<endl;
+             ng++;}
+           else {
+             xx[ip/20] = Float_t (pr_y->GetBinCenter(ip));
+             yy[ip/20] = yg/ng;
+             yg=0;
+             ng=0;
+             //                      cout<<ip<<" "<<ip/20<<" "<< xx[ip/20]<<" "<< yy[ip/20]<<endl;
+           }
+         }
+       TGraph *gr = new TGraph(np,xx,yy);
+       gr->SetMinimum(hmin);
+       gr->SetMaximum(hmax);
+       fWalk.AddAtAndExpand(gr,i);       
+       //      fWalk.AddAtAndExpand(gr,i+12);
+
+       Int_t nbinsled= led_cfd->GetXaxis()->GetNbins();
+       cout<<" nbins led "<<nbinsled<<endl;
+       //      cout<<"  qtc_cfd "<<hminbin<<" "<<hmaxbin<<" "<<nbins<<endl;
+       //  qtc_cfd->Draw();
+       TProfile *prled_y = led_cfd->ProfileX();
+       //      Float_t maxHr=pr_y->GetBinCenter(hmaxbin);
+       
+       prled_y->SetMaximum(hmax);
+       prled_y->SetMinimum(hmin);
+       Int_t npled=nbinsled/20;
+       Double_t *xxled = new Double_t[np];
+       Double_t *yyled = new Double_t[np];
+       Int_t ngled=0;
+       Double_t ygled=0;
+       for (Int_t ip=1; ip<nbinsled; ip++)
+         {
+           if(ip%20 != 0 ) {
+             if (prled_y->GetBinContent(ip) !=0)
+               ygled +=prled_y->GetBinContent(ip);
+             //        cout<<ng<<" "<<pr_y->GetBinContent(ip)<<" "<<yg<<endl;
+             ngled++;}
+           else {
+             xxled[ip/20] = Float_t (prled_y->GetBinCenter(ip));
+             yyled[ip/20] = ygled/ngled;
+             ygled=0;
+             ngled=0;
+           }
+         }
+       TGraph *grled = new TGraph(npled,xxled,yyled);
+       grled->SetMinimum(hmin);
+       grled->SetMaximum(hmax);
+       fAmpLEDRec.AddAtAndExpand(grled,i);       
+       //      delete [] xx;
+       //      delete [] yy;
+       
       }
-      delete cfd;
-      delete qtccfd;
-      delete ledcfd;                   
+      
     }
-  }
+  
+
 
 }
 
index b2e278d..56fc352 100644 (file)
@@ -37,7 +37,7 @@
 #include <AliCDBStorage.h>  
 #include <TMath.h>
 #include <TSystem.h>
-#include <Riostream.h>
+//#include <Riostream.h>
 #include <TGeoManager.h>
 #include <TGeoPhysicalNode.h>
 #include <TGeoMatrix.h>
@@ -149,7 +149,7 @@ void AliT0Parameters::InitIfOnline()
 // for switching to this one should write
   // AliT0RawReader myrawreader(rawReader);
 //     myrawreader.SetOnlineMode(kTRUE);
-cout<<" AliT0Parameters::InitIfOnline() "<<endl;
+
   if (fIsInit) return;
    //standart configuration (used for simulation)
    //Int_t trm=0; Int_t tdc=0; Int_t chain=0; Int_t channel=0;
index cca35fa..25328a8 100644 (file)
@@ -113,7 +113,7 @@ Bool_t  AliT0RawReader::Next()
    Int_t fNTRM = fParam->GetNumberOfTRMs();
    for ( Int_t k=0; k<110; k++) {
     koefhits[k]=0;
-    for ( Int_t jj=0; jj<5; jj++) {
+    for ( Int_t jj=0; jj<50; jj++) {
       fAllData[k][jj]=0;
      }
    }
@@ -188,7 +188,7 @@ Bool_t  AliT0RawReader::Next()
                }
                if(correct){
                  hit=koefhits[koef];
-                 if(hit>5) {  
+                 if(hit>50) {  
                    AliWarning(Form("Too many hits for %i channel  ! ",koef)); 
                    break; 
                  }
index 16a7367..4d250c9 100644 (file)
@@ -62,7 +62,7 @@ class AliT0RawReader : public TTask {
   AliT0Parameters *fParam;       // instanse of  Parameters class
   Bool_t           fIsOnline;     // for case online DA usage
   
-  Int_t            fAllData[110][5]; // container for raw data
+  Int_t            fAllData[110][50]; // container for raw data
   
  ClassDef(AliT0RawReader,2) //class for reading T0 Raw data
 };
index a97e77d..59e0082 100644 (file)
@@ -216,33 +216,40 @@ void AliT0Reconstructor::Reconstruct(AliRawReader* rawReader, TTree*recTree) con
   // T0RecPoint writing 
   
   //Q->T-> coefficients !!!! should be measured!!!
-  Int_t allData[110][5];
+  Int_t allData[110][50];
   
   TArrayI * timeCFD = new TArrayI(24); 
   TArrayI * timeLED = new TArrayI(24); 
   TArrayI * chargeQT0 = new TArrayI(24); 
   TArrayI * chargeQT1 = new TArrayI(24); 
 
-   for (Int_t i=0; i<110; i++) {
-     allData[i][0]=0;
-   }
+  for (Int_t i0=0; i0<105; i0++)
+    {
+      for (Int_t j0=0; j0<50; j0++) allData[i0][j0]=0;         
+    }
+  
 
-   AliT0RawReader myrawreader(rawReader);
-   if (!myrawreader.Next())
-     AliDebug(1,Form(" no raw data found!! %i", myrawreader.Next()));
-   for (Int_t i=0; i<110; i++) {
-     allData[i][0]=myrawreader.GetData(i,0);
-   }
-  AliT0Calibrator *calib = new AliT0Calibrator(); 
+  AliDebug(10," before read data ");
+  AliT0RawReader myrawreader(rawReader);
+  if (!myrawreader.Next())
+    AliDebug(1,Form(" no raw data found!! %i", myrawreader.Next()));
 
+    for (Int_t i=0; i<105; i++) {
+      for (Int_t iHit=0; iHit<50; iHit++) 
+       {
+         allData[i][iHit] = myrawreader.GetData(i,iHit);
+       }
+    }
+  AliT0Calibrator *calib = new AliT0Calibrator(); 
+  
   //  Int_t mV2Mip = param->GetmV2Mip();     
   //mV2Mip = param->GetmV2Mip();     
   Float_t channelWidth = fParam->GetChannelWidth() ;  
 
   Int_t meanT0 = fParam->GetMeanT0();
  
-  for (Int_t in=0; in<24; in++)
-     {
+  for (Int_t in=0; in<24; in++)  
+    {
        timeLED->AddAt(allData[in+1][0],in);
        timeCFD->AddAt(allData[in+25][0],in);
        chargeQT1->AddAt(allData[in+57][0],in);
@@ -250,11 +257,11 @@ void AliT0Reconstructor::Reconstruct(AliRawReader* rawReader, TTree*recTree) con
        AliDebug(10, Form(" readed Raw %i %i %i %i %i", in, timeLED->At(in),timeCFD->At(in),chargeQT0->At(in),chargeQT1->At(in)));
      }
 
-  Float_t besttimeA=999999;
-  Float_t besttimeC=999999;
+  Float_t besttimeA=9999999;
+  Float_t besttimeC=9999999;
   Int_t pmtBestA=99999;
   Int_t pmtBestC=99999;
-  Float_t timeDiff=999999, meanTime=0;
+  Float_t timeDiff=9999999, meanTime=0;
 
   
   AliT0RecPoint* frecpoints= new AliT0RecPoint ();
@@ -265,7 +272,8 @@ void AliT0Reconstructor::Reconstruct(AliRawReader* rawReader, TTree*recTree) con
   Float_t time[24], adc[24];
   for (Int_t ipmt=0; ipmt<24; ipmt++) {
     if(timeCFD->At(ipmt)>0 ){
-      Double_t qt0 = Double_t(chargeQT0->At(ipmt));
+      /* 
+     Double_t qt0 = Double_t(chargeQT0->At(ipmt));
       Double_t qt1 = Double_t(chargeQT1->At(ipmt));
       if((qt1-qt0)>0)  adc[ipmt] = TMath::Exp( Double_t (channelWidth*(qt1-qt0)/1000));
       //      time[ipmt] = channelWidth * (calib-> WalkCorrection( ipmt,qt1 , timeCFD->At(ipmt) ) ) ;
@@ -276,6 +284,17 @@ void AliT0Reconstructor::Reconstruct(AliRawReader* rawReader, TTree*recTree) con
       frecpoints->SetAmp(ipmt,adc[ipmt]);
       frecpoints->SetAmpLED(ipmt,qt);
     AliDebug(1,Form(" QTC %f mv,  QTC  %f MIPS time in chann %f time %f ",adc[ipmt], adc[ipmt]/50.,time[ipmt], time[ipmt]*channelWidth));
+      */
+      Float_t qt0 = Float_t(chargeQT0->At(ipmt));
+      Float_t qt1 = Float_t(chargeQT1->At(ipmt));
+      if((qt0-qt1)>0)  adc[ipmt] = qt0-qt1;
+      time[ipmt] = calib-> WalkCorrection( ipmt, adc[ipmt], timeCFD->At(ipmt) ) ;
+      Double_t sl = timeLED->At(ipmt) - time[ipmt];
+      Double_t qt=((TGraph*)fAmpLEDrec.At(ipmt))->Eval(sl);
+      frecpoints->SetTime(ipmt,time[ipmt]);
+      frecpoints->SetAmp(ipmt,adc[ipmt]);
+      frecpoints->SetAmpLED(ipmt,qt);
+      AliDebug(10,Form(" QTC %f , time in chann %f ",adc[ipmt] ,time[ipmt]));
      
     }
     else {
@@ -299,15 +318,16 @@ void AliT0Reconstructor::Reconstruct(AliRawReader* rawReader, TTree*recTree) con
         pmtBestA=ipmt;}
     }
   }
-  if(besttimeA !=999999)  frecpoints->SetTimeBestA(Int_t(besttimeA));
-  if( besttimeC != 999999 ) frecpoints->SetTimeBestC(Int_t(besttimeC));
+  if(besttimeA !=9999999)  frecpoints->SetTimeBestA(Int_t(besttimeA));
+  if( besttimeC != 9999999 ) frecpoints->SetTimeBestC(Int_t(besttimeC));
   AliDebug(1,Form(" besttimeA %f ps,  besttimeC %f ps",besttimeA, besttimeC));
   Float_t c = 0.0299792; // cm/ps
-  Float_t vertex = 0;
-  if(besttimeA !=999999 && besttimeC != 999999 ){
-    timeDiff = (besttimeC - besttimeA)*channelWidth;
-    meanTime = (meanT0 - (besttimeA + besttimeC)/2) * channelWidth;   
-    vertex = c*(timeDiff)/2. + (fdZonA - fdZonC)/2; //-(lenr-lenl))/2;
+  Float_t vertex = 99999;
+  if(besttimeA <9999999 && besttimeC < 9999999 ){
+    timeDiff = besttimeC - besttimeA;
+    //    meanTime = (meanT0 - (besttimeA + besttimeC)/2) * channelWidth;
+    meanTime =  (besttimeA + besttimeC)/2;  
+    vertex = c*(timeDiff)/2. + (fdZonA - fdZonC)/2; 
     AliDebug(1,Form("  timeDiff %f ps,  meanTime %f ps, vertex %f cm",timeDiff, meanTime,vertex ));
     frecpoints->SetVertex(vertex);
     frecpoints->SetMeanTime(Int_t(meanTime));