]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PHOS/AliPHOSReconstructor.cxx
add setters
[u/mrichter/AliRoot.git] / PHOS / AliPHOSReconstructor.cxx
CommitLineData
d15a28e7 1/**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
15
b2a60966 16/* $Id$ */
17
d15a28e7 18//_________________________________________________________________________
a5e00016 19//--
20//-- Yves Schutz (SUBATECH)
dfe0be07 21// Reconstruction class. Redesigned from the old AliReconstructionner class and
22// derived from STEER/AliReconstructor.
23//
d15a28e7 24// --- ROOT system ---
bb5c37a5 25#include "TGeoManager.h"
26#include "TGeoMatrix.h"
00cfce1d 27
d15a28e7 28// --- Standard library ---
364de5c6 29
d15a28e7 30// --- AliRoot header files ---
9a2cdbdf 31#include "AliLog.h"
b3006690 32#include "AliAltroMapping.h"
af885e0f 33#include "AliESDEvent.h"
33ba95c3 34#include "AliESDCaloCluster.h"
a5e00016 35#include "AliESDCaloCells.h"
f444a19f 36#include "AliPHOSReconstructor.h"
7acf6008 37#include "AliPHOSClusterizerv1.h"
7acf6008 38#include "AliPHOSTrackSegmentMakerv1.h"
39#include "AliPHOSPIDv1.h"
23904d16 40#include "AliPHOSTracker.h"
d22dd3b4 41#include "AliRawReader.h"
d3aa2291 42#include "AliPHOSCalibData.h"
7e88424f 43#include "AliCDBEntry.h"
44#include "AliCDBManager.h"
64df000d 45#include "AliPHOSTrigger.h"
46#include "AliPHOSGeometry.h"
9a2cdbdf 47#include "AliPHOSDigit.h"
48#include "AliPHOSTrackSegment.h"
49#include "AliPHOSEmcRecPoint.h"
50#include "AliPHOSRecParticle.h"
379c5c09 51#include "AliPHOSRawFitterv0.h"
52#include "AliPHOSRawFitterv1.h"
53#include "AliPHOSRawFitterv2.h"
f4a5c5fd 54#include "AliPHOSRawFitterv3.h"
de0cfd46 55#include "AliPHOSRawFitterv4.h"
9a2cdbdf 56#include "AliPHOSRawDigiProducer.h"
57#include "AliPHOSPulseGenerator.h"
e1aec4f9 58#include "AliPHOSTriggerRawDigit.h"
59#include "AliPHOSTriggerRawDigiProducer.h"
60#include "AliPHOSTriggerParameters.h"
e957fea8 61
f444a19f 62ClassImp(AliPHOSReconstructor)
d15a28e7 63
2e60107f 64Bool_t AliPHOSReconstructor::fgDebug = kFALSE ;
6483babc 65TClonesArray* AliPHOSReconstructor::fgDigitsArray = 0; // Array of PHOS digits
66TObjArray* AliPHOSReconstructor::fgEMCRecPoints = 0; // Array of EMC rec.points
d3aa2291 67AliPHOSCalibData * AliPHOSReconstructor::fgCalibData = 0 ;
e1aec4f9 68TClonesArray* AliPHOSReconstructor::fgTriggerDigits = 0; // Array of PHOS trigger digits
2e60107f 69
d15a28e7 70//____________________________________________________________________________
9a2cdbdf 71AliPHOSReconstructor::AliPHOSReconstructor() :
771123c7 72 fGeom(NULL),fClusterizer(NULL),fTSM(NULL),fPID(NULL),fTmpDigLG(NULL)
d15a28e7 73{
b2a60966 74 // ctor
771123c7 75 fGeom = AliPHOSGeometry::GetInstance("IHEP","");
76 fClusterizer = new AliPHOSClusterizerv1 (fGeom);
77 fTSM = new AliPHOSTrackSegmentMakerv1(fGeom);
78 fPID = new AliPHOSPIDv1 (fGeom);
79 fTmpDigLG = new TClonesArray("AliPHOSDigit",100);
80 fgDigitsArray = new TClonesArray("AliPHOSDigit",100);
81 fgEMCRecPoints = new TObjArray(100) ;
d3aa2291 82 if (!fgCalibData)
83 fgCalibData = new AliPHOSCalibData(-1); //use AliCDBManager's run number
e1aec4f9 84
85 fgTriggerDigits = new TClonesArray("AliPHOSTriggerRawDigit",100);
86
1d76a1f4 87 AliInfo(Form("PHOS bad channel map contains %d bad channel(s).\n",
88 fgCalibData->GetNumOfEmcBadChannels()));
d3aa2291 89
e68222ce 90}
6ad0bfa0 91
0379a13e 92//____________________________________________________________________________
771123c7 93AliPHOSReconstructor::~AliPHOSReconstructor()
0379a13e 94{
95 // dtor
9a2cdbdf 96 delete fGeom;
8d8258f6 97 delete fClusterizer;
dcab1c7e 98 delete fTSM;
99 delete fPID;
771123c7 100 delete fTmpDigLG;
6483babc 101 delete fgDigitsArray;
102 delete fgEMCRecPoints;
e1aec4f9 103 delete fgTriggerDigits;
0379a13e 104}
7acf6008 105
7acf6008 106//____________________________________________________________________________
9a2cdbdf 107void AliPHOSReconstructor::Reconstruct(TTree* digitsTree, TTree* clustersTree) const
35293055 108{
9a2cdbdf 109 // 'single-event' local reco method called by AliReconstruction;
dfe0be07 110 // Only the clusterization is performed,; the rest of the reconstruction is done in FillESD because the track
af885e0f 111 // segment maker needs access to the AliESDEvent object to retrieve the tracks reconstructed by
dfe0be07 112 // the global tracking.
9a2cdbdf 113
7e88424f 114 fClusterizer->InitParameters();
8d8258f6 115 fClusterizer->SetInput(digitsTree);
116 fClusterizer->SetOutput(clustersTree);
a68156e6 117 if ( Debug() )
8d8258f6 118 fClusterizer->Digits2Clusters("deb all") ;
a68156e6 119 else
8d8258f6 120 fClusterizer->Digits2Clusters("") ;
a68156e6 121}
122
123//____________________________________________________________________________
9a2cdbdf 124void AliPHOSReconstructor::FillESD(TTree* digitsTree, TTree* clustersTree,
125 AliESDEvent* esd) const
a68156e6 126{
9a2cdbdf 127 // This method produces PHOS rec-particles,
128 // then it creates AliESDtracks out of them and
129 // write tracks to the ESD
130
e68222ce 131
9a2cdbdf 132 // do current event; the loop over events is done by AliReconstruction::Run()
dcab1c7e 133 fTSM->SetESD(esd) ;
134 fTSM->SetInput(clustersTree);
9a2cdbdf 135 if ( Debug() )
dcab1c7e 136 fTSM->Clusters2TrackSegments("deb all") ;
9a2cdbdf 137 else
dcab1c7e 138 fTSM->Clusters2TrackSegments("") ;
35293055 139
dcab1c7e 140 fPID->SetInput(clustersTree, fTSM->GetTrackSegments()) ;
141 fPID->SetESD(esd) ;
dfe0be07 142 if ( Debug() )
dcab1c7e 143 fPID->TrackSegments2RecParticles("deb all") ;
dfe0be07 144 else
dcab1c7e 145 fPID->TrackSegments2RecParticles("") ;
7acf6008 146
dcab1c7e 147 TClonesArray *recParticles = fPID->GetRecParticles();
148 Int_t nOfRecParticles = recParticles->GetEntriesFast();
a5fa6165 149
9a2cdbdf 150 AliDebug(2,Form("%d rec. particles, option %s",nOfRecParticles,GetOption()));
a5e00016 151
152 // Read digits array
153
154 TBranch *branch = digitsTree->GetBranch("PHOS");
155 if (!branch) {
156 AliError("can't get the branch with the PHOS digits !");
157 return;
158 }
6483babc 159 branch->SetAddress(&fgDigitsArray);
a5e00016 160 branch->GetEntry(0);
161
162 // Get the clusters array
163
164 TBranch *emcbranch = clustersTree->GetBranch("PHOSEmcRP");
165 if (!emcbranch) {
166 AliError("can't get the branch with the PHOS EMC clusters !");
167 return;
168 }
169
6483babc 170 emcbranch->SetAddress(&fgEMCRecPoints);
a5e00016 171 emcbranch->GetEntry(0);
26d0974e 172
173
e1aec4f9 174 // Trigger
e1aec4f9 175
26d0974e 176 TBranch *tbranch = digitsTree->GetBranch("TPHOS");
177 if (tbranch) {
178
179 tbranch->SetAddress(&fgTriggerDigits);
180 tbranch->GetEntry(0);
181
182 AliESDCaloTrigger* trgESD = esd->GetCaloTrigger("PHOS");
183
184 if (trgESD) {
185 trgESD->Allocate(fgTriggerDigits->GetEntriesFast());
e1aec4f9 186
26d0974e 187 for (Int_t i = 0; i < fgTriggerDigits->GetEntriesFast(); i++) {
188 AliPHOSTriggerRawDigit* tdig = (AliPHOSTriggerRawDigit*)fgTriggerDigits->At(i);
189
190 Int_t mod,modX,modZ;
191 tdig->GetModXZ(mod,modX,modZ);
192
193 const Int_t relId[4] = {5-mod,0,modX+1,modZ+1};
194 Int_t absId;
195
196 fGeom->RelToAbsNumbering(relId,absId);
197 trgESD->Add(mod,absId,tdig->GetAmp(),0.,(Int_t*)NULL,0,0,0);
198 }
199 }
e1aec4f9 200 }
e1aec4f9 201
fd3fd391 202// //#########Calculate trigger and set trigger info###########
a5e00016 203
fd3fd391 204// AliPHOSTrigger tr ;
205// // tr.SetPatchSize(1);//create 4x4 patches
206// tr.SetSimulation(kFALSE);
207// tr.Trigger(fgDigitsArray);
64df000d 208
fd3fd391 209// Float_t maxAmp2x2 = tr.Get2x2MaxAmplitude();
210// Float_t maxAmpnxn = tr.GetnxnMaxAmplitude();
211// Float_t ampOutOfPatch2x2 = tr.Get2x2AmpOutOfPatch() ;
212// Float_t ampOutOfPatchnxn = tr.GetnxnAmpOutOfPatch() ;
213
214// Int_t iSM2x2 = tr.Get2x2SuperModule();
215// Int_t iSMnxn = tr.GetnxnSuperModule();
216// Int_t iCrystalPhi2x2 = tr.Get2x2CrystalPhi();
217// Int_t iCrystalPhinxn = tr.GetnxnCrystalPhi();
218// Int_t iCrystalEta2x2 = tr.Get2x2CrystalEta();
219// Int_t iCrystalEtanxn = tr.GetnxnCrystalEta();
220
221// AliDebug(2, Form("Trigger 2x2 max amp %f, out amp %f, SM %d, iphi %d ieta %d",
222// maxAmp2x2, ampOutOfPatch2x2, iSM2x2,iCrystalPhi2x2, iCrystalEta2x2));
223// AliDebug(2, Form("Trigger 4x4 max amp %f , out amp %f, SM %d, iphi %d, ieta %d",
224// maxAmpnxn, ampOutOfPatchnxn, iSMnxn,iCrystalPhinxn, iCrystalEtanxn));
225
226// // Attention! PHOS modules in order to calculate AbsId need to be 1-5 not 0-4 as returns trigger.
227// Int_t iRelId2x2 []= {iSM2x2+1,0,iCrystalPhi2x2,iCrystalEta2x2};
228// Int_t iAbsId2x2 =-1;
229// Int_t iRelIdnxn []= {iSMnxn+1,0,iCrystalPhinxn,iCrystalEtanxn};
230// Int_t iAbsIdnxn =-1;
231// TVector3 pos2x2(-1,-1,-1);
232// TVector3 posnxn(-1,-1,-1);
233// fGeom->RelToAbsNumbering(iRelId2x2, iAbsId2x2);
234// fGeom->RelToAbsNumbering(iRelIdnxn, iAbsIdnxn);
235// fGeom->RelPosInAlice(iAbsId2x2, pos2x2);
236// fGeom->RelPosInAlice(iAbsIdnxn, posnxn);
237
238// TArrayF triggerPosition(6);
239// triggerPosition[0] = pos2x2(0) ;
240// triggerPosition[1] = pos2x2(1) ;
241// triggerPosition[2] = pos2x2(2) ;
242// triggerPosition[3] = posnxn(0) ;
243// triggerPosition[4] = posnxn(1) ;
244// triggerPosition[5] = posnxn(2) ;
245
246// TArrayF triggerAmplitudes(4);
247// triggerAmplitudes[0] = maxAmp2x2 ;
248// triggerAmplitudes[1] = ampOutOfPatch2x2 ;
249// triggerAmplitudes[2] = maxAmpnxn ;
250// triggerAmplitudes[3] = ampOutOfPatchnxn ;
251
252// //esd->SetPHOSTriggerCells(triggerPosition);
253// esd->AddPHOSTriggerPosition(triggerPosition);
254// esd->AddPHOSTriggerAmplitudes(triggerAmplitudes);
64df000d 255
e68222ce 256
a5e00016 257 //########################################
258 //############# Fill CaloCells ###########
259 //########################################
260
6483babc 261 Int_t nDigits = fgDigitsArray->GetEntries();
a5e00016 262 Int_t idignew = 0 ;
263 AliDebug(1,Form("%d digits",nDigits));
264
265 const Int_t knEMC = fGeom->GetNModules()*fGeom->GetNPhi()*fGeom->GetNZ();
266 AliESDCaloCells &phsCells = *(esd->GetPHOSCells());
267 phsCells.CreateContainer(nDigits);
268 phsCells.SetType(AliESDCaloCells::kPHOSCell);
269
270 // Add to CaloCells only EMC digits with non-zero energy
271 for (Int_t idig = 0 ; idig < nDigits ; idig++) {
6483babc 272 const AliPHOSDigit * dig = (const AliPHOSDigit*)fgDigitsArray->At(idig);
12dd7f10 273 if(dig->GetId() <= knEMC &&
274 Calibrate(dig->GetEnergy(),dig->GetId()) > GetRecoParam()->GetEMCMinE() ){
6f47f50d 275 phsCells.SetCell(idignew,dig->GetId(), Calibrate(dig->GetEnergy(),dig->GetId()),
3b6a6812 276 CalibrateT(dig->GetTime(),dig->GetId()),
277 dig->GetPrimary(1)) ;
a5e00016 278 idignew++;
279 }
e68222ce 280 }
a5e00016 281 phsCells.SetNumberOfCells(idignew);
282 phsCells.Sort();
e68222ce 283
a5e00016 284 //########################################
285 //############## Fill CaloClusters #######
286 //########################################
f4e0dd30 287
dfe0be07 288 for (Int_t recpart = 0 ; recpart < nOfRecParticles ; recpart++) {
09828f52 289 AliPHOSRecParticle *rp = static_cast<AliPHOSRecParticle*>(recParticles->At(recpart));
dfe0be07 290 if (Debug())
291 rp->Print();
25ed816e 292 // Get track segment and EMC rec.point associated with this rec.particle
dcab1c7e 293 AliPHOSTrackSegment *ts = static_cast<AliPHOSTrackSegment *>(fTSM->GetTrackSegments()
a5e00016 294 ->At(rp->GetPHOSTSIndex()));
9a2cdbdf 295
6483babc 296 AliPHOSEmcRecPoint *emcRP = static_cast<AliPHOSEmcRecPoint *>(fgEMCRecPoints->At(ts->GetEmcIndex()));
25ed816e 297 AliESDCaloCluster *ec = new AliESDCaloCluster() ;
e68222ce 298
85c60a8e 299 Float_t xyz[3];
8013c27e 300 for (Int_t ixyz=0; ixyz<3; ixyz++)
301 xyz[ixyz] = rp->GetPos()[ixyz];
dd7ee508 302
303 AliDebug(2,Form("Global position xyz=(%f,%f,%f)",xyz[0],xyz[1],xyz[2]));
77ea1c6f 304
a5e00016 305 // Create cell lists
306
307 Int_t cellMult = emcRP->GetDigitsMultiplicity();
308 Int_t *digitsList = emcRP->GetDigitsList();
309 Float_t *rpElist = emcRP->GetEnergiesList() ;
310 UShort_t *absIdList = new UShort_t[cellMult];
311 Double_t *fracList = new Double_t[cellMult];
312
313 for (Int_t iCell=0; iCell<cellMult; iCell++) {
6483babc 314 AliPHOSDigit *digit = static_cast<AliPHOSDigit *>(fgDigitsArray->At(digitsList[iCell]));
a5e00016 315 absIdList[iCell] = (UShort_t)(digit->GetId());
316 if (digit->GetEnergy() > 0)
d3aa2291 317 fracList[iCell] = rpElist[iCell]/(Calibrate(digit->GetEnergy(),digit->GetId()));
a5e00016 318 else
319 fracList[iCell] = 0;
25ed816e 320 }
77ea1c6f 321
7592dfc4 322 //Primaries
323 Int_t primMult = 0;
4dd59c4a 324 Int_t *primList = emcRP->GetPrimaries(primMult);
a5e00016 325
25312a8e 326 Float_t energy=0.;
7e88424f 327 if (GetRecoParam()->EMCEcore2ESD())
48c5db5b 328 energy = emcRP->GetCoreEnergy();
329 else
330 energy = rp->Energy();
25312a8e 331 //Apply nonlinearity correction
332 if(GetRecoParam()->GetEMCEnergyCorrectionOn())
333 energy=CorrectNonlinearity(energy) ;
48c5db5b 334
7592dfc4 335 // fills the ESDCaloCluster
c8fe2783 336 ec->SetType(AliVCluster::kPHOSNeutral);
a5e00016 337 ec->SetPosition(xyz); //rec.point position in MARS
48c5db5b 338 ec->SetE(energy); //total or core particle energy
c8fe2783 339 ec->SetDispersion(emcRP->GetDispersion()); //cluster dispersion
340 ec->SetPID(rp->GetPID()) ; //array of particle identification
25ed816e 341 ec->SetM02(emcRP->GetM2x()) ; //second moment M2x
342 ec->SetM20(emcRP->GetM2z()) ; //second moment M2z
343 ec->SetNExMax(emcRP->GetNExMax()); //number of local maxima
a5e00016 344 ec->SetEmcCpvDistance(ts->GetCpvDistance("r")); //Only radius, what about separate x,z????
95bf21ad 345 ec->SetTrackDistance(ts->GetCpvDistance("x"),ts->GetCpvDistance("z"));
c8fe2783 346 ec->SetChi2(-1); //not yet implemented
6f47f50d 347 ec->SetTOF(emcRP->GetTime()); //Time of flight - already calibrated in EMCRecPoint
78902954 348
a5e00016 349 //Cells contributing to clusters
350 ec->SetNCells(cellMult);
351 ec->SetCellsAbsId(absIdList);
352 ec->SetCellsAmplitudeFraction(fracList);
7592dfc4 353
3744a6cf 354 //Distance to the nearest bad crystal
355 ec->SetDistanceToBadChannel(emcRP->GetDistanceToBadCrystal());
7592dfc4 356
357 //Array of MC indeces
4dd59c4a 358 TArrayI arrayPrim(primMult,primList);
7592dfc4 359 ec->AddLabels(arrayPrim);
64df000d 360
e44c41e9 361 //Matched ESD track
362 TArrayI arrayTrackMatched(1);
363 arrayTrackMatched[0]= ts->GetTrackIndex();
364 ec->AddTracksMatched(arrayTrackMatched);
365
95bf21ad 366 Int_t index = esd->AddCaloCluster(ec);
367
368 //Set pointer to this cluster in ESD track
369 Int_t nt=esd->GetNumberOfTracks();
370 for (Int_t itr=0; itr<nt; itr++) {
371 AliESDtrack *esdTrack=esd->GetTrack(itr);
372 if(!esdTrack->IsPHOS())
373 continue ;
374 if(esdTrack->GetPHOScluster()==-recpart){ //we store negative cluster number
375 esdTrack->SetPHOScluster(index) ;
376//no garatie that only one track matched this cluster
377// break ;
378 }
379 }
380
9a2cdbdf 381 delete ec;
091d150a 382 delete [] fracList;
383 delete [] absIdList;
e68222ce 384 }
771123c7 385 fgDigitsArray ->Clear();
386 fgEMCRecPoints->Clear("C");
387 recParticles ->Clear();
bb5c37a5 388
389 //Store PHOS misalignment matrixes
390 FillMisalMatrixes(esd) ;
391
dd7ee508 392}
393
e68222ce 394//____________________________________________________________________________
d76c31f4 395AliTracker* AliPHOSReconstructor::CreateTracker() const
dd7ee508 396{
9a2cdbdf 397 // creates the PHOS tracker
398 return new AliPHOSTracker();
399}
dd7ee508 400
1267d56d 401//____________________________________________________________________________
9a2cdbdf 402void AliPHOSReconstructor::ConvertDigits(AliRawReader* rawReader, TTree* digitsTree) const
403{
404 // Converts raw data to
405 // PHOS digits
406 // Works on a single-event basis
9a2cdbdf 407 rawReader->Reset() ;
dd7ee508 408
379c5c09 409 AliPHOSRawFitterv0 * fitter ;
77ea1c6f 410
7e88424f 411 const TObjArray* maps = AliPHOSRecoParam::GetMappings();
b3006690 412 if(!maps) AliFatal("Cannot retrieve ALTRO mappings!!");
413
47ba0d5d 414 AliAltroMapping *mapping[20];
415 for(Int_t i = 0; i < 20; i++) {
b3006690 416 mapping[i] = (AliAltroMapping*)maps->At(i);
417 }
418
adc447ab 419 if (strcmp(GetRecoParam()->EMCFitterVersion(),"v0")==0)
420 fitter=new AliPHOSRawFitterv0();
421 else if (strcmp(GetRecoParam()->EMCFitterVersion(),"v1")==0)
379c5c09 422 fitter=new AliPHOSRawFitterv1();
423 else if (strcmp(GetRecoParam()->EMCFitterVersion(),"v2")==0)
424 fitter=new AliPHOSRawFitterv2();
f4a5c5fd 425 else if (strcmp(GetRecoParam()->EMCFitterVersion(),"v3")==0)
426 fitter=new AliPHOSRawFitterv3();
7e88424f 427 else
de0cfd46 428 fitter=new AliPHOSRawFitterv4();
77ea1c6f 429
379c5c09 430 fitter->SubtractPedestals(GetRecoParam()->EMCSubtractPedestals());
431 fitter->SetAmpOffset (GetRecoParam()->GetGlobalAltroOffset());
432 fitter->SetAmpThreshold (GetRecoParam()->GetGlobalAltroThreshold());
8be3a30a 433
9a2cdbdf 434 TClonesArray *digits = new TClonesArray("AliPHOSDigit",1);
435 digits->SetName("DIGITS");
436 Int_t bufsize = 32000;
437 digitsTree->Branch("PHOS", &digits, bufsize);
dd7ee508 438
379c5c09 439 AliPHOSRawDigiProducer rdp(rawReader,mapping);
8be3a30a 440
379c5c09 441 rdp.SetEmcMinAmp(GetRecoParam()->GetEMCRawDigitThreshold()); // in ADC
442 rdp.SetCpvMinAmp(GetRecoParam()->GetCPVMinE());
443 rdp.SetSampleQualityCut(GetRecoParam()->GetEMCSampleQualityCut());
771123c7 444 rdp.MakeDigits(digits,fTmpDigLG,fitter);
77ea1c6f 445
379c5c09 446 delete fitter ;
7592dfc4 447
e1aec4f9 448 TClonesArray *tdigits = new TClonesArray("AliPHOSTriggerRawDigit",1);
449 tdigits->SetName("TDIGITS");
450 digitsTree->Branch("TPHOS", &tdigits, bufsize);
451
452 rawReader->Reset();
453 AliPHOSTriggerRawDigiProducer tdp(rawReader);
892b88d6 454
455 AliPHOSTriggerParameters* parameters = (AliPHOSTriggerParameters*)AliPHOSRecoParam::GetTriggerParameters();
e1aec4f9 456
457 tdp.SetTriggerParameters(parameters);
458 tdp.ProcessEvent(tdigits);
459
379c5c09 460 if (AliLog::GetGlobalDebugLevel() == 1) {
461 Int_t modMax=-111;
462 Int_t colMax=-111;
463 Int_t rowMax=-111;
464 Float_t eMax=-333;
465 //!!!for debug!!!
466
467 Int_t relId[4];
468 for(Int_t iDigit=0; iDigit<digits->GetEntries(); iDigit++) {
469 AliPHOSDigit* digit = (AliPHOSDigit*)digits->At(iDigit);
470 if(digit->GetEnergy()>eMax) {
471 fGeom->AbsToRelNumbering(digit->GetId(),relId);
472 eMax=digit->GetEnergy();
473 modMax=relId[0];
474 rowMax=relId[2];
475 colMax=relId[3];
476 }
dd7ee508 477 }
379c5c09 478
479 AliDebug(1,Form("Digit with max. energy: modMax %d colMax %d rowMax %d eMax %f\n\n",
480 modMax,colMax,rowMax,eMax));
dd7ee508 481 }
e1aec4f9 482
9a2cdbdf 483 digitsTree->Fill();
e1aec4f9 484
e68222ce 485 digits->Delete();
486 delete digits;
e1aec4f9 487
488 tdigits->Delete();
489 delete tdigits;
d7d3b67b 490}
d3aa2291 491//==================================================================================
492Float_t AliPHOSReconstructor::Calibrate(Float_t amp, Int_t absId)const{
493 // Calibrate EMC digit, i.e. multiply its Amp by a factor read from CDB
494
495 const AliPHOSGeometry *geom = AliPHOSGeometry::GetInstance() ;
496
497 //Determine rel.position of the cell absolute ID
498 Int_t relId[4];
499 geom->AbsToRelNumbering(absId,relId);
500 Int_t module=relId[0];
501 Int_t row =relId[2];
502 Int_t column=relId[3];
503 if(relId[1]){ //CPV
504 Float_t calibration = fgCalibData->GetADCchannelCpv(module,column,row);
505 return amp*calibration ;
506 }
507 else{ //EMC
508 Float_t calibration = fgCalibData->GetADCchannelEmc(module,column,row);
509 return amp*calibration ;
510 }
511}
bb5c37a5 512//==================================================================================
6f47f50d 513Float_t AliPHOSReconstructor::CalibrateT(Float_t time, Int_t absId)const{
514 // Calibrate EMC digit, i.e. multiply its Amp by a factor read from CDB
515
516 const AliPHOSGeometry *geom = AliPHOSGeometry::GetInstance() ;
517
518 //Determine rel.position of the cell absolute ID
519 Int_t relId[4];
520 geom->AbsToRelNumbering(absId,relId);
521 Int_t module=relId[0];
522 Int_t row =relId[2];
523 Int_t column=relId[3];
524 if(relId[1]){ //CPV
525 return 0. ;
526 }
527 else{ //EMC
528 time += fgCalibData->GetTimeShiftEmc(module,column,row);
529 return time ;
530 }
531}
532//==================================================================================
bb5c37a5 533void AliPHOSReconstructor::FillMisalMatrixes(AliESDEvent* esd)const{
534 //Store PHOS matrixes in ESD Header
535
536 //Check, if matrixes was already stored
537 for(Int_t mod=0 ;mod<5; mod++){
538 if(esd->GetPHOSMatrix(mod)!=0)
539 return ;
540 }
541
542 //Create and store matrixes
543 if(!gGeoManager){
544 AliError("Can not store misal. matrixes: no gGeoManager! \n") ;
545 return ;
546 }
547 //Note, that owner of copied marixes will be header
548 char path[255] ;
549 TGeoHMatrix * m ;
550 for(Int_t mod=0; mod<5; mod++){
3da0f212 551 snprintf(path,255,"/ALIC_1/PHOS_%d",mod+1) ; //In Geometry modules numbered 1,2,.,5
bb5c37a5 552 if (gGeoManager->cd(path)){
553 m = gGeoManager->GetCurrentMatrix() ;
554 esd->SetPHOSMatrix(new TGeoHMatrix(*m),mod) ;
555 }
556 else{
557 esd->SetPHOSMatrix(NULL,mod) ;
558 }
559 }
560
561}
25312a8e 562//==================================================================================
563Float_t AliPHOSReconstructor::CorrectNonlinearity(Float_t en){
d3aa2291 564
81046c73 565 //For backward compatibility, if no RecoParameters found
566 if(!GetRecoParam()){
567 return 0.0241+1.0504*en+0.000249*en*en ;
568 }
569
25312a8e 570 if(strcmp(GetRecoParam()->GetNonlinearityCorrectionVersion(),"NoCorrection")==0){
571 return en ;
572 }
573 if(strcmp(GetRecoParam()->GetNonlinearityCorrectionVersion(),"Gustavo2005")==0){
574 const Float_t *par=GetRecoParam()->GetNonlinearityParams() ;
575 return par[0]+par[1]*en + par[2]*en*en ;
576 }
577 if(strcmp(GetRecoParam()->GetNonlinearityCorrectionVersion(),"Henrik2010")==0){
578 const Float_t *par=GetRecoParam()->GetNonlinearityParams() ;
579 return en*(par[0]+par[1]*TMath::Exp(-en*par[2]))*(1.+par[3]*TMath::Exp(-en*par[4]))*(1.+par[6]/(en*en+par[5])) ;
580 }
581 //For backward compatibility
582 if(strcmp(GetRecoParam()->GetNonlinearityCorrectionVersion(),"")==0){
583 return 0.0241+1.0504*en+0.000249*en*en ;
584 }
585 return en ;
586}
d3aa2291 587
e1aec4f9 588void AliPHOSReconstructor::readTRUParameters(AliPHOSTriggerParameters* parameters) const
589{
590 //Read trigger parameters.
591
592 TString path(gSystem->Getenv("ALICE_ROOT"));
593 path += "/PHOS/macros/Trigger/OCDB/";
594
595 for (Int_t mod = 2; mod < 5; ++mod) { // module
596 for (Int_t tru = 0; tru < 4; tru++) { // tru row
597 for (Int_t branch = 0; branch < 2; branch++) { // branch
598
599 // Open the Appropriate pedestal file
600 TString fileName = path;
601 fileName += "pedestal_m";
602 fileName = fileName += mod;
603 fileName+="_r";
604 fileName+=tru;
605 fileName+="_b";
606 fileName+=branch;
607 fileName+=".dat";
608 std::ifstream instream;
609 instream.open(fileName.Data());
610
611 // Read pedestals from file
612 if( ! instream.is_open() )
613 Printf("E-TRUPedestals: could not open %s", fileName.Data());
614 else
615 {
616 Int_t ped[112];
617
04f0835e 618 char ch_s[36];
e1aec4f9 619 char *ch_s_p = ch_s;
620 //Int_t nlines = 0;
621
622 Int_t t_ped_0 =0;
623 Int_t t_ped_1 =0;
624 Int_t t_ped_2 =0;
625
626 for(Int_t n=0; n<112; n++)
627 {
628 instream.getline(ch_s_p,36);
629 if (ch_s_p[23]<='9' && ch_s_p[23]>='0')
630 {
631 t_ped_0 = ch_s_p[23]-'0';
632 }
633 else if (ch_s_p[23]>='A' && ch_s_p[23]<='Z')
634 {
635 t_ped_0 = ch_s_p[23]-'A'+10;
636
637 }
638
639 if (ch_s_p[22]<='9' && ch_s_p[22]>='0')
640 {
641 t_ped_1 = ch_s_p[22]-'0';
642 }
643 else if (ch_s_p[22]<='Z' && ch_s_p[22]>='A')
644 {
645 t_ped_1 = ch_s_p[22]-'A'+10;
646 }
647
648 if (ch_s_p[21]<='9' && ch_s_p[21]>='0')
649 {
650 t_ped_2 = ch_s_p[21]-'0';
651 }
652 else if (ch_s_p[21]<='Z' && ch_s_p[21]>='A')
653 {
654 t_ped_2 = ch_s_p[21]-'A'+10;
655 }
656
657 ped[n]=t_ped_2*256+t_ped_1*16+t_ped_0;
658
659
660 }
661 for (Int_t xrow = 0; xrow < 8; xrow++){
662 for (Int_t zcol = 0; zcol < 14; zcol++){
663 Int_t pedestal = ped[zcol*8+xrow];
664
665 if( pedestal < 612 && pedestal > 412 ) // resonable
666 parameters->SetTRUPedestal(pedestal, mod, tru, branch, xrow, zcol);
667 else // unresonable
668 continue;
669 }
670 }
671 } // Ends read of pedestals from branch from file.
672 instream.close();
673 }// end branch
674 }// end tru
675
676 }// end for mod
677}
678
679
680
681