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