]>
Commit | Line | Data |
---|---|---|
7a4cf423 | 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: AliAnalysisTaskCaloFilter.cxx $ */ | |
17 | ||
18 | ////////////////////////////////////////////////////////// | |
19 | // Filter the ESDCaloClusters and ESDCaloCells of EMCAL, | |
20 | // PHOS or both, creating the corresponing AODCaloClusters | |
21 | // and AODCaloCells. | |
22 | // Keep also the AODHeader information and the vertex. | |
23 | // Needed for calorimeter calibration. | |
24 | // Copy of AliAnalysisTaskESDfilter. | |
25 | // Author: Gustavo Conesa Balbastre (INFN - Frascati) | |
26 | ////////////////////////////////////////////////////////// | |
27 | ||
44cf05d7 | 28 | //Root |
29 | #include "TGeoManager.h" | |
30 | ||
31 | //STEER | |
7a4cf423 | 32 | #include "AliESDEvent.h" |
33 | #include "AliAODEvent.h" | |
7a4cf423 | 34 | #include "AliLog.h" |
247abff4 | 35 | #include "AliVCluster.h" |
36 | #include "AliVCaloCells.h" | |
247abff4 | 37 | #include "AliVEventHandler.h" |
38 | #include "AliAnalysisManager.h" | |
39 | #include "AliInputEventHandler.h" | |
3a58eee6 | 40 | #include "AliESDtrackCuts.h" |
44cf05d7 | 41 | #include "AliTriggerAnalysis.h" |
42 | ||
43 | //EMCAL | |
44 | #include "AliEMCALRecoUtils.h" | |
45 | #include "AliEMCALGeometry.h" | |
46 | ||
47 | #include "AliAnalysisTaskCaloFilter.h" | |
7a4cf423 | 48 | |
49 | ClassImp(AliAnalysisTaskCaloFilter) | |
50 | ||
51 | //////////////////////////////////////////////////////////////////////// | |
52 | ||
53 | AliAnalysisTaskCaloFilter::AliAnalysisTaskCaloFilter(): | |
247abff4 | 54 | AliAnalysisTaskSE(), //fCuts(0x0), |
55 | fCaloFilter(0), fCorrect(kFALSE), | |
3b13c34c | 56 | fEMCALGeo(0x0),fEMCALGeoName("EMCAL_FIRSTYEARV1"), |
3a58eee6 | 57 | fEMCALRecoUtils(new AliEMCALRecoUtils), |
44cf05d7 | 58 | fESDtrackCuts(0), fTriggerAnalysis (new AliTriggerAnalysis), fTrackMultEtaCut(0.8), |
3b13c34c | 59 | fLoadEMCALMatrices(kFALSE), //fLoadPHOSMatrices(kFALSE), |
60 | fGeoMatrixSet(kFALSE) | |
7a4cf423 | 61 | { |
62 | // Default constructor | |
3a58eee6 | 63 | fESDtrackCuts = AliESDtrackCuts::GetStandardITSTPCTrackCuts2010(); |
3b13c34c | 64 | for(Int_t i = 0; i < 10; i++) fEMCALMatrix[i] = 0 ; |
65 | //for(Int_t i = 0; i < 5 ; i++) fPHOSMatrix[i] = 0 ; | |
3a58eee6 | 66 | |
7a4cf423 | 67 | } |
68 | ||
69 | //__________________________________________________ | |
70 | AliAnalysisTaskCaloFilter::AliAnalysisTaskCaloFilter(const char* name): | |
247abff4 | 71 | AliAnalysisTaskSE(name), //fCuts(0x0), |
72 | fCaloFilter(0), fCorrect(kFALSE), | |
3b13c34c | 73 | fEMCALGeo(0x0),fEMCALGeoName("EMCAL_FIRSTYEARV1"), |
3a58eee6 | 74 | fEMCALRecoUtils(new AliEMCALRecoUtils), |
44cf05d7 | 75 | fESDtrackCuts(0), fTriggerAnalysis (new AliTriggerAnalysis), fTrackMultEtaCut(0.8), |
3b13c34c | 76 | fLoadEMCALMatrices(kFALSE), //fLoadPHOSMatrices(kFALSE), |
77 | fGeoMatrixSet(kFALSE) | |
7a4cf423 | 78 | { |
79 | // Constructor | |
3a58eee6 | 80 | fESDtrackCuts = AliESDtrackCuts::GetStandardITSTPCTrackCuts2010(); |
3b13c34c | 81 | for(Int_t i = 0; i < 10; i++) fEMCALMatrix[i] = 0 ; |
82 | //for(Int_t i = 0; i < 5 ; i++) fPHOSMatrix[i] = 0 ; | |
3a58eee6 | 83 | |
7a4cf423 | 84 | } |
85 | ||
86 | //__________________________________________________ | |
247abff4 | 87 | AliAnalysisTaskCaloFilter::~AliAnalysisTaskCaloFilter() |
7a4cf423 | 88 | { |
247abff4 | 89 | //Destructor. |
90 | ||
44cf05d7 | 91 | if(fEMCALGeo) delete fEMCALGeo; |
92 | if(fEMCALRecoUtils) delete fEMCALRecoUtils; | |
93 | if(fESDtrackCuts) delete fESDtrackCuts; | |
94 | if(fTriggerAnalysis) delete fTriggerAnalysis; | |
3b13c34c | 95 | |
247abff4 | 96 | } |
97 | ||
98 | //__________________________________________________ | |
99 | void AliAnalysisTaskCaloFilter::UserCreateOutputObjects() | |
100 | { | |
101 | // Init geometry | |
102 | ||
103 | fEMCALGeo = AliEMCALGeometry::GetInstance(fEMCALGeoName) ; | |
7a4cf423 | 104 | |
247abff4 | 105 | } |
106 | ||
107 | //__________________________________________________ | |
108 | void AliAnalysisTaskCaloFilter::UserExec(Option_t */*option*/) | |
109 | { | |
110 | // Execute analysis for current event | |
44cf05d7 | 111 | // Copy input ESD or AOD header, vertex, CaloClusters and CaloCells to output AOD |
112 | ||
247abff4 | 113 | if (fDebug > 0) |
114 | printf("CaloFilter: Analysing event # %d\n", (Int_t)Entry()); | |
7a4cf423 | 115 | |
7a4cf423 | 116 | |
247abff4 | 117 | AliVEvent* event = InputEvent(); |
247abff4 | 118 | if(!event) { |
44cf05d7 | 119 | printf("AliAnalysisTaskCaloFilter::UserExec - This event does not contain Input?"); |
2dfb1428 | 120 | return; |
121 | } | |
fbad5435 | 122 | |
123 | //Magic line to write events to file | |
124 | AliAnalysisManager::GetAnalysisManager()->GetOutputEventHandler()->SetFillAOD(kTRUE); | |
125 | ||
fbad5435 | 126 | Bool_t bAOD = kFALSE; |
127 | if(!strcmp(event->GetName(),"AliAODEvent")) bAOD=kTRUE; | |
128 | Bool_t bESD = kFALSE; | |
129 | if(!strcmp(event->GetName(),"AliESDEvent")) bESD=kTRUE; | |
3a58eee6 | 130 | |
44cf05d7 | 131 | //------------------------------------------- |
132 | //Event selection parameters | |
133 | //------------------------------------------- | |
134 | //Is it a pileup event? | |
135 | Bool_t bPileup = event->IsPileupFromSPD(3, 0.8, 3., 2., 5.); //Default values, if not it does not compile | |
136 | //Bool_t bPileup = event->IsPileupFromSPD(); | |
137 | //if(bPileup) return kFALSE; | |
138 | Int_t trackMult = 0; | |
139 | Bool_t bV0AND = kFALSE; | |
140 | Bool_t bGoodVertex = kFALSE; | |
3a58eee6 | 141 | if(bESD){ |
44cf05d7 | 142 | //Get track multiplicity |
3a58eee6 | 143 | Int_t nTracks = InputEvent()->GetNumberOfTracks() ; |
144 | for (Int_t itrack = 0; itrack < nTracks; itrack++) {////////////// track loop | |
145 | AliVTrack * track = (AliVTrack*)InputEvent()->GetTrack(itrack) ; // retrieve track from esd | |
146 | if(!fESDtrackCuts->AcceptTrack((AliESDtrack*)track)) continue; | |
3b13c34c | 147 | //Count the tracks in eta < 0.8 |
3a58eee6 | 148 | if(TMath::Abs(track->Eta())< fTrackMultEtaCut) trackMult++; |
44cf05d7 | 149 | } |
150 | //V0AND? | |
151 | ||
152 | bV0AND = fTriggerAnalysis->IsOfflineTriggerFired(dynamic_cast<AliESDEvent*> (event), AliTriggerAnalysis::kV0AND); | |
153 | //if(!bV0AND) return kFALSE; | |
154 | //Well reconstructed vertex | |
155 | bGoodVertex = CheckForPrimaryVertex(); | |
156 | //if(!bGoodVertex) return kFALSE; | |
157 | ||
158 | }//ESDs | |
159 | ||
160 | if(fDebug > 0) | |
161 | printf("AliAnalysisTaskCaloFilter::UserExec() - PileUp %d, Good Vertex %d, v0AND %d, Track Mult in |eta| < %2.1f = %d\n", | |
162 | bPileup,bGoodVertex,bV0AND, fTrackMultEtaCut, trackMult); | |
163 | //Put bools with event selection parameters in an array, as a patch, put it later in the MC labels list | |
e67f256b | 164 | Int_t eventSelection[] = {bPileup,bGoodVertex,bV0AND,trackMult}; |
44cf05d7 | 165 | |
166 | //---------------------------------------------------- | |
167 | //Set in AOD General Event Parameters, vertex, runnumber etc | |
168 | //---------------------------------------------------- | |
3a58eee6 | 169 | |
7a4cf423 | 170 | // set arrays and pointers |
171 | Float_t posF[3]; | |
172 | Double_t pos[3]; | |
173 | ||
174 | Double_t covVtx[6]; | |
175 | ||
176 | for (Int_t i = 0; i < 6; i++) covVtx[i] = 0.; | |
247abff4 | 177 | |
7a4cf423 | 178 | AliAODHeader* header = AODEvent()->GetHeader(); |
247abff4 | 179 | |
180 | header->SetRunNumber(event->GetRunNumber()); | |
181 | header->SetOfflineTrigger(fInputHandler->IsEventSelected()); // propagate the decision of the physics selection | |
182 | if(bESD) | |
183 | header->SetFiredTriggerClasses(((AliESDEvent*)event)->GetFiredTriggerClasses()); | |
184 | header->SetTriggerMask(event->GetTriggerMask()); | |
185 | header->SetTriggerCluster(event->GetTriggerCluster()); | |
186 | ||
187 | header->SetBunchCrossNumber(event->GetBunchCrossNumber()); | |
188 | header->SetOrbitNumber(event->GetOrbitNumber()); | |
189 | header->SetPeriodNumber(event->GetPeriodNumber()); | |
190 | header->SetEventType(event->GetEventType()); | |
7a4cf423 | 191 | header->SetMuonMagFieldScale(-999.); // FIXME |
e67f256b | 192 | //header->SetCentrality(0); // FIXME |
7a4cf423 | 193 | |
247abff4 | 194 | header->SetTriggerMask(event->GetTriggerMask()); |
195 | header->SetTriggerCluster(event->GetTriggerCluster()); | |
196 | header->SetMagneticField(event->GetMagneticField()); | |
197 | header->SetZDCN1Energy(event->GetZDCN1Energy()); | |
198 | header->SetZDCP1Energy(event->GetZDCP1Energy()); | |
199 | header->SetZDCN2Energy(event->GetZDCN2Energy()); | |
200 | header->SetZDCP2Energy(event->GetZDCP2Energy()); | |
201 | header->SetZDCEMEnergy(event->GetZDCEMEnergy(0),event->GetZDCEMEnergy(1)); | |
202 | Float_t diamxy[2]={event->GetDiamondX(),event->GetDiamondY()}; | |
203 | Float_t diamcov[3]; event->GetDiamondCovXY(diamcov); | |
7a4cf423 | 204 | header->SetDiamond(diamxy,diamcov); |
247abff4 | 205 | if(bESD){ |
206 | header->SetDiamondZ(((AliESDEvent*)event)->GetDiamondZ(),((AliESDEvent*)event)->GetSigma2DiamondZ()); | |
207 | } | |
7a4cf423 | 208 | // |
209 | // | |
210 | Int_t nVertices = 1 ;/* = prim. vtx*/; | |
247abff4 | 211 | Int_t nCaloClus = event->GetNumberOfCaloClusters(); |
7a4cf423 | 212 | |
213 | AODEvent()->ResetStd(0, nVertices, 0, 0, 0, nCaloClus, 0, 0); | |
214 | ||
215 | // Access to the AOD container of vertices | |
216 | TClonesArray &vertices = *(AODEvent()->GetVertices()); | |
217 | Int_t jVertices=0; | |
218 | ||
219 | // Add primary vertex. The primary tracks will be defined | |
220 | // after the loops on the composite objects (V0, cascades, kinks) | |
247abff4 | 221 | event->GetPrimaryVertex()->GetXYZ(pos); |
222 | Float_t chi = 0; | |
223 | if (bESD){ | |
224 | ((AliESDEvent*)event)->GetPrimaryVertex()->GetCovMatrix(covVtx); | |
225 | chi = ((AliESDEvent*)event)->GetPrimaryVertex()->GetChi2toNDF(); | |
226 | } | |
227 | else if (bAOD){ | |
228 | ((AliAODEvent*)event)->GetPrimaryVertex()->GetCovMatrix(covVtx); | |
229 | chi = ((AliAODEvent*)event)->GetPrimaryVertex()->GetChi2perNDF();//Different from ESD? | |
230 | } | |
7a4cf423 | 231 | |
232 | AliAODVertex * primary = new(vertices[jVertices++]) | |
247abff4 | 233 | AliAODVertex(pos, covVtx, chi, NULL, -1, AliAODVertex::kPrimary); |
234 | primary->SetName(event->GetPrimaryVertex()->GetName()); | |
235 | primary->SetTitle(event->GetPrimaryVertex()->GetTitle()); | |
7a4cf423 | 236 | |
237 | // Access to the AOD container of clusters | |
238 | TClonesArray &caloClusters = *(AODEvent()->GetCaloClusters()); | |
239 | Int_t jClusters=0; | |
240 | ||
44cf05d7 | 241 | //------------------------------------------- |
f2ccb5b8 | 242 | //Do Corrections in EMCAL |
44cf05d7 | 243 | //------------------------------------------- |
f2ccb5b8 | 244 | //If EMCAL, and requested, correct energy, position ... |
245 | //Need to do this in a separate loop before filling the ESDs because of the track matching recalculations | |
246 | if(fCorrect && (fCaloFilter==kEMCAL || fCaloFilter==kBoth) ) { | |
3b13c34c | 247 | |
248 | if(!fGeoMatrixSet){ | |
249 | if(fLoadEMCALMatrices){ | |
c0b85449 | 250 | printf("AliAnalysisTaskCaloFilter::UserExec() - Load user defined EMCAL geometry matrices\n"); |
3b13c34c | 251 | for(Int_t mod=0; mod < (fEMCALGeo->GetEMCGeometry())->GetNumberOfSuperModules(); mod++){ |
252 | if(fEMCALMatrix[mod]){ | |
253 | if(DebugLevel() > 1) | |
254 | fEMCALMatrix[mod]->Print(); | |
255 | fEMCALGeo->SetMisalMatrix(fEMCALMatrix[mod],mod) ; | |
256 | } | |
257 | fGeoMatrixSet=kTRUE; | |
258 | }//SM loop | |
259 | }//Load matrices | |
260 | else if(!gGeoManager){ | |
261 | printf("AliAnalysisTaskCaloFilter::UserExec() - Get geo matrices from data\n"); | |
262 | //Still not implemented in AOD, just a workaround to be able to work at least with ESDs | |
263 | if(!strcmp(event->GetName(),"AliAODEvent")) { | |
264 | if(DebugLevel() > 1) | |
265 | printf("AliAnalysisTaskCaloFilter Use ideal geometry, values geometry matrix not kept in AODs.\n"); | |
266 | }//AOD | |
267 | else { | |
268 | if(DebugLevel() > 1) printf("AliAnalysisTaskCaloFilter Load Misaligned matrices. \n"); | |
269 | AliESDEvent* esd = dynamic_cast<AliESDEvent*>(event) ; | |
270 | if(!esd) { | |
271 | printf("AliAnalysisTaskCaloFilter::UserExec() - This event does not contain ESDs?"); | |
272 | return; | |
273 | } | |
274 | for(Int_t mod=0; mod < (fEMCALGeo->GetEMCGeometry())->GetNumberOfSuperModules(); mod++){ | |
275 | //if(DebugLevel() > 1) | |
276 | esd->GetEMCALMatrix(mod)->Print(); | |
277 | if(esd->GetEMCALMatrix(mod)) fEMCALGeo->SetMisalMatrix(esd->GetEMCALMatrix(mod),mod) ; | |
278 | } | |
279 | fGeoMatrixSet=kTRUE; | |
280 | }//ESD | |
281 | }//Load matrices from Data | |
44cf05d7 | 282 | |
283 | //Recover time dependent corrections, put then in recalibration histograms. Do it once | |
284 | fEMCALRecoUtils->SetTimeDependentCorrections(InputEvent()->GetRunNumber()); | |
285 | ||
3b13c34c | 286 | }//first event |
287 | ||
288 | ||
f2ccb5b8 | 289 | //Cluster Loop |
290 | for (Int_t iClust=0; iClust<nCaloClus; ++iClust) { | |
291 | ||
292 | AliVCluster * cluster = event->GetCaloCluster(iClust); | |
293 | if(cluster->IsPHOS()) continue ; | |
294 | ||
247abff4 | 295 | Float_t position[]={0,0,0}; |
296 | if(DebugLevel() > 2) | |
297 | printf("Check cluster %d for bad channels and close to border\n",cluster->GetID()); | |
298 | if(fEMCALRecoUtils->ClusterContainsBadChannel(fEMCALGeo,cluster->GetCellsAbsId(), cluster->GetNCells())) continue; | |
f2ccb5b8 | 299 | // if(!fEMCALRecoUtils->CheckCellFiducialRegion(fEMCALGeo, cluster, event->GetEMCALCells())) { |
300 | // printf("Finally reject\n"); | |
301 | // continue; | |
302 | // } | |
247abff4 | 303 | if(DebugLevel() > 2) |
304 | { | |
3b13c34c | 305 | printf("Filter, before : i %d, E %f, dispersion %f, m02 %f, m20 %f, distToBad %f\n",iClust,cluster->E(), |
306 | cluster->GetDispersion(),cluster->GetM02(),cluster->GetM20(), cluster->GetDistanceToBadChannel()); | |
247abff4 | 307 | cluster->GetPosition(position); |
308 | printf("Filter, before : i %d, x %f, y %f, z %f\n",cluster->GetID(), position[0], position[1], position[2]); | |
309 | } | |
f2ccb5b8 | 310 | |
3b13c34c | 311 | //Recalculate distance to bad channels, if new list of bad channels provided |
312 | fEMCALRecoUtils->RecalculateClusterDistanceToBadChannel(fEMCALGeo, event->GetEMCALCells(), cluster); | |
313 | ||
5ef94e1b | 314 | if(fEMCALRecoUtils->IsRecalibrationOn()) { |
315 | fEMCALRecoUtils->RecalibrateClusterEnergy(fEMCALGeo, cluster, event->GetEMCALCells()); | |
316 | fEMCALRecoUtils->RecalculateClusterShowerShapeParameters(fEMCALGeo, event->GetEMCALCells(),cluster); | |
317 | fEMCALRecoUtils->RecalculateClusterPID(cluster); | |
5ef94e1b | 318 | } |
44907916 | 319 | |
5ef94e1b | 320 | fEMCALRecoUtils->RecalculateClusterPosition(fEMCALGeo, event->GetEMCALCells(),cluster); |
f2ccb5b8 | 321 | |
247abff4 | 322 | if(DebugLevel() > 2) |
323 | { | |
3b13c34c | 324 | printf("Filter, after : i %d, E %f, dispersion %f, m02 %f, m20 %f, distToBad %f\n",cluster->GetID(),cluster->E(), |
325 | cluster->GetDispersion(),cluster->GetM02(),cluster->GetM20(), cluster->GetDistanceToBadChannel()); | |
247abff4 | 326 | cluster->GetPosition(position); |
327 | printf("Filter, after : i %d, x %f, y %f, z %f\n",cluster->GetID(), position[0], position[1], position[2]); | |
328 | } | |
329 | ||
44907916 | 330 | cluster->SetE(fEMCALRecoUtils->CorrectClusterEnergyLinearity(cluster)); |
331 | ||
f2ccb5b8 | 332 | } |
333 | //Recalculate track-matching | |
334 | fEMCALRecoUtils->FindMatches(event); | |
335 | ||
336 | } // corrections in EMCAL | |
337 | ||
44cf05d7 | 338 | //------------------------------------------- |
339 | // Now loop on clusters to fill AODs | |
340 | //------------------------------------------- | |
f2ccb5b8 | 341 | for (Int_t iClust=0; iClust<nCaloClus; ++iClust) { |
342 | ||
343 | AliVCluster * cluster = event->GetCaloCluster(iClust); | |
344 | ||
345 | //Check which calorimeter information we want to keep. | |
346 | ||
347 | if(fCaloFilter!=kBoth){ | |
348 | if (fCaloFilter==kPHOS && cluster->IsEMCAL()) continue ; | |
349 | else if(fCaloFilter==kEMCAL && cluster->IsPHOS()) continue ; | |
350 | } | |
351 | ||
352 | //Temporary trick, FIXME | |
353 | Float_t dR = cluster->GetTrackDx(); | |
354 | Float_t dZ = cluster->GetTrackDz(); | |
355 | if(DebugLevel() > 2) | |
356 | printf("Original residuals : dZ %f, dR %f\n ",dZ, dR); | |
357 | //-------------------------------------------------------------- | |
358 | //If EMCAL and corrections done, get the new matching parameters, do not copy noisy clusters | |
3f47437c | 359 | if(cluster->IsEMCAL() && fCorrect && bESD){ |
f2ccb5b8 | 360 | if(DebugLevel() > 2) |
361 | printf("Check cluster %d for bad channels and close to border\n",cluster->GetID()); | |
362 | if(fEMCALRecoUtils->ClusterContainsBadChannel(fEMCALGeo,cluster->GetCellsAbsId(), cluster->GetNCells())) continue; | |
363 | // if(!fEMCALRecoUtils->CheckCellFiducialRegion(fEMCALGeo, cluster, event->GetEMCALCells())) { | |
364 | // printf("Finally reject\n"); | |
365 | // continue; | |
366 | // } | |
367 | ||
368 | fEMCALRecoUtils->GetMatchedResiduals(cluster->GetID(),dR,dZ); | |
3f47437c | 369 | cluster->SetTrackDistance(dR,dZ); |
370 | } | |
371 | ||
372 | if(DebugLevel() > 2){ | |
373 | if(cluster->IsEMCAL()) printf("EMCAL Track-Cluster Residuals : dZ %f, dR %f\n ",dZ, dR); | |
374 | if(cluster->IsPHOS()) printf("PHOS Track-Cluster Residuals : dZ %f, dR %f\n ",dZ, dR); | |
247abff4 | 375 | } |
3f47437c | 376 | |
247abff4 | 377 | //-------------------------------------------------------------- |
378 | ||
379 | //Now fill AODs | |
f2ccb5b8 | 380 | |
7a4cf423 | 381 | Int_t id = cluster->GetID(); |
382 | Float_t energy = cluster->E(); | |
383 | cluster->GetPosition(posF); | |
7a4cf423 | 384 | |
385 | AliAODCaloCluster *caloCluster = new(caloClusters[jClusters++]) | |
386 | AliAODCaloCluster(id, | |
e67f256b | 387 | 4, |
388 | eventSelection, | |
7a4cf423 | 389 | energy, |
390 | posF, | |
391 | NULL, | |
c8fe2783 | 392 | cluster->GetType()); |
7a4cf423 | 393 | |
f2ccb5b8 | 394 | caloCluster->SetChi2(dZ);//Temporary trick, FIXME |
7a4cf423 | 395 | caloCluster->SetCaloCluster(cluster->GetDistanceToBadChannel(), |
c8fe2783 | 396 | cluster->GetDispersion(), |
7a4cf423 | 397 | cluster->GetM20(), cluster->GetM02(), |
f2ccb5b8 | 398 | dR, //Temporary trick, FIXME |
7a4cf423 | 399 | cluster->GetNExMax(),cluster->GetTOF()) ; |
400 | ||
c8fe2783 | 401 | caloCluster->SetPIDFromESD(cluster->GetPID()); |
7a4cf423 | 402 | caloCluster->SetNCells(cluster->GetNCells()); |
403 | caloCluster->SetCellsAbsId(cluster->GetCellsAbsId()); | |
404 | caloCluster->SetCellsAmplitudeFraction(cluster->GetCellsAmplitudeFraction()); | |
405 | ||
247abff4 | 406 | if(DebugLevel() > 2) |
407 | { | |
f2ccb5b8 | 408 | printf("Filter, aod : i %d, E %f, dispersion %f, m02 %f, m20 %f\n",caloCluster->GetID(),caloCluster->E(), |
247abff4 | 409 | caloCluster->GetDispersion(),caloCluster->GetM02(),caloCluster->GetM20()); |
410 | caloCluster->GetPosition(posF); | |
f2ccb5b8 | 411 | printf("Filter, aod : i %d, x %f, y %f, z %f\n",caloCluster->GetID(), posF[0], posF[1], posF[2]); |
247abff4 | 412 | } |
413 | ||
3a58eee6 | 414 | //Matched tracks, just to know if there was any match, the track pointer is useless. |
f2ccb5b8 | 415 | //Temporary trick, FIXME |
3a58eee6 | 416 | if(bESD){ |
f2ccb5b8 | 417 | if(TMath::Abs(dR) < 990 && TMath::Abs(dZ) < 990) { //Default value in PHOS 999, in EMCAL 1024, why? |
418 | if(DebugLevel() > 2) | |
419 | printf("*** Cluster Track-Matched *** dR %f, dZ %f\n",caloCluster->GetEmcCpvDistance(),caloCluster->Chi2()); | |
420 | caloCluster->AddTrackMatched(0x0); | |
421 | }// fill the array with one entry to signal a possible match | |
422 | //TArrayI* matchedT = ((AliESDCaloCluster*)cluster)->GetTracksMatched(); | |
423 | //if (InputEvent()->GetNumberOfTracks() > 0 && matchedT && cluster->GetTrackMatchedIndex() >= 0) { | |
424 | // for (Int_t im = 0; im < matchedT->GetSize(); im++) { | |
425 | // Int_t iESDtrack = matchedT->At(im);; | |
426 | // if ((AliVTrack*)InputEvent()->GetTrack(iESDtrack) != 0) { | |
427 | // caloCluster->AddTrackMatched((AliVTrack*)InputEvent()->GetTrack(iESDtrack)); | |
428 | // } | |
429 | // } | |
430 | //}// There is at least a match with a track | |
3a58eee6 | 431 | } |
7a4cf423 | 432 | } |
433 | caloClusters.Expand(jClusters); // resize TObjArray to 'remove' slots for pseudo clusters | |
434 | // end of loop on calo clusters | |
435 | ||
436 | // fill EMCAL cell info | |
247abff4 | 437 | if ((fCaloFilter==kBoth || fCaloFilter==kEMCAL) && event->GetEMCALCells()) { // protection against missing ESD information |
438 | AliVCaloCells &eventEMcells = *(event->GetEMCALCells()); | |
439 | Int_t nEMcell = eventEMcells.GetNumberOfCells() ; | |
7a4cf423 | 440 | |
441 | AliAODCaloCells &aodEMcells = *(AODEvent()->GetEMCALCells()); | |
442 | aodEMcells.CreateContainer(nEMcell); | |
c8fe2783 | 443 | aodEMcells.SetType(AliVCaloCells::kEMCALCell); |
247abff4 | 444 | Double_t calibFactor = 1.; |
445 | for (Int_t iCell = 0; iCell < nEMcell; iCell++) { | |
5ef94e1b | 446 | Int_t imod = -1, iphi =-1, ieta=-1,iTower = -1, iIphi = -1, iIeta = -1; |
447 | fEMCALGeo->GetCellIndex(eventEMcells.GetCellNumber(iCell),imod,iTower,iIphi,iIeta); | |
448 | fEMCALGeo->GetCellPhiEtaIndexInSModule(imod,iTower,iIphi, iIeta,iphi,ieta); | |
449 | ||
247abff4 | 450 | if(fCorrect && fEMCALRecoUtils->IsRecalibrationOn()){ |
247abff4 | 451 | calibFactor = fEMCALRecoUtils->GetEMCALChannelRecalibrationFactor(imod,ieta,iphi); |
452 | } | |
5ef94e1b | 453 | |
454 | if(!fEMCALRecoUtils->GetEMCALChannelStatus(imod, ieta, iphi)){ //Channel is not declared as bad | |
455 | aodEMcells.SetCell(iCell,eventEMcells.GetCellNumber(iCell),eventEMcells.GetAmplitude(iCell)*calibFactor); | |
456 | //printf("GOOD channel\n"); | |
457 | } | |
458 | else { | |
459 | aodEMcells.SetCell(iCell,eventEMcells.GetCellNumber(iCell),0); | |
460 | //printf("BAD channel\n"); | |
5ef94e1b | 461 | } |
7a4cf423 | 462 | } |
463 | aodEMcells.Sort(); | |
464 | } | |
465 | ||
466 | // fill PHOS cell info | |
247abff4 | 467 | if ((fCaloFilter==kBoth || fCaloFilter==kPHOS) && event->GetPHOSCells()) { // protection against missing ESD information |
468 | AliVCaloCells &eventPHcells = *(event->GetPHOSCells()); | |
469 | Int_t nPHcell = eventPHcells.GetNumberOfCells() ; | |
7a4cf423 | 470 | |
471 | AliAODCaloCells &aodPHcells = *(AODEvent()->GetPHOSCells()); | |
472 | aodPHcells.CreateContainer(nPHcell); | |
c8fe2783 | 473 | aodPHcells.SetType(AliVCaloCells::kPHOSCell); |
7a4cf423 | 474 | for (Int_t iCell = 0; iCell < nPHcell; iCell++) { |
247abff4 | 475 | aodPHcells.SetCell(iCell,eventPHcells.GetCellNumber(iCell),eventPHcells.GetAmplitude(iCell)); |
7a4cf423 | 476 | } |
477 | aodPHcells.Sort(); | |
478 | } | |
479 | ||
480 | ||
481 | return; | |
482 | } | |
483 | ||
44cf05d7 | 484 | //____________________________________________________________________________ |
485 | Bool_t AliAnalysisTaskCaloFilter::CheckForPrimaryVertex(){ | |
486 | //Check if the vertex was well reconstructed, copy from V0Reader of conversion group | |
487 | //It only works for ESDs | |
488 | ||
489 | AliESDEvent * event = dynamic_cast<AliESDEvent*> (InputEvent()); | |
490 | if(event->GetPrimaryVertexTracks()->GetNContributors() > 0) { | |
491 | return 1; | |
492 | } | |
493 | ||
494 | if(event->GetPrimaryVertexTracks()->GetNContributors() < 1) { | |
495 | // SPD vertex | |
496 | if(event->GetPrimaryVertexSPD()->GetNContributors() > 0) { | |
497 | //cout<<"spd vertex type::"<< fESDEvent->GetPrimaryVertex()->GetName() << endl; | |
498 | return 1; | |
499 | ||
500 | } | |
501 | if(event->GetPrimaryVertexSPD()->GetNContributors() < 1) { | |
502 | // cout<<"bad vertex type::"<< fESDEvent->GetPrimaryVertex()->GetName() << endl; | |
503 | return 0; | |
504 | } | |
505 | } | |
506 | return 0; | |
507 | //return fInputEvent->GetPrimaryVertex()->GetNContributors()>0; | |
508 | } | |
509 | ||
510 | ||
5ef94e1b | 511 | //_____________________________________________________ |
512 | void AliAnalysisTaskCaloFilter::PrintInfo(){ | |
513 | ||
514 | //Print settings | |
515 | ||
516 | printf("TASK: AnalysisCaloFilter \n"); | |
517 | printf("\t Not only filter, correct Clusters? %d\n",fCorrect); | |
518 | printf("\t Calorimeter Filtering Option ? %d\n",fCaloFilter); | |
3b13c34c | 519 | //printf("\t Use handmade geo matrices? EMCAL %d, PHOS %d\n",fLoadEMCALMatrices, fLoadPHOSMatrices); |
520 | printf("\t Use handmade geo matrices? EMCAL %d, PHOS 0\n",fLoadEMCALMatrices); | |
5ef94e1b | 521 | } |
522 | ||
247abff4 | 523 | //_____________________________________________________ |
524 | //void AliAnalysisTaskCaloFilter::LocalInit() | |
525 | //{ | |
526 | // // Local Initialization | |
527 | // | |
528 | // // Create cuts/param objects and publish to slot | |
529 | // const Int_t buffersize = 255; | |
530 | // char onePar[buffersize] ; | |
531 | // fCuts = new TList(); | |
532 | // | |
533 | // snprintf(onePar,buffersize, "Calorimeter Filtering Option %d", fCaloFilter) ; | |
534 | // fCuts->Add(new TObjString(onePar)); | |
535 | // snprintf(onePar,buffersize, "Not only filter but correct? %d cells;", fCorrect) ; | |
536 | // fCuts->Add(new TObjString(onePar)); | |
537 | // | |
538 | // // Post Data | |
539 | // PostData(2, fCuts); | |
540 | // | |
541 | //} | |
7a4cf423 | 542 | |
7a4cf423 | 543 | |
544 | //__________________________________________________ | |
545 | void AliAnalysisTaskCaloFilter::Terminate(Option_t */*option*/) | |
546 | { | |
547 | // Terminate analysis | |
548 | // | |
549 | if (fDebug > 1) printf("AnalysisCaloFilter: Terminate() \n"); | |
550 | } | |
551 |