17 #include "TGeoManager.h" 20 #include "TInterpreter.h" 23 #include "AliESDEvent.h" 24 #include "AliAODEvent.h" 26 #include "AliVCluster.h" 27 #include "AliVCaloCells.h" 28 #include "AliVEventHandler.h" 29 #include "AliAODHandler.h" 30 #include "AliAnalysisManager.h" 31 #include "AliInputEventHandler.h" 34 #include "AliEMCALRecoUtils.h" 35 #include "AliEMCALGeometry.h" 48 fCaloFilter(0), fEventSelection(),
49 fAcceptAllMBEvent(kFALSE),fMBTriggerMask(AliVEvent::kMB),
51 fEMCALGeo(0x0), fEMCALGeoName(
"EMCAL_COMPLETE12SMV1_DCAL_8SM"),
52 fEMCALRecoUtils(new AliEMCALRecoUtils),
53 fLoadEMCALMatrices(kFALSE),
54 fGeoMatrixSet(kFALSE),
55 fConfigName(
""), fFillAODFile(kTRUE),
56 fFillMCParticles(kFALSE),
57 fFillTracks(kFALSE), fFillHybridTracks(kFALSE),
58 fFillAllVertices(kFALSE), fFillv0s(kFALSE),
60 fEMCALEnergyCut(0.), fEMCALNcellsCut (0),
61 fPHOSEnergyCut(0.), fPHOSNcellsCut (0),
63 fVzCut(100.), fCheckEventVertex(kTRUE),
65 fESDEvent(0x0), fAODEvent(0x0)
132 Bool_t isMB = (((AliInputEventHandler*)(AliAnalysisManager::GetAnalysisManager()->GetInputEventHandler()))->IsEventSelected() &
fMBTriggerMask);
157 Int_t nCluster = InputEvent() -> GetNumberOfCaloClusters();
158 AliVCaloCells * caloCell = InputEvent() -> GetEMCALCells();
159 Int_t bc = InputEvent() -> GetBunchCrossNumber();
161 for(
Int_t icalo = 0; icalo < nCluster; icalo++)
163 AliVCluster *clus = (AliVCluster*) (InputEvent()->GetCaloCluster(icalo));
169 AliDebug(1,Form(
"Accept : E %2.2f > %2.2f, nCells %d > %d",
176 AliDebug(1,
"Reject");
194 Int_t nCluster = InputEvent() -> GetNumberOfCaloClusters();
196 for(
Int_t icalo = 0; icalo < nCluster; icalo++)
198 AliVCluster *clus = (AliVCluster*) (InputEvent()->GetCaloCluster(icalo));
203 AliDebug(1,Form(
"Accept : E %2.2f > %2.2f, nCells %d > %d",
210 AliDebug(1,
"Reject");
228 for (
Int_t nTrack = 0; nTrack <
fEvent->GetNumberOfTracks(); ++nTrack)
230 AliVTrack *track = (AliVTrack*)
fEvent->GetTrack(nTrack);
242 AliDebug(1,Form(
"Accept : pT %2.2f > %2.2f",track->Pt(),
fTrackPtCut));
248 AliDebug(1,
"Reject");
259 InputEvent()->GetPrimaryVertex()->GetXYZ(v) ;
261 if(TMath::Abs(v[2]) >
fVzCut)
263 AliDebug(1,Form(
"Vz Reject : vz %2.2f > %2.2f",v[2],
fVzCut));
303 if(
fESDEvent->GetPrimaryVertexTracks()->GetNContributors() > 0)
306 if(
fESDEvent->GetPrimaryVertexTracks()->GetNContributors() < 1)
309 if(
fESDEvent->GetPrimaryVertexSPD()->GetNContributors() > 0)
314 if(
fESDEvent->GetPrimaryVertexSPD()->GetNContributors() < 1)
317 AliDebug(1,
"Reject, GetPrimaryVertexSPD()->GetNContributors() < 1");
323 AliDebug(1,
"Reject, GetPrimaryVertexTracks()->GetNContributors() > 1");
334 if (
fAODEvent->GetPrimaryVertex() != NULL)
336 if(
fAODEvent->GetPrimaryVertex()->GetNContributors() > 0)
return kTRUE;
339 if(
fAODEvent->GetPrimaryVertexSPD() != NULL)
341 if(
fAODEvent->GetPrimaryVertexSPD()->GetNContributors() > 0)
347 AliWarning(Form(
"Number of contributors from bad vertex type:: %s",
348 fAODEvent->GetPrimaryVertex()->GetName()));
353 AliDebug(1,
"Reject, GetPrimaryVertexTracks()->GetNContributors() > 1");
371 AliInfo(
"Load user defined EMCAL geometry matrices");
372 for(
Int_t mod=0; mod < (
fEMCALGeo->GetEMCGeometry())->GetNumberOfSuperModules(); mod++)
383 else if(!gGeoManager)
385 AliInfo(
"Get geo matrices from data");
387 if(!strcmp(InputEvent()->GetName(),
"AliAODEvent"))
389 AliDebug(1,
"Use ideal geometry, values geometry matrix not kept in AODs");
393 AliDebug(1,
"Load Misaligned matrices");
397 AliInfo(
"This event does not contain ESDs?");
400 for(
Int_t mod=0; mod < (
fEMCALGeo->GetEMCGeometry())->GetNumberOfSuperModules(); mod++)
403 esd->GetEMCALMatrix(mod)->Print();
404 if(esd->GetEMCALMatrix(mod))
fEMCALGeo->SetMisalMatrix(esd->GetEMCALMatrix(mod),mod) ;
413 Int_t nCaloClus = InputEvent()->GetNumberOfCaloClusters();
415 for (
Int_t iClust=0; iClust<nCaloClus; ++iClust)
417 AliVCluster * cluster = InputEvent()->GetCaloCluster(iClust);
419 if(cluster->IsPHOS())
continue ;
423 AliDebug(1,Form(
"Check cluster %d for bad channels and close to border",cluster->GetID()));
427 AliDebug(2,Form(
"Filter, before : i %d, E %f, dispersion %f, m02 %f, m20 %f, distToBad %f",iClust,cluster->E(),
428 cluster->GetDispersion(),cluster->GetM02(),cluster->GetM20(), cluster->GetDistanceToBadChannel()));
429 cluster->GetPosition(position);
430 AliDebug(2,Form(
"Filter, before : i %d, x %f, y %f, z %f",cluster->GetID(), position[0], position[1], position[2]));
444 AliDebug(2,Form(
"Filter, after : i %d, E %f, dispersion %f, m02 %f, m20 %f, distToBad %f",cluster->GetID(),cluster->E(),
445 cluster->GetDispersion(),cluster->GetM02(),cluster->GetM20(), cluster->GetDistanceToBadChannel()));
446 cluster->GetPosition(position);
447 AliDebug(1,Form(
"Filter, after : i %d, x %f, y %f, z %f",cluster->GetID(), position[0], position[1], position[2]));
449 cluster->SetE(
fEMCALRecoUtils->CorrectClusterEnergyLinearity(cluster));
467 AliVCaloCells &eventEMcells = *(
fEvent->GetEMCALCells());
468 Int_t nEMcell = eventEMcells.GetNumberOfCells() ;
470 AliAODCaloCells &aodEMcells = *(AODEvent()->GetEMCALCells());
471 aodEMcells.CreateContainer(nEMcell);
472 aodEMcells.SetType(AliVCaloCells::kEMCALCell);
474 for (
Int_t iCell = 0; iCell < nEMcell; iCell++)
476 Int_t imod = -1, iphi =-1, ieta=-1,iTower = -1, iIphi = -1, iIeta = -1;
477 fEMCALGeo->GetCellIndex(eventEMcells.GetCellNumber(iCell),imod,iTower,iIphi,iIeta);
478 fEMCALGeo->GetCellPhiEtaIndexInSModule(imod,iTower,iIphi, iIeta,iphi,ieta);
482 calibFactor =
fEMCALRecoUtils->GetEMCALChannelRecalibrationFactor(imod,ieta,iphi);
487 aodEMcells.SetCell(iCell,
488 eventEMcells.GetCellNumber(iCell),
489 eventEMcells.GetAmplitude(iCell)*calibFactor,
490 eventEMcells.GetTime(iCell),
491 eventEMcells.GetMCLabel(iCell),
492 eventEMcells.GetEFraction(iCell),
493 eventEMcells.GetHighGain(iCell));
498 aodEMcells.SetCell(iCell,eventEMcells.GetCellNumber(iCell),0,-1,-1,0);
508 AliVCaloCells &eventPHcells = *(
fEvent->GetPHOSCells());
509 Int_t nPHcell = eventPHcells.GetNumberOfCells() ;
511 AliAODCaloCells &aodPHcells = *(AODEvent()->GetPHOSCells());
512 aodPHcells.CreateContainer(nPHcell);
513 aodPHcells.SetType(AliVCaloCells::kPHOSCell);
515 for (
Int_t iCell = 0; iCell < nPHcell; iCell++)
517 aodPHcells.SetCell(iCell,
518 eventPHcells.GetCellNumber(iCell),
519 eventPHcells.GetAmplitude(iCell),
520 eventPHcells.GetTime(iCell),
521 eventPHcells.GetMCLabel(iCell),
522 eventPHcells.GetEFraction(iCell),
523 eventPHcells.GetHighGain(iCell));
536 TClonesArray &caloClusters = *(AODEvent()->GetCaloClusters());
540 Int_t nCaloClus =
fEvent->GetNumberOfCaloClusters();
541 for (
Int_t iClust=0; iClust<nCaloClus; ++iClust)
543 AliVCluster * cluster =
fEvent->GetCaloCluster(iClust);
554 Float_t dR = cluster->GetTrackDx();
555 Float_t dZ = cluster->GetTrackDz();
557 AliDebug(2,Form(
"Original residuals : dZ %f, dR %f",dZ, dR));
563 AliDebug(2,Form(
"Check cluster %d for bad channels and close to border",cluster->GetID()));
567 if(
fEMCALRecoUtils->IsExoticCluster(cluster, InputEvent()->GetEMCALCells(),InputEvent()->GetBunchCrossNumber()))
continue;
570 cluster->SetTrackDistance(dR,dZ);
573 AliDebug(2,Form(
"EMCAL? %d, PHOS? %d Track-Cluster Residuals : dZ %f, dR %f",cluster->IsEMCAL(), cluster->IsPHOS(),dZ, dR));
579 Int_t id = cluster->GetID();
581 cluster->GetPosition(posF);
583 AliAODCaloCluster *caloCluster =
new(caloClusters[jClusters++])
584 AliAODCaloCluster(
id,
585 cluster->GetNLabels(),
586 cluster->GetLabels(),
592 caloCluster->SetCaloCluster(cluster->GetDistanceToBadChannel(),
593 cluster->GetDispersion(),
594 cluster->GetM20(), cluster->GetM02(),
596 cluster->GetNExMax(),cluster->GetTOF()) ;
598 caloCluster->SetPIDFromESD(cluster->GetPID());
599 caloCluster->SetNCells(cluster->GetNCells());
600 caloCluster->SetCellsAbsId(cluster->GetCellsAbsId());
601 caloCluster->SetCellsAmplitudeFraction(cluster->GetCellsAmplitudeFraction());
602 caloCluster->SetTrackDistance(dR, dZ);
604 caloCluster->SetCellsMCEdepFractionMap(cluster->GetCellsMCEdepFractionMap());
605 caloCluster->SetClusterMCEdepFraction (cluster->GetClusterMCEdepFraction ());
607 AliDebug(2,Form(
"Filter, aod : i %d, E %f, dispersion %f, m02 %f, m20 %f",caloCluster->GetID(),caloCluster->E(),
608 caloCluster->GetDispersion(),caloCluster->GetM02(),caloCluster->GetM20()));
609 caloCluster->GetPosition(posF);
610 AliDebug(2,Form(
"Filter, aod : i %d, x %f, y %f, z %f",caloCluster->GetID(), posF[0], posF[1], posF[2]));
613 if(TMath::Abs(dR) < 990 && TMath::Abs(dZ) < 990)
615 caloCluster->AddTrackMatched(
new AliAODTrack);
620 caloClusters.Expand(jClusters);
630 AliAODCaloTrigger* triggerEM = AODEvent()->GetCaloTrigger(
"EMCAL");
631 AliAODCaloTrigger* triggerPH = AODEvent()->GetCaloTrigger(
"PHOS");
635 AliAODCaloTrigger* inTriggerEM =
fAODEvent ->GetCaloTrigger(
"EMCAL");
636 AliAODCaloTrigger* inTriggerPH =
fAODEvent ->GetCaloTrigger(
"PHOS");
648 AliAODHeader* header =
dynamic_cast<AliAODHeader*
>(AODEvent()->GetHeader());
651 AliFatal(
"Not a standard AOD");
658 *header = *((AliAODHeader*)
fAODEvent->GetHeader());
666 header->SetRunNumber(
fEvent->GetRunNumber());
668 TTree* tree = fInputHandler->GetTree();
671 TFile*
file = tree->GetCurrentFile();
672 if (file) header->SetESDFileName(file->GetName());
675 header->SetBunchCrossNumber(
fEvent->GetBunchCrossNumber());
676 header->SetOrbitNumber(
fEvent->GetOrbitNumber());
677 header->SetPeriodNumber(
fEvent->GetPeriodNumber());
678 header->SetEventType(
fEvent->GetEventType());
681 if(
fEvent->GetCentrality())
683 header->SetCentrality(
new AliCentrality(*(
fEvent->GetCentrality())));
687 header->SetCentrality(0);
691 header->SetOfflineTrigger(fInputHandler->IsEventSelected());
692 header->SetFiredTriggerClasses(
fESDEvent->GetFiredTriggerClasses());
693 header->SetTriggerMask(
fEvent->GetTriggerMask());
694 header->SetTriggerCluster(
fEvent->GetTriggerCluster());
695 header->SetL0TriggerInputs(
fESDEvent->GetHeader()->GetL0TriggerInputs());
696 header->SetL1TriggerInputs(
fESDEvent->GetHeader()->GetL1TriggerInputs());
697 header->SetL2TriggerInputs(
fESDEvent->GetHeader()->GetL2TriggerInputs());
699 header->SetMagneticField(
fEvent->GetMagneticField());
700 header->SetMuonMagFieldScale(
fESDEvent->GetCurrentDip()/6000.);
702 header->SetZDCN1Energy(
fEvent->GetZDCN1Energy());
703 header->SetZDCP1Energy(
fEvent->GetZDCP1Energy());
704 header->SetZDCN2Energy(
fEvent->GetZDCN2Energy());
705 header->SetZDCP2Energy(
fEvent->GetZDCP2Energy());
706 header->SetZDCEMEnergy(
fEvent->GetZDCEMEnergy(0),
fEvent->GetZDCEMEnergy(1));
710 fEvent->GetDiamondCovXY(diamcov);
711 header->SetDiamond(diamxy,diamcov);
722 TClonesArray* inMCParticles = (TClonesArray*) (
fAODEvent ->FindListObject(
"mcparticles"));
723 TClonesArray* ouMCParticles = (TClonesArray*) ( AODEvent()->FindListObject(
"mcparticles"));
725 if( inMCParticles && ouMCParticles )
new (ouMCParticles) TClonesArray(*inMCParticles);
735 AliAODTrack* aodTrack(0x0);
746 TClonesArray* ouTracks = AODEvent()->GetTracks();
750 Int_t nCopyTrack = 0;
751 for (
Int_t nTrack = 0; nTrack <
fAODEvent->GetNumberOfTracks(); ++nTrack)
753 AliAODTrack *track =
dynamic_cast<AliAODTrack*
>(
fAODEvent->GetTrack(nTrack));
754 if(!track) AliFatal(
"Not a standard AOD");
765 Bool_t isDCA = track->GetPosition(pos);
766 track->GetCovMatrix(covTr);
769 AliAODVertex* primVertex = (AliAODVertex*) AODEvent()->GetVertices()->At(0);
771 aodTrack =
new((*ouTracks)[nCopyTrack++]) AliAODTrack(
780 track->GetITSClusterMap(),
783 track->GetUsedForVtxFit(),
784 track->GetUsedForPrimVtxFit(),
785 (AliAODTrack::AODTrk_t) track->GetType(),
786 track->GetFilterMap());
789 aodTrack->SetPIDForTracking(track->GetPIDForTracking());
790 aodTrack->SetIsHybridGlobalConstrainedGlobal(track->IsHybridGlobalConstrainedGlobal());
791 aodTrack->SetIsHybridTPCConstrainedGlobal (track->IsHybridTPCConstrainedGlobal());
792 aodTrack->SetIsGlobalConstrained (track->IsGlobalConstrained());
793 aodTrack->SetIsTPCConstrained (track->IsTPCConstrained());
795 aodTrack->SetTPCFitMap (track->GetTPCFitMap());
796 aodTrack->SetTPCClusterMap(track->GetTPCClusterMap());
797 aodTrack->SetTPCSharedMap (track->GetTPCSharedMap());
799 aodTrack->SetChi2MatchTrigger(track->GetChi2MatchTrigger());
803 aodTrack->SetPxPyPzAtDCA(track->PxAtDCA(),track->PyAtDCA(),track->PzAtDCA());
804 aodTrack->SetXYAtDCA (track->XAtDCA() ,track->YAtDCA());
806 aodTrack->SetFlags (track->GetFlags());
807 aodTrack->SetTPCPointsF (track->GetTPCNclsF());
811 if(track->IsEMCAL()) aodTrack->SetEMCALcluster(track->GetEMCALcluster());
812 if(track->IsPHOS()) aodTrack->SetPHOScluster (track->GetPHOScluster());
813 aodTrack->SetTrackPhiEtaPtOnEMCal( track->GetTrackPhiOnEMCal(), track->GetTrackPhiOnEMCal(), track->GetTrackPtOnEMCal() );
834 TClonesArray* inv0 =
fAODEvent ->GetV0s();
835 TClonesArray* ouv0 = AODEvent()->GetV0s();
839 Int_t allv0s = inv0->GetEntriesFast();
841 for (
Int_t nv0s = 0; nv0s < allv0s; ++nv0s)
843 AliAODv0 *v0 = (AliAODv0*)inv0->At(nv0s);
845 new((*ouv0)[nv0s]) AliAODv0(*v0);
859 AliAODVZERO* vzeroData = AODEvent()->GetVZEROData();
862 else *vzeroData = *(
fAODEvent->GetVZEROData());
873 for (
Int_t i = 0; i < 6; i++) covVtx[i] = 0.;
878 TClonesArray* inVertices =
fAODEvent ->GetVertices();
879 TClonesArray* ouVertices = AODEvent()->GetVertices();
884 Int_t allVertices = inVertices->GetEntriesFast();
890 if(allVertices > 3) allVertices = 3;
895 for (
Int_t nVertices = 0; nVertices < allVertices; ++nVertices)
897 AliAODVertex *vertex = (AliAODVertex*)inVertices->At(nVertices);
899 new((*ouVertices)[nVertices]) AliAODVertex(*vertex);
911 TClonesArray &vertices = *(AODEvent()->GetVertices());
915 fEvent ->GetPrimaryVertex()->GetXYZ(pos);
916 fESDEvent->GetPrimaryVertex()->GetCovMatrix(covVtx);
919 AliAODVertex * primary =
new(vertices[jVertices++])
921 primary->SetName(
fEvent->GetPrimaryVertex()->GetName());
922 primary->SetTitle(
fEvent->GetPrimaryVertex()->GetTitle());
935 AliInfo(Form(
"Configure analysis with %s",
fConfigName.Data()));
973 printf(
"AnalysisCaloFilter::PrintInfo() \n");
975 printf(
"\t Not only filter, correct Clusters? %d\n",
fCorrect);
976 printf(
"\t Calorimeter Filtering Option ? %d\n",
fCaloFilter);
981 printf(
"\t Fill: AOD file? %d Tracks? %d; all Vertex? %d; v0s? %d; VZERO ? %d\n",
984 printf(
"\t Event Selection based : EMCAL? %d, PHOS? %d Tracks? %d - Accept all MB with mask %d? %d\n",
987 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",
1000 TClonesArray * aodMCParticles =
new TClonesArray(
"AliAODMCParticle",500);
1001 aodMCParticles->SetName(
"mcparticles");
1002 ((AliAODHandler*)AliAnalysisManager::GetAnalysisManager()->GetOutputEventHandler())->AddBranch(
"TClonesArray", &aodMCParticles);
1013 AliDebug(1,Form(
"Analysing event # %d", (
Int_t)Entry()));
1021 AliInfo(
"This event does not contain Input?");
1033 AliAnalysisManager::GetAnalysisManager()->GetOutputEventHandler()->SetFillAOD(
fFillAODFile);
1037 Int_t nVertices = 0;
1039 Int_t nCaloClus =
fEvent->GetNumberOfCaloClusters();
1042 AODEvent()->ResetStd(nTracks, nVertices, 0, 0, 0, nCaloClus, 0, 0);
void FillAODTracks()
Copy AOD track.
void FillAODCaloClusters()
void Print(std::ostream &o, const char *name, Double_t dT, Double_t dVM, Double_t alldT, Double_t alldVM)
Bool_t CheckForPrimaryVertex()
AliEMCALGeometry * fEMCALGeo
! EMCAL geometry.
Bool_t fEventSelection[3]
Define which detector is used to select the event: {EMCAL,PHOS,Tracks}.
Int_t fPHOSNcellsCut
At least a PHOS cluster with fNCellsCut cells over fEnergyCut.
void FillAODVZERO()
Copy VZERO.
Float_t fTrackPtCut
Select events with at least a track with this pT.
Bool_t fFillVZERO
Fill the output AOD file with VZERO input.
virtual void UserExec(Option_t *option)
void PrintInfo()
Print settings.
Bool_t fFillTracks
Fill the output AOD file with tracks.
Bool_t CheckForPrimaryVertexInESDs()
void FillAODVertices()
Copy vertices.
Bool_t fCheckEventVertex
Check the primary vertex of the event or not.
Bool_t fAcceptAllMBEvent
Do not select the MB events with same Event selection cuts as other triggers.
Int_t fCorrect
Recalibrate or recalculate different cluster parameters, only for EMCal.
AliAnalysisTaskCaloFilter()
Default constructor.
Bool_t fFillHybridTracks
Fill the output AOD file with hybrid tracks, only when fFillTracks = kTRUE.
void FillAODCaloTrigger()
AliAODCaloTrigger direct copy.
Int_t fCaloFilter
Calorimeter to filter: kBoth, kEMCAL, kPHOS.
virtual void UserCreateOutputObjects()
Init EMCal geometry and create the AOD MC particles branch.
AliAODEvent * fAODEvent
! AOD event pointer (cast of fEvent).
TString fEMCALGeoName
Name of geometry to use.
TString fConfigName
Name of analysis configuration file.
Bool_t AcceptEventVertex()
Filter Calorimeter ESDs into AODs.
Bool_t fLoadEMCALMatrices
Matrices set from configuration, not get from geometry.root or from ESDs/AODs.
AliEMCALRecoUtils * fEMCALRecoUtils
Pointer to EMCAL utilities for clusterization.
Int_t fEMCALNcellsCut
At least an EMCAL cluster with fNCellsCut cells over fEnergyCut.
Float_t fEMCALEnergyCut
At least an EMCAL cluster with this energy in the event.
void FillAODHeader()
AOD Header copy.
AliESDEvent * fESDEvent
! ESD event pointer (cast of fEvent).
AliVEvent * fEvent
! Event pointer.
void FillAODMCParticles()
Copy AOD MC particles.
Bool_t AcceptEventTrack()
Bool_t fFillv0s
Fill the output AOD file with v0s.
Float_t fVzCut
At least events with vertex within cut.
Bool_t fFillMCParticles
Fill the output AOD file with MC particles.
TFile * file
TList with histograms for a given trigger.
UInt_t fMBTriggerMask
Define the mask for MB events, it should be kMB, but not always defined, use kAnyINT instead...
void CorrectionsInEMCAL()
Bool_t AcceptEventEMCAL()
Float_t fPHOSEnergyCut
At least a PHOS cluster with this energy in the event.
virtual ~AliAnalysisTaskCaloFilter()
Destructor.
Bool_t fFillAODFile
Fill the output AOD file with clusters.
TGeoHMatrix * fEMCALMatrix[22]
Geometry matrices with alignments.
Bool_t fFillAllVertices
Fill the output AOD file with all vertices.
void FillAODCaloCells()
Fill EMCAL/PHOS cell info.
Bool_t fGeoMatrixSet
Set geometry matrices only once, for the first event.
Bool_t CheckForPrimaryVertexInAODs()