Double check if SM is running added. Some redundant output removed from SM
[u/mrichter/AliRoot.git] / ITS / AliITSHits2SDigits.C
... / ...
CommitLineData
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
17Int_t AliITSHits2SDigits(TString filename = "galice.root")
18 {
19 // Standard ITS Hits to 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 AliRunLoader::Instance();
26 delete gAlice;
27 gAlice=0;
28 }
29
30 // Connect the Root Galice file containing Geometry, Kine and Hits
31
32 AliRunLoader* rl = AliRunLoader::Open(filename);
33 if (rl == 0x0)
34 {
35 cerr<<"AliITSHits2SDigits.C : Can not open session RL=NULL"
36 << endl;
37 return 3;
38 }
39
40 Int_t retval = rl->LoadgAlice();
41 if (retval)
42 {
43 cerr<<"AliITSHits2SDigits.C : LoadgAlice returned error"
44 << endl;
45 return 3;
46 }
47 gAlice=rl->GetAliRun();
48 AliITSLoader* gime = (AliITSLoader*) rl->GetLoader("ITSLoader");
49 if (gime == 0x0)
50 {
51 cerr<<"AliITSHits2SDigits.C : can not get ITS loader"
52 << endl;
53 }
54 AliITS *ITS = (AliITS*)gAlice->GetDetector("ITS");
55 if (!ITS) {
56 cerr<<"AliITSHits2SDigits.C : AliITS object not found on file"
57 << endl;
58 return 3;
59 } // end if !ITS
60 if(!(ITS->GetITSgeom())){
61 cerr << " AliITSgeom not found. Can't digitize without it." << endl;
62 return 4;
63 } // end if
64
65 TStopwatch timer;
66 Int_t evNumber1 = 0;
67 Int_t evNumber2 = AliRunLoader::GetNumberOfEvents();
68 timer.Start();
69 retval = gime->LoadHits();
70 if (retval)
71 {
72 cerr<<"AliITSHits2SDigits.C : ITSLoader::LoadHits returned error"
73 << endl;
74 return 3;
75 }
76 retval = gime->LoadSDigits("recreate");
77 if (retval)
78 {
79 cerr<<"AliITSHits2SDigits.C : ITSLoader::LoadSDigits returned error"
80 << endl;
81 return 3;
82 }
83 for(Int_t event = evNumber1; event < evNumber2; event++){
84 rl->GetEvent(event);
85 if(!gime->TreeS()){
86 cout << "Having to create the SDigits Tree." << endl;
87 gime->MakeTree("S");
88 } // end
89
90 ITS->MakeBranch("S");
91 ITS->SetTreeAddress();
92 cout<<"Making ITS SDigits for event "<<event<<endl;
93 ITS->Hits2SDigits();
94 } // end for event
95 timer.Stop();
96 timer.Print();
97
98 delete rl; // sdigfile is closed by deleting gAlice if != hitfile.
99 return 0;
100}