]>
Commit | Line | Data |
---|---|---|
8d8f0259 | 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 | //#define DEBUG | |
16 | ||
17 | //______________________________________________________________________ | |
18 | Bool_t GaliceITSok(){ | |
19 | // Checks gAlice to see that ITS and the ITS geometry are properly | |
20 | // defined. If not return kFALSE and deletes gAlice and set it to zero. | |
21 | ||
22 | if(!gAlice){ | |
23 | return kFALSE; | |
24 | } // end if !gAlice | |
25 | // gAlice defined check to see if ITS is properly defined. | |
26 | AliITS *ITS = (AliITS*)gAlice->GetDetector("ITS"); | |
27 | if(!ITS){ // ITS not defined, delete and reload gAlice | |
28 | delete gAlice; | |
29 | gAlice = 0; | |
30 | return kFALSE; | |
31 | } // end if !ITS | |
32 | // ITS defined | |
33 | if(!(ITS->GetITSgeom())){ | |
34 | delete gAlice; | |
35 | gAlice = 0; | |
36 | return kFALSE; | |
37 | } // end if !(ITS->GetITSgeom()) | |
38 | // ITS and ITS geometry properly defined defined. | |
39 | return kTRUE; | |
40 | } | |
41 | //______________________________________________________________________ | |
42 | TFile * AccessFile(TString FileName, TString acctype){ | |
43 | // Function used to open the input file and fetch the AliRun object | |
44 | ||
45 | TFile *retfil = 0; | |
46 | TFile *file = (TFile*)gROOT->GetListOfFiles()->FindObject(FileName); | |
47 | if(file) { | |
48 | file->Close(); | |
49 | delete file; | |
50 | file = 0; | |
51 | } // end if file | |
52 | if(acctype.Contains("U")){ | |
53 | file = new TFile(FileName,"UPDATE"); | |
54 | } // end if open for update | |
55 | if(acctype.Contains("N") && !file){ | |
56 | file = new TFile(FileName,"RECREATE"); | |
57 | } // end if open a new file | |
58 | if(!file) file = new TFile(FileName,"READ"); // default readonly | |
59 | if (!file->IsOpen()) { | |
60 | cerr << "Can't open " << FileName << " !" << endl; | |
61 | return retfil; | |
62 | } // end if error opeing file | |
63 | ||
64 | // Get AliRun object from file or return if not on file | |
65 | if (gAlice) {delete gAlice; gAlice = 0;} | |
66 | gAlice = (AliRun*)file->Get("gAlice"); | |
67 | if (!gAlice) { | |
68 | cerr << "AliRun object not found on file "<< FileName << "!" << endl; | |
69 | file->Close(); // close file and return error. | |
70 | return retfil; | |
71 | } // end if !gAlice | |
72 | return file; | |
73 | } | |
74 | //______________________________________________________________________ | |
75 | void writeAR(TFile * fin, TFile *fou) { | |
76 | TDirectory *current = gDirectory; | |
77 | fou->cd(); | |
78 | gAlice->TreeE()->SetBranchStatus("*",1); | |
79 | gAlice->TreeE()->Write(0,TObject::kOverwrite); | |
80 | gAlice->Write(0,TObject::kOverwrite); | |
81 | current->cd(); | |
82 | #ifdef DEBUG | |
83 | cout << "AliRun object from file "<<fin->GetName() | |
84 | << " written to file " << fou->GetName() <<"." << endl; | |
85 | #endif | |
86 | } | |
87 | //______________________________________________________________________ | |
88 | Int_t ChangeITSDefaults(TFile *hitfile,AliITS *ITS,TString opt){ | |
89 | ||
90 | TDatime *ct0 = new TDatime(2002,04,26,00,00,00); | |
91 | TDatime ct = *ct0; | |
92 | if(hitfile) ct = hitfile->GetCreationDate(); | |
93 | ||
94 | if(ct0->GetDate()>ct.GetDate()){ | |
95 | // For old files, must change SDD noise. | |
96 | AliITSresponseSDD *resp1 = (AliITSresponseSDD*)ITS->DetType(1)-> | |
97 | GetResponseModel(); | |
98 | resp1 = new AliITSresponseSDD(); | |
99 | ITS->SetResponseModel(1,resp1); | |
100 | cout << "Changed response class for SDD:" << endl; | |
101 | resp1->Print(); | |
102 | } // end if | |
103 | ||
104 | if(opt.Contains("Dubna")){ | |
105 | AliITSresponseSPDdubna *resp0 = new AliITSresponseSPDdubna(); | |
106 | if(ITS->DetType(0)->GetResponseModel() !=0){ | |
107 | delete ((AliITSresponse*)ITS->DetType(0)->GetResponseModel()); | |
108 | ITS->DetType(0)->ResponseModel(0); | |
109 | } // end if | |
110 | ITS->DetType(0)->ResponseModel(resp0); | |
111 | AliITSsegmentationSPD *seg0 = (AliITSsegmentationSPD*)ITS-> | |
112 | DetType(0)->GetSegmentationModel(); | |
113 | AliITSsimulationSPDdubna *sim0 = new AliITSsimulationSPDdubna(seg0, | |
114 | resp0); | |
115 | if(ITS->DetType(0)->GetSimulationModel() !=0){ | |
116 | delete ((AliITSsimulation*)ITS->DetType(0)->GetSimulationModel()); | |
117 | ITS->DetType(0)->SimulationModel(0); | |
118 | } // end if | |
119 | ITS->DetType(0)->SimulationModel(sim0); | |
120 | } // end if Dubna | |
121 | } |