]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ITS/AliITSHits2Digits.C
Use of appropriate sensor depending response objects in SPD simulation
[u/mrichter/AliRoot.git] / ITS / AliITSHits2Digits.C
1 #if !defined(__CINT__) || defined(__MAKECINT__)
2
3 #include "Riostream.h"
4 #include "TDatime.h"
5 #include "TClassTable.h"
6 #include "AliRun.h"
7 #include "AliRunDigitizer.h"
8 #include "AliITSDigitizer.h"
9 #include "AliITS.h"
10 #include "AliITSDetType.h"
11 #include "AliITSLoader.h"
12 #include "AliITSresponseSDD.h"
13 #include "TStopwatch.h"
14
15 #endif
16
17 //#define DEBUG
18 Int_t AliITSHits2Digits(TString inFile = "galice.root"){
19     // Standard ITS Hits to Digits, excluding creation of SDigits.
20
21     // Dynamically link some shared libs
22    if (gClassTable->GetID("AliRun") < 0) {
23       gROOT->ProcessLine(".x $(ALICE_ROOT)/macros/loadlibs.C");
24     }else if (gAlice){
25       delete gAlice->GetRunLoader();
26       delete gAlice;
27       gAlice=0;
28      } 
29
30    AliRunLoader* rl = AliRunLoader::Open(inFile.Data());
31     if (rl == 0x0)
32      {
33       cerr<<"AliITSHits2Digits.C : Can not open session RL=NULL"
34            << endl;
35        return 3;
36      }
37      
38     Int_t retval = rl->LoadgAlice();
39     if (retval)
40      {
41       cerr<<"AliITSHits2Digits.C : LoadgAlice returned error"
42            << endl;
43        return 3;
44      }
45     gAlice=rl->GetAliRun();
46     AliITSLoader* gime = (AliITSLoader*)rl->GetLoader("ITSLoader");
47     if (gime == 0x0)
48      {
49       cerr<<"AliITSHits2Digits.C : can not get ITS loader"
50            << endl;
51      }
52     AliITS *ITS = (AliITS*)gAlice->GetDetector("ITS");      
53     if (!ITS) {
54         cerr<<"AliITSHits2Digit.C : AliITS object not found on file"
55             << endl;
56         return 3;
57     }  // end if !ITS
58
59     if(!(ITS->GetITSgeom())){
60         cerr << " AliITSgeom not found. Can't digitize without it." << endl;
61         return 4;
62     } // end if
63
64     
65
66     TStopwatch timer;
67     Int_t evNumber1 = 0;
68     Int_t evNumber2 = gAlice->GetEventsPerRun();
69     timer.Start();
70     retval = gime->LoadHits();
71     if (retval)
72      {
73       cerr<<"AliITSHits2Digits.C : ITSLoader::LoadHits returned error"
74            << endl;
75        return 3;
76      }
77
78     retval = gime->LoadDigits("recreate");
79     if (retval)
80      {
81       cerr<<"AliITSHits2Digits.C : ITSLoader::LoadDigits returned error"
82            << endl;
83        return 3;
84      }
85     for(Int_t nevent = evNumber1; nevent < evNumber2; nevent++){
86         // cout<<"Producing Digits for event n."<<nevent<<endl;
87
88         rl->GetEvent(nevent);
89         if(!gime->TreeD()){ 
90             cout << "Having to create the Digits Tree." << endl;
91             gime->MakeTree("D");
92         } // end if creating digits tree
93         ITS->MakeBranch("D");
94         ITS->SetTreeAddress();   
95         ITS->Hits2Digits();
96     } // end for nevent
97     timer.Stop();
98     timer.Print();
99
100     delete rl;
101     return 0;
102 }