Fix for FMD DA
[u/mrichter/AliRoot.git] / ITS / AliITSHits2SDigits.C
CommitLineData
02a71a71 1#if !defined(__CINT__) || defined(__MAKECINT__)
2
d2e7afa1 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"
02a71a71 13#include "TStopwatch.h"
fb4129e9 14
02a71a71 15#endif
cc2535cd 16
88cb7938 17Int_t AliITSHits2SDigits(TString filename = "galice.root")
18 {
d2e7afa1 19 // Standard ITS Hits to SDigits.
02a71a71 20
21 // Dynamically link some shared libs
22 if (gClassTable->GetID("AliRun") < 0) {
d2e7afa1 23 gROOT->ProcessLine(".x $(ALICE_ROOT)/macros/loadlibs.C");
24 }else if (gAlice){
33c3c91a 25 delete AliRunLoader::Instance();
d2e7afa1 26 delete gAlice;
27 gAlice=0;
28 }
02a71a71 29
30 // Connect the Root Galice file containing Geometry, Kine and Hits
31
88cb7938 32 AliRunLoader* rl = AliRunLoader::Open(filename);
33 if (rl == 0x0)
34 {
d2e7afa1 35 cerr<<"AliITSHits2SDigits.C : Can not open session RL=NULL"
88cb7938 36 << endl;
37 return 3;
38 }
39
40 Int_t retval = rl->LoadgAlice();
41 if (retval)
42 {
d2e7afa1 43 cerr<<"AliITSHits2SDigits.C : LoadgAlice returned error"
88cb7938 44 << endl;
45 return 3;
46 }
47 gAlice=rl->GetAliRun();
d2e7afa1 48 AliITSLoader* gime = (AliITSLoader*) rl->GetLoader("ITSLoader");
88cb7938 49 if (gime == 0x0)
50 {
d2e7afa1 51 cerr<<"AliITSHits2SDigits.C : can not get ITS loader"
88cb7938 52 << endl;
53 }
02a71a71 54 AliITS *ITS = (AliITS*)gAlice->GetDetector("ITS");
55 if (!ITS) {
d2e7afa1 56 cerr<<"AliITSHits2SDigits.C : AliITS object not found on file"
fb4129e9 57 << endl;
58 return 3;
02a71a71 59 } // end if !ITS
60 if(!(ITS->GetITSgeom())){
d2e7afa1 61 cerr << " AliITSgeom not found. Can't digitize without it." << endl;
88cb7938 62 return 4;
02a71a71 63 } // end if
cc2535cd 64
fb4129e9 65 TStopwatch timer;
02a71a71 66 Int_t evNumber1 = 0;
880d6abe 67 Int_t evNumber2 = AliRunLoader::GetNumberOfEvents();
02a71a71 68 timer.Start();
88cb7938 69 retval = gime->LoadHits();
70 if (retval)
71 {
d2e7afa1 72 cerr<<"AliITSHits2SDigits.C : ITSLoader::LoadHits returned error"
88cb7938 73 << endl;
74 return 3;
75 }
76 retval = gime->LoadSDigits("recreate");
77 if (retval)
78 {
d2e7afa1 79 cerr<<"AliITSHits2SDigits.C : ITSLoader::LoadSDigits returned error"
88cb7938 80 << endl;
81 return 3;
82 }
02a71a71 83 for(Int_t event = evNumber1; event < evNumber2; event++){
88cb7938 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();
02a71a71 94 } // end for event
95 timer.Stop();
96 timer.Print();
02a71a71 97
88cb7938 98 delete rl; // sdigfile is closed by deleting gAlice if != hitfile.
d2e7afa1 99 return 0;
02a71a71 100}