]> git.uio.no Git - u/mrichter/AliRoot.git/blame - ITS/AliITSHits2SDigitsDubna.C
Removing obsolete macros
[u/mrichter/AliRoot.git] / ITS / AliITSHits2SDigitsDubna.C
CommitLineData
ad456e33 1TFile* AccessFile(TString inFile="galice.root", TString acctype="R");
2void writeAR(TFile * fin, TFile *fou);
3
4Int_t AliITSHits2SDigitsDubna(Int_t evNumber1=0,Int_t evNumber2=0,
5 TString inFile ="galice.root",
6 TString outFile="galiceS.root"){
7
8 // Dynamically link some shared libs
9 if (gClassTable->GetID("AliRun") < 0) {
10 gROOT->LoadMacro("loadlibs.C");
11 loadlibs();
12 } // end if
13
14 // Connect the Root Galice file containing Geometry, Kine and Hits
15
16 TFile *file;
17 if(outFile.Data() == inFile.Data()){
18 file = AccessFile(inFile,"U");
19 }
20 else {
21 file = AccessFile(inFile);
22 }
23
24 TFile *file2 = 0; // possible output file for TreeS
25
26 if(!(outFile.Data() == inFile.Data())){
27 // open output file and create TreeS on it
28 file2 = gAlice->InitTreeFile("S",outFile);
29 }
30
31 AliITS *ITS = (AliITS*)gAlice->GetDetector("ITS");
32 if (!ITS) {
33 cerr<<"AliITSHits2DigitsDefault.C : AliITS object not found on file"
34 << endl;
35 return 3;
36 } // end if !ITS
37 if(!(ITS->GetITSgeom())){
38 cerr << " AliITSgeom not found. Can't digitize with out it." << endl;
39 return 4;
40 } // end if
41
42 // For old files, must change SPD noise.
43 AliITSresponseSPDdubna *resp0 = new AliITSresponseSPDdubna();
44 if(ITS->DetType(0)->GetResponseModel() !=0){
45 delete ((AliITSresponse*)ITS->DetType(0)->GetResponseModel());
46 ITS->DetType(0)->ResponseModel(0);
47 } // end if
48 ITS->DetType(0)->ResponseModel(resp0);
49 AliITSsegmentationSPD *seg0 = (AliITSsegmentationSPD*)ITS->DetType(0)->GetSegmentationModel();
50 AliITSsimulationSPDdubna *sim0 = new AliITSsimulationSPDdubna(seg0,resp0);
51 if(ITS->DetType(0)->GetSimulationModel() !=0){
52 delete ((AliITSsimulation*)ITS->DetType(0)->GetSimulationModel());
53 ITS->DetType(0)->SimulationModel(0);
54 } // end if
55 ITS->DetType(0)->SimulationModel(sim0);
56
57 TStopwatch timer;
58 timer.Start();
59 for(Int_t nevent = evNumber1; nevent <= evNumber2; nevent++){
60 gAlice->GetEvent(nevent);
61 if(!gAlice->TreeS() && file2 == 0){
62 cout << "Having to create the SDigits Tree." << endl;
63 gAlice->MakeTree("S");
64 } // end if !gAlice->TreeS()
65 if(file2)gAlice->MakeTree("S",file2);
66 // make branch
67 ITS->MakeBranch("S");
68 ITS->SetTreeAddress();
69 cout<<"Making ITS SDigits for event "<<nevent<<endl;
70 TStopwatch timer;
71 Long_t size0 = file->GetSize();
72 ITS->Hits2SDigits();
73 }
74 timer.Stop();
75 timer.Print();
76
77 // write the AliRun object to the output file
78 if(file2)writeAR(file,file2);
79
80 delete gAlice; gAlice=0;
81 file->Close();
82}
83
84//-------------------------------------------------------------------
85TFile * AccessFile(TString FileName, TString acctype){
86
87 // Function used to open the input file and fetch the AliRun object
88
89 TFile *retfil = 0;
90 TFile *file = (TFile*)gROOT->GetListOfFiles()->FindObject(FileName);
91 if (file) {file->Close(); delete file; file = 0;}
92 if(acctype.Contains("U")){
93 file = new TFile(FileName,"update");
94 }
95 if(acctype.Contains("N") && !file){
96 file = new TFile(FileName,"recreate");
97 }
98 if(!file) file = new TFile(FileName); // default readonly
99 if (!file->IsOpen()) {
100 cerr<<"Can't open "<<FileName<<" !" << endl;
101 return retfil;
102 }
103
104 // Get AliRun object from file or return if not on file
105 if (gAlice) {delete gAlice; gAlice = 0;}
106 gAlice = (AliRun*)file->Get("gAlice");
107 if (!gAlice) {
108 cerr << "AliRun object not found on file"<< endl;
109 return retfil;
110 }
111 return file;
112}
113
114//-------------------------------------------------------------------
115void writeAR(TFile * fin, TFile *fou) {
116 TDirectory *current = gDirectory;
117 TTree *Te;
118 TTree *TeNew;
119 AliHeader *alhe = new AliHeader();
120 Te = (TTree*)fin->Get("TE");
121 Te->SetBranchAddress("Header",&alhe);
122 Te->SetBranchStatus("*",1);
123 fou->cd();
124 TeNew = Te->CloneTree();
125 TeNew->Write(0,TObject::kOverwrite);
126 gAlice->Write(0,TObject::kOverwrite);
127 current->cd();
128 delete alhe;
129 cout<<"AliRun object written to file\n";
130}
131
132
133
134
135