]>
Commit | Line | Data |
---|---|---|
9ad8b5dd | 1 | /************************************************************************** |
2 | * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * | |
3 | * * | |
4 | * Author: The ALICE Off-line Project. * | |
5 | * Contributors are mentioned in the code where appropriate. * | |
6 | * * | |
7 | * Permission to use, copy, modify and distribute this software and its * | |
8 | * documentation strictly for non-commercial purposes is hereby granted * | |
9 | * without fee, provided that the above copyright notice appears in all * | |
10 | * copies and that both the copyright notice and this permission notice * | |
11 | * appear in the supporting documentation. The authors make no claims * | |
12 | * about the suitability of this software for any purpose. It is * | |
13 | * provided "as is" without express or implied warranty. * | |
14 | **************************************************************************/ | |
15 | ||
88cb7938 | 16 | /* $Id$ */ |
7d62fb64 | 17 | /////////////////////////////////////////////////////////////////////////// |
18 | //Piotr.Skowronski@cern.ch : // | |
19 | //Corrections applied in order to compile (only) // | |
20 | // with new I/O and folder structure // | |
21 | //To be implemented correctly by responsible // | |
22 | // // | |
23 | // Class used to steer // | |
24 | // the digitization for ITS // | |
25 | // // | |
26 | /////////////////////////////////////////////////////////////////////////// | |
88cb7938 | 27 | |
28af028c | 28 | #include <stdlib.h> |
88cb7938 | 29 | #include <TClonesArray.h> |
9ad8b5dd | 30 | #include <TTree.h> |
31 | #include <TBranch.h> | |
32 | ||
64f311fe | 33 | #include "AliRun.h" |
34 | #include "AliRunLoader.h" | |
35 | #include "AliLoader.h" | |
36 | #include "AliLog.h" | |
37 | #include "AliRunDigitizer.h" | |
9ad8b5dd | 38 | #include "AliITSDigitizer.h" |
88cb7938 | 39 | #include "AliITSgeom.h" |
e3c90d69 | 40 | #include "AliITSgeomTGeo.h" |
9ad8b5dd | 41 | #include "AliITSsimulation.h" |
0b572028 | 42 | |
9ad8b5dd | 43 | ClassImp(AliITSDigitizer) |
44 | ||
45 | //______________________________________________________________________ | |
7537d03c | 46 | AliITSDigitizer::AliITSDigitizer() : AliDigitizer(), |
47 | fITS(0), | |
48 | fModActive(0), | |
49 | fInit(kFALSE), | |
50 | fRoif(-1), | |
51 | fRoiifile(0), | |
52 | fFlagFirstEv(kTRUE){ | |
9ad8b5dd | 53 | // Default constructor. Assign fITS since it is never written out from |
54 | // here. | |
55 | // Inputs: | |
56 | // Option_t * opt Not used | |
57 | // Outputs: | |
58 | // none. | |
59 | // Return: | |
60 | // A blank AliITSDigitizer class. | |
e3c90d69 | 61 | fModActive = new Bool_t[AliITSgeomTGeo::GetNModules()]; |
5f054b91 | 62 | for(Int_t i=0;i<AliITSgeomTGeo::GetNModules();i++) fModActive[i] = kTRUE; |
9ad8b5dd | 63 | |
9ad8b5dd | 64 | } |
65 | //______________________________________________________________________ | |
7537d03c | 66 | AliITSDigitizer::AliITSDigitizer(AliRunDigitizer *mngr) : AliDigitizer(mngr), |
67 | fITS(0), | |
68 | fModActive(0), | |
69 | fInit(kFALSE), | |
70 | fRoif(-1), | |
71 | fRoiifile(0), | |
72 | fFlagFirstEv(kTRUE){ | |
9ad8b5dd | 73 | // Standard constructor. Assign fITS since it is never written out from |
74 | // here. | |
75 | // Inputs: | |
76 | // Option_t * opt Not used | |
77 | // Outputs: | |
78 | // none. | |
79 | // Return: | |
80 | // An AliItSDigitizer class. | |
e3c90d69 | 81 | fModActive = new Bool_t[AliITSgeomTGeo::GetNModules()]; |
5f054b91 | 82 | for(Int_t i=0;i<AliITSgeomTGeo::GetNModules();i++) fModActive[i] = kTRUE; |
9ad8b5dd | 83 | } |
7d62fb64 | 84 | |
7d62fb64 | 85 | |
9ad8b5dd | 86 | //______________________________________________________________________ |
87 | AliITSDigitizer::~AliITSDigitizer(){ | |
88 | // Default destructor. | |
89 | // Inputs: | |
90 | // Option_t * opt Not used | |
91 | // Outputs: | |
92 | // none. | |
93 | // Return: | |
94 | // none. | |
9ad8b5dd | 95 | fITS = 0; // don't delete fITS. Done else where. |
0b572028 | 96 | if(fModActive) delete[] fModActive; |
9ad8b5dd | 97 | } |
9ad8b5dd | 98 | //______________________________________________________________________ |
99 | Bool_t AliITSDigitizer::Init(){ | |
fd04285a | 100 | // Initialization. Set up region of interest, if switched on, and |
101 | // loads ITS and ITSgeom. | |
9ad8b5dd | 102 | // Inputs: |
103 | // none. | |
104 | // Outputs: | |
105 | // none. | |
106 | // Return: | |
107 | // none. | |
fca85276 | 108 | |
fd04285a | 109 | fInit = kTRUE; // Assume for now init will work. |
fca85276 | 110 | if(!gAlice) { |
111 | fITS = 0; | |
fca85276 | 112 | fRoiifile = 0; |
fd04285a | 113 | fInit = kFALSE; |
114 | Warning("Init","gAlice not found"); | |
115 | return fInit; | |
fca85276 | 116 | } // end if |
117 | fITS = (AliITS *)(gAlice->GetDetector("ITS")); | |
118 | if(!fITS){ | |
fca85276 | 119 | fRoiifile = 0; |
fd04285a | 120 | fInit = kFALSE; |
121 | Warning("Init","ITS not found"); | |
122 | return fInit; | |
e3c90d69 | 123 | } |
124 | if(!fITS->GetITSgeom()){ | |
fca85276 | 125 | fRoiifile = 0; |
fd04285a | 126 | fInit = kFALSE; |
127 | Warning("Init","ITS geometry not found"); | |
128 | return fInit; | |
fca85276 | 129 | } // end if |
fd04285a | 130 | return fInit; |
9ad8b5dd | 131 | } |
132 | //______________________________________________________________________ | |
133 | void AliITSDigitizer::Exec(Option_t* opt){ | |
fca85276 | 134 | // Main digitization function. |
9ad8b5dd | 135 | // Inputs: |
fca85276 | 136 | // Option_t * opt list of sub detector to digitize. =0 all. |
9ad8b5dd | 137 | // Outputs: |
138 | // none. | |
139 | // Return: | |
140 | // none. | |
f1888ca5 | 141 | |
e3c90d69 | 142 | char name[21] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; |
8e8eae84 | 143 | const char *all; |
9ad8b5dd | 144 | const char *det[3] = {strstr(opt,"SPD"),strstr(opt,"SDD"), |
145 | strstr(opt,"SSD")}; | |
f1888ca5 | 146 | if( !det[0] && !det[1] && !det[2] ) all = "All"; |
9ad8b5dd | 147 | else all = 0; |
2a476797 | 148 | Int_t nfiles = GetManager()->GetNinputs(); |
149 | Int_t event = GetManager()->GetOutputEventNr(); | |
9ad8b5dd | 150 | AliITSsimulation *sim = 0; |
2a476797 | 151 | if(fFlagFirstEv){ |
152 | fITS->SetDefaults(); | |
153 | fITS->SetDefaultSimulation(); | |
154 | fFlagFirstEv=kFALSE; | |
155 | } | |
fd04285a | 156 | if(!fInit){ |
2a476797 | 157 | Error("Exec","Init not successful, aborting."); |
f1888ca5 | 158 | return; |
9ad8b5dd | 159 | } // end if |
160 | ||
e3c90d69 | 161 | snprintf(name,20,"%s",fITS->GetName()); |
9ad8b5dd | 162 | |
2a476797 | 163 | Int_t size = fITS->GetITSgeom()->GetIndexMax(); |
fd04285a | 164 | Int_t module,id,ifiles,mask; |
165 | Bool_t lmod; | |
166 | Int_t *fl = new Int_t[nfiles]; | |
167 | fl[0] = fRoiifile; | |
168 | mask = 1; | |
88cb7938 | 169 | for(id=0;id<nfiles;id++) |
170 | if(id!=fRoiifile) | |
171 | { | |
172 | // just in case fRoiifile!=0. | |
173 | fl[mask] = id; | |
174 | mask++; | |
175 | } // end for,if | |
f1888ca5 | 176 | TClonesArray * sdig = new TClonesArray( "AliITSpListItem",1000 ); |
177 | ||
88cb7938 | 178 | TString loadname(name); |
179 | loadname+="Loader"; | |
180 | ||
181 | AliRunLoader *inRL = 0x0, *outRL = 0x0; | |
182 | AliLoader *ingime = 0x0, *outgime = 0x0; | |
183 | ||
184 | outRL = AliRunLoader::GetRunLoader(fManager->GetOutputFolderName()); | |
185 | if ( outRL == 0x0) | |
186 | { | |
187 | Error("Exec","Can not get Output Run Loader"); | |
e3c90d69 | 188 | delete [] fl; |
88cb7938 | 189 | return; |
190 | } | |
191 | outRL->GetEvent(event); | |
192 | outgime = outRL->GetLoader(loadname); | |
193 | if ( outgime == 0x0) | |
194 | { | |
195 | Error("Exec","Can not get Output ITS Loader"); | |
e3c90d69 | 196 | delete [] fl; |
88cb7938 | 197 | return; |
198 | } | |
7d62fb64 | 199 | |
88cb7938 | 200 | outgime->LoadDigits("update"); |
201 | if (outgime->TreeD() == 0x0) outgime->MakeTree("D"); | |
202 | ||
fd04285a | 203 | // Digitize |
88cb7938 | 204 | fITS->MakeBranchInTreeD(outgime->TreeD()); |
64f311fe | 205 | if(fRoif!=0) { |
206 | AliDebug(1,"Region of Interest digitization selected"); | |
207 | } | |
208 | else { | |
209 | AliDebug(1,"No Region of Interest selected. Digitizing everything"); | |
210 | } | |
e3c90d69 | 211 | |
f1888ca5 | 212 | |
88cb7938 | 213 | for(ifiles=0; ifiles<nfiles; ifiles++ ) |
214 | { | |
215 | inRL = AliRunLoader::GetRunLoader(fManager->GetInputFolderName(fl[ifiles])); | |
216 | ingime = inRL->GetLoader(loadname); | |
217 | if (ingime->TreeS() == 0x0) ingime->LoadSDigits(); | |
218 | } | |
219 | ||
220 | for(module=0; module<size; module++ ) | |
221 | { | |
e3c90d69 | 222 | if(fRoif!=0) if(!fModActive[module]) continue; |
7d62fb64 | 223 | id = fITS->GetITSgeom()->GetModuleType(module); |
224 | if(!all && !det[id]) continue; | |
225 | sim = (AliITSsimulation*)fITS->GetSimulationModel(id); | |
226 | if(!sim) { | |
f1888ca5 | 227 | Error( "Exec", "The simulation class was not instanciated!" ); |
9ad8b5dd | 228 | exit(1); |
229 | } // end if !sim | |
7d62fb64 | 230 | // Fill the module with the sum of SDigits |
fd04285a | 231 | sim->InitSimulationModule(module, event); |
232 | //cout << "Module=" << module; | |
88cb7938 | 233 | for(ifiles=0; ifiles<nfiles; ifiles++ ) |
234 | { | |
235 | if(fRoif!=0) if(!fModActive[module]) continue; | |
236 | ||
237 | inRL = AliRunLoader::GetRunLoader(fManager->GetInputFolderName(fl[ifiles])); | |
238 | ingime = inRL->GetLoader(loadname); | |
239 | ||
240 | TTree *treeS = ingime->TreeS(); | |
241 | fITS->SetTreeAddress(); | |
242 | ||
e6b4e6b9 | 243 | if( !treeS ) continue; |
88cb7938 | 244 | TBranch *brchSDigits = treeS->GetBranch( name ); |
245 | if( brchSDigits ) | |
246 | { | |
f1888ca5 | 247 | brchSDigits->SetAddress( &sdig ); |
248 | } else { | |
249 | Error( "Exec", "branch ITS not found in TreeS, input file %d ", | |
250 | ifiles ); | |
e3c90d69 | 251 | delete [] fl; |
fd04285a | 252 | return; |
f1888ca5 | 253 | } // end if brchSDigits |
254 | sdig->Clear(); | |
fd04285a | 255 | mask = GetManager()->GetMask(ifiles); |
f1888ca5 | 256 | // add summable digits to module |
257 | brchSDigits->GetEvent( module ); | |
fd04285a | 258 | lmod = sim->AddSDigitsToModule(sdig,mask); |
e95475eb | 259 | if(fRegionOfInterest && (ifiles==0)) |
88cb7938 | 260 | { |
261 | fModActive[module] = lmod; | |
262 | } // end if | |
f1888ca5 | 263 | } // end for ifiles |
fd04285a | 264 | //cout << " end ifiles loop" << endl; |
fca85276 | 265 | // Digitize current module sum(SDigits)->Digits |
7d62fb64 | 266 | sim->FinishSDigitiseModule(); |
f1888ca5 | 267 | |
9ad8b5dd | 268 | // fills all branches - wasted disk space |
88cb7938 | 269 | outgime->TreeD()->Fill(); |
7d62fb64 | 270 | fITS->ResetDigits(); |
9ad8b5dd | 271 | } // end for module |
7d62fb64 | 272 | |
88cb7938 | 273 | outgime->TreeD()->AutoSave(); |
274 | outgime->WriteDigits("OVERWRITE"); | |
275 | outgime->UnloadDigits(); | |
88cb7938 | 276 | for(ifiles=0; ifiles<nfiles; ifiles++ ) |
277 | { | |
278 | inRL = AliRunLoader::GetRunLoader(fManager->GetInputFolderName(fl[ifiles])); | |
279 | ingime = inRL->GetLoader(loadname); | |
280 | ingime->UnloadSDigits(); | |
281 | } | |
fd04285a | 282 | |
283 | delete[] fl; | |
f1888ca5 | 284 | sdig->Clear(); |
285 | delete sdig; | |
0b572028 | 286 | for(Int_t i=0;i<fITS->GetITSgeom()->GetIndexMax();i++) fModActive[i] = kTRUE; |
7d62fb64 | 287 | |
288 | ||
fd04285a | 289 | return; |
9ad8b5dd | 290 | } |
fca85276 | 291 | //______________________________________________________________________ |
292 | void AliITSDigitizer::SetByRegionOfInterest(TTree *ts){ | |
293 | // Scans through the ITS branch of the SDigits tree, ts, for modules | |
294 | // which have SDigits in them. For these modules, a flag is set to | |
295 | // digitize only these modules. The value of fRoif determines how many | |
296 | // neighboring modules will also be turned on. fRoif=0 will turn on only | |
297 | // those modules with SDigits in them. fRoif=1 will turn on, in addition, | |
298 | // those modules that are +-1 module from the one with the SDigits. And | |
299 | // So on. This last feature is not supported yet. | |
300 | // Inputs: | |
301 | // TTree *ts The tree in which the existing SDigits will define the | |
302 | // region of interest. | |
303 | // Outputs: | |
304 | // none. | |
305 | // Return: | |
306 | // none. | |
fd04285a | 307 | Int_t m,nm,i; |
308 | ||
309 | if(fRoif==0) return; | |
310 | if(ts==0) return; | |
fca85276 | 311 | TBranch *brchSDigits = ts->GetBranch(fITS->GetName()); |
312 | TClonesArray * sdig = new TClonesArray( "AliITSpListItem",1000 ); | |
fd04285a | 313 | //cout << "Region of Interest ts="<<ts<<" brchSDigits="<<brchSDigits<<" sdig="<<sdig<<endl; |
fca85276 | 314 | |
315 | if( brchSDigits ) { | |
88cb7938 | 316 | brchSDigits->SetAddress( &sdig ); |
fca85276 | 317 | } else { |
88cb7938 | 318 | Error( "SetByRegionOfInterest","branch ITS not found in TreeS"); |
319 | return; | |
fca85276 | 320 | } // end if brchSDigits |
321 | ||
322 | nm = fITS->GetITSgeom()->GetIndexMax(); | |
323 | for(m=0;m<nm;m++){ | |
88cb7938 | 324 | fModActive[m] = kFALSE; // Not active by default |
325 | sdig->Clear(); | |
326 | brchSDigits->GetEvent(m); | |
327 | if(sdig->GetLast()>=0) for(i=0;i<sdig->GetLast();i++){ | |
328 | // activate the necessary modules | |
329 | if(((AliITSpList*)sdig->At(m))->GetpListItem(i)->GetSignal()>0.0){ // Must have non zero signal. | |
330 | fModActive[m] = kTRUE; | |
331 | break; | |
332 | } // end if | |
333 | } // end if. end for i. | |
334 | //cout << fModActive[m]; | |
335 | //cout << endl; | |
fca85276 | 336 | } // end for m |
64f311fe | 337 | AliDebug(1,"Digitization by Region of Interest selected"); |
fca85276 | 338 | sdig->Clear(); |
339 | delete sdig; | |
fd04285a | 340 | return; |
fca85276 | 341 | } |