]>
Commit | Line | Data |
---|---|---|
3b9df642 | 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 | $Id$ | |
18 | */ | |
19 | ||
fcf95fc7 | 20 | |
7d62fb64 | 21 | ///////////////////////////////////////////////////////////////////// |
22 | // Base simulation functions for ITS // | |
23 | // // | |
24 | // // | |
25 | ///////////////////////////////////////////////////////////////////// | |
26 | #include "TBranch.h" | |
27 | #include "TClonesArray.h" | |
28 | #include "TObjArray.h" | |
29 | #include "TTree.h" | |
30 | ||
31 | #include "AliRun.h" | |
8ba39da9 | 32 | |
33 | #include "AliCDBManager.h" | |
34 | #include "AliCDBId.h" | |
35 | #include "AliCDBStorage.h" | |
36 | #include "AliCDBEntry.h" | |
37 | #include "AliCDBMetaData.h" | |
38 | ||
7d62fb64 | 39 | #include "AliITSdigit.h" |
40 | #include "AliITSdigitSPD.h" | |
41 | #include "AliITSdigitSDD.h" | |
42 | #include "AliITSdigitSSD.h" | |
3b9df642 | 43 | #include "AliITSDetTypeSim.h" |
7d62fb64 | 44 | #include "AliITSpListItem.h" |
fcf95fc7 | 45 | #include "AliITSresponseSDD.h" |
46 | #include "AliITSCalibrationSDD.h" | |
47 | #include "AliITSCalibrationSSD.h" | |
7d62fb64 | 48 | #include "AliITSsegmentationSPD.h" |
49 | #include "AliITSsegmentationSDD.h" | |
50 | #include "AliITSsegmentationSSD.h" | |
51 | #include "AliITSsimulation.h" | |
52 | #include "AliITSsimulationSPD.h" | |
53 | #include "AliITSsimulationSDD.h" | |
54 | #include "AliITSsimulationSSD.h" | |
55 | ||
56 | ||
57 | const Int_t AliITSDetTypeSim::fgkNdettypes = 3; | |
8ba39da9 | 58 | const Int_t AliITSDetTypeSim::fgkDefaultNModulesSPD = 240; |
59 | const Int_t AliITSDetTypeSim::fgkDefaultNModulesSDD = 260; | |
60 | const Int_t AliITSDetTypeSim::fgkDefaultNModulesSSD = 1698; | |
3b9df642 | 61 | |
62 | ClassImp(AliITSDetTypeSim) | |
63 | ||
64 | //---------------------------------------------------------------------- | |
65 | AliITSDetTypeSim::AliITSDetTypeSim(): | |
66 | TObject(), | |
67 | fGeom(), // | |
68 | fSimulation(), // [NDet] | |
69 | fSegmentation(), // [NDet] | |
fcf95fc7 | 70 | fCalibration(), // [NMod] |
3b9df642 | 71 | fPreProcess(), // [] e.g. Fill fHitModule with hits |
72 | fPostProcess(), // [] e.g. Wright Raw data | |
3b9df642 | 73 | fNSDigits(0), //! number of SDigits |
74 | fSDigits(), //! [NMod][NSDigits] | |
75 | fNDigits(0), //! number of Digits | |
76 | fDigits(), //! [NMod][NDigits] | |
77 | fHitClassName(), // String with Hit class name. | |
78 | fSDigClassName(),// String with SDigit class name. | |
79 | fDigClassName(){ // String with digit class name. | |
80 | // Default Constructor | |
81 | // Inputs: | |
82 | // none. | |
83 | // Outputs: | |
84 | // none. | |
85 | // Return: | |
86 | // A properly zero-ed AliITSDetTypeSim class. | |
7d62fb64 | 87 | fGeom = 0; |
88 | fSimulation = new TObjArray(fgkNdettypes); | |
89 | fSegmentation = new TObjArray(fgkNdettypes); | |
1964ae5f | 90 | fSegmentation->SetOwner(kTRUE); |
fcf95fc7 | 91 | fCalibration = 0; |
7d62fb64 | 92 | fPreProcess = 0; |
93 | fPostProcess = 0; | |
94 | fNSDigits = 0; | |
95 | fSDigits = new TClonesArray("AliITSpListItem",1000); | |
96 | fDigits = new TObjArray(fgkNdettypes); | |
97 | fNDigits = new Int_t[fgkNdettypes]; | |
98 | fLoader = 0; | |
8ba39da9 | 99 | fNMod[0] = fgkDefaultNModulesSPD; |
100 | fNMod[1] = fgkDefaultNModulesSDD; | |
101 | fNMod[2] = fgkDefaultNModulesSSD; | |
102 | SetRunNumber(); | |
103 | ||
3b9df642 | 104 | } |
105 | //---------------------------------------------------------------------- | |
106 | AliITSDetTypeSim::~AliITSDetTypeSim(){ | |
107 | // Destructor | |
108 | // Inputs: | |
109 | // none. | |
110 | // Outputs: | |
111 | // none. | |
112 | // Return: | |
113 | // Nothing. | |
7d62fb64 | 114 | |
7d62fb64 | 115 | if(fSimulation){ |
116 | fSimulation->Delete(); | |
117 | delete fSimulation; | |
118 | fSimulation = 0; | |
119 | } | |
120 | ||
121 | if(fSegmentation){ | |
122 | fSegmentation->Delete(); | |
123 | delete fSegmentation; | |
124 | fSegmentation = 0; | |
125 | } | |
126 | ||
fcf95fc7 | 127 | if(fCalibration){ |
2a476797 | 128 | AliITSresponse* rspd = ((AliITSCalibration*)fCalibration->At(fGeom->GetStartSPD()))->GetResponse(); |
fcf95fc7 | 129 | AliITSresponse* rsdd = ((AliITSCalibration*)fCalibration->At(fGeom->GetStartSDD()))->GetResponse(); |
130 | AliITSresponse* rssd = ((AliITSCalibration*)fCalibration->At(fGeom->GetStartSSD()))->GetResponse(); | |
131 | if(rspd) delete rspd; | |
132 | if(rsdd) delete rsdd; | |
133 | if(rssd) delete rssd; | |
134 | fCalibration->Delete(); | |
135 | delete fCalibration; | |
136 | fCalibration = 0; | |
7d62fb64 | 137 | } |
7dc65edb | 138 | |
fcf95fc7 | 139 | if(fGeom) delete fGeom; |
140 | ||
7d62fb64 | 141 | if(fPreProcess){ |
142 | fPreProcess->Delete(); | |
143 | delete fPreProcess; | |
144 | fPreProcess = 0; | |
145 | } | |
146 | ||
147 | if(fPostProcess){ | |
148 | fPostProcess->Delete(); | |
149 | delete fPostProcess; | |
150 | fPostProcess = 0; | |
151 | } | |
2a476797 | 152 | |
153 | if(fNDigits) delete [] fNDigits; | |
154 | ||
7d62fb64 | 155 | if (fLoader) |
156 | { | |
157 | fLoader->GetModulesFolder()->Remove(this); | |
158 | } | |
159 | ||
7d62fb64 | 160 | if (fSDigits) { |
161 | fSDigits->Delete(); | |
162 | delete fSDigits; | |
163 | fSDigits=0; | |
164 | } | |
165 | if (fDigits) { | |
166 | fDigits->Delete(); | |
167 | delete fDigits; | |
168 | fDigits=0; | |
169 | } | |
170 | ||
3b9df642 | 171 | } |
172 | //---------------------------------------------------------------------- | |
7d62fb64 | 173 | AliITSDetTypeSim::AliITSDetTypeSim(const AliITSDetTypeSim &source) : TObject(source){ |
174 | // Copy Constructor for object AliITSDetTypeSim not allowed | |
175 | if(this==&source) return; | |
176 | Error("Copy constructor", | |
177 | "You are not allowed to make a copy of the AliITSDetTypeSim"); | |
178 | exit(1); | |
3b9df642 | 179 | |
7d62fb64 | 180 | |
3b9df642 | 181 | } |
182 | //---------------------------------------------------------------------- | |
7d62fb64 | 183 | AliITSDetTypeSim& AliITSDetTypeSim::operator=(const AliITSDetTypeSim &source){ |
3b9df642 | 184 | // The = operator for object AliITSDetTypeSim |
7d62fb64 | 185 | |
186 | if(&source==this) return *this; | |
187 | Error("operator=","You are not allowed to make a copy of the AliITSDetTypeSIm"); | |
188 | exit(1); | |
3b9df642 | 189 | return *this; |
190 | } | |
7d62fb64 | 191 | |
192 | ||
3b9df642 | 193 | //______________________________________________________________________ |
7d62fb64 | 194 | void AliITSDetTypeSim::SetSimulationModel(Int_t dettype,AliITSsimulation *sim){ |
195 | ||
196 | //Set simulation model for detector type | |
197 | ||
198 | if(fSimulation==0) fSimulation = new TObjArray(fgkNdettypes); | |
199 | fSimulation->AddAt(sim,dettype); | |
200 | } | |
201 | //______________________________________________________________________ | |
202 | AliITSsimulation* AliITSDetTypeSim::GetSimulationModel(Int_t dettype){ | |
203 | ||
204 | //Get simulation model for detector type | |
205 | if(fSimulation==0) { | |
206 | Warning("GetSimulationModel","fSimulation is 0!"); | |
207 | return 0; | |
208 | } | |
209 | return (AliITSsimulation*)(fSimulation->At(dettype)); | |
210 | } | |
211 | //______________________________________________________________________ | |
212 | AliITSsimulation* AliITSDetTypeSim::GetSimulationModelByModule(Int_t module){ | |
213 | ||
214 | //Get simulation model by module number | |
215 | if(fGeom==0) { | |
216 | Warning("GetSimulationModelByModule","fGeom is 0!"); | |
217 | return 0; | |
218 | } | |
219 | ||
220 | return GetSimulationModel(fGeom->GetModuleType(module)); | |
221 | } | |
fcf95fc7 | 222 | //_______________________________________________________________________ |
1964ae5f | 223 | void AliITSDetTypeSim::SetDefaultSegmentation(Int_t idet){ |
224 | // Set default segmentation model objects | |
225 | AliITSsegmentation *seg; | |
226 | if(fSegmentation==0x0){ | |
227 | fSegmentation = new TObjArray(fgkNdettypes); | |
228 | fSegmentation->SetOwner(kTRUE); | |
229 | } | |
230 | if(GetSegmentationModel(idet))delete (AliITSsegmentation*)fSegmentation->At(idet); | |
231 | if(idet==0){ | |
232 | seg = new AliITSsegmentationSPD(fGeom); | |
233 | } | |
234 | else if(idet==1){ | |
fcf95fc7 | 235 | AliITSCalibration* res = GetCalibrationModel(fGeom->GetStartSDD()); |
1964ae5f | 236 | seg = new AliITSsegmentationSDD(fGeom,res); |
237 | } | |
238 | else { | |
239 | seg = new AliITSsegmentationSSD(fGeom); | |
240 | } | |
241 | SetSegmentationModel(idet,seg); | |
242 | } | |
243 | ||
7d62fb64 | 244 | //______________________________________________________________________ |
245 | void AliITSDetTypeSim::SetSegmentationModel(Int_t dettype,AliITSsegmentation *seg){ | |
246 | ||
247 | //Set segmentation model for detector type | |
fcf95fc7 | 248 | if(fSegmentation==0x0){ |
1964ae5f | 249 | fSegmentation = new TObjArray(fgkNdettypes); |
250 | fSegmentation->SetOwner(kTRUE); | |
251 | } | |
7d62fb64 | 252 | fSegmentation->AddAt(seg,dettype); |
253 | ||
254 | } | |
255 | //______________________________________________________________________ | |
256 | AliITSsegmentation* AliITSDetTypeSim::GetSegmentationModel(Int_t dettype){ | |
257 | ||
258 | //Get segmentation model for detector type | |
259 | ||
260 | if(fSegmentation==0) { | |
261 | Warning("GetSegmentationModel","fSegmentation is 0!"); | |
262 | return 0; | |
263 | } | |
264 | return (AliITSsegmentation*)(fSegmentation->At(dettype)); | |
265 | ||
266 | } | |
267 | //_______________________________________________________________________ | |
268 | AliITSsegmentation* AliITSDetTypeSim::GetSegmentationModelByModule(Int_t module){ | |
269 | ||
270 | //Get segmentation model by module number | |
271 | if(fGeom==0){ | |
272 | Warning("GetSegmentationModelByModule","fGeom is 0!"); | |
273 | return 0; | |
274 | } | |
275 | return GetSegmentationModel(fGeom->GetModuleType(module)); | |
276 | ||
277 | } | |
278 | //_______________________________________________________________________ | |
fcf95fc7 | 279 | void AliITSDetTypeSim::CreateCalibrationArray() { |
8ba39da9 | 280 | |
fcf95fc7 | 281 | //Create the container of calibration functions with correct size |
282 | if (fCalibration) { | |
283 | fCalibration->Delete(); | |
284 | delete fCalibration; | |
8ba39da9 | 285 | } |
286 | ||
287 | Int_t nModTot = 0; | |
288 | for (Int_t i=0; i<fgkNdettypes; i++) nModTot += fNMod[i]; | |
fcf95fc7 | 289 | fCalibration = new TObjArray(nModTot); |
290 | fCalibration->SetOwner(kTRUE); | |
291 | fCalibration->Clear(); | |
8ba39da9 | 292 | |
293 | } | |
294 | //_______________________________________________________________________ | |
fcf95fc7 | 295 | void AliITSDetTypeSim::SetCalibrationModel(Int_t iMod, AliITSCalibration *resp){ |
8ba39da9 | 296 | |
297 | //Set response model for modules | |
298 | ||
fcf95fc7 | 299 | if (fCalibration==0) CreateCalibrationArray(); |
8ba39da9 | 300 | |
fcf95fc7 | 301 | if (fCalibration->At(iMod)!=0) |
302 | delete (AliITSCalibration*) fCalibration->At(iMod); | |
303 | fCalibration->AddAt(resp, iMod); | |
8ba39da9 | 304 | |
305 | } | |
8ba39da9 | 306 | |
7d62fb64 | 307 | //______________________________________________________________________ |
fcf95fc7 | 308 | void AliITSDetTypeSim::ResetCalibrationArray(){ |
7d62fb64 | 309 | |
310 | //resets response array | |
fcf95fc7 | 311 | if(fCalibration) |
312 | fCalibration->Clear(); | |
8ba39da9 | 313 | |
7d62fb64 | 314 | } |
315 | //______________________________________________________________________ | |
316 | void AliITSDetTypeSim::ResetSegmentation(){ | |
317 | ||
318 | //Resets segmentation array | |
fcf95fc7 | 319 | if(fSegmentation) fSegmentation->Clear(); |
7d62fb64 | 320 | } |
321 | ||
322 | //_______________________________________________________________________ | |
fcf95fc7 | 323 | AliITSCalibration* AliITSDetTypeSim::GetCalibrationModel(Int_t iMod){ |
8ba39da9 | 324 | //Get response model for module number iMod |
325 | ||
fcf95fc7 | 326 | if(fCalibration==0) { |
327 | AliError("fCalibration is 0!"); | |
7d62fb64 | 328 | return 0; |
8ba39da9 | 329 | } |
330 | ||
fcf95fc7 | 331 | return (AliITSCalibration*)(fCalibration->At(iMod)); |
8ba39da9 | 332 | |
7d62fb64 | 333 | } |
334 | //_______________________________________________________________________ | |
335 | void AliITSDetTypeSim::SetDefaults(){ | |
336 | ||
337 | //Set defaults for segmentation and response | |
8ba39da9 | 338 | |
7d62fb64 | 339 | if(fGeom==0){ |
340 | Warning("SetDefaults","fGeom is 0!"); | |
341 | return; | |
342 | } | |
fcf95fc7 | 343 | if (fCalibration==0) CreateCalibrationArray(); |
7d62fb64 | 344 | |
fcf95fc7 | 345 | ResetCalibrationArray(); |
7d62fb64 | 346 | ResetSegmentation(); |
8ba39da9 | 347 | if(!GetCalibration()){AliFatal("Exit"); exit(0);} |
7d62fb64 | 348 | |
3a7c3e6d | 349 | for(Int_t idet=0;idet<fgkNdettypes;idet++){ |
7d62fb64 | 350 | //SPD |
3a7c3e6d | 351 | if(idet==0){ |
fcf95fc7 | 352 | if(!GetSegmentationModel(idet)) SetDefaultSegmentation(idet); |
353 | const char *kData0=(GetCalibrationModel(fGeom->GetStartSPD()))->DataType(); | |
7d62fb64 | 354 | if (strstr(kData0,"real")) { |
3a7c3e6d | 355 | SetDigitClassName(idet,"AliITSdigit"); |
8ba39da9 | 356 | } |
357 | else { | |
358 | SetDigitClassName(idet,"AliITSdigitSPD"); | |
359 | } | |
7d62fb64 | 360 | } |
361 | //SDD | |
3a7c3e6d | 362 | if(idet==1){ |
fcf95fc7 | 363 | if(!GetSegmentationModel(idet)) SetDefaultSegmentation(idet); |
364 | AliITSCalibrationSDD* rsp = (AliITSCalibrationSDD*)GetCalibrationModel(fGeom->GetStartSDD()); | |
365 | const char *kopt = ((AliITSresponseSDD*)rsp->GetResponse())->ZeroSuppOption(); | |
8ba39da9 | 366 | if((!strstr(kopt,"2D"))&&(!strstr(kopt,"1D"))) { |
367 | SetDigitClassName(idet,"AliITSdigit"); | |
368 | } | |
369 | else { | |
370 | SetDigitClassName(idet,"AliITSdigitSDD"); | |
371 | } | |
372 | ||
7d62fb64 | 373 | } |
374 | //SSD | |
3a7c3e6d | 375 | if(idet==2){ |
1964ae5f | 376 | if(!GetSegmentationModel(idet))SetDefaultSegmentation(idet); |
fcf95fc7 | 377 | |
378 | const char *kData2 = (GetCalibrationModel(fGeom->GetStartSSD())->DataType()); | |
7d62fb64 | 379 | if (strstr(kData2,"real")) { |
3a7c3e6d | 380 | SetDigitClassName(idet,"AliITSdigit"); |
8ba39da9 | 381 | } |
382 | else { | |
383 | SetDigitClassName(idet,"AliITSdigitSSD"); | |
384 | } | |
7d62fb64 | 385 | } |
8ba39da9 | 386 | } |
8ba39da9 | 387 | } |
388 | ||
389 | //______________________________________________________________________ | |
390 | Bool_t AliITSDetTypeSim::GetCalibration() { | |
391 | // Get Default calibration if a storage is not defined. | |
7d62fb64 | 392 | |
fcf95fc7 | 393 | AliCDBEntry *entrySPD = AliCDBManager::Instance()->Get("ITS/Calib/CalibSPD", fRunNumber); |
394 | AliCDBEntry *entrySDD = AliCDBManager::Instance()->Get("ITS/Calib/CalibSDD", fRunNumber); | |
395 | AliCDBEntry *entrySSD = AliCDBManager::Instance()->Get("ITS/Calib/CalibSSD", fRunNumber); | |
396 | AliCDBEntry *entry2SPD = AliCDBManager::Instance()->Get("ITS/Calib/RespSPD", fRunNumber); | |
397 | AliCDBEntry *entry2SDD = AliCDBManager::Instance()->Get("ITS/Calib/RespSDD", fRunNumber); | |
398 | AliCDBEntry *entry2SSD = AliCDBManager::Instance()->Get("ITS/Calib/RespSSD", fRunNumber); | |
06232459 | 399 | |
fcf95fc7 | 400 | if(!entrySPD || !entrySDD || !entrySSD || !entry2SPD || !entry2SDD || !entry2SSD){ |
401 | AliWarning("Calibration object retrieval failed! Dummy calibration will be used."); | |
402 | AliCDBStorage *origStorage = AliCDBManager::Instance()->GetDefaultStorage(); | |
403 | AliCDBManager::Instance()->SetDefaultStorage("local://$ALICE_ROOT"); | |
06232459 | 404 | |
fcf95fc7 | 405 | entrySPD = AliCDBManager::Instance()->Get("ITS/Calib/CalibSPD", fRunNumber); |
406 | entrySDD = AliCDBManager::Instance()->Get("ITS/Calib/CalibSDD", fRunNumber); | |
407 | entrySSD = AliCDBManager::Instance()->Get("ITS/Calib/CalibSSD", fRunNumber); | |
408 | entry2SPD = AliCDBManager::Instance()->Get("ITS/Calib/RespSPD", fRunNumber); | |
409 | entry2SDD = AliCDBManager::Instance()->Get("ITS/Calib/RespSDD", fRunNumber); | |
410 | entry2SSD = AliCDBManager::Instance()->Get("ITS/Calib/RespSSD", fRunNumber); | |
06232459 | 411 | |
fcf95fc7 | 412 | AliCDBManager::Instance()->SetDefaultStorage(origStorage); |
8ba39da9 | 413 | } |
8ba39da9 | 414 | |
06232459 | 415 | |
8ba39da9 | 416 | TObjArray *respSPD = (TObjArray *)entrySPD->GetObject(); |
417 | entrySPD->SetObject(NULL); | |
418 | entrySPD->SetOwner(kTRUE); | |
06232459 | 419 | |
fcf95fc7 | 420 | AliITSresponseSPD *pSPD = (AliITSresponseSPD*)entry2SPD->GetObject(); |
421 | entry2SPD->SetObject(NULL); | |
422 | entry2SPD->SetOwner(kTRUE); | |
423 | ||
8ba39da9 | 424 | TObjArray *respSDD = (TObjArray *)entrySDD->GetObject(); |
425 | entrySDD->SetObject(NULL); | |
426 | entrySDD->SetOwner(kTRUE); | |
06232459 | 427 | |
fcf95fc7 | 428 | AliITSresponseSDD *pSDD = (AliITSresponseSDD*)entry2SDD->GetObject(); |
429 | entry2SDD->SetObject(NULL); | |
430 | entry2SDD->SetOwner(kTRUE); | |
431 | ||
8ba39da9 | 432 | TObjArray *respSSD = (TObjArray *)entrySSD->GetObject(); |
433 | entrySSD->SetObject(NULL); | |
434 | entrySSD->SetOwner(kTRUE); | |
06232459 | 435 | |
fcf95fc7 | 436 | AliITSresponseSSD *pSSD = (AliITSresponseSSD*)entry2SSD->GetObject(); |
437 | entry2SSD->SetObject(NULL); | |
438 | entry2SSD->SetOwner(kTRUE); | |
439 | ||
8ba39da9 | 440 | // DB entries are dleted. In this waymetadeta objects are deleted as well |
441 | delete entrySPD; | |
442 | delete entrySDD; | |
443 | delete entrySSD; | |
fcf95fc7 | 444 | delete entry2SPD; |
445 | delete entry2SDD; | |
446 | delete entry2SSD; | |
447 | ||
448 | if ((!pSPD)||(!pSDD)||(!pSSD)) { | |
449 | AliWarning("Can not get calibration from calibration database !"); | |
450 | return kFALSE; | |
451 | } | |
8ba39da9 | 452 | if ((! respSPD)||(! respSDD)||(! respSSD)) { |
453 | AliWarning("Can not get calibration from calibration database !"); | |
454 | return kFALSE; | |
455 | } | |
456 | fNMod[0] = respSPD->GetEntries(); | |
457 | fNMod[1] = respSDD->GetEntries(); | |
458 | fNMod[2] = respSSD->GetEntries(); | |
459 | AliInfo(Form("%i SPD, %i SDD and %i SSD in calibration database", | |
460 | fNMod[0], fNMod[1], fNMod[2])); | |
fcf95fc7 | 461 | AliITSCalibration* res; |
8ba39da9 | 462 | for (Int_t i=0; i<fNMod[0]; i++) { |
fcf95fc7 | 463 | res = (AliITSCalibration*) respSPD->At(i); |
464 | res->SetResponse((AliITSresponse*)pSPD); | |
465 | SetCalibrationModel(i, res); | |
8ba39da9 | 466 | } |
467 | for (Int_t i=0; i<fNMod[1]; i++) { | |
fcf95fc7 | 468 | res = (AliITSCalibration*) respSDD->At(i); |
469 | res->SetResponse(pSDD); | |
8ba39da9 | 470 | Int_t iMod = i + fNMod[0]; |
fcf95fc7 | 471 | SetCalibrationModel(iMod, res); |
8ba39da9 | 472 | } |
473 | for (Int_t i=0; i<fNMod[2]; i++) { | |
fcf95fc7 | 474 | res = (AliITSCalibration*) respSSD->At(i); |
475 | res->SetResponse((AliITSresponse*)pSSD); | |
8ba39da9 | 476 | Int_t iMod = i + fNMod[0] + fNMod[1]; |
fcf95fc7 | 477 | SetCalibrationModel(iMod, res); |
8ba39da9 | 478 | } |
479 | ||
480 | return kTRUE; | |
7d62fb64 | 481 | } |
482 | ||
8ba39da9 | 483 | |
484 | ||
7d62fb64 | 485 | //_______________________________________________________________________ |
486 | void AliITSDetTypeSim::SetDefaultSimulation(){ | |
487 | ||
488 | //Set default simulation for detector type | |
489 | ||
7d62fb64 | 490 | if(fGeom==0){ |
fcf95fc7 | 491 | Warning("SetDefaultSimulation","fGeom is 0!"); |
8ba39da9 | 492 | return; |
493 | } | |
fcf95fc7 | 494 | if(fCalibration==0){ |
495 | Warning("SetDefaultSimulation","fCalibration is 0!"); | |
7d62fb64 | 496 | return; |
497 | } | |
fcf95fc7 | 498 | if(fSegmentation==0){ |
499 | Warning("SetDefaultSimulation","fSegmentation is 0!"); | |
500 | for(Int_t i=0;i<fgkNdettypes;i++) SetDefaultSegmentation(i); | |
1964ae5f | 501 | } |
fcf95fc7 | 502 | else{ |
1964ae5f | 503 | for(Int_t i=0;i<fgkNdettypes;i++){ |
504 | if(!GetSegmentationModel(i)){ | |
fcf95fc7 | 505 | Warning("SetDefaultSimulation","Segmentation not defined for det %d - Default taken\n!",i); |
1964ae5f | 506 | SetDefaultSegmentation(i); |
507 | } | |
508 | } | |
509 | } | |
7d62fb64 | 510 | AliITSsimulation* sim; |
511 | ||
512 | for(Int_t idet=0;idet<fgkNdettypes;idet++){ | |
513 | //SPD | |
514 | if(idet==0){ | |
515 | sim = GetSimulationModel(idet); | |
fcf95fc7 | 516 | |
7d62fb64 | 517 | if(!sim){ |
8ba39da9 | 518 | sim = new AliITSsimulationSPD(this); |
7d62fb64 | 519 | SetSimulationModel(idet,sim); |
7d62fb64 | 520 | } |
521 | } | |
522 | //SDD | |
523 | if(idet==1){ | |
524 | sim = GetSimulationModel(idet); | |
525 | if(!sim){ | |
8ba39da9 | 526 | sim = new AliITSsimulationSDD(this); |
7d62fb64 | 527 | SetSimulationModel(idet,sim); |
7d62fb64 | 528 | } |
529 | ||
530 | } | |
531 | //SSD | |
532 | if(idet==2){ | |
533 | sim = GetSimulationModel(idet); | |
534 | if(!sim){ | |
8ba39da9 | 535 | sim = new AliITSsimulationSSD(this); |
7d62fb64 | 536 | SetSimulationModel(idet,sim); |
7d62fb64 | 537 | } |
538 | ||
539 | } | |
540 | ||
541 | } | |
542 | } | |
543 | ||
8ba39da9 | 544 | |
545 | ||
546 | ||
7d62fb64 | 547 | //___________________________________________________________________ |
548 | void AliITSDetTypeSim::SetTreeAddressS(TTree* treeS, Char_t* name){ | |
549 | // Set branch address for the ITS summable digits Trees. | |
550 | ||
551 | char branchname[30]; | |
552 | ||
553 | if(!treeS){ | |
554 | return; | |
555 | } | |
556 | if (fSDigits == 0x0){ | |
557 | fSDigits = new TClonesArray("AliITSpListItem",1000); | |
558 | } | |
559 | TBranch *branch; | |
560 | sprintf(branchname,"%s",name); | |
561 | branch = treeS->GetBranch(branchname); | |
562 | if (branch) branch->SetAddress(&fSDigits); | |
563 | ||
564 | } | |
565 | //___________________________________________________________________ | |
566 | void AliITSDetTypeSim::SetTreeAddressD(TTree* treeD, Char_t* name){ | |
567 | // Set branch address for the digit Trees. | |
568 | ||
569 | const char *det[3] = {"SPD","SDD","SSD"}; | |
570 | TBranch *branch; | |
571 | ||
572 | char branchname[30]; | |
573 | ||
574 | if(!treeD){ | |
575 | return; | |
576 | } | |
577 | if(!fDigits){ | |
578 | fDigits = new TObjArray(fgkNdettypes); | |
579 | } | |
580 | for(Int_t i=0;i<fgkNdettypes;i++){ | |
581 | Char_t* digclass = GetDigitClassName(i); | |
582 | if(digclass==0x0){ | |
583 | if(i==0) SetDigitClassName(i,"AliITSdigitSPD"); | |
584 | if(i==1) SetDigitClassName(i,"AliITSdigitSDD"); | |
585 | if(i==2) SetDigitClassName(i,"AliITSdigitSSD"); | |
586 | digclass = GetDigitClassName(i); | |
587 | } | |
588 | TString classn = digclass; | |
589 | if(!(fDigits->At(i))){ | |
590 | fDigits->AddAt(new TClonesArray(classn.Data(),1000),i); | |
3b9df642 | 591 | }else{ |
7d62fb64 | 592 | ResetDigits(i); |
593 | } | |
594 | ||
595 | if(fgkNdettypes==3) sprintf(branchname,"%sDigits%s",name,det[i]); | |
596 | else sprintf(branchname,"%sDigits%d",name,i+1); | |
597 | if(fDigits){ | |
598 | branch = treeD->GetBranch(branchname); | |
599 | if(branch) branch->SetAddress(&((*fDigits)[i])); | |
600 | } | |
601 | } | |
3b9df642 | 602 | |
3b9df642 | 603 | } |
7d62fb64 | 604 | //___________________________________________________________________ |
605 | void AliITSDetTypeSim::ResetDigits(){ | |
606 | // Reset number of digits and the digits array for the ITS detector. | |
607 | ||
608 | ||
609 | if(!fDigits){ | |
610 | Error("ResetDigits","fDigits is null!"); | |
611 | return; | |
612 | } | |
613 | for(Int_t i=0;i<fgkNdettypes;i++){ | |
614 | ResetDigits(i); | |
615 | } | |
616 | } | |
617 | //___________________________________________________________________ | |
618 | void AliITSDetTypeSim::ResetDigits(Int_t branch){ | |
619 | // Reset number of digits and the digits array for this branch. | |
620 | ||
621 | if(fDigits->At(branch)){ | |
622 | ((TClonesArray*)fDigits->At(branch))->Clear(); | |
623 | } | |
624 | if(fNDigits) fNDigits[branch]=0; | |
625 | ||
626 | } | |
627 | ||
628 | ||
629 | ||
630 | //_______________________________________________________________________ | |
631 | void AliITSDetTypeSim::SDigitsToDigits(Option_t* opt, Char_t* name){ | |
632 | // Standard Summable digits to Digits function. | |
633 | if(!fGeom){ | |
634 | Warning("SDigitsToDigits","fGeom is null!!"); | |
635 | return; | |
636 | } | |
637 | ||
638 | const char *all = strstr(opt,"All"); | |
639 | const char *det[3] = {strstr(opt,"SPD"),strstr(opt,"SDD"), | |
640 | strstr(opt,"SSD")}; | |
641 | if( !det[0] && !det[1] && !det[2] ) all = "All"; | |
642 | else all = 0; | |
643 | static Bool_t setDef = kTRUE; | |
644 | if(setDef) SetDefaultSimulation(); | |
645 | setDef = kFALSE; | |
646 | ||
647 | AliITSsimulation *sim =0; | |
648 | TTree* trees = fLoader->TreeS(); | |
649 | if( !(trees && GetSDigits()) ){ | |
650 | Error("SDigits2Digits","Error: No trees or SDigits. Returning."); | |
651 | return; | |
652 | } | |
653 | sprintf(name,"%s",name); | |
654 | TBranch* brchSDigits = trees->GetBranch(name); | |
655 | ||
656 | Int_t id; | |
657 | for(Int_t module=0;module<fGeom->GetIndexMax();module++){ | |
658 | id = fGeom->GetModuleType(module); | |
659 | if (!all && !det[id]) continue; | |
660 | sim = (AliITSsimulation*)GetSimulationModel(id); | |
8ba39da9 | 661 | printf("module=%d name=%s\n",module,sim->ClassName()); |
7d62fb64 | 662 | if(!sim){ |
663 | Error("SDigit2Digits","The simulation class was not " | |
664 | "instanciated for module %d type %s!",module, | |
665 | fGeom->GetModuleTypeName(module)); | |
666 | exit(1); | |
667 | } | |
668 | sim->InitSimulationModule(module,gAlice->GetEvNumber()); | |
669 | ||
670 | fSDigits->Clear(); | |
671 | brchSDigits->GetEvent(module); | |
672 | sim->AddSDigitsToModule(fSDigits,0); | |
673 | sim->FinishSDigitiseModule(); | |
674 | fLoader->TreeD()->Fill(); | |
675 | ResetDigits(); | |
676 | } | |
677 | fLoader->TreeD()->GetEntries(); | |
678 | fLoader->TreeD()->AutoSave(); | |
679 | fLoader->TreeD()->Reset(); | |
680 | } | |
681 | ||
682 | ||
683 | ||
684 | //_________________________________________________________ | |
685 | void AliITSDetTypeSim::AddSumDigit(AliITSpListItem &sdig){ | |
686 | ||
687 | //Adds the module full of summable digits to the summable digits tree. | |
688 | TClonesArray &lsdig = *fSDigits; | |
689 | new(lsdig[fNSDigits++]) AliITSpListItem(sdig); | |
690 | } | |
691 | //__________________________________________________________ | |
692 | void AliITSDetTypeSim::AddRealDigit(Int_t branch, Int_t *digits){ | |
693 | // Add a real digit - as coming from data. | |
694 | TClonesArray &ldigits = *((TClonesArray*)fDigits->At(branch)); | |
695 | new(ldigits[fNDigits[branch]++]) AliITSdigit(digits); | |
696 | } | |
697 | //__________________________________________________________ | |
698 | void AliITSDetTypeSim::AddSimDigit(Int_t branch, AliITSdigit* d){ | |
699 | ||
700 | // Add a simulated digit. | |
701 | TClonesArray &ldigits = *((TClonesArray*)fDigits->At(branch)); | |
702 | switch(branch){ | |
703 | case 0: | |
704 | new(ldigits[fNDigits[branch]++]) AliITSdigitSPD(*((AliITSdigitSPD*)d)); | |
705 | break; | |
706 | case 1: | |
707 | new(ldigits[fNDigits[branch]++]) AliITSdigitSDD(*((AliITSdigitSDD*)d)); | |
708 | break; | |
709 | case 2: | |
710 | new(ldigits[fNDigits[branch]++]) AliITSdigitSSD(*((AliITSdigitSSD*)d)); | |
711 | break; | |
712 | } | |
713 | ||
7d62fb64 | 714 | } |
715 | ||
3b9df642 | 716 | //______________________________________________________________________ |
7d62fb64 | 717 | void AliITSDetTypeSim::AddSimDigit(Int_t branch,Float_t phys,Int_t *digits, |
718 | Int_t *tracks,Int_t *hits,Float_t *charges){ | |
719 | // Add a simulated digit to the list. | |
720 | ||
721 | TClonesArray &ldigits = *((TClonesArray*)fDigits->At(branch)); | |
fcf95fc7 | 722 | AliITSCalibrationSDD *resp = 0; |
7d62fb64 | 723 | switch(branch){ |
724 | case 0: | |
725 | new(ldigits[fNDigits[branch]++]) AliITSdigitSPD(digits,tracks,hits); | |
726 | break; | |
727 | case 1: | |
fcf95fc7 | 728 | resp = (AliITSCalibrationSDD*)GetCalibrationModel(fGeom->GetStartSDD()); |
7d62fb64 | 729 | new(ldigits[fNDigits[branch]++]) AliITSdigitSDD(phys,digits,tracks, |
730 | hits,charges,resp); | |
731 | break; | |
732 | case 2: | |
733 | new(ldigits[fNDigits[branch]++]) AliITSdigitSSD(digits,tracks,hits); | |
734 | break; | |
735 | } | |
3b9df642 | 736 | } |
8ba39da9 | 737 | |
738 | ||
739 | ||
740 | //______________________________________________________________________ | |
741 | void AliITSDetTypeSim::StoreCalibration(Int_t firstRun, Int_t lastRun, AliCDBMetaData &md) { | |
742 | ||
743 | // Store calibration in the calibration database | |
744 | ||
745 | // The database must be created in an external piece of code (i.e. | |
746 | // a configuration macro ) | |
747 | ||
748 | if(!AliCDBManager::Instance()->IsDefaultStorageSet()) { | |
06232459 | 749 | AliWarning("No storage set! Will use dummy one"); |
8ba39da9 | 750 | AliCDBManager::Instance()->SetDefaultStorage("local://$ALICE_ROOT"); |
8ba39da9 | 751 | } |
752 | ||
fcf95fc7 | 753 | if (!fCalibration) { |
754 | AliError("AliITSCalibration classes are not defined - nothing done"); | |
8ba39da9 | 755 | return; |
756 | } | |
fcf95fc7 | 757 | AliCDBId idRespSPD("ITS/Calib/CalibSPD",firstRun, lastRun); |
758 | AliCDBId idRespSDD("ITS/Calib/CalibSDD",firstRun, lastRun); | |
759 | AliCDBId idRespSSD("ITS/Calib/CalibSSD",firstRun, lastRun); | |
8ba39da9 | 760 | |
761 | TObjArray respSPD(fNMod[0]); | |
762 | TObjArray respSDD(fNMod[1]-fNMod[0]); | |
763 | TObjArray respSSD(fNMod[2]-fNMod[1]); | |
764 | respSPD.SetOwner(kFALSE); | |
765 | respSSD.SetOwner(kFALSE); | |
766 | respSSD.SetOwner(kFALSE); | |
767 | ||
768 | Int_t index[fgkNdettypes]; | |
769 | for (Int_t i = 0; i<fgkNdettypes; i++ ) { | |
770 | index[i] = 0; | |
771 | for (Int_t j = 0; j<=i; j++ ) | |
772 | index[i]+=fNMod[j]; | |
773 | } | |
774 | ||
775 | for (Int_t i = 0; i<index[0]; i++ ) | |
fcf95fc7 | 776 | respSPD.Add(fCalibration->At(i)); |
8ba39da9 | 777 | |
778 | for (Int_t i = index[0]; i<index[1]; i++ ) | |
fcf95fc7 | 779 | respSDD.Add(fCalibration->At(i)); |
8ba39da9 | 780 | |
781 | for (Int_t i = index[1]; i<index[2]; i++ ) | |
fcf95fc7 | 782 | respSSD.Add(fCalibration->At(i)); |
8ba39da9 | 783 | |
06232459 | 784 | AliCDBManager::Instance()->Put(&respSPD, idRespSPD, &md); |
785 | AliCDBManager::Instance()->Put(&respSDD, idRespSDD, &md); | |
786 | AliCDBManager::Instance()->Put(&respSSD, idRespSSD, &md); | |
fcf95fc7 | 787 | |
788 | ||
789 | ||
8ba39da9 | 790 | } |
791 | ||
792 |