1 ////////////////////////////////////////////////////////////////////////
3 // name: AliHits2SDigits
5 // last update: 4.4.2002
6 // author: Jiri Chudoba
10 // creates sdigits for several detectors
13 // TString fileName ... galice input file
14 // Int_t nEvents ... how many events to proceed
15 // Int_t firstEvent ... first event number
16 // Int_t ITS, TPC, ... many flags for diff. detectors
20 // 21.07.03 - changes for NewIO
22 // 04.04.02 - first version
24 ////////////////////////////////////////////////////////////////////////
26 #if !defined(__CINT__) || defined(__MAKECINT__)
30 #include "TDirectory.h"
33 #include "TParticle.h"
34 #include "TPC/AliTPCDigitsArray.h"
35 #include "AliHeader.h"
36 #include "TGeometry.h"
37 #include "TObjArray.h"
39 #include "ITS/AliITS.h"
40 #include "TPC/AliTPC.h"
41 #include "PHOS/AliPHOSSDigitizer.h"
42 #include "TRD/AliTRDdigitizer.h"
43 #include "TStopwatch.h"
44 #include "TRD/AliTRDparameter.h"
47 AliRunLoader* Init(TString fileName);
49 AliTRDdigitizer *InitTRDdigitizer();
54 Bool_t gSameFiles = kFALSE;
58 Int_t AliHits2SDigits(TString fileName="galice.root",
59 Int_t nEvents = 1, Int_t firstEvent = 0, Int_t iITS = 0,
60 Int_t iTPC = 0, Int_t iTRD = 0,Int_t iPHOS = 0)
65 AliRunLoader* rl = Init(fileName);
71 ITS = (AliITS*) gAlice->GetModule("ITS");
74 cerr<<"AliITS object not found on file." << endl;
75 } else if (!ITS->GetITSgeom()) {
76 cerr<<"AliITSgeom not found." << endl;
84 TPC = (AliTPC*)gAlice->GetDetector("TPC");
87 cerr<<"AliTPC object not found"<<endl;
92 AliTRDdigitizer *sdTRD = NULL;
94 sdTRD = InitTRDdigitizer();
99 AliPHOSSDigitizer *sdPHOS = NULL;
101 sdPHOS = new AliPHOSSDigitizer(fileName.Data());
111 for (Int_t iEvent = firstEvent;iEvent<firstEvent+nEvents;iEvent++){
112 rl->GetEvent(iEvent);
113 // gAlice->MakeTree("S",fileSDigits);
117 if (gDEBUG) {cout<<" Create ITS sdigits: ";}
118 AliLoader* loader = rl->GetLoader("ITSLoader");
121 loader->LoadHits("read");
122 loader->LoadSDigits("recreate");
123 if(!loader->TreeS()) loader->MakeTree("S");
124 ITS->MakeBranch("S");
125 ITS->SetTreeAddress();
127 loader->UnloadHits();
128 loader->UnloadSDigits();
129 if (gDEBUG) {cout<<"done"<<endl;}
131 else if (gDEBUG) {cout<<"Did not get loader"<<endl;}
136 if (gDEBUG) {cout<<" Create TPC sdigits: ";}
137 AliLoader* loader = rl->GetLoader("TPCLoader");
140 loader->LoadHits("read");
141 loader->LoadSDigits("recreate");
143 TPC->SetTreeAddress();
144 TPC->SetActiveSectors(1);
145 TPC->Hits2SDigits2(iEvent);
146 loader->UnloadHits();
147 loader->UnloadSDigits();
148 if (gDEBUG) {cout<<"done"<<endl;}
150 else if (gDEBUG) {cout<<"Did not get loader"<<endl;}
155 if (gDEBUG) {cout<<" Create TRD sdigits: ";}
156 AliLoader* loader = rl->GetLoader("TRDLoader");
159 loader->LoadHits("read");
160 loader->LoadSDigits("recreate");
162 sdTRD->WriteDigits();
163 loader->UnloadHits();
164 loader->UnloadSDigits();
165 if (gDEBUG) {cout<<"done"<<endl;}
167 else if (gDEBUG) {cout<<"Did not get loader"<<endl;}
170 } // end of loop over events
172 // PHOS processes always all events
174 sdPHOS->ExecuteTask("deb all");
188 ////////////////////////////////////////////////////////////////////////
189 AliRunLoader* Init(TString fileName)
191 // open input file, read in gAlice, prepare output file
192 if (gAlice) delete gAlice;
194 AliRunLoader*rl = AliRunLoader::Open(fileName);
195 if (rl == 0x0) return 0x0;
197 gAlice = rl->GetAliRun();
203 ////////////////////////////////////////////////////////////////////////
204 ////////////////////////////////////////////////////////////////////////
205 AliTRDdigitizer *InitTRDdigitizer() {
206 // initialization of TRD digitizer
207 AliTRDdigitizer *sdTRD = new AliTRDdigitizer("TRDdigitizer"
208 ,"TRD digitizer class");
210 sdTRD->SetSDigits(kTRUE);
211 AliTRDparameter *TRDparam = new AliTRDparameter("TRDparameter"
212 ,"TRD parameter class");
214 sdTRD->SetParameter(TRDparam);
215 sdTRD->InitDetector();