]>
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 | //_________________________________________________________________________ |
a3dfe79c | 19 | //*-- |
dfe0be07 | 20 | //*-- Yves Schutz (SUBATECH) |
21 | // Reconstruction class. Redesigned from the old AliReconstructionner class and | |
22 | // derived from STEER/AliReconstructor. | |
23 | // | |
d15a28e7 | 24 | // --- ROOT system --- |
25 | ||
d15a28e7 | 26 | // --- Standard library --- |
364de5c6 | 27 | |
d15a28e7 | 28 | // --- AliRoot header files --- |
9a2cdbdf | 29 | #include "AliLog.h" |
30 | #include "AliPHOSQualAssDataMaker.h" | |
af885e0f | 31 | #include "AliESDEvent.h" |
33ba95c3 | 32 | #include "AliESDCaloCluster.h" |
f444a19f | 33 | #include "AliPHOSReconstructor.h" |
7acf6008 | 34 | #include "AliPHOSClusterizerv1.h" |
7acf6008 | 35 | #include "AliPHOSTrackSegmentMakerv1.h" |
36 | #include "AliPHOSPIDv1.h" | |
23904d16 | 37 | #include "AliPHOSTracker.h" |
d22dd3b4 | 38 | #include "AliRawReader.h" |
64df000d | 39 | #include "AliPHOSTrigger.h" |
40 | #include "AliPHOSGeometry.h" | |
3799bcb5 | 41 | #include "AliPHOSRecoParamEmc.h" |
42 | #include "AliPHOSRecoParamCpv.h" | |
9a2cdbdf | 43 | #include "AliPHOSDigit.h" |
44 | #include "AliPHOSTrackSegment.h" | |
45 | #include "AliPHOSEmcRecPoint.h" | |
46 | #include "AliPHOSRecParticle.h" | |
47 | #include "AliPHOSRawDecoder.h" | |
48 | #include "AliPHOSRawDigiProducer.h" | |
49 | #include "AliPHOSPulseGenerator.h" | |
e957fea8 | 50 | |
f444a19f | 51 | ClassImp(AliPHOSReconstructor) |
d15a28e7 | 52 | |
2e60107f | 53 | Bool_t AliPHOSReconstructor::fgDebug = kFALSE ; |
3799bcb5 | 54 | AliPHOSRecoParam* AliPHOSReconstructor::fgkRecoParamEmc =0; // EMC rec. parameters |
55 | AliPHOSRecoParam* AliPHOSReconstructor::fgkRecoParamCpv =0; // CPV rec. parameters | |
2e60107f | 56 | |
d15a28e7 | 57 | //____________________________________________________________________________ |
9a2cdbdf | 58 | AliPHOSReconstructor::AliPHOSReconstructor() : |
59 | fGeom(NULL) | |
d15a28e7 | 60 | { |
b2a60966 | 61 | // ctor |
0379a13e | 62 | |
3799bcb5 | 63 | if (!fgkRecoParamEmc) { |
64 | AliWarning("The Reconstruction parameters for EMC nonitialized - Used default one"); | |
65 | fgkRecoParamEmc = AliPHOSRecoParamEmc::GetEmcDefaultParameters(); | |
66 | } | |
67 | ||
68 | if (!fgkRecoParamCpv) { | |
69 | AliWarning("The Reconstruction parameters for CPV nonitialized - Used default one"); | |
70 | fgkRecoParamCpv = AliPHOSRecoParamCpv::GetCpvDefaultParameters(); | |
71 | } | |
72 | ||
9a2cdbdf | 73 | fGeom = AliPHOSGeometry::GetInstance("IHEP",""); |
6ad0bfa0 | 74 | } |
75 | ||
0379a13e | 76 | //____________________________________________________________________________ |
77 | AliPHOSReconstructor::~AliPHOSReconstructor() | |
78 | { | |
79 | // dtor | |
9a2cdbdf | 80 | delete fGeom; |
0379a13e | 81 | } |
7acf6008 | 82 | |
7acf6008 | 83 | //____________________________________________________________________________ |
9a2cdbdf | 84 | void AliPHOSReconstructor::Reconstruct(TTree* digitsTree, TTree* clustersTree) const |
35293055 | 85 | { |
9a2cdbdf | 86 | // 'single-event' local reco method called by AliReconstruction; |
dfe0be07 | 87 | // Only the clusterization is performed,; the rest of the reconstruction is done in FillESD because the track |
af885e0f | 88 | // segment maker needs access to the AliESDEvent object to retrieve the tracks reconstructed by |
dfe0be07 | 89 | // the global tracking. |
9a2cdbdf | 90 | |
91 | AliPHOSClusterizerv1 clu(fGeom); | |
92 | clu.SetInput(digitsTree); | |
93 | clu.SetOutput(clustersTree); | |
a68156e6 | 94 | if ( Debug() ) |
9a2cdbdf | 95 | clu.Digits2Clusters("deb all") ; |
a68156e6 | 96 | else |
9a2cdbdf | 97 | clu.Digits2Clusters("") ; |
a68156e6 | 98 | } |
99 | ||
100 | //____________________________________________________________________________ | |
9a2cdbdf | 101 | void AliPHOSReconstructor::FillESD(TTree* digitsTree, TTree* clustersTree, |
102 | AliESDEvent* esd) const | |
a68156e6 | 103 | { |
9a2cdbdf | 104 | // This method produces PHOS rec-particles, |
105 | // then it creates AliESDtracks out of them and | |
106 | // write tracks to the ESD | |
107 | ||
108 | AliPHOSTrackSegmentMaker *tsm = new AliPHOSTrackSegmentMakerv1(fGeom); | |
109 | tsm->GetQualAssDataMaker()->Init(AliQualAss::kTRACKSEGMENTS) ; | |
110 | AliPHOSPID *pid = new AliPHOSPIDv1(fGeom); | |
111 | pid->GetQualAssDataMaker()->Init(AliQualAss::kRECPARTICLES) ; | |
112 | ||
113 | // do current event; the loop over events is done by AliReconstruction::Run() | |
114 | tsm->SetESD(esd) ; | |
115 | tsm->SetInput(clustersTree); | |
116 | if ( Debug() ) | |
117 | tsm->Clusters2TrackSegments("deb all") ; | |
118 | else | |
119 | tsm->Clusters2TrackSegments("") ; | |
35293055 | 120 | |
9a2cdbdf | 121 | tsm->GetQualAssDataMaker()->SetData(tsm->GetTrackSegments()) ; |
122 | tsm->GetQualAssDataMaker()->Exec(AliQualAss::kTRACKSEGMENTS) ; | |
f5eaa851 | 123 | |
9a2cdbdf | 124 | pid->SetInput(clustersTree, tsm->GetTrackSegments()) ; |
125 | pid->SetESD(esd) ; | |
dfe0be07 | 126 | if ( Debug() ) |
9a2cdbdf | 127 | pid->TrackSegments2RecParticles("deb all") ; |
dfe0be07 | 128 | else |
9a2cdbdf | 129 | pid->TrackSegments2RecParticles("") ; |
7acf6008 | 130 | |
9a2cdbdf | 131 | pid->GetQualAssDataMaker()->SetData(pid->GetRecParticles()) ; |
132 | pid->GetQualAssDataMaker()->Exec(AliQualAss::kRECPARTICLES) ; | |
133 | ||
134 | // PLEASE FIX IT. SHOULD GO TO ALIRECONSTRUCTION !! | |
135 | // if ( eventNumber == gime->MaxEvent()-1 ) { | |
136 | // fTSM->GetQualAssDataMaker()->Finish(AliQualAss::kTRACKSEGMENTS) ; | |
137 | // fPID->GetQualAssDataMaker()->Finish(AliQualAss::kRECPARTICLES) ; | |
138 | // } | |
139 | ||
23904d16 | 140 | // This function creates AliESDtracks from AliPHOSRecParticles |
141 | // and | |
142 | // writes them to the ESD | |
bf72996e | 143 | |
9a2cdbdf | 144 | TClonesArray *recParticles = pid->GetRecParticles(); |
dfe0be07 | 145 | Int_t nOfRecParticles = recParticles->GetEntries(); |
a5fa6165 | 146 | |
147 | ||
85c60a8e | 148 | esd->SetNumberOfPHOSClusters(nOfRecParticles) ; |
dd7ee508 | 149 | esd->SetFirstPHOSCluster(esd->GetNumberOfCaloClusters()) ; |
a5fa6165 | 150 | |
9a2cdbdf | 151 | AliDebug(2,Form("%d rec. particles, option %s",nOfRecParticles,GetOption())); |
8013c27e | 152 | |
64df000d | 153 | |
154 | //#########Calculate trigger and set trigger info########### | |
155 | ||
156 | AliPHOSTrigger tr ; | |
157 | // tr.SetPatchSize(1);//create 4x4 patches | |
158 | tr.Trigger(); | |
159 | ||
160 | Float_t maxAmp2x2 = tr.Get2x2MaxAmplitude(); | |
161 | Float_t maxAmpnxn = tr.GetnxnMaxAmplitude(); | |
162 | Float_t ampOutOfPatch2x2 = tr.Get2x2AmpOutOfPatch() ; | |
163 | Float_t ampOutOfPatchnxn = tr.GetnxnAmpOutOfPatch() ; | |
164 | ||
64df000d | 165 | Int_t iSM2x2 = tr.Get2x2SuperModule(); |
166 | Int_t iSMnxn = tr.GetnxnSuperModule(); | |
167 | Int_t iCrystalPhi2x2 = tr.Get2x2CrystalPhi(); | |
168 | Int_t iCrystalPhinxn = tr.GetnxnCrystalPhi(); | |
169 | Int_t iCrystalEta2x2 = tr.Get2x2CrystalEta(); | |
170 | Int_t iCrystalEtanxn = tr.GetnxnCrystalEta(); | |
171 | ||
172 | AliDebug(2, Form("Trigger 2x2 max amp %f, out amp %f, SM %d, iphi %d ieta %d", maxAmp2x2, ampOutOfPatch2x2, iSM2x2,iCrystalPhi2x2, iCrystalEta2x2)); | |
173 | AliDebug(2, Form("Trigger 4x4 max amp %f , out amp %f, SM %d, iphi %d, ieta %d", maxAmpnxn, ampOutOfPatchnxn, iSMnxn,iCrystalPhinxn, iCrystalEtanxn)); | |
174 | ||
24b8fcca | 175 | Int_t iRelId2x2 []= {iSM2x2+1,0,iCrystalPhi2x2,iCrystalEta2x2};// PHOS modules in order to calculate AbsId need to be 1-5 not 0-4 as returns trigger. |
64df000d | 176 | Int_t iAbsId2x2 =-1; |
24b8fcca | 177 | Int_t iRelIdnxn []= {iSMnxn+1,0,iCrystalPhinxn,iCrystalEtanxn};// PHOS modules in order to calculate AbsId need to be 1-5 not 0-4 as returns trigger. |
64df000d | 178 | Int_t iAbsIdnxn =-1; |
179 | TVector3 pos2x2(-1,-1,-1); | |
180 | TVector3 posnxn(-1,-1,-1); | |
9a2cdbdf | 181 | fGeom->RelToAbsNumbering(iRelId2x2, iAbsId2x2); |
182 | fGeom->RelToAbsNumbering(iRelIdnxn, iAbsIdnxn); | |
183 | fGeom->RelPosInAlice(iAbsId2x2, pos2x2); | |
184 | fGeom->RelPosInAlice(iAbsIdnxn, posnxn); | |
64df000d | 185 | |
186 | TArrayF triggerPosition(6); | |
187 | triggerPosition[0] = pos2x2(0) ; | |
188 | triggerPosition[1] = pos2x2(1) ; | |
189 | triggerPosition[2] = pos2x2(2) ; | |
190 | triggerPosition[3] = posnxn(0) ; | |
191 | triggerPosition[4] = posnxn(1) ; | |
192 | triggerPosition[5] = posnxn(2) ; | |
193 | ||
194 | TArrayF triggerAmplitudes(4); | |
195 | triggerAmplitudes[0] = maxAmp2x2 ; | |
196 | triggerAmplitudes[1] = ampOutOfPatch2x2 ; | |
197 | triggerAmplitudes[2] = maxAmpnxn ; | |
198 | triggerAmplitudes[3] = ampOutOfPatchnxn ; | |
199 | ||
200 | //esd->SetPHOSTriggerCells(triggerPosition); | |
201 | esd->AddPHOSTriggerPosition(triggerPosition); | |
202 | esd->AddPHOSTriggerAmplitudes(triggerAmplitudes); | |
203 | ||
204 | //###################################### | |
7592dfc4 | 205 | |
64df000d | 206 | //Fill CaloClusters |
f4e0dd30 | 207 | const Float_t kBigShort = std::numeric_limits<short int>::max() - 1; |
208 | const Float_t nsec100 = 1e9*100.; // units of 0.01 ns | |
209 | const Float_t gev500 = 500.; // units of GeV/500 | |
210 | ||
dfe0be07 | 211 | for (Int_t recpart = 0 ; recpart < nOfRecParticles ; recpart++) { |
212 | AliPHOSRecParticle * rp = dynamic_cast<AliPHOSRecParticle*>(recParticles->At(recpart)); | |
213 | if (Debug()) | |
214 | rp->Print(); | |
25ed816e | 215 | // Get track segment and EMC rec.point associated with this rec.particle |
9a2cdbdf | 216 | AliPHOSTrackSegment *ts = static_cast<AliPHOSTrackSegment *>(tsm->GetTrackSegments()->At(rp->GetPHOSTSIndex())); |
217 | ||
218 | // Get the clusters array | |
219 | TBranch *emcbranch = clustersTree->GetBranch("PHOSEmcRP"); | |
220 | if (!emcbranch) { | |
221 | AliError("can't get the branch with the PHOS EMC clusters !"); | |
222 | return; | |
223 | } | |
224 | TObjArray *emcRecPoints = new TObjArray(100) ; | |
225 | emcbranch->SetAddress(&emcRecPoints); | |
226 | emcbranch->GetEntry(0); | |
227 | ||
228 | AliPHOSEmcRecPoint *emcRP = static_cast<AliPHOSEmcRecPoint *>(emcRecPoints->At(ts->GetEmcIndex())); | |
25ed816e | 229 | AliESDCaloCluster *ec = new AliESDCaloCluster() ; |
7592dfc4 | 230 | |
85c60a8e | 231 | Float_t xyz[3]; |
8013c27e | 232 | for (Int_t ixyz=0; ixyz<3; ixyz++) |
233 | xyz[ixyz] = rp->GetPos()[ixyz]; | |
dd7ee508 | 234 | |
235 | AliDebug(2,Form("Global position xyz=(%f,%f,%f)",xyz[0],xyz[1],xyz[2])); | |
236 | ||
7592dfc4 | 237 | //Create digits lists |
25ed816e | 238 | Int_t digitMult = emcRP->GetDigitsMultiplicity(); |
239 | Int_t *digitsList = emcRP->GetDigitsList(); | |
7592dfc4 | 240 | Short_t *amplList = new Short_t[digitMult]; |
241 | Short_t *timeList = new Short_t[digitMult]; | |
242 | Short_t *digiList = new Short_t[digitMult]; | |
25ed816e | 243 | |
9a2cdbdf | 244 | // Read digits array |
245 | TBranch *branch = digitsTree->GetBranch("PHOS"); | |
246 | if (!branch) { | |
247 | AliError("can't get the branch with the PHOS digits !"); | |
248 | return; | |
249 | } | |
250 | TClonesArray *digitsArr = new TClonesArray("AliPHOSDigit",100); | |
251 | branch->SetAddress(&digitsArr); | |
252 | branch->GetEntry(0); | |
253 | ||
7592dfc4 | 254 | // Convert Float_t* and Int_t* to Short_t* to save memory |
25ed816e | 255 | for (Int_t iDigit=0; iDigit<digitMult; iDigit++) { |
9a2cdbdf | 256 | AliPHOSDigit *digit = static_cast<AliPHOSDigit *>(digitsArr->At(digitsList[iDigit])); |
f4e0dd30 | 257 | amplList[iDigit] = |
258 | (Short_t)(TMath::Min(digit->GetEnergy()*gev500,kBigShort)); // Energy in units of GeV/500 | |
259 | timeList[iDigit] = | |
260 | (Short_t)(TMath::Min(digit->GetTime()*nsec100,kBigShort)); // time in units of 0.01 ns | |
7592dfc4 | 261 | digiList[iDigit] = (Short_t)(digit->GetId()); |
25ed816e | 262 | } |
7592dfc4 | 263 | |
264 | //Primaries | |
265 | Int_t primMult = 0; | |
266 | Int_t *primInts = emcRP->GetPrimaries(primMult); | |
267 | Short_t *primList = new Short_t[primMult]; | |
268 | for (Int_t ipr=0; ipr<primMult; ipr++) | |
269 | primList[ipr] = (Short_t)(primInts[ipr]); | |
270 | ||
271 | // fills the ESDCaloCluster | |
272 | ||
34541ea2 | 273 | ec->SetPHOS(kTRUE); |
7592dfc4 | 274 | ec->SetPosition(xyz); //rec.point position in MARS |
275 | ec->SetE(rp->Energy()); //total particle energy | |
25ed816e | 276 | ec->SetClusterDisp(emcRP->GetDispersion()); //cluster dispersion |
277 | ec->SetPid (rp->GetPID()) ; //array of particle identification | |
25ed816e | 278 | ec->SetM02(emcRP->GetM2x()) ; //second moment M2x |
279 | ec->SetM20(emcRP->GetM2z()) ; //second moment M2z | |
280 | ec->SetNExMax(emcRP->GetNExMax()); //number of local maxima | |
25ed816e | 281 | ec->SetEmcCpvDistance(-1); //not yet implemented |
282 | ec->SetClusterChi2(-1); //not yet implemented | |
283 | ec->SetM11(-1) ; //not yet implemented | |
3744a6cf | 284 | |
7592dfc4 | 285 | //Digits Lists |
286 | TArrayS arrayAmpList(digitMult,amplList); | |
287 | TArrayS arrayTimeList(digitMult,timeList); | |
288 | TArrayS arrayIndexList(digitMult,digiList); | |
289 | ec->AddDigitAmplitude(arrayAmpList); | |
290 | ec->AddDigitTime(arrayTimeList); | |
291 | ec->AddDigitIndex(arrayIndexList); | |
292 | ||
3744a6cf | 293 | //Distance to the nearest bad crystal |
294 | ec->SetDistanceToBadChannel(emcRP->GetDistanceToBadCrystal()); | |
7592dfc4 | 295 | |
296 | //Array of MC indeces | |
297 | TArrayS arrayPrim(primMult,primList); | |
298 | ec->AddLabels(arrayPrim); | |
299 | ||
300 | //Array of tracks uncomment when available in future | |
301 | //TArrayS arrayTrackMatched(1);// Only one track, temporal solution. | |
302 | //arrayTrackMatched[0]= (Short_t)(matchedTrack[iClust]); | |
303 | //ec->AddTracksMatched(arrayTrackMatched); | |
64df000d | 304 | |
dfe0be07 | 305 | // add the track to the esd object |
85c60a8e | 306 | esd->AddCaloCluster(ec); |
9a2cdbdf | 307 | delete ec; |
308 | delete [] primList; | |
309 | delete [] amplList; | |
310 | delete [] timeList; | |
311 | delete [] digiList; | |
dd7ee508 | 312 | } |
313 | } | |
314 | ||
9a2cdbdf | 315 | AliTracker* AliPHOSReconstructor::CreateTracker(AliRunLoader* /* runLoader */) const |
dd7ee508 | 316 | { |
9a2cdbdf | 317 | // creates the PHOS tracker |
318 | return new AliPHOSTracker(); | |
319 | } | |
dd7ee508 | 320 | |
9a2cdbdf | 321 | void AliPHOSReconstructor::ConvertDigits(AliRawReader* rawReader, TTree* digitsTree) const |
322 | { | |
323 | // Converts raw data to | |
324 | // PHOS digits | |
325 | // Works on a single-event basis | |
dd7ee508 | 326 | |
9a2cdbdf | 327 | rawReader->Reset() ; |
dd7ee508 | 328 | |
9a2cdbdf | 329 | AliPHOSRawDecoder dc(rawReader); |
330 | TString option = GetOption(); | |
331 | if (option.Contains("OldRCUFormat")) | |
332 | dc.SetOldRCUFormat(kTRUE); | |
333 | else | |
334 | dc.SetOldRCUFormat(kFALSE); | |
dd7ee508 | 335 | |
9a2cdbdf | 336 | dc.SubtractPedestals(kTRUE); |
dd7ee508 | 337 | |
9a2cdbdf | 338 | TClonesArray *digits = new TClonesArray("AliPHOSDigit",1); |
339 | digits->SetName("DIGITS"); | |
340 | Int_t bufsize = 32000; | |
341 | digitsTree->Branch("PHOS", &digits, bufsize); | |
dd7ee508 | 342 | |
9a2cdbdf | 343 | AliPHOSRawDigiProducer pr; |
344 | pr.MakeDigits(digits,&dc); | |
7592dfc4 | 345 | |
9a2cdbdf | 346 | //ADC counts -> GeV |
347 | for(Int_t i=0; i<digits->GetEntries(); i++) { | |
348 | AliPHOSDigit* digit = (AliPHOSDigit*)digits->At(i); | |
349 | digit->SetEnergy(digit->GetEnergy()/AliPHOSPulseGenerator::GeV2ADC()); | |
350 | } | |
351 | ||
352 | //!!!!for debug!!! | |
353 | Int_t modMax=-111; | |
354 | Int_t colMax=-111; | |
355 | Int_t rowMax=-111; | |
356 | Float_t eMax=-333; | |
357 | //!!!for debug!!! | |
358 | ||
359 | Int_t relId[4]; | |
360 | for(Int_t iDigit=0; iDigit<digits->GetEntries(); iDigit++) { | |
361 | AliPHOSDigit* digit = (AliPHOSDigit*)digits->At(iDigit); | |
362 | if(digit->GetEnergy()>eMax) { | |
363 | fGeom->AbsToRelNumbering(digit->GetId(),relId); | |
364 | eMax=digit->GetEnergy(); | |
365 | modMax=relId[0]; | |
366 | rowMax=relId[2]; | |
367 | colMax=relId[3]; | |
dd7ee508 | 368 | } |
369 | } | |
370 | ||
9a2cdbdf | 371 | AliDebug(1,Form("Digit with max. energy: modMax %d colMax %d rowMax %d eMax %f\n\n", |
372 | modMax,colMax,rowMax,eMax)); | |
dd7ee508 | 373 | |
9a2cdbdf | 374 | digitsTree->Fill(); |
d7d3b67b | 375 | } |