]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - TPC/AliTPCHits2Digits.C
.so cleanup: more less-obvious cleanup
[u/mrichter/AliRoot.git] / TPC / AliTPCHits2Digits.C
index 529900a3ea8616ebf12978ccce9be972c71d2861..7957a98baad294056557f3ed6011a12e7d7ed9d5 100644 (file)
@@ -1,22 +1,29 @@
-Int_t AliTPCHits2Digits(Int_t nevent=1)
-{
+#if !defined(__CINT__) || defined(__MAKECINT__)
+  #include <Riostream.h>
 
-  // new version by J.Belikov
+  #include "AliRun.h"
+  #include "AliRunLoader.h"
+  #include "AliLoader.h"
+  #include "AliTPC.h"
 
+  #include "TStopwatch.h"
+#endif
+
+extern AliRun *gAlice;
+
+Int_t AliTPCHits2Digits(Int_t nev=5) {
   // Connect the Root Galice file containing Geometry, Kine and Hits
-  if (gAlice) 
-   { 
-     delete gAlice->GetRunLoader();
+  if (gAlice) { 
+     delete AliRunLoader::Instance();
      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";
+  if (!rl) {
+    cerr<<"Can't load RunLoader from "<<endl;
     return 1;
-   }
+  }
 
   // Get AliRun object from file or create it if not on file
 
@@ -28,33 +35,28 @@ Int_t AliTPCHits2Digits(Int_t nevent=1)
     return 2;
   }
 
-
-
-  // gAlice->GetEvent(0);
   AliTPC *TPC = (AliTPC*)gAlice->GetDetector("TPC");      
   AliLoader * tpcl = rl->GetLoader("TPCLoader");
-  if ((TPC == 0x0) || (tpcl == 0x0))
-   {
+  if ((TPC == 0x0) || (tpcl == 0x0)) {
     cerr<<"AliTPCHits2Digits.C : Can not find TPC or TPCLoader\n";
-//    delete rl;
+    delete rl;
     return 3;
-   }
+  }
   tpcl->LoadHits("READ");
   tpcl->LoadDigits("recreate");
 
   TStopwatch timer;
   timer.Start();
 
 // uncomment below lines to set sectors active
+ // uncomment below lines to set sectors active
  // Int_t sec[10]={0,1,2,3,4,5,6,7,8,9};
  // TPC->SetActiveSectors(sec,10);
 
-  for(Int_t eventn =0;eventn<nevent;eventn++){
-    printf("Processing event %d \n",eventn);
-    rl->GetEvent(eventn);
+  for (Int_t i=0; i<nev; i++){
+    printf("Processing event %d \n",i);
+    if(rl->GetEvent(i)) break;
     TPC->SetActiveSectors(); // all sectors set active
-    for (Int_t i=0;i<72;i++) if (TPC->IsSectorActive(i)) printf("%d\t",i);
-    TPC->Hits2Digits(eventn);
+    TPC->Hits2Digits(i);
   }
 
   delete rl;
@@ -63,5 +65,5 @@ Int_t AliTPCHits2Digits(Int_t nevent=1)
   timer.Print();
 
   return 0;
-};
+}