]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - TPC/AliTPCHits2SDigits.C
Typo corrected.
[u/mrichter/AliRoot.git] / TPC / AliTPCHits2SDigits.C
index acabef5cbb871df80412788fc87fe68a983cf851..77e4b4eb21febbc4e067d9c8966162233d1b62ef 100644 (file)
@@ -1,3 +1,18 @@
+#ifndef __CINT__
+  #include "alles.h"
+  #include "AliRun.h"
+  #include "AliRunLoader.h"
+  #include "AliLoader.h"
+  #include "AliMagF.h"
+  #include "AliTPCtracker.h"
+  #include "AliITS.h"
+  #include "AliITSgeom.h"
+  #include "AliITSRecPoint.h"
+  #include "AliITSclusterV2.h"
+  #include "AliITSsimulationFastPoints.h"
+  #include "AliITStrackerV2.h"
+
+#endif
 Int_t AliTPCHits2SDigits(Int_t nevent=1)
 {
 
@@ -5,29 +20,45 @@ Int_t AliTPCHits2SDigits(Int_t nevent=1)
 
   // Connect the Root Galice file containing Geometry, Kine and Hits
 
-  const char * inFile_old = "galice.root"; 
-  const char * inFile_new = "galice.root";
-  TFile *file = (TFile*)gROOT->GetListOfFiles()->FindObject(inFile_old);
-  if (file) {file->Close(); delete file;}
-  file =  TFile::Open(inFile_new,"UPDATE");
-  if (!file->IsOpen()) {
-    cerr<<"Can't open "<<inFile_new<<" !\n";
+  //it assures full cleaning of prevous session
+   if (gAlice)
+    {
+      delete gAlice->GetRunLoader();
+      delete gAlice;//if everything was OK here it is already NULL
+      gAlice = 0x0;
+    }
+
+  AliRunLoader *rl = AliRunLoader::Open("galice.root","Event","update");
+  if (!rl) 
+   {
+    cerr<<"Can't load RunLoader from "<<inFile_new<<" !\n";
     return 1;
-  }
+   }
 
   // Get AliRun object from file or create it if not on file
-  if (gAlice) delete gAlice;
-  gAlice = (AliRun*)file->Get("gAlice");
+  
+  rl->LoadgAlice();
+  gAlice = rl->GetAliRun();
   if (!gAlice) {
     cerr<<"AliTPCHits2Digits.C : AliRun object not found on file\n";
+    delete rl;
     return 2;
   }
 
-
-
   // gAlice->GetEvent(0);
-  AliTPC *TPC = (AliTPC*)gAlice->GetDetector("TPC");      
-
+  AliTPC *TPC = (AliTPC*)gAlice->GetDetector("TPC");
+  AliLoader * tpcl = rl->GetLoader("TPCLoader");
+  if ((TPC == 0x0) || (tpcl == 0x0))
+   {
+    cerr<<"AliTPCHits2Digits.C : Can not find TPC or TPCLoader\n";
+    delete rl;
+    return 3;
+   }
+  
+  tpcl->LoadHits("READ");
+  tpcl->LoadSDigits("RECREATE");
+  
   TStopwatch timer;
   timer.Start();
 
@@ -37,15 +68,16 @@ Int_t AliTPCHits2SDigits(Int_t nevent=1)
 
   for(Int_t eventn =0;eventn<nevent;eventn++){
     printf("Processing event %d \n",eventn);
-    gAlice->GetEvent(eventn);
+    rl->GetEvent(eventn);
+    TPC->SetTreeAddress();
     TPC->SetActiveSectors(); // all sectors set active
     printf("\nActive sectors\n");
     for (Int_t i=0;i<72;i++) if (TPC->IsSectorActive(i)) printf("%d\t",i);
+    
     TPC->Hits2SDigits2(eventn);
   } 
 
-  delete gAlice; gAlice=0;
-  file->Close(); delete file;
+  delete rl;
   timer.Stop();
   timer.Print();