]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TPC/AliTPCHits2Digits.C
Transition to NewIO
[u/mrichter/AliRoot.git] / TPC / AliTPCHits2Digits.C
1 Int_t AliTPCHits2Digits(Int_t nevent=1)
2 {
3
4   // new version by J.Belikov
5
6   // Connect the Root Galice file containing Geometry, Kine and Hits
7   if (gAlice) 
8    { 
9      delete gAlice->GetRunLoader();
10      delete gAlice;//if everything was OK here it is already NULL
11      gAlice = 0x0;
12    }
13
14   AliRunLoader *rl = AliRunLoader::Open("galice.root","Event","update");
15   if (!rl) 
16    {
17     cerr<<"Can't load RunLoader from "<<inFile_new<<" !\n";
18     return 1;
19    }
20
21   // Get AliRun object from file or create it if not on file
22
23   rl->LoadgAlice();
24  
25   gAlice = rl->GetAliRun();
26   if (!gAlice) {
27     cerr<<"AliTPCHits2Digits.C : AliRun object not found on file\n";
28     return 2;
29   }
30
31
32
33   // gAlice->GetEvent(0);
34   AliTPC *TPC = (AliTPC*)gAlice->GetDetector("TPC");      
35   AliLoader * tpcl = rl->GetLoader("TPCLoader");
36   if ((TPC == 0x0) || (tpcl == 0x0))
37    {
38     cerr<<"AliTPCHits2Digits.C : Can not find TPC or TPCLoader\n";
39 //    delete rl;
40     return 3;
41    }
42   tpcl->LoadHits("READ");
43   tpcl->LoadDigits("recreate");
44
45   TStopwatch timer;
46   timer.Start();
47
48   // uncomment below lines to set sectors active
49  // Int_t sec[10]={0,1,2,3,4,5,6,7,8,9};
50  // TPC->SetActiveSectors(sec,10);
51
52   for(Int_t eventn =0;eventn<nevent;eventn++){
53     printf("Processing event %d \n",eventn);
54     rl->GetEvent(eventn);
55     TPC->SetActiveSectors(); // all sectors set active
56     for (Int_t i=0;i<72;i++) if (TPC->IsSectorActive(i)) printf("%d\t",i);
57     TPC->Hits2Digits(eventn);
58   }
59
60   delete rl;
61
62   timer.Stop();
63   timer.Print();
64
65   return 0;
66 };
67