Line data Source code
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 :
20 :
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"
32 :
33 : #include "AliCDBManager.h"
34 : #include "AliCDBId.h"
35 : #include "AliCDBStorage.h"
36 : #include "AliCDBEntry.h"
37 : #include "AliCDBMetaData.h"
38 : #include "AliITSdigit.h"
39 : #include "AliITSdigitSPD.h"
40 : #include "AliITSdigitSDD.h"
41 : #include "AliITSdigitSSD.h"
42 : #include "AliITSgeom.h"
43 : #include "AliITSDetTypeSim.h"
44 : #include "AliITSpListItem.h"
45 : #include "AliITSCalibration.h"
46 : #include "AliITSCalibrationSDD.h"
47 : #include "AliITSMapSDD.h"
48 : #include "AliITSCorrMapSDD.h"
49 : #include "AliITSDriftSpeedArraySDD.h"
50 : #include "AliITSDriftSpeedSDD.h"
51 : #include "AliITSCalibrationSSD.h"
52 : #include "AliITSNoiseSSDv2.h"
53 : #include "AliITSGainSSDv2.h"
54 : #include "AliITSBadChannelsSSDv2.h"
55 : #include "AliITSNoiseSSD.h"
56 : #include "AliITSGainSSD.h"
57 : #include "AliITSBadChannelsSSD.h"
58 : #include "AliITSCalibrationSSD.h"
59 : #include "AliITSsegmentationSPD.h"
60 : #include "AliITSsegmentationSDD.h"
61 : #include "AliITSsegmentationSSD.h"
62 : #include "AliITSsimulation.h"
63 : #include "AliITSsimulationSPD.h"
64 : #include "AliITSsimulationSDD.h"
65 : #include "AliITSsimulationSSD.h"
66 : #include "AliITSresponseSDD.h"
67 : #include "AliITSDDLModuleMapSDD.h"
68 : #include "AliITSTriggerConditions.h"
69 : #include "AliBaseLoader.h"
70 : #include "AliLog.h"
71 : #include <iostream>
72 :
73 : const Int_t AliITSDetTypeSim::fgkNdettypes = 3;
74 : const Int_t AliITSDetTypeSim::fgkDefaultNModulesSPD = 240;
75 : const Int_t AliITSDetTypeSim::fgkDefaultNModulesSDD = 260;
76 : const Int_t AliITSDetTypeSim::fgkDefaultNModulesSSD = 1698;
77 :
78 : using std::endl;
79 : using std::cout;
80 116 : ClassImp(AliITSDetTypeSim)
81 :
82 : //----------------------------------------------------------------------
83 : AliITSDetTypeSim::AliITSDetTypeSim():
84 13 : TObject(),
85 13 : fSimulation(), // [NDet]
86 13 : fSegmentation(), // [NDet]
87 13 : fCalibration(), // [NMod]
88 13 : fSSDCalibration(0),
89 13 : fSPDNoisy(0),
90 13 : fSPDSparseDead(0),
91 13 : fNSDigits(0), //! number of SDigits
92 13 : fSDigits("AliITSpListItem",1000),
93 13 : fNDigits(0), //! number of Digits
94 13 : fRunNumber(0), //! Run number (to access DB)
95 13 : fDigits(), //! [NMod][NDigits]
96 13 : fSimuPar(0),
97 13 : fDDLMapSDD(0),
98 13 : fRespSDD(0),
99 13 : fAveGainSDD(0),
100 13 : fkDigClassName(), // String with digit class name.
101 13 : fLoader(0), // local pointer to loader
102 13 : fFirstcall(kTRUE),
103 13 : fFOGenerator(),
104 13 : fTriggerConditions(NULL)
105 65 : {
106 : // Default Constructor
107 : // Inputs:
108 : // none.
109 : // Outputs:
110 : // none.
111 : // Return:
112 : // A properly zero-ed AliITSDetTypeSim class.
113 :
114 39 : fSimulation = new TObjArray(fgkNdettypes);
115 39 : fSegmentation = new TObjArray(fgkNdettypes);
116 13 : fSegmentation->SetOwner(kTRUE);
117 39 : fDigits = new TObjArray(fgkNdettypes);
118 26 : fNDigits = new Int_t[fgkNdettypes];
119 39 : fDDLMapSDD=new AliITSDDLModuleMapSDD();
120 39 : fSimuPar= new AliITSSimuParam();
121 39 : fSSDCalibration=new AliITSCalibrationSSD();
122 13 : SetRunNumber();
123 26 : }
124 : //----------------------------------------------------------------------
125 78 : AliITSDetTypeSim::~AliITSDetTypeSim(){
126 : // Destructor
127 : // Inputs:
128 : // none.
129 : // Outputs:
130 : // none.
131 : // Return:
132 : // Nothing.
133 :
134 13 : if(fSimulation){
135 13 : fSimulation->Delete();
136 26 : delete fSimulation;
137 : }
138 13 : fSimulation = 0;
139 13 : if(fSegmentation){
140 13 : fSegmentation->Delete();
141 26 : delete fSegmentation;
142 : }
143 13 : fSegmentation = 0;
144 15 : if(fCalibration && fRunNumber<0){
145 :
146 0 : fCalibration->Delete();
147 0 : delete fCalibration;
148 : }
149 13 : fCalibration = 0;
150 13 : if(fSSDCalibration) {
151 26 : if(!(AliCDBManager::Instance()->GetCacheFlag())) {
152 0 : delete fSSDCalibration;
153 0 : fSSDCalibration = NULL;
154 0 : }
155 : }
156 13 : if(fSPDNoisy){
157 4 : if(!(AliCDBManager::Instance()->GetCacheFlag())) {
158 0 : fSPDNoisy->Delete();
159 0 : delete fSPDNoisy;
160 0 : fSPDNoisy = 0;
161 0 : }
162 : }
163 13 : if(fSPDSparseDead){
164 0 : if(!(AliCDBManager::Instance()->GetCacheFlag())) {
165 0 : fSPDSparseDead->Delete();
166 0 : delete fSPDSparseDead;
167 0 : fSPDSparseDead = 0;
168 0 : }
169 : }
170 39 : if(fSimuPar) delete fSimuPar;
171 13 : if(fRespSDD){
172 4 : if(!(AliCDBManager::Instance()->GetCacheFlag())){
173 0 : delete fRespSDD;
174 0 : fRespSDD=0;
175 0 : }
176 : }
177 39 : if(fDDLMapSDD) delete fDDLMapSDD;
178 39 : if(fNDigits) delete [] fNDigits;
179 13 : fNDigits = 0;
180 39 : if (fLoader)fLoader->GetModulesFolder()->Remove(this);
181 13 : fLoader = 0; // Not deleting it.
182 13 : fSDigits.Delete();
183 13 : if (fDigits) {
184 13 : fDigits->Delete();
185 26 : delete fDigits;
186 : }
187 13 : fDigits=0;
188 39 : }
189 : //----------------------------------------------------------------------
190 : // AliITSDetTypeSim::AliITSDetTypeSim(const AliITSDetTypeSim &source) : TObject(source),
191 : // fSimulation(source.fSimulation), // [NDet]
192 : // fSegmentation(source.fSegmentation), // [NDet]
193 : // fCalibration(source.fCalibration), // [NMod]
194 : // fSSDCalibration(source.fSSDCalibration),
195 : // fSPDNoisy(source.fSPDNoisy),
196 : // fSPDSparseDead(source.fSPDSparseDead),
197 : // fNSDigits(source.fNSDigits), //! number of SDigits
198 : // fSDigits(*((TClonesArray*)source.fSDigits.Clone())),
199 : // fNDigits(source.fNDigits), //! number of Digits
200 : // fRunNumber(source.fRunNumber), //! Run number (to access DB)
201 : // fDigits(source.fDigits), //! [NMod][NDigits]
202 : // fSimuPar(source.fSimuPar),
203 : // fDDLMapSDD(source.fDDLMapSDD),
204 : // fRespSDD(source.fRespSDD),
205 : // fAveGainSDD(source.fAveGainSDD),
206 : // fkDigClassName(), // String with digit class name.
207 : // fLoader(source.fLoader), // local pointer to loader
208 : // fFirstcall(source.fFirstcall),
209 : // fFOGenerator(source.fFOGenerator),
210 : // fTriggerConditions(source.fTriggerConditions)
211 : // {
212 : // // Copy Constructor for object AliITSDetTypeSim not allowed
213 : // for(Int_t i=0;i<fgkNdettypes;i++){
214 : // fkDigClassName[i] = source.fkDigClassName[i];
215 : // }
216 : // }
217 : // //----------------------------------------------------------------------
218 : // AliITSDetTypeSim& AliITSDetTypeSim::operator=(const AliITSDetTypeSim &source){
219 : // // The = operator for object AliITSDetTypeSim
220 :
221 : // this->~AliITSDetTypeSim();
222 : // new(this) AliITSDetTypeSim(source);
223 : // return *this;
224 : // }
225 :
226 : //______________________________________________________________________
227 : void AliITSDetTypeSim::SetITSgeom(AliITSgeom *geom){
228 : // Sets/replaces the existing AliITSgeom object kept in AliITSLoader
229 : //
230 : // Inputs:
231 : // AliITSgoem *geom The AliITSgeom object to be used.
232 : // Output:
233 : // none.
234 : // Return:
235 : // none.
236 4 : if(!fLoader){
237 0 : Error("SetITSgeom","No pointer to loader - nothing done");
238 0 : return;
239 : }
240 : else {
241 2 : fLoader->SetITSgeom(geom); // protections in AliITSLoader::SetITSgeom
242 : }
243 :
244 2 : }
245 : //______________________________________________________________________
246 : void AliITSDetTypeSim::SetLoader(AliITSLoader *loader){
247 : // Sets the local copy of the AliITSLoader, and passes on the
248 : // AliITSgeom object as needed.
249 : // Inputs
250 : // AliITSLoader *loader pointer to AliITSLoader for local use
251 : // Outputs:
252 : // none.
253 : // Return:
254 : // none.
255 :
256 410 : if(fLoader==loader) return; // Same do nothing
257 13 : if(fLoader){ // alread have an existing loader
258 0 : Error("SetLoader",
259 : "Already have an exisiting loader ptr=%p Nothing done",
260 : fLoader);
261 0 : } // end if
262 13 : fLoader = loader;
263 218 : }
264 : //______________________________________________________________________
265 : void AliITSDetTypeSim::SetSimulationModel(Int_t dettype,AliITSsimulation *sim){
266 :
267 : //Set simulation model for detector type
268 :
269 6 : if(fSimulation==0) fSimulation = new TObjArray(fgkNdettypes);
270 3 : fSimulation->AddAt(sim,dettype);
271 3 : }
272 : //______________________________________________________________________
273 : AliITSsimulation* AliITSDetTypeSim::GetSimulationModel(Int_t dettype) const {
274 :
275 : //Get simulation model for detector type
276 17590 : if(fSimulation==0) {
277 0 : Warning("GetSimulationModel","fSimulation is 0!");
278 0 : return 0;
279 : }
280 8795 : return (AliITSsimulation*)(fSimulation->At(dettype));
281 8795 : }
282 : //______________________________________________________________________
283 : AliITSsimulation* AliITSDetTypeSim::GetSimulationModelByModule(Int_t module) const {
284 :
285 : //Get simulation model by module number
286 0 : if(GetITSgeom()==0) {
287 0 : Warning("GetSimulationModelByModule","GetITSgeom() is 0!");
288 0 : return 0;
289 : }
290 :
291 0 : return GetSimulationModel(GetITSgeom()->GetModuleType(module));
292 0 : }
293 : //_______________________________________________________________________
294 : void AliITSDetTypeSim::SetDefaultSegmentation(Int_t idet){
295 : // Set default segmentation model objects
296 : AliITSsegmentation *seg;
297 :
298 30 : if(fSegmentation==0x0){
299 0 : fSegmentation = new TObjArray(fgkNdettypes);
300 0 : fSegmentation->SetOwner(kTRUE);
301 0 : }
302 15 : if(GetSegmentationModel(idet))
303 0 : delete (AliITSsegmentation*)fSegmentation->At(idet);
304 15 : if(idet==0){
305 10 : seg = new AliITSsegmentationSPD();
306 25 : }else if(idet==1){
307 20 : seg = new AliITSsegmentationSDD();
308 5 : AliITSCalibrationSDD* cal=(AliITSCalibrationSDD*)GetCalibrationModel(fgkDefaultNModulesSPD+1);
309 5 : if(cal->IsAMAt20MHz()){
310 5 : seg->SetPadSize(seg->Dpz(0),20.);
311 5 : seg->SetNPads(seg->Npz()/2,128);
312 5 : }
313 5 : }else {
314 10 : seg = new AliITSsegmentationSSD();
315 : }
316 15 : SetSegmentationModel(idet,seg);
317 15 : }
318 : //______________________________________________________________________
319 : void AliITSDetTypeSim::SetSegmentationModel(Int_t dettype,
320 : AliITSsegmentation *seg){
321 :
322 : //Set segmentation model for detector type
323 30 : if(fSegmentation==0x0){
324 0 : fSegmentation = new TObjArray(fgkNdettypes);
325 0 : fSegmentation->SetOwner(kTRUE);
326 0 : }
327 15 : fSegmentation->AddAt(seg,dettype);
328 15 : }
329 : //______________________________________________________________________
330 : AliITSsegmentation* AliITSDetTypeSim::GetSegmentationModel(Int_t dettype) const{
331 : //Get segmentation model for detector type
332 :
333 194234208 : if(fSegmentation==0) {
334 0 : Warning("GetSegmentationModel","fSegmentation is 0!");
335 0 : return 0;
336 : }
337 97117104 : return (AliITSsegmentation*)(fSegmentation->At(dettype));
338 97117104 : }
339 : //_______________________________________________________________________
340 : AliITSsegmentation* AliITSDetTypeSim::GetSegmentationModelByModule(Int_t module) const{
341 : //Get segmentation model by module number
342 0 : if(GetITSgeom()==0){
343 0 : Warning("GetSegmentationModelByModule","GetITSgeom() is 0!");
344 0 : return 0;
345 : }
346 0 : return GetSegmentationModel(GetITSgeom()->GetModuleType(module));
347 0 : }
348 : //_______________________________________________________________________
349 : void AliITSDetTypeSim::CreateCalibrationArray() {
350 : //Create the container of calibration functions with correct size
351 4 : if (fCalibration) {
352 0 : Warning("CreateCalibration","pointer to calibration object exists\n");
353 0 : fCalibration->Delete();
354 0 : delete fCalibration;
355 : }
356 :
357 2 : Int_t nModTot = GetITSgeom()->GetIndexMax();
358 4 : fCalibration = new TObjArray(nModTot);
359 2 : fCalibration->SetOwner(kTRUE);
360 2 : fCalibration->Clear();
361 2 : }
362 : //_______________________________________________________________________
363 : void AliITSDetTypeSim::SetCalibrationModel(Int_t iMod, AliITSCalibration *resp){
364 : //Set response model for modules
365 :
366 2000 : if (fCalibration==0) CreateCalibrationArray();
367 :
368 1000 : if (fCalibration->At(iMod)!=0)
369 0 : delete (AliITSCalibration*) fCalibration->At(iMod);
370 1000 : fCalibration->AddAt(resp, iMod);
371 1000 : }
372 : //_______________________________________________________________________
373 : void AliITSDetTypeSim::SetSPDNoisyModel(Int_t iMod, AliITSCalibration *cal){
374 : //Set noisy pixel info for the SPD module iMod
375 960 : if (fSPDNoisy==0) {
376 4 : fSPDNoisy = new TObjArray(fgkDefaultNModulesSPD);
377 2 : fSPDNoisy->SetOwner(kTRUE);
378 2 : fSPDNoisy->Clear();
379 2 : }
380 :
381 480 : if (fSPDNoisy->At(iMod) != 0)
382 0 : delete (AliITSCalibration*) fSPDNoisy->At(iMod);
383 480 : fSPDNoisy->AddAt(cal,iMod);
384 480 : }
385 : //_______________________________________________________________________
386 : void AliITSDetTypeSim::SetSPDSparseDeadModel(Int_t iMod, AliITSCalibration *cal){
387 : //Set sparse dead pixel info for the SPD module iMod
388 0 : if (fSPDSparseDead==0) {
389 0 : fSPDSparseDead = new TObjArray(fgkDefaultNModulesSPD);
390 0 : fSPDSparseDead->SetOwner(kTRUE);
391 0 : fSPDSparseDead->Clear();
392 0 : }
393 :
394 0 : if (fSPDNoisy->At(iMod) != 0)
395 0 : delete (AliITSCalibration*) fSPDNoisy->At(iMod);
396 0 : fSPDNoisy->AddAt(cal,iMod);
397 0 : }
398 : //______________________________________________________________________
399 : void AliITSDetTypeSim::ResetCalibrationArray(){
400 : //resets response array
401 0 : if(fCalibration && fRunNumber<0){ // if fRunNumber<0 fCalibration is owner
402 : /*
403 : AliITSresponse* rspd = ((AliITSCalibration*)fCalibration->At(
404 : GetITSgeom()->GetStartSPD()))->GetResponse();
405 : AliITSresponse* rssd = ((AliITSCalibration*)fCalibration->At(
406 : GetITSgeom()->GetStartSSD()))->GetResponse();
407 : if(rspd) delete rspd;
408 : if(rssd) delete rssd;
409 : */
410 0 : fCalibration->Clear();
411 0 : }else if (fCalibration && fRunNumber>=0){
412 0 : fCalibration->Clear();
413 0 : }
414 0 : }
415 : //______________________________________________________________________
416 : void AliITSDetTypeSim::ResetSegmentation(){
417 : //Resets segmentation array
418 15 : if(fSegmentation) fSegmentation->Clear();
419 5 : }
420 : //_______________________________________________________________________
421 : AliITSCalibration* AliITSDetTypeSim::GetCalibrationModel(Int_t iMod) const {
422 : //Get response model for module number iMod
423 :
424 41552 : if(fCalibration==0) {
425 0 : AliError("fCalibration is 0!");
426 0 : return 0;
427 : }
428 20776 : if(iMod<fgkDefaultNModulesSPD+fgkDefaultNModulesSDD){
429 400 : return (AliITSCalibration*)fCalibration->At(iMod);
430 : }else{
431 20376 : Int_t i=iMod-(fgkDefaultNModulesSPD+fgkDefaultNModulesSDD);
432 20376 : fSSDCalibration->SetModule(i);
433 20376 : return (AliITSCalibration*)fSSDCalibration;
434 : }
435 :
436 20776 : }
437 : //_______________________________________________________________________
438 : AliITSCalibration* AliITSDetTypeSim::GetSPDNoisyModel(Int_t iMod) const {
439 : //Get SPD noisy calib for module iMod
440 0 : if(fSPDNoisy==0) {
441 0 : AliWarning("fSPDNoisy is 0!");
442 0 : return 0;
443 : }
444 0 : return (AliITSCalibration*)fSPDNoisy->At(iMod);
445 0 : }
446 : //_______________________________________________________________________
447 : void AliITSDetTypeSim::SetDefaults(){
448 : //Set defaults for segmentation and response
449 :
450 10 : if(GetITSgeom()==0){
451 0 : Warning("SetDefaults","GetITSgeom() is 0!");
452 0 : return;
453 : } // end if
454 5 : if (fCalibration==0) {
455 2 : CreateCalibrationArray();
456 2 : } // end if
457 :
458 5 : ResetSegmentation();
459 5 : if(!GetCalibration()){AliFatal("Exit"); exit(0);}
460 :
461 5 : SetDigitClassName(0,"AliITSdigitSPD");
462 5 : SetDigitClassName(1,"AliITSdigitSDD");
463 5 : SetDigitClassName(2,"AliITSdigitSSD");
464 :
465 40 : for(Int_t idet=0;idet<fgkNdettypes;idet++){
466 30 : if(!GetSegmentationModel(idet)) SetDefaultSegmentation(idet);
467 : }
468 5 : }
469 : //______________________________________________________________________
470 : Bool_t AliITSDetTypeSim::GetCalibration() {
471 : // Get Default calibration if a storage is not defined.
472 :
473 10 : if(!fFirstcall){
474 3 : AliITSCalibration* cal = GetCalibrationModel(0);
475 6 : if(cal)return kTRUE;
476 0 : }
477 : else {
478 2 : fFirstcall = kFALSE;
479 : }
480 :
481 2 : SetRunNumber((Int_t)AliCDBManager::Instance()->GetRun());
482 2 : Int_t run=GetRunNumber();
483 :
484 2 : Bool_t origCacheStatus = AliCDBManager::Instance()->GetCacheFlag();
485 : Bool_t isCacheActive = kTRUE;
486 2 : if(GetRunNumber()<0){
487 : isCacheActive=kFALSE;
488 0 : fCalibration->SetOwner(kTRUE);
489 0 : }
490 : else{
491 2 : fCalibration->SetOwner(kFALSE);
492 : }
493 :
494 2 : AliCDBManager::Instance()->SetCacheFlag(isCacheActive);
495 :
496 4 : AliCDBEntry *deadSPD = AliCDBManager::Instance()->Get("ITS/Calib/SPDDead", run);
497 4 : AliCDBEntry *noisySPD = AliCDBManager::Instance()->Get("ITS/Calib/SPDNoisy", run);
498 4 : AliCDBEntry *foEffSPD = AliCDBManager::Instance()->Get("ITS/Calib/SPDFOEfficiency", run);
499 4 : AliCDBEntry *foNoiSPD = AliCDBManager::Instance()->Get("ITS/Calib/SPDFONoise", run);
500 4 : AliCDBEntry *entrySDD = AliCDBManager::Instance()->Get("ITS/Calib/CalibSDD", run);
501 4 : AliCDBEntry *entry2SDD = AliCDBManager::Instance()->Get("ITS/Calib/RespSDD");
502 4 : AliCDBEntry *drSpSDD = AliCDBManager::Instance()->Get("ITS/Calib/DriftSpeedSDD",run);
503 4 : AliCDBEntry *ddlMapSDD = AliCDBManager::Instance()->Get("ITS/Calib/DDLMapSDD",run);
504 : //AliCDBEntry *mapASDD = AliCDBManager::Instance()->Get("ITS/Calib/MapsAnodeSDD",run);
505 4 : AliCDBEntry *mapTSDD = AliCDBManager::Instance()->Get("ITS/Calib/MapsTimeSDD",run);
506 : // AliCDBEntry *entrySSD = AliCDBManager::Instance()->Get("ITS/Calib/CalibSSD", run);
507 4 : AliCDBEntry *entryNoiseSSD = AliCDBManager::Instance()->Get("ITS/Calib/NoiseSSD");
508 4 : AliCDBEntry *entryGainSSD = AliCDBManager::Instance()->Get("ITS/Calib/GainSSD");
509 4 : AliCDBEntry *entryBadChannelsSSD = AliCDBManager::Instance()->Get("ITS/Calib/BadChannelsSSD");
510 :
511 18 : if(!deadSPD || !noisySPD || !foEffSPD || !foNoiSPD
512 10 : || !entrySDD || !entry2SDD || !entryNoiseSSD || !entryGainSSD || !entryBadChannelsSSD
513 6 : || !drSpSDD || !ddlMapSDD || !mapTSDD){
514 0 : AliFatal("Calibration object retrieval failed! ");
515 0 : return kFALSE;
516 : }
517 :
518 :
519 2 : TObjArray *calDeadSPD = (TObjArray*) deadSPD->GetObject();
520 2 : if (!isCacheActive) deadSPD->SetObject(NULL);
521 2 : deadSPD->SetOwner(kTRUE);
522 :
523 2 : TObjArray *calNoisySPD = (TObjArray*) noisySPD->GetObject();
524 2 : if (!isCacheActive) noisySPD->SetObject(NULL);
525 2 : noisySPD->SetOwner(kTRUE);
526 :
527 2 : AliITSFOEfficiencySPD *calFoEffSPD = (AliITSFOEfficiencySPD*) foEffSPD->GetObject();
528 2 : if (!isCacheActive) foEffSPD->SetObject(NULL);
529 2 : foEffSPD->SetOwner(kTRUE);
530 :
531 2 : AliITSFONoiseSPD *calFoNoiSPD = (AliITSFONoiseSPD*) foNoiSPD->GetObject();
532 2 : if (!isCacheActive) foNoiSPD->SetObject(NULL);
533 2 : foNoiSPD->SetOwner(kTRUE);
534 :
535 2 : TObjArray *calSDD = (TObjArray *)entrySDD->GetObject();
536 2 : if(!isCacheActive)entrySDD->SetObject(NULL);
537 2 : entrySDD->SetOwner(kTRUE);
538 :
539 2 : AliITSresponseSDD *pSDD = (AliITSresponseSDD*)entry2SDD->GetObject();
540 2 : if(!isCacheActive)entry2SDD->SetObject(NULL);
541 2 : entry2SDD->SetOwner(kTRUE);
542 :
543 2 : TObjArray *drSp = (TObjArray *)drSpSDD->GetObject();
544 2 : if(!isCacheActive)drSpSDD->SetObject(NULL);
545 2 : drSpSDD->SetOwner(kTRUE);
546 :
547 2 : AliITSDDLModuleMapSDD *ddlsdd=(AliITSDDLModuleMapSDD*)ddlMapSDD->GetObject();
548 2 : if(!isCacheActive)ddlMapSDD->SetObject(NULL);
549 2 : ddlMapSDD->SetOwner(kTRUE);
550 :
551 : // TObjArray *mapAn = (TObjArray *)mapASDD->GetObject();
552 : // if(!isCacheActive)mapASDD->SetObject(NULL);
553 : // mapASDD->SetOwner(kTRUE);
554 :
555 2 : TObjArray *mapT = (TObjArray *)mapTSDD->GetObject();
556 2 : if(!isCacheActive)mapTSDD->SetObject(NULL);
557 2 : mapTSDD->SetOwner(kTRUE);
558 :
559 : /*
560 : TObjArray *calSSD = (TObjArray *)entrySSD->GetObject();
561 : if(!isCacheActive)entrySSD->SetObject(NULL);
562 : entrySSD->SetOwner(kTRUE);
563 : */
564 :
565 2 : TObject *emptyssd = 0; TString ssdobjectname;
566 : AliITSNoiseSSDv2 *noiseSSD = NULL;
567 2 : emptyssd = (TObject *)entryNoiseSSD->GetObject();
568 4 : ssdobjectname = emptyssd->GetName();
569 4 : if(ssdobjectname=="TObjArray") {
570 0 : noiseSSD = new AliITSNoiseSSDv2();
571 0 : TObjArray *noiseSSDOld = (TObjArray *)entryNoiseSSD->GetObject();
572 0 : ReadOldSSDNoise(noiseSSDOld, noiseSSD);
573 0 : }
574 4 : else if(ssdobjectname=="AliITSNoiseSSDv2")
575 2 : noiseSSD = (AliITSNoiseSSDv2 *)entryNoiseSSD->GetObject();
576 2 : if(!isCacheActive)entryNoiseSSD->SetObject(NULL);
577 2 : entryNoiseSSD->SetOwner(kTRUE);
578 :
579 : AliITSGainSSDv2 *gainSSD = NULL;
580 2 : emptyssd = (TObject *)entryGainSSD->GetObject();
581 4 : ssdobjectname = emptyssd->GetName();
582 4 : if(ssdobjectname=="Gain") {
583 0 : TObjArray *gainSSDOld = (TObjArray *)entryGainSSD->GetObject();
584 0 : gainSSD = new AliITSGainSSDv2();
585 0 : ReadOldSSDGain(gainSSDOld, gainSSD);
586 0 : }
587 4 : else if(ssdobjectname=="AliITSGainSSDv2")
588 2 : gainSSD = (AliITSGainSSDv2 *)entryGainSSD->GetObject();
589 2 : if(!isCacheActive)entryGainSSD->SetObject(NULL);
590 2 : entryGainSSD->SetOwner(kTRUE);
591 :
592 : AliITSBadChannelsSSDv2 *badChannelsSSD = NULL;
593 2 : emptyssd = (TObject *)entryBadChannelsSSD->GetObject();
594 4 : ssdobjectname = emptyssd->GetName();
595 4 : if(ssdobjectname=="TObjArray") {
596 0 : TObjArray *badChannelsSSDOld = (TObjArray *)entryBadChannelsSSD->GetObject();
597 0 : badChannelsSSD = new AliITSBadChannelsSSDv2();
598 0 : ReadOldSSDBadChannels(badChannelsSSDOld, badChannelsSSD);
599 0 : }
600 4 : else if(ssdobjectname=="AliITSBadChannelsSSDv2")
601 2 : badChannelsSSD = (AliITSBadChannelsSSDv2*)entryBadChannelsSSD->GetObject();
602 2 : if(!isCacheActive)entryBadChannelsSSD->SetObject(NULL);
603 2 : entryBadChannelsSSD->SetOwner(kTRUE);
604 :
605 : /*AliITSNoiseSSDv2 *noiseSSD = (AliITSNoiseSSDv2 *)entryNoiseSSD->GetObject();
606 : if(!isCacheActive)entryNoiseSSD->SetObject(NULL);
607 : entryNoiseSSD->SetOwner(kTRUE);
608 :
609 : AliITSGainSSDv2 *gainSSD = (AliITSGainSSDv2 *)entryGainSSD->GetObject();
610 : if(!isCacheActive)entryGainSSD->SetObject(NULL);
611 : entryGainSSD->SetOwner(kTRUE);
612 :
613 : AliITSBadChannelsSSDv2 *badchannelsSSD =
614 : (AliITSBadChannelsSSDv2 *)entryBadChannelsSSD->GetObject();
615 : if(!isCacheActive)entryBadChannelsSSD->SetObject(NULL);
616 : entryBadChannelsSSD->SetOwner(kTRUE);*/
617 :
618 : // DB entries are deleted. In this way metadeta objects are deleted as well
619 2 : if(!isCacheActive){
620 0 : delete deadSPD;
621 0 : delete noisySPD;
622 0 : delete foEffSPD;
623 0 : delete foNoiSPD;
624 0 : delete entrySDD;
625 0 : delete entry2SDD;
626 0 : delete entryNoiseSSD;
627 0 : delete entryGainSSD;
628 0 : delete entryBadChannelsSSD;
629 : // delete mapASDD;
630 0 : delete mapTSDD;
631 0 : delete drSpSDD;
632 0 : delete ddlMapSDD;
633 : }
634 :
635 4 : AliCDBManager::Instance()->SetCacheFlag(origCacheStatus);
636 :
637 18 : if ((!calDeadSPD) || (!calNoisySPD) || (!calFoEffSPD) || (!calFoNoiSPD)
638 8 : || (!calSDD) || (!pSDD)|| (!drSp) || (!ddlsdd)
639 8 : || (!mapT) || (!noiseSSD)|| (!gainSSD)|| (!badChannelsSSD)) {
640 0 : AliWarning("Can not get calibration from calibration database !");
641 0 : return kFALSE;
642 : }
643 :
644 :
645 2 : Int_t nmods0 = calDeadSPD->GetEntries();
646 2 : Int_t nmods1 = calSDD->GetEntries();
647 :
648 10 : AliDebug(1,Form("%i SPD, %i SDD and %i SSD in calibration database",
649 : nmods0,nmods1,fgkDefaultNModulesSSD));
650 : AliITSCalibration* cal;
651 964 : for (Int_t i=0; i<nmods0; i++) {
652 960 : cal = (AliITSCalibration*) calDeadSPD->At(i);
653 480 : SetCalibrationModel(i, cal);
654 960 : cal = (AliITSCalibration*) calNoisySPD->At(i);
655 480 : SetSPDNoisyModel(i, cal);
656 : }
657 :
658 2 : fFOGenerator.SetEfficiency(calFoEffSPD); // this cal object is used only by the generator
659 2 : fFOGenerator.SetNoise(calFoNoiSPD); // this cal object is used only by the generator
660 :
661 2 : fDDLMapSDD->SetDDLMap(ddlsdd);
662 2 : fRespSDD=pSDD;
663 : Float_t avegain=0.;
664 : Float_t nGdAnodes=0;
665 : Bool_t oldMapFormat=kFALSE;
666 2 : TObject* objmap=(TObject*)mapT->At(0);
667 4 : TString cname(objmap->ClassName());
668 4 : if(cname.CompareTo("AliITSMapSDD")==0){
669 : oldMapFormat=kTRUE;
670 0 : AliInfo("SDD Maps converted to new format");
671 : }
672 :
673 1044 : for (Int_t i=0; i<fgkDefaultNModulesSDD; i++) {
674 520 : Int_t iddl,icarlos;
675 520 : Int_t iMod = i + fgkDefaultNModulesSPD;
676 520 : fDDLMapSDD->FindInDDLMap(iMod,iddl,icarlos);
677 520 : if(iddl<0){
678 0 : AliITSCalibrationSDD* calsdddead=new AliITSCalibrationSDD();
679 0 : calsdddead->SetBad();
680 0 : AliITSDriftSpeedSDD* driftspdef = new AliITSDriftSpeedSDD();
681 0 : AliITSDriftSpeedArraySDD* arrdrsp=new AliITSDriftSpeedArraySDD(1);
682 0 : arrdrsp->AddDriftSpeed(driftspdef);
683 0 : calsdddead->SetDriftSpeed(0,arrdrsp);
684 0 : calsdddead->SetDriftSpeed(1,arrdrsp);
685 0 : SetCalibrationModel(iMod, calsdddead);
686 0 : AliWarning(Form("SDD module %d not present in DDL map: set it as dead",iMod));
687 0 : }else{
688 1040 : cal = (AliITSCalibration*) calSDD->At(i);
689 533520 : for(Int_t iAnode=0;iAnode< ((AliITSCalibrationSDD*)cal)->NOfAnodes(); iAnode++){
690 532480 : if(((AliITSCalibrationSDD*)cal)->IsBadChannel(iAnode)) continue;
691 262280 : avegain+= ((AliITSCalibrationSDD*)cal)->GetChannelGain(iAnode);
692 262280 : nGdAnodes++;
693 262280 : }
694 520 : Int_t i0=2*i;
695 520 : Int_t i1=1+2*i;
696 1040 : AliITSDriftSpeedArraySDD* arr0 = (AliITSDriftSpeedArraySDD*) drSp->At(i0);
697 1040 : AliITSDriftSpeedArraySDD* arr1 = (AliITSDriftSpeedArraySDD*) drSp->At(i1);
698 :
699 : AliITSCorrMapSDD* mt0 = 0;
700 : AliITSCorrMapSDD* mt1 = 0;
701 520 : if(oldMapFormat){
702 0 : AliITSMapSDD* oldmap0=(AliITSMapSDD*)mapT->At(i0);
703 0 : AliITSMapSDD* oldmap1=(AliITSMapSDD*)mapT->At(i1);
704 0 : mt0=oldmap0->ConvertToNewFormat();
705 0 : mt1=oldmap1->ConvertToNewFormat();
706 0 : }else{
707 1040 : mt0=(AliITSCorrMapSDD*)mapT->At(i0);
708 1040 : mt1=(AliITSCorrMapSDD*)mapT->At(i1);
709 : }
710 520 : cal->SetDriftSpeed(0,arr0);
711 520 : cal->SetDriftSpeed(1,arr1);
712 520 : cal->SetMapT(0,mt0);
713 520 : cal->SetMapT(1,mt1);
714 520 : SetCalibrationModel(iMod, cal);
715 : }
716 520 : }
717 4 : if(nGdAnodes) fAveGainSDD=avegain/nGdAnodes;
718 10 : AliDebug(3,Form("SDD average gain=%f\n",fAveGainSDD));
719 2 : fSSDCalibration->SetNoise(noiseSSD);
720 2 : fSSDCalibration->SetGain(gainSSD);
721 2 : fSSDCalibration->SetBadChannels(badChannelsSSD);
722 : //fSSDCalibration->FillBadChipMap();
723 :
724 :
725 :
726 : return kTRUE;
727 9 : }
728 : //_______________________________________________________________________
729 : void AliITSDetTypeSim::SetDefaultSimulation(){
730 : //Set default simulation for detector type
731 :
732 2 : if(GetITSgeom()==0){
733 0 : Warning("SetDefaultSimulation","GetITSgeom() is 0!");
734 0 : return;
735 : }
736 1 : if(fCalibration==0){
737 0 : Warning("SetDefaultSimulation","fCalibration is 0!");
738 0 : return;
739 : }
740 1 : if(fSegmentation==0){
741 0 : Warning("SetDefaultSimulation","fSegmentation is 0!");
742 0 : for(Int_t i=0;i<fgkNdettypes;i++) SetDefaultSegmentation(i);
743 11 : }else for(Int_t i=0;i<fgkNdettypes;i++) if(!GetSegmentationModel(i)){
744 0 : Warning("SetDefaultSimulation",
745 : "Segmentation not defined for det %d - Default taken\n!",i);
746 0 : SetDefaultSegmentation(i);
747 0 : }
748 : AliITSsimulation* sim;
749 :
750 8 : for(Int_t idet=0;idet<fgkNdettypes;idet++){
751 : //SPD
752 3 : if(idet==0){
753 1 : sim = GetSimulationModel(idet);
754 1 : if(!sim){
755 2 : sim = new AliITSsimulationSPD(this);
756 1 : SetSimulationModel(idet,sim);
757 1 : }
758 : }
759 : //SDD
760 3 : if(idet==1){
761 1 : sim = GetSimulationModel(idet);
762 1 : if(!sim){
763 2 : sim = new AliITSsimulationSDD(this);
764 1 : SetSimulationModel(idet,sim);
765 1 : }
766 : }
767 : //SSD
768 3 : if(idet==2){
769 1 : sim = GetSimulationModel(idet);
770 1 : if(!sim){
771 2 : sim = new AliITSsimulationSSD(this);
772 1 : SetSimulationModel(idet,sim);
773 1 : }
774 : }
775 :
776 : }
777 2 : }
778 : //___________________________________________________________________
779 : void AliITSDetTypeSim::SetTreeAddressS(TTree* treeS, const Char_t* name){
780 : // Set branch address for the ITS summable digits Trees.
781 :
782 374 : if(!treeS){
783 : return;
784 : }
785 : TBranch *branch;
786 0 : branch = treeS->GetBranch(name);
787 0 : TClonesArray *sdigi = &fSDigits;
788 0 : if (branch) branch->SetAddress(&sdigi);
789 :
790 187 : }
791 : //___________________________________________________________________
792 : void AliITSDetTypeSim::SetTreeAddressD(TTree* treeD, const Char_t* name){
793 : // Set branch address for the digit Trees.
794 :
795 382 : const char *det[3] = {"SPD","SDD","SSD"};
796 : TBranch *branch;
797 :
798 191 : TString branchname;
799 :
800 191 : if(!treeD){
801 147 : return;
802 : }
803 44 : if(!fDigits){
804 0 : fDigits = new TObjArray(fgkNdettypes);
805 0 : }
806 352 : for(Int_t i=0;i<fgkNdettypes;i++){
807 132 : const Char_t* digclass = GetDigitClassName(i);
808 132 : if(digclass==0x0){
809 12 : if(i==0) SetDigitClassName(i,"AliITSdigitSPD");
810 12 : if(i==1) SetDigitClassName(i,"AliITSdigitSDD");
811 12 : if(i==2) SetDigitClassName(i,"AliITSdigitSSD");
812 9 : digclass = GetDigitClassName(i);
813 9 : }
814 132 : TString classn = digclass;
815 264 : if(!(fDigits->At(i))){
816 60 : fDigits->AddAt(new TClonesArray(classn.Data(),1000),i);
817 : }else{
818 117 : ResetDigits(i);
819 : }
820 :
821 132 : if(fgkNdettypes==3) branchname.Form("%sDigits%s",name,det[i]);
822 : else branchname.Form("%sDigits%d",name,i+1);
823 264 : branch = treeD->GetBranch(branchname.Data());
824 390 : if(branch) branch->SetAddress(&((*fDigits)[i]));
825 132 : }
826 235 : }
827 : //___________________________________________________________________
828 : void AliITSDetTypeSim::ResetDigits(){
829 : // Reset number of digits and the digits array for the ITS detector.
830 :
831 17584 : if(!fDigits){
832 0 : Error("ResetDigits","fDigits is null!");
833 0 : return;
834 : }
835 70336 : for(Int_t i=0;i<fgkNdettypes;i++){
836 26376 : ResetDigits(i);
837 : }
838 8792 : }
839 : //___________________________________________________________________
840 : void AliITSDetTypeSim::ResetDigits(Int_t branch){
841 : // Reset number of digits and the digits array for this branch.
842 :
843 53010 : if(fDigits->At(branch)){
844 26505 : ((TClonesArray*)fDigits->At(branch))->Clear();
845 26505 : }
846 53010 : if(fNDigits) fNDigits[branch]=0;
847 :
848 26505 : }
849 :
850 :
851 :
852 : //_______________________________________________________________________
853 : void AliITSDetTypeSim::SDigitsToDigits(Option_t* opt, Char_t* name){
854 : // Standard Summable digits to Digits function.
855 0 : if(!GetITSgeom()){
856 0 : Warning("SDigitsToDigits","GetITSgeom() is null!!");
857 0 : return;
858 : }
859 :
860 0 : const char *all = strstr(opt,"All");
861 0 : const char *det[3] = {strstr(opt,"SPD"),strstr(opt,"SDD"),
862 0 : strstr(opt,"SSD")};
863 0 : if(!all && !det[0] && !det[1] && !det[2] ) all = "All";
864 :
865 : static Bool_t setDef = kTRUE;
866 0 : if(setDef) SetDefaultSimulation();
867 0 : setDef = kFALSE;
868 :
869 : AliITSsimulation *sim =0;
870 0 : TTree* trees = fLoader->TreeS();
871 0 : if( !(trees && GetSDigits()) ){
872 0 : Error("SDigits2Digits","Error: No trees or SDigits. Returning.");
873 0 : return;
874 : }
875 :
876 0 : TBranch* brchSDigits = trees->GetBranch(name);
877 :
878 : Int_t id;
879 0 : for(Int_t module=0;module<GetITSgeom()->GetIndexMax();module++){
880 0 : id = GetITSgeom()->GetModuleType(module);
881 0 : if (!all && !det[id]) continue;
882 0 : sim = (AliITSsimulation*)GetSimulationModel(id);
883 0 : if(!sim){
884 0 : Error("SDigit2Digits","The simulation class was not "
885 : "instanciated for module %d type %s!",module,
886 0 : GetITSgeom()->GetModuleTypeName(module));
887 0 : exit(1);
888 : }
889 0 : sim->InitSimulationModule(module,gAlice->GetEvNumber());
890 :
891 0 : fSDigits.Clear();
892 0 : brchSDigits->GetEvent(module);
893 0 : sim->AddSDigitsToModule(&fSDigits,0);
894 0 : sim->FinishSDigitiseModule();
895 0 : fLoader->TreeD()->Fill();
896 0 : ResetDigits();
897 0 : }
898 :
899 0 : WriteFOSignals();
900 0 : fLoader->TreeD()->GetEntries();
901 0 : fLoader->TreeD()->AutoSave();
902 0 : fLoader->TreeD()->Reset();
903 0 : }
904 : //_________________________________________________________
905 : void AliITSDetTypeSim::AddSumDigit(AliITSpListItem &sdig){
906 : //Adds the module full of summable digits to the summable digits tree.
907 :
908 0 : new(fSDigits[fNSDigits++]) AliITSpListItem(sdig);
909 0 : }
910 : //__________________________________________________________
911 : void AliITSDetTypeSim::AddSimDigit(Int_t branch, const AliITSdigit* d){
912 : // Add a simulated digit.
913 :
914 296 : TClonesArray &ldigits = *((TClonesArray*)fDigits->At(branch));
915 148 : switch(branch){
916 : case 0:
917 148 : new(ldigits[fNDigits[branch]++]) AliITSdigitSPD(*((AliITSdigitSPD*)d));
918 : break;
919 : case 1:
920 0 : new(ldigits[fNDigits[branch]++]) AliITSdigitSDD(*((AliITSdigitSDD*)d));
921 : break;
922 : case 2:
923 0 : new(ldigits[fNDigits[branch]++]) AliITSdigitSSD(*((AliITSdigitSSD*)d));
924 : break;
925 : }
926 148 : }
927 : //______________________________________________________________________
928 : void AliITSDetTypeSim::AddSimDigit(Int_t branch,Float_t phys,Int_t *digits,
929 : Int_t *tracks,Int_t *hits,Float_t *charges,
930 : Int_t sigexpanded){
931 : // Add a simulated digit to the list.
932 :
933 26216 : TClonesArray &ldigits = *((TClonesArray*)fDigits->At(branch));
934 13108 : switch(branch){
935 : case 0:
936 0 : new(ldigits[fNDigits[branch]++]) AliITSdigitSPD(digits,tracks,hits);
937 : break;
938 : case 1:
939 643 : new(ldigits[fNDigits[branch]++]) AliITSdigitSDD(phys,digits,tracks,
940 : hits,charges,sigexpanded);
941 : break;
942 : case 2:
943 12465 : new(ldigits[fNDigits[branch]++]) AliITSdigitSSD(digits,tracks,hits);
944 : break;
945 : }
946 13108 : }
947 : //______________________________________________________________________
948 : void AliITSDetTypeSim::ReadOldSSDNoise(const TObjArray *array,
949 : AliITSNoiseSSDv2 *noiseSSD) {
950 : //Reads the old SSD calibration object and converts it to the new format
951 : const Int_t fgkSSDSTRIPSPERMODULE = 1536;
952 : const Int_t fgkSSDPSIDESTRIPSPERMODULE = 768;
953 :
954 0 : Int_t gNMod = array->GetEntries();
955 0 : cout<<"Converting old calibration object for noise..."<<endl;
956 :
957 : //NOISE
958 : Double_t noise = 0.0;
959 0 : for (Int_t iModule = 0; iModule < gNMod; iModule++) {
960 0 : AliITSNoiseSSD *noiseModule = (AliITSNoiseSSD*) (array->At(iModule));
961 0 : for(Int_t iStrip = 0; iStrip < fgkSSDSTRIPSPERMODULE; iStrip++) {
962 0 : noise = (iStrip < fgkSSDPSIDESTRIPSPERMODULE) ? noiseModule->GetNoiseP(iStrip) : noiseModule->GetNoiseN(1535 - iStrip);
963 0 : if(iStrip < fgkSSDPSIDESTRIPSPERMODULE)
964 0 : noiseSSD->AddNoiseP(iModule,iStrip,noise);
965 0 : if(iStrip >= fgkSSDPSIDESTRIPSPERMODULE)
966 0 : noiseSSD->AddNoiseN(iModule,1535 - iStrip,noise);
967 : }//loop over strips
968 : }//loop over modules
969 0 : }
970 :
971 : //______________________________________________________________________
972 : void AliITSDetTypeSim::ReadOldSSDBadChannels(const TObjArray *array,
973 : AliITSBadChannelsSSDv2 *badChannelsSSD) {
974 : //Reads the old SSD calibration object and converts it to the new format
975 0 : Int_t nMod = array->GetEntries();
976 0 : cout<<"Converting old calibration object for bad channels..."<<endl;
977 0 : for (Int_t iModule = 0; iModule < nMod; iModule++) {
978 : //for (Int_t iModule = 0; iModule < 1; iModule++) {
979 0 : AliITSBadChannelsSSD *bad = (AliITSBadChannelsSSD*) (array->At(iModule));
980 0 : TArrayI arrayPSide = bad->GetBadPChannelsList();
981 0 : for(Int_t iPCounter = 0; iPCounter < arrayPSide.GetSize(); iPCounter++)
982 0 : badChannelsSSD->AddBadChannelP(iModule,
983 : iPCounter,
984 0 : (Char_t)arrayPSide.At(iPCounter));
985 :
986 0 : TArrayI arrayNSide = bad->GetBadNChannelsList();
987 0 : for(Int_t iNCounter = 0; iNCounter < arrayNSide.GetSize(); iNCounter++)
988 0 : badChannelsSSD->AddBadChannelN(iModule,
989 : iNCounter,
990 0 : (Char_t)arrayNSide.At(iNCounter));
991 :
992 0 : }//loop over modules
993 0 : }
994 :
995 : //______________________________________________________________________
996 : void AliITSDetTypeSim::ReadOldSSDGain(const TObjArray *array,
997 : AliITSGainSSDv2 *gainSSD) {
998 : //Reads the old SSD calibration object and converts it to the new format
999 :
1000 0 : Int_t nMod = array->GetEntries();
1001 0 : cout<<"Converting old calibration object for gain..."<<endl;
1002 :
1003 : //GAIN
1004 0 : for (Int_t iModule = 0; iModule < nMod; iModule++) {
1005 0 : AliITSGainSSD *gainModule = (AliITSGainSSD*) (array->At(iModule));
1006 0 : TArrayF arrayPSide = gainModule->GetGainP();
1007 0 : for(Int_t iPCounter = 0; iPCounter < arrayPSide.GetSize(); iPCounter++)
1008 0 : gainSSD->AddGainP(iModule,
1009 : iPCounter,
1010 0 : arrayPSide.At(iPCounter));
1011 0 : TArrayF arrayNSide = gainModule->GetGainN();
1012 0 : for(Int_t iNCounter = 0; iNCounter < arrayNSide.GetSize(); iNCounter++)
1013 0 : gainSSD->AddGainN(iModule,
1014 : iNCounter,
1015 0 : arrayNSide.At(iNCounter));
1016 0 : }//loop over modules
1017 0 : }
1018 : //______________________________________________________________________
1019 : void AliITSDetTypeSim::ProcessSPDDigitForFastOr(UInt_t module, UInt_t colM, UInt_t rowM) {
1020 : // Processes wether a single fired pixel will give rise to a fast-or signal
1021 296 : fFOGenerator.ProcessPixelHitM(module,colM,rowM);
1022 148 : }
1023 : //_______________________________________________________________________
1024 : AliITSTriggerConditions* AliITSDetTypeSim::GetTriggerConditions() {
1025 : // Get Pixel Trigger Conditions (separate method since it is used only when simulating trigger)
1026 8 : if (fTriggerConditions==NULL) { // read from db
1027 1 : fRunNumber = ((Int_t)AliCDBManager::Instance()->GetRun());
1028 1 : Bool_t origCacheStatus = AliCDBManager::Instance()->GetCacheFlag();
1029 : Bool_t isCacheActive;
1030 1 : if (fRunNumber<0) isCacheActive=kFALSE;
1031 : else isCacheActive=kTRUE;
1032 1 : AliCDBManager::Instance()->SetCacheFlag(isCacheActive);
1033 2 : AliCDBEntry *pitCond = AliCDBManager::Instance()->Get("TRIGGER/SPD/PITConditions", fRunNumber);
1034 1 : if (!pitCond) {
1035 0 : AliError("Trigger conditions retrieval failed! ");
1036 0 : return NULL;
1037 : }
1038 1 : fTriggerConditions = (AliITSTriggerConditions*) pitCond->GetObject();
1039 1 : if (!isCacheActive) pitCond->SetObject(NULL);
1040 1 : pitCond->SetOwner(kTRUE);
1041 1 : if (!isCacheActive) {
1042 0 : delete pitCond;
1043 : }
1044 1 : AliCDBManager::Instance()->SetCacheFlag(origCacheStatus);
1045 1 : if (fTriggerConditions==NULL) {
1046 0 : AliWarning("fTriggerConditions is NULL!");
1047 0 : }
1048 1 : }
1049 4 : return fTriggerConditions;
1050 4 : }
1051 : //_______________________________________________________________________
1052 : void AliITSDetTypeSim::WriteFOSignals() {
1053 : // write fo signals to event
1054 :
1055 8 : if (!fLoader) {
1056 0 : AliError("ITS loader is NULL.");
1057 0 : return;
1058 : }
1059 :
1060 4 : if(!fLoader->TreeD()){
1061 0 : AliError("No TreeD available");
1062 0 : return;
1063 : }
1064 4 : TTree *tree = fLoader->TreeD();
1065 8 : AliITSFOSignalsSPD *foSignals = new AliITSFOSignalsSPD(*GetFOSignals());
1066 4 : tree->GetUserInfo()->Add(foSignals);
1067 4 : fFOGenerator.ResetSignals();
1068 8 : }
1069 :
|