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"
31 #include "AliESDEvent.h"
32 #include "AliESDCaloCluster.h"
33 #include "AliESDtrack.h"
34 #include "AliEMCALLoader.h"
35 #include "AliEMCALRawUtils.h"
36 #include "AliEMCALClusterizerv1.h"
37 #include "AliEMCALRecPoint.h"
38 #include "AliEMCALPID.h"
39 #include "AliEMCALTrigger.h"
40 #include "AliRawReader.h"
41 #include "AliCDBEntry.h"
42 #include "AliCDBManager.h"
43 #include "AliEMCALRecParam.h"
44 // to be removed - it is here just because of geom
46 #include "AliRunLoader.h"
48 ClassImp(AliEMCALReconstructor)
50 AliEMCALRecParam* AliEMCALReconstructor::fgkRecParam = 0; // EMCAL rec. parameters
52 //____________________________________________________________________________
53 AliEMCALReconstructor::AliEMCALReconstructor()
59 //____________________________________________________________________________
60 AliEMCALReconstructor::AliEMCALReconstructor(const AliEMCALReconstructor & rec)
61 : AliReconstructor(rec),
67 //____________________________________________________________________________
68 AliEMCALReconstructor::~AliEMCALReconstructor()
73 //____________________________________________________________________________
74 void AliEMCALReconstructor::InitRecParam() const
76 // Check if the instance of AliEMCALRecParam exists,
77 // if not, get it from OCDB if available, otherwise create a default one
79 if (!fgkRecParam && (AliCDBManager::Instance()->IsDefaultStorageSet())) {
80 AliCDBEntry *entry = (AliCDBEntry*)
81 AliCDBManager::Instance()->Get("EMCAL/Config/RecParam");
82 if (entry) fgkRecParam = (AliEMCALRecParam*) entry->GetObject();
86 AliWarning("The Reconstruction parameters for EMCAL nonitialized - Used default one");
87 fgkRecParam = new AliEMCALRecParam;
91 //____________________________________________________________________________
92 void AliEMCALReconstructor::Reconstruct(TTree* digitsTree, TTree* clustersTree) const
94 // method called by AliReconstruction;
95 // Only the clusterization is performed,; the rest of the reconstruction is done in FillESD because the track
96 // segment maker needs access to the AliESD object to retrieve the tracks reconstructed by
97 // the global tracking.
98 // Works on the current event.
101 AliEMCALClusterizerv1 clu;
102 clu.SetInput(digitsTree);
103 clu.SetOutput(clustersTree);
105 clu.Digits2Clusters("deb all") ;
107 clu.Digits2Clusters("pseudo") ;
110 //____________________________________________________________________________
111 void AliEMCALReconstructor::ConvertDigits(AliRawReader* rawReader, TTree* digitsTree) const
114 // Conversion from raw data to
116 // Works on a single-event basis
120 TClonesArray *digitsArr = new TClonesArray("AliEMCALDigit",100);
121 Int_t bufsize = 32000;
122 digitsTree->Branch("EMCAL", &digitsArr, bufsize);
124 static AliEMCALRawUtils rawUtils;
125 rawUtils.Raw2Digits(rawReader,digitsArr);
133 //____________________________________________________________________________
134 void AliEMCALReconstructor::FillESD(TTree* /*digitsTree*/, TTree* clustersTree,
135 AliESDEvent* esd) const
137 // Called by AliReconstruct after Reconstruct() and global tracking and vertexing
138 // Works on the current event
139 const double timeScale = 1.e+11; // transition constant from sec to 0.01 ns
141 // Creates AliESDCaloCluster from AliEMCALRecPoints
143 TObjArray *clusters = new TObjArray(100);
144 TBranch *branch = clustersTree->GetBranch("EMCALECARP");
145 branch->SetAddress(&clusters);
146 clustersTree->GetEvent(0);
148 Int_t nClusters = clusters->GetEntries(), nClustersNew=0;
149 AliDebug(1,Form("%d clusters",nClusters));
150 // Int_t nRP=0, nPC=0; // in input
151 esd->SetFirstEMCALCluster(esd->GetNumberOfCaloClusters()); // Put after Phos clusters
153 //######################################################
154 //#########Calculate trigger and set trigger info###########
155 //######################################################
158 // tr.SetPatchSize(1);//create 4x4 patches
161 Float_t maxAmp2x2 = tr.Get2x2MaxAmplitude();
162 Float_t maxAmpnxn = tr.GetnxnMaxAmplitude();
163 Float_t ampOutOfPatch2x2 = tr.Get2x2AmpOutOfPatch() ;
164 Float_t ampOutOfPatchnxn = tr.GetnxnAmpOutOfPatch() ;
166 AliEMCALGeometry * geom = 0;
167 AliRunLoader *runLoader = AliRunLoader::GetRunLoader();
168 if (runLoader->GetAliRun() && runLoader->GetAliRun()->GetDetector("EMCAL"))
169 geom = dynamic_cast<AliEMCAL*>(runLoader->GetAliRun()->GetDetector("EMCAL"))->GetGeometry();
171 geom = AliEMCALGeometry::GetInstance(AliEMCALGeometry::GetDefaulGeometryName());
173 Int_t iSM2x2 = tr.Get2x2SuperModule();
174 Int_t iSMnxn = tr.GetnxnSuperModule();
175 Int_t iCellPhi2x2 = tr.Get2x2CellPhi();
176 Int_t iCellPhinxn = tr.GetnxnCellPhi();
177 Int_t iCellEta2x2 = tr.Get2x2CellEta();
178 Int_t iCellEtanxn = tr.GetnxnCellEta();
180 AliDebug(2, Form("Trigger 2x2 max amp %f, out amp %f, SM %d, iphi %d ieta %d", maxAmp2x2, ampOutOfPatch2x2, iSM2x2,iCellPhi2x2, iCellEta2x2));
181 AliDebug(2, Form("Trigger 4x4 max amp %f , out amp %f, SM %d, iphi %d, ieta %d", maxAmpnxn, ampOutOfPatchnxn, iSMnxn,iCellPhinxn, iCellEtanxn));
183 TVector3 pos2x2(-1,-1,-1);
184 TVector3 posnxn(-1,-1,-1);
186 Int_t iAbsId2x2 = geom->GetAbsCellIdFromCellIndexes( iSM2x2, iCellPhi2x2, iCellEta2x2) ;
187 Int_t iAbsIdnxn = geom->GetAbsCellIdFromCellIndexes( iSMnxn, iCellPhinxn, iCellEtanxn) ;
188 geom->GetGlobal(iAbsId2x2, pos2x2);
189 geom->GetGlobal(iAbsIdnxn, posnxn);
191 TArrayF triggerPosition(6);
192 triggerPosition[0] = pos2x2(0) ;
193 triggerPosition[1] = pos2x2(1) ;
194 triggerPosition[2] = pos2x2(2) ;
195 triggerPosition[3] = posnxn(0) ;
196 triggerPosition[4] = posnxn(1) ;
197 triggerPosition[5] = posnxn(2) ;
199 TArrayF triggerAmplitudes(4);
200 triggerAmplitudes[0] = maxAmp2x2 ;
201 triggerAmplitudes[1] = ampOutOfPatch2x2 ;
202 triggerAmplitudes[2] = maxAmpnxn ;
203 triggerAmplitudes[3] = ampOutOfPatchnxn ;
205 esd->AddEMCALTriggerPosition(triggerPosition);
206 esd->AddEMCALTriggerAmplitudes(triggerAmplitudes);
208 //######################################################
209 //#######################TRACK MATCHING###############
210 //######################################################
211 //Fill list of integers, each one is index of track to which the cluster belongs.
213 // step 1 - initialize array of matched track indexes
214 Int_t *matchedTrack = new Int_t[nClusters];
215 for (Int_t iclus = 0; iclus < nClusters; iclus++)
216 matchedTrack[iclus] = -1; // neg. index --> no matched track
218 // step 2, change the flag for all matched clusters found in tracks
219 Int_t iemcalMatch = -1;
220 Int_t endtpc = esd->GetNumberOfTracks();
221 for (Int_t itrack = 0; itrack < endtpc; itrack++) {
222 AliESDtrack * track = esd->GetTrack(itrack) ; // retrieve track
223 iemcalMatch = track->GetEMCALcluster();
224 if(iemcalMatch >= 0) matchedTrack[iemcalMatch] = itrack;
227 //########################################
228 //##############Fill CaloClusters#############
229 //########################################
232 for (Int_t iClust = 0 ; iClust < nClusters ; iClust++) {
233 const AliEMCALRecPoint * clust = (const AliEMCALRecPoint*)clusters->At(iClust);
234 //if(clust->GetClusterType()== AliESDCaloCluster::kEMCALClusterv1) nRP++; else nPC++;
235 if (Debug()) clust->Print();
236 // Get information from EMCAL reconstruction points
239 clust->GetGlobalPosition(gpos);
240 for (Int_t ixyz=0; ixyz<3; ixyz++)
241 xyz[ixyz] = gpos[ixyz];
243 Int_t digitMult = clust->GetMultiplicity();
244 TArrayS amplList(digitMult);
245 TArrayS timeList(digitMult);
246 TArrayS digiList(digitMult);
247 Float_t *amplFloat = clust->GetEnergiesList();
248 Float_t *timeFloat = clust->GetTimeList();
249 Int_t *digitInts = clust->GetAbsId();
251 clust->GetElipsAxis(elipAxis);
253 // Convert Float_t* and Int_t* to Short_t* to save memory
254 // Problem : we should recalculate a cluster characteristics when discard digit(s)
255 Int_t newdigitMult = 0;
256 for (Int_t iDigit=0; iDigit<digitMult; iDigit++) {
257 if (amplFloat[iDigit] > 0) {
258 amplList[newdigitMult] = (UShort_t)(amplFloat[iDigit]*500);
259 // Time in units of 0.01 ns = 10 ps
260 if(timeFloat[iDigit] < 65536./timeScale)
261 timeList[newdigitMult] = (UShort_t)(timeFloat[iDigit]*timeScale);
263 timeList[newdigitMult] = 65535;
264 digiList[newdigitMult] = (UShort_t)(digitInts[iDigit]);
267 else if (clust->GetClusterType() != AliESDCaloCluster::kEMCALPseudoCluster)
268 Warning("FillESD()","Negative or 0 digit amplitude in cluster");
271 if(newdigitMult > 0) { // accept cluster if it has some digit
274 amplList.Set(newdigitMult);
275 timeList.Set(newdigitMult);
276 digiList.Set(newdigitMult);
279 Int_t parentMult = 0;
280 Int_t *parentList = clust->GetParents(parentMult);
282 // fills the ESDCaloCluster
283 AliESDCaloCluster * ec = new AliESDCaloCluster() ;
284 ec->SetClusterType(clust->GetClusterType());
285 ec->SetPosition(xyz);
286 ec->SetE(clust->GetEnergy());
287 ec->AddDigitAmplitude(amplList);
288 ec->AddDigitTime(timeList);
289 ec->AddDigitIndex(digiList);
291 if(clust->GetClusterType()== AliESDCaloCluster::kEMCALClusterv1){
293 ec->SetClusterDisp(clust->GetDispersion());
294 ec->SetClusterChi2(-1); //not yet implemented
295 ec->SetM02(elipAxis[0]*elipAxis[0]) ;
296 ec->SetM20(elipAxis[1]*elipAxis[1]) ;
297 ec->SetM11(-1) ; //not yet implemented
299 TArrayI arrayTrackMatched(1);// Only one track, temporal solution.
300 arrayTrackMatched[0]= matchedTrack[iClust];
301 ec->AddTracksMatched(arrayTrackMatched);
303 TArrayI arrayParents(parentMult,parentList);
304 ec->AddLabels(arrayParents);
307 // add the cluster to the esd object
308 esd->AddCaloCluster(ec);
312 } // cycle on clusters
314 delete [] matchedTrack;
316 esd->SetNumberOfEMCALClusters(nClustersNew);
317 //if(nClustersNew != nClusters)
318 //printf(" ##### nClusters %i -> new %i ##### \n", nClusters, nClustersNew );
320 //Fill ESDCaloCluster with PID weights
321 AliEMCALPID *pid = new AliEMCALPID;
322 //pid->SetPrintInfo(kTRUE);
323 pid->SetReconstructor(kTRUE);