]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - T0/AliT0CalibWalk.cxx
effc++ warnings
[u/mrichter/AliRoot.git] / T0 / AliT0CalibWalk.cxx
index 448792e1d223c7fea4bec2103894df7a18191488..6df8cdb582b4db99e261dc9268c3cee419958833 100644 (file)
 ///////////////////////////////////////////////////////////////////////////////
 
 #include "AliT0CalibWalk.h"
-#include "AliT0LookUpValue.h"
 #include "AliLog.h"
-#include "AliRun.h"
 
 #include <TObjArray.h>
 #include <TGraph.h>
 #include <TFile.h>
-#include <TAxis.h>
 #include <TH2F.h> 
 #include <TMath.h>
 #include <TSystem.h>
 #include <Riostream.h>
 #include <TSpectrum.h>
-#include <TVirtualFitter.h>
 #include <TProfile.h>
 
-#include <string>
 
 ClassImp(AliT0CalibWalk)
 
@@ -94,6 +89,7 @@ AliT0CalibWalk::~AliT0CalibWalk()
 //________________________________________________________________
 void AliT0CalibWalk::SetWalk(Int_t ipmt)
 {
+  //read QTC walk graph from external file
 
   Int_t mv, ps; 
   Int_t x[70000], y[70000], index[70000];
@@ -150,6 +146,7 @@ void AliT0CalibWalk::SetWalk(Int_t ipmt)
 
 void AliT0CalibWalk::SetAmpLEDRec(Int_t ipmt)
 {
+  // read LED walk from external file
   Float_t mv, ps; 
   Float_t x[100], y[100];
   string buffer;
@@ -179,74 +176,116 @@ void AliT0CalibWalk::SetAmpLEDRec(Int_t ipmt)
 
 void AliT0CalibWalk::MakeWalkCorrGraph(const char *laserFile)
 {
+  //make walk corerction for preprocessor
+
   TFile *gFile = TFile::Open(laserFile);
-  gSystem->Load("libSpectrum");
-  TGraph *gr[24];
   Int_t npeaks = 20;
-  Int_t sigma=3;
-  Bool_t down=false;
+  Double_t sigma=3.;
+  Bool_t down = false;
 
   Int_t index[20];
-  Char_t buf1[10], buf2[10],title[10];
-
+  Char_t buf1[10], buf2[10],buf3[20];
+  
+  
   for (Int_t i=0; i<24; i++)
-  {
-    sprintf(buf1,"T0_C_%i_CFD",i+1);
-    sprintf(buf2,"CFD_QTC%i",i+1);
-    // cout<<buf1<<" "<<buf2<<endl;
-    TH2F *qtc_cfd = (TH2F*) gFile->Get(buf2);
-    TH1F *cfd = (TH1F*) gFile->Get(buf1);
-    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]];
-      Float_t hmax = xp+10*sigma;
-      Float_t hmin = xp-10*sigma;
-      Int_t nbins= qtc_cfd->GetXaxis()->GetNbins();
-      TProfile *pr_y = qtc_cfd->ProfileX();
-      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);
-          }
-          ng++;
-        }
-        else
-        {
-          xx[ip/20] = Float_t (pr_y->GetBinCenter(ip));
-          yy[ip/20] = yg/ng;
-          yg=0;
-          ng=0;
-        }
+      if(i>11) {  sprintf(buf1,"T0_A_%i_CFD",i+1-12); }
+
+      if(i<12) { sprintf(buf1,"T0_C_%i_CFD",i+1); }
+
+      sprintf(buf2,"CFD_QTC%i",i+1);
+      sprintf(buf3,"CFD_LED%i",i+1);
+      cout<<buf1<<" "<<buf2<<" "<<buf3<<endl;
+      TH2F *qtcVScfd = (TH2F*) gFile->Get(buf2);
+      TH2F *ledVScfd = (TH2F*) gFile->Get(buf3);
+      TH1F *cfd = (TH1F*) gFile->Get(buf1);
+      TSpectrum *s = new TSpectrum(2*npeaks,1);
+      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]];
+       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;
+
+       //QTC
+       Int_t nbins= qtcVScfd->GetXaxis()->GetNbins();
+       cout<<" nbins "<<nbins<<endl;
+       TProfile *prY = qtcVScfd->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;
+           }
+         }
+       TGraph *gr = new TGraph(np,xx,yy);
+       gr->SetMinimum(hmin);
+       gr->SetMaximum(hmax);
+       fWalk.AddAtAndExpand(gr,i);       
+
+       //LED
+       Int_t nbinsled= ledVScfd->GetXaxis()->GetNbins();
+       cout<<" nbins led "<<nbinsled<<endl;
+       TProfile *prledY = ledVScfd->ProfileX();
+       
+       prledY->SetMaximum(hmax);
+       prledY->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 (prledY->GetBinContent(ip) !=0)
+               ygled +=prledY->GetBinContent(ip);
+             ngled++;}
+           else {
+             xxled[ip/20] = Float_t (prledY->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 [] xxled;
+       delete [] yyled;
+       delete prY;
+       delete prledY;
+       
       }
-      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);
-      fWalk.AddAtAndExpand(gr[i],i);     
-       delete [] xx;
-      delete [] yy;
-      delete gr[i];
+      delete cfd;
+      delete qtcVScfd;
+      delete ledVScfd;
     }
-  }
-
-  gFile->Close();
-  delete gFile;
+  
 }