]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ITS/AliITSh2sd.C
User stepping methods added (E. Futo)
[u/mrichter/AliRoot.git] / ITS / AliITSh2sd.C
1 #if !defined(__CINT__) || defined(__MAKECINT__)
2
3 #include "iostream.h"
4 #include "TDatime.h"
5 #include "TFile.h"
6 #include "TString.h"
7 #include "../STEER/AliRun.h"
8 #include "../STEER/AliRunDigitizer.h"
9 //#include "AliITSDigitizer.h"
10 #include "AliITS.h"
11 #include "AliITSDetType.h"
12 #include "AliITSresponseSDD.h"
13 #include "TStopwatch.h"
14
15 Bool_t GaliceITSok();
16 TFile* AccessFile(TString inFile="galice.root", TString acctype="R");
17 void writeAR(TFile * fin, TFile *fou);
18 Int_t ChangeITSDefaults(TFile *hitfile,AliITS *ITS,TString opt="");
19 void loadlibs();
20
21 #endif
22
23
24 //#define DEBUG
25
26 Int_t AliITSh2sd(TString hf="galice.root",TString sf="",TString opt=""){
27     // Produce ITS SDigits from Hits.
28
29     // Dynamically link some shared libs
30     if (gClassTable->GetID("AliRun") < 0) {
31         gROOT->LoadMacro("loadlibs.C");
32         loadlibs();
33     } // end if
34     gROOT->LoadMacro("$(ALICE_ROOT)/ITS/AliITSstandard.C");
35
36     TFile *hfp = 0, *sfp = 0;
37     if(!GaliceITSok()){
38         // gAlice not define. Must open a file and read it in.
39         if(hf.CompareTo(sf) == 0 || sf.CompareTo("") == 0) {
40             // Input file = output file
41             hfp = AccessFile(hf,"U");  // input file open for update.
42         }else{ // Input file different from output file.
43             hfp = AccessFile(hf,"R"); // input file open as read only
44             // open output file and create TreeR on it
45             sfp = gAlice->InitTreeFile("S",sf);
46         } // end if
47     } // end if !GALICEITSOK()
48     AliITS *ITS = (AliITS*) (gAlice->GetDetector("ITS"));
49
50     ChangeITSDefaults(hfp,ITS,opt);
51     // write the AliRun object to the output file if different from input file.
52     if(sfp) writeAR(hfp,sfp);
53
54     TStopwatch timer;
55     Int_t evNumber1 = 0;
56     Int_t evNumber2 = gAlice->GetEventsPerRun();
57     timer.Start();
58     for(Int_t event = evNumber1; event < evNumber2; event++){
59         gAlice->GetEvent(event);
60         if(!gAlice->TreeS() && sfp == 0){ 
61             cout << "Having to create the SDigits Tree." << endl;
62             gAlice->MakeTree("S");
63         } // end if !gAlice->TreeS()
64         if(sfp) gAlice->MakeTree("S",sfp);
65         //    make branch
66         ITS->MakeBranch("S");
67         ITS->SetTreeAddress();
68 #ifdef DEBUG
69         cout<<"Making ITS SDigits for event "<<event<<endl;
70 #endif
71         ITS->Hits2SDigits();
72     } // end for event
73     timer.Stop();
74     timer.Print();
75     if(sfp!=0){
76         cout << sf << " size =" << sfp->GetSize() << endl;
77     }else if(hfp!=0){
78         cout << hfp << " size =" << hfp->GetSize() << endl;
79     } // end if sfp!=0
80     return 0;
81 }