1 ////////////////////////////////////////////////////////////////////////
3 // name: AliHits2SDigits
5 // last update: 4.4.2002
6 // author: Jiri Chudoba
10 // creates sdigits for several detectors
11 // stores sdigits in separate file (or in the source file
12 // with hits). Stores gAlice object and copies TE to the
16 // TString fileNameSDigits ... output file with sdigits
17 // TString fileNameHits ... input file with hits
18 // Int_t nEvents ... how many events to proceed
19 // Int_t firstEvent ... first event number
20 // Int_t ITS, TPC, ... many flags for diff. detectors
24 // 04.04.02 - first version
26 ////////////////////////////////////////////////////////////////////////
28 #if !defined(__CINT__) || defined(__MAKECINT__)
32 #include "TDirectory.h"
35 #include "TParticle.h"
36 #include "TPC/AliTPCDigitsArray.h"
37 #include "AliHeader.h"
38 #include "TGeometry.h"
39 #include "TObjArray.h"
41 #include "ITS/AliITS.h"
42 #include "TPC/AliTPC.h"
43 #include "PHOS/AliPHOSSDigitizer.h"
44 #include "TRD/AliTRDdigitizer.h"
45 #include "TStopwatch.h"
46 #include "TRD/AliTRDparameter.h"
49 AliRunLoader* Init(TString fileName);
51 AliTRDdigitizer *InitTRDdigitizer();
52 void AliCopy(TFile *inputFile, TFile *outputFile);
57 Bool_t gSameFiles = kFALSE;
61 Int_t AliHits2SDigits(TString fileName="rfio:galice.root",
62 Int_t nEvents = 1, Int_t firstEvent = 0, Int_t iITS = 0,
63 Int_t iTPC = 0, Int_t iTRD = 0,Int_t iPHOS = 0,
69 AliRunLoader* rl = Init(fileName);
72 // AliCopy(gFileHits,fileSDigits);
79 ITS = (AliITS*) gAlice->GetModule("ITS");
82 cerr<<"AliITS object not found on file." << endl;
83 } else if (!ITS->GetITSgeom()) {
84 cerr<<"AliITSgeom not found." << endl;
92 TPC = (AliTPC*)gAlice->GetDetector("TPC");
95 cerr<<"AliTPC object not found"<<endl;
100 AliTRDdigitizer *sdTRD;
102 sdTRD = InitTRDdigitizer();
107 AliPHOSSDigitizer *sdPHOS;
109 sdPHOS = new AliPHOSSDigitizer(fileName.Data());
119 for (Int_t iEvent = firstEvent;iEvent<firstEvent+nEvents;iEvent++){
120 rl->GetEvent(iEvent);
121 // gAlice->MakeTree("S",fileSDigits);
125 if (gDEBUG) {cout<<" Create ITS sdigits: ";}
126 AliLoader* loader = rl->GetLoader("ITSLoader");
129 loader->LoadHits("read");
130 loader->LoadSDigits("update");
131 ITS->SetTreeAddress();
133 loader->UnloadHits();
134 loader->UnloadSDigits();
135 if (gDEBUG) {cout<<"done"<<endl;}
137 else if (gDEBUG) {cout<<"Did not get loader"<<endl;}
142 if (gDEBUG) {cout<<" Create TPC sdigits: ";}
143 AliLoader* loader = rl->GetLoader("TPCLoader");
146 loader->LoadHits("read");
147 loader->LoadSDigits("update");
149 TPC->SetActiveSectors(1);
150 TPC->Hits2SDigits2(iEvent);
151 loader->UnloadHits();
152 loader->UnloadSDigits();
153 if (gDEBUG) {cout<<"done"<<endl;}
155 else if (gDEBUG) {cout<<"Did not get loader"<<endl;}
160 if (gDEBUG) {cout<<" Create TRD sdigits: ";}
161 AliLoader* loader = rl->GetLoader("TRDLoader");
164 loader->LoadHits("read");
165 loader->LoadSDigits("update");
167 sdTRD->WriteDigits();
168 loader->UnloadHits();
169 loader->UnloadSDigits();
170 if (gDEBUG) {cout<<"done"<<endl;}
172 else if (gDEBUG) {cout<<"Did not get loader"<<endl;}
175 } // end of loop over events
177 // PHOS processes always all events
179 sdPHOS->ExecuteTask("deb all");
192 ////////////////////////////////////////////////////////////////////////
193 AliRunLoader* Init(TString fileName)
195 // open input file, read in gAlice, prepare output file
196 if (gAlice) delete gAlice;
198 AliRunLoader*rl = AliRunLoader::Open(fileName);
199 if (rl == 0x0) return 0x0;
201 gAlice = rl->GetAliRun();
207 ////////////////////////////////////////////////////////////////////////
208 ////////////////////////////////////////////////////////////////////////
209 AliTRDdigitizer *InitTRDdigitizer() {
210 // initialization of TRD digitizer
211 AliTRDdigitizer *sdTRD = new AliTRDdigitizer("TRDdigitizer"
212 ,"TRD digitizer class");
214 sdTRD->SetSDigits(kTRUE);
215 AliTRDparameter *TRDparam = new AliTRDparameter("TRDparameter"
216 ,"TRD parameter class");
218 sdTRD->SetParameter(TRDparam);
219 sdTRD->InitDetector();
220 if (!sdTRD->MakeBranch()) {
221 cerr<<"Problems with TRD digitizer initialization."<<endl;
225 ////////////////////////////////////////////////////////////////////////
226 /*void AliCopy(TFile *inputFile, TFile *outputFile) {
230 if (gDEBUG) cout<<"Copy gAlice: ";
233 if (gDEBUG) cout<<"done"<<endl;
235 TTree *treeE = gAlice->TreeE();
237 cerr<<"No TreeE found "<<endl;
242 if (gDEBUG) cout<<"Copy TreeE: ";
243 AliHeader *header = new AliHeader();
244 treeE->SetBranchAddress("Header", &header);
245 treeE->SetBranchStatus("*",1);
246 TTree *treeENew = treeE->CloneTree();
248 if (gDEBUG) cout<<"done"<<endl;
251 if (gDEBUG) cout<<"Copy AliceGeom: ";
252 TGeometry *AliceGeom = static_cast<TGeometry*>(inputFile->Get("AliceGeom"));
254 cerr<<"AliceGeom was not found in the input file "<<endl;
258 if (gDEBUG) cout<<"done"<<endl;