]> git.uio.no Git - u/mrichter/AliRoot.git/blame - ITS/AliITSDetTypeRec.cxx
Changes to the Improve method (J. Belikov) Savannah bug 76361
[u/mrichter/AliRoot.git] / ITS / AliITSDetTypeRec.cxx
CommitLineData
3b9df642 1/***************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
b17dae48 5 * Conributors are mentioned in the code where appropriate. *
3b9df642 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/*
140e5249 17 $Id$
3b9df642 18*/
19
7d62fb64 20////////////////////////////////////////////////////////////////////////
21// This class defines the "Standard" reconstruction for the ITS //
22// detector. //
23// //
24////////////////////////////////////////////////////////////////////////
25#include "TObjArray.h"
26#include "TTree.h"
27
8ba39da9 28#include "AliCDBManager.h"
8ba39da9 29#include "AliCDBEntry.h"
7d62fb64 30#include "AliITSClusterFinder.h"
7d62fb64 31#include "AliITSClusterFinderV2SPD.h"
32#include "AliITSClusterFinderV2SDD.h"
33#include "AliITSClusterFinderV2SSD.h"
3b9df642 34#include "AliITSDetTypeRec.h"
ef665f5e 35#include "AliITSDDLModuleMapSDD.h"
7d62fb64 36#include "AliITSRecPoint.h"
e5c65a6d 37#include "AliITSRecPointContainer.h"
fcf95fc7 38#include "AliITSCalibrationSDD.h"
54af1add 39#include "AliITSMapSDD.h"
fb4dfab9 40#include "AliITSCalibrationSSD.h"
88128115 41#include "AliITSNoiseSSDv2.h"
42#include "AliITSGainSSDv2.h"
43#include "AliITSBadChannelsSSDv2.h"
fb4dfab9 44#include "AliITSNoiseSSD.h"
45#include "AliITSGainSSD.h"
46#include "AliITSBadChannelsSSD.h"
dc5c67dc 47#include "AliITSresponseSDD.h"
7d62fb64 48#include "AliITSsegmentationSPD.h"
49#include "AliITSsegmentationSDD.h"
50#include "AliITSsegmentationSSD.h"
00a7cc50 51#include "AliLog.h"
ad7f2bfa 52#include "AliITSRawStreamSPD.h"
53#include "AliITSTriggerConditions.h"
54#include "AliITSFOSignalsSPD.h"
55#include "AliRunLoader.h"
56#include "AliDataLoader.h"
57#include "AliITSLoader.h"
7d62fb64 58
ef665f5e 59class AliITSDriftSpeedArraySDD;
54af1add 60class AliITSCorrMapSDD;
ef665f5e 61class AliITSRecoParam;
3b9df642 62
7d62fb64 63const Int_t AliITSDetTypeRec::fgkNdettypes = 3;
8ba39da9 64const Int_t AliITSDetTypeRec::fgkDefaultNModulesSPD = 240;
65const Int_t AliITSDetTypeRec::fgkDefaultNModulesSDD = 260;
66const Int_t AliITSDetTypeRec::fgkDefaultNModulesSSD = 1698;
67
3b9df642 68ClassImp(AliITSDetTypeRec)
69
7d62fb64 70//________________________________________________________________
e56160b8 71AliITSDetTypeRec::AliITSDetTypeRec(): TObject(),
72fNMod(0),
6cae184e 73fITSgeom(0),
e56160b8 74fReconstruction(0),
75fSegmentation(0),
76fCalibration(0),
ced4d9bc 77fSSDCalibration(0),
23197852 78fSPDDead(0),
ad7f2bfa 79fTriggerConditions(0),
e56160b8 80fDigits(0),
ad7f2bfa 81fFOSignals(0),
979b5a5f 82fDDLMapSDD(0),
253e68a0 83fRespSDD(0),
75065a60 84fAveGainSDD(0),
e56160b8 85fRecPoints(0),
86fNRecPoints(0),
62b93da7 87fFirstcall(kTRUE),
ff44c37c 88fLoadOnlySPDCalib(0),
89fFastOrFiredMap(1200){
8e50d897 90 // Standard Constructor
91 // Inputs:
92 // none.
93 // Outputs:
94 // none.
95 // Return:
96 //
7d62fb64 97
7d62fb64 98 fReconstruction = new TObjArray(fgkNdettypes);
7d62fb64 99 fDigits = new TObjArray(fgkNdettypes);
8e50d897 100 for(Int_t i=0; i<3; i++){
ef665f5e 101 fkDigClassName[i]=0;
8e50d897 102 }
ced4d9bc 103 fSSDCalibration=new AliITSCalibrationSSD();
8e50d897 104 fNMod = new Int_t [fgkNdettypes];
105 fNMod[0] = fgkDefaultNModulesSPD;
106 fNMod[1] = fgkDefaultNModulesSDD;
107 fNMod[2] = fgkDefaultNModulesSSD;
00a7cc50 108 fRecPoints = new TClonesArray("AliITSRecPoint",3000);
7d62fb64 109 fNRecPoints = 0;
7d62fb64 110
7d62fb64 111
7d62fb64 112}
7537d03c 113
7d62fb64 114//______________________________________________________________________
7537d03c 115AliITSDetTypeRec::AliITSDetTypeRec(const AliITSDetTypeRec & rec):TObject(rec),
116fNMod(rec.fNMod),
6cae184e 117fITSgeom(rec.fITSgeom),
7537d03c 118fReconstruction(rec.fReconstruction),
119fSegmentation(rec.fSegmentation),
120fCalibration(rec.fCalibration),
ced4d9bc 121fSSDCalibration(rec.fSSDCalibration),
23197852 122fSPDDead(rec.fSPDDead),
ad7f2bfa 123fTriggerConditions(rec.fTriggerConditions),
7537d03c 124fDigits(rec.fDigits),
ad7f2bfa 125fFOSignals(rec.fFOSignals),
979b5a5f 126fDDLMapSDD(rec.fDDLMapSDD),
253e68a0 127fRespSDD(rec.fRespSDD),
75065a60 128fAveGainSDD(rec.fAveGainSDD),
7537d03c 129fRecPoints(rec.fRecPoints),
130fNRecPoints(rec.fNRecPoints),
62b93da7 131fFirstcall(rec.fFirstcall),
ff44c37c 132fLoadOnlySPDCalib(rec.fLoadOnlySPDCalib),
133fFastOrFiredMap(rec.fFastOrFiredMap){
7d62fb64 134
e56160b8 135 // Copy constructor.
7537d03c 136
7d62fb64 137}
138//______________________________________________________________________
e56160b8 139AliITSDetTypeRec& AliITSDetTypeRec::operator=(const AliITSDetTypeRec& source){
7537d03c 140 // Assignment operator.
141 this->~AliITSDetTypeRec();
142 new(this) AliITSDetTypeRec(source);
143 return *this;
7d62fb64 144
e56160b8 145}
7537d03c 146
7d62fb64 147//_____________________________________________________________________
3b9df642 148AliITSDetTypeRec::~AliITSDetTypeRec(){
7d62fb64 149 //Destructor
6cae184e 150
fcf95fc7 151 if(fReconstruction){
152 fReconstruction->Delete();
153 delete fReconstruction;
154 fReconstruction = 0;
155 }
156 if(fSegmentation){
157 fSegmentation->Delete();
158 delete fSegmentation;
159 fSegmentation = 0;
160 }
6cae184e 161 if(fCalibration){
7032f6a2 162 if(!(AliCDBManager::Instance()->GetCacheFlag())) {
7032f6a2 163 fCalibration->Delete();
164 delete fCalibration;
165 fCalibration = 0;
253e68a0 166 if(fRespSDD) delete fRespSDD;
167 if(fDDLMapSDD) delete fDDLMapSDD;
168 }
fcf95fc7 169 }
964d8c19 170 if(fSSDCalibration){
171 if(!(AliCDBManager::Instance()->GetCacheFlag())) {
172 delete fSSDCalibration;
173 fSSDCalibration = NULL;
174 }
175 }
ced4d9bc 176 if(fSPDDead){
23197852 177 if(!(AliCDBManager::Instance()->GetCacheFlag())) {
178 fSPDDead->Delete();
179 delete fSPDDead;
180 fSPDDead = 0;
181 }
ad7f2bfa 182 }
183 if(fTriggerConditions){
184 if(!(AliCDBManager::Instance()->GetCacheFlag())) {
185 fTriggerConditions->Delete();
186 delete fTriggerConditions;
187 fTriggerConditions = 0;
188 }
189 }
7d62fb64 190 if(fDigits){
191 fDigits->Delete();
192 delete fDigits;
193 fDigits=0;
194 }
195 if(fRecPoints){
196 fRecPoints->Delete();
197 delete fRecPoints;
198 fRecPoints=0;
199 }
8e50d897 200 delete [] fNMod;
7d62fb64 201
6cae184e 202 if (fITSgeom) delete fITSgeom;
203
7d62fb64 204}
8e50d897 205
7d62fb64 206//___________________________________________________________________
207void AliITSDetTypeRec::SetReconstructionModel(Int_t dettype,AliITSClusterFinder *clf){
208
209 //Set reconstruction model for detector type
210
211 if(fReconstruction==0) fReconstruction = new TObjArray(fgkNdettypes);
212 if(fReconstruction->At(dettype)!=0) delete fReconstruction->At(dettype);
213 fReconstruction->AddAt(clf,dettype);
214}
215//______________________________________________________________________
04c81913 216AliITSClusterFinder* AliITSDetTypeRec::GetReconstructionModel(Int_t dettype) const{
7d62fb64 217
218 //Get reconstruction model for detector type
219 if(fReconstruction==0) {
220 Warning("GetReconstructionModel","fReconstruction is 0!");
221 return 0;
222 }
223 return (AliITSClusterFinder*)fReconstruction->At(dettype);
224}
225
226//______________________________________________________________________
227void AliITSDetTypeRec::SetSegmentationModel(Int_t dettype,AliITSsegmentation *seg){
228
229 //Set segmentation model for detector type
230
231 if(fSegmentation==0) fSegmentation = new TObjArray(fgkNdettypes);
232 if(fSegmentation->At(dettype)!=0) delete fSegmentation->At(dettype);
233 fSegmentation->AddAt(seg,dettype);
234
235}
236//______________________________________________________________________
04c81913 237AliITSsegmentation* AliITSDetTypeRec::GetSegmentationModel(Int_t dettype) const {
7d62fb64 238
239 //Get segmentation model for detector type
240
241 if(fSegmentation==0) {
242 Warning("GetSegmentationModel","fSegmentation is 0!");
243 return 0;
244 }
245 return (AliITSsegmentation*)fSegmentation->At(dettype);
246
247}
248//_______________________________________________________________________
fcf95fc7 249void AliITSDetTypeRec::SetCalibrationModel(Int_t iMod, AliITSCalibration *cal){
8ba39da9 250
251 //Set calibration (response) for the module iMod of type dettype
252 if (fCalibration==0) {
8e50d897 253 fCalibration = new TObjArray(GetITSgeom()->GetIndexMax());
8ba39da9 254 fCalibration->SetOwner(kTRUE);
255 fCalibration->Clear();
256 }
257
258 if (fCalibration->At(iMod) != 0)
fcf95fc7 259 delete (AliITSCalibration*) fCalibration->At(iMod);
8ba39da9 260 fCalibration->AddAt(cal,iMod);
7d62fb64 261
7d62fb64 262}
263//_______________________________________________________________________
23197852 264void AliITSDetTypeRec::SetSPDDeadModel(Int_t iMod, AliITSCalibration *cal){
265
266 //Set dead pixel info for the SPD module iMod
267 if (fSPDDead==0) {
268 fSPDDead = new TObjArray(fgkDefaultNModulesSPD);
269 fSPDDead->SetOwner(kTRUE);
270 fSPDDead->Clear();
271 }
272
273 if (fSPDDead->At(iMod) != 0)
274 delete (AliITSCalibration*) fSPDDead->At(iMod);
275 fSPDDead->AddAt(cal,iMod);
276}
277//_______________________________________________________________________
04c81913 278AliITSCalibration* AliITSDetTypeRec::GetCalibrationModel(Int_t iMod) const {
7d62fb64 279
8ba39da9 280 //Get calibration model for module type
7d62fb64 281
282 if(fCalibration==0) {
8ba39da9 283 Warning("GetalibrationModel","fCalibration is 0!");
7d62fb64 284 return 0;
285 }
8ba39da9 286
ced4d9bc 287 if(iMod<fgkDefaultNModulesSPD+fgkDefaultNModulesSDD){
288 return (AliITSCalibration*)fCalibration->At(iMod);
289 }else{
290 Int_t i=iMod-(fgkDefaultNModulesSPD+fgkDefaultNModulesSDD);
291 fSSDCalibration->SetModule(i);
292 return (AliITSCalibration*)fSSDCalibration;
293 }
294
7d62fb64 295}
23197852 296//_______________________________________________________________________
04c81913 297AliITSCalibration* AliITSDetTypeRec::GetSPDDeadModel(Int_t iMod) const {
23197852 298
299 //Get SPD dead for module iMod
300
301 if(fSPDDead==0) {
302 AliWarning("fSPDDead is 0!");
303 return 0;
304 }
23197852 305 return (AliITSCalibration*)fSPDDead->At(iMod);
306}
ad7f2bfa 307//_______________________________________________________________________
308AliITSTriggerConditions* AliITSDetTypeRec::GetTriggerConditions() const {
309 //Get Pixel Trigger Conditions
310 if (fTriggerConditions==0) {
311 AliWarning("fTriggerConditions is 0!");
312 }
313 return fTriggerConditions;
314}
7d62fb64 315//______________________________________________________________________
dc5c67dc 316void AliITSDetTypeRec::SetTreeAddressD(TTree* const treeD){
7d62fb64 317 // Set branch address for the tree of digits.
318
ad7f2bfa 319 const char *det[4] = {"SPD","SDD","SSD","ITS"};
320 TBranch *branch;
321 const Char_t* digclass;
322 Int_t i;
323 char branchname[30];
324
325 if(!treeD) return;
326 if (fDigits == 0x0) fDigits = new TObjArray(fgkNdettypes);
327 for (i=0; i<fgkNdettypes; i++) {
328 digclass = GetDigitClassName(i);
329 if(!(fDigits->At(i))) {
330 fDigits->AddAt(new TClonesArray(digclass,1000),i);
331 }
332 else{
333 ResetDigits(i);
7d62fb64 334 }
ad7f2bfa 335 if (fgkNdettypes==3) sprintf(branchname,"%sDigits%s",det[3],det[i]);
336 else sprintf(branchname,"%sDigits%d",det[3],i+1);
337 if (fDigits) {
338 branch = treeD->GetBranch(branchname);
339 if (branch) branch->SetAddress(&((*fDigits)[i]));
340 }
341 }
342
7d62fb64 343}
344
345//_______________________________________________________________________
dc5c67dc 346TBranch* AliITSDetTypeRec::MakeBranchInTree(TTree* const tree,
347 const char* name, const char *classname,
348 void* address,Int_t size,Int_t splitlevel)
7d62fb64 349{
350//
351// Makes branch in given tree and diverts them to a separate file
352//
353//
354//
355
356 if (tree == 0x0) {
357 Error("MakeBranchInTree","Making Branch %s Tree is NULL",name);
358 return 0x0;
359 }
360 TBranch *branch = tree->GetBranch(name);
361 if (branch) {
362 return branch;
363 }
364 if (classname){
365 branch = tree->Branch(name,classname,address,size,splitlevel);
366 }
367 else {
368 branch = tree->Bronch(name, "TClonesArray", address, size, splitlevel);
369 }
370
371 return branch;
372}
373
374//____________________________________________________________________
375void AliITSDetTypeRec::SetDefaults(){
376
377 //Set defaults for segmentation and response
378
8e50d897 379 if(!GetITSgeom()){
380 Warning("SetDefaults","null pointer to AliITSgeomGeom !");
7d62fb64 381 return;
382 }
383
384 AliITSsegmentation* seg;
8ba39da9 385 if(!GetCalibration()) {AliFatal("Exit");exit(0);}
7d62fb64 386
387 for(Int_t dettype=0;dettype<fgkNdettypes;dettype++){
388 if(dettype==0){
d24bc9d6 389 seg = new AliITSsegmentationSPD();
7d62fb64 390 SetSegmentationModel(dettype,seg);
3a7c3e6d 391 SetDigitClassName(dettype,"AliITSdigitSPD");
7d62fb64 392 }
d5eae813 393 if(dettype==1){
394 seg = new AliITSsegmentationSDD();
395 if(fLoadOnlySPDCalib==kFALSE){
62b93da7 396 AliITSCalibrationSDD* cal=(AliITSCalibrationSDD*)GetCalibrationModel(fgkDefaultNModulesSPD+1);
397 if(cal->IsAMAt20MHz()){
398 seg->SetPadSize(seg->Dpz(0),20.);
399 seg->SetNPads(seg->Npz()/2,128);
400 }
b27af87f 401 }
d5eae813 402 SetSegmentationModel(dettype,seg);
403 SetDigitClassName(dettype,"AliITSdigitSDD");
7d62fb64 404 }
405 if(dettype==2){
d24bc9d6 406 AliITSsegmentationSSD* seg2 = new AliITSsegmentationSSD();
7d62fb64 407 SetSegmentationModel(dettype,seg2);
7d62fb64 408 SetDigitClassName(dettype,"AliITSdigitSSD");
7d62fb64 409 }
7d62fb64 410 }
7d62fb64 411}
8ba39da9 412//______________________________________________________________________
413Bool_t AliITSDetTypeRec::GetCalibration() {
414 // Get Default calibration if a storage is not defined.
415
b17dae48 416 if(!fFirstcall){
417 AliITSCalibration* cal = GetCalibrationModel(0);
418 if(cal)return kTRUE;
62b93da7 419 }else {
b17dae48 420 fFirstcall = kFALSE;
421 }
06232459 422
6cae184e 423 // SetRunNumber((Int_t)AliCDBManager::Instance()->GetRun());
424 // Int_t run=GetRunNumber();
b17dae48 425
6cae184e 426 Bool_t cacheStatus = AliCDBManager::Instance()->GetCacheFlag();
b17dae48 427 if (fCalibration==0) {
428 fCalibration = new TObjArray(GetITSgeom()->GetIndexMax());
6cae184e 429 fCalibration->SetOwner(!cacheStatus);
b17dae48 430 fCalibration->Clear();
431 }
75065a60 432
433 Bool_t retCode=GetCalibrationSPD(cacheStatus);
434 if(retCode==kFALSE) return kFALSE;
435
436 if(fLoadOnlySPDCalib==kFALSE){
437 retCode=GetCalibrationSDD(cacheStatus);
438 if(retCode==kFALSE) return kFALSE;
439 retCode=GetCalibrationSSD(cacheStatus);
440 if(retCode==kFALSE) return kFALSE;
441 }
442
443 AliInfo(Form("%i SPD, %i SDD and %i SSD in calibration database",
444 fNMod[0], fNMod[1], fNMod[2]));
445 return kTRUE;
446}
447//______________________________________________________________________
448Bool_t AliITSDetTypeRec::GetCalibrationSPD(Bool_t cacheStatus) {
449 // Get SPD calibration objects from OCDB
8d37cc87 450 // dead pixel are not used for local reconstruction
75065a60 451
ad7f2bfa 452
453 AliCDBEntry *noisySPD = AliCDBManager::Instance()->Get("ITS/Calib/SPDNoisy");
23197852 454 AliCDBEntry *deadSPD = AliCDBManager::Instance()->Get("ITS/Calib/SPDDead");
e122592f 455 AliCDBEntry *pitCond = AliCDBManager::Instance()->Get("TRIGGER/SPD/PITConditions");
ad7f2bfa 456 if(!noisySPD || !deadSPD || !pitCond ){
62b93da7 457 AliFatal("SPD Calibration object retrieval failed! ");
458 return kFALSE;
ad7f2bfa 459 }
75065a60 460
ad7f2bfa 461 TObjArray *calNoisySPD = (TObjArray*) noisySPD->GetObject();
462 if (!cacheStatus) noisySPD->SetObject(NULL);
463 noisySPD->SetOwner(kTRUE);
fb4dfab9 464
ad7f2bfa 465 TObjArray *calDeadSPD = (TObjArray*) deadSPD->GetObject();
466 if (!cacheStatus) deadSPD->SetObject(NULL);
62b93da7 467 deadSPD->SetOwner(kTRUE);
468
ad7f2bfa 469 AliITSTriggerConditions *calPitCond = (AliITSTriggerConditions*) pitCond->GetObject();
470 if (!cacheStatus) pitCond->SetObject(NULL);
471 pitCond->SetOwner(kTRUE);
b457135f 472
62b93da7 473 if(!cacheStatus){
ad7f2bfa 474 delete noisySPD;
62b93da7 475 delete deadSPD;
ad7f2bfa 476 delete pitCond;
62b93da7 477 }
ad7f2bfa 478 if ((!calNoisySPD) || (!calDeadSPD) || (!calPitCond)){
62b93da7 479 AliWarning("Can not get SPD calibration from calibration database !");
480 return kFALSE;
481 }
482
ad7f2bfa 483 fNMod[0] = calNoisySPD->GetEntries();
62b93da7 484
485 AliITSCalibration* cal;
486 for (Int_t i=0; i<fNMod[0]; i++) {
ad7f2bfa 487 cal = (AliITSCalibration*) calNoisySPD->At(i);
62b93da7 488 SetCalibrationModel(i, cal);
ad7f2bfa 489 cal = (AliITSCalibration*) calDeadSPD->At(i);
62b93da7 490 SetSPDDeadModel(i, cal);
491 }
ad7f2bfa 492 fTriggerConditions = calPitCond;
62b93da7 493
62b93da7 494 return kTRUE;
495}
75065a60 496
62b93da7 497//______________________________________________________________________
75065a60 498Bool_t AliITSDetTypeRec::GetCalibrationSDD(Bool_t cacheStatus) {
499 // Get SDD calibration objects from OCDB
500
62b93da7 501 AliCDBEntry *entrySDD = AliCDBManager::Instance()->Get("ITS/Calib/CalibSDD");
6cae184e 502 AliCDBEntry *entry2SDD = AliCDBManager::Instance()->Get("ITS/Calib/RespSDD");
18da6e54 503 AliCDBEntry *drSpSDD = AliCDBManager::Instance()->Get("ITS/Calib/DriftSpeedSDD");
979b5a5f 504 AliCDBEntry *ddlMapSDD = AliCDBManager::Instance()->Get("ITS/Calib/DDLMapSDD");
62b93da7 505 // AliCDBEntry *mapASDD = AliCDBManager::Instance()->Get("ITS/Calib/MapsAnodeSDD");
028a3709 506 AliCDBEntry *mapTSDD = AliCDBManager::Instance()->Get("ITS/Calib/MapsTimeSDD");
06232459 507
e5b2f7f2 508 if(!entrySDD || !entry2SDD || !drSpSDD || !ddlMapSDD || !mapTSDD ){
75065a60 509 AliFatal("SDD Calibration object retrieval failed! ");
e8c4cf33 510 return kFALSE;
566f73ca 511 }
512
23197852 513
fcf95fc7 514
b17dae48 515 TObjArray *calSDD = (TObjArray *)entrySDD->GetObject();
6cae184e 516 if(!cacheStatus)entrySDD->SetObject(NULL);
8ba39da9 517 entrySDD->SetOwner(kTRUE);
fcf95fc7 518
519 AliITSresponseSDD *pSDD = (AliITSresponseSDD*)entry2SDD->GetObject();
6cae184e 520 if(!cacheStatus)entry2SDD->SetObject(NULL);
fcf95fc7 521 entry2SDD->SetOwner(kTRUE);
522
18da6e54 523 TObjArray *drSp = (TObjArray *)drSpSDD->GetObject();
524 if(!cacheStatus)drSpSDD->SetObject(NULL);
525 drSpSDD->SetOwner(kTRUE);
526
979b5a5f 527 AliITSDDLModuleMapSDD *ddlsdd=(AliITSDDLModuleMapSDD*)ddlMapSDD->GetObject();
528 if(!cacheStatus)ddlMapSDD->SetObject(NULL);
529 ddlMapSDD->SetOwner(kTRUE);
530
2ebd5518 531// TObjArray *mapAn = (TObjArray *)mapASDD->GetObject();
532// if(!cacheStatus)mapASDD->SetObject(NULL);
533// mapASDD->SetOwner(kTRUE);
028a3709 534
535 TObjArray *mapT = (TObjArray *)mapTSDD->GetObject();
536 if(!cacheStatus)mapTSDD->SetObject(NULL);
537 mapTSDD->SetOwner(kTRUE);
538
75065a60 539
540 // DB entries are deleted. In this way metadeta objects are deleted as well
541 if(!cacheStatus){
542 delete entrySDD;
543 delete entry2SDD;
544 //delete mapASDD;
75065a60 545 delete mapTSDD;
546 delete drSpSDD;
547 delete ddlMapSDD;
548 }
549
e5b2f7f2 550 if ((!pSDD)||(!calSDD) || (!drSp) || (!ddlsdd) || (!mapT) ){
75065a60 551 AliWarning("Can not get SDD calibration from calibration database !");
552 return kFALSE;
553 }
554
555 fNMod[1] = calSDD->GetEntries();
556
557 fDDLMapSDD=ddlsdd;
558 fRespSDD=pSDD;
75065a60 559 AliITSCalibration* cal;
560 Float_t avegain=0.;
561 Float_t nGdAnodes=0;
54af1add 562 Bool_t oldMapFormat=kFALSE;
563 TObject* objmap=(TObject*)mapT->At(0);
564 TString cname(objmap->ClassName());
565 if(cname.CompareTo("AliITSMapSDD")==0){
566 oldMapFormat=kTRUE;
567 AliInfo("SDD Maps converted to new format");
568 }
75065a60 569 for(Int_t iddl=0; iddl<AliITSDDLModuleMapSDD::GetNDDLs(); iddl++){
570 for(Int_t icar=0; icar<AliITSDDLModuleMapSDD::GetNModPerDDL();icar++){
571 Int_t iMod=fDDLMapSDD->GetModuleNumber(iddl,icar);
572 if(iMod==-1) continue;
573 Int_t i=iMod - fgkDefaultNModulesSPD;
574 cal = (AliITSCalibration*) calSDD->At(i);
575 Int_t i0=2*i;
576 Int_t i1=1+2*i;
577 for(Int_t iAnode=0;iAnode< ((AliITSCalibrationSDD*)cal)->NOfAnodes(); iAnode++){
578 if(((AliITSCalibrationSDD*)cal)->IsBadChannel(iAnode)) continue;
579 avegain+= ((AliITSCalibrationSDD*)cal)->GetChannelGain(iAnode);
580 nGdAnodes++;
581 }
582 AliITSDriftSpeedArraySDD* arr0 = (AliITSDriftSpeedArraySDD*) drSp->At(i0);
75065a60 583 AliITSDriftSpeedArraySDD* arr1 = (AliITSDriftSpeedArraySDD*) drSp->At(i1);
54af1add 584
585 AliITSCorrMapSDD* mt0 = 0;
586 AliITSCorrMapSDD* mt1 = 0;
587 if(oldMapFormat){
588 AliITSMapSDD* oldmap0=(AliITSMapSDD*)mapT->At(i0);
589 AliITSMapSDD* oldmap1=(AliITSMapSDD*)mapT->At(i1);
590 mt0=oldmap0->ConvertToNewFormat();
591 mt1=oldmap1->ConvertToNewFormat();
592 }else{
593 mt0=(AliITSCorrMapSDD*)mapT->At(i0);
594 mt1=(AliITSCorrMapSDD*)mapT->At(i1);
595 }
75065a60 596 cal->SetDriftSpeed(0,arr0);
597 cal->SetDriftSpeed(1,arr1);
75065a60 598 cal->SetMapT(0,mt0);
599 cal->SetMapT(1,mt1);
600 SetCalibrationModel(iMod, cal);
601 }
602 }
603 if(nGdAnodes) fAveGainSDD=avegain/nGdAnodes;
604 return kTRUE;
605}
606
607
608//______________________________________________________________________
609Bool_t AliITSDetTypeRec::GetCalibrationSSD(Bool_t cacheStatus) {
610 // Get SSD calibration objects from OCDB
611 // AliCDBEntry *entrySSD = AliCDBManager::Instance()->Get("ITS/Calib/CalibSSD");
612
613 AliCDBEntry *entryNoiseSSD = AliCDBManager::Instance()->Get("ITS/Calib/NoiseSSD");
614 AliCDBEntry *entryGainSSD = AliCDBManager::Instance()->Get("ITS/Calib/GainSSD");
615 AliCDBEntry *entryBadChannelsSSD = AliCDBManager::Instance()->Get("ITS/Calib/BadChannelsSSD");
616
617 if(!entryNoiseSSD || !entryGainSSD || !entryBadChannelsSSD){
618 AliFatal("SSD Calibration object retrieval failed! ");
619 return kFALSE;
620 }
621
9b4aee57 622 TObject *emptyssd = 0; TString ssdobjectname;
964d8c19 623 AliITSNoiseSSDv2 *noiseSSD = NULL;
88128115 624 emptyssd = (TObject *)entryNoiseSSD->GetObject();
625 ssdobjectname = emptyssd->GetName();
626 if(ssdobjectname=="TObjArray") {
627 TObjArray *noiseSSDOld = (TObjArray *)entryNoiseSSD->GetObject();
964d8c19 628 noiseSSD = new AliITSNoiseSSDv2();
88128115 629 ReadOldSSDNoise(noiseSSDOld, noiseSSD);
630 }
631 else if(ssdobjectname=="AliITSNoiseSSDv2")
632 noiseSSD = (AliITSNoiseSSDv2 *)entryNoiseSSD->GetObject();
fb4dfab9 633 if(!cacheStatus)entryNoiseSSD->SetObject(NULL);
634 entryNoiseSSD->SetOwner(kTRUE);
635
964d8c19 636 AliITSGainSSDv2 *gainSSD = NULL;;
88128115 637 emptyssd = (TObject *)entryGainSSD->GetObject();
638 ssdobjectname = emptyssd->GetName();
639 if(ssdobjectname=="Gain") {
640 TObjArray *gainSSDOld = (TObjArray *)entryGainSSD->GetObject();
964d8c19 641 gainSSD = new AliITSGainSSDv2();
88128115 642 ReadOldSSDGain(gainSSDOld, gainSSD);
643 }
644 else if(ssdobjectname=="AliITSGainSSDv2")
645 gainSSD = (AliITSGainSSDv2 *)entryGainSSD->GetObject();
fb4dfab9 646 if(!cacheStatus)entryGainSSD->SetObject(NULL);
647 entryGainSSD->SetOwner(kTRUE);
648
964d8c19 649 AliITSBadChannelsSSDv2 *badChannelsSSD = NULL;
88128115 650 emptyssd = (TObject *)entryBadChannelsSSD->GetObject();
651 ssdobjectname = emptyssd->GetName();
652 if(ssdobjectname=="TObjArray") {
653 TObjArray *badChannelsSSDOld = (TObjArray *)entryBadChannelsSSD->GetObject();
964d8c19 654 badChannelsSSD = new AliITSBadChannelsSSDv2();
88128115 655 ReadOldSSDBadChannels(badChannelsSSDOld, badChannelsSSD);
656 }
657 else if(ssdobjectname=="AliITSBadChannelsSSDv2")
658 badChannelsSSD = (AliITSBadChannelsSSDv2*)entryBadChannelsSSD->GetObject();
fb4dfab9 659 if(!cacheStatus)entryBadChannelsSSD->SetObject(NULL);
660 entryBadChannelsSSD->SetOwner(kTRUE);
fcf95fc7 661
b17dae48 662 // DB entries are deleted. In this way metadeta objects are deleted as well
6cae184e 663 if(!cacheStatus){
fb4dfab9 664 delete entryNoiseSSD;
665 delete entryGainSSD;
666 delete entryBadChannelsSSD;
b17dae48 667 }
06232459 668
75065a60 669 if ((!noiseSSD)|| (!gainSSD)|| (!badChannelsSSD)) {
670 AliWarning("Can not get SSD calibration from calibration database !");
8ba39da9 671 return kFALSE;
672 }
fcf95fc7 673
ced4d9bc 674 fSSDCalibration->SetNoise(noiseSSD);
ced4d9bc 675 fSSDCalibration->SetGain(gainSSD);
88128115 676 fSSDCalibration->SetBadChannels(badChannelsSSD);
ced4d9bc 677 //fSSDCalibration->FillBadChipMap();
678
8ba39da9 679 return kTRUE;
680}
681
7d62fb64 682//________________________________________________________________
3a7c3e6d 683void AliITSDetTypeRec::SetDefaultClusterFindersV2(Bool_t rawdata){
7d62fb64 684
685 //Set defaults for cluster finder V2
686
8e50d897 687 if(!GetITSgeom()){
688 Warning("SetDefaults","Null pointer to AliITSgeom !");
7d62fb64 689 return;
690 }
691
7d62fb64 692 AliITSClusterFinder *clf;
693
3a7c3e6d 694 for(Int_t dettype=0;dettype<fgkNdettypes;dettype++){
7d62fb64 695 //SPD
696 if(dettype==0){
697 if(!GetReconstructionModel(dettype)){
8ba39da9 698 clf = new AliITSClusterFinderV2SPD(this);
7d62fb64 699 clf->InitGeometry();
3a7c3e6d 700 if(!rawdata) clf->SetDigits(DigitsAddress(0));
7d62fb64 701 SetReconstructionModel(dettype,clf);
702
703 }
704 }
705 //SDD
706 if(dettype==1){
707 if(!GetReconstructionModel(dettype)){
8ba39da9 708 clf = new AliITSClusterFinderV2SDD(this);
709 clf->InitGeometry();
3a7c3e6d 710 if(!rawdata) clf->SetDigits(DigitsAddress(1));
7d62fb64 711 SetReconstructionModel(dettype,clf);
712 }
713
714 }
715
716 //SSD
717 if(dettype==2){
718 if(!GetReconstructionModel(dettype)){
8ba39da9 719 clf = new AliITSClusterFinderV2SSD(this);
7d62fb64 720 clf->InitGeometry();
3a7c3e6d 721 if(!rawdata) clf->SetDigits(DigitsAddress(2));
7d62fb64 722 SetReconstructionModel(dettype,clf);
723 }
724 }
725
726 }
727
728}
729//______________________________________________________________________
6cae184e 730void AliITSDetTypeRec::MakeBranch(TTree* tree, Option_t* option){
7d62fb64 731
732 //Creates branches for clusters and recpoints
733 Bool_t cR = (strstr(option,"R")!=0);
734 Bool_t cRF = (strstr(option,"RF")!=0);
7d62fb64 735
736 if(cRF)cR = kFALSE;
737
6cae184e 738 if(cR) MakeBranchR(tree);
739 if(cRF) MakeBranchRF(tree);
7d62fb64 740
741}
742
7d62fb64 743//___________________________________________________________________
744void AliITSDetTypeRec::ResetDigits(){
745 // Reset number of digits and the digits array for the ITS detector.
746
747 if(!fDigits) return;
748 for(Int_t i=0;i<fgkNdettypes;i++){
749 ResetDigits(i);
750 }
751}
752//___________________________________________________________________
753void AliITSDetTypeRec::ResetDigits(Int_t branch){
754 // Reset number of digits and the digits array for this branch.
755
756 if(fDigits->At(branch)) ((TClonesArray*)fDigits->At(branch))->Clear();
7d62fb64 757
7d62fb64 758}
759//__________________________________________________________________
6cae184e 760void AliITSDetTypeRec::MakeBranchR(TTree *treeR, Option_t *opt){
7d62fb64 761
762 //Creates tree branches for recpoints
763 // Inputs:
764 // cont char *file File name where RecPoints branch is to be written
765 // to. If blank it write the SDigits to the same
766 // file in which the Hits were found.
767
7d62fb64 768 Int_t buffsz = 4000;
769 char branchname[30];
770
771 // only one branch for rec points for all detector types
772 Bool_t oFast= (strstr(opt,"Fast")!=0);
7d62fb64 773
774 Char_t detname[10] = "ITS";
775
776
777 if(oFast){
778 sprintf(branchname,"%sRecPointsF",detname);
7d62fb64 779 } else {
780 sprintf(branchname,"%sRecPoints",detname);
781 }
782
00a7cc50 783 if(!fRecPoints)fRecPoints = new TClonesArray("AliITSRecPoint",1000);
6cae184e 784 if (treeR)
785 MakeBranchInTree(treeR,branchname,0,&fRecPoints,buffsz,99);
7d62fb64 786}
787//______________________________________________________________________
dc5c67dc 788void AliITSDetTypeRec::SetTreeAddressR(TTree* const treeR){
7d62fb64 789 // Set branch address for the Reconstructed points Trees.
3b9df642 790 // Inputs:
7d62fb64 791 // TTree *treeR Tree containing the RecPoints.
3b9df642 792 // Outputs:
7d62fb64 793 // none.
3b9df642 794 // Return:
7d62fb64 795
ad7f2bfa 796 char branchname[30];
797 Char_t namedet[10]="ITS";
7d62fb64 798
ad7f2bfa 799 if(!treeR) return;
800 if(fRecPoints==0x0) fRecPoints = new TClonesArray("AliITSRecPoint",1000);
801 TBranch *branch;
802 sprintf(branchname,"%sRecPoints",namedet);
803 branch = treeR->GetBranch(branchname);
804 if (branch) {
00a7cc50 805 branch->SetAddress(&fRecPoints);
ad7f2bfa 806 }
807 else {
00a7cc50 808 sprintf(branchname,"%sRecPointsF",namedet);
7d62fb64 809 branch = treeR->GetBranch(branchname);
810 if (branch) {
00a7cc50 811 branch->SetAddress(&fRecPoints);
7d62fb64 812 }
ad7f2bfa 813 }
3b9df642 814}
7d62fb64 815//____________________________________________________________________
816void AliITSDetTypeRec::AddRecPoint(const AliITSRecPoint &r){
817 // Add a reconstructed space point to the list
818 // Inputs:
819 // const AliITSRecPoint &r RecPoint class to be added to the tree
820 // of reconstructed points TreeR.
821 // Outputs:
822 // none.
823 // Return:
824 // none.
825
826 TClonesArray &lrecp = *fRecPoints;
827 new(lrecp[fNRecPoints++]) AliITSRecPoint(r);
828}
7d62fb64 829
830//______________________________________________________________________
5d2c2f86 831void AliITSDetTypeRec::DigitsToRecPoints(TTree *treeD,TTree *treeR,Int_t lastentry,Option_t *opt, Int_t optCluFind){
7d62fb64 832 // cluster finding and reconstruction of space points
833 // the condition below will disappear when the geom class will be
834 // initialized for all versions - for the moment it is only for v5 !
835 // 7 is the SDD beam test version
836 // Inputs:
6cae184e 837 // TTree *treeD Digits tree
838 // TTree *treeR Clusters tree
7d62fb64 839 // Int_t lastentry Offset for module when not all of the modules
840 // are processed.
841 // Option_t *opt String indicating which ITS sub-detectors should
842 // be processed. If ="All" then all of the ITS
843 // sub detectors are processed.
844
7d62fb64 845 const char *all = strstr(opt,"All");
846 const char *det[3] = {strstr(opt,"SPD"),strstr(opt,"SDD"),
847 strstr(opt,"SSD")};
5d2c2f86 848 if(optCluFind==0){
00a7cc50 849 SetDefaultClusterFindersV2();
75a74b11 850 AliDebug(1,"V2 cluster finder has been selected \n");
5d2c2f86 851 }else{
852 SetDefaultClusterFindersV2();
06a7cbee 853 AliInfo("Cluster Finder Option not implemented, V2 cluster finder will be used \n");
00a7cc50 854 }
7d62fb64 855
ad7f2bfa 856
857 // Reset Fast-OR fired map
858 ResetFastOrFiredMap();
859
860 if (all || det[0]) { // SPD present
861 // Get the FO signals for this event
862 AliRunLoader* runLoader = AliRunLoader::Instance();
863 AliITSLoader* itsLoader = (AliITSLoader*) runLoader->GetLoader("ITSLoader");
864 if (!itsLoader) {
865 AliError("ITS loader is NULL.");
866 }
a0d76912 867 else {
868 fFOSignals = (AliITSFOSignalsSPD*)itsLoader->TreeD()->GetUserInfo()->FindObject("AliITSFOSignalsSPD");
869 if(!fFOSignals) AliError("FO signals not retrieved");
870 }
871
ad7f2bfa 872 }
873
874
7d62fb64 875 AliITSClusterFinder *rec = 0;
876 Int_t id,module,first=0;
8e50d897 877 for(module=0;module<GetITSgeom()->GetIndexMax();module++){
878 id = GetITSgeom()->GetModuleType(module);
7d62fb64 879 if (!all && !det[id]) continue;
8e50d897 880 if(det[id]) first = GetITSgeom()->GetStartDet(id);
7d62fb64 881 rec = (AliITSClusterFinder*)GetReconstructionModel(id);
882 TClonesArray *itsDigits = DigitsAddress(id);
6cae184e 883 if (!rec)
884 AliFatal("The reconstruction class was not instanciated!");
5e5bc8f1 885 ResetDigits(); // MvL: Not sure we neeed this when rereading anyways
7d62fb64 886 if (all) {
6cae184e 887 treeD->GetEvent(lastentry+module);
ad7f2bfa 888 }
889 else {
890 treeD->GetEvent(lastentry+(module-first));
891 }
892 Int_t ndigits = itsDigits->GetEntriesFast();
893 if (ndigits>0 || id==0) { // for SPD we always want to call FindRawClusters (to process FO signals)
894 rec->SetDetTypeRec(this);
895 rec->SetDigits(DigitsAddress(id));
896 // rec->SetClusters(ClustersAddress(id));
897 rec->FindRawClusters(module);
898 } // end if
899 treeR->Fill();
900 ResetRecPoints();
901 }
902
903 // Remove PIT in-active chips from Fast-OR fired map
904 if (all || det[0]) { // SPD present
905 RemoveFastOrFiredInActive();
e5c65a6d 906 // here removing bits which have no associated clusters
907 RemoveFastOrFiredFromDead(GetFiredChipMap(treeR));
ad7f2bfa 908 }
3b1d8321 909
910 AliITSRecPointContainer* rpcont = AliITSRecPointContainer::Instance();
911 Int_t nClu[6];
912 nClu[0]=rpcont->GetNClustersInLayer(1,treeR);
913 for(Int_t iLay=2; iLay<=6; iLay++) nClu[iLay-1]=rpcont->GetNClustersInLayerFast(iLay);
914 AliInfo(Form("Number of RecPoints in ITS Layers = %d %d %d %d %d %d",
915 nClu[0],nClu[1],nClu[2],nClu[3],nClu[4],nClu[5]));
7d62fb64 916}
917//______________________________________________________________________
8484b32d 918void AliITSDetTypeRec::DigitsToRecPoints(AliRawReader* rawReader,TTree *treeR,Option_t *opt){
7d62fb64 919 // cluster finding and reconstruction of space points
920 // the condition below will disappear when the geom class will be
921 // initialized for all versions - for the moment it is only for v5 !
922 // 7 is the SDD beam test version
923 // Inputs:
6cae184e 924 // AliRawReader *rawReader Pointer to the raw-data reader
925 // TTree *treeR Clusters tree
7d62fb64 926 // Outputs:
927 // none.
928 // Return:
929 // none.
8484b32d 930 const char *all = strstr(opt,"All");
931 const char *det[3] = {strstr(opt,"SPD"),strstr(opt,"SDD"),
932 strstr(opt,"SSD")};
ad7f2bfa 933
7d62fb64 934 Int_t id=0;
01ef1bd4 935 AliITSRecPointContainer* rpc = AliITSRecPointContainer::Instance();
936 rpc->FullReset();
937 TClonesArray* array = rpc->UncheckedGetClusters(0);
938 TBranch *branch = treeR->Branch("ITSRecPoints",&array);
939 DigitsToRecPoints(rawReader,opt);
d97fc3e0 940
7d62fb64 941 Int_t nClusters =0;
8e50d897 942 for(Int_t iModule=0;iModule<GetITSgeom()->GetIndexMax();iModule++){
8484b32d 943 id = GetITSgeom()->GetModuleType(iModule);
944 if (!all && !det[id]) continue;
01ef1bd4 945 array = rpc->UncheckedGetClusters(iModule);
7d62fb64 946 if(!array){
c157c94e 947 AliDebug(1,Form("data for module %d missing!",iModule));
7d62fb64 948 }
6cae184e 949 branch->SetAddress(&array);
950 treeR->Fill();
7d62fb64 951 nClusters+=array->GetEntriesFast();
7d62fb64 952 }
cd634801 953
01ef1bd4 954 rpc->FullReset();
c157c94e 955
3b1d8321 956 AliITSRecPointContainer* rpcont = AliITSRecPointContainer::Instance();
957 Int_t nClu[6];
958 nClu[0]=rpcont->GetNClustersInLayer(1,treeR);
959 for(Int_t iLay=2; iLay<=6; iLay++) nClu[iLay-1]=rpcont->GetNClustersInLayerFast(iLay);
960 AliInfo(Form("Number of RecPoints in ITS Layers = %d %d %d %d %d %d, Total = %d",
961 nClu[0],nClu[1],nClu[2],nClu[3],nClu[4],nClu[5],nClusters));
d97fc3e0 962}
963//______________________________________________________________________
01ef1bd4 964void AliITSDetTypeRec::DigitsToRecPoints(AliRawReader* rawReader,Option_t *opt){
d97fc3e0 965 // cluster finding and reconstruction of space points
966 // the condition below will disappear when the geom class will be
967 // initialized for all versions - for the moment it is only for v5 !
968 // 7 is the SDD beam test version
969 // Inputs:
970 // AliRawReader *rawReader Pointer to the raw-data reader
d97fc3e0 971 // Outputs:
972 // none.
973 // Return:
974 // none.
975 const char *all = strstr(opt,"All");
976 const char *det[3] = {strstr(opt,"SPD"),strstr(opt,"SDD"),
977 strstr(opt,"SSD")};
978
979 // Reset Fast-OR fired map
980 ResetFastOrFiredMap();
981
982 AliITSClusterFinder *rec = 0;
983 Int_t id=0;
984
985 for(id=0;id<3;id++){
986 if (!all && !det[id]) continue;
987 rec = (AliITSClusterFinder*)GetReconstructionModel(id);
988 if (!rec)
989 AliFatal("The reconstruction class was not instantiated");
990 rec->SetDetTypeRec(this);
01ef1bd4 991 rec->RawdataToClusters(rawReader);
d97fc3e0 992 }
993
ad7f2bfa 994 // Remove PIT in-active chips from Fast-OR fired map
995 if (all || det[0]) { // SPD present
996 RemoveFastOrFiredInActive();
e5c65a6d 997 // here removing bits which have no associated clusters
01ef1bd4 998 RemoveFastOrFiredFromDead(GetFiredChipMap());
e5c65a6d 999
ad7f2bfa 1000 }
7d62fb64 1001}
88128115 1002//______________________________________________________________________
ef665f5e 1003void AliITSDetTypeRec::ReadOldSSDNoise(const TObjArray *array,
88128115 1004 AliITSNoiseSSDv2 *noiseSSD) {
1005 //Reads the old SSD calibration object and converts it to the new format
1006 const Int_t fgkSSDSTRIPSPERMODULE = 1536;
1007 const Int_t fgkSSDPSIDESTRIPSPERMODULE = 768;
1008
3dd31ed2 1009 Int_t gNMod = array->GetEntries();
88128115 1010 cout<<"Converting old calibration object for noise..."<<endl;
1011
1012 //NOISE
1013 Double_t noise = 0.0;
3dd31ed2 1014 for (Int_t iModule = 0; iModule < gNMod; iModule++) {
88128115 1015 AliITSNoiseSSD *noiseModule = (AliITSNoiseSSD*) (array->At(iModule));
1016 for(Int_t iStrip = 0; iStrip < fgkSSDSTRIPSPERMODULE; iStrip++) {
1017 noise = (iStrip < fgkSSDPSIDESTRIPSPERMODULE) ? noiseModule->GetNoiseP(iStrip) : noiseModule->GetNoiseN(1535 - iStrip);
1018 if(iStrip < fgkSSDPSIDESTRIPSPERMODULE)
1019 noiseSSD->AddNoiseP(iModule,iStrip,noise);
1020 if(iStrip >= fgkSSDPSIDESTRIPSPERMODULE)
1021 noiseSSD->AddNoiseN(iModule,1535 - iStrip,noise);
1022 }//loop over strips
1023 }//loop over modules
1024}
1025
1026//______________________________________________________________________
ef665f5e 1027void AliITSDetTypeRec::ReadOldSSDBadChannels(const TObjArray *array,
88128115 1028 AliITSBadChannelsSSDv2 *badChannelsSSD) {
1029 //Reads the old SSD calibration object and converts it to the new format
3dd31ed2 1030 Int_t gNMod = array->GetEntries();
88128115 1031 cout<<"Converting old calibration object for bad channels..."<<endl;
3dd31ed2 1032 for (Int_t iModule = 0; iModule < gNMod; iModule++) {
88128115 1033 //for (Int_t iModule = 0; iModule < 1; iModule++) {
1034 AliITSBadChannelsSSD *bad = (AliITSBadChannelsSSD*) (array->At(iModule));
1035 TArrayI arrayPSide = bad->GetBadPChannelsList();
1036 for(Int_t iPCounter = 0; iPCounter < arrayPSide.GetSize(); iPCounter++)
1037 badChannelsSSD->AddBadChannelP(iModule,
1038 iPCounter,
1039 (Char_t)arrayPSide.At(iPCounter));
1040
1041 TArrayI arrayNSide = bad->GetBadNChannelsList();
1042 for(Int_t iNCounter = 0; iNCounter < arrayNSide.GetSize(); iNCounter++)
1043 badChannelsSSD->AddBadChannelN(iModule,
1044 iNCounter,
1045 (Char_t)arrayNSide.At(iNCounter));
1046
1047 }//loop over modules
1048}
1049
1050//______________________________________________________________________
ef665f5e 1051void AliITSDetTypeRec::ReadOldSSDGain(const TObjArray *array,
88128115 1052 AliITSGainSSDv2 *gainSSD) {
1053 //Reads the old SSD calibration object and converts it to the new format
1054
3dd31ed2 1055 Int_t gNMod = array->GetEntries();
88128115 1056 cout<<"Converting old calibration object for gain..."<<endl;
1057
1058 //GAIN
3dd31ed2 1059 for (Int_t iModule = 0; iModule < gNMod; iModule++) {
88128115 1060 AliITSGainSSD *gainModule = (AliITSGainSSD*) (array->At(iModule));
1061 TArrayF arrayPSide = gainModule->GetGainP();
1062 for(Int_t iPCounter = 0; iPCounter < arrayPSide.GetSize(); iPCounter++)
1063 gainSSD->AddGainP(iModule,
1064 iPCounter,
1065 arrayPSide.At(iPCounter));
1066 TArrayF arrayNSide = gainModule->GetGainN();
1067 for(Int_t iNCounter = 0; iNCounter < arrayNSide.GetSize(); iNCounter++)
1068 gainSSD->AddGainN(iModule,
1069 iNCounter,
1070 arrayNSide.At(iNCounter));
1071 }//loop over modules
1072}
ad7f2bfa 1073//______________________________________________________________________
1074void AliITSDetTypeRec::RemoveFastOrFiredInActive() {
1075 // Removes the chips that were in-active in the pixel trigger (from fast-or fired map)
e5c65a6d 1076
ad7f2bfa 1077 if (fTriggerConditions==NULL) {
1078 AliError("Pixel trigger conditions are missing.");
1079 return;
1080 }
1081 Int_t eq = -1;
1082 Int_t hs = -1;
1083 Int_t chip = -1;
1084 while (fTriggerConditions->GetNextInActiveChip(eq,hs,chip)) {
1085 UInt_t chipKey = AliITSRawStreamSPD::GetOfflineChipKeyFromOnline(eq,hs,chip);
1086 fFastOrFiredMap.SetBitNumber(chipKey,kFALSE);
1087 }
1088}
1089//______________________________________________________________________
01ef1bd4 1090TBits AliITSDetTypeRec::GetFiredChipMap() const {
e5c65a6d 1091
1092 //
1093 // TBits of the fired chips
1094 //
1095
01ef1bd4 1096 AliITSRecPointContainer* rpc = AliITSRecPointContainer::Instance();
1097
e5c65a6d 1098 TBits isfiredchip(1200);
1099
1100 AliITSsegmentationSPD *segSPD = (AliITSsegmentationSPD*)GetSegmentationModel(0);
1101 if(!segSPD) {
1102 AliError("no segmentation model for SPD available, the fired chip map is empty. Exiting");
1103 return isfiredchip;
1104 }
1105
1106
1107 for(Int_t imod =0; imod < fgkDefaultNModulesSPD; imod++){
01ef1bd4 1108 TClonesArray *array = rpc->UncheckedGetClusters(imod);
1109 if(!array) continue;
1110 Int_t nCluster = array->GetEntriesFast();
e5c65a6d 1111
01ef1bd4 1112 while(nCluster--) {
1113 AliITSRecPoint* cluster = (AliITSRecPoint*)array->UncheckedAt(nCluster);
e5c65a6d 1114 if (cluster->GetLayer()>1)continue;
01ef1bd4 1115 Float_t local[3]={-1,-1};
1116 local[1]=cluster->GetDetLocalX();
1117 local[0]=cluster->GetDetLocalZ();
1118
1119 Int_t eq = AliITSRawStreamSPD::GetOnlineEqIdFromOffline(imod);
1120 Int_t hs = AliITSRawStreamSPD::GetOnlineHSFromOffline(imod);
1121 Int_t row, col;
1122 segSPD->LocalToDet(0.5,local[0],row,col);
1123 Int_t chip = AliITSRawStreamSPD::GetOnlineChipFromOffline(imod,col);
1124 Int_t chipkey = AliITSRawStreamSPD::GetOfflineChipKeyFromOnline(eq,hs,chip);
1125 isfiredchip.SetBitNumber(chipkey,kTRUE);
1126 }
e5c65a6d 1127
01ef1bd4 1128 }
e5c65a6d 1129
01ef1bd4 1130 return isfiredchip;
e5c65a6d 1131
1132}
1133//______________________________________________________________________
1134TBits AliITSDetTypeRec::GetFiredChipMap(TTree *treeR) const{
1135 //
1136 // TBits of the fired chips
1137 //
1138 TBits isfiredchip(1200);
1139
1140 if(!treeR) {
1141 AliError("no treeR. fired chip map stays empty. Exiting.");
1142 return isfiredchip;
1143 }
1144
1145 AliITSRecPointContainer* rpcont=AliITSRecPointContainer::Instance();
1146 TClonesArray *recpoints = rpcont->FetchClusters(0,treeR);
1147 if(!rpcont->GetStatusOK() || !rpcont->IsSPDActive()){
1148 AliError("no clusters. fired chip map stays empty. Exiting.");
1149 return isfiredchip;
1150 }
1151
1152 AliITSsegmentationSPD *segSPD = (AliITSsegmentationSPD*)GetSegmentationModel(0);
1153
1154 for(Int_t imod =0; imod < fgkDefaultNModulesSPD; imod++){
1155 recpoints = rpcont->UncheckedGetClusters(imod);
1156 Int_t nCluster = recpoints->GetEntriesFast();
1157
1158 // loop over clusters
1159 while(nCluster--) {
1160 AliITSRecPoint* cluster = (AliITSRecPoint*)recpoints->UncheckedAt(nCluster);
1161 if (cluster->GetLayer()>1)continue;
1162 Float_t local[3]={-1,-1};
1163 local[1]=cluster->GetDetLocalX();
1164 local[0]=cluster->GetDetLocalZ();
1165
1166 Int_t eq = AliITSRawStreamSPD::GetOnlineEqIdFromOffline(imod);
1167 Int_t hs = AliITSRawStreamSPD::GetOnlineHSFromOffline(imod);
1168 Int_t row, col;
1169 segSPD->LocalToDet(0.5,local[0],row,col);
1170 Int_t chip = AliITSRawStreamSPD::GetOnlineChipFromOffline(imod,col);
1171 Int_t chipkey = AliITSRawStreamSPD::GetOfflineChipKeyFromOnline(eq,hs,chip);
1172 isfiredchip.SetBitNumber(chipkey,kTRUE);
1173 }
1174 }
1175
1176 return isfiredchip;
1177}
1178//______________________________________________________________________
1179void AliITSDetTypeRec::RemoveFastOrFiredFromDead(TBits firedchipmap){
1180 //
1181 // resetting of the fast-or bit on cluster basis.
1182 // fast-or bits can be remnant from SPD ideal simulation (no dead channels)
1183 //
1184
1185 for(Int_t chipKey=0; chipKey<1200; chipKey++){
1186 // FO masked chips have been previously removed
1187 if(!fFastOrFiredMap.TestBitNumber(chipKey)) continue;
1188 if(!firedchipmap.TestBitNumber(chipKey)) {
1189 fFastOrFiredMap.SetBitNumber(chipKey,kFALSE);
1190 AliDebug(2,Form("removing bit in key %i \n ",chipKey));
1191 }
1192 }
1193
1194}
1195//______________________________________________________________________
ad7f2bfa 1196void AliITSDetTypeRec::SetFastOrFiredMapOnline(UInt_t eq, UInt_t hs, UInt_t chip) {
1197 // Set fast-or fired map for this chip
1198 Int_t chipKey = AliITSRawStreamSPD::GetOfflineChipKeyFromOnline(eq,hs,chip);
1199 return SetFastOrFiredMap(chipKey);
1200}
88128115 1201