]>
Commit | Line | Data |
---|---|---|
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 --- |
00cfce1d | 25 | |
d15a28e7 | 26 | // --- Standard library --- |
364de5c6 | 27 | |
d15a28e7 | 28 | // --- AliRoot header files --- |
9a2cdbdf | 29 | #include "AliLog.h" |
b3006690 | 30 | #include "AliAltroMapping.h" |
af885e0f | 31 | #include "AliESDEvent.h" |
33ba95c3 | 32 | #include "AliESDCaloCluster.h" |
a5e00016 | 33 | #include "AliESDCaloCells.h" |
f444a19f | 34 | #include "AliPHOSReconstructor.h" |
7acf6008 | 35 | #include "AliPHOSClusterizerv1.h" |
7acf6008 | 36 | #include "AliPHOSTrackSegmentMakerv1.h" |
37 | #include "AliPHOSPIDv1.h" | |
23904d16 | 38 | #include "AliPHOSTracker.h" |
d22dd3b4 | 39 | #include "AliRawReader.h" |
7e88424f | 40 | #include "AliCDBEntry.h" |
41 | #include "AliCDBManager.h" | |
64df000d | 42 | #include "AliPHOSTrigger.h" |
43 | #include "AliPHOSGeometry.h" | |
9a2cdbdf | 44 | #include "AliPHOSDigit.h" |
45 | #include "AliPHOSTrackSegment.h" | |
46 | #include "AliPHOSEmcRecPoint.h" | |
47 | #include "AliPHOSRecParticle.h" | |
48 | #include "AliPHOSRawDecoder.h" | |
77ea1c6f | 49 | #include "AliPHOSRawDecoderv1.h" |
710634f4 | 50 | #include "AliPHOSRawDecoderv2.h" |
9a2cdbdf | 51 | #include "AliPHOSRawDigiProducer.h" |
52 | #include "AliPHOSPulseGenerator.h" | |
e957fea8 | 53 | |
f444a19f | 54 | ClassImp(AliPHOSReconstructor) |
d15a28e7 | 55 | |
2e60107f | 56 | Bool_t AliPHOSReconstructor::fgDebug = kFALSE ; |
6483babc | 57 | TClonesArray* AliPHOSReconstructor::fgDigitsArray = 0; // Array of PHOS digits |
58 | TObjArray* AliPHOSReconstructor::fgEMCRecPoints = 0; // Array of EMC rec.points | |
2e60107f | 59 | |
d15a28e7 | 60 | //____________________________________________________________________________ |
9a2cdbdf | 61 | AliPHOSReconstructor::AliPHOSReconstructor() : |
dcab1c7e | 62 | fGeom(NULL),fClusterizer(NULL),fTSM(NULL),fPID(NULL) |
d15a28e7 | 63 | { |
b2a60966 | 64 | // ctor |
8d8258f6 | 65 | fGeom = AliPHOSGeometry::GetInstance("IHEP",""); |
dcab1c7e | 66 | fClusterizer = new AliPHOSClusterizerv1 (fGeom); |
67 | fTSM = new AliPHOSTrackSegmentMakerv1(fGeom); | |
68 | fPID = new AliPHOSPIDv1 (fGeom); | |
6483babc | 69 | fgDigitsArray = new TClonesArray("AliPHOSDigit",100); |
70 | fgEMCRecPoints= new TObjArray(100) ; | |
e68222ce | 71 | } |
6ad0bfa0 | 72 | |
0379a13e | 73 | //____________________________________________________________________________ |
74 | AliPHOSReconstructor::~AliPHOSReconstructor() | |
75 | { | |
76 | // dtor | |
9a2cdbdf | 77 | delete fGeom; |
8d8258f6 | 78 | delete fClusterizer; |
dcab1c7e | 79 | delete fTSM; |
80 | delete fPID; | |
6483babc | 81 | delete fgDigitsArray; |
82 | delete fgEMCRecPoints; | |
0379a13e | 83 | } |
7acf6008 | 84 | |
7acf6008 | 85 | //____________________________________________________________________________ |
9a2cdbdf | 86 | void AliPHOSReconstructor::Reconstruct(TTree* digitsTree, TTree* clustersTree) const |
35293055 | 87 | { |
9a2cdbdf | 88 | // 'single-event' local reco method called by AliReconstruction; |
dfe0be07 | 89 | // Only the clusterization is performed,; the rest of the reconstruction is done in FillESD because the track |
af885e0f | 90 | // segment maker needs access to the AliESDEvent object to retrieve the tracks reconstructed by |
dfe0be07 | 91 | // the global tracking. |
9a2cdbdf | 92 | |
7e88424f | 93 | fClusterizer->InitParameters(); |
8d8258f6 | 94 | fClusterizer->SetInput(digitsTree); |
95 | fClusterizer->SetOutput(clustersTree); | |
a68156e6 | 96 | if ( Debug() ) |
8d8258f6 | 97 | fClusterizer->Digits2Clusters("deb all") ; |
a68156e6 | 98 | else |
8d8258f6 | 99 | fClusterizer->Digits2Clusters("") ; |
a68156e6 | 100 | } |
101 | ||
102 | //____________________________________________________________________________ | |
9a2cdbdf | 103 | void AliPHOSReconstructor::FillESD(TTree* digitsTree, TTree* clustersTree, |
104 | AliESDEvent* esd) const | |
a68156e6 | 105 | { |
9a2cdbdf | 106 | // This method produces PHOS rec-particles, |
107 | // then it creates AliESDtracks out of them and | |
108 | // write tracks to the ESD | |
109 | ||
e68222ce | 110 | |
9a2cdbdf | 111 | // do current event; the loop over events is done by AliReconstruction::Run() |
dcab1c7e | 112 | fTSM->SetESD(esd) ; |
113 | fTSM->SetInput(clustersTree); | |
9a2cdbdf | 114 | if ( Debug() ) |
dcab1c7e | 115 | fTSM->Clusters2TrackSegments("deb all") ; |
9a2cdbdf | 116 | else |
dcab1c7e | 117 | fTSM->Clusters2TrackSegments("") ; |
35293055 | 118 | |
71994f35 | 119 | fPID->SetEnergyCorrectionOn(GetRecoParam()->GetEMCEnergyCorrectionOn()); |
120 | ||
dcab1c7e | 121 | fPID->SetInput(clustersTree, fTSM->GetTrackSegments()) ; |
122 | fPID->SetESD(esd) ; | |
dfe0be07 | 123 | if ( Debug() ) |
dcab1c7e | 124 | fPID->TrackSegments2RecParticles("deb all") ; |
dfe0be07 | 125 | else |
dcab1c7e | 126 | fPID->TrackSegments2RecParticles("") ; |
7acf6008 | 127 | |
dcab1c7e | 128 | TClonesArray *recParticles = fPID->GetRecParticles(); |
129 | Int_t nOfRecParticles = recParticles->GetEntriesFast(); | |
a5fa6165 | 130 | |
85c60a8e | 131 | esd->SetNumberOfPHOSClusters(nOfRecParticles) ; |
dd7ee508 | 132 | esd->SetFirstPHOSCluster(esd->GetNumberOfCaloClusters()) ; |
a5e00016 | 133 | |
9a2cdbdf | 134 | AliDebug(2,Form("%d rec. particles, option %s",nOfRecParticles,GetOption())); |
a5e00016 | 135 | |
136 | // Read digits array | |
137 | ||
138 | TBranch *branch = digitsTree->GetBranch("PHOS"); | |
139 | if (!branch) { | |
140 | AliError("can't get the branch with the PHOS digits !"); | |
141 | return; | |
142 | } | |
6483babc | 143 | branch->SetAddress(&fgDigitsArray); |
a5e00016 | 144 | branch->GetEntry(0); |
145 | ||
146 | // Get the clusters array | |
147 | ||
148 | TBranch *emcbranch = clustersTree->GetBranch("PHOSEmcRP"); | |
149 | if (!emcbranch) { | |
150 | AliError("can't get the branch with the PHOS EMC clusters !"); | |
151 | return; | |
152 | } | |
153 | ||
6483babc | 154 | emcbranch->SetAddress(&fgEMCRecPoints); |
a5e00016 | 155 | emcbranch->GetEntry(0); |
8013c27e | 156 | |
64df000d | 157 | //#########Calculate trigger and set trigger info########### |
a5e00016 | 158 | |
64df000d | 159 | AliPHOSTrigger tr ; |
160 | // tr.SetPatchSize(1);//create 4x4 patches | |
bfae5a5d | 161 | tr.SetSimulation(kFALSE); |
6483babc | 162 | tr.Trigger(fgDigitsArray); |
64df000d | 163 | |
164 | Float_t maxAmp2x2 = tr.Get2x2MaxAmplitude(); | |
165 | Float_t maxAmpnxn = tr.GetnxnMaxAmplitude(); | |
166 | Float_t ampOutOfPatch2x2 = tr.Get2x2AmpOutOfPatch() ; | |
167 | Float_t ampOutOfPatchnxn = tr.GetnxnAmpOutOfPatch() ; | |
168 | ||
64df000d | 169 | Int_t iSM2x2 = tr.Get2x2SuperModule(); |
170 | Int_t iSMnxn = tr.GetnxnSuperModule(); | |
171 | Int_t iCrystalPhi2x2 = tr.Get2x2CrystalPhi(); | |
172 | Int_t iCrystalPhinxn = tr.GetnxnCrystalPhi(); | |
173 | Int_t iCrystalEta2x2 = tr.Get2x2CrystalEta(); | |
174 | Int_t iCrystalEtanxn = tr.GetnxnCrystalEta(); | |
175 | ||
a5e00016 | 176 | AliDebug(2, Form("Trigger 2x2 max amp %f, out amp %f, SM %d, iphi %d ieta %d", |
177 | maxAmp2x2, ampOutOfPatch2x2, iSM2x2,iCrystalPhi2x2, iCrystalEta2x2)); | |
178 | AliDebug(2, Form("Trigger 4x4 max amp %f , out amp %f, SM %d, iphi %d, ieta %d", | |
179 | maxAmpnxn, ampOutOfPatchnxn, iSMnxn,iCrystalPhinxn, iCrystalEtanxn)); | |
64df000d | 180 | |
bfae5a5d | 181 | // Attention! PHOS modules in order to calculate AbsId need to be 1-5 not 0-4 as returns trigger. |
182 | Int_t iRelId2x2 []= {iSM2x2+1,0,iCrystalPhi2x2,iCrystalEta2x2}; | |
64df000d | 183 | Int_t iAbsId2x2 =-1; |
bfae5a5d | 184 | Int_t iRelIdnxn []= {iSMnxn+1,0,iCrystalPhinxn,iCrystalEtanxn}; |
64df000d | 185 | Int_t iAbsIdnxn =-1; |
186 | TVector3 pos2x2(-1,-1,-1); | |
187 | TVector3 posnxn(-1,-1,-1); | |
9a2cdbdf | 188 | fGeom->RelToAbsNumbering(iRelId2x2, iAbsId2x2); |
189 | fGeom->RelToAbsNumbering(iRelIdnxn, iAbsIdnxn); | |
190 | fGeom->RelPosInAlice(iAbsId2x2, pos2x2); | |
191 | fGeom->RelPosInAlice(iAbsIdnxn, posnxn); | |
64df000d | 192 | |
193 | TArrayF triggerPosition(6); | |
194 | triggerPosition[0] = pos2x2(0) ; | |
195 | triggerPosition[1] = pos2x2(1) ; | |
196 | triggerPosition[2] = pos2x2(2) ; | |
197 | triggerPosition[3] = posnxn(0) ; | |
198 | triggerPosition[4] = posnxn(1) ; | |
199 | triggerPosition[5] = posnxn(2) ; | |
200 | ||
201 | TArrayF triggerAmplitudes(4); | |
202 | triggerAmplitudes[0] = maxAmp2x2 ; | |
203 | triggerAmplitudes[1] = ampOutOfPatch2x2 ; | |
204 | triggerAmplitudes[2] = maxAmpnxn ; | |
205 | triggerAmplitudes[3] = ampOutOfPatchnxn ; | |
206 | ||
207 | //esd->SetPHOSTriggerCells(triggerPosition); | |
208 | esd->AddPHOSTriggerPosition(triggerPosition); | |
209 | esd->AddPHOSTriggerAmplitudes(triggerAmplitudes); | |
210 | ||
e68222ce | 211 | |
a5e00016 | 212 | //######################################## |
213 | //############# Fill CaloCells ########### | |
214 | //######################################## | |
215 | ||
6483babc | 216 | Int_t nDigits = fgDigitsArray->GetEntries(); |
a5e00016 | 217 | Int_t idignew = 0 ; |
218 | AliDebug(1,Form("%d digits",nDigits)); | |
219 | ||
220 | const Int_t knEMC = fGeom->GetNModules()*fGeom->GetNPhi()*fGeom->GetNZ(); | |
221 | AliESDCaloCells &phsCells = *(esd->GetPHOSCells()); | |
222 | phsCells.CreateContainer(nDigits); | |
223 | phsCells.SetType(AliESDCaloCells::kPHOSCell); | |
224 | ||
225 | // Add to CaloCells only EMC digits with non-zero energy | |
226 | for (Int_t idig = 0 ; idig < nDigits ; idig++) { | |
6483babc | 227 | const AliPHOSDigit * dig = (const AliPHOSDigit*)fgDigitsArray->At(idig); |
0428f331 | 228 | if(dig->GetId() <= knEMC && dig->GetEnergy() > GetRecoParam()->GetEMCMinE() ){ |
710634f4 | 229 | //printf("i %d; id %d; amp %f; time %e\n", |
230 | //idignew,dig->GetId(),dig->GetEnergy(), dig->GetTime()); | |
a5e00016 | 231 | phsCells.SetCell(idignew,dig->GetId(), dig->GetEnergy(), dig->GetTime()); |
232 | idignew++; | |
233 | } | |
e68222ce | 234 | } |
a5e00016 | 235 | phsCells.SetNumberOfCells(idignew); |
236 | phsCells.Sort(); | |
e68222ce | 237 | |
a5e00016 | 238 | //######################################## |
239 | //############## Fill CaloClusters ####### | |
240 | //######################################## | |
f4e0dd30 | 241 | |
dfe0be07 | 242 | for (Int_t recpart = 0 ; recpart < nOfRecParticles ; recpart++) { |
a5e00016 | 243 | AliPHOSRecParticle *rp = dynamic_cast<AliPHOSRecParticle*>(recParticles->At(recpart)); |
dfe0be07 | 244 | if (Debug()) |
245 | rp->Print(); | |
25ed816e | 246 | // Get track segment and EMC rec.point associated with this rec.particle |
dcab1c7e | 247 | AliPHOSTrackSegment *ts = static_cast<AliPHOSTrackSegment *>(fTSM->GetTrackSegments() |
a5e00016 | 248 | ->At(rp->GetPHOSTSIndex())); |
9a2cdbdf | 249 | |
6483babc | 250 | AliPHOSEmcRecPoint *emcRP = static_cast<AliPHOSEmcRecPoint *>(fgEMCRecPoints->At(ts->GetEmcIndex())); |
25ed816e | 251 | AliESDCaloCluster *ec = new AliESDCaloCluster() ; |
e68222ce | 252 | |
85c60a8e | 253 | Float_t xyz[3]; |
8013c27e | 254 | for (Int_t ixyz=0; ixyz<3; ixyz++) |
255 | xyz[ixyz] = rp->GetPos()[ixyz]; | |
dd7ee508 | 256 | |
257 | AliDebug(2,Form("Global position xyz=(%f,%f,%f)",xyz[0],xyz[1],xyz[2])); | |
77ea1c6f | 258 | |
a5e00016 | 259 | // Create cell lists |
260 | ||
261 | Int_t cellMult = emcRP->GetDigitsMultiplicity(); | |
262 | Int_t *digitsList = emcRP->GetDigitsList(); | |
263 | Float_t *rpElist = emcRP->GetEnergiesList() ; | |
264 | UShort_t *absIdList = new UShort_t[cellMult]; | |
265 | Double_t *fracList = new Double_t[cellMult]; | |
266 | ||
267 | for (Int_t iCell=0; iCell<cellMult; iCell++) { | |
6483babc | 268 | AliPHOSDigit *digit = static_cast<AliPHOSDigit *>(fgDigitsArray->At(digitsList[iCell])); |
a5e00016 | 269 | absIdList[iCell] = (UShort_t)(digit->GetId()); |
270 | if (digit->GetEnergy() > 0) | |
271 | fracList[iCell] = rpElist[iCell]/digit->GetEnergy(); | |
272 | else | |
273 | fracList[iCell] = 0; | |
25ed816e | 274 | } |
77ea1c6f | 275 | |
7592dfc4 | 276 | //Primaries |
277 | Int_t primMult = 0; | |
4dd59c4a | 278 | Int_t *primList = emcRP->GetPrimaries(primMult); |
a5e00016 | 279 | |
48c5db5b | 280 | Float_t energy; |
7e88424f | 281 | if (GetRecoParam()->EMCEcore2ESD()) |
48c5db5b | 282 | energy = emcRP->GetCoreEnergy(); |
283 | else | |
284 | energy = rp->Energy(); | |
285 | ||
7592dfc4 | 286 | // fills the ESDCaloCluster |
8ada0ffe | 287 | ec->SetClusterType(AliESDCaloCluster::kPHOSCluster); |
a5e00016 | 288 | ec->SetPosition(xyz); //rec.point position in MARS |
48c5db5b | 289 | ec->SetE(energy); //total or core particle energy |
25ed816e | 290 | ec->SetClusterDisp(emcRP->GetDispersion()); //cluster dispersion |
e68222ce | 291 | ec->SetPid(rp->GetPID()) ; //array of particle identification |
25ed816e | 292 | ec->SetM02(emcRP->GetM2x()) ; //second moment M2x |
293 | ec->SetM20(emcRP->GetM2z()) ; //second moment M2z | |
294 | ec->SetNExMax(emcRP->GetNExMax()); //number of local maxima | |
a5e00016 | 295 | ec->SetEmcCpvDistance(ts->GetCpvDistance("r")); //Only radius, what about separate x,z???? |
25ed816e | 296 | ec->SetClusterChi2(-1); //not yet implemented |
78902954 | 297 | ec->SetTOF(emcRP->GetTime()); //Time of flight |
298 | ||
a5e00016 | 299 | //Cells contributing to clusters |
300 | ec->SetNCells(cellMult); | |
301 | ec->SetCellsAbsId(absIdList); | |
302 | ec->SetCellsAmplitudeFraction(fracList); | |
7592dfc4 | 303 | |
3744a6cf | 304 | //Distance to the nearest bad crystal |
305 | ec->SetDistanceToBadChannel(emcRP->GetDistanceToBadCrystal()); | |
7592dfc4 | 306 | |
307 | //Array of MC indeces | |
4dd59c4a | 308 | TArrayI arrayPrim(primMult,primList); |
7592dfc4 | 309 | ec->AddLabels(arrayPrim); |
64df000d | 310 | |
e44c41e9 | 311 | //Matched ESD track |
312 | TArrayI arrayTrackMatched(1); | |
313 | arrayTrackMatched[0]= ts->GetTrackIndex(); | |
314 | ec->AddTracksMatched(arrayTrackMatched); | |
315 | ||
85c60a8e | 316 | esd->AddCaloCluster(ec); |
9a2cdbdf | 317 | delete ec; |
091d150a | 318 | delete [] fracList; |
319 | delete [] absIdList; | |
e68222ce | 320 | } |
6483babc | 321 | fgDigitsArray ->Delete(); |
322 | fgEMCRecPoints->Delete(); | |
323 | recParticles ->Delete(); | |
dd7ee508 | 324 | } |
325 | ||
e68222ce | 326 | //____________________________________________________________________________ |
d76c31f4 | 327 | AliTracker* AliPHOSReconstructor::CreateTracker() const |
dd7ee508 | 328 | { |
9a2cdbdf | 329 | // creates the PHOS tracker |
330 | return new AliPHOSTracker(); | |
331 | } | |
dd7ee508 | 332 | |
1267d56d | 333 | //____________________________________________________________________________ |
9a2cdbdf | 334 | void AliPHOSReconstructor::ConvertDigits(AliRawReader* rawReader, TTree* digitsTree) const |
335 | { | |
336 | // Converts raw data to | |
337 | // PHOS digits | |
338 | // Works on a single-event basis | |
9a2cdbdf | 339 | rawReader->Reset() ; |
dd7ee508 | 340 | |
77ea1c6f | 341 | AliPHOSRawDecoder * dc ; |
342 | ||
7e88424f | 343 | const TObjArray* maps = AliPHOSRecoParam::GetMappings(); |
b3006690 | 344 | if(!maps) AliFatal("Cannot retrieve ALTRO mappings!!"); |
345 | ||
346 | AliAltroMapping *mapping[4]; | |
347 | for(Int_t i = 0; i < 4; i++) { | |
348 | mapping[i] = (AliAltroMapping*)maps->At(i); | |
349 | } | |
350 | ||
7e88424f | 351 | if (strcmp(GetRecoParam()->EMCDecoderVersion(),"v1")==0) |
b3006690 | 352 | dc=new AliPHOSRawDecoderv1(rawReader,mapping); |
7e88424f | 353 | else if (strcmp(GetRecoParam()->EMCDecoderVersion(),"v2")==0) |
354 | dc=new AliPHOSRawDecoderv2(rawReader,mapping); | |
355 | else | |
356 | dc=new AliPHOSRawDecoder(rawReader,mapping); | |
77ea1c6f | 357 | |
7e88424f | 358 | dc->SubtractPedestals(GetRecoParam()->EMCSubtractPedestals()); |
86121c91 | 359 | |
9a2cdbdf | 360 | TClonesArray *digits = new TClonesArray("AliPHOSDigit",1); |
361 | digits->SetName("DIGITS"); | |
362 | Int_t bufsize = 32000; | |
363 | digitsTree->Branch("PHOS", &digits, bufsize); | |
dd7ee508 | 364 | |
7e88424f | 365 | AliPHOSRawDigiProducer pr(GetRecoParam()); |
77ea1c6f | 366 | pr.MakeDigits(digits,dc); |
367 | ||
368 | delete dc ; | |
7592dfc4 | 369 | |
9a2cdbdf | 370 | //!!!!for debug!!! |
a28333c5 | 371 | /* |
9a2cdbdf | 372 | Int_t modMax=-111; |
373 | Int_t colMax=-111; | |
374 | Int_t rowMax=-111; | |
375 | Float_t eMax=-333; | |
376 | //!!!for debug!!! | |
377 | ||
378 | Int_t relId[4]; | |
379 | for(Int_t iDigit=0; iDigit<digits->GetEntries(); iDigit++) { | |
380 | AliPHOSDigit* digit = (AliPHOSDigit*)digits->At(iDigit); | |
381 | if(digit->GetEnergy()>eMax) { | |
382 | fGeom->AbsToRelNumbering(digit->GetId(),relId); | |
383 | eMax=digit->GetEnergy(); | |
384 | modMax=relId[0]; | |
385 | rowMax=relId[2]; | |
386 | colMax=relId[3]; | |
dd7ee508 | 387 | } |
388 | } | |
389 | ||
9a2cdbdf | 390 | AliDebug(1,Form("Digit with max. energy: modMax %d colMax %d rowMax %d eMax %f\n\n", |
391 | modMax,colMax,rowMax,eMax)); | |
a28333c5 | 392 | */ |
9a2cdbdf | 393 | digitsTree->Fill(); |
e68222ce | 394 | digits->Delete(); |
395 | delete digits; | |
d7d3b67b | 396 | } |