Digits and reconstruction with TObject
authoralla <alla@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 15 Apr 2002 08:04:01 +0000 (08:04 +0000)
committeralla <alla@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 15 Apr 2002 08:04:01 +0000 (08:04 +0000)
START/AliSTARTDigitizer.cxx
START/AliSTARTvertex.cxx
START/Makefile
START/readDigits.C
START/readVertex.C

index d9b9a51dc2f6888ec376a4b1da05724c629adc3a..d9c4ca1893a2c1cf3711b5989177189d52e8fdc1 100644 (file)
@@ -137,7 +137,6 @@ void AliSTARTDigitizer::Exec(Option_t* option)
        }//time for right shoulder
        if(volume==2){            
          timeleft = startHit->fTime;
-         //                printf("timeleft %f\n",timeleft);
          if(timeleft<besttimeleft) {
            besttimeleft=timeleft;
          } //timeleftbest
@@ -147,10 +146,12 @@ void AliSTARTDigitizer::Exec(Option_t* option)
  
     //folding with experimental time distribution
     Float_t besttimerightGaus=gRandom->Gaus(besttimeright,0.05);
+    Float_t koef=69.7/350.;
+    besttimeleft=koef*besttimeleft;
     Float_t besttimeleftGaus=gRandom->Gaus(besttimeleft,0.05);
     timediff=besttimerightGaus-besttimeleftGaus;
     meanTime=(besttimerightGaus+besttimeleftGaus)/2.;
-    if ( TMath::Abs(timediff)<TMath::Abs(10.) && meanTime<TMath::Abs(7.1)) 
+    if ( TMath::Abs(timediff)<TMath::Abs(3.) && meanTime<TMath::Abs(5.)) 
      {
        //we assume centre of bunch is 5ns after TTS signal
        //TOF values are relative of the end of bunch
@@ -161,7 +162,6 @@ void AliSTARTDigitizer::Exec(Option_t* option)
        Float_t t2=1000.*besttimerightGaus;
        t1=t1/channelWidth+ppBunch; //time in ps to channelWidth
        t2=t2/channelWidth+ppBunch; //time in ps to channelWidth
-     
        timeav=(t1+t2)/2.;
      
        // Time to TDC signal
@@ -172,7 +172,7 @@ void AliSTARTDigitizer::Exec(Option_t* option)
        timeAv = (Int_t)(timeav);   // time (ps) channel numbres
        timeDiff = (Int_t)(timediff); // time ( ps) channel numbres
        fdigits->Set(timeAv,timeDiff);
-      fdigits->Print();
+       fdigits->Print();
      }
     else
       {timeAv=999999; timeDiff=99999;}
index 7b76137621bfcf6a918c83b819c7eb02ddfa107d..26360c36e89aa09a695b607429bd83a3a73ac7e0 100644 (file)
@@ -14,6 +14,9 @@
  **************************************************************************/
 /*
 $Log$
+Revision 1.6  2001/10/19 05:29:38  alla
+bug in meduim fixed
+
 Revision 1.5  2001/07/27 13:03:12  hristov
 Default Branch split level set to 99
 
@@ -30,7 +33,7 @@ Revision 1.1  2000/03/24 17:46:58  alla
 Vertex reconstruction
 
 */ 
-#include <TObject.h>
+#include "TObject.h"
 #include "AliSTARTvertex.h"
 #include "AliSTARTdigit.h"
 #include "AliSTARThit.h"
@@ -40,6 +43,9 @@ Vertex reconstruction
 
 //#include "TTree.h"
 #include "TDirectory.h"
+#include <stdlib.h>
+#include <iostream.h>
+#include <fstream.h>
 
 ClassImp(AliSTARTvertex)
 
@@ -65,28 +71,27 @@ void AliSTARTvertex::Reconstruct(Int_t evNumber=1)
   Float_t timePs;
   char nameTD[8],nameTR[8];
 
-  TBranch *bRec=0;
-  TBranch *bd;
   AliSTARTdigit *digits;
-  AliSTARTvertex *vertex;
-  Int_t buffersize=256;
+  AliSTARTvertex *fvertex;
  
-  // TParticle *particle;
   digits = new AliSTARTdigit();
-  vertex = new AliSTARTvertex();
+  fvertex = new AliSTARTvertex();
 
  // Event ------------------------- LOOP  
    
-  sprintf(nameTD,"TreeD%d",evNumber);
+  gAlice->GetEvent(evNumber);
+
+  sprintf(nameTD,"START_D_%d",evNumber);
+  TObject *td = (TObject*)gDirectory->Get(nameTD);
   printf("%s\n",nameTD);
-  TTree *td = (TTree*)gDirectory->Get(nameTD);
-  bd = td->GetBranch("START");
-  bd->SetAddress(&digits);
-  bd->GetEvent(0);
-  sprintf(nameTR,"TreeR%d",evNumber);
-  TTree *tr = new TTree(nameTR,"START");
-  bRec = tr->Branch("START","AliSTARTvertex",&vertex,buffersize);
+  
+  if (!td) {
+    cerr<<"something wrong with output...."<<exit;
+    return;
+  }
+  td->Read(nameTD);
+  digits->Read(nameTD);
+  digits->Dump();
   if(digits->GetTime()!=999999)
     {
       timediff=digits->GetTime();     //time in number of channels
@@ -94,13 +99,29 @@ void AliSTARTvertex::Reconstruct(Int_t evNumber=1)
       Float_t c = 299792458/1.e9;  //speed of light cm/ps
       //Float_t c = 0.3;  //speed of light mm/ps
       Float_t Zposit=timePs*c;// for 0 vertex
-      vertex->Set((Int_t) Zposit);
-      tr->Fill();
-      tr->Write();
+      cout<<" Zposit "<<Zposit<<endl;
+      fvertex->Set((Int_t) Zposit);
       }
-
+    TTree *outTree = gAlice->TreeR();
+    if (!outTree) {
+      cerr<<"something wrong with output...."<<exit;
+      return;
+    }
+    TTree *outTreeR = gAlice->TreeR();
+    if (!outTreeR) {
+      cerr<<"something wrong with output...."<<exit;
+      return;
+    }
+  sprintf(nameTR,"START_R_%d",evNumber);
+  printf("%s\n",nameTR);
+    TDirectory *wd = gDirectory;
+    outTreeR->GetDirectory()->cd();
+    fvertex->Write(nameTR);
+    wd->cd();
 }
 
 
 
 
+
+
index fcd0a8ed4bb7d9302e15be80ab1e5b60e2add00a..dddd17edc0f23fa5852bb18cc77dfef8055e758a 100644 (file)
@@ -10,7 +10,7 @@ PACKAGE = START
 
 # C++ sources
 
-SRCS          = AliSTART.cxx AliSTARTv0.cxx AliSTARTv1.cxx AliSTARThit.cxx AliSTARTdigit.cxx AliSTARTvertex.cxx
+SRCS          = AliSTART.cxx AliSTARTv0.cxx AliSTARTv1.cxx AliSTARThit.cxx AliSTARTdigit.cxx AliSTARTvertex.cxx AliSTARTDigitizer.cxx 
 
 # C++ Headers
 
index 9ab99bd4d49e0b13cdbfe4e02bc24ddabb84d262..f96c17f3bed6e70df3b905d0826457f4985ea963 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("galice.root","UPDATE");
+  if (!file) file = new TFile("production.root","UPDATE");
   
   // Get AliRun object from file or create it if not on file
   if (!gAlice) {
@@ -20,44 +20,42 @@ void readDigits(Int_t evNumber=1)
   }
   char nameTD[8],nameTR[8];
 
-  TH1F *hTimediff = new TH1F("hTimediff","Time difference",100,0,256);
-  TH1F *hTimePs = new TH1F("hTimePs","Time in Ps",100,-2000,2000);
+  TH1F *hTimediff = new TH1F("hTimediff","Time difference",100,0,200);
+  TH1F *hTimePs = new TH1F("hTimePs","Time in Ps",100,2000,3000);
   
   digits = new AliSTARTdigit();
-  TBranch *bd;
 
 
  // Event ------------------------- LOOP  
   for (j=0; j<evNumber; j++){
-    sprintf(nameTD,"TreeD%d",j);
+    gAlice->GetEvent(j);
+    sprintf(nameTD,"START_D_%d",j);
     printf("%s\n",nameTD);
-    TTree *TD = (TTree*)gDirectory->Get(nameTD);
-    bd = TD->GetBranch("START");
-    bd->SetAddress(&digits);
-    bd->GetEvent(0); 
-    //    printf(" Digits: %d \n ",digits->GetTime()); 
-    
-    printf("time %d\n",digits->GetTime());
+  TObject *td = (TObject*)gDirectory->Get(nameTD);
+  digits->Read(nameTD);
+  digits->Dump();
+  printf("time %d\n",digits->GetTime());
     
     if(digits->GetTime()!=999999){
-      Int_t timediff = digits->GetTime();
-      Double_t timePs=(timediff-128)*10.; // time in Ps channel_width =10ps
-      //      cout<<"timediff "<<timediff<<" timePs "<<timePs<<endl;
+      Int_t timediff = digits->GetMeanTime();
+      //     Double_t timePs=(timediff-128)*10.; // time in Ps channel_width =10ps
+      Double_t timePs=(timediff)*10.; // time in Ps channel_width =10ps
+      cout<<"timediff "<<timediff<<" timePs "<<timePs<<endl;
       hTimediff->Fill(timediff);
       hTimePs->Fill(timePs);
     }
   }
-
-    Hfile = new TFile("figs.root","UPDATE","Histograms for STASRT digits");
-   printf("Writting histograms to root file \n");
-   Hfile->cd();
+  
+      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);
-  TCanvas *c1 = new TCanvas("c1","Alice START Time ",400,10,600,600);
+    gStyle->SetOptStat(111111);
+  //  TCanvas *c1 = new TCanvas("c1","Alice START Time ",400,10,600,600);
   hTimePs->SetXTitle("arriving time, ps");
   hTimePs->SetYTitle("number of events");
   hTimePs->Write();
-
+  Hfile->Close();
     
  
 } // end of macro
index a7da4b345a1ffdcd39c347bf13a7d7ed284b578b..f35b68c22283bbc06dbec41b08d1e2a0b9fd8d58 100644 (file)
@@ -10,7 +10,7 @@ void readVertex(Int_t evNumber=1)
   // Connect the Root Galice file containing Geometry, Kine and Hits
 
   TFile *file =  (TFile*)gROOT->GetListOfFiles()->FindObject("galice.root");
-  if (!file) file = new TFile("galice.root","UPDATE");
+  if (!file) file = new TFile("production.root","UPDATE");
   
   // Get AliRun object from file or create it if not on file
   if (!gAlice) {
@@ -21,46 +21,45 @@ void readVertex(Int_t evNumber=1)
   char nameTD[8],nameTR[8];
 
   TH1F *hVertex = new TH1F("hVertex","Z position of vertex",100,-350,350);
+  TH1F *hRealVertex = new TH1F("hRealVertex","Z position of vertex",100,-350,350);
   
   digits = new AliSTARTdigit();
   vertex = new AliSTARTvertex();
-  TBranch *bd;
-  TBranch *bRec;
-
  // Event ------------------------- LOOP  
-  for (j=0; j<evNumber; j++){
-    sprintf(nameTD,"TreeD%d",j);
-    printf("%s\n",nameTD);
-    TTree *TD = (TTree*)gDirectory->Get(nameTD);
-    bd = TD->GetBranch("START");
-    bd->SetAddress(&digits);
-    bd->GetEvent(0); 
-    printf(" Digits: %d \n ",digits->GetTime()); 
-    
+  for (Int_t j=0; j<evNumber; j++){
     
-    sprintf(nameTR,"TreeR%d",j);
+    sprintf(nameTR,"START_R_%d",j);
     printf("%s\n",nameTR);
-    TTree *TR = (TTree*)gDirectory->Get(nameTR);
-    bRec = TR->GetBranch("START");
-    bRec->SetAddress(&vertex);
-    bRec->GetEvent(0);
-    if(digits->GetTime()!=999999){
-      hVertex->Fill(vertex->GetVertex());
-      // printf(" Z position %f\n",vertex->GetVertex());
-    }
+    TObject *tr = (TObject*)gDirectory->Get(nameTR);
+    cout<<" tr "<<tr<<endl;
+    vertex->Read(nameTR);
+    
+    hVertex->Fill(vertex->GetVertex());
+    printf(" Z position %f\n",vertex->GetVertex());
+    gAlice->GetEvent(j);
+    AliHeader *header = gAlice->GetHeader();
+    AliGenEventHeader* genHeader = header->GenEventHeader();
+    TArrayF *o = new TArrayF(3); 
+    genHeader->PrimaryVertex(*o);
+    cout<<" o "<<o<<endl;
+    Float_t zRealVertex=o->At(2);
+    cout<<" zRealVertex "<<zRealVertex<<endl;
+    hRealVertex->Fill(zRealVertex);
+       
   }
-    Hfile = new TFile("figs1.root","RECREATE","Histograms for START Vertex");
+    Hfile = new TFile("figs.root","UPDATE","Histograms for START Vertex");
    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 (vertex)",400,10,600,600);
-
   hVertex->SetXTitle("vertex position, mm");
   hVertex->SetYTitle("number of events");
   hVertex->Write();
+  hRealVertex->SetXTitle("vertex position, mm");
+  hRealVertex->SetYTitle("number of events");
+  hRealVertex->Write();
 
 } // end of macro