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 ---
29 #include "AliEMCALReconstructor.h"
32 #include "AliESDEvent.h"
33 #include "AliESDCaloCluster.h"
34 #include "AliESDtrack.h"
35 #include "AliRunLoader.h"
36 #include "AliEMCALLoader.h"
37 #include "AliEMCALRawUtils.h"
38 #include "AliEMCALClusterizerv1.h"
39 #include "AliEMCALRecPoint.h"
40 #include "AliEMCALPID.h"
41 #include "AliEMCALTrigger.h"
42 #include "AliRawReader.h"
44 ClassImp(AliEMCALReconstructor)
46 //____________________________________________________________________________
47 AliEMCALReconstructor::AliEMCALReconstructor()
53 //____________________________________________________________________________
54 AliEMCALReconstructor::AliEMCALReconstructor(const AliEMCALReconstructor & rec)
55 : AliReconstructor(rec),
61 //____________________________________________________________________________
62 AliEMCALReconstructor::~AliEMCALReconstructor()
67 //____________________________________________________________________________
68 void AliEMCALReconstructor::Reconstruct(AliRunLoader* runLoader) const
70 // method called by AliReconstruction;
71 // Only the clusterization is performed,; the rest of the reconstruction is done in FillESD because the track
72 // segment maker needs access to the AliESD object to retrieve the tracks reconstructed by
73 // the global tracking.
75 TString headerFile(runLoader->GetFileName()) ;
76 TString branchName(runLoader->GetEventFolder()->GetName() ) ;
78 AliEMCALClusterizerv1 clu(headerFile, branchName);
79 AliEMCALLoader *emcalLoader = dynamic_cast<AliEMCALLoader*>(runLoader->GetDetectorLoader("EMCAL"));
81 Int_t nEvents = runLoader->GetNumberOfEvents();
82 runLoader->LoadDigits("EMCAL");
83 for (Int_t ievent = 0; ievent < nEvents; ievent++) {
84 runLoader->GetEvent(ievent);
86 clu.ExecuteTask("deb all") ;
88 clu.ExecuteTask("pseudo") ;
90 // Unload the Digits and RecPoints
91 emcalLoader->UnloadDigits() ;
92 emcalLoader->UnloadRecPoints() ;
95 //____________________________________________________________________________
96 void AliEMCALReconstructor::Reconstruct(AliRunLoader* runLoader, AliRawReader* rawReader) const
99 // Reconstruction loop for Raw Data processing
101 // Only the clusterization is performed
102 // Track-cluster matching is done in FillESD because the track
103 // segment maker needs access to the AliESD object to retrieve
104 // the tracks reconstructed by the global tracking.
106 TString headerFile(runLoader->GetFileName()) ;
107 TString branchName(runLoader->GetEventFolder()->GetName()) ;
109 static AliEMCALRawUtils rawUtils;
110 AliEMCALClusterizerv1 clu(headerFile, branchName);
111 AliEMCALLoader *emcalLoader = dynamic_cast<AliEMCALLoader*>(runLoader->GetDetectorLoader("EMCAL"));
115 while (rawReader->NextEvent()) {
116 runLoader->GetEvent(iEvent++);
118 rawUtils.Raw2Digits(rawReader);
121 clu.ExecuteTask("deb pseudo all") ;
123 clu.ExecuteTask("pseudo") ;
124 // Unload the RecPoints
125 emcalLoader->UnloadRecPoints() ;
129 //____________________________________________________________________________
130 void AliEMCALReconstructor::FillESD(AliRunLoader* runLoader, AliESDEvent* esd) const
132 // Called by AliReconstruct after Reconstruct() and global tracking and vertexing
133 const double timeScale = 1.e+11; // transition constant from sec to 0.01 ns
135 Int_t eventNumber = runLoader->GetEventNumber() ;
137 // Creates AliESDCaloCluster from AliEMCALRecPoints
138 AliEMCALLoader *emcalLoader = dynamic_cast<AliEMCALLoader*>(runLoader->GetDetectorLoader("EMCAL"));
139 runLoader->LoadRecPoints("EMCAL");
140 runLoader->GetEvent(eventNumber);
141 TObjArray *clusters = emcalLoader->RecPoints();
142 Int_t nClusters = clusters->GetEntries(), nClustersNew=0;
143 AliDebug(1,Form("Event %d: %d clusters",eventNumber,nClusters));
144 // Int_t nRP=0, nPC=0; // in input
145 esd->SetFirstEMCALCluster(esd->GetNumberOfCaloClusters()); // Put after Phos clusters
147 //######################################################
148 //#########Calculate trigger and set trigger info###########
149 //######################################################
152 // tr.SetPatchSize(1);//create 4x4 patches
155 Float_t maxAmp2x2 = tr.Get2x2MaxAmplitude();
156 Float_t maxAmpnxn = tr.GetnxnMaxAmplitude();
157 Float_t ampOutOfPatch2x2 = tr.Get2x2AmpOutOfPatch() ;
158 Float_t ampOutOfPatchnxn = tr.GetnxnAmpOutOfPatch() ;
160 AliEMCALGeometry * geom = 0;
161 if (runLoader->GetAliRun() && runLoader->GetAliRun()->GetDetector("EMCAL"))
162 geom = dynamic_cast<AliEMCAL*>(runLoader->GetAliRun()->GetDetector("EMCAL"))->GetGeometry();
164 geom = AliEMCALGeometry::GetInstance(AliEMCALGeometry::GetDefaulGeometryName());
166 Int_t iSM2x2 = tr.Get2x2SuperModule();
167 Int_t iSMnxn = tr.GetnxnSuperModule();
168 Int_t iCellPhi2x2 = tr.Get2x2CellPhi();
169 Int_t iCellPhinxn = tr.GetnxnCellPhi();
170 Int_t iCellEta2x2 = tr.Get2x2CellEta();
171 Int_t iCellEtanxn = tr.GetnxnCellEta();
173 AliDebug(2, Form("Trigger 2x2 max amp %f, out amp %f, SM %d, iphi %d ieta %d", maxAmp2x2, ampOutOfPatch2x2, iSM2x2,iCellPhi2x2, iCellEta2x2));
174 AliDebug(2, Form("Trigger 4x4 max amp %f , out amp %f, SM %d, iphi %d, ieta %d", maxAmpnxn, ampOutOfPatchnxn, iSMnxn,iCellPhinxn, iCellEtanxn));
176 TVector3 pos2x2(-1,-1,-1);
177 TVector3 posnxn(-1,-1,-1);
179 Int_t iAbsId2x2 = geom->GetAbsCellIdFromCellIndexes( iSM2x2, iCellPhi2x2, iCellEta2x2) ;
180 Int_t iAbsIdnxn = geom->GetAbsCellIdFromCellIndexes( iSMnxn, iCellPhinxn, iCellEtanxn) ;
181 geom->GetGlobal(iAbsId2x2, pos2x2);
182 geom->GetGlobal(iAbsIdnxn, posnxn);
184 TArrayF triggerPosition(6);
185 triggerPosition[0] = pos2x2(0) ;
186 triggerPosition[1] = pos2x2(1) ;
187 triggerPosition[2] = pos2x2(2) ;
188 triggerPosition[3] = posnxn(0) ;
189 triggerPosition[4] = posnxn(1) ;
190 triggerPosition[5] = posnxn(2) ;
192 TArrayF triggerAmplitudes(4);
193 triggerAmplitudes[0] = maxAmp2x2 ;
194 triggerAmplitudes[1] = ampOutOfPatch2x2 ;
195 triggerAmplitudes[2] = maxAmpnxn ;
196 triggerAmplitudes[3] = ampOutOfPatchnxn ;
198 esd->AddEMCALTriggerPosition(triggerPosition);
199 esd->AddEMCALTriggerAmplitudes(triggerAmplitudes);
201 //######################################################
202 //#######################TRACK MATCHING###############
203 //######################################################
204 //Fill list of integers, each one is index of track to which the cluster belongs.
206 // step 1 - initialize array of matched track indexes
207 Int_t *matchedTrack = new Int_t[nClusters];
208 for (Int_t iclus = 0; iclus < nClusters; iclus++)
209 matchedTrack[iclus] = -1; // neg. index --> no matched track
211 // step 2, change the flag for all matched clusters found in tracks
212 Int_t iemcalMatch = -1;
213 Int_t endtpc = esd->GetNumberOfTracks();
214 for (Int_t itrack = 0; itrack < endtpc; itrack++) {
215 AliESDtrack * track = esd->GetTrack(itrack) ; // retrieve track
216 iemcalMatch = track->GetEMCALcluster();
217 if(iemcalMatch >= 0) matchedTrack[iemcalMatch] = itrack;
220 //########################################
221 //##############Fill CaloClusters#############
222 //########################################
225 for (Int_t iClust = 0 ; iClust < nClusters ; iClust++) {
226 const AliEMCALRecPoint * clust = emcalLoader->RecPoint(iClust);
227 //if(clust->GetClusterType()== AliESDCaloCluster::kClusterv1) nRP++; else nPC++;
228 if (Debug()) clust->Print();
229 // Get information from EMCAL reconstruction points
232 clust->GetGlobalPosition(gpos);
233 for (Int_t ixyz=0; ixyz<3; ixyz++)
234 xyz[ixyz] = gpos[ixyz];
236 Int_t digitMult = clust->GetMultiplicity();
237 Short_t *amplList = new Short_t[digitMult];
238 Short_t *timeList = new Short_t[digitMult];
239 Short_t *digiList = new Short_t[digitMult];
240 Float_t *amplFloat = clust->GetEnergiesList();
241 Float_t *timeFloat = clust->GetTimeList();
242 Int_t *digitInts = clust->GetAbsId();
244 clust->GetElipsAxis(elipAxis);
246 // Convert Float_t* and Int_t* to Short_t* to save memory
247 // Problem : we should recalculate a cluster characteristics when discard digit(s)
248 Int_t newdigitMult = 0;
249 for (Int_t iDigit=0; iDigit<digitMult; iDigit++) {
250 if (amplFloat[iDigit] > 0) {
251 amplList[newdigitMult] = (UShort_t)(amplFloat[iDigit]*500);
252 // Time in units of 0.01 ns = 10 ps
253 if(timeFloat[iDigit] < 65536./timeScale)
254 timeList[newdigitMult] = (UShort_t)(timeFloat[iDigit]*timeScale);
256 timeList[newdigitMult] = 65535;
257 digiList[newdigitMult] = (UShort_t)(digitInts[iDigit]);
260 else if (clust->GetClusterType() != AliESDCaloCluster::kPseudoCluster)
261 Warning("FillESD()","Negative or 0 digit amplitude in cluster");
264 if(newdigitMult > 0) { // accept cluster if it has some digit
266 if(newdigitMult != digitMult) { // some digits were deleted
267 Short_t *amplListNew = new Short_t[newdigitMult];
268 Short_t *timeListNew = new Short_t[newdigitMult];
269 Short_t *digiListNew = new Short_t[newdigitMult];
270 for (Int_t iDigit=0; iDigit<newdigitMult; iDigit++) {
271 amplListNew[iDigit] = amplList[iDigit];
272 timeListNew[iDigit] = timeList[iDigit];
273 digiListNew[iDigit] = digiList[iDigit];
280 amplList = amplListNew;
281 timeList = timeListNew;
282 digiList = digiListNew;
286 Int_t parentMult = 0;
287 Int_t *parentInts = clust->GetParents(parentMult);
288 Short_t *parentList = new Short_t[parentMult];
289 for (Int_t ipr=0; ipr<parentMult; ipr++)
290 parentList[ipr] = (Short_t)(parentInts[ipr]);
293 // fills the ESDCaloCluster
294 AliESDCaloCluster * ec = new AliESDCaloCluster() ;
296 ec->SetClusterType(clust->GetClusterType());
297 ec->SetPosition(xyz);
298 ec->SetE(clust->GetEnergy());
299 TArrayS arrayAmpList(newdigitMult,amplList);
300 TArrayS arrayTimeList(newdigitMult,timeList);
301 TArrayS arrayIndexList(newdigitMult,digiList);
302 ec->AddDigitAmplitude(arrayAmpList);
303 ec->AddDigitTime(arrayTimeList);
304 ec->AddDigitIndex(arrayIndexList);
306 if(clust->GetClusterType()== AliESDCaloCluster::kClusterv1){
308 ec->SetClusterDisp(clust->GetDispersion());
309 ec->SetClusterChi2(-1); //not yet implemented
310 ec->SetM02(elipAxis[0]*elipAxis[0]) ;
311 ec->SetM20(elipAxis[1]*elipAxis[1]) ;
312 ec->SetM11(-1) ; //not yet implemented
314 TArrayS arrayTrackMatched(1);// Only one track, temporal solution.
315 arrayTrackMatched[0]= (Short_t)(matchedTrack[iClust]);
316 ec->AddTracksMatched(arrayTrackMatched);
318 TArrayS arrayParents(parentMult,parentList);
319 ec->AddLabels(arrayParents);
322 // add the cluster to the esd object
323 esd->AddCaloCluster(ec);
326 } else { // no new ESD cluster
331 } // cycle on clusters
332 esd->SetNumberOfEMCALClusters(nClustersNew);
333 //if(nClustersNew != nClusters)
334 //printf(" ##### nClusters %i -> new %i ##### \n", nClusters, nClustersNew );
336 //Fill ESDCaloCluster with PID weights
337 AliEMCALPID *pid = new AliEMCALPID;
338 //pid->SetPrintInfo(kTRUE);
339 pid->SetReconstructor(kTRUE);