1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
18 //_________________________________________________________________________
20 //*-- Yves Schutz (SUBATECH)
21 // Reconstruction class. Redesigned from the old AliReconstructionner class and
22 // derived from STEER/AliReconstructor.
24 // --- ROOT system ---
26 // --- Standard library ---
28 // --- AliRoot header files ---
30 #include "AliPHOSReconstructor.h"
31 #include "AliPHOSClusterizerv1.h"
32 #include "AliPHOSTrackSegmentMakerv1.h"
33 #include "AliPHOSPIDv1.h"
34 #include "AliPHOSGetter.h"
35 #include "AliPHOSTracker.h"
36 #include "AliRawReader.h"
37 #include "AliPHOSTrigger.h"
38 #include "AliPHOSGeometry.h"
40 ClassImp(AliPHOSReconstructor)
42 Bool_t AliPHOSReconstructor::fgDebug = kFALSE ;
44 //____________________________________________________________________________
45 AliPHOSReconstructor::AliPHOSReconstructor()
51 //____________________________________________________________________________
52 AliPHOSReconstructor::~AliPHOSReconstructor()
58 //____________________________________________________________________________
59 void AliPHOSReconstructor::Reconstruct(AliRunLoader* runLoader) const
61 // method called by AliReconstruction;
62 // Only the clusterization is performed,; the rest of the reconstruction is done in FillESD because the track
63 // segment maker needs access to the AliESD object to retrieve the tracks reconstructed by
64 // the global tracking.
66 TString headerFile(runLoader->GetFileName()) ;
67 TString branchName(runLoader->GetEventFolder()->GetName()) ;
69 AliPHOSClusterizerv1 clu(headerFile, branchName);
70 clu.SetEventRange(0, -1) ; // do all the events
72 clu.ExecuteTask("deb all") ;
78 //____________________________________________________________________________
79 void AliPHOSReconstructor::Reconstruct(AliRunLoader* runLoader, AliRawReader* rawreader) const
81 // method called by AliReconstruction;
82 // Only the clusterization is performed,; the rest of the reconstruction is done in FillESD because the track
83 // segment maker needs access to the AliESD object to retrieve the tracks reconstructed by
84 // the global tracking.
85 // Here we reconstruct from Raw Data
88 TString headerFile(runLoader->GetFileName()) ;
89 TString branchName(runLoader->GetEventFolder()->GetName()) ;
91 AliPHOSClusterizerv1 clu(headerFile, branchName);
92 clu.SetEventRange(0, -1) ; // do all the events
93 clu.SetRawReader(rawreader);
95 TString option = GetOption();
96 if (option.Contains("OldRCUFormat"))
97 clu.SetOldRCUFormat(kTRUE);
100 clu.ExecuteTask("deb all") ;
102 clu.ExecuteTask("") ;
106 //____________________________________________________________________________
107 void AliPHOSReconstructor::FillESD(AliRunLoader* runLoader, AliESD* esd) const
109 // This function creates AliESDtracks from AliPHOSRecParticles
111 // writes them to the ESD
113 Int_t eventNumber = runLoader->GetEventNumber() ;
115 AliPHOSGetter *gime = AliPHOSGetter::Instance();
116 gime->Event(eventNumber, "DRTP") ;
117 TClonesArray *recParticles = gime->RecParticles();
118 Int_t nOfRecParticles = recParticles->GetEntries();
120 esd->SetNumberOfPHOSClusters(nOfRecParticles) ;
121 esd->SetFirstPHOSCluster(esd->GetNumberOfCaloClusters()) ;
123 AliDebug(2,Form("%d digits and %d rec. particles in event %d, option %s",gime->Digits()->GetEntries(),nOfRecParticles,eventNumber,GetOption()));
126 //#########Calculate trigger and set trigger info###########
129 // tr.SetPatchSize(1);//create 4x4 patches
132 Float_t maxAmp2x2 = tr.Get2x2MaxAmplitude();
133 Float_t maxAmpnxn = tr.GetnxnMaxAmplitude();
134 Float_t ampOutOfPatch2x2 = tr.Get2x2AmpOutOfPatch() ;
135 Float_t ampOutOfPatchnxn = tr.GetnxnAmpOutOfPatch() ;
137 AliPHOSGeometry * geom = gime->PHOSGeometry();
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();
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));
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.
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.
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);
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) ;
168 TArrayF triggerAmplitudes(4);
169 triggerAmplitudes[0] = maxAmp2x2 ;
170 triggerAmplitudes[1] = ampOutOfPatch2x2 ;
171 triggerAmplitudes[2] = maxAmpnxn ;
172 triggerAmplitudes[3] = ampOutOfPatchnxn ;
174 //esd->SetPHOSTriggerCells(triggerPosition);
175 esd->AddPHOSTriggerPosition(triggerPosition);
176 esd->AddPHOSTriggerAmplitudes(triggerAmplitudes);
178 //######################################
181 for (Int_t recpart = 0 ; recpart < nOfRecParticles ; recpart++) {
182 AliPHOSRecParticle * rp = dynamic_cast<AliPHOSRecParticle*>(recParticles->At(recpart));
185 // Get track segment and EMC rec.point associated with this rec.particle
186 AliPHOSTrackSegment *ts = gime->TrackSegment(rp->GetPHOSTSIndex());
187 AliPHOSEmcRecPoint *emcRP = gime->EmcRecPoint(ts->GetEmcIndex());
188 AliESDCaloCluster *ec = new AliESDCaloCluster() ;
191 for (Int_t ixyz=0; ixyz<3; ixyz++)
192 xyz[ixyz] = rp->GetPos()[ixyz];
194 AliDebug(2,Form("Global position xyz=(%f,%f,%f)",xyz[0],xyz[1],xyz[2]));
196 //Create digits lists
197 Int_t digitMult = emcRP->GetDigitsMultiplicity();
198 Int_t *digitsList = emcRP->GetDigitsList();
199 Short_t *amplList = new Short_t[digitMult];
200 Short_t *timeList = new Short_t[digitMult];
201 Short_t *digiList = new Short_t[digitMult];
203 // Convert Float_t* and Int_t* to Short_t* to save memory
204 for (Int_t iDigit=0; iDigit<digitMult; iDigit++) {
205 AliPHOSDigit *digit = gime->Digit(digitsList[iDigit]);
206 amplList[iDigit] = (Short_t)(digit->GetEnergy()*500); // Energy in units of GeV/500
207 timeList[iDigit] = (Short_t)(digit->GetTime()*1e9*100); // time in units of 0.01 ns
208 digiList[iDigit] = (Short_t)(digit->GetId());
213 Int_t *primInts = emcRP->GetPrimaries(primMult);
214 Short_t *primList = new Short_t[primMult];
215 for (Int_t ipr=0; ipr<primMult; ipr++)
216 primList[ipr] = (Short_t)(primInts[ipr]);
218 // fills the ESDCaloCluster
221 ec->SetPosition(xyz); //rec.point position in MARS
222 ec->SetE(rp->Energy()); //total particle energy
223 ec->SetClusterDisp(emcRP->GetDispersion()); //cluster dispersion
224 ec->SetPid (rp->GetPID()) ; //array of particle identification
225 ec->SetM02(emcRP->GetM2x()) ; //second moment M2x
226 ec->SetM20(emcRP->GetM2z()) ; //second moment M2z
227 ec->SetNExMax(emcRP->GetNExMax()); //number of local maxima
228 ec->SetEmcCpvDistance(-1); //not yet implemented
229 ec->SetClusterChi2(-1); //not yet implemented
230 ec->SetM11(-1) ; //not yet implemented
233 TArrayS arrayAmpList(digitMult,amplList);
234 TArrayS arrayTimeList(digitMult,timeList);
235 TArrayS arrayIndexList(digitMult,digiList);
236 ec->AddDigitAmplitude(arrayAmpList);
237 ec->AddDigitTime(arrayTimeList);
238 ec->AddDigitIndex(arrayIndexList);
240 //Distance to the nearest bad crystal
241 ec->SetDistanceToBadChannel(emcRP->GetDistanceToBadCrystal());
243 //Array of MC indeces
244 TArrayS arrayPrim(primMult,primList);
245 ec->AddLabels(arrayPrim);
247 //Array of tracks uncomment when available in future
248 //TArrayS arrayTrackMatched(1);// Only one track, temporal solution.
249 //arrayTrackMatched[0]= (Short_t)(matchedTrack[iClust]);
250 //ec->AddTracksMatched(arrayTrackMatched);
252 // add the track to the esd object
253 esd->AddCaloCluster(ec);
258 //____________________________________________________________________________
259 void AliPHOSReconstructor::FillESD(AliRunLoader* runLoader,
260 AliRawReader* rawReader, AliESD* esd) const
262 //This function creates AliESDtracks from AliPHOSRecParticles
263 //and writes them to the ESD in the case of raw data reconstruction.
265 Int_t eventNumber = runLoader->GetEventNumber() ;
267 AliPHOSGetter *gime = AliPHOSGetter::Instance();
268 gime->Event(eventNumber, "DRTP") ;
270 TClonesArray *recParticles = gime->RecParticles();
271 Int_t nOfRecParticles = recParticles->GetEntries();
273 esd->SetNumberOfPHOSClusters(nOfRecParticles) ;
274 esd->SetFirstPHOSCluster(esd->GetNumberOfCaloClusters()) ;
276 AliDebug(2,Form("%d digits and %d rec. particles in event %d, option %s",gime->Digits()->GetEntries(),nOfRecParticles,eventNumber,GetOption()));
278 for (Int_t recpart = 0 ; recpart < nOfRecParticles ; recpart++) {
279 AliPHOSRecParticle * rp = dynamic_cast<AliPHOSRecParticle*>(recParticles->At(recpart));
283 for (Int_t ixyz=0; ixyz<3; ixyz++)
284 xyz[ixyz] = rp->GetPos()[ixyz];
286 AliDebug(2,Form("Global position xyz=(%f,%f,%f)",xyz[0],xyz[1],xyz[2]));
288 AliPHOSTrackSegment *ts = gime->TrackSegment(rp->GetPHOSTSIndex());
289 AliPHOSEmcRecPoint *emcRP = gime->EmcRecPoint(ts->GetEmcIndex());
290 AliESDCaloCluster *ec = new AliESDCaloCluster() ;
292 Int_t digitMult = emcRP->GetDigitsMultiplicity();
293 Int_t *digitsList = emcRP->GetDigitsList();
294 Short_t *amplList = new Short_t[digitMult];
295 Short_t *digiList = new Short_t[digitMult];
297 // Convert Float_t* and Int_t* to UShort_t* to save memory
298 for (Int_t iDigit=0; iDigit<digitMult; iDigit++) {
299 AliPHOSDigit *digit = gime->Digit(digitsList[iDigit]);
301 AliFatal(Form("Digit not found at the expected position %d!",iDigit));
304 amplList[iDigit] = (Short_t)digit->GetEnergy();
305 digiList[iDigit] = (Short_t)(digit->GetId());
306 //timeList[iDigit] = (Short_t)(digit->GetTime());
311 ec->SetPosition(xyz); //rec.point position in MARS
312 ec->SetE(rp->Energy()); //total particle energy
313 ec->SetClusterDisp(emcRP->GetDispersion()); //cluster dispersion
314 ec->SetPid (rp->GetPID()) ; //array of particle identification
315 ec->SetM02(emcRP->GetM2x()) ; //second moment M2x
316 ec->SetM20(emcRP->GetM2z()) ; //second moment M2z
317 ec->SetNExMax(emcRP->GetNExMax()); //number of local maxima
319 ec->SetEmcCpvDistance(-1); //not yet implemented
320 ec->SetClusterChi2(-1); //not yet implemented
321 ec->SetM11(-1) ; //not yet implemented
322 // TArrayS arrayAmpList(digitMult,amplList);
323 // TArrayS arrayTimeList(digitMult,timeList);
324 // TArrayS arrayIndexList(digitMult,digiList);
325 // ec->AddDigitAmplitude(arrayAmpList);
326 // ec->AddDigitTime(arrayTimeList);
327 // ec->AddDigitIndex(arrayIndexList);
328 //Distance to the nearest bad crystal
329 ec->SetDistanceToBadChannel(emcRP->GetDistanceToBadCrystal());
331 // add the track to the esd object
332 esd->AddCaloCluster(ec);
341 AliTracker* AliPHOSReconstructor::CreateTracker(AliRunLoader* runLoader) const
343 // creates the PHOS tracker
344 if (!runLoader) return NULL;
345 return new AliPHOSTracker(runLoader);