new Digits structure
[u/mrichter/AliRoot.git] / START / readDigits.C
index f96c17f..ee6f59c 100644 (file)
@@ -10,7 +10,7 @@ void readDigits(Int_t evNumber=1)
   // Connect the Root Galice file containing Geometry, Kine and Hits
   TFile *file =  (TFile*)gROOT->GetListOfFiles()->FindObject("galice.root");
   //TFile *file =  (TFile*)gROOT->GetListOfFiles()->FindObject("galice.root");
-  if (!file) file = new TFile("production.root","UPDATE");
+  if (!file) file = new TFile("galice.root","UPDATE");
   
   // Get AliRun object from file or create it if not on file
   if (!gAlice) {
@@ -21,40 +21,88 @@ void readDigits(Int_t evNumber=1)
   char nameTD[8],nameTR[8];
 
   TH1F *hTimediff = new TH1F("hTimediff","Time difference",100,0,200);
-  TH1F *hTimePs = new TH1F("hTimePs","Time in Ps",100,2000,3000);
-  
+  TH1F *hTimePs = new TH1F("hTimePs","Time in Ps",100,-200,200);
+  TH1F *hMeanTime = new TH1F("hMeanTime","Time in Ps",100,2000,2500);
+  TH1F *hallADC = new TH1F("hallright","ADC summary right",100,0,200);
+  TH1F *hADCright = new TH1F("hADCright","ADC right",100,0,200);
+  TH1F *hADCleft = new TH1F("hADCleft","ADC left",100,0,200);
+  TH1F *hTimeright = new TH1F("hTimeright","Time right",100,2000.,3200.);
+  TH1F *hTimeleft = new TH1F("hTimeleft","Time left",100,2000.,3200.);
+  TH1F *hBestTimeright = new TH1F("hBestTimeright","First time right",
+                                 100,2000.,3200);
+  TH1F *hBestTimeleft = new TH1F("hBestTimeleft","First time left",
+                                100,11000.,13000.);
+   
   digits = new AliSTARTdigit();
-
+  timeRight = new TArrayI(12);
+  timeLeft = new TArrayI(12);
+  ADCRight = new TArrayI(12);
+  ADCLeft = new TArrayI(12);
 
  // Event ------------------------- LOOP  
-  for (j=0; j<evNumber; j++){
-    gAlice->GetEvent(j);
+  for (Int_t j=0; j<evNumber; j++){
+    //  gAlice->GetEvent(j);
     sprintf(nameTD,"START_D_%d",j);
     printf("%s\n",nameTD);
-  TObject *td = (TObject*)gDirectory->Get(nameTD);
-  digits->Read(nameTD);
-  digits->Dump();
-  printf("time %d\n",digits->GetTime());
+    TObject *td = (TObject*)gDirectory->Get(nameTD);
+    digits->Read(nameTD);
+  // digits->Dump();
+  // digits->Print();
+    printf("time %d\n",digits->GetTimeDiff());
     
-    if(digits->GetTime()!=999999){
-      Int_t timediff = digits->GetMeanTime();
+    if(digits->GetTimeDiff()!=999999){
+      Int_t timediff = digits->GetTimeDiff();
       //     Double_t timePs=(timediff-128)*10.; // time in Ps channel_width =10ps
-      Double_t timePs=(timediff)*10.; // time in Ps channel_width =10ps
+      Int_t timePs=(512-timediff)*2.5.; // time in Ps channel_width =10ps
       cout<<"timediff "<<timediff<<" timePs "<<timePs<<endl;
       hTimediff->Fill(timediff);
       hTimePs->Fill(timePs);
+      Int_t mean=digits->GetMeanTime();
+      cout<<" mean "<<mean<<endl;
+      mean=mean*2.5;
+      hMeanTime->Fill(mean);
+      Int_t br=digits->GetBestTimeRight(); 
+      Int_t bl=digits->GetBestTimeLeft();
+      cout<<"BestTimeRight "<<br*2.5<<" BestTimeLeft "<<bl*2.5<<endl;
+      hBestTimeright->Fill(br*2.5); 
+      hBestTimeleft ->Fill(bl*2.5); 
+      digits->GetTimeRight(*timeRight );
+      digits->GetTimeLeft(*timeLeft );
+      digits->GetADCRight(*ADCRight );
+      digits->GetADCLeft(*ADCLeft );
+       for (Int_t i=0; i<12; i++) 
+       {
+         Int_t t=timeRight.At(i);
+         Int_t ADC=ADCRight.At(i);
+         hTimeright->Fill(t*2.5);
+         hADCright->Fill(ADC);
+       }
+       for (Int_t i=0; i<12; i++) 
+       {
+         Int_t ADC=ADCRight.At(i);
+         Int_t t=timeLeft.At(i);
+         hTimeleft->Fill(t*2.5);
+         hADCleft->Fill(ADC);
+       }
     }
   }
   
-      Hfile = new TFile("figs.root","UPDATE","Histograms for STASRT digits");
-    printf("Writting histograms to root file \n");
-    Hfile->cd();
-//Create a canvas, set the view range, show histograms
-    gStyle->SetOptStat(111111);
+  Hfile = new TFile("Figdigits.root","RECREATE","Histograms for START digits");
+  printf("Writting histograms to root file \n");
+  Hfile->cd();
+  //Create a canvas, set the view range, show histograms
+  gStyle->SetOptStat(111111);
   //  TCanvas *c1 = new TCanvas("c1","Alice START Time ",400,10,600,600);
+  hADCright->Write();
+  hADCleft->Write();
+  hTimeright->Write();
+  hTimeleft->Write();
   hTimePs->SetXTitle("arriving time, ps");
   hTimePs->SetYTitle("number of events");
   hTimePs->Write();
+  hMeanTime->Write();
+  hBestTimeright->Write(); 
+  hBestTimeleft ->Write(); 
   Hfile->Close();