]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ITS/AliITSHits2SDigits.C
Transition to NewIO
[u/mrichter/AliRoot.git] / ITS / AliITSHits2SDigits.C
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"
12
13 #endif
14
15 Int_t AliITSHits2SDigits(TString  filename = "galice.root")
16  {
17     // Standeard ITS Hits to SDigits.
18
19     // Dynamically link some shared libs
20     if (gClassTable->GetID("AliRun") < 0) {
21      gROOT->LoadMacro("loadlibs.C");
22      loadlibs();
23     } else if (gAlice){
24        delete gAlice->GetRunLoader();
25        delete gAlice;
26        gAlice=0;
27      }
28
29     // Connect the Root Galice file containing Geometry, Kine and Hits
30
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      }
53     AliITS *ITS = (AliITS*)gAlice->GetDetector("ITS");      
54     if (!ITS) {
55         cerr<<"AliITSHits2DigitsDefault.C : AliITS object not found on file"
56             << endl;
57         return 3;
58     }  // end if !ITS
59     if(!(ITS->GetITSgeom())){
60        cerr << " AliITSgeom not found. Can't digitize with out it." << endl;
61        return 4;
62     } // end if
63
64     TStopwatch timer;
65     Int_t evNumber1 = 0;
66     Int_t evNumber2 = gAlice->GetEventsPerRun();
67     timer.Start();
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      }
82     for(Int_t event = evNumber1; event < evNumber2; event++){
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();
93     } // end for event
94     timer.Stop();
95     timer.Print();
96
97     delete rl; // sdigfile is closed by deleting gAlice if != hitfile.
98 }