Script supersceeded by AliForwarddNdetaTask.C and
[u/mrichter/AliRoot.git] / TPC / AliTPCHits2Digits.C
CommitLineData
c630aafd 1#if !defined(__CINT__) || defined(__MAKECINT__)
2 #include <Riostream.h>
50d005ae 3
c630aafd 4 #include "AliRun.h"
5 #include "AliRunLoader.h"
6 #include "AliLoader.h"
7 #include "AliTPC.h"
50d005ae 8
c630aafd 9 #include "TStopwatch.h"
10#endif
11
12extern AliRun *gAlice;
13
14Int_t AliTPCHits2Digits(Int_t nev=5) {
50d005ae 15 // Connect the Root Galice file containing Geometry, Kine and Hits
c630aafd 16 if (gAlice) {
33c3c91a 17 delete AliRunLoader::Instance();
88cb7938 18 delete gAlice;//if everything was OK here it is already NULL
19 gAlice = 0x0;
c630aafd 20 }
73042f01 21
88cb7938 22 AliRunLoader *rl = AliRunLoader::Open("galice.root","Event","update");
c630aafd 23 if (!rl) {
24 cerr<<"Can't load RunLoader from "<<endl;
73042f01 25 return 1;
c630aafd 26 }
50d005ae 27
73042f01 28 // Get AliRun object from file or create it if not on file
88cb7938 29
30 rl->LoadgAlice();
31
32 gAlice = rl->GetAliRun();
73042f01 33 if (!gAlice) {
34 cerr<<"AliTPCHits2Digits.C : AliRun object not found on file\n";
35 return 2;
36 }
50d005ae 37
afc42102 38 AliTPC *TPC = (AliTPC*)gAlice->GetDetector("TPC");
88cb7938 39 AliLoader * tpcl = rl->GetLoader("TPCLoader");
c630aafd 40 if ((TPC == 0x0) || (tpcl == 0x0)) {
88cb7938 41 cerr<<"AliTPCHits2Digits.C : Can not find TPC or TPCLoader\n";
c630aafd 42 delete rl;
88cb7938 43 return 3;
c630aafd 44 }
88cb7938 45 tpcl->LoadHits("READ");
46 tpcl->LoadDigits("recreate");
47
afc42102 48 TStopwatch timer;
49 timer.Start();
50d005ae 50
c630aafd 51 // uncomment below lines to set sectors active
7a09f434 52 // Int_t sec[10]={0,1,2,3,4,5,6,7,8,9};
53 // TPC->SetActiveSectors(sec,10);
dbab3f1e 54
c630aafd 55 for (Int_t i=0; i<nev; i++){
56 printf("Processing event %d \n",i);
6687a3ca 57 if(rl->GetEvent(i)) break;
dbab3f1e 58 TPC->SetActiveSectors(); // all sectors set active
c630aafd 59 TPC->Hits2Digits(i);
afc42102 60 }
73042f01 61
88cb7938 62 delete rl;
63
afc42102 64 timer.Stop();
65 timer.Print();
66
73042f01 67 return 0;
c630aafd 68}
8c555625 69