]>
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 | ||
16 | /* | |
17 | $Log$ | |
28af028c | 18 | Revision 1.8 2003/03/03 17:00:30 masera |
19 | Corrections to comply with coding conventions | |
20 | ||
0b572028 | 21 | Revision 1.7 2002/10/25 18:54:22 barbera |
22 | Various improvements and updates from B.S.Nilsen and T. Virgili | |
23 | ||
f8d9a5b8 | 24 | Revision 1.6 2002/10/22 14:45:34 alibrary |
25 | Introducing Riostream.h | |
26 | ||
4ae5bbc4 | 27 | Revision 1.5 2002/10/14 14:57:00 hristov |
28 | Merging the VirtualMC branch to the main development branch (HEAD) | |
29 | ||
b9d0a01d | 30 | Revision 1.3.4.1 2002/06/10 17:51:14 hristov |
31 | Merged with v3-08-02 | |
32 | ||
33 | Revision 1.4 2002/04/24 22:08:12 nilsen | |
34 | New ITS Digitizer/merger with two macros. One to make SDigits (old way) and | |
35 | one to run the merger (modified for Jiri). | |
36 | ||
fd04285a | 37 | Revision 1.3 2002/03/25 10:48:55 nilsen |
38 | New ITS SDigit merging with region of interest cut. Update for changes in | |
39 | AliDigitizer. Additional optimization should be done. | |
40 | ||
fca85276 | 41 | Revision 1.2 2002/03/15 17:26:40 nilsen |
42 | New SDigit version of ITS Digitizer. | |
43 | ||
f1888ca5 | 44 | Revision 1.1 2001/11/27 16:27:28 nilsen |
45 | Adding AliITSDigitizer class to do merging and digitization . Based on the | |
46 | TTask method. AliITSDigitizer class added to the Makefile and ITSLinkDef.h | |
47 | file. The following files required minor changes. AliITS, added functions | |
48 | SetHitsAddressBranch, MakeBranchInTreeD and modified MakeBranchD. | |
fca85276 | 49 | AliITSsimulationSDD.cxx needed a Tree independent way of returning back to |
f1888ca5 | 50 | the original Root Directory in function Compress1D. Now it uses gDirectory. |
51 | ||
52 | Revision 1.2 2002/03/01 E. Lopez | |
fca85276 | 53 | Digitization changed to start from SDigits instead of Hits. |
f1888ca5 | 54 | The SDigits are reading as TClonesArray of AliITSpListItem |
9ad8b5dd | 55 | */ |
0b572028 | 56 | // |
57 | // Class used to steer | |
58 | // the digitization for ITS | |
59 | // | |
60 | // | |
28af028c | 61 | #include <stdlib.h> |
4ae5bbc4 | 62 | #include <Riostream.h> |
0b572028 | 63 | #include <TClonesArray.h> |
9ad8b5dd | 64 | #include <TTree.h> |
65 | #include <TBranch.h> | |
66 | ||
67 | #include <AliRun.h> | |
68 | #include <AliRunDigitizer.h> | |
69 | ||
70 | #include "AliITSDigitizer.h" | |
0b572028 | 71 | #include "AliITSgeom.h" |
fd04285a | 72 | #include "AliITSpList.h" |
9ad8b5dd | 73 | #include "AliITSsimulation.h" |
74 | #include "AliITSDetType.h" | |
0b572028 | 75 | |
9ad8b5dd | 76 | |
77 | ClassImp(AliITSDigitizer) | |
78 | ||
79 | //______________________________________________________________________ | |
80 | AliITSDigitizer::AliITSDigitizer() : AliDigitizer(){ | |
81 | // Default constructor. Assign fITS since it is never written out from | |
82 | // here. | |
83 | // Inputs: | |
84 | // Option_t * opt Not used | |
85 | // Outputs: | |
86 | // none. | |
87 | // Return: | |
88 | // A blank AliITSDigitizer class. | |
89 | ||
fd04285a | 90 | fITS = 0; |
0b572028 | 91 | fModActive = 0; |
fd04285a | 92 | fRoif = -1; |
fca85276 | 93 | fRoiifile = 0; |
fd04285a | 94 | fInit = kFALSE; |
9ad8b5dd | 95 | } |
96 | //______________________________________________________________________ | |
97 | AliITSDigitizer::AliITSDigitizer(AliRunDigitizer *mngr) : AliDigitizer(mngr){ | |
98 | // Standard constructor. Assign fITS since it is never written out from | |
99 | // here. | |
100 | // Inputs: | |
101 | // Option_t * opt Not used | |
102 | // Outputs: | |
103 | // none. | |
104 | // Return: | |
105 | // An AliItSDigitizer class. | |
106 | ||
fd04285a | 107 | fITS = 0; |
0b572028 | 108 | fModActive = 0; |
fd04285a | 109 | fRoif = -1; |
110 | fRoiifile = 0; | |
111 | fInit = kFALSE; | |
9ad8b5dd | 112 | } |
113 | //______________________________________________________________________ | |
114 | AliITSDigitizer::~AliITSDigitizer(){ | |
115 | // Default destructor. | |
116 | // Inputs: | |
117 | // Option_t * opt Not used | |
118 | // Outputs: | |
119 | // none. | |
120 | // Return: | |
121 | // none. | |
122 | ||
123 | fITS = 0; // don't delete fITS. Done else where. | |
0b572028 | 124 | if(fModActive) delete[] fModActive; |
9ad8b5dd | 125 | } |
9ad8b5dd | 126 | //______________________________________________________________________ |
127 | Bool_t AliITSDigitizer::Init(){ | |
fd04285a | 128 | // Initialization. Set up region of interest, if switched on, and |
129 | // loads ITS and ITSgeom. | |
9ad8b5dd | 130 | // Inputs: |
131 | // none. | |
132 | // Outputs: | |
133 | // none. | |
134 | // Return: | |
135 | // none. | |
fca85276 | 136 | |
fd04285a | 137 | fInit = kTRUE; // Assume for now init will work. |
fca85276 | 138 | if(!gAlice) { |
139 | fITS = 0; | |
fca85276 | 140 | fRoiifile = 0; |
fd04285a | 141 | fInit = kFALSE; |
142 | Warning("Init","gAlice not found"); | |
143 | return fInit; | |
fca85276 | 144 | } // end if |
145 | fITS = (AliITS *)(gAlice->GetDetector("ITS")); | |
146 | if(!fITS){ | |
fca85276 | 147 | fRoiifile = 0; |
fd04285a | 148 | fInit = kFALSE; |
149 | Warning("Init","ITS not found"); | |
150 | return fInit; | |
fca85276 | 151 | } else if(fITS->GetITSgeom()){ |
fd04285a | 152 | //cout << "fRoif,fRoiifile="<<fRoif<<" "<<fRoiifile<<endl; |
0b572028 | 153 | fModActive = new Bool_t[fITS->GetITSgeom()->GetIndexMax()]; |
fca85276 | 154 | } else{ |
fca85276 | 155 | fRoiifile = 0; |
fd04285a | 156 | fInit = kFALSE; |
157 | Warning("Init","ITS geometry not found"); | |
158 | return fInit; | |
fca85276 | 159 | } // end if |
0b572028 | 160 | // fModActive needs to be set to a default all kTRUE value |
161 | for(Int_t i=0;i<fITS->GetITSgeom()->GetIndexMax();i++) fModActive[i] = kTRUE; | |
fd04285a | 162 | /* This will not work from Init. ts is aways returned as zero. |
163 | TTree *ts; | |
fca85276 | 164 | if(fRoif>=0 && fRoiifile>=0 && fRoiifile<GetManager()->GetNinputs()){ |
165 | ts = GetManager()->GetInputTreeS(fRoiifile); | |
fd04285a | 166 | if(!ts){ |
167 | if(!gAlice) ts = gAlice->TreeS(); | |
168 | if(!ts){ | |
169 | cout <<"The TTree TreeS needed to set by region not found." | |
170 | " No region of interest cut will be applied."<< endl; | |
171 | return fInit; | |
172 | } // end if | |
173 | } // end if | |
174 | cout << "calling SetByReionOfInterest ts="<< ts <<endl; | |
fca85276 | 175 | SetByRegionOfInterest(ts); |
176 | } // end if | |
177 | */ | |
fd04285a | 178 | return fInit; |
9ad8b5dd | 179 | } |
180 | //______________________________________________________________________ | |
181 | void AliITSDigitizer::Exec(Option_t* opt){ | |
fca85276 | 182 | // Main digitization function. |
9ad8b5dd | 183 | // Inputs: |
fca85276 | 184 | // Option_t * opt list of sub detector to digitize. =0 all. |
9ad8b5dd | 185 | // Outputs: |
186 | // none. | |
187 | // Return: | |
188 | // none. | |
f1888ca5 | 189 | |
9ad8b5dd | 190 | char name[20] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; |
191 | char *all; | |
192 | const char *det[3] = {strstr(opt,"SPD"),strstr(opt,"SDD"), | |
193 | strstr(opt,"SSD")}; | |
f1888ca5 | 194 | if( !det[0] && !det[1] && !det[2] ) all = "All"; |
9ad8b5dd | 195 | else all = 0; |
196 | AliITSsimulation *sim = 0; | |
197 | AliITSDetType *iDetType = 0; | |
f1888ca5 | 198 | static Bool_t setDef = kTRUE; |
9ad8b5dd | 199 | |
fd04285a | 200 | if(!fInit){ |
201 | Error("Exec","Init not succesfull, aborting."); | |
f1888ca5 | 202 | return; |
9ad8b5dd | 203 | } // end if |
204 | ||
f1888ca5 | 205 | if( setDef ) fITS->SetDefaultSimulation(); |
206 | setDef = kFALSE; | |
fd04285a | 207 | sprintf(name,"%s",fITS->GetName()); |
9ad8b5dd | 208 | |
f1888ca5 | 209 | Int_t nfiles = GetManager()->GetNinputs(); |
210 | Int_t event = GetManager()->GetOutputEventNr(); | |
211 | Int_t size = fITS->GetITSgeom()->GetIndexMax(); | |
fd04285a | 212 | Int_t module,id,ifiles,mask; |
213 | Bool_t lmod; | |
214 | Int_t *fl = new Int_t[nfiles]; | |
215 | fl[0] = fRoiifile; | |
216 | mask = 1; | |
217 | for(id=0;id<nfiles;id++) if(id!=fRoiifile){ | |
218 | // just in case fRoiifile!=0. | |
219 | fl[mask] = id; | |
220 | mask++; | |
221 | } // end for,if | |
f1888ca5 | 222 | TClonesArray * sdig = new TClonesArray( "AliITSpListItem",1000 ); |
223 | ||
fd04285a | 224 | // Digitize |
225 | fITS->MakeBranchInTreeD(GetManager()->GetTreeD()); | |
f8d9a5b8 | 226 | if(fRoif!=0) Info("AliITSDigitizer","Region of Interest digitization selected"); |
227 | else Info("AliITSDigitizer","No Region of Interest selected. Digitizing everything"); | |
0b572028 | 228 | //cout <<"fModActive="<<fModActive<<" fRoif="<<fRoif; |
229 | if(fModActive==0) fRoif = 0; // fModActive array must be define for RIO cuts. | |
f8d9a5b8 | 230 | //cout <<" fRoif="<<fRoif<<endl; |
f1888ca5 | 231 | |
fd04285a | 232 | for(module=0; module<size; module++ ){ |
0b572028 | 233 | if(fRoif!=0) if(!fModActive[module]) continue; |
fd04285a | 234 | id = fITS->GetITSgeom()->GetModuleType(module); |
235 | if(!all && !det[id]) continue; | |
f1888ca5 | 236 | iDetType = fITS->DetType( id ); |
9ad8b5dd | 237 | sim = (AliITSsimulation*)iDetType->GetSimulationModel(); |
fca85276 | 238 | if(!sim) { |
f1888ca5 | 239 | Error( "Exec", "The simulation class was not instanciated!" ); |
9ad8b5dd | 240 | exit(1); |
241 | } // end if !sim | |
fca85276 | 242 | |
f1888ca5 | 243 | // Fill the module with the sum of SDigits |
fd04285a | 244 | sim->InitSimulationModule(module, event); |
245 | //cout << "Module=" << module; | |
246 | for(ifiles=0; ifiles<nfiles; ifiles++ ){ | |
0b572028 | 247 | if(fRoif!=0) if(!fModActive[module]) continue; |
fd04285a | 248 | //cout <<" fl[ifiles=" << ifiles << "]=" << fl[ifiles]; |
249 | TTree *treeS = GetManager()->GetInputTreeS(fl[ifiles]); | |
f1888ca5 | 250 | if( !(treeS && fITS->GetSDigits()) ) continue; |
251 | TBranch *brchSDigits = treeS->GetBranch( name ); | |
252 | if( brchSDigits ) { | |
253 | brchSDigits->SetAddress( &sdig ); | |
254 | } else { | |
255 | Error( "Exec", "branch ITS not found in TreeS, input file %d ", | |
256 | ifiles ); | |
fd04285a | 257 | return; |
f1888ca5 | 258 | } // end if brchSDigits |
259 | sdig->Clear(); | |
fd04285a | 260 | mask = GetManager()->GetMask(ifiles); |
f1888ca5 | 261 | // add summable digits to module |
262 | brchSDigits->GetEvent( module ); | |
fd04285a | 263 | lmod = sim->AddSDigitsToModule(sdig,mask); |
264 | if(ifiles==0){ | |
0b572028 | 265 | fModActive[module] = lmod; |
fd04285a | 266 | } // end if |
0b572028 | 267 | //cout << " fModActive["<<module<<"]="; |
268 | //if(fModActive[module]) cout << "kTRUE"; | |
fd04285a | 269 | //else cout << "kFALSE"; |
f1888ca5 | 270 | } // end for ifiles |
fd04285a | 271 | //cout << " end ifiles loop" << endl; |
fca85276 | 272 | // Digitize current module sum(SDigits)->Digits |
f1888ca5 | 273 | sim->FinishSDigitiseModule(); |
274 | ||
9ad8b5dd | 275 | // fills all branches - wasted disk space |
276 | GetManager()->GetTreeD()->Fill(); | |
277 | fITS->ResetDigits(); | |
278 | } // end for module | |
fd04285a | 279 | //cout << "end modules loop"<<endl; |
280 | ||
281 | GetManager()->GetTreeD()->AutoSave(); | |
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; |
fd04285a | 287 | return; |
9ad8b5dd | 288 | } |
fca85276 | 289 | //______________________________________________________________________ |
290 | void AliITSDigitizer::SetByRegionOfInterest(TTree *ts){ | |
291 | // Scans through the ITS branch of the SDigits tree, ts, for modules | |
292 | // which have SDigits in them. For these modules, a flag is set to | |
293 | // digitize only these modules. The value of fRoif determines how many | |
294 | // neighboring modules will also be turned on. fRoif=0 will turn on only | |
295 | // those modules with SDigits in them. fRoif=1 will turn on, in addition, | |
296 | // those modules that are +-1 module from the one with the SDigits. And | |
297 | // So on. This last feature is not supported yet. | |
298 | // Inputs: | |
299 | // TTree *ts The tree in which the existing SDigits will define the | |
300 | // region of interest. | |
301 | // Outputs: | |
302 | // none. | |
303 | // Return: | |
304 | // none. | |
fd04285a | 305 | Int_t m,nm,i; |
306 | ||
307 | if(fRoif==0) return; | |
308 | if(ts==0) return; | |
fca85276 | 309 | TBranch *brchSDigits = ts->GetBranch(fITS->GetName()); |
310 | TClonesArray * sdig = new TClonesArray( "AliITSpListItem",1000 ); | |
fd04285a | 311 | //cout << "Region of Interest ts="<<ts<<" brchSDigits="<<brchSDigits<<" sdig="<<sdig<<endl; |
fca85276 | 312 | |
313 | if( brchSDigits ) { | |
fd04285a | 314 | brchSDigits->SetAddress( &sdig ); |
fca85276 | 315 | } else { |
316 | Error( "SetByRegionOfInterest","branch ITS not found in TreeS"); | |
317 | return; | |
318 | } // end if brchSDigits | |
319 | ||
320 | nm = fITS->GetITSgeom()->GetIndexMax(); | |
321 | for(m=0;m<nm;m++){ | |
0b572028 | 322 | //cout << " fModActive["<<m<<"]="; |
323 | fModActive[m] = kFALSE; // Not active by default | |
fca85276 | 324 | sdig->Clear(); |
325 | brchSDigits->GetEvent(m); | |
fd04285a | 326 | if(sdig->GetLast()>=0) for(i=0;i<sdig->GetLast();i++){ |
327 | // activate the necessary modules | |
328 | if(((AliITSpList*)sdig->At(m))->GetpListItem(i)->GetSignal()>0.0){ // Must have non zero signal. | |
0b572028 | 329 | fModActive[m] = kTRUE; |
fd04285a | 330 | break; |
fca85276 | 331 | } // end if |
fd04285a | 332 | } // end if. end for i. |
0b572028 | 333 | //cout << fModActive[m]; |
fd04285a | 334 | //cout << endl; |
fca85276 | 335 | } // end for m |
f8d9a5b8 | 336 | Info("AliITSDigitizer","Digitization by Region of Interest selected"); |
fca85276 | 337 | sdig->Clear(); |
338 | delete sdig; | |
fd04285a | 339 | return; |
fca85276 | 340 | } |