]> git.uio.no Git - u/mrichter/AliRoot.git/blame - ITS/oldmacros/AliITSSDigits2DigitsDubna.C
Print removed
[u/mrichter/AliRoot.git] / ITS / oldmacros / AliITSSDigits2DigitsDubna.C
CommitLineData
b3d9d240 1TFile* AccessFile(TString inFile="galice.root", TString acctype="R");
2void writeAR(TFile * fin, TFile *fou);
3void AliITSSD2D(TString inFile, TString outFile);
4
5void AliITSSDigits2DigitsDubna(TString inFile= "galiceS.root",
6 TString outFile = "galiceD.root"){
7 // This macro takes SDigits and produces Digits. No merging is done
8 // and only one galice.root file is used.
9 // Dynamically link some shared libs
10 TStopwatch timer;
11
12 if(gAlice){
13 delete gAlice;
14 gAlice = 0;
15 } // end if gAlice
16 cout << "Creating digits from summable digits for the ITS..." << endl;
17 AliITSSD2D(inFile,outFile);
18 timer.Stop();
19 timer.Print();
20}
21//______________________________________________________________________
22void AliITSSD2D(TString inFile, TString outFile){
23 AliRunDigitizer * manager = new AliRunDigitizer(1,1);
24 char ftmp[50];
25 sprintf(ftmp,"%s",inFile.Data());
26 TFile *file0 = AccessFile(ftmp);
27 AliITS *ITS = (AliITS*)gAlice->GetDetector("ITS");
28 if (!ITS) {
29 cerr<<"AliITSHits2DigitsDefault.C : AliITS object not found on file"
30 << endl;
31 return 3;
32 } // end if !ITS
33 if(!(ITS->GetITSgeom())){
34 cerr << " AliITSgeom not found. Can't digitize with out it." << endl;
35 return 4;
36 } // end if
37
38 // For old files, must change SPD noise.
39 AliITSresponseSPDdubna *resp0 = new AliITSresponseSPDdubna();
40 if(ITS->DetType(0)->GetResponseModel() !=0){
41 delete ((AliITSresponse*)ITS->DetType(0)->GetResponseModel());
42 ITS->DetType(0)->ResponseModel(0);
43 } // end if
44 ITS->DetType(0)->ResponseModel(resp0);
45 AliITSsegmentationSPD *seg0 = (AliITSsegmentationSPD*)ITS->DetType(0)->
46 GetSegmentationModel();
47 AliITSsimulationSPDdubna *sim0 = new AliITSsimulationSPDdubna(seg0,resp0);
48 if(ITS->DetType(0)->GetSimulationModel() !=0){
49 delete ((AliITSsimulation*)ITS->DetType(0)->GetSimulationModel());
50 ITS->DetType(0)->SimulationModel(0);
51 } // end if
52 ITS->DetType(0)->SimulationModel(sim0);
53 manager->SetInputStream(0,ftmp);
54 if(outFile != "")manager->SetOutputFile(outFile);
55 AliITSDigitizer *dITS = new AliITSDigitizer(manager);
56 manager->Exec("");
57 TFile *file = (TFile*)gROOT->GetListOfFiles()->FindObject(inFile);
58 TFile *file2 = 0;
59 if(outFile != ""){
60 file2 = new TFile(outFile,"UPDATE");
61 writeAR(file,file2);
62 } // end if outFile!=""
63 delete manager;
64 if(file){
65 file->Write();
66 } // end if file
67 if(file2){
68 file2->Close();
69 delete file2;
70 } // end if file2
71}
72//______________________________________________________________________
73TFile * AccessFile(TString FileName, TString acctype){
74
75 // Function used to open the input file and fetch the AliRun object
76
77 TFile *retfil = 0;
78 TFile *file = (TFile*)gROOT->GetListOfFiles()->FindObject(FileName);
79 if (file) {file->Close(); delete file; file = 0;}
80 if(acctype.Contains("U")){
81 file = new TFile(FileName,"update");
82 }
83 if(acctype.Contains("N") && !file){
84 file = new TFile(FileName,"recreate");
85 }
86 if(!file) file = new TFile(FileName); // default readonly
87 if (!file->IsOpen()) {
88 cerr<<"Can't open "<<FileName<<" !" << endl;
89 return retfil;
90 }
91
92 // Get AliRun object from file or return if not on file
93 if (gAlice) {delete gAlice; gAlice = 0;}
94 gAlice = (AliRun*)file->Get("gAlice");
95 if (!gAlice) {
96 cerr << "AliRun object not found on file"<< endl;
97 return retfil;
98 }
99 return file;
100}
101//______________________________________________________________________
102void writeAR(TFile * fin, TFile *fou) {
103 TDirectory *current = gDirectory;
104 TTree *Te;
105 TTree *TeNew;
106 AliHeader *alhe = new AliHeader();
107 Te = (TTree*)fin->Get("TE");
108 Te->SetBranchAddress("Header",&alhe);
109 Te->SetBranchStatus("*",1);
110 fou->cd();
111 TeNew = Te->CloneTree();
112 TeNew->Write(0,TObject::kOverwrite);
113 gAlice->Write(0,TObject::kOverwrite);
114 current->cd();
115 delete alhe;
116 cout<<"AliRun object written to file\n";
117}