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