]>
Commit | Line | Data |
---|---|---|
f6019cda | 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 | ||
16 | /* $Id$ */ | |
17 | ||
18 | //_________________________________________________________________________ | |
fa42b1f3 | 19 | //-- |
20 | //-- Yves Schutz (SUBATECH) | |
f6019cda | 21 | // Reconstruction class. Redesigned from the old AliReconstructionner class and |
22 | // derived from STEER/AliReconstructor. | |
23 | // | |
85c25c2e | 24 | //-- Aleksei Pavlinov : added staf for EMCAL jet trigger 9Apr 25, 2008) |
25 | // : fgDigitsArr should read just once at event | |
26 | ||
f6019cda | 27 | // --- ROOT system --- |
85c25c2e | 28 | #include <TList.h> |
29 | #include <TClonesArray.h> | |
60d8ad94 | 30 | #include <TH2.h> |
0c5b726e | 31 | #include "TGeoManager.h" |
32 | #include "TGeoMatrix.h" | |
f6019cda | 33 | |
34 | // --- Standard library --- | |
35 | ||
36 | // --- AliRoot header files --- | |
f6019cda | 37 | #include "AliEMCALReconstructor.h" |
5dee926e | 38 | |
aaa3cb7c | 39 | #include "AliCodeTimer.h" |
af885e0f | 40 | #include "AliESDEvent.h" |
89ffc0b0 | 41 | #include "AliESDCaloCluster.h" |
0e7c6655 | 42 | #include "AliESDCaloCells.h" |
6a0cf740 | 43 | #include "AliESDtrack.h" |
5dee926e | 44 | #include "AliEMCALLoader.h" |
98e9578e | 45 | #include "AliEMCALRawUtils.h" |
0e7c6655 | 46 | #include "AliEMCALDigit.h" |
f6019cda | 47 | #include "AliEMCALClusterizerv1.h" |
5dee926e | 48 | #include "AliEMCALRecPoint.h" |
dc293ae9 | 49 | #include "AliEMCALPID.h" |
0964c2e9 | 50 | #include "AliEMCALTrigger.h" |
1d59832c | 51 | #include "AliRawReader.h" |
fa42b1f3 | 52 | #include "AliCDBEntry.h" |
53 | #include "AliCDBManager.h" | |
65bdc82f | 54 | #include "AliEMCALGeometry.h" |
ac8ae9fe | 55 | #include "AliEMCAL.h" |
85c25c2e | 56 | #include "AliEMCALHistoUtilities.h" |
57 | #include "AliESDVZERO.h" | |
0c5b726e | 58 | #include "AliCDBManager.h" |
72c58de0 | 59 | #include "AliRunLoader.h" |
60 | #include "AliRun.h" | |
916f1e76 | 61 | #include "AliEMCALTriggerData.h" |
62 | #include "AliEMCALTriggerElectronics.h" | |
63 | #include "AliVZEROLoader.h" | |
1d59832c | 64 | |
85c25c2e | 65 | ClassImp(AliEMCALReconstructor) |
f6019cda | 66 | |
ba6de5ea | 67 | const AliEMCALRecParam* AliEMCALReconstructor::fgkRecParam = 0; // EMCAL rec. parameters |
65bdc82f | 68 | AliEMCALRawUtils* AliEMCALReconstructor::fgRawUtils = 0; // EMCAL raw utilities class |
9517d886 | 69 | AliEMCALClusterizer* AliEMCALReconstructor::fgClusterizer = 0; // EMCAL clusterizer class |
85c25c2e | 70 | TClonesArray* AliEMCALReconstructor::fgDigitsArr = 0; // shoud read just once at event |
916f1e76 | 71 | AliEMCALTriggerElectronics* AliEMCALReconstructor::fgTriggerProcessor = 0x0; |
f6019cda | 72 | //____________________________________________________________________________ |
18a21c7c | 73 | AliEMCALReconstructor::AliEMCALReconstructor() |
40164976 | 74 | : fDebug(kFALSE), fList(0), fGeom(0),fCalibData(0),fPedestalData(0) |
f6019cda | 75 | { |
76 | // ctor | |
65bdc82f | 77 | |
78 | fgRawUtils = new AliEMCALRawUtils; | |
72c58de0 | 79 | |
80 | //To make sure we match with the geometry in a simulation file, | |
81 | //let's try to get it first. If not, take the default geometry | |
33c3c91a | 82 | AliRunLoader *rl = AliRunLoader::Instance(); |
72c58de0 | 83 | if (rl->GetAliRun() && rl->GetAliRun()->GetDetector("EMCAL")) { |
84 | fGeom = dynamic_cast<AliEMCAL*>(rl->GetAliRun()->GetDetector("EMCAL"))->GetGeometry(); | |
85 | } else { | |
86 | AliInfo(Form("Using default geometry in reconstruction")); | |
937d0661 | 87 | fGeom = AliEMCALGeometry::GetInstance(AliEMCALGeometry::GetDefaultGeometryName()); |
65bdc82f | 88 | } |
0e7c6655 | 89 | |
0c5b726e | 90 | //Get calibration parameters |
91 | if(!fCalibData) | |
92 | { | |
93 | AliCDBEntry *entry = (AliCDBEntry*) | |
94 | AliCDBManager::Instance()->Get("EMCAL/Calib/Data"); | |
95 | if (entry) fCalibData = (AliEMCALCalibData*) entry->GetObject(); | |
96 | } | |
97 | ||
98 | if(!fCalibData) | |
99 | AliFatal("Calibration parameters not found in CDB!"); | |
100 | ||
40164976 | 101 | //Get calibration parameters |
102 | if(!fPedestalData) | |
103 | { | |
104 | AliCDBEntry *entry = (AliCDBEntry*) | |
105 | AliCDBManager::Instance()->Get("EMCAL/Calib/Pedestals"); | |
106 | if (entry) fPedestalData = (AliCaloCalibPedestal*) entry->GetObject(); | |
107 | } | |
108 | ||
109 | if(!fPedestalData) | |
110 | AliFatal("Dead map not found in CDB!"); | |
111 | ||
112 | ||
0c5b726e | 113 | //Init the clusterizer with geometry and calibration pointers, avoid doing it twice. |
40164976 | 114 | fgClusterizer = new AliEMCALClusterizerv1(fGeom, fCalibData,fPedestalData); |
0c5b726e | 115 | |
72c58de0 | 116 | if(!fGeom) AliFatal(Form("Could not get geometry!")); |
117 | ||
916f1e76 | 118 | fgTriggerProcessor = new AliEMCALTriggerElectronics(); |
f6019cda | 119 | } |
120 | ||
f6019cda | 121 | //____________________________________________________________________________ |
122 | AliEMCALReconstructor::~AliEMCALReconstructor() | |
123 | { | |
124 | // dtor | |
65bdc82f | 125 | delete fGeom; |
5e3106bc | 126 | delete fgRawUtils; |
127 | delete fgClusterizer; | |
916f1e76 | 128 | delete fgTriggerProcessor; |
129 | ||
aaa3cb7c | 130 | AliCodeTimer::Instance()->Print(); |
f6019cda | 131 | } |
132 | ||
85c25c2e | 133 | //____________________________________________________________________________ |
134 | void AliEMCALReconstructor::Init() | |
135 | { | |
136 | // Trigger hists - Oct 24, 2007 | |
137 | fList = AliEMCALHistoUtilities::GetTriggersListOfHists(kTRUE); | |
138 | } | |
139 | ||
f6019cda | 140 | //____________________________________________________________________________ |
c47157cd | 141 | void AliEMCALReconstructor::Reconstruct(TTree* digitsTree, TTree* clustersTree) const |
f6019cda | 142 | { |
143 | // method called by AliReconstruction; | |
144 | // Only the clusterization is performed,; the rest of the reconstruction is done in FillESD because the track | |
145 | // segment maker needs access to the AliESD object to retrieve the tracks reconstructed by | |
146 | // the global tracking. | |
c47157cd | 147 | // Works on the current event. |
fa42b1f3 | 148 | |
1a429a6b | 149 | AliCodeTimerAuto("",0) |
aaa3cb7c | 150 | |
85c25c2e | 151 | ReadDigitsArrayFromTree(digitsTree); |
0832a2bf | 152 | fgClusterizer->InitParameters(); |
4601e3a7 | 153 | fgClusterizer->SetOutput(clustersTree); |
916f1e76 | 154 | |
155 | AliEMCALTriggerData* trgData = new AliEMCALTriggerData(); | |
156 | ||
157 | Int_t bufferSize = 32000; | |
158 | ||
159 | if (TBranch* triggerBranch = clustersTree->GetBranch("EMTRG")) | |
160 | triggerBranch->SetAddress(&trgData); | |
161 | else | |
162 | clustersTree->Branch("EMTRG","AliEMCALTriggerData",&trgData,bufferSize); | |
163 | ||
164 | AliVZEROLoader* vzeroLoader = dynamic_cast<AliVZEROLoader*>(AliRunLoader::Instance()->GetDetectorLoader("VZERO")); | |
165 | ||
166 | TTree* treeV0 = 0x0; | |
167 | ||
168 | if (vzeroLoader) | |
169 | { | |
170 | vzeroLoader->LoadDigits("READ"); | |
171 | treeV0 = vzeroLoader->TreeD(); | |
172 | } | |
173 | ||
174 | TClonesArray *trgDigits = new TClonesArray("AliEMCALRawDigit",1000); | |
175 | TBranch *branchdig = digitsTree->GetBranch("EMTRG"); | |
176 | if (!branchdig) | |
177 | { | |
178 | AliError("Can't get the branch with the EMCAL trigger digits !"); | |
179 | return; | |
180 | } | |
181 | ||
182 | branchdig->SetAddress(&trgDigits); | |
183 | branchdig->GetEntry(0); | |
184 | ||
185 | fgTriggerProcessor->Digits2Trigger(trgDigits, treeV0, trgData); | |
186 | ||
187 | trgDigits->Delete(); | |
0c5b726e | 188 | |
85c25c2e | 189 | if(fgDigitsArr && fgDigitsArr->GetEntries()) { |
190 | ||
9517d886 | 191 | fgClusterizer->SetInput(digitsTree); |
9517d886 | 192 | |
85c25c2e | 193 | if(Debug()) |
9517d886 | 194 | fgClusterizer->Digits2Clusters("deb all") ; |
85c25c2e | 195 | else |
9517d886 | 196 | fgClusterizer->Digits2Clusters(""); |
197 | ||
198 | fgClusterizer->Clear(); | |
85c25c2e | 199 | |
200 | } | |
9517d886 | 201 | |
916f1e76 | 202 | clustersTree->Fill(); |
203 | ||
204 | delete trgData; | |
f6019cda | 205 | } |
206 | ||
a68156e6 | 207 | //____________________________________________________________________________ |
c47157cd | 208 | void AliEMCALReconstructor::ConvertDigits(AliRawReader* rawReader, TTree* digitsTree) const |
98e9578e | 209 | |
a68156e6 | 210 | { |
c47157cd | 211 | // Conversion from raw data to |
212 | // EMCAL digits. | |
213 | // Works on a single-event basis | |
85c60a8e | 214 | |
98e9578e | 215 | rawReader->Reset() ; |
98e9578e | 216 | |
3e5fa09c | 217 | TClonesArray *digitsArr = new TClonesArray("AliEMCALDigit",200); |
916f1e76 | 218 | TClonesArray *digitsTrg = new TClonesArray("AliEMCALRawDigit", 200); |
219 | ||
c47157cd | 220 | Int_t bufsize = 32000; |
221 | digitsTree->Branch("EMCAL", &digitsArr, bufsize); | |
916f1e76 | 222 | digitsTree->Branch("EMTRG", &digitsTrg, bufsize); |
98e9578e | 223 | |
65bdc82f | 224 | //must be done here because, in constructor, option is not yet known |
225 | fgRawUtils->SetOption(GetOption()); | |
b4133f05 | 226 | |
0832a2bf | 227 | fgRawUtils->SetRawFormatHighLowGainFactor(GetRecParam()->GetHighLowGainFactor()); |
228 | fgRawUtils->SetRawFormatOrder(GetRecParam()->GetOrderParameter()); | |
229 | fgRawUtils->SetRawFormatTau(GetRecParam()->GetTau()); | |
230 | fgRawUtils->SetNoiseThreshold(GetRecParam()->GetNoiseThreshold()); | |
231 | fgRawUtils->SetNPedSamples(GetRecParam()->GetNPedSamples()); | |
9f467289 | 232 | fgRawUtils->SetRemoveBadChannels(GetRecParam()->GetRemoveBadChannels()); |
233 | fgRawUtils->SetFittingAlgorithm(GetRecParam()->GetFittingAlgorithm()); | |
b4133f05 | 234 | |
916f1e76 | 235 | fgRawUtils->Raw2Digits(rawReader,digitsArr,fPedestalData,digitsTrg); |
c615db53 | 236 | |
237 | digitsTree->Fill(); | |
89d338a6 | 238 | digitsArr->Delete(); |
916f1e76 | 239 | digitsTrg->Delete(); |
89d338a6 | 240 | delete digitsArr; |
916f1e76 | 241 | delete digitsTrg; |
c615db53 | 242 | |
a68156e6 | 243 | } |
244 | ||
85c25c2e | 245 | |
f6019cda | 246 | //____________________________________________________________________________ |
0e7c6655 | 247 | void AliEMCALReconstructor::FillESD(TTree* digitsTree, TTree* clustersTree, |
c47157cd | 248 | AliESDEvent* esd) const |
f6019cda | 249 | { |
98e9578e | 250 | // Called by AliReconstruct after Reconstruct() and global tracking and vertexing |
85c25c2e | 251 | // and V0 |
c47157cd | 252 | // Works on the current event |
85c25c2e | 253 | // printf(" ## AliEMCALReconstructor::FillESD() is started ### \n "); |
254 | //return; | |
92da3372 | 255 | |
6a0cf740 | 256 | //###################################################### |
0964c2e9 | 257 | //#########Calculate trigger and set trigger info########### |
6a0cf740 | 258 | //###################################################### |
85c25c2e | 259 | |
260 | AliEMCALTrigger tr; | |
261 | // tr.SetPatchSize(1); // create 4x4 patches | |
262 | tr.SetSimulation(kFALSE); // Reconstruction mode | |
263 | tr.SetDigitsList(fgDigitsArr); | |
264 | // Get VZERO total multiplicity for jet trigger simulation | |
265 | // The simulation of jey trigger will be incorrect if no VZERO data | |
266 | // at ESD | |
267 | AliESDVZERO* vZero = esd->GetVZEROData(); | |
268 | if(vZero) { | |
269 | tr.SetVZER0Multiplicity(vZero->GetMTotV0A() + vZero->GetMTotV0C()); | |
270 | } | |
271 | // | |
0964c2e9 | 272 | tr.Trigger(); |
85c25c2e | 273 | |
0964c2e9 | 274 | Float_t maxAmp2x2 = tr.Get2x2MaxAmplitude(); |
275 | Float_t maxAmpnxn = tr.GetnxnMaxAmplitude(); | |
276 | Float_t ampOutOfPatch2x2 = tr.Get2x2AmpOutOfPatch() ; | |
277 | Float_t ampOutOfPatchnxn = tr.GetnxnAmpOutOfPatch() ; | |
278 | ||
0964c2e9 | 279 | Int_t iSM2x2 = tr.Get2x2SuperModule(); |
280 | Int_t iSMnxn = tr.GetnxnSuperModule(); | |
85c25c2e | 281 | Int_t iModulePhi2x2 = tr.Get2x2ModulePhi(); |
282 | Int_t iModulePhinxn = tr.GetnxnModulePhi(); | |
283 | Int_t iModuleEta2x2 = tr.Get2x2ModuleEta(); | |
284 | Int_t iModuleEtanxn = tr.GetnxnModuleEta(); | |
0964c2e9 | 285 | |
85c25c2e | 286 | AliDebug(2, Form("Trigger 2x2 max amp %f, out amp %f, SM %d, iphi %d ieta %d", maxAmp2x2, ampOutOfPatch2x2, iSM2x2,iModulePhi2x2, iModuleEta2x2)); |
287 | AliDebug(2, Form("Trigger 4x4 max amp %f , out amp %f, SM %d, iphi %d, ieta %d", maxAmpnxn, ampOutOfPatchnxn, iSMnxn,iModulePhinxn, iModuleEtanxn)); | |
0964c2e9 | 288 | |
289 | TVector3 pos2x2(-1,-1,-1); | |
290 | TVector3 posnxn(-1,-1,-1); | |
291 | ||
85c25c2e | 292 | Int_t iAbsId2x2 = fGeom->GetAbsCellIdFromCellIndexes( iSM2x2, iModulePhi2x2, iModuleEta2x2) ; // should be changed to Module |
293 | Int_t iAbsIdnxn = fGeom->GetAbsCellIdFromCellIndexes( iSMnxn, iModulePhinxn, iModuleEtanxn) ; | |
65bdc82f | 294 | fGeom->GetGlobal(iAbsId2x2, pos2x2); |
295 | fGeom->GetGlobal(iAbsIdnxn, posnxn); | |
85c25c2e | 296 | //printf(" iAbsId2x2 %i iAbsIdnxn %i \n", iAbsId2x2, iAbsIdnxn); |
0964c2e9 | 297 | |
298 | TArrayF triggerPosition(6); | |
299 | triggerPosition[0] = pos2x2(0) ; | |
300 | triggerPosition[1] = pos2x2(1) ; | |
301 | triggerPosition[2] = pos2x2(2) ; | |
302 | triggerPosition[3] = posnxn(0) ; | |
303 | triggerPosition[4] = posnxn(1) ; | |
85c25c2e | 304 | triggerPosition[5] = posnxn(2) ; |
305 | //printf(" triggerPosition "); | |
306 | //for(int i=0; i<6; i++) printf(" %i %f : ", i, triggerPosition[i]); | |
0964c2e9 | 307 | |
308 | TArrayF triggerAmplitudes(4); | |
309 | triggerAmplitudes[0] = maxAmp2x2 ; | |
310 | triggerAmplitudes[1] = ampOutOfPatch2x2 ; | |
311 | triggerAmplitudes[2] = maxAmpnxn ; | |
312 | triggerAmplitudes[3] = ampOutOfPatchnxn ; | |
85c25c2e | 313 | //printf("\n triggerAmplitudes "); |
314 | //for(int i=0; i<4; i++) printf(" %i %f : ", i, triggerAmplitudes[i]); | |
315 | //printf("\n"); | |
85d4cbde | 316 | //tr.Print(""); |
60d8ad94 | 317 | // |
318 | // Trigger jet staff | |
319 | // | |
320 | if(tr.GetNJetThreshold()>0) { | |
321 | // Jet phi/eta | |
322 | Int_t n0 = triggerPosition.GetSize(); | |
323 | const TH2F *hpatch = tr.GetJetMatrixE(); | |
324 | triggerPosition.Set(n0 + 2); | |
325 | for(Int_t i=0; i<2; i++) triggerPosition[n0+i] = hpatch->GetMean(i+1); | |
326 | // Add jet ampitudes | |
327 | n0 = triggerAmplitudes.GetSize(); | |
328 | triggerAmplitudes.Set(n0 + tr.GetNJetThreshold()); | |
329 | Double_t *ampJet = tr.GetL1JetThresholds(); | |
330 | for(Int_t i=0; i<tr.GetNJetThreshold(); i++){ | |
331 | triggerAmplitudes[n0 + i] = Float_t(ampJet[i]); | |
332 | } | |
333 | } | |
0964c2e9 | 334 | esd->AddEMCALTriggerPosition(triggerPosition); |
335 | esd->AddEMCALTriggerAmplitudes(triggerAmplitudes); | |
85c25c2e | 336 | // Fill trigger hists |
337 | AliEMCALHistoUtilities::FillTriggersListOfHists(fList,&triggerPosition,&triggerAmplitudes); | |
aaa3cb7c | 338 | |
0e7c6655 | 339 | //######################################## |
340 | //##############Fill CaloCells############### | |
341 | //######################################## | |
aaa3cb7c | 342 | |
0e7c6655 | 343 | TClonesArray *digits = new TClonesArray("AliEMCALDigit",1000); |
344 | TBranch *branchdig = digitsTree->GetBranch("EMCAL"); | |
345 | if (!branchdig) { | |
0c5b726e | 346 | AliError("can't get the branch with the EMCAL digits !"); |
0e7c6655 | 347 | return; |
348 | } | |
349 | branchdig->SetAddress(&digits); | |
350 | digitsTree->GetEvent(0); | |
351 | Int_t nDigits = digits->GetEntries(), idignew = 0 ; | |
352 | AliDebug(1,Form("%d digits",nDigits)); | |
353 | ||
354 | AliESDCaloCells &emcCells = *(esd->GetEMCALCells()); | |
355 | emcCells.CreateContainer(nDigits); | |
356 | emcCells.SetType(AliESDCaloCells::kEMCALCell); | |
0c5b726e | 357 | Float_t energy = 0; |
0e7c6655 | 358 | for (Int_t idig = 0 ; idig < nDigits ; idig++) { |
359 | const AliEMCALDigit * dig = (const AliEMCALDigit*)digits->At(idig); | |
360 | if(dig->GetAmp() > 0 ){ | |
0c5b726e | 361 | energy = (static_cast<AliEMCALClusterizerv1*> (fgClusterizer))->Calibrate(dig->GetAmp(),dig->GetId()); |
40164976 | 362 | if(energy > 0){ //Digits tagged as bad (dead, hot, not alive) are set to 0 in calibrate, remove them |
363 | emcCells.SetCell(idignew,dig->GetId(),energy, dig->GetTime()); | |
364 | idignew++; | |
365 | } | |
0e7c6655 | 366 | } |
367 | } | |
368 | emcCells.SetNumberOfCells(idignew); | |
369 | emcCells.Sort(); | |
370 | ||
371 | //------------------------------------------------------------ | |
372 | //-----------------CLUSTERS----------------------------- | |
373 | //------------------------------------------------------------ | |
374 | TObjArray *clusters = new TObjArray(100); | |
375 | TBranch *branch = clustersTree->GetBranch("EMCALECARP"); | |
376 | branch->SetAddress(&clusters); | |
377 | clustersTree->GetEvent(0); | |
378 | ||
379 | Int_t nClusters = clusters->GetEntries(), nClustersNew=0; | |
380 | AliDebug(1,Form("%d clusters",nClusters)); | |
381 | esd->SetFirstEMCALCluster(esd->GetNumberOfCaloClusters()); // Put after Phos clusters | |
382 | ||
85c25c2e | 383 | |
6a0cf740 | 384 | //###################################################### |
385 | //#######################TRACK MATCHING############### | |
386 | //###################################################### | |
387 | //Fill list of integers, each one is index of track to which the cluster belongs. | |
388 | ||
389 | // step 1 - initialize array of matched track indexes | |
390 | Int_t *matchedTrack = new Int_t[nClusters]; | |
391 | for (Int_t iclus = 0; iclus < nClusters; iclus++) | |
392 | matchedTrack[iclus] = -1; // neg. index --> no matched track | |
393 | ||
394 | // step 2, change the flag for all matched clusters found in tracks | |
395 | Int_t iemcalMatch = -1; | |
396 | Int_t endtpc = esd->GetNumberOfTracks(); | |
397 | for (Int_t itrack = 0; itrack < endtpc; itrack++) { | |
398 | AliESDtrack * track = esd->GetTrack(itrack) ; // retrieve track | |
399 | iemcalMatch = track->GetEMCALcluster(); | |
65f4a419 | 400 | if(iemcalMatch >= 0) matchedTrack[iemcalMatch] = itrack; |
6a0cf740 | 401 | } |
85c25c2e | 402 | |
6a0cf740 | 403 | //######################################## |
85c25c2e | 404 | //##############Fill CaloClusters############# |
6a0cf740 | 405 | //######################################## |
35397e76 | 406 | esd->SetNumberOfEMCALClusters(nClusters); |
5dee926e | 407 | for (Int_t iClust = 0 ; iClust < nClusters ; iClust++) { |
c47157cd | 408 | const AliEMCALRecPoint * clust = (const AliEMCALRecPoint*)clusters->At(iClust); |
8ada0ffe | 409 | //if(clust->GetClusterType()== AliESDCaloCluster::kEMCALClusterv1) nRP++; else nPC++; |
85c60a8e | 410 | if (Debug()) clust->Print(); |
a7a5421e | 411 | // Get information from EMCAL reconstruction points |
85c60a8e | 412 | Float_t xyz[3]; |
5dee926e | 413 | TVector3 gpos; |
414 | clust->GetGlobalPosition(gpos); | |
35397e76 | 415 | for (Int_t ixyz=0; ixyz<3; ixyz++) |
5dee926e | 416 | xyz[ixyz] = gpos[ixyz]; |
85c25c2e | 417 | Float_t elipAxis[2]; |
418 | clust->GetElipsAxis(elipAxis); | |
35397e76 | 419 | //Create digits lists |
420 | Int_t cellMult = clust->GetMultiplicity(); | |
421 | //TArrayS digiList(digitMult); | |
422 | Float_t *amplFloat = clust->GetEnergiesList(); | |
423 | Int_t *digitInts = clust->GetAbsId(); | |
424 | TArrayS absIdList(cellMult); | |
eb972628 | 425 | TArrayD fracList(cellMult); |
35397e76 | 426 | |
427 | Int_t newCellMult = 0; | |
428 | for (Int_t iCell=0; iCell<cellMult; iCell++) { | |
429 | if (amplFloat[iCell] > 0) { | |
430 | absIdList[newCellMult] = (UShort_t)(digitInts[iCell]); | |
eb972628 | 431 | //Uncomment when unfolding is done |
432 | //if(emcCells.GetCellAmplitude(digitInts[iCell])>0) | |
433 | //fracList[newCellMult] = amplFloat[iCell]/(emcCells.GetCellAmplitude(digitInts[iCell])*calibration);//get cell calibration value | |
434 | //else | |
435 | fracList[newCellMult] = 0; | |
35397e76 | 436 | newCellMult++; |
92da3372 | 437 | } |
92da3372 | 438 | } |
85c25c2e | 439 | |
eb972628 | 440 | absIdList.Set(newCellMult); |
441 | fracList.Set(newCellMult); | |
442 | ||
35397e76 | 443 | if(newCellMult > 0) { // accept cluster if it has some digit |
444 | nClustersNew++; | |
65721814 | 445 | //Primaries |
7592dfc4 | 446 | Int_t parentMult = 0; |
fa42b1f3 | 447 | Int_t *parentList = clust->GetParents(parentMult); |
a7a5421e | 448 | // fills the ESDCaloCluster |
35397e76 | 449 | AliESDCaloCluster * ec = new AliESDCaloCluster() ; |
450 | ec->SetClusterType(AliESDCaloCluster::kEMCALClusterv1); | |
7592dfc4 | 451 | ec->SetPosition(xyz); |
452 | ec->SetE(clust->GetEnergy()); | |
40164976 | 453 | |
454 | //Distance to the nearest bad crystal | |
455 | ec->SetDistanceToBadChannel(clust->GetDistanceToBadTower()); | |
456 | ||
35397e76 | 457 | ec->SetNCells(newCellMult); |
458 | //Change type of list from short to ushort | |
459 | UShort_t *newAbsIdList = new UShort_t[newCellMult]; | |
eb972628 | 460 | Double_t *newFracList = new Double_t[newCellMult]; |
35397e76 | 461 | for(Int_t i = 0; i < newCellMult ; i++) { |
462 | newAbsIdList[i]=absIdList[i]; | |
eb972628 | 463 | newFracList[i]=fracList[i]; |
35397e76 | 464 | } |
465 | ec->SetCellsAbsId(newAbsIdList); | |
eb972628 | 466 | ec->SetCellsAmplitudeFraction(newFracList); |
35397e76 | 467 | ec->SetClusterDisp(clust->GetDispersion()); |
468 | ec->SetClusterChi2(-1); //not yet implemented | |
469 | ec->SetM02(elipAxis[0]*elipAxis[0]) ; | |
470 | ec->SetM20(elipAxis[1]*elipAxis[1]) ; | |
78902954 | 471 | ec->SetTOF(clust->GetTime()) ; //time-of-fligh |
225cd96d | 472 | ec->SetNExMax(clust->GetNExMax()); //number of local maxima |
35397e76 | 473 | TArrayI arrayTrackMatched(1);// Only one track, temporal solution. |
474 | arrayTrackMatched[0]= matchedTrack[iClust]; | |
475 | ec->AddTracksMatched(arrayTrackMatched); | |
476 | ||
477 | TArrayI arrayParents(parentMult,parentList); | |
478 | ec->AddLabels(arrayParents); | |
479 | ||
6a0cf740 | 480 | // add the cluster to the esd object |
eb972628 | 481 | esd->AddCaloCluster(ec); |
a7a5421e | 482 | delete ec; |
85d4cbde | 483 | delete [] newAbsIdList ; |
eb972628 | 484 | delete [] newFracList ; |
35397e76 | 485 | } |
486 | } // cycle on clusters | |
85c25c2e | 487 | |
35397e76 | 488 | delete [] matchedTrack; |
85c25c2e | 489 | |
35397e76 | 490 | esd->SetNumberOfEMCALClusters(nClustersNew); |
491 | //if(nClustersNew != nClusters) | |
492 | //printf(" ##### nClusters %i -> new %i ##### \n", nClusters, nClustersNew ); | |
85c25c2e | 493 | |
35397e76 | 494 | //Fill ESDCaloCluster with PID weights |
85c25c2e | 495 | AliEMCALPID *pid = new AliEMCALPID; |
496 | //pid->SetPrintInfo(kTRUE); | |
497 | pid->SetReconstructor(kTRUE); | |
498 | pid->RunPID(esd); | |
85c25c2e | 499 | delete pid; |
eb972628 | 500 | |
89d338a6 | 501 | delete digits; |
85c25c2e | 502 | delete clusters; |
eb972628 | 503 | |
35397e76 | 504 | // printf(" ## AliEMCALReconstructor::FillESD() is ended : ncl %i -> %i ### \n ",nClusters, nClustersNew); |
0c5b726e | 505 | |
506 | //Store EMCAL misalignment matrixes | |
507 | FillMisalMatrixes(esd) ; | |
508 | ||
509 | } | |
510 | ||
511 | //================================================================================== | |
512 | void AliEMCALReconstructor::FillMisalMatrixes(AliESDEvent* esd)const{ | |
513 | //Store EMCAL matrixes in ESD Header | |
514 | ||
515 | //Check, if matrixes was already stored | |
516 | for(Int_t sm = 0 ; sm < 12; sm++){ | |
517 | if(esd->GetEMCALMatrix(sm)!=0) | |
518 | return ; | |
519 | } | |
520 | ||
521 | //Create and store matrixes | |
522 | if(!gGeoManager){ | |
523 | AliError("Can not store misal. matrixes: no gGeoManager! \n") ; | |
524 | return ; | |
525 | } | |
526 | //Note, that owner of copied marixes will be header | |
527 | char path[255] ; | |
5e3106bc | 528 | TGeoHMatrix * m = 0x0; |
0c5b726e | 529 | for(Int_t sm = 0; sm < 12; sm++){ |
530 | sprintf(path,"/ALIC_1/XEN1_1/SMOD_%d",sm+1) ; //In Geometry modules numbered 1,2,.,5 | |
531 | if(sm >= 10) sprintf(path,"/ALIC_1/XEN1_1/SM10_%d",sm-10+1) ; | |
532 | ||
9ddc5deb | 533 | if (gGeoManager->CheckPath(path)){ |
0c5b726e | 534 | m = gGeoManager->GetCurrentMatrix() ; |
535 | esd->SetEMCALMatrix(new TGeoHMatrix(*m),sm) ; | |
536 | } | |
537 | else{ | |
538 | esd->SetEMCALMatrix(NULL,sm) ; | |
539 | } | |
540 | } | |
f6019cda | 541 | } |
dc293ae9 | 542 | |
0c5b726e | 543 | |
544 | ||
9517d886 | 545 | //__________________________________________________________________________ |
85c25c2e | 546 | void AliEMCALReconstructor::ReadDigitsArrayFromTree(TTree *digitsTree) const |
547 | { | |
548 | // See AliEMCALClusterizer::SetInput(TTree *digitsTree); | |
549 | if(fgDigitsArr) { | |
550 | // Clear previous digits | |
551 | fgDigitsArr->Delete(); | |
552 | delete fgDigitsArr; | |
553 | } | |
554 | // Read the digits from the input tree | |
555 | TBranch *branch = digitsTree->GetBranch("EMCAL"); | |
556 | if (!branch) { | |
557 | AliError("can't get the branch with the EMCAL digits !"); | |
558 | return; | |
559 | } | |
560 | fgDigitsArr = new TClonesArray("AliEMCALDigit",100); | |
561 | branch->SetAddress(&fgDigitsArr); | |
562 | branch->GetEntry(0); | |
563 | } | |
98e9578e | 564 | |
916f1e76 | 565 |