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 "AliRunLoader.h"
33 #include "AliEMCALLoader.h"
34 #include "AliEMCALClusterizerv1.h"
35 #include "AliEMCALRecPoint.h"
36 #include "AliEMCALPID.h"
37 #include "AliEMCALTrigger.h"
38 #include "AliRawReader.h"
41 ClassImp(AliEMCALReconstructor)
43 //____________________________________________________________________________
44 AliEMCALReconstructor::AliEMCALReconstructor()
50 //____________________________________________________________________________
51 AliEMCALReconstructor::AliEMCALReconstructor(const AliEMCALReconstructor & rec)
52 : AliReconstructor(rec),
58 //____________________________________________________________________________
59 AliEMCALReconstructor::~AliEMCALReconstructor()
64 //____________________________________________________________________________
65 void AliEMCALReconstructor::Reconstruct(AliRunLoader* runLoader) const
67 // method called by AliReconstruction;
68 // Only the clusterization is performed,; the rest of the reconstruction is done in FillESD because the track
69 // segment maker needs access to the AliESD object to retrieve the tracks reconstructed by
70 // the global tracking.
72 TString headerFile(runLoader->GetFileName()) ;
73 TString branchName(runLoader->GetEventFolder()->GetName() ) ;
75 AliEMCALClusterizerv1 clu(headerFile, branchName);
76 clu.SetEventRange(0, -1) ; // do all the events
78 clu.ExecuteTask("deb all") ;
80 clu.ExecuteTask("pseudo") ;
84 //____________________________________________________________________________
85 void AliEMCALReconstructor::Reconstruct(AliRunLoader* runLoader, AliRawReader* rawreader) const
87 // method called by AliReconstruction;
88 // Only the clusterization is performed,; the rest of the reconstruction is done in FillESD because the track
89 // segment maker needs access to the AliESD object to retrieve the tracks reconstructed by
90 // the global tracking.
91 // Here we reconstruct from Raw Data
94 TString headerFile(runLoader->GetFileName()) ;
95 TString branchName(runLoader->GetEventFolder()->GetName()) ;
97 AliEMCALClusterizerv1 clu(headerFile, branchName);
98 clu.SetEventRange(0, -1) ; // do all the events
100 clu.ExecuteTask("deb pseudo all") ;
102 clu.ExecuteTask("pseudo") ;
106 //____________________________________________________________________________
107 void AliEMCALReconstructor::FillESD(AliRunLoader* runLoader, AliESD* esd) const
109 // Called by AliReconstruct after Reconstruct() and global tracking and vertxing
110 const double timeScale = 1.e+11; // transition constant from sec to 0.01ns (10ps)
112 Int_t eventNumber = runLoader->GetEventNumber() ;
114 TString headerFile(runLoader->GetFileName()) ;
115 TString branchName(runLoader->GetEventFolder()->GetName()) ;
116 // Creates AliESDCaloCluster from AliEMCALRecPoints
117 AliRunLoader *rl = AliRunLoader::GetRunLoader();
118 AliEMCALLoader *emcalLoader = dynamic_cast<AliEMCALLoader*>(rl->GetDetectorLoader("EMCAL"));
120 rl->LoadKinematics(); // To get the primary label
121 rl->LoadDigits(); // To get the primary label
122 rl->LoadHits(); // To get the primary label
123 rl->GetEvent(eventNumber);
124 TObjArray *clusters = emcalLoader->RecPoints();
125 Int_t nClusters = clusters->GetEntries(), nClustersNew=0;
126 // Int_t nRP=0, nPC=0; // in input
127 esd->SetFirstEMCALCluster(esd->GetNumberOfCaloClusters()); // Put after Phos clusters
129 //#########Calculate trigger and set trigger info###########
132 // tr.SetPatchSize(1);//create 4x4 patches
135 Float_t maxAmp2x2 = tr.Get2x2MaxAmplitude();
136 Float_t maxAmpnxn = tr.GetnxnMaxAmplitude();
137 Float_t ampOutOfPatch2x2 = tr.Get2x2AmpOutOfPatch() ;
138 Float_t ampOutOfPatchnxn = tr.GetnxnAmpOutOfPatch() ;
140 AliEMCALGeometry * geom = AliEMCALGeometry::GetInstance(AliEMCALGeometry::GetDefaulGeometryName());
142 Int_t iSM2x2 = tr.Get2x2SuperModule();
143 Int_t iSMnxn = tr.GetnxnSuperModule();
144 Int_t iCellPhi2x2 = tr.Get2x2CellPhi();
145 Int_t iCellPhinxn = tr.GetnxnCellPhi();
146 Int_t iCellEta2x2 = tr.Get2x2CellEta();
147 Int_t iCellEtanxn = tr.GetnxnCellEta();
149 AliDebug(2, Form("Trigger 2x2 max amp %f, out amp %f, SM %d, iphi %d ieta %d", maxAmp2x2, ampOutOfPatch2x2, iSM2x2,iCellPhi2x2, iCellEta2x2));
150 AliDebug(2, Form("Trigger 4x4 max amp %f , out amp %f, SM %d, iphi %d, ieta %d", maxAmpnxn, ampOutOfPatchnxn, iSMnxn,iCellPhinxn, iCellEtanxn));
152 TVector3 pos2x2(-1,-1,-1);
153 TVector3 posnxn(-1,-1,-1);
155 Int_t iAbsId2x2 = geom->GetAbsCellIdFromCellIndexes( iSM2x2, iCellPhi2x2, iCellEta2x2) ;
156 Int_t iAbsIdnxn = geom->GetAbsCellIdFromCellIndexes( iSMnxn, iCellPhinxn, iCellEtanxn) ;
157 geom->GetGlobal(iAbsId2x2, pos2x2);
158 geom->GetGlobal(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->AddEMCALTriggerPosition(triggerPosition);
175 esd->AddEMCALTriggerAmplitudes(triggerAmplitudes);
177 //######################################
181 for (Int_t iClust = 0 ; iClust < nClusters ; iClust++) {
182 const AliEMCALRecPoint * clust = emcalLoader->RecPoint(iClust);
183 //if(clust->GetClusterType()== AliESDCaloCluster::kClusterv1) nRP++; else nPC++;
184 if (Debug()) clust->Print();
185 // Get information from EMCAL reconstruction points
188 clust->GetGlobalPosition(gpos);
189 for (Int_t ixyz=0; ixyz<3; ixyz++)
190 xyz[ixyz] = gpos[ixyz];
192 Int_t digitMult = clust->GetMultiplicity();
193 UShort_t *amplList = new UShort_t[digitMult];
194 UShort_t *timeList = new UShort_t[digitMult];
195 UShort_t *digiList = new UShort_t[digitMult];
196 Float_t *amplFloat = clust->GetEnergiesList();
197 Float_t *timeFloat = clust->GetTimeList();
198 Int_t *digitInts = clust->GetAbsId();
200 clust->GetElipsAxis(elipAxis);
202 // Convert Float_t* and Int_t* to UShort_t* to save memory
203 // Problem : we should recalculate a cluster characteristics when discard digit(s)
204 Int_t newdigitMult = 0;
205 for (Int_t iDigit=0; iDigit<digitMult; iDigit++) {
206 if(timeFloat[iDigit] < 65536./timeScale) {
207 amplList[newdigitMult] = (UShort_t)(amplFloat[iDigit]*500);
208 if(amplList[newdigitMult] > 0) { // accept digit if poztive amplitude
209 timeList[newdigitMult] = (UShort_t)(timeFloat[iDigit]*timeScale); // Time in units of 0.01 ns = 10 ps
210 digiList[newdigitMult] = (UShort_t)(digitInts[iDigit]);
216 if(newdigitMult > 0) { // accept cluster if it has some digit
218 if(newdigitMult != digitMult) { // some digits were deleted
219 UShort_t *amplListNew = new UShort_t[newdigitMult];
220 UShort_t *timeListNew = new UShort_t[newdigitMult];
221 UShort_t *digiListNew = new UShort_t[newdigitMult];
222 for (Int_t iDigit=0; iDigit<newdigitMult; iDigit++) {
223 amplListNew[iDigit] = amplList[iDigit];
224 timeListNew[iDigit] = timeList[iDigit];
225 digiListNew[iDigit] = digiList[iDigit];
232 amplList = amplListNew;
233 timeList = timeListNew;
234 digiList = digiListNew;
239 Int_t *primInts = clust->GetPrimaries(primMult);
240 UShort_t *primList = new UShort_t[primMult];
241 for (Int_t ipr=0; ipr<primMult; ipr++)
242 primList[ipr] = (UShort_t)(primInts[ipr]);
245 // fills the ESDCaloCluster
246 AliESDCaloCluster * ec = new AliESDCaloCluster() ;
247 ec->SetClusterType(clust->GetClusterType());
248 ec->SetGlobalPosition(xyz);
249 ec->SetClusterEnergy(clust->GetEnergy());
251 ec->SetNumberOfDigits(newdigitMult);
252 ec->SetDigitAmplitude(amplList); //energies
253 ec->SetDigitTime(timeList); //times
254 ec->SetDigitIndex(digiList); //indices
255 if(clust->GetClusterType()== AliESDCaloCluster::kClusterv1){
256 ec->SetPrimaryIndex(clust->GetPrimaryIndex());
257 ec->SetNumberOfPrimaries(primMult); //primary multiplicity
258 ec->SetListOfPrimaries(primList); //primary List for a cluster
259 ec->SetClusterDisp(clust->GetDispersion());
260 ec->SetClusterChi2(-1); //not yet implemented
261 ec->SetM02(elipAxis[0]*elipAxis[0]) ;
262 ec->SetM20(elipAxis[1]*elipAxis[1]) ;
263 ec->SetM11(-1) ; //not yet implemented
265 // add the cluster to the esd object
266 esd->AddCaloCluster(ec);
268 } else { // no new ESD cluster
273 } // cycle on clusters
274 // printf(" %i : nClusters %i : RP %i PC %i \n", eventNumber, nClusters, nRP, nPC);
275 esd->SetNumberOfEMCALClusters(nClustersNew);
276 //if(nClustersNew != nClusters)
277 //printf(" ##### nClusters %i -> new %i ##### \n", nClusters, nClustersNew );
279 //Fill ESDCaloCluster with PID weights
280 AliEMCALPID *pid = new AliEMCALPID;
281 //pid->SetPrintInfo(kTRUE);
282 pid->SetReconstructor(kTRUE);