]>
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" |
9ad8b5dd | 40 | #include "AliITSsimulation.h" |
0b572028 | 41 | |
9ad8b5dd | 42 | ClassImp(AliITSDigitizer) |
43 | ||
44 | //______________________________________________________________________ | |
7537d03c | 45 | AliITSDigitizer::AliITSDigitizer() : AliDigitizer(), |
46 | fITS(0), | |
47 | fModActive(0), | |
48 | fInit(kFALSE), | |
49 | fRoif(-1), | |
50 | fRoiifile(0), | |
51 | fFlagFirstEv(kTRUE){ | |
9ad8b5dd | 52 | // Default constructor. Assign fITS since it is never written out from |
53 | // here. | |
54 | // Inputs: | |
55 | // Option_t * opt Not used | |
56 | // Outputs: | |
57 | // none. | |
58 | // Return: | |
59 | // A blank AliITSDigitizer class. | |
60 | ||
9ad8b5dd | 61 | } |
62 | //______________________________________________________________________ | |
7537d03c | 63 | AliITSDigitizer::AliITSDigitizer(AliRunDigitizer *mngr) : AliDigitizer(mngr), |
64 | fITS(0), | |
65 | fModActive(0), | |
66 | fInit(kFALSE), | |
67 | fRoif(-1), | |
68 | fRoiifile(0), | |
69 | fFlagFirstEv(kTRUE){ | |
9ad8b5dd | 70 | // Standard constructor. Assign fITS since it is never written out from |
71 | // here. | |
72 | // Inputs: | |
73 | // Option_t * opt Not used | |
74 | // Outputs: | |
75 | // none. | |
76 | // Return: | |
77 | // An AliItSDigitizer class. | |
78 | ||
9ad8b5dd | 79 | } |
7d62fb64 | 80 | |
7d62fb64 | 81 | |
9ad8b5dd | 82 | //______________________________________________________________________ |
83 | AliITSDigitizer::~AliITSDigitizer(){ | |
84 | // Default destructor. | |
85 | // Inputs: | |
86 | // Option_t * opt Not used | |
87 | // Outputs: | |
88 | // none. | |
89 | // Return: | |
90 | // none. | |
9ad8b5dd | 91 | fITS = 0; // don't delete fITS. Done else where. |
0b572028 | 92 | if(fModActive) delete[] fModActive; |
9ad8b5dd | 93 | } |
9ad8b5dd | 94 | //______________________________________________________________________ |
95 | Bool_t AliITSDigitizer::Init(){ | |
fd04285a | 96 | // Initialization. Set up region of interest, if switched on, and |
97 | // loads ITS and ITSgeom. | |
9ad8b5dd | 98 | // Inputs: |
99 | // none. | |
100 | // Outputs: | |
101 | // none. | |
102 | // Return: | |
103 | // none. | |
fca85276 | 104 | |
fd04285a | 105 | fInit = kTRUE; // Assume for now init will work. |
fca85276 | 106 | if(!gAlice) { |
107 | fITS = 0; | |
fca85276 | 108 | fRoiifile = 0; |
fd04285a | 109 | fInit = kFALSE; |
110 | Warning("Init","gAlice not found"); | |
111 | return fInit; | |
fca85276 | 112 | } // end if |
113 | fITS = (AliITS *)(gAlice->GetDetector("ITS")); | |
114 | if(!fITS){ | |
fca85276 | 115 | fRoiifile = 0; |
fd04285a | 116 | fInit = kFALSE; |
117 | Warning("Init","ITS not found"); | |
118 | return fInit; | |
fca85276 | 119 | } else if(fITS->GetITSgeom()){ |
fd04285a | 120 | //cout << "fRoif,fRoiifile="<<fRoif<<" "<<fRoiifile<<endl; |
0b572028 | 121 | fModActive = new Bool_t[fITS->GetITSgeom()->GetIndexMax()]; |
fca85276 | 122 | } else{ |
fca85276 | 123 | fRoiifile = 0; |
fd04285a | 124 | fInit = kFALSE; |
125 | Warning("Init","ITS geometry not found"); | |
126 | return fInit; | |
fca85276 | 127 | } // end if |
0b572028 | 128 | // fModActive needs to be set to a default all kTRUE value |
129 | for(Int_t i=0;i<fITS->GetITSgeom()->GetIndexMax();i++) fModActive[i] = kTRUE; | |
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 | |
9ad8b5dd | 142 | char name[20] = {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 | ||
fd04285a | 161 | sprintf(name,"%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"); | |
188 | return; | |
189 | } | |
190 | outRL->GetEvent(event); | |
191 | outgime = outRL->GetLoader(loadname); | |
192 | if ( outgime == 0x0) | |
193 | { | |
194 | Error("Exec","Can not get Output ITS Loader"); | |
195 | return; | |
196 | } | |
7d62fb64 | 197 | |
88cb7938 | 198 | outgime->LoadDigits("update"); |
199 | if (outgime->TreeD() == 0x0) outgime->MakeTree("D"); | |
200 | ||
fd04285a | 201 | // Digitize |
88cb7938 | 202 | fITS->MakeBranchInTreeD(outgime->TreeD()); |
64f311fe | 203 | if(fRoif!=0) { |
204 | AliDebug(1,"Region of Interest digitization selected"); | |
205 | } | |
206 | else { | |
207 | AliDebug(1,"No Region of Interest selected. Digitizing everything"); | |
208 | } | |
0b572028 | 209 | if(fModActive==0) fRoif = 0; // fModActive array must be define for RIO cuts. |
f1888ca5 | 210 | |
88cb7938 | 211 | for(ifiles=0; ifiles<nfiles; ifiles++ ) |
212 | { | |
213 | inRL = AliRunLoader::GetRunLoader(fManager->GetInputFolderName(fl[ifiles])); | |
214 | ingime = inRL->GetLoader(loadname); | |
215 | if (ingime->TreeS() == 0x0) ingime->LoadSDigits(); | |
216 | } | |
217 | ||
218 | for(module=0; module<size; module++ ) | |
219 | { | |
7d62fb64 | 220 | if(fModActive && fRoif!=0) if(!fModActive[module]) continue; |
221 | id = fITS->GetITSgeom()->GetModuleType(module); | |
222 | if(!all && !det[id]) continue; | |
223 | sim = (AliITSsimulation*)fITS->GetSimulationModel(id); | |
224 | if(!sim) { | |
f1888ca5 | 225 | Error( "Exec", "The simulation class was not instanciated!" ); |
9ad8b5dd | 226 | exit(1); |
227 | } // end if !sim | |
7d62fb64 | 228 | // Fill the module with the sum of SDigits |
fd04285a | 229 | sim->InitSimulationModule(module, event); |
230 | //cout << "Module=" << module; | |
88cb7938 | 231 | for(ifiles=0; ifiles<nfiles; ifiles++ ) |
232 | { | |
233 | if(fRoif!=0) if(!fModActive[module]) continue; | |
234 | ||
235 | inRL = AliRunLoader::GetRunLoader(fManager->GetInputFolderName(fl[ifiles])); | |
236 | ingime = inRL->GetLoader(loadname); | |
237 | ||
238 | TTree *treeS = ingime->TreeS(); | |
239 | fITS->SetTreeAddress(); | |
240 | ||
e6b4e6b9 | 241 | if( !treeS ) continue; |
88cb7938 | 242 | TBranch *brchSDigits = treeS->GetBranch( name ); |
243 | if( brchSDigits ) | |
244 | { | |
f1888ca5 | 245 | brchSDigits->SetAddress( &sdig ); |
246 | } else { | |
247 | Error( "Exec", "branch ITS not found in TreeS, input file %d ", | |
248 | ifiles ); | |
fd04285a | 249 | return; |
f1888ca5 | 250 | } // end if brchSDigits |
251 | sdig->Clear(); | |
fd04285a | 252 | mask = GetManager()->GetMask(ifiles); |
f1888ca5 | 253 | // add summable digits to module |
254 | brchSDigits->GetEvent( module ); | |
fd04285a | 255 | lmod = sim->AddSDigitsToModule(sdig,mask); |
e95475eb | 256 | if(fRegionOfInterest && (ifiles==0)) |
88cb7938 | 257 | { |
258 | fModActive[module] = lmod; | |
259 | } // end if | |
f1888ca5 | 260 | } // end for ifiles |
fd04285a | 261 | //cout << " end ifiles loop" << endl; |
fca85276 | 262 | // Digitize current module sum(SDigits)->Digits |
7d62fb64 | 263 | sim->FinishSDigitiseModule(); |
f1888ca5 | 264 | |
9ad8b5dd | 265 | // fills all branches - wasted disk space |
88cb7938 | 266 | outgime->TreeD()->Fill(); |
7d62fb64 | 267 | fITS->ResetDigits(); |
9ad8b5dd | 268 | } // end for module |
7d62fb64 | 269 | |
88cb7938 | 270 | outgime->TreeD()->AutoSave(); |
271 | outgime->WriteDigits("OVERWRITE"); | |
272 | outgime->UnloadDigits(); | |
88cb7938 | 273 | for(ifiles=0; ifiles<nfiles; ifiles++ ) |
274 | { | |
275 | inRL = AliRunLoader::GetRunLoader(fManager->GetInputFolderName(fl[ifiles])); | |
276 | ingime = inRL->GetLoader(loadname); | |
277 | ingime->UnloadSDigits(); | |
278 | } | |
fd04285a | 279 | |
280 | delete[] fl; | |
f1888ca5 | 281 | sdig->Clear(); |
282 | delete sdig; | |
0b572028 | 283 | for(Int_t i=0;i<fITS->GetITSgeom()->GetIndexMax();i++) fModActive[i] = kTRUE; |
7d62fb64 | 284 | |
285 | ||
fd04285a | 286 | return; |
9ad8b5dd | 287 | } |
fca85276 | 288 | //______________________________________________________________________ |
289 | void AliITSDigitizer::SetByRegionOfInterest(TTree *ts){ | |
290 | // Scans through the ITS branch of the SDigits tree, ts, for modules | |
291 | // which have SDigits in them. For these modules, a flag is set to | |
292 | // digitize only these modules. The value of fRoif determines how many | |
293 | // neighboring modules will also be turned on. fRoif=0 will turn on only | |
294 | // those modules with SDigits in them. fRoif=1 will turn on, in addition, | |
295 | // those modules that are +-1 module from the one with the SDigits. And | |
296 | // So on. This last feature is not supported yet. | |
297 | // Inputs: | |
298 | // TTree *ts The tree in which the existing SDigits will define the | |
299 | // region of interest. | |
300 | // Outputs: | |
301 | // none. | |
302 | // Return: | |
303 | // none. | |
fd04285a | 304 | Int_t m,nm,i; |
305 | ||
306 | if(fRoif==0) return; | |
307 | if(ts==0) return; | |
fca85276 | 308 | TBranch *brchSDigits = ts->GetBranch(fITS->GetName()); |
309 | TClonesArray * sdig = new TClonesArray( "AliITSpListItem",1000 ); | |
fd04285a | 310 | //cout << "Region of Interest ts="<<ts<<" brchSDigits="<<brchSDigits<<" sdig="<<sdig<<endl; |
fca85276 | 311 | |
312 | if( brchSDigits ) { | |
88cb7938 | 313 | brchSDigits->SetAddress( &sdig ); |
fca85276 | 314 | } else { |
88cb7938 | 315 | Error( "SetByRegionOfInterest","branch ITS not found in TreeS"); |
316 | return; | |
fca85276 | 317 | } // end if brchSDigits |
318 | ||
319 | nm = fITS->GetITSgeom()->GetIndexMax(); | |
320 | for(m=0;m<nm;m++){ | |
88cb7938 | 321 | //cout << " fModActive["<<m<<"]="; |
322 | fModActive[m] = kFALSE; // Not active by default | |
323 | sdig->Clear(); | |
324 | brchSDigits->GetEvent(m); | |
325 | if(sdig->GetLast()>=0) for(i=0;i<sdig->GetLast();i++){ | |
326 | // activate the necessary modules | |
327 | if(((AliITSpList*)sdig->At(m))->GetpListItem(i)->GetSignal()>0.0){ // Must have non zero signal. | |
328 | fModActive[m] = kTRUE; | |
329 | break; | |
330 | } // end if | |
331 | } // end if. end for i. | |
332 | //cout << fModActive[m]; | |
333 | //cout << endl; | |
fca85276 | 334 | } // end for m |
64f311fe | 335 | AliDebug(1,"Digitization by Region of Interest selected"); |
fca85276 | 336 | sdig->Clear(); |
337 | delete sdig; | |
fd04285a | 338 | return; |
fca85276 | 339 | } |