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