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