]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - TRD/AliTRDtest.C
Provides digitization
[u/mrichter/AliRoot.git] / TRD / AliTRDtest.C
index 42fb096920677133b32526190640af5b31b4c67d..562da5ce532d18e306754d19dd1f50b334cf060e 100644 (file)
@@ -16,9 +16,9 @@ Int_t AliTRDtest()
   gAlice->SetDebug(2);
   gAlice->Run(1);
 
-  if (gAlice) delete gAlice;
-  file   = (TFile *) gROOT->GetListOfFiles()->FindObject("TRD_test.root");
-  gAlice = (AliRun *) file->Get("gAlice");
+  //if (gAlice) delete gAlice;
+  //file   = (TFile *) gROOT->GetListOfFiles()->FindObject("TRD_test.root");
+  //gAlice = (AliRun *) file->Get("gAlice");
 
   // Analyze the TRD hits
   if (rc = AliTRDanalyzeHits()) return rc;
@@ -26,22 +26,22 @@ Int_t AliTRDtest()
   // Run the digitization
   if (rc = AliTRDcreateDigits()) return rc;
 
-  if (gAlice) delete gAlice;
-  file   = (TFile *) gROOT->GetListOfFiles()->FindObject("TRD_test.root");
-  gAlice = (AliRun *) file->Get("gAlice");
+//    if (gAlice) delete gAlice;
+//    file   = (TFile *) gROOT->GetListOfFiles()->FindObject("TRD_test.root");
+//    gAlice = (AliRun *) file->Get("gAlice");
 
-  // Analyze the digits
-  if (rc = AliTRDanalyzeDigits()) return rc;
+//    // Analyze the digits
+//    if (rc = AliTRDanalyzeDigits()) return rc;
 
-  // Create the cluster
-  if (rc = AliTRDcreateCluster()) return rc;
+//    // Create the cluster
+//    if (rc = AliTRDcreateCluster()) return rc;
 
-  if (gAlice) delete gAlice;
-  file   = (TFile *) gROOT->GetListOfFiles()->FindObject("TRD_test.root");
-  gAlice = (AliRun *) file->Get("gAlice");
+//    if (gAlice) delete gAlice;
+//    file   = (TFile *) gROOT->GetListOfFiles()->FindObject("TRD_test.root");
+//    gAlice = (AliRun *) file->Get("gAlice");
 
-  // Analyze the cluster
-  if (rc = AliTRDanalyzeCluster()) return rc;
+//    // Analyze the cluster
+//    if (rc = AliTRDanalyzeCluster()) return rc;
 
   //file   = (TFile *) gROOT->GetListOfFiles()->FindObject("TRD_test.root");
   //file->Close();
@@ -62,12 +62,22 @@ Int_t AliTRDanalyzeHits()
 
   Int_t rc = 0;
 
-  if (!gAlice) {
-    cout << "<AliTRDanalyzeHits> No AliRun object found" << endl;
+  AliRunLoader *rl = gAlice->GetRunLoader();
+  if (!rl) {
+    cout << "<AliTRDanalyzeHits> No RunLoader found" << endl;
     rc = 1;
     return rc;
   }
-  gAlice->GetEvent(0);
+
+  // Import the Trees for the event nEvent in the file
+  rl->GetEvent(0);
+  
+  AliLoader* loader = rl->GetLoader("TRDLoader");
+  if (!loader) {
+    cout << "<AliTRDanalyzeHits> No TRDLoader found" << endl;
+    rc = 2;
+    return rc;
+  }
 
   // Get the pointer to the TRD detector 
   AliTRD *trd = (AliTRD *) gAlice->GetDetector("TRD");
@@ -117,7 +127,7 @@ Int_t AliTRDanalyzeHits()
                                     ,50,0.0,1000.0);
 
   // Get the pointer hit tree
-  TTree *hitTree = gAlice->TreeH();  
+  TTree *hitTree = loader->TreeH();  
   if (!hitTree) {
     cout << "<AliTRDanalyzeHits> No hit tree found" << endl;
     rc = 4;
@@ -171,25 +181,26 @@ Int_t AliTRDanalyzeHits()
         hQtr->Fill(TMath::Abs(q));
       }
 
-      TParticle *part = gAlice->Particle(track);
+//        printf("Getting TParticle for track %d\n",track);
+//        TParticle *part = gAlice->Particle(track);
 
-      if ((plane == 0) && (q > 0)) {
+//        if ((plane == 0) && (q > 0)) {
 
-        // 3 GeV electrons
-        if ((part->GetPdgCode() ==   11) && 
-            (part->P()          >   2.9)) {
-          nPrimE++;
-          nTotE += ((Int_t) q);
-        }
+//          // 3 GeV electrons
+//          if ((part->GetPdgCode() ==   11) && 
+//              (part->P()          >   2.9)) {
+//            nPrimE++;
+//            nTotE += ((Int_t) q);
+//          }
 
-        // MIP pions
-        if ((part->GetPdgCode() == -211) &&
-            (part->P()          >   0.5)) {
-          nPrimP++;
-          nTotP += ((Int_t) q);
-        }
+//          // MIP pions
+//          if ((part->GetPdgCode() == -211) &&
+//              (part->P()          >   0.5)) {
+//            nPrimP++;
+//            nTotP += ((Int_t) q);
+//          }
 
-      }
+//        }
 
       hit = (AliTRDhit *) trd->NextHit();         
 
@@ -262,7 +273,9 @@ Int_t AliTRDcreateDigits()
   // Create the TRD digitzer 
   AliTRDdigitizer *digitizer = new AliTRDdigitizer("TRDdigitizer"
                                                   ,"TRD digitizer class");
+  digitizer->Open("TRD_test.root");
   digitizer->InitDetector();
+  digitizer->InitOutput(0);
 
   // Set the parameter
   digitizer->SetDebug(1);
@@ -281,10 +294,10 @@ Int_t AliTRDcreateDigits()
   }
 
   // Write the digits into the input file
-  if (!(digitizer->MakeBranch())) {
-    rc = 3;
-    return rc;
-  }
+  //if (!(digitizer->MakeBranch())) {
+  //  rc = 3;
+  //  return rc;
+  //}
 
   // Write the digits into the input file
   if (!(digitizer->WriteDigits())) {
@@ -377,7 +390,7 @@ Int_t AliTRDanalyzeDigits()
   Int_t countDigits = 0;
   Int_t iSec        = trd->GetSensSector();
   Int_t iCha        = trd->GetSensChamber();
-  Int_t timeMax     = geo->GetTimeTotal();
+  Int_t timeMax     = parameter->GetTimeTotal();
 
   TProfile *hAmpTimeEl = new TProfile("hAmpTimeEl","Amplitude of the digits (electrons)"
                                      ,timeMax,-0.5,((Double_t) timeMax)-0.5);
@@ -578,7 +591,7 @@ Int_t AliTRDanalyzeCluster()
   TH1F *hClusAll   = new TH1F("hClusAll"  ,"Amplitude of the cluster (all)"     
                                           ,501,-0.5,500.5);
   TH1F *hClusNoise = new TH1F("hClusNoise","Amplitude of the cluster (noise)"   
-                                          ,  5,-0.5,  4.5);
+                                          , 11,-0.5, 10.5);
   TH1F *hClusEl    = new TH1F("hClusEl"   ,"Amplitude of the cluster (electron)"
                                           ,501,-0.5,500.5);
   TH1F *hClusPi    = new TH1F("hClusPi"   ,"Amplitude of the cluster (pion)"    
@@ -642,9 +655,9 @@ Int_t AliTRDanalyzeCluster()
       Int_t    plane    = geo->GetPlane(detector);
       Int_t    chamber  = geo->GetChamber(detector);
       Float_t  energy   = cluster->GetQ();
-      Int_t    track0   = cluster->GetTrackIndex(0);
-      Int_t    track1   = cluster->GetTrackIndex(1);
-      Int_t    track2   = cluster->GetTrackIndex(2);
+      Int_t    track0   = cluster->GetLabel(0);
+      Int_t    track1   = cluster->GetLabel(1);
+      Int_t    track2   = cluster->GetLabel(2);
       TParticle *particle = 0;
       if (track0 > -1) {
         particle = gAlice->Particle(track0);
@@ -696,10 +709,10 @@ Int_t AliTRDanalyzeCluster()
   fun->SetLineColor(2);
   fun->Draw("SAME");
   
-  //cCluster->cd(2);
-  //gPad->SetLogy();
+  cCluster->cd(2);
+  gPad->SetLogy();
   Float_t meanNoise = hClusNoise->GetMean();
-  //hClusNoise->Draw();
+  hClusNoise->Draw();
 
   cCluster->cd(3);
   gPad->SetLogy();