Corrections to avoid warning messages.
[u/mrichter/AliRoot.git] / ITS / AliITSHits2SDigits.C
CommitLineData
02a71a71 1#if !defined(__CINT__) || defined(__MAKECINT__)
2
3#include "iostream.h"
4#include "TDatetime.h"
5#include "STEER/AliRun.h"
6#include "STEER/AliRunDigitizer.h"
7#include "ITS/AliITSDigitizer.h"
8#include "ITS/AliITS.h"
9#include "ITS/AliITSDetType.h"
10#include "ITS/AliITSresponseSDD.h"
11#include "TStopwatch.h"
fb4129e9 12
02a71a71 13#endif
cc2535cd 14
88cb7938 15Int_t AliITSHits2SDigits(TString filename = "galice.root")
16 {
02a71a71 17 // Standeard ITS Hits to SDigits.
18
19 // Dynamically link some shared libs
20 if (gClassTable->GetID("AliRun") < 0) {
88cb7938 21 gROOT->LoadMacro("loadlibs.C");
22 loadlibs();
23 } else if (gAlice){
24 delete gAlice->GetRunLoader();
25 delete gAlice;
26 gAlice=0;
27 }
02a71a71 28
29 // Connect the Root Galice file containing Geometry, Kine and Hits
30
88cb7938 31 AliRunLoader* rl = AliRunLoader::Open(filename);
32 if (rl == 0x0)
33 {
34 cerr<<"AliITSHits2DigitsDefault.C : Can not open session RL=NULL"
35 << endl;
36 return 3;
37 }
38
39 Int_t retval = rl->LoadgAlice();
40 if (retval)
41 {
42 cerr<<"AliITSHits2DigitsDefault.C : LoadgAlice returned error"
43 << endl;
44 return 3;
45 }
46 gAlice=rl->GetAliRun();
47 AliLoader* gime = rl->GetLoader("ITSLoader");
48 if (gime == 0x0)
49 {
50 cerr<<"AliITSHits2DigitsDefault.C : can not get ITS loader"
51 << endl;
52 }
02a71a71 53 AliITS *ITS = (AliITS*)gAlice->GetDetector("ITS");
54 if (!ITS) {
fb4129e9 55 cerr<<"AliITSHits2DigitsDefault.C : AliITS object not found on file"
56 << endl;
57 return 3;
02a71a71 58 } // end if !ITS
59 if(!(ITS->GetITSgeom())){
88cb7938 60 cerr << " AliITSgeom not found. Can't digitize with out it." << endl;
61 return 4;
02a71a71 62 } // end if
cc2535cd 63
fb4129e9 64 TStopwatch timer;
02a71a71 65 Int_t evNumber1 = 0;
66 Int_t evNumber2 = gAlice->GetEventsPerRun();
67 timer.Start();
88cb7938 68 retval = gime->LoadHits();
69 if (retval)
70 {
71 cerr<<"AliITSHits2DigitsDefault.C : ITSLoader::LoadHits returned error"
72 << endl;
73 return 3;
74 }
75 retval = gime->LoadSDigits("recreate");
76 if (retval)
77 {
78 cerr<<"AliITSHits2DigitsDefault.C : ITSLoader::LoadSDigits returned error"
79 << endl;
80 return 3;
81 }
02a71a71 82 for(Int_t event = evNumber1; event < evNumber2; event++){
88cb7938 83 rl->GetEvent(event);
84 if(!gime->TreeS()){
85 cout << "Having to create the SDigits Tree." << endl;
86 gime->MakeTree("S");
87 } // end
88
89 ITS->MakeBranch("S");
90 ITS->SetTreeAddress();
91 cout<<"Making ITS SDigits for event "<<event<<endl;
92 ITS->Hits2SDigits();
02a71a71 93 } // end for event
94 timer.Stop();
95 timer.Print();
02a71a71 96
88cb7938 97 delete rl; // sdigfile is closed by deleting gAlice if != hitfile.
02a71a71 98}