1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
16 //////////////////////////////////////////////////////////
17 // Filter the ESDCaloClusters and ESDCaloCells of EMCAL,
18 // PHOS or both, creating the corresponing AODCaloClusters
20 // Keep also the AODHeader information and the vertex.
21 // Keep tracks, v0s, VZERO if requested
22 // Select events containing a cluster or track avobe a given threshold
23 // Copy of AliAnalysisTaskESDfilter.
24 // Author: Gustavo Conesa Balbastre (INFN - Frascati)
25 //////////////////////////////////////////////////////////
28 #include "TGeoManager.h"
31 #include "TInterpreter.h"
34 #include "AliESDEvent.h"
35 #include "AliAODEvent.h"
37 #include "AliVCluster.h"
38 #include "AliVCaloCells.h"
39 #include "AliVEventHandler.h"
40 #include "AliAnalysisManager.h"
41 #include "AliInputEventHandler.h"
44 #include "AliEMCALRecoUtils.h"
45 #include "AliEMCALGeometry.h"
47 #include "AliAnalysisTaskCaloFilter.h"
49 ClassImp(AliAnalysisTaskCaloFilter)
51 ////////////////////////////////////////////////////////////////////////
53 AliAnalysisTaskCaloFilter::AliAnalysisTaskCaloFilter():
54 AliAnalysisTaskSE("CaloFilterTask"),
55 fCaloFilter(0), fEventSelection(),
56 fAcceptAllMBEvent(kFALSE), fCorrect(kFALSE),
57 fEMCALGeo(0x0), fEMCALGeoName("EMCAL_COMPLETE12SMV1"),
58 fEMCALRecoUtils(new AliEMCALRecoUtils),
59 fLoadEMCALMatrices(kFALSE), //fLoadPHOSMatrices(kFALSE),
60 fGeoMatrixSet(kFALSE),
61 fConfigName(""), fFillAODFile(kTRUE),
62 fFillTracks(kFALSE), fFillHybridTracks(kFALSE),
63 fFillAllVertices(kFALSE), fFillv0s(kFALSE),
65 fEMCALEnergyCut(0.), fEMCALNcellsCut (0),
66 fPHOSEnergyCut(0.), fPHOSNcellsCut (0),
68 fVzCut(100.), fEvent(0x0),
69 fESDEvent(0x0), fAODEvent(0x0)
71 // Default constructor
73 fEventSelection[0] = kFALSE;
74 fEventSelection[1] = kFALSE;
75 fEventSelection[2] = kFALSE;
77 for(Int_t i = 0; i < 12; i++) fEMCALMatrix[i] = 0 ;
78 //for(Int_t i = 0; i < 5 ; i++) fPHOSMatrix[i] = 0 ;
82 //__________________________________________________
83 AliAnalysisTaskCaloFilter::AliAnalysisTaskCaloFilter(const char* name):
84 AliAnalysisTaskSE(name),
85 fCaloFilter(0), fEventSelection(),
86 fAcceptAllMBEvent(kFALSE), fCorrect(kFALSE),
87 fEMCALGeo(0x0), fEMCALGeoName("EMCAL_COMPLETE12SMV1"),
88 fEMCALRecoUtils(new AliEMCALRecoUtils),
89 fLoadEMCALMatrices(kFALSE), //fLoadPHOSMatrices(kFALSE),
90 fGeoMatrixSet(kFALSE),
91 fConfigName(""), fFillAODFile(kTRUE),
92 fFillTracks(kFALSE), fFillHybridTracks(kFALSE),
93 fFillAllVertices(kFALSE), fFillv0s(kFALSE),
95 fEMCALEnergyCut(0.), fEMCALNcellsCut(0),
96 fPHOSEnergyCut(0.), fPHOSNcellsCut(0),
98 fVzCut(100.), fEvent(0x0),
99 fESDEvent(0x0), fAODEvent(0x0)
103 fEventSelection[0] = kFALSE;
104 fEventSelection[1] = kFALSE;
105 fEventSelection[2] = kFALSE;
107 for(Int_t i = 0; i < 12; i++) fEMCALMatrix[i] = 0 ;
108 //for(Int_t i = 0; i < 5 ; i++) fPHOSMatrix[i] = 0 ;
112 //__________________________________________________
113 AliAnalysisTaskCaloFilter::~AliAnalysisTaskCaloFilter()
117 if(fEMCALGeo) delete fEMCALGeo;
118 if(fEMCALRecoUtils) delete fEMCALRecoUtils;
122 //_____________________________________________
123 Bool_t AliAnalysisTaskCaloFilter::AcceptEvent()
125 // Define conditions to accept the event to be filtered
127 Bool_t eventSel = kFALSE;
129 Bool_t isMB = (((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->IsEventSelected() & AliVEvent::kMB);
131 if ( isMB && fAcceptAllMBEvent ) eventSel = kTRUE; // accept any MB event
133 else if( fEventSelection[0] && AcceptEventEMCAL() ) eventSel = kTRUE; // accept event depending on EMCAL activity
135 else if( fEventSelection[1] && AcceptEventPHOS () ) eventSel = kTRUE; // accept event depending on PHOS activity
137 else if( fEventSelection[2] && AcceptEventTrack() ) eventSel = kTRUE; // accept event depending on Track activity
143 //__________________________________________________
144 Bool_t AliAnalysisTaskCaloFilter::AcceptEventEMCAL()
146 // Accept event given there is a EMCAL cluster with enough energy, and not noisy, exotic
148 if(fCaloFilter==kPHOS) return kTRUE; // accept
150 if(fEMCALEnergyCut <= 0) return kTRUE; // accept
152 Int_t nCluster = InputEvent() -> GetNumberOfCaloClusters();
153 AliVCaloCells * caloCell = InputEvent() -> GetEMCALCells();
154 Int_t bc = InputEvent() -> GetBunchCrossNumber();
156 for(Int_t icalo = 0; icalo < nCluster; icalo++)
158 AliVCluster *clus = (AliVCluster*) (InputEvent()->GetCaloCluster(icalo));
160 if( ( clus->IsEMCAL() ) && ( clus->GetNCells() > fEMCALNcellsCut ) && ( clus->E() > fEMCALEnergyCut ) &&
161 fEMCALRecoUtils->IsGoodCluster(clus,fEMCALGeo,caloCell,bc))
164 if (fDebug > 0) printf("AliAnalysisTaskCaloFilter::AcceptEventEMCAL() - Accept : E %2.2f > %2.2f, nCells %d > %d \n",
165 clus->E(), fEMCALEnergyCut, clus->GetNCells(), fEMCALNcellsCut);
172 if (fDebug > 0) printf("AliAnalysisTaskCaloFilter::AcceptEventEMCAL() - Reject \n");
178 //_________________________________________________
179 Bool_t AliAnalysisTaskCaloFilter::AcceptEventPHOS()
181 // Accept event given there is a PHOS cluster with enough energy and not noisy/exotic
183 if(fCaloFilter==kEMCAL) return kTRUE; // accept
185 if(fPHOSEnergyCut <= 0) return kTRUE; // accept
187 Int_t nCluster = InputEvent() -> GetNumberOfCaloClusters();
189 for(Int_t icalo = 0; icalo < nCluster; icalo++)
191 AliVCluster *clus = (AliVCluster*) (InputEvent()->GetCaloCluster(icalo));
193 if( ( clus->IsPHOS() ) && ( clus->GetNCells() > fPHOSNcellsCut ) && ( clus->E() > fPHOSEnergyCut ))
196 if (fDebug > 0) printf("AliAnalysisTaskCaloFilter::AcceptEventPHOS() - Accept : E %2.2f > %2.2f, nCells %d > %d \n",
197 clus->E(), fPHOSEnergyCut, clus->GetNCells(), fPHOSNcellsCut);
204 if (fDebug > 0) printf("AliAnalysisTaskCaloFilter::AcceptEventPHOS() - Reject \n");
210 //__________________________________________________
211 Bool_t AliAnalysisTaskCaloFilter::AcceptEventTrack()
213 // Accept event if there is a track avobe a certain pT
215 if(fTrackPtCut <= 0) return kTRUE; // accept
217 Double_t pTrack[3] = {0,0,0};
219 for (Int_t nTrack = 0; nTrack < fEvent->GetNumberOfTracks(); ++nTrack)
221 AliVTrack *track = (AliVTrack*) fEvent->GetTrack(nTrack);
223 // Select only hybrid tracks?
224 if(fAODEvent && fFillHybridTracks && !((AliAODTrack*)track)->IsHybridGlobalConstrainedGlobal()) continue;
226 track->GetPxPyPz(pTrack) ;
228 TLorentzVector momentum(pTrack[0],pTrack[1],pTrack[2],0);
230 if(momentum.Pt() > fTrackPtCut)
232 if (fDebug > 0) printf("AliAnalysisTaskCaloFilter::AcceptEventTrack() - Accept : pT %2.2f > %2.2f \n",
233 momentum.Pt(), fTrackPtCut);
240 if (fDebug > 0) printf("AliAnalysisTaskCaloFilter::AcceptEventTrack() - Reject \n");
246 //___________________________________________________
247 Bool_t AliAnalysisTaskCaloFilter::AcceptEventVertex()
249 // Accept event with good vertex
252 InputEvent()->GetPrimaryVertex()->GetXYZ(v) ;
254 if(TMath::Abs(v[2]) > fVzCut)
256 if (fDebug > 0) printf("AliAnalysisTaskCaloFilter::AcceptEventVertex() - Vz Reject \n");
260 return CheckForPrimaryVertex();
263 //_______________________________________________________
264 Bool_t AliAnalysisTaskCaloFilter::CheckForPrimaryVertex()
266 //Check if the vertex was well reconstructed, copy from v0Reader of conversion group
267 //It only works for ESDs
272 // Check that the vertex is not (0,0,0)
274 InputEvent()->GetPrimaryVertex()->GetXYZ(v) ;
276 if(TMath::Abs(v[2]) < 1e-6 &&
277 TMath::Abs(v[1]) < 1e-6 &&
278 TMath::Abs(v[0]) < 1e-6 )
280 if (fDebug > 0) printf("AliAnalysisTaskCaloFilter::CheckForPrimaryVertex() - Reject \n");
289 if(fESDEvent->GetPrimaryVertexTracks()->GetNContributors() > 0)
294 if(fESDEvent->GetPrimaryVertexTracks()->GetNContributors() < 1)
297 if(fESDEvent->GetPrimaryVertexSPD()->GetNContributors() > 0)
299 //cout<<"spd vertex type::"<< fESDEvent->GetPrimaryVertex()->GetName() << endl;
303 if(fESDEvent->GetPrimaryVertexSPD()->GetNContributors() < 1)
305 // cout<<"bad vertex type::"<< fESDEvent->GetPrimaryVertex()->GetName() << endl;
306 if (fDebug > 0) printf("AliAnalysisTaskCaloFilter::CheckForPrimaryVertex() - Reject \n");
311 if (fDebug > 0) printf("AliAnalysisTaskCaloFilter::CheckForPrimaryVertex() - Reject \n");
317 //__________________________________________________
318 void AliAnalysisTaskCaloFilter::CorrectionsInEMCAL()
320 //If EMCAL, and requested, correct energy, position ...
322 //Need to do this in a separate loop before filling the ESDs because of the track matching recalculations
324 if(fCorrect && (fCaloFilter==kEMCAL || fCaloFilter==kBoth) )
328 if(fLoadEMCALMatrices)
330 printf("AliAnalysisTaskCaloFilter::UserExec() - Load user defined EMCAL geometry matrices\n");
331 for(Int_t mod=0; mod < (fEMCALGeo->GetEMCGeometry())->GetNumberOfSuperModules(); mod++){
332 if(fEMCALMatrix[mod]){
334 fEMCALMatrix[mod]->Print();
335 fEMCALGeo->SetMisalMatrix(fEMCALMatrix[mod],mod) ;
340 else if(!gGeoManager)
342 printf("AliAnalysisTaskCaloFilter::UserExec() - Get geo matrices from data\n");
343 //Still not implemented in AOD, just a workaround to be able to work at least with ESDs
344 if(!strcmp(InputEvent()->GetName(),"AliAODEvent"))
347 printf("AliAnalysisTaskCaloFilter Use ideal geometry, values geometry matrix not kept in AODs.\n");
351 if(DebugLevel() > 1) printf("AliAnalysisTaskCaloFilter Load Misaligned matrices. \n");
352 AliESDEvent* esd = dynamic_cast<AliESDEvent*>(InputEvent()) ;
355 printf("AliAnalysisTaskCaloFilter::UserExec() - This event does not contain ESDs?");
358 for(Int_t mod=0; mod < (fEMCALGeo->GetEMCGeometry())->GetNumberOfSuperModules(); mod++)
360 //if(DebugLevel() > 1)
361 esd->GetEMCALMatrix(mod)->Print();
362 if(esd->GetEMCALMatrix(mod)) fEMCALGeo->SetMisalMatrix(esd->GetEMCALMatrix(mod),mod) ;
366 }//Load matrices from Data
371 Int_t nCaloClus = InputEvent()->GetNumberOfCaloClusters();
373 for (Int_t iClust=0; iClust<nCaloClus; ++iClust)
375 AliVCluster * cluster = InputEvent()->GetCaloCluster(iClust);
377 if(cluster->IsPHOS()) continue ;
379 Float_t position[]={0,0,0};
381 printf("Check cluster %d for bad channels and close to border\n",cluster->GetID());
382 if(fEMCALRecoUtils->ClusterContainsBadChannel(fEMCALGeo,cluster->GetCellsAbsId(), cluster->GetNCells())) continue;
386 printf("Filter, before : i %d, E %f, dispersion %f, m02 %f, m20 %f, distToBad %f\n",iClust,cluster->E(),
387 cluster->GetDispersion(),cluster->GetM02(),cluster->GetM20(), cluster->GetDistanceToBadChannel());
388 cluster->GetPosition(position);
389 printf("Filter, before : i %d, x %f, y %f, z %f\n",cluster->GetID(), position[0], position[1], position[2]);
392 //Recalculate distance to bad channels, if new list of bad channels provided
393 fEMCALRecoUtils->RecalculateClusterDistanceToBadChannel(fEMCALGeo, InputEvent()->GetEMCALCells(), cluster);
395 if(fEMCALRecoUtils->IsRecalibrationOn())
397 fEMCALRecoUtils->RecalibrateClusterEnergy(fEMCALGeo, cluster, InputEvent()->GetEMCALCells());
398 fEMCALRecoUtils->RecalculateClusterShowerShapeParameters(fEMCALGeo, InputEvent()->GetEMCALCells(),cluster);
399 fEMCALRecoUtils->RecalculateClusterPID(cluster);
402 fEMCALRecoUtils->RecalculateClusterPosition(fEMCALGeo, InputEvent()->GetEMCALCells(),cluster);
406 printf("Filter, after : i %d, E %f, dispersion %f, m02 %f, m20 %f, distToBad %f\n",cluster->GetID(),cluster->E(),
407 cluster->GetDispersion(),cluster->GetM02(),cluster->GetM20(), cluster->GetDistanceToBadChannel());
408 cluster->GetPosition(position);
409 printf("Filter, after : i %d, x %f, y %f, z %f\n",cluster->GetID(), position[0], position[1], position[2]);
412 cluster->SetE(fEMCALRecoUtils->CorrectClusterEnergyLinearity(cluster));
416 //Recalculate track-matching
417 fEMCALRecoUtils->FindMatches(InputEvent(),0,fEMCALGeo);
419 } // corrections in EMCAL
422 //________________________________________________
423 void AliAnalysisTaskCaloFilter::FillAODCaloCells()
425 // Fill EMCAL/PHOS cell info
428 if ((fCaloFilter==kBoth || fCaloFilter==kEMCAL) && fEvent->GetEMCALCells())
429 { // protection against missing ESD information
430 AliVCaloCells &eventEMcells = *(fEvent->GetEMCALCells());
431 Int_t nEMcell = eventEMcells.GetNumberOfCells() ;
433 AliAODCaloCells &aodEMcells = *(AODEvent()->GetEMCALCells());
434 aodEMcells.CreateContainer(nEMcell);
435 aodEMcells.SetType(AliVCaloCells::kEMCALCell);
436 Double_t calibFactor = 1.;
437 for (Int_t iCell = 0; iCell < nEMcell; iCell++)
439 Int_t imod = -1, iphi =-1, ieta=-1,iTower = -1, iIphi = -1, iIeta = -1;
440 fEMCALGeo->GetCellIndex(eventEMcells.GetCellNumber(iCell),imod,iTower,iIphi,iIeta);
441 fEMCALGeo->GetCellPhiEtaIndexInSModule(imod,iTower,iIphi, iIeta,iphi,ieta);
443 if(fCorrect && fEMCALRecoUtils->IsRecalibrationOn())
445 calibFactor = fEMCALRecoUtils->GetEMCALChannelRecalibrationFactor(imod,ieta,iphi);
448 if(!fEMCALRecoUtils->GetEMCALChannelStatus(imod, ieta, iphi))
449 { //Channel is not declared as bad
450 aodEMcells.SetCell(iCell,eventEMcells.GetCellNumber(iCell),eventEMcells.GetAmplitude(iCell)*calibFactor,
451 eventEMcells.GetTime(iCell),eventEMcells.GetMCLabel(iCell),eventEMcells.GetEFraction(iCell));
452 //printf("GOOD channel\n");
456 aodEMcells.SetCell(iCell,eventEMcells.GetCellNumber(iCell),0,-1,-1,0);
457 //printf("BAD channel\n");
464 if ((fCaloFilter==kBoth || fCaloFilter==kPHOS) && fEvent->GetPHOSCells())
465 { // protection against missing ESD information
466 AliVCaloCells &eventPHcells = *(fEvent->GetPHOSCells());
467 Int_t nPHcell = eventPHcells.GetNumberOfCells() ;
469 AliAODCaloCells &aodPHcells = *(AODEvent()->GetPHOSCells());
470 aodPHcells.CreateContainer(nPHcell);
471 aodPHcells.SetType(AliVCaloCells::kPHOSCell);
473 for (Int_t iCell = 0; iCell < nPHcell; iCell++)
475 aodPHcells.SetCell(iCell,eventPHcells.GetCellNumber(iCell),eventPHcells.GetAmplitude(iCell),
476 eventPHcells.GetTime(iCell),eventPHcells.GetMCLabel(iCell),eventPHcells.GetEFraction(iCell));
484 //___________________________________________________
485 void AliAnalysisTaskCaloFilter::FillAODCaloClusters()
487 // Fill the AOD with caloclusters
489 // Access to the AOD container of clusters
491 TClonesArray &caloClusters = *(AODEvent()->GetCaloClusters());
495 Int_t nCaloClus = fEvent->GetNumberOfCaloClusters();
496 for (Int_t iClust=0; iClust<nCaloClus; ++iClust)
499 AliVCluster * cluster = fEvent->GetCaloCluster(iClust);
501 //Check which calorimeter information we want to keep.
503 if(fCaloFilter!=kBoth)
505 if (fCaloFilter==kPHOS && cluster->IsEMCAL()) continue ;
506 else if(fCaloFilter==kEMCAL && cluster->IsPHOS()) continue ;
509 // Get original residuals, in case of previous recalculation, reset them
510 Float_t dR = cluster->GetTrackDx();
511 Float_t dZ = cluster->GetTrackDz();
514 printf("Original residuals : dZ %f, dR %f\n ",dZ, dR);
516 //--------------------------------------------------------------
517 //If EMCAL and corrections done, get the new matching parameters, do not copy noisy clusters
518 if(cluster->IsEMCAL() && fCorrect)
521 printf("Check cluster %d for bad channels and close to border\n",cluster->GetID());
523 if(fEMCALRecoUtils->ClusterContainsBadChannel(fEMCALGeo,cluster->GetCellsAbsId(), cluster->GetNCells())) continue;
525 if(fEMCALRecoUtils->IsExoticCluster(cluster, InputEvent()->GetEMCALCells(),InputEvent()->GetBunchCrossNumber())) continue;
527 fEMCALRecoUtils->GetMatchedResiduals(cluster->GetID(),dR,dZ);
528 cluster->SetTrackDistance(dR,dZ);
533 if(cluster->IsEMCAL()) printf("EMCAL Track-Cluster Residuals : dZ %f, dR %f\n ",dZ, dR);
534 if(cluster->IsPHOS()) printf("PHOS Track-Cluster Residuals : dZ %f, dR %f\n ",dZ, dR);
537 //--------------------------------------------------------------
541 Int_t id = cluster->GetID();
542 Float_t energy = cluster->E();
543 cluster->GetPosition(posF);
545 AliAODCaloCluster *caloCluster = new(caloClusters[jClusters++])
546 AliAODCaloCluster(id,
547 cluster->GetNLabels(),
548 cluster->GetLabels(),
554 caloCluster->SetCaloCluster(cluster->GetDistanceToBadChannel(),
555 cluster->GetDispersion(),
556 cluster->GetM20(), cluster->GetM02(),
558 cluster->GetNExMax(),cluster->GetTOF()) ;
560 caloCluster->SetPIDFromESD(cluster->GetPID());
561 caloCluster->SetNCells(cluster->GetNCells());
562 caloCluster->SetCellsAbsId(cluster->GetCellsAbsId());
563 caloCluster->SetCellsAmplitudeFraction(cluster->GetCellsAmplitudeFraction());
564 caloCluster->SetTrackDistance(dR, dZ);
568 printf("Filter, aod : i %d, E %f, dispersion %f, m02 %f, m20 %f\n",caloCluster->GetID(),caloCluster->E(),
569 caloCluster->GetDispersion(),caloCluster->GetM02(),caloCluster->GetM20());
570 caloCluster->GetPosition(posF);
571 printf("Filter, aod : i %d, x %f, y %f, z %f\n",caloCluster->GetID(), posF[0], posF[1], posF[2]);
574 //Matched tracks, just to know if there was any match, the track pointer is useless if tracks not stored
575 if(TMath::Abs(dR) < 990 && TMath::Abs(dZ) < 990)
576 { //Default value in PHOS 999, in EMCAL 1024, why?
577 caloCluster->AddTrackMatched(new AliAODTrack);
579 // TO DO, in case Tracks available, think how to put the matched track in AOD
582 caloClusters.Expand(jClusters); // resize TObjArray to 'remove' slots
586 //__________________________________________________
587 void AliAnalysisTaskCaloFilter::FillAODCaloTrigger()
589 // AOD CaloTrigger copy
591 AliAODCaloTrigger* triggerEM = AODEvent()->GetCaloTrigger("EMCAL");
592 AliAODCaloTrigger* triggerPH = AODEvent()->GetCaloTrigger("PHOS");
597 if(fCaloFilter==kBoth || fCaloFilter==kPHOS) *triggerPH = *(fAODEvent->GetCaloTrigger("PHOS"));
599 if(fCaloFilter==kBoth || fCaloFilter==kEMCAL) *triggerEM = *(fAODEvent->GetCaloTrigger("EMCAL"));
606 //______________________________________________
607 void AliAnalysisTaskCaloFilter::FillAODHeader()
611 AliAODHeader* header = AODEvent()->GetHeader();
616 *header = *(fAODEvent->GetHeader());
620 if(!fESDEvent) return;
624 header->SetRunNumber(fEvent->GetRunNumber());
626 TTree* tree = fInputHandler->GetTree();
629 TFile* file = tree->GetCurrentFile();
630 if (file) header->SetESDFileName(file->GetName());
633 header->SetBunchCrossNumber(fEvent->GetBunchCrossNumber());
634 header->SetOrbitNumber(fEvent->GetOrbitNumber());
635 header->SetPeriodNumber(fEvent->GetPeriodNumber());
636 header->SetEventType(fEvent->GetEventType());
639 if(fEvent->GetCentrality())
641 header->SetCentrality(new AliCentrality(*(fEvent->GetCentrality())));
645 header->SetCentrality(0);
649 header->SetOfflineTrigger(fInputHandler->IsEventSelected()); // propagate the decision of the physics selection
650 header->SetFiredTriggerClasses(fESDEvent->GetFiredTriggerClasses());
651 header->SetTriggerMask(fEvent->GetTriggerMask());
652 header->SetTriggerCluster(fEvent->GetTriggerCluster());
653 header->SetL0TriggerInputs(fESDEvent->GetHeader()->GetL0TriggerInputs());
654 header->SetL1TriggerInputs(fESDEvent->GetHeader()->GetL1TriggerInputs());
655 header->SetL2TriggerInputs(fESDEvent->GetHeader()->GetL2TriggerInputs());
657 header->SetMagneticField(fEvent->GetMagneticField());
658 //header->SetMuonMagFieldScale(fESDEvent->GetCurrentDip()/6000.);
660 header->SetZDCN1Energy(fEvent->GetZDCN1Energy());
661 header->SetZDCP1Energy(fEvent->GetZDCP1Energy());
662 header->SetZDCN2Energy(fEvent->GetZDCN2Energy());
663 header->SetZDCP2Energy(fEvent->GetZDCP2Energy());
664 header->SetZDCEMEnergy(fEvent->GetZDCEMEnergy(0),fEvent->GetZDCEMEnergy(1));
666 Float_t diamxy[2]={fEvent->GetDiamondX(),fEvent->GetDiamondY()};
668 fEvent->GetDiamondCovXY(diamcov);
669 header->SetDiamond(diamxy,diamcov);
670 header->SetDiamondZ(fESDEvent->GetDiamondZ(),fESDEvent->GetSigma2DiamondZ());
674 //_____________________________________________
675 void AliAnalysisTaskCaloFilter::FillAODTracks()
679 if(!fFillTracks) return;
681 AliAODTrack* aodTrack(0x0);
683 Double_t pos[3] = { 0. };
684 Double_t covTr[21]= { 0. };
685 Double_t pid[10] = { 0. };
686 Double_t p[3] = { 0. };
691 //TClonesArray* inTracks = fAODEvent ->GetTracks();
692 TClonesArray* ouTracks = AODEvent()->GetTracks();
693 //new (ouTracks) TClonesArray(*inTracks);
695 //printf("N tracks %d\n",fAODEvent->GetNumberOfTracks());
696 Int_t nCopyTrack = 0;
697 for (Int_t nTrack = 0; nTrack < fAODEvent->GetNumberOfTracks(); ++nTrack)
699 AliAODTrack *track = fAODEvent->GetTrack(nTrack);
701 // Select only hybrid tracks?
702 if(fFillHybridTracks && !track->IsHybridGlobalConstrainedGlobal()) continue;
704 // Remove PID object to save space
705 //track->SetDetPID(0x0);
707 //new((*ouTracks)[nCopyTrack++]) AliAODTrack(*track);
710 Bool_t isDCA = track->GetPosition(pos);
711 track->GetCovMatrix(covTr);
714 AliAODVertex* primVertex = (AliAODVertex*) AODEvent()->GetVertices()->At(0); // primary vertex, copied previously!!!
716 aodTrack = new((*ouTracks)[nCopyTrack++]) AliAODTrack(
725 track->GetITSClusterMap(),
728 track->GetUsedForVtxFit(),
729 track->GetUsedForPrimVtxFit(),
730 (AliAODTrack::AODTrk_t) track->GetType(),
731 track->GetFilterMap(),
732 track->Chi2perNDF());
735 aodTrack->SetIsHybridGlobalConstrainedGlobal(track->IsHybridGlobalConstrainedGlobal());
736 aodTrack->SetIsHybridTPCConstrainedGlobal (track->IsHybridTPCConstrainedGlobal());
737 aodTrack->SetIsGlobalConstrained (track->IsGlobalConstrained());
738 aodTrack->SetIsTPCConstrained (track->IsTPCConstrained());
740 aodTrack->SetTPCFitMap (track->GetTPCFitMap());
741 aodTrack->SetTPCClusterMap(track->GetTPCClusterMap());
742 aodTrack->SetTPCSharedMap (track->GetTPCSharedMap());
744 aodTrack->SetChi2MatchTrigger(track->GetChi2MatchTrigger());
746 // set the DCA values to the AOD track
748 aodTrack->SetPxPyPzAtDCA(track->PxAtDCA(),track->PyAtDCA(),track->PzAtDCA());
749 aodTrack->SetXYAtDCA (track->XAtDCA() ,track->YAtDCA());
751 aodTrack->SetFlags (track->GetFlags());
752 aodTrack->SetTPCPointsF (track->GetTPCNclsF());
756 if(track->IsEMCAL()) aodTrack->SetEMCALcluster(track->GetEMCALcluster());
757 if(track->IsPHOS()) aodTrack->SetPHOScluster (track->GetPHOScluster());
758 aodTrack->SetTrackPhiEtaOnEMCal( track->GetTrackPhiOnEMCal(), track->GetTrackPhiOnEMCal() );
762 //printf("Final N tracks %d\n",nCopyTrack);
769 //_________________________________________
770 void AliAnalysisTaskCaloFilter::FillAODv0s()
772 // Copy v0s (use if you know what you do, use quite a lot of memory)
774 if(!fFillv0s) return;
779 TClonesArray* inv0 = fAODEvent ->GetV0s();
780 TClonesArray* ouv0 = AODEvent()->GetV0s();
782 //new (ouv0s) TClonesArray(*inv0s);
784 Int_t allv0s = inv0->GetEntriesFast();
786 for (Int_t nv0s = 0; nv0s < allv0s; ++nv0s)
788 AliAODv0 *v0 = (AliAODv0*)inv0->At(nv0s);
790 new((*ouv0)[nv0s]) AliAODv0(*v0);
798 //____________________________________________
799 void AliAnalysisTaskCaloFilter::FillAODVZERO()
803 if(!fFillVZERO) return;
805 AliAODVZERO* vzeroData = AODEvent()->GetVZEROData();
807 if(fESDEvent) *vzeroData = *(fESDEvent->GetVZEROData());
808 else *vzeroData = *(fAODEvent->GetVZEROData());
812 //_______________________________________________
813 void AliAnalysisTaskCaloFilter::FillAODVertices()
817 // set arrays and pointers
820 for (Int_t i = 0; i < 6; i++) covVtx[i] = 0.;
825 TClonesArray* inVertices = fAODEvent ->GetVertices();
826 TClonesArray* ouVertices = AODEvent()->GetVertices();
828 //new (ouVertices) TClonesArray(*inVertices);
830 //Keep only the first 3 vertices if not requested
831 Int_t allVertices = inVertices->GetEntriesFast();
833 //printf("n Vertices %d\n",allVertices);
835 if(!fFillAllVertices)
837 if(allVertices > 3) allVertices = 3;
840 //printf("Final n Vertices %d\n",allVertices);
842 for (Int_t nVertices = 0; nVertices < allVertices; ++nVertices)
844 AliAODVertex *vertex = (AliAODVertex*)inVertices->At(nVertices);
846 new((*ouVertices)[nVertices]) AliAODVertex(*vertex);
852 if(!fESDEvent) return;
856 // Access to the AOD container of vertices
858 TClonesArray &vertices = *(AODEvent()->GetVertices());
860 // Add primary vertex. The primary tracks will be defined
861 // after the loops on the composite objects (v0, cascades, kinks)
862 fEvent ->GetPrimaryVertex()->GetXYZ(pos);
863 fESDEvent->GetPrimaryVertex()->GetCovMatrix(covVtx);
864 Float_t chi = fESDEvent->GetPrimaryVertex()->GetChi2toNDF();
866 AliAODVertex * primary = new(vertices[jVertices++])
867 AliAODVertex(pos, covVtx, chi, NULL, -1, AliAODVertex::kPrimary);
868 primary->SetName(fEvent->GetPrimaryVertex()->GetName());
869 primary->SetTitle(fEvent->GetPrimaryVertex()->GetTitle());
873 //____________________________________
874 void AliAnalysisTaskCaloFilter::Init()
876 //Init analysis with configuration macro if available
878 if(gROOT->LoadMacro(fConfigName) >=0)
880 printf("Configure analysis with %s\n",fConfigName.Data());
882 AliAnalysisTaskCaloFilter *filter = (AliAnalysisTaskCaloFilter*)gInterpreter->ProcessLine("ConfigCaloFilter()");
884 fEMCALGeoName = filter->fEMCALGeoName;
885 fLoadEMCALMatrices = filter->fLoadEMCALMatrices;
886 fFillAODFile = filter->fFillAODFile;
887 fFillTracks = filter->fFillTracks;
888 fFillHybridTracks = filter->fFillHybridTracks;
889 fFillv0s = filter->fFillv0s;
890 fFillVZERO = filter->fFillVZERO;
891 fFillAllVertices = filter->fFillAllVertices;
892 fEMCALRecoUtils = filter->fEMCALRecoUtils;
893 fConfigName = filter->fConfigName;
894 fCaloFilter = filter->fCaloFilter;
895 fEventSelection[0] = filter->fEventSelection[0];
896 fEventSelection[1] = filter->fEventSelection[1];
897 fEventSelection[2] = filter->fEventSelection[2];
898 fAcceptAllMBEvent = filter->fAcceptAllMBEvent;
899 fCorrect = filter->fCorrect;
900 fEMCALEnergyCut = filter->fEMCALEnergyCut;
901 fEMCALNcellsCut = filter->fEMCALNcellsCut;
902 fPHOSEnergyCut = filter->fPHOSEnergyCut;
903 fPHOSNcellsCut = filter->fPHOSNcellsCut;
904 fTrackPtCut = filter->fTrackPtCut;
905 fVzCut = filter->fVzCut;
907 for(Int_t i = 0; i < 12; i++) fEMCALMatrix[i] = filter->fEMCALMatrix[i] ;
911 //_________________________________________
912 void AliAnalysisTaskCaloFilter::PrintInfo()
916 printf("AnalysisCaloFilter::PrintInfo() \n");
918 printf("\t Not only filter, correct Clusters? %d\n",fCorrect);
919 printf("\t Calorimeter Filtering Option ? %d\n",fCaloFilter);
921 //printf("\t Use handmade geo matrices? EMCAL %d, PHOS %d\n",fLoadEMCALMatrices, fLoadPHOSMatrices);
922 printf("\t Use handmade geo matrices? EMCAL %d, PHOS 0\n",fLoadEMCALMatrices);
924 printf("\t Fill: AOD file? %d Tracks? %d; all Vertex? %d; v0s? %d; VZERO ? %d\n",
925 fFillAODFile,fFillTracks,fFillAllVertices, fFillv0s, fFillVZERO);
927 printf("\t Event Selection based : EMCAL? %d, PHOS? %d Tracks? %d - Accept all MB? %d\n",
928 fEventSelection[0],fEventSelection[1],fEventSelection[2],fAcceptAllMBEvent);
930 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",
931 fEMCALEnergyCut,fEMCALNcellsCut,fPHOSEnergyCut,fPHOSNcellsCut, fTrackPtCut,fVzCut);
934 //_______________________________________________________
935 void AliAnalysisTaskCaloFilter::UserCreateOutputObjects()
939 fEMCALGeo = AliEMCALGeometry::GetInstance(fEMCALGeoName) ;
943 //____________________________________________________________
944 void AliAnalysisTaskCaloFilter::UserExec(Option_t */*option*/)
946 // Execute analysis for current event
947 // Copy input ESD or AOD header, vertex, CaloClusters and CaloCells to output AOD
950 printf("CaloFilter: Analysing event # %d\n", (Int_t)Entry());
952 fEvent = InputEvent();
953 fAODEvent = dynamic_cast<AliAODEvent*> (fEvent);
954 fESDEvent = dynamic_cast<AliESDEvent*> (fEvent);
958 printf("AliAnalysisTaskCaloFilter::UserExec - This event does not contain Input?");
962 // printf("Start processing : %s\n",fAODEvent->GetFiredTriggerClasses().Data());
966 if(!AcceptEvent()) return ;
968 //Magic line to write events to file
970 AliAnalysisManager::GetAnalysisManager()->GetOutputEventHandler()->SetFillAOD(fFillAODFile);
975 if(fFillv0s) nVertices = fEvent->GetNumberOfV0s();
976 Int_t nCaloClus = fEvent->GetNumberOfCaloClusters();
977 Int_t nTracks = fEvent->GetNumberOfTracks();
979 AODEvent()->ResetStd(nTracks, nVertices, 0, 0, 0, nCaloClus, 0, 0);
989 FillAODVertices(); // Do it before the track filtering to have the reference to the vertex
998 CorrectionsInEMCAL();
1001 FillAODCaloClusters();
1007 FillAODCaloTrigger();
1009 //printf("Filtered event, end processing : %s\n",fAODEvent->GetFiredTriggerClasses().Data());