]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TPC/AliTPCHits2SDigitsJCH.C
Improvement in tracking by J. Belikov
[u/mrichter/AliRoot.git] / TPC / AliTPCHits2SDigitsJCH.C
1 #if !defined(__CINT__) || defined(__MAKECINT__)
2 #include "iostream.h"
3 #include "TFile.h"
4 #include "TTree.h"
5 #include "AliRun.h"
6 #include "AliTPC.h"
7 #endif
8
9
10 Int_t AliTPCHits2SDigitsJCH(TString fileNameSDigits="sdigits.root", TString fileNameHits="rfio:galice.root", Int_t nEvents = 1, Int_t firstEvent = 0)
11 {
12
13   TString fileMode = "read";
14   if (fileNameSDigits == fileNameHits || fileNameSDigits == "") fileMode = "update";
15   TFile *fileHits =  TFile::Open(fileNameHits.Data(),fileMode.Data());
16   if (!fileHits->IsOpen()) {
17     cerr<<"Can't open "<<fileNameHits.Data()<<" !\n";
18     return 1;
19   }
20
21   // Get AliRun object from file or create it if not on file
22   if (gAlice) delete gAlice; gAlice = 0;
23   gAlice = (AliRun*)fileHits->Get("gAlice");
24   if (!gAlice) {
25     cerr<<"AliTPCHits2Digits.C : AliRun object not found on file\n";
26     return 2;
27   }
28
29   AliTPC *TPC = (AliTPC*)gAlice->GetDetector("TPC");      
30
31   TStopwatch timer;
32   timer.Start();
33
34   if (fileNameSDigits != fileNameHits && fileNameSDigits != "")  gAlice->InitTreeFile("S",fileNameSDigits.Data());
35
36   // uncomment lines below to set active sectors 
37   //Int_t sec[10]={4,5,6,7,8,4+36,5+36,6+36,7+36,8+36};
38   //TPC->SetActiveSectors(sec,10);
39
40   for(Int_t iEvent = firstEvent;iEvent<firstEvent+nEvents;iEvent++){
41     printf("Processing event %d \n",iEvent);
42     gAlice->GetEvent(iEvent);
43 //    TPC->SetActiveSectors(1); // all sectors set active
44     printf("\nActive sectors\n");
45     for (Int_t i=0;i<72;i++) {
46       if (i%10 == 0) printf("\n");
47       if (TPC->IsSectorActive(i)) printf("%2d ",i);
48     }
49     printf("\n");
50     TPC->Hits2SDigits2(iEvent);
51   } 
52
53   timer.Stop();
54   timer.Print();
55   delete gAlice; gAlice=0;
56   fileHits->Close(); delete fileHits;
57
58   return 0;
59 };
60