]>
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 --- |
af885e0f | 29 | #include "AliESDEvent.h" |
f444a19f | 30 | #include "AliPHOSReconstructor.h" |
7acf6008 | 31 | #include "AliPHOSClusterizerv1.h" |
7acf6008 | 32 | #include "AliPHOSTrackSegmentMakerv1.h" |
33 | #include "AliPHOSPIDv1.h" | |
35293055 | 34 | #include "AliPHOSGetter.h" |
23904d16 | 35 | #include "AliPHOSTracker.h" |
d22dd3b4 | 36 | #include "AliRawReader.h" |
64df000d | 37 | #include "AliPHOSTrigger.h" |
38 | #include "AliPHOSGeometry.h" | |
e957fea8 | 39 | |
f444a19f | 40 | ClassImp(AliPHOSReconstructor) |
d15a28e7 | 41 | |
2e60107f | 42 | Bool_t AliPHOSReconstructor::fgDebug = kFALSE ; |
43 | ||
d15a28e7 | 44 | //____________________________________________________________________________ |
2e60107f | 45 | AliPHOSReconstructor::AliPHOSReconstructor() |
d15a28e7 | 46 | { |
b2a60966 | 47 | // ctor |
0379a13e | 48 | |
6ad0bfa0 | 49 | } |
50 | ||
0379a13e | 51 | //____________________________________________________________________________ |
52 | AliPHOSReconstructor::~AliPHOSReconstructor() | |
53 | { | |
54 | // dtor | |
55 | ||
56 | } | |
7acf6008 | 57 | |
7acf6008 | 58 | //____________________________________________________________________________ |
772634e0 | 59 | void AliPHOSReconstructor::Reconstruct(AliRunLoader* runLoader) const |
35293055 | 60 | { |
dfe0be07 | 61 | // method called by AliReconstruction; |
62 | // Only the clusterization is performed,; the rest of the reconstruction is done in FillESD because the track | |
af885e0f | 63 | // segment maker needs access to the AliESDEvent object to retrieve the tracks reconstructed by |
dfe0be07 | 64 | // the global tracking. |
65 | ||
66 | TString headerFile(runLoader->GetFileName()) ; | |
9ee4fde2 | 67 | TString branchName(runLoader->GetEventFolder()->GetName()) ; |
a68156e6 | 68 | |
69 | AliPHOSClusterizerv1 clu(headerFile, branchName); | |
70 | clu.SetEventRange(0, -1) ; // do all the events | |
71 | if ( Debug() ) | |
72 | clu.ExecuteTask("deb all") ; | |
73 | else | |
74 | clu.ExecuteTask("") ; | |
75 | ||
76 | } | |
77 | ||
78 | //____________________________________________________________________________ | |
772634e0 | 79 | void AliPHOSReconstructor::Reconstruct(AliRunLoader* runLoader, AliRawReader* rawreader) const |
a68156e6 | 80 | { |
81 | // method called by AliReconstruction; | |
82 | // Only the clusterization is performed,; the rest of the reconstruction is done in FillESD because the track | |
af885e0f | 83 | // segment maker needs access to the AliESDEvent object to retrieve the tracks reconstructed by |
a68156e6 | 84 | // the global tracking. |
85 | // Here we reconstruct from Raw Data | |
772634e0 | 86 | |
a68156e6 | 87 | rawreader->Reset() ; |
88 | TString headerFile(runLoader->GetFileName()) ; | |
89 | TString branchName(runLoader->GetEventFolder()->GetName()) ; | |
35293055 | 90 | |
dfe0be07 | 91 | AliPHOSClusterizerv1 clu(headerFile, branchName); |
f88e2313 | 92 | clu.SetEventRange(0, -1) ; // do all the events |
d22dd3b4 | 93 | clu.SetRawReader(rawreader); |
f5eaa851 | 94 | |
95 | TString option = GetOption(); | |
96 | if (option.Contains("OldRCUFormat")) | |
97 | clu.SetOldRCUFormat(kTRUE); | |
98 | ||
dfe0be07 | 99 | if ( Debug() ) |
100 | clu.ExecuteTask("deb all") ; | |
101 | else | |
d22dd3b4 | 102 | clu.ExecuteTask("") ; |
0379a13e | 103 | |
35293055 | 104 | } |
7acf6008 | 105 | |
7acf6008 | 106 | //____________________________________________________________________________ |
af885e0f | 107 | void AliPHOSReconstructor::FillESD(AliRunLoader* runLoader, AliESDEvent* esd) const |
7acf6008 | 108 | { |
23904d16 | 109 | // This function creates AliESDtracks from AliPHOSRecParticles |
110 | // and | |
111 | // writes them to the ESD | |
bf72996e | 112 | |
23904d16 | 113 | Int_t eventNumber = runLoader->GetEventNumber() ; |
dfe0be07 | 114 | |
25ed816e | 115 | AliPHOSGetter *gime = AliPHOSGetter::Instance(); |
116 | gime->Event(eventNumber, "DRTP") ; | |
117 | TClonesArray *recParticles = gime->RecParticles(); | |
dfe0be07 | 118 | Int_t nOfRecParticles = recParticles->GetEntries(); |
25ed816e | 119 | |
85c60a8e | 120 | esd->SetNumberOfPHOSClusters(nOfRecParticles) ; |
dd7ee508 | 121 | esd->SetFirstPHOSCluster(esd->GetNumberOfCaloClusters()) ; |
122 | ||
123 | AliDebug(2,Form("%d digits and %d rec. particles in event %d, option %s",gime->Digits()->GetEntries(),nOfRecParticles,eventNumber,GetOption())); | |
8013c27e | 124 | |
64df000d | 125 | |
126 | //#########Calculate trigger and set trigger info########### | |
127 | ||
128 | AliPHOSTrigger tr ; | |
129 | // tr.SetPatchSize(1);//create 4x4 patches | |
130 | tr.Trigger(); | |
131 | ||
132 | Float_t maxAmp2x2 = tr.Get2x2MaxAmplitude(); | |
133 | Float_t maxAmpnxn = tr.GetnxnMaxAmplitude(); | |
134 | Float_t ampOutOfPatch2x2 = tr.Get2x2AmpOutOfPatch() ; | |
135 | Float_t ampOutOfPatchnxn = tr.GetnxnAmpOutOfPatch() ; | |
136 | ||
137 | AliPHOSGeometry * geom = gime->PHOSGeometry(); | |
138 | ||
139 | Int_t iSM2x2 = tr.Get2x2SuperModule(); | |
140 | Int_t iSMnxn = tr.GetnxnSuperModule(); | |
141 | Int_t iCrystalPhi2x2 = tr.Get2x2CrystalPhi(); | |
142 | Int_t iCrystalPhinxn = tr.GetnxnCrystalPhi(); | |
143 | Int_t iCrystalEta2x2 = tr.Get2x2CrystalEta(); | |
144 | Int_t iCrystalEtanxn = tr.GetnxnCrystalEta(); | |
145 | ||
146 | AliDebug(2, Form("Trigger 2x2 max amp %f, out amp %f, SM %d, iphi %d ieta %d", maxAmp2x2, ampOutOfPatch2x2, iSM2x2,iCrystalPhi2x2, iCrystalEta2x2)); | |
147 | AliDebug(2, Form("Trigger 4x4 max amp %f , out amp %f, SM %d, iphi %d, ieta %d", maxAmpnxn, ampOutOfPatchnxn, iSMnxn,iCrystalPhinxn, iCrystalEtanxn)); | |
148 | ||
24b8fcca | 149 | 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 | 150 | Int_t iAbsId2x2 =-1; |
24b8fcca | 151 | 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 | 152 | Int_t iAbsIdnxn =-1; |
153 | TVector3 pos2x2(-1,-1,-1); | |
154 | TVector3 posnxn(-1,-1,-1); | |
155 | geom->RelToAbsNumbering(iRelId2x2, iAbsId2x2); | |
156 | geom->RelToAbsNumbering(iRelIdnxn, iAbsIdnxn); | |
157 | geom->RelPosInAlice(iAbsId2x2, pos2x2); | |
158 | geom->RelPosInAlice(iAbsIdnxn, posnxn); | |
159 | ||
160 | TArrayF triggerPosition(6); | |
161 | triggerPosition[0] = pos2x2(0) ; | |
162 | triggerPosition[1] = pos2x2(1) ; | |
163 | triggerPosition[2] = pos2x2(2) ; | |
164 | triggerPosition[3] = posnxn(0) ; | |
165 | triggerPosition[4] = posnxn(1) ; | |
166 | triggerPosition[5] = posnxn(2) ; | |
167 | ||
168 | TArrayF triggerAmplitudes(4); | |
169 | triggerAmplitudes[0] = maxAmp2x2 ; | |
170 | triggerAmplitudes[1] = ampOutOfPatch2x2 ; | |
171 | triggerAmplitudes[2] = maxAmpnxn ; | |
172 | triggerAmplitudes[3] = ampOutOfPatchnxn ; | |
173 | ||
174 | //esd->SetPHOSTriggerCells(triggerPosition); | |
175 | esd->AddPHOSTriggerPosition(triggerPosition); | |
176 | esd->AddPHOSTriggerAmplitudes(triggerAmplitudes); | |
177 | ||
178 | //###################################### | |
7592dfc4 | 179 | |
64df000d | 180 | //Fill CaloClusters |
f4e0dd30 | 181 | const Float_t kBigShort = std::numeric_limits<short int>::max() - 1; |
182 | const Float_t nsec100 = 1e9*100.; // units of 0.01 ns | |
183 | const Float_t gev500 = 500.; // units of GeV/500 | |
184 | ||
dfe0be07 | 185 | for (Int_t recpart = 0 ; recpart < nOfRecParticles ; recpart++) { |
186 | AliPHOSRecParticle * rp = dynamic_cast<AliPHOSRecParticle*>(recParticles->At(recpart)); | |
187 | if (Debug()) | |
188 | rp->Print(); | |
25ed816e | 189 | // Get track segment and EMC rec.point associated with this rec.particle |
190 | AliPHOSTrackSegment *ts = gime->TrackSegment(rp->GetPHOSTSIndex()); | |
191 | AliPHOSEmcRecPoint *emcRP = gime->EmcRecPoint(ts->GetEmcIndex()); | |
192 | AliESDCaloCluster *ec = new AliESDCaloCluster() ; | |
7592dfc4 | 193 | |
85c60a8e | 194 | Float_t xyz[3]; |
8013c27e | 195 | for (Int_t ixyz=0; ixyz<3; ixyz++) |
196 | xyz[ixyz] = rp->GetPos()[ixyz]; | |
dd7ee508 | 197 | |
198 | AliDebug(2,Form("Global position xyz=(%f,%f,%f)",xyz[0],xyz[1],xyz[2])); | |
199 | ||
7592dfc4 | 200 | //Create digits lists |
25ed816e | 201 | Int_t digitMult = emcRP->GetDigitsMultiplicity(); |
202 | Int_t *digitsList = emcRP->GetDigitsList(); | |
7592dfc4 | 203 | Short_t *amplList = new Short_t[digitMult]; |
204 | Short_t *timeList = new Short_t[digitMult]; | |
205 | Short_t *digiList = new Short_t[digitMult]; | |
25ed816e | 206 | |
7592dfc4 | 207 | // Convert Float_t* and Int_t* to Short_t* to save memory |
25ed816e | 208 | for (Int_t iDigit=0; iDigit<digitMult; iDigit++) { |
209 | AliPHOSDigit *digit = gime->Digit(digitsList[iDigit]); | |
f4e0dd30 | 210 | amplList[iDigit] = |
211 | (Short_t)(TMath::Min(digit->GetEnergy()*gev500,kBigShort)); // Energy in units of GeV/500 | |
212 | timeList[iDigit] = | |
213 | (Short_t)(TMath::Min(digit->GetTime()*nsec100,kBigShort)); // time in units of 0.01 ns | |
7592dfc4 | 214 | digiList[iDigit] = (Short_t)(digit->GetId()); |
25ed816e | 215 | } |
7592dfc4 | 216 | |
217 | //Primaries | |
218 | Int_t primMult = 0; | |
219 | Int_t *primInts = emcRP->GetPrimaries(primMult); | |
220 | Short_t *primList = new Short_t[primMult]; | |
221 | for (Int_t ipr=0; ipr<primMult; ipr++) | |
222 | primList[ipr] = (Short_t)(primInts[ipr]); | |
223 | ||
224 | // fills the ESDCaloCluster | |
225 | ||
34541ea2 | 226 | ec->SetPHOS(kTRUE); |
7592dfc4 | 227 | ec->SetPosition(xyz); //rec.point position in MARS |
228 | ec->SetE(rp->Energy()); //total particle energy | |
25ed816e | 229 | ec->SetClusterDisp(emcRP->GetDispersion()); //cluster dispersion |
230 | ec->SetPid (rp->GetPID()) ; //array of particle identification | |
25ed816e | 231 | ec->SetM02(emcRP->GetM2x()) ; //second moment M2x |
232 | ec->SetM20(emcRP->GetM2z()) ; //second moment M2z | |
233 | ec->SetNExMax(emcRP->GetNExMax()); //number of local maxima | |
25ed816e | 234 | ec->SetEmcCpvDistance(-1); //not yet implemented |
235 | ec->SetClusterChi2(-1); //not yet implemented | |
236 | ec->SetM11(-1) ; //not yet implemented | |
3744a6cf | 237 | |
7592dfc4 | 238 | //Digits Lists |
239 | TArrayS arrayAmpList(digitMult,amplList); | |
240 | TArrayS arrayTimeList(digitMult,timeList); | |
241 | TArrayS arrayIndexList(digitMult,digiList); | |
242 | ec->AddDigitAmplitude(arrayAmpList); | |
243 | ec->AddDigitTime(arrayTimeList); | |
244 | ec->AddDigitIndex(arrayIndexList); | |
245 | ||
3744a6cf | 246 | //Distance to the nearest bad crystal |
247 | ec->SetDistanceToBadChannel(emcRP->GetDistanceToBadCrystal()); | |
7592dfc4 | 248 | |
249 | //Array of MC indeces | |
250 | TArrayS arrayPrim(primMult,primList); | |
251 | ec->AddLabels(arrayPrim); | |
252 | ||
253 | //Array of tracks uncomment when available in future | |
254 | //TArrayS arrayTrackMatched(1);// Only one track, temporal solution. | |
255 | //arrayTrackMatched[0]= (Short_t)(matchedTrack[iClust]); | |
256 | //ec->AddTracksMatched(arrayTrackMatched); | |
64df000d | 257 | |
dfe0be07 | 258 | // add the track to the esd object |
85c60a8e | 259 | esd->AddCaloCluster(ec); |
dd7ee508 | 260 | delete ec; |
261 | } | |
262 | } | |
263 | ||
34541ea2 | 264 | //____________________________________________________________________________ |
dd7ee508 | 265 | void AliPHOSReconstructor::FillESD(AliRunLoader* runLoader, |
af885e0f | 266 | AliRawReader* rawReader, AliESDEvent* esd) const |
dd7ee508 | 267 | { |
268 | //This function creates AliESDtracks from AliPHOSRecParticles | |
269 | //and writes them to the ESD in the case of raw data reconstruction. | |
270 | ||
271 | Int_t eventNumber = runLoader->GetEventNumber() ; | |
272 | ||
dd7ee508 | 273 | AliPHOSGetter *gime = AliPHOSGetter::Instance(); |
cbddd97f | 274 | gime->Event(eventNumber, "DRTP") ; |
dd7ee508 | 275 | |
276 | TClonesArray *recParticles = gime->RecParticles(); | |
277 | Int_t nOfRecParticles = recParticles->GetEntries(); | |
278 | ||
279 | esd->SetNumberOfPHOSClusters(nOfRecParticles) ; | |
280 | esd->SetFirstPHOSCluster(esd->GetNumberOfCaloClusters()) ; | |
281 | ||
282 | AliDebug(2,Form("%d digits and %d rec. particles in event %d, option %s",gime->Digits()->GetEntries(),nOfRecParticles,eventNumber,GetOption())); | |
283 | ||
284 | for (Int_t recpart = 0 ; recpart < nOfRecParticles ; recpart++) { | |
285 | AliPHOSRecParticle * rp = dynamic_cast<AliPHOSRecParticle*>(recParticles->At(recpart)); | |
286 | ||
287 | if(rp) { | |
288 | Float_t xyz[3]; | |
289 | for (Int_t ixyz=0; ixyz<3; ixyz++) | |
290 | xyz[ixyz] = rp->GetPos()[ixyz]; | |
291 | ||
292 | AliDebug(2,Form("Global position xyz=(%f,%f,%f)",xyz[0],xyz[1],xyz[2])); | |
293 | ||
294 | AliPHOSTrackSegment *ts = gime->TrackSegment(rp->GetPHOSTSIndex()); | |
295 | AliPHOSEmcRecPoint *emcRP = gime->EmcRecPoint(ts->GetEmcIndex()); | |
296 | AliESDCaloCluster *ec = new AliESDCaloCluster() ; | |
297 | ||
298 | Int_t digitMult = emcRP->GetDigitsMultiplicity(); | |
299 | Int_t *digitsList = emcRP->GetDigitsList(); | |
7592dfc4 | 300 | Short_t *amplList = new Short_t[digitMult]; |
301 | Short_t *digiList = new Short_t[digitMult]; | |
dd7ee508 | 302 | |
303 | // Convert Float_t* and Int_t* to UShort_t* to save memory | |
304 | for (Int_t iDigit=0; iDigit<digitMult; iDigit++) { | |
305 | AliPHOSDigit *digit = gime->Digit(digitsList[iDigit]); | |
306 | if(!digit) { | |
307 | AliFatal(Form("Digit not found at the expected position %d!",iDigit)); | |
308 | } | |
309 | else { | |
7592dfc4 | 310 | amplList[iDigit] = (Short_t)digit->GetEnergy(); |
311 | digiList[iDigit] = (Short_t)(digit->GetId()); | |
312 | //timeList[iDigit] = (Short_t)(digit->GetTime()); | |
dd7ee508 | 313 | } |
314 | } | |
315 | ||
34541ea2 | 316 | ec->SetPHOS(kTRUE); |
7592dfc4 | 317 | ec->SetPosition(xyz); //rec.point position in MARS |
318 | ec->SetE(rp->Energy()); //total particle energy | |
dd7ee508 | 319 | ec->SetClusterDisp(emcRP->GetDispersion()); //cluster dispersion |
320 | ec->SetPid (rp->GetPID()) ; //array of particle identification | |
321 | ec->SetM02(emcRP->GetM2x()) ; //second moment M2x | |
322 | ec->SetM20(emcRP->GetM2z()) ; //second moment M2z | |
323 | ec->SetNExMax(emcRP->GetNExMax()); //number of local maxima | |
7592dfc4 | 324 | |
dd7ee508 | 325 | ec->SetEmcCpvDistance(-1); //not yet implemented |
326 | ec->SetClusterChi2(-1); //not yet implemented | |
327 | ec->SetM11(-1) ; //not yet implemented | |
7592dfc4 | 328 | // TArrayS arrayAmpList(digitMult,amplList); |
329 | // TArrayS arrayTimeList(digitMult,timeList); | |
330 | // TArrayS arrayIndexList(digitMult,digiList); | |
331 | // ec->AddDigitAmplitude(arrayAmpList); | |
332 | // ec->AddDigitTime(arrayTimeList); | |
333 | // ec->AddDigitIndex(arrayIndexList); | |
3744a6cf | 334 | //Distance to the nearest bad crystal |
335 | ec->SetDistanceToBadChannel(emcRP->GetDistanceToBadCrystal()); | |
336 | ||
dd7ee508 | 337 | // add the track to the esd object |
338 | esd->AddCaloCluster(ec); | |
339 | delete ec; | |
3744a6cf | 340 | |
dd7ee508 | 341 | } |
342 | } | |
343 | ||
344 | ||
d7d3b67b | 345 | } |
23904d16 | 346 | |
347 | AliTracker* AliPHOSReconstructor::CreateTracker(AliRunLoader* runLoader) const | |
348 | { | |
349 | // creates the PHOS tracker | |
350 | if (!runLoader) return NULL; | |
351 | return new AliPHOSTracker(runLoader); | |
352 | } | |
353 |