]>
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 | ||
7a4cf423 | 16 | ////////////////////////////////////////////////////////// |
17 | // Filter the ESDCaloClusters and ESDCaloCells of EMCAL, | |
18 | // PHOS or both, creating the corresponing AODCaloClusters | |
19 | // and AODCaloCells. | |
20 | // Keep also the AODHeader information and the vertex. | |
ea00d1fa | 21 | // Keep tracks, v0s, VZERO if requested |
22 | // Select events containing a cluster or track avobe a given threshold | |
7a4cf423 | 23 | // Copy of AliAnalysisTaskESDfilter. |
24 | // Author: Gustavo Conesa Balbastre (INFN - Frascati) | |
25 | ////////////////////////////////////////////////////////// | |
26 | ||
44cf05d7 | 27 | //Root |
28 | #include "TGeoManager.h" | |
5994e71f | 29 | #include "TFile.h" |
5994e71f | 30 | #include "TROOT.h" |
31 | #include "TInterpreter.h" | |
44cf05d7 | 32 | |
33 | //STEER | |
7a4cf423 | 34 | #include "AliESDEvent.h" |
35 | #include "AliAODEvent.h" | |
7a4cf423 | 36 | #include "AliLog.h" |
247abff4 | 37 | #include "AliVCluster.h" |
38 | #include "AliVCaloCells.h" | |
247abff4 | 39 | #include "AliVEventHandler.h" |
eee2ea01 | 40 | #include "AliAODHandler.h" |
247abff4 | 41 | #include "AliAnalysisManager.h" |
42 | #include "AliInputEventHandler.h" | |
44cf05d7 | 43 | |
44 | //EMCAL | |
45 | #include "AliEMCALRecoUtils.h" | |
46 | #include "AliEMCALGeometry.h" | |
47 | ||
48 | #include "AliAnalysisTaskCaloFilter.h" | |
7a4cf423 | 49 | |
50 | ClassImp(AliAnalysisTaskCaloFilter) | |
e4de0408 | 51 | |
7a4cf423 | 52 | //////////////////////////////////////////////////////////////////////// |
53 | ||
54 | AliAnalysisTaskCaloFilter::AliAnalysisTaskCaloFilter(): | |
ea00d1fa | 55 | AliAnalysisTaskSE("CaloFilterTask"), |
56 | fCaloFilter(0), fEventSelection(), | |
57 | fAcceptAllMBEvent(kFALSE), fCorrect(kFALSE), | |
58 | fEMCALGeo(0x0), fEMCALGeoName("EMCAL_COMPLETE12SMV1"), | |
e4de0408 | 59 | fEMCALRecoUtils(new AliEMCALRecoUtils), |
60 | fLoadEMCALMatrices(kFALSE), //fLoadPHOSMatrices(kFALSE), | |
61 | fGeoMatrixSet(kFALSE), | |
ea00d1fa | 62 | fConfigName(""), fFillAODFile(kTRUE), |
eee2ea01 | 63 | fFillMCParticles(kFALSE), |
ea00d1fa | 64 | fFillTracks(kFALSE), fFillHybridTracks(kFALSE), |
65 | fFillAllVertices(kFALSE), fFillv0s(kFALSE), | |
66 | fFillVZERO(kFALSE), | |
67 | fEMCALEnergyCut(0.), fEMCALNcellsCut (0), | |
68 | fPHOSEnergyCut(0.), fPHOSNcellsCut (0), | |
69 | fTrackPtCut(-1), | |
70 | fVzCut(100.), fEvent(0x0), | |
71 | fESDEvent(0x0), fAODEvent(0x0) | |
7a4cf423 | 72 | { |
73 | // Default constructor | |
e4de0408 | 74 | |
ea00d1fa | 75 | fEventSelection[0] = kFALSE; |
76 | fEventSelection[1] = kFALSE; | |
77 | fEventSelection[2] = kFALSE; | |
78 | ||
e3990982 | 79 | for(Int_t i = 0; i < 12; i++) fEMCALMatrix[i] = 0 ; |
3b13c34c | 80 | //for(Int_t i = 0; i < 5 ; i++) fPHOSMatrix[i] = 0 ; |
5994e71f | 81 | |
7a4cf423 | 82 | } |
83 | ||
84 | //__________________________________________________ | |
85 | AliAnalysisTaskCaloFilter::AliAnalysisTaskCaloFilter(const char* name): | |
ea00d1fa | 86 | AliAnalysisTaskSE(name), |
87 | fCaloFilter(0), fEventSelection(), | |
88 | fAcceptAllMBEvent(kFALSE), fCorrect(kFALSE), | |
89 | fEMCALGeo(0x0), fEMCALGeoName("EMCAL_COMPLETE12SMV1"), | |
e4de0408 | 90 | fEMCALRecoUtils(new AliEMCALRecoUtils), |
91 | fLoadEMCALMatrices(kFALSE), //fLoadPHOSMatrices(kFALSE), | |
92 | fGeoMatrixSet(kFALSE), | |
ea00d1fa | 93 | fConfigName(""), fFillAODFile(kTRUE), |
eee2ea01 | 94 | fFillMCParticles(kFALSE), |
ea00d1fa | 95 | fFillTracks(kFALSE), fFillHybridTracks(kFALSE), |
96 | fFillAllVertices(kFALSE), fFillv0s(kFALSE), | |
97 | fFillVZERO(kFALSE), | |
98 | fEMCALEnergyCut(0.), fEMCALNcellsCut(0), | |
99 | fPHOSEnergyCut(0.), fPHOSNcellsCut(0), | |
100 | fTrackPtCut(-1), | |
101 | fVzCut(100.), fEvent(0x0), | |
102 | fESDEvent(0x0), fAODEvent(0x0) | |
7a4cf423 | 103 | { |
104 | // Constructor | |
e4de0408 | 105 | |
ea00d1fa | 106 | fEventSelection[0] = kFALSE; |
107 | fEventSelection[1] = kFALSE; | |
108 | fEventSelection[2] = kFALSE; | |
109 | ||
e3990982 | 110 | for(Int_t i = 0; i < 12; i++) fEMCALMatrix[i] = 0 ; |
3b13c34c | 111 | //for(Int_t i = 0; i < 5 ; i++) fPHOSMatrix[i] = 0 ; |
e4de0408 | 112 | |
7a4cf423 | 113 | } |
114 | ||
115 | //__________________________________________________ | |
247abff4 | 116 | AliAnalysisTaskCaloFilter::~AliAnalysisTaskCaloFilter() |
7a4cf423 | 117 | { |
247abff4 | 118 | //Destructor. |
119 | ||
44cf05d7 | 120 | if(fEMCALGeo) delete fEMCALGeo; |
121 | if(fEMCALRecoUtils) delete fEMCALRecoUtils; | |
5994e71f | 122 | |
247abff4 | 123 | } |
124 | ||
ea00d1fa | 125 | //_____________________________________________ |
126 | Bool_t AliAnalysisTaskCaloFilter::AcceptEvent() | |
247abff4 | 127 | { |
ea00d1fa | 128 | // Define conditions to accept the event to be filtered |
e4de0408 | 129 | |
f80aea56 | 130 | if(!AcceptEventVertex()) return kFALSE; |
131 | ||
ea00d1fa | 132 | Bool_t eventSel = kFALSE; |
e4de0408 | 133 | |
ea00d1fa | 134 | Bool_t isMB = (((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->IsEventSelected() & AliVEvent::kMB); |
e4de0408 | 135 | |
ea00d1fa | 136 | if ( isMB && fAcceptAllMBEvent ) eventSel = kTRUE; // accept any MB event |
e4de0408 | 137 | |
ea00d1fa | 138 | else if( fEventSelection[0] && AcceptEventEMCAL() ) eventSel = kTRUE; // accept event depending on EMCAL activity |
e4de0408 | 139 | |
ea00d1fa | 140 | else if( fEventSelection[1] && AcceptEventPHOS () ) eventSel = kTRUE; // accept event depending on PHOS activity |
e4de0408 | 141 | |
ea00d1fa | 142 | else if( fEventSelection[2] && AcceptEventTrack() ) eventSel = kTRUE; // accept event depending on Track activity |
e4de0408 | 143 | |
ea00d1fa | 144 | return eventSel ; |
e4de0408 | 145 | |
146 | } | |
147 | ||
e4de0408 | 148 | //__________________________________________________ |
149 | Bool_t AliAnalysisTaskCaloFilter::AcceptEventEMCAL() | |
150 | { | |
ea00d1fa | 151 | // Accept event given there is a EMCAL cluster with enough energy, and not noisy, exotic |
152 | ||
153 | if(fCaloFilter==kPHOS) return kTRUE; // accept | |
e4de0408 | 154 | |
ea00d1fa | 155 | if(fEMCALEnergyCut <= 0) return kTRUE; // accept |
e4de0408 | 156 | |
157 | Int_t nCluster = InputEvent() -> GetNumberOfCaloClusters(); | |
158 | AliVCaloCells * caloCell = InputEvent() -> GetEMCALCells(); | |
159 | Int_t bc = InputEvent() -> GetBunchCrossNumber(); | |
160 | ||
161 | for(Int_t icalo = 0; icalo < nCluster; icalo++) | |
162 | { | |
ea00d1fa | 163 | AliVCluster *clus = (AliVCluster*) (InputEvent()->GetCaloCluster(icalo)); |
e4de0408 | 164 | |
ea00d1fa | 165 | if( ( clus->IsEMCAL() ) && ( clus->GetNCells() > fEMCALNcellsCut ) && ( clus->E() > fEMCALEnergyCut ) && |
e4de0408 | 166 | fEMCALRecoUtils->IsGoodCluster(clus,fEMCALGeo,caloCell,bc)) |
167 | { | |
168 | ||
ea00d1fa | 169 | if (fDebug > 0) printf("AliAnalysisTaskCaloFilter::AcceptEventEMCAL() - Accept : E %2.2f > %2.2f, nCells %d > %d \n", |
170 | clus->E(), fEMCALEnergyCut, clus->GetNCells(), fEMCALNcellsCut); | |
e4de0408 | 171 | |
172 | return kTRUE; | |
173 | } | |
44cf05d7 | 174 | |
e4de0408 | 175 | }// loop |
44cf05d7 | 176 | |
ea00d1fa | 177 | if (fDebug > 0) printf("AliAnalysisTaskCaloFilter::AcceptEventEMCAL() - Reject \n"); |
178 | ||
e4de0408 | 179 | return kFALSE; |
44cf05d7 | 180 | |
e4de0408 | 181 | } |
182 | ||
ea00d1fa | 183 | //_________________________________________________ |
184 | Bool_t AliAnalysisTaskCaloFilter::AcceptEventPHOS() | |
185 | { | |
186 | // Accept event given there is a PHOS cluster with enough energy and not noisy/exotic | |
3a58eee6 | 187 | |
ea00d1fa | 188 | if(fCaloFilter==kEMCAL) return kTRUE; // accept |
7a4cf423 | 189 | |
ea00d1fa | 190 | if(fPHOSEnergyCut <= 0) return kTRUE; // accept |
191 | ||
192 | Int_t nCluster = InputEvent() -> GetNumberOfCaloClusters(); | |
193 | ||
194 | for(Int_t icalo = 0; icalo < nCluster; icalo++) | |
195 | { | |
196 | AliVCluster *clus = (AliVCluster*) (InputEvent()->GetCaloCluster(icalo)); | |
e4de0408 | 197 | |
ea00d1fa | 198 | if( ( clus->IsPHOS() ) && ( clus->GetNCells() > fPHOSNcellsCut ) && ( clus->E() > fPHOSEnergyCut )) |
e4de0408 | 199 | { |
e4de0408 | 200 | |
ea00d1fa | 201 | if (fDebug > 0) printf("AliAnalysisTaskCaloFilter::AcceptEventPHOS() - Accept : E %2.2f > %2.2f, nCells %d > %d \n", |
202 | clus->E(), fPHOSEnergyCut, clus->GetNCells(), fPHOSNcellsCut); | |
e4de0408 | 203 | |
ea00d1fa | 204 | return kTRUE; |
e4de0408 | 205 | } |
206 | ||
ea00d1fa | 207 | }// loop |
208 | ||
209 | if (fDebug > 0) printf("AliAnalysisTaskCaloFilter::AcceptEventPHOS() - Reject \n"); | |
210 | ||
211 | return kFALSE; | |
212 | ||
213 | } | |
e4de0408 | 214 | |
ea00d1fa | 215 | //__________________________________________________ |
216 | Bool_t AliAnalysisTaskCaloFilter::AcceptEventTrack() | |
e4de0408 | 217 | { |
ea00d1fa | 218 | // Accept event if there is a track avobe a certain pT |
e4de0408 | 219 | |
ea00d1fa | 220 | if(fTrackPtCut <= 0) return kTRUE; // accept |
e4de0408 | 221 | |
ea00d1fa | 222 | Double_t pTrack[3] = {0,0,0}; |
e4de0408 | 223 | |
ea00d1fa | 224 | for (Int_t nTrack = 0; nTrack < fEvent->GetNumberOfTracks(); ++nTrack) |
e4de0408 | 225 | { |
ea00d1fa | 226 | AliVTrack *track = (AliVTrack*) fEvent->GetTrack(nTrack); |
e4de0408 | 227 | |
ea00d1fa | 228 | // Select only hybrid tracks? |
229 | if(fAODEvent && fFillHybridTracks && !((AliAODTrack*)track)->IsHybridGlobalConstrainedGlobal()) continue; | |
e4de0408 | 230 | |
ea00d1fa | 231 | track->GetPxPyPz(pTrack) ; |
e4de0408 | 232 | |
ea00d1fa | 233 | TLorentzVector momentum(pTrack[0],pTrack[1],pTrack[2],0); |
e4de0408 | 234 | |
ea00d1fa | 235 | if(momentum.Pt() > fTrackPtCut) |
e4de0408 | 236 | { |
ea00d1fa | 237 | if (fDebug > 0) printf("AliAnalysisTaskCaloFilter::AcceptEventTrack() - Accept : pT %2.2f > %2.2f \n", |
238 | momentum.Pt(), fTrackPtCut); | |
239 | ||
240 | return kTRUE; | |
e4de0408 | 241 | } |
242 | ||
ea00d1fa | 243 | } |
e4de0408 | 244 | |
ea00d1fa | 245 | if (fDebug > 0) printf("AliAnalysisTaskCaloFilter::AcceptEventTrack() - Reject \n"); |
e4de0408 | 246 | |
ea00d1fa | 247 | return kFALSE; |
248 | ||
249 | } | |
e4de0408 | 250 | |
ea00d1fa | 251 | //___________________________________________________ |
252 | Bool_t AliAnalysisTaskCaloFilter::AcceptEventVertex() | |
e4de0408 | 253 | { |
ea00d1fa | 254 | // Accept event with good vertex |
e4de0408 | 255 | |
ea00d1fa | 256 | Double_t v[3]; |
257 | InputEvent()->GetPrimaryVertex()->GetXYZ(v) ; | |
247abff4 | 258 | |
f80aea56 | 259 | |
ea00d1fa | 260 | if(TMath::Abs(v[2]) > fVzCut) |
e4de0408 | 261 | { |
f80aea56 | 262 | if (fDebug > 0) printf("AliAnalysisTaskCaloFilter::AcceptEventVertex() - Vz Reject : vz %2.2f > %2.2f\n",v[2],fVzCut); |
263 | ||
ea00d1fa | 264 | return kFALSE ; |
e4de0408 | 265 | } |
266 | ||
ea00d1fa | 267 | return CheckForPrimaryVertex(); |
268 | } | |
269 | ||
270 | //_______________________________________________________ | |
271 | Bool_t AliAnalysisTaskCaloFilter::CheckForPrimaryVertex() | |
272 | { | |
273 | //Check if the vertex was well reconstructed, copy from v0Reader of conversion group | |
274 | //It only works for ESDs | |
a8088a22 | 275 | |
ea00d1fa | 276 | // AODs |
277 | if(!fESDEvent) | |
e4de0408 | 278 | { |
ea00d1fa | 279 | // Check that the vertex is not (0,0,0) |
280 | Double_t v[3]; | |
281 | InputEvent()->GetPrimaryVertex()->GetXYZ(v) ; | |
282 | ||
283 | if(TMath::Abs(v[2]) < 1e-6 && | |
284 | TMath::Abs(v[1]) < 1e-6 && | |
285 | TMath::Abs(v[0]) < 1e-6 ) | |
8ebce41d | 286 | { |
f80aea56 | 287 | if (fDebug > 0) printf("AliAnalysisTaskCaloFilter::CheckForPrimaryVertex() - Reject v(0,0,0) \n"); |
ea00d1fa | 288 | |
289 | return kFALSE ; | |
290 | } | |
e4de0408 | 291 | |
ea00d1fa | 292 | return kTRUE; |
e4de0408 | 293 | } |
294 | ||
ea00d1fa | 295 | // ESDs |
296 | if(fESDEvent->GetPrimaryVertexTracks()->GetNContributors() > 0) | |
297 | { | |
298 | return kTRUE; | |
299 | } | |
e4de0408 | 300 | |
ea00d1fa | 301 | if(fESDEvent->GetPrimaryVertexTracks()->GetNContributors() < 1) |
e4de0408 | 302 | { |
ea00d1fa | 303 | // SPD vertex |
304 | if(fESDEvent->GetPrimaryVertexSPD()->GetNContributors() > 0) | |
8ebce41d | 305 | { |
ea00d1fa | 306 | //cout<<"spd vertex type::"<< fESDEvent->GetPrimaryVertex()->GetName() << endl; |
307 | return kTRUE; | |
8ebce41d | 308 | |
ea00d1fa | 309 | } |
310 | if(fESDEvent->GetPrimaryVertexSPD()->GetNContributors() < 1) | |
311 | { | |
312 | // cout<<"bad vertex type::"<< fESDEvent->GetPrimaryVertex()->GetName() << endl; | |
f80aea56 | 313 | if (fDebug > 0) printf("AliAnalysisTaskCaloFilter::CheckForPrimaryVertex() - Reject, GetPrimaryVertexSPD()->GetNContributors() < 1 \n"); |
314 | ||
ea00d1fa | 315 | return kFALSE; |
316 | } | |
e4de0408 | 317 | } |
7a4cf423 | 318 | |
f80aea56 | 319 | if (fDebug > 0) printf("AliAnalysisTaskCaloFilter::CheckForPrimaryVertex() - Reject, GetPrimaryVertexTracks()->GetNContributors() > 1 \n"); |
a8088a22 | 320 | |
ea00d1fa | 321 | return kFALSE; |
7a4cf423 | 322 | |
e4de0408 | 323 | } |
324 | ||
325 | //__________________________________________________ | |
326 | void AliAnalysisTaskCaloFilter::CorrectionsInEMCAL() | |
327 | { | |
f2ccb5b8 | 328 | //If EMCAL, and requested, correct energy, position ... |
e4de0408 | 329 | |
f2ccb5b8 | 330 | //Need to do this in a separate loop before filling the ESDs because of the track matching recalculations |
e4de0408 | 331 | |
332 | if(fCorrect && (fCaloFilter==kEMCAL || fCaloFilter==kBoth) ) | |
333 | { | |
334 | if(!fGeoMatrixSet) | |
335 | { | |
336 | if(fLoadEMCALMatrices) | |
337 | { | |
c0b85449 | 338 | printf("AliAnalysisTaskCaloFilter::UserExec() - Load user defined EMCAL geometry matrices\n"); |
3b13c34c | 339 | for(Int_t mod=0; mod < (fEMCALGeo->GetEMCGeometry())->GetNumberOfSuperModules(); mod++){ |
340 | if(fEMCALMatrix[mod]){ | |
341 | if(DebugLevel() > 1) | |
342 | fEMCALMatrix[mod]->Print(); | |
343 | fEMCALGeo->SetMisalMatrix(fEMCALMatrix[mod],mod) ; | |
344 | } | |
345 | fGeoMatrixSet=kTRUE; | |
346 | }//SM loop | |
347 | }//Load matrices | |
e4de0408 | 348 | else if(!gGeoManager) |
349 | { | |
3b13c34c | 350 | printf("AliAnalysisTaskCaloFilter::UserExec() - Get geo matrices from data\n"); |
351 | //Still not implemented in AOD, just a workaround to be able to work at least with ESDs | |
e4de0408 | 352 | if(!strcmp(InputEvent()->GetName(),"AliAODEvent")) |
353 | { | |
3b13c34c | 354 | if(DebugLevel() > 1) |
355 | printf("AliAnalysisTaskCaloFilter Use ideal geometry, values geometry matrix not kept in AODs.\n"); | |
356 | }//AOD | |
e4de0408 | 357 | else |
358 | { | |
3b13c34c | 359 | if(DebugLevel() > 1) printf("AliAnalysisTaskCaloFilter Load Misaligned matrices. \n"); |
e4de0408 | 360 | AliESDEvent* esd = dynamic_cast<AliESDEvent*>(InputEvent()) ; |
361 | if(!esd) | |
362 | { | |
3b13c34c | 363 | printf("AliAnalysisTaskCaloFilter::UserExec() - This event does not contain ESDs?"); |
364 | return; | |
365 | } | |
e4de0408 | 366 | for(Int_t mod=0; mod < (fEMCALGeo->GetEMCGeometry())->GetNumberOfSuperModules(); mod++) |
367 | { | |
3b13c34c | 368 | //if(DebugLevel() > 1) |
369 | esd->GetEMCALMatrix(mod)->Print(); | |
370 | if(esd->GetEMCALMatrix(mod)) fEMCALGeo->SetMisalMatrix(esd->GetEMCALMatrix(mod),mod) ; | |
371 | } | |
372 | fGeoMatrixSet=kTRUE; | |
373 | }//ESD | |
374 | }//Load matrices from Data | |
e4de0408 | 375 | |
3b13c34c | 376 | }//first event |
377 | ||
f2ccb5b8 | 378 | //Cluster Loop |
e4de0408 | 379 | Int_t nCaloClus = InputEvent()->GetNumberOfCaloClusters(); |
380 | ||
381 | for (Int_t iClust=0; iClust<nCaloClus; ++iClust) | |
382 | { | |
383 | AliVCluster * cluster = InputEvent()->GetCaloCluster(iClust); | |
f2ccb5b8 | 384 | |
f2ccb5b8 | 385 | if(cluster->IsPHOS()) continue ; |
e4de0408 | 386 | |
247abff4 | 387 | Float_t position[]={0,0,0}; |
388 | if(DebugLevel() > 2) | |
389 | printf("Check cluster %d for bad channels and close to border\n",cluster->GetID()); | |
390 | if(fEMCALRecoUtils->ClusterContainsBadChannel(fEMCALGeo,cluster->GetCellsAbsId(), cluster->GetNCells())) continue; | |
e4de0408 | 391 | |
247abff4 | 392 | if(DebugLevel() > 2) |
393 | { | |
3b13c34c | 394 | printf("Filter, before : i %d, E %f, dispersion %f, m02 %f, m20 %f, distToBad %f\n",iClust,cluster->E(), |
395 | cluster->GetDispersion(),cluster->GetM02(),cluster->GetM20(), cluster->GetDistanceToBadChannel()); | |
247abff4 | 396 | cluster->GetPosition(position); |
397 | printf("Filter, before : i %d, x %f, y %f, z %f\n",cluster->GetID(), position[0], position[1], position[2]); | |
398 | } | |
f2ccb5b8 | 399 | |
3b13c34c | 400 | //Recalculate distance to bad channels, if new list of bad channels provided |
e4de0408 | 401 | fEMCALRecoUtils->RecalculateClusterDistanceToBadChannel(fEMCALGeo, InputEvent()->GetEMCALCells(), cluster); |
402 | ||
403 | if(fEMCALRecoUtils->IsRecalibrationOn()) | |
404 | { | |
405 | fEMCALRecoUtils->RecalibrateClusterEnergy(fEMCALGeo, cluster, InputEvent()->GetEMCALCells()); | |
406 | fEMCALRecoUtils->RecalculateClusterShowerShapeParameters(fEMCALGeo, InputEvent()->GetEMCALCells(),cluster); | |
5ef94e1b | 407 | fEMCALRecoUtils->RecalculateClusterPID(cluster); |
5ef94e1b | 408 | } |
e4de0408 | 409 | |
410 | fEMCALRecoUtils->RecalculateClusterPosition(fEMCALGeo, InputEvent()->GetEMCALCells(),cluster); | |
f2ccb5b8 | 411 | |
247abff4 | 412 | if(DebugLevel() > 2) |
413 | { | |
3b13c34c | 414 | printf("Filter, after : i %d, E %f, dispersion %f, m02 %f, m20 %f, distToBad %f\n",cluster->GetID(),cluster->E(), |
415 | cluster->GetDispersion(),cluster->GetM02(),cluster->GetM20(), cluster->GetDistanceToBadChannel()); | |
247abff4 | 416 | cluster->GetPosition(position); |
417 | printf("Filter, after : i %d, x %f, y %f, z %f\n",cluster->GetID(), position[0], position[1], position[2]); | |
418 | } | |
419 | ||
44907916 | 420 | cluster->SetE(fEMCALRecoUtils->CorrectClusterEnergyLinearity(cluster)); |
421 | ||
f2ccb5b8 | 422 | } |
e4de0408 | 423 | |
f2ccb5b8 | 424 | //Recalculate track-matching |
e4de0408 | 425 | fEMCALRecoUtils->FindMatches(InputEvent(),0,fEMCALGeo); |
f2ccb5b8 | 426 | |
427 | } // corrections in EMCAL | |
7a4cf423 | 428 | } |
429 | ||
ea00d1fa | 430 | //________________________________________________ |
431 | void AliAnalysisTaskCaloFilter::FillAODCaloCells() | |
432 | { | |
433 | // Fill EMCAL/PHOS cell info | |
434 | ||
435 | // EMCAL | |
436 | if ((fCaloFilter==kBoth || fCaloFilter==kEMCAL) && fEvent->GetEMCALCells()) | |
437 | { // protection against missing ESD information | |
438 | AliVCaloCells &eventEMcells = *(fEvent->GetEMCALCells()); | |
439 | Int_t nEMcell = eventEMcells.GetNumberOfCells() ; | |
440 | ||
441 | AliAODCaloCells &aodEMcells = *(AODEvent()->GetEMCALCells()); | |
442 | aodEMcells.CreateContainer(nEMcell); | |
443 | aodEMcells.SetType(AliVCaloCells::kEMCALCell); | |
444 | Double_t calibFactor = 1.; | |
445 | for (Int_t iCell = 0; iCell < nEMcell; iCell++) | |
446 | { | |
447 | Int_t imod = -1, iphi =-1, ieta=-1,iTower = -1, iIphi = -1, iIeta = -1; | |
448 | fEMCALGeo->GetCellIndex(eventEMcells.GetCellNumber(iCell),imod,iTower,iIphi,iIeta); | |
449 | fEMCALGeo->GetCellPhiEtaIndexInSModule(imod,iTower,iIphi, iIeta,iphi,ieta); | |
450 | ||
451 | if(fCorrect && fEMCALRecoUtils->IsRecalibrationOn()) | |
452 | { | |
453 | calibFactor = fEMCALRecoUtils->GetEMCALChannelRecalibrationFactor(imod,ieta,iphi); | |
454 | } | |
455 | ||
456 | if(!fEMCALRecoUtils->GetEMCALChannelStatus(imod, ieta, iphi)) | |
457 | { //Channel is not declared as bad | |
458 | aodEMcells.SetCell(iCell,eventEMcells.GetCellNumber(iCell),eventEMcells.GetAmplitude(iCell)*calibFactor, | |
459 | eventEMcells.GetTime(iCell),eventEMcells.GetMCLabel(iCell),eventEMcells.GetEFraction(iCell)); | |
460 | //printf("GOOD channel\n"); | |
461 | } | |
462 | else | |
463 | { | |
464 | aodEMcells.SetCell(iCell,eventEMcells.GetCellNumber(iCell),0,-1,-1,0); | |
465 | //printf("BAD channel\n"); | |
466 | } | |
467 | } | |
468 | aodEMcells.Sort(); | |
469 | } | |
470 | ||
471 | // PHOS | |
472 | if ((fCaloFilter==kBoth || fCaloFilter==kPHOS) && fEvent->GetPHOSCells()) | |
473 | { // protection against missing ESD information | |
474 | AliVCaloCells &eventPHcells = *(fEvent->GetPHOSCells()); | |
475 | Int_t nPHcell = eventPHcells.GetNumberOfCells() ; | |
476 | ||
477 | AliAODCaloCells &aodPHcells = *(AODEvent()->GetPHOSCells()); | |
478 | aodPHcells.CreateContainer(nPHcell); | |
479 | aodPHcells.SetType(AliVCaloCells::kPHOSCell); | |
480 | ||
481 | for (Int_t iCell = 0; iCell < nPHcell; iCell++) | |
482 | { | |
483 | aodPHcells.SetCell(iCell,eventPHcells.GetCellNumber(iCell),eventPHcells.GetAmplitude(iCell), | |
484 | eventPHcells.GetTime(iCell),eventPHcells.GetMCLabel(iCell),eventPHcells.GetEFraction(iCell)); | |
485 | } | |
486 | ||
487 | aodPHcells.Sort(); | |
488 | } | |
489 | } | |
490 | ||
491 | ||
492 | //___________________________________________________ | |
493 | void AliAnalysisTaskCaloFilter::FillAODCaloClusters() | |
e4de0408 | 494 | { |
ea00d1fa | 495 | // Fill the AOD with caloclusters |
44cf05d7 | 496 | |
ea00d1fa | 497 | // Access to the AOD container of clusters |
31364cb2 | 498 | |
ea00d1fa | 499 | TClonesArray &caloClusters = *(AODEvent()->GetCaloClusters()); |
500 | Int_t jClusters=0; | |
501 | Float_t posF[3] ; | |
502 | ||
503 | Int_t nCaloClus = fEvent->GetNumberOfCaloClusters(); | |
504 | for (Int_t iClust=0; iClust<nCaloClus; ++iClust) | |
e4de0408 | 505 | { |
e4de0408 | 506 | |
ea00d1fa | 507 | AliVCluster * cluster = fEvent->GetCaloCluster(iClust); |
e4de0408 | 508 | |
ea00d1fa | 509 | //Check which calorimeter information we want to keep. |
510 | ||
511 | if(fCaloFilter!=kBoth) | |
512 | { | |
513 | if (fCaloFilter==kPHOS && cluster->IsEMCAL()) continue ; | |
514 | else if(fCaloFilter==kEMCAL && cluster->IsPHOS()) continue ; | |
515 | } | |
516 | ||
517 | // Get original residuals, in case of previous recalculation, reset them | |
518 | Float_t dR = cluster->GetTrackDx(); | |
519 | Float_t dZ = cluster->GetTrackDz(); | |
520 | ||
521 | if(DebugLevel() > 2) | |
522 | printf("Original residuals : dZ %f, dR %f\n ",dZ, dR); | |
523 | ||
524 | //-------------------------------------------------------------- | |
525 | //If EMCAL and corrections done, get the new matching parameters, do not copy noisy clusters | |
526 | if(cluster->IsEMCAL() && fCorrect) | |
527 | { | |
528 | if(DebugLevel() > 2) | |
529 | printf("Check cluster %d for bad channels and close to border\n",cluster->GetID()); | |
530 | ||
531 | if(fEMCALRecoUtils->ClusterContainsBadChannel(fEMCALGeo,cluster->GetCellsAbsId(), cluster->GetNCells())) continue; | |
532 | ||
533 | if(fEMCALRecoUtils->IsExoticCluster(cluster, InputEvent()->GetEMCALCells(),InputEvent()->GetBunchCrossNumber())) continue; | |
534 | ||
535 | fEMCALRecoUtils->GetMatchedResiduals(cluster->GetID(),dR,dZ); | |
536 | cluster->SetTrackDistance(dR,dZ); | |
537 | } | |
538 | ||
539 | if(DebugLevel() > 2) | |
540 | { | |
541 | if(cluster->IsEMCAL()) printf("EMCAL Track-Cluster Residuals : dZ %f, dR %f\n ",dZ, dR); | |
542 | if(cluster->IsPHOS()) printf("PHOS Track-Cluster Residuals : dZ %f, dR %f\n ",dZ, dR); | |
543 | } | |
544 | ||
545 | //-------------------------------------------------------------- | |
546 | ||
547 | //Now fill AODs | |
548 | ||
549 | Int_t id = cluster->GetID(); | |
550 | Float_t energy = cluster->E(); | |
551 | cluster->GetPosition(posF); | |
552 | ||
553 | AliAODCaloCluster *caloCluster = new(caloClusters[jClusters++]) | |
554 | AliAODCaloCluster(id, | |
555 | cluster->GetNLabels(), | |
556 | cluster->GetLabels(), | |
557 | energy, | |
558 | posF, | |
559 | NULL, | |
560 | cluster->GetType()); | |
561 | ||
562 | caloCluster->SetCaloCluster(cluster->GetDistanceToBadChannel(), | |
563 | cluster->GetDispersion(), | |
564 | cluster->GetM20(), cluster->GetM02(), | |
565 | -1, | |
566 | cluster->GetNExMax(),cluster->GetTOF()) ; | |
567 | ||
568 | caloCluster->SetPIDFromESD(cluster->GetPID()); | |
569 | caloCluster->SetNCells(cluster->GetNCells()); | |
570 | caloCluster->SetCellsAbsId(cluster->GetCellsAbsId()); | |
571 | caloCluster->SetCellsAmplitudeFraction(cluster->GetCellsAmplitudeFraction()); | |
572 | caloCluster->SetTrackDistance(dR, dZ); | |
573 | ||
574 | if(DebugLevel() > 2) | |
575 | { | |
576 | printf("Filter, aod : i %d, E %f, dispersion %f, m02 %f, m20 %f\n",caloCluster->GetID(),caloCluster->E(), | |
577 | caloCluster->GetDispersion(),caloCluster->GetM02(),caloCluster->GetM20()); | |
578 | caloCluster->GetPosition(posF); | |
579 | printf("Filter, aod : i %d, x %f, y %f, z %f\n",caloCluster->GetID(), posF[0], posF[1], posF[2]); | |
580 | } | |
581 | ||
582 | //Matched tracks, just to know if there was any match, the track pointer is useless if tracks not stored | |
583 | if(TMath::Abs(dR) < 990 && TMath::Abs(dZ) < 990) | |
584 | { //Default value in PHOS 999, in EMCAL 1024, why? | |
585 | caloCluster->AddTrackMatched(new AliAODTrack); | |
586 | } | |
587 | // TO DO, in case Tracks available, think how to put the matched track in AOD | |
e4de0408 | 588 | } |
589 | ||
ea00d1fa | 590 | caloClusters.Expand(jClusters); // resize TObjArray to 'remove' slots |
591 | ||
592 | } | |
593 | ||
594 | //__________________________________________________ | |
595 | void AliAnalysisTaskCaloFilter::FillAODCaloTrigger() | |
596 | { | |
597 | // AOD CaloTrigger copy | |
598 | ||
599 | AliAODCaloTrigger* triggerEM = AODEvent()->GetCaloTrigger("EMCAL"); | |
600 | AliAODCaloTrigger* triggerPH = AODEvent()->GetCaloTrigger("PHOS"); | |
601 | ||
602 | // Copy from AODs | |
603 | if(fAODEvent) | |
e4de0408 | 604 | { |
ea00d1fa | 605 | if(fCaloFilter==kBoth || fCaloFilter==kPHOS) *triggerPH = *(fAODEvent->GetCaloTrigger("PHOS")); |
606 | ||
607 | if(fCaloFilter==kBoth || fCaloFilter==kEMCAL) *triggerEM = *(fAODEvent->GetCaloTrigger("EMCAL")); | |
608 | ||
609 | return; | |
44cf05d7 | 610 | } |
611 | ||
ea00d1fa | 612 | } |
613 | ||
614 | //______________________________________________ | |
615 | void AliAnalysisTaskCaloFilter::FillAODHeader() | |
616 | { | |
617 | // AOD header copy | |
618 | ||
619 | AliAODHeader* header = AODEvent()->GetHeader(); | |
620 | ||
621 | // Copy from AODs | |
622 | if(fAODEvent) | |
e4de0408 | 623 | { |
ea00d1fa | 624 | *header = *(fAODEvent->GetHeader()); |
625 | return; | |
626 | } | |
627 | ||
628 | if(!fESDEvent) return; | |
629 | ||
630 | // Copy from ESDs | |
631 | ||
632 | header->SetRunNumber(fEvent->GetRunNumber()); | |
633 | ||
634 | TTree* tree = fInputHandler->GetTree(); | |
635 | if (tree) | |
636 | { | |
637 | TFile* file = tree->GetCurrentFile(); | |
638 | if (file) header->SetESDFileName(file->GetName()); | |
639 | } | |
640 | ||
641 | header->SetBunchCrossNumber(fEvent->GetBunchCrossNumber()); | |
642 | header->SetOrbitNumber(fEvent->GetOrbitNumber()); | |
643 | header->SetPeriodNumber(fEvent->GetPeriodNumber()); | |
644 | header->SetEventType(fEvent->GetEventType()); | |
645 | ||
646 | //Centrality | |
647 | if(fEvent->GetCentrality()) | |
648 | { | |
649 | header->SetCentrality(new AliCentrality(*(fEvent->GetCentrality()))); | |
650 | } | |
651 | else | |
652 | { | |
653 | header->SetCentrality(0); | |
654 | } | |
655 | ||
656 | //Trigger | |
657 | header->SetOfflineTrigger(fInputHandler->IsEventSelected()); // propagate the decision of the physics selection | |
658 | header->SetFiredTriggerClasses(fESDEvent->GetFiredTriggerClasses()); | |
659 | header->SetTriggerMask(fEvent->GetTriggerMask()); | |
660 | header->SetTriggerCluster(fEvent->GetTriggerCluster()); | |
661 | header->SetL0TriggerInputs(fESDEvent->GetHeader()->GetL0TriggerInputs()); | |
662 | header->SetL1TriggerInputs(fESDEvent->GetHeader()->GetL1TriggerInputs()); | |
663 | header->SetL2TriggerInputs(fESDEvent->GetHeader()->GetL2TriggerInputs()); | |
664 | ||
665 | header->SetMagneticField(fEvent->GetMagneticField()); | |
666 | //header->SetMuonMagFieldScale(fESDEvent->GetCurrentDip()/6000.); | |
667 | ||
668 | header->SetZDCN1Energy(fEvent->GetZDCN1Energy()); | |
669 | header->SetZDCP1Energy(fEvent->GetZDCP1Energy()); | |
670 | header->SetZDCN2Energy(fEvent->GetZDCN2Energy()); | |
671 | header->SetZDCP2Energy(fEvent->GetZDCP2Energy()); | |
672 | header->SetZDCEMEnergy(fEvent->GetZDCEMEnergy(0),fEvent->GetZDCEMEnergy(1)); | |
673 | ||
674 | Float_t diamxy[2]={fEvent->GetDiamondX(),fEvent->GetDiamondY()}; | |
675 | Float_t diamcov[3]; | |
676 | fEvent->GetDiamondCovXY(diamcov); | |
677 | header->SetDiamond(diamxy,diamcov); | |
678 | header->SetDiamondZ(fESDEvent->GetDiamondZ(),fESDEvent->GetSigma2DiamondZ()); | |
679 | ||
680 | } | |
681 | ||
eee2ea01 | 682 | |
683 | //__________________________________________________ | |
684 | void AliAnalysisTaskCaloFilter::FillAODMCParticles() | |
685 | { | |
686 | // Copy MC particles | |
687 | ||
688 | if(!fFillMCParticles) return; | |
689 | ||
690 | TClonesArray* inMCParticles = (TClonesArray*) (fAODEvent ->FindListObject("mcparticles")); | |
691 | TClonesArray* ouMCParticles = (TClonesArray*) ( AODEvent()->FindListObject("mcparticles")); | |
692 | ||
693 | if( inMCParticles && ouMCParticles ) new (ouMCParticles) TClonesArray(*inMCParticles); | |
694 | ||
695 | } | |
696 | ||
ea00d1fa | 697 | //_____________________________________________ |
698 | void AliAnalysisTaskCaloFilter::FillAODTracks() | |
699 | { | |
700 | // AOD track copy | |
701 | ||
702 | if(!fFillTracks) return; | |
703 | ||
704 | AliAODTrack* aodTrack(0x0); | |
705 | ||
706 | Double_t pos[3] = { 0. }; | |
707 | Double_t covTr[21]= { 0. }; | |
708 | Double_t pid[10] = { 0. }; | |
709 | Double_t p[3] = { 0. }; | |
710 | ||
711 | // Copy from AODs | |
712 | if(fAODEvent) | |
713 | { | |
714 | //TClonesArray* inTracks = fAODEvent ->GetTracks(); | |
715 | TClonesArray* ouTracks = AODEvent()->GetTracks(); | |
716 | //new (ouTracks) TClonesArray(*inTracks); | |
717 | ||
718 | //printf("N tracks %d\n",fAODEvent->GetNumberOfTracks()); | |
719 | Int_t nCopyTrack = 0; | |
720 | for (Int_t nTrack = 0; nTrack < fAODEvent->GetNumberOfTracks(); ++nTrack) | |
e4de0408 | 721 | { |
ea00d1fa | 722 | AliAODTrack *track = fAODEvent->GetTrack(nTrack); |
44cf05d7 | 723 | |
ea00d1fa | 724 | // Select only hybrid tracks? |
725 | if(fFillHybridTracks && !track->IsHybridGlobalConstrainedGlobal()) continue; | |
726 | ||
727 | // Remove PID object to save space | |
728 | //track->SetDetPID(0x0); | |
729 | ||
730 | //new((*ouTracks)[nCopyTrack++]) AliAODTrack(*track); | |
731 | ||
732 | track->GetPxPyPz(p); | |
733 | Bool_t isDCA = track->GetPosition(pos); | |
734 | track->GetCovMatrix(covTr); | |
735 | track->GetPID(pid); | |
736 | ||
737 | AliAODVertex* primVertex = (AliAODVertex*) AODEvent()->GetVertices()->At(0); // primary vertex, copied previously!!! | |
738 | ||
739 | aodTrack = new((*ouTracks)[nCopyTrack++]) AliAODTrack( | |
740 | track->GetID(), | |
741 | track->GetLabel(), | |
742 | p, | |
743 | kTRUE, | |
744 | pos, | |
745 | isDCA, | |
746 | covTr, | |
747 | track->Charge(), | |
748 | track->GetITSClusterMap(), | |
749 | pid, | |
750 | primVertex, | |
751 | track->GetUsedForVtxFit(), | |
752 | track->GetUsedForPrimVtxFit(), | |
753 | (AliAODTrack::AODTrk_t) track->GetType(), | |
754 | track->GetFilterMap(), | |
755 | track->Chi2perNDF()); | |
756 | ||
757 | ||
758 | aodTrack->SetIsHybridGlobalConstrainedGlobal(track->IsHybridGlobalConstrainedGlobal()); | |
759 | aodTrack->SetIsHybridTPCConstrainedGlobal (track->IsHybridTPCConstrainedGlobal()); | |
760 | aodTrack->SetIsGlobalConstrained (track->IsGlobalConstrained()); | |
761 | aodTrack->SetIsTPCConstrained (track->IsTPCConstrained()); | |
762 | ||
763 | aodTrack->SetTPCFitMap (track->GetTPCFitMap()); | |
764 | aodTrack->SetTPCClusterMap(track->GetTPCClusterMap()); | |
765 | aodTrack->SetTPCSharedMap (track->GetTPCSharedMap()); | |
766 | ||
767 | aodTrack->SetChi2MatchTrigger(track->GetChi2MatchTrigger()); | |
768 | ||
769 | // set the DCA values to the AOD track | |
770 | ||
771 | aodTrack->SetPxPyPzAtDCA(track->PxAtDCA(),track->PyAtDCA(),track->PzAtDCA()); | |
772 | aodTrack->SetXYAtDCA (track->XAtDCA() ,track->YAtDCA()); | |
773 | ||
774 | aodTrack->SetFlags (track->GetFlags()); | |
775 | aodTrack->SetTPCPointsF (track->GetTPCNclsF()); | |
776 | ||
777 | // Calo | |
778 | ||
779 | if(track->IsEMCAL()) aodTrack->SetEMCALcluster(track->GetEMCALcluster()); | |
780 | if(track->IsPHOS()) aodTrack->SetPHOScluster (track->GetPHOScluster()); | |
781 | aodTrack->SetTrackPhiEtaOnEMCal( track->GetTrackPhiOnEMCal(), track->GetTrackPhiOnEMCal() ); | |
782 | ||
783 | } | |
784 | ||
785 | //printf("Final N tracks %d\n",nCopyTrack); | |
786 | ||
787 | return; | |
788 | } | |
789 | ||
790 | } | |
791 | ||
792 | //_________________________________________ | |
793 | void AliAnalysisTaskCaloFilter::FillAODv0s() | |
794 | { | |
795 | // Copy v0s (use if you know what you do, use quite a lot of memory) | |
796 | ||
797 | if(!fFillv0s) return; | |
798 | ||
799 | // Copy from AODs | |
800 | if(fAODEvent) | |
801 | { | |
802 | TClonesArray* inv0 = fAODEvent ->GetV0s(); | |
803 | TClonesArray* ouv0 = AODEvent()->GetV0s(); | |
804 | ||
805 | //new (ouv0s) TClonesArray(*inv0s); | |
806 | ||
807 | Int_t allv0s = inv0->GetEntriesFast(); | |
808 | ||
809 | for (Int_t nv0s = 0; nv0s < allv0s; ++nv0s) | |
e4de0408 | 810 | { |
ea00d1fa | 811 | AliAODv0 *v0 = (AliAODv0*)inv0->At(nv0s); |
812 | ||
813 | new((*ouv0)[nv0s]) AliAODv0(*v0); | |
814 | } | |
815 | ||
816 | return; | |
817 | } | |
818 | ||
819 | } | |
820 | ||
821 | //____________________________________________ | |
822 | void AliAnalysisTaskCaloFilter::FillAODVZERO() | |
823 | { | |
824 | // Copy VZERO | |
825 | ||
826 | if(!fFillVZERO) return; | |
827 | ||
828 | AliAODVZERO* vzeroData = AODEvent()->GetVZEROData(); | |
829 | ||
830 | if(fESDEvent) *vzeroData = *(fESDEvent->GetVZEROData()); | |
831 | else *vzeroData = *(fAODEvent->GetVZEROData()); | |
832 | ||
833 | } | |
834 | ||
835 | //_______________________________________________ | |
836 | void AliAnalysisTaskCaloFilter::FillAODVertices() | |
837 | { | |
838 | // Copy vertices | |
839 | ||
840 | // set arrays and pointers | |
841 | Double_t pos[3] ; | |
842 | Double_t covVtx[6]; | |
843 | for (Int_t i = 0; i < 6; i++) covVtx[i] = 0.; | |
844 | ||
845 | // Copy from AODs | |
846 | if(fAODEvent) | |
847 | { | |
848 | TClonesArray* inVertices = fAODEvent ->GetVertices(); | |
849 | TClonesArray* ouVertices = AODEvent()->GetVertices(); | |
850 | ||
851 | //new (ouVertices) TClonesArray(*inVertices); | |
852 | ||
853 | //Keep only the first 3 vertices if not requested | |
854 | Int_t allVertices = inVertices->GetEntriesFast(); | |
855 | ||
856 | //printf("n Vertices %d\n",allVertices); | |
857 | ||
858 | if(!fFillAllVertices) | |
859 | { | |
860 | if(allVertices > 3) allVertices = 3; | |
44cf05d7 | 861 | } |
ea00d1fa | 862 | |
863 | //printf("Final n Vertices %d\n",allVertices); | |
864 | ||
865 | for (Int_t nVertices = 0; nVertices < allVertices; ++nVertices) | |
866 | { | |
867 | AliAODVertex *vertex = (AliAODVertex*)inVertices->At(nVertices); | |
868 | ||
869 | new((*ouVertices)[nVertices]) AliAODVertex(*vertex); | |
870 | } | |
871 | ||
872 | return; | |
44cf05d7 | 873 | } |
ea00d1fa | 874 | |
875 | if(!fESDEvent) return; | |
876 | ||
877 | // Copy from ESDs | |
878 | ||
879 | // Access to the AOD container of vertices | |
880 | Int_t jVertices=0; | |
881 | TClonesArray &vertices = *(AODEvent()->GetVertices()); | |
882 | ||
883 | // Add primary vertex. The primary tracks will be defined | |
884 | // after the loops on the composite objects (v0, cascades, kinks) | |
885 | fEvent ->GetPrimaryVertex()->GetXYZ(pos); | |
886 | fESDEvent->GetPrimaryVertex()->GetCovMatrix(covVtx); | |
887 | Float_t chi = fESDEvent->GetPrimaryVertex()->GetChi2toNDF(); | |
888 | ||
889 | AliAODVertex * primary = new(vertices[jVertices++]) | |
890 | AliAODVertex(pos, covVtx, chi, NULL, -1, AliAODVertex::kPrimary); | |
891 | primary->SetName(fEvent->GetPrimaryVertex()->GetName()); | |
892 | primary->SetTitle(fEvent->GetPrimaryVertex()->GetTitle()); | |
e4de0408 | 893 | |
44cf05d7 | 894 | } |
895 | ||
ea00d1fa | 896 | //____________________________________ |
897 | void AliAnalysisTaskCaloFilter::Init() | |
898 | { | |
899 | //Init analysis with configuration macro if available | |
900 | ||
901 | if(gROOT->LoadMacro(fConfigName) >=0) | |
902 | { | |
903 | printf("Configure analysis with %s\n",fConfigName.Data()); | |
904 | ||
905 | AliAnalysisTaskCaloFilter *filter = (AliAnalysisTaskCaloFilter*)gInterpreter->ProcessLine("ConfigCaloFilter()"); | |
906 | ||
907 | fEMCALGeoName = filter->fEMCALGeoName; | |
908 | fLoadEMCALMatrices = filter->fLoadEMCALMatrices; | |
909 | fFillAODFile = filter->fFillAODFile; | |
910 | fFillTracks = filter->fFillTracks; | |
911 | fFillHybridTracks = filter->fFillHybridTracks; | |
912 | fFillv0s = filter->fFillv0s; | |
913 | fFillVZERO = filter->fFillVZERO; | |
914 | fFillAllVertices = filter->fFillAllVertices; | |
915 | fEMCALRecoUtils = filter->fEMCALRecoUtils; | |
916 | fConfigName = filter->fConfigName; | |
917 | fCaloFilter = filter->fCaloFilter; | |
918 | fEventSelection[0] = filter->fEventSelection[0]; | |
919 | fEventSelection[1] = filter->fEventSelection[1]; | |
920 | fEventSelection[2] = filter->fEventSelection[2]; | |
921 | fAcceptAllMBEvent = filter->fAcceptAllMBEvent; | |
922 | fCorrect = filter->fCorrect; | |
923 | fEMCALEnergyCut = filter->fEMCALEnergyCut; | |
924 | fEMCALNcellsCut = filter->fEMCALNcellsCut; | |
925 | fPHOSEnergyCut = filter->fPHOSEnergyCut; | |
926 | fPHOSNcellsCut = filter->fPHOSNcellsCut; | |
927 | fTrackPtCut = filter->fTrackPtCut; | |
928 | fVzCut = filter->fVzCut; | |
929 | ||
930 | for(Int_t i = 0; i < 12; i++) fEMCALMatrix[i] = filter->fEMCALMatrix[i] ; | |
931 | } | |
932 | } | |
933 | ||
e4de0408 | 934 | //_________________________________________ |
935 | void AliAnalysisTaskCaloFilter::PrintInfo() | |
936 | { | |
5ef94e1b | 937 | //Print settings |
e4de0408 | 938 | |
2ec3a257 | 939 | printf("AnalysisCaloFilter::PrintInfo() \n"); |
ea00d1fa | 940 | |
5ef94e1b | 941 | printf("\t Not only filter, correct Clusters? %d\n",fCorrect); |
942 | printf("\t Calorimeter Filtering Option ? %d\n",fCaloFilter); | |
ea00d1fa | 943 | |
3b13c34c | 944 | //printf("\t Use handmade geo matrices? EMCAL %d, PHOS %d\n",fLoadEMCALMatrices, fLoadPHOSMatrices); |
945 | printf("\t Use handmade geo matrices? EMCAL %d, PHOS 0\n",fLoadEMCALMatrices); | |
ea00d1fa | 946 | |
947 | printf("\t Fill: AOD file? %d Tracks? %d; all Vertex? %d; v0s? %d; VZERO ? %d\n", | |
948 | fFillAODFile,fFillTracks,fFillAllVertices, fFillv0s, fFillVZERO); | |
949 | ||
950 | printf("\t Event Selection based : EMCAL? %d, PHOS? %d Tracks? %d - Accept all MB? %d\n", | |
951 | fEventSelection[0],fEventSelection[1],fEventSelection[2],fAcceptAllMBEvent); | |
952 | ||
953 | printf("\t \t EMCAL E > %2.2f, EMCAL nCells >= %d, PHOS E > %2.2f, PHOS nCells >= %d, Track pT > %2.2f, |vz| < %2.2f\n", | |
954 | fEMCALEnergyCut,fEMCALNcellsCut,fPHOSEnergyCut,fPHOSNcellsCut, fTrackPtCut,fVzCut); | |
955 | } | |
956 | ||
957 | //_______________________________________________________ | |
958 | void AliAnalysisTaskCaloFilter::UserCreateOutputObjects() | |
959 | { | |
960 | // Init geometry | |
961 | ||
962 | fEMCALGeo = AliEMCALGeometry::GetInstance(fEMCALGeoName) ; | |
963 | ||
eee2ea01 | 964 | if(fFillMCParticles) |
965 | { | |
966 | TClonesArray * aodMCParticles = new TClonesArray("AliAODMCParticle",500); | |
967 | aodMCParticles->SetName("mcparticles"); | |
968 | ((AliAODHandler*)AliAnalysisManager::GetAnalysisManager()->GetOutputEventHandler())->AddBranch("TClonesArray", &aodMCParticles); | |
969 | } | |
970 | ||
ea00d1fa | 971 | } |
972 | ||
973 | //____________________________________________________________ | |
974 | void AliAnalysisTaskCaloFilter::UserExec(Option_t */*option*/) | |
975 | { | |
976 | // Execute analysis for current event | |
977 | // Copy input ESD or AOD header, vertex, CaloClusters and CaloCells to output AOD | |
978 | ||
979 | if (fDebug > 0) | |
980 | printf("CaloFilter: Analysing event # %d\n", (Int_t)Entry()); | |
981 | ||
982 | fEvent = InputEvent(); | |
983 | fAODEvent = dynamic_cast<AliAODEvent*> (fEvent); | |
984 | fESDEvent = dynamic_cast<AliESDEvent*> (fEvent); | |
985 | ||
986 | if(!fEvent) | |
987 | { | |
988 | printf("AliAnalysisTaskCaloFilter::UserExec - This event does not contain Input?"); | |
989 | return; | |
990 | } | |
991 | ||
992 | // printf("Start processing : %s\n",fAODEvent->GetFiredTriggerClasses().Data()); | |
993 | ||
994 | // Select the event | |
995 | ||
996 | if(!AcceptEvent()) return ; | |
997 | ||
998 | //Magic line to write events to file | |
999 | ||
1000 | AliAnalysisManager::GetAnalysisManager()->GetOutputEventHandler()->SetFillAOD(fFillAODFile); | |
1001 | ||
1002 | // Reset output AOD | |
1003 | ||
1004 | Int_t nVertices = 0; | |
1005 | if(fFillv0s) nVertices = fEvent->GetNumberOfV0s(); | |
1006 | Int_t nCaloClus = fEvent->GetNumberOfCaloClusters(); | |
1007 | Int_t nTracks = fEvent->GetNumberOfTracks(); | |
1008 | ||
1009 | AODEvent()->ResetStd(nTracks, nVertices, 0, 0, 0, nCaloClus, 0, 0); | |
1010 | ||
1011 | // Copy | |
1012 | ||
1013 | FillAODHeader(); | |
1014 | ||
1015 | // | |
1016 | FillAODv0s(); | |
1017 | ||
1018 | // | |
1019 | FillAODVertices(); // Do it before the track filtering to have the reference to the vertex | |
1020 | ||
1021 | // | |
1022 | FillAODVZERO(); | |
1023 | ||
1024 | // | |
1025 | FillAODTracks(); | |
1026 | ||
1027 | // | |
1028 | CorrectionsInEMCAL(); | |
1029 | ||
1030 | // | |
1031 | FillAODCaloClusters(); | |
1032 | ||
1033 | // | |
1034 | FillAODCaloCells(); | |
1035 | ||
1036 | // | |
1037 | FillAODCaloTrigger(); | |
1038 | ||
eee2ea01 | 1039 | // |
1040 | FillAODMCParticles(); | |
1041 | ||
ea00d1fa | 1042 | //printf("Filtered event, end processing : %s\n",fAODEvent->GetFiredTriggerClasses().Data()); |
1043 | ||
7a4cf423 | 1044 | } |
1045 |