8 #include <TClonesArray.h>
9 #include "AliAODCaloCluster.h"
10 #include "AliAODEvent.h"
11 #include "AliAnalysisManager.h"
12 #include "AliEMCALRecoUtils.h"
13 #include "AliESDCaloCluster.h"
14 #include "AliESDEvent.h"
15 #include "AliEmcalClusterMaker.h"
17 ClassImp(AliEmcalClusterMaker)
19 //________________________________________________________________________
20 AliEmcalClusterMaker::AliEmcalClusterMaker() :
21 AliAnalysisTaskEmcal("AliEmcalClusterMaker", kFALSE),
28 fEnergyTimeHistBefore(0),
31 fEnergyTimeHistAfter(0)
33 // Default constructor.
36 //________________________________________________________________________
37 AliEmcalClusterMaker::AliEmcalClusterMaker(const char *name, Bool_t histo) :
38 AliAnalysisTaskEmcal(name, histo),
39 fOutCaloName("EmcClusters"),
45 fEnergyTimeHistBefore(0),
48 fEnergyTimeHistAfter(0)
50 // Standard constructor.
52 SetMakeGeneralHistograms(histo);
54 fBranchNames="ESD:AliESDRun.,AliESDHeader.,PrimaryVertex.";
57 //________________________________________________________________________
58 AliEmcalClusterMaker::~AliEmcalClusterMaker()
63 //________________________________________________________________________
64 void AliEmcalClusterMaker::UserCreateOutputObjects()
66 // Create my user objects.
68 AliAnalysisTaskEmcal::UserCreateOutputObjects();
71 fRecoUtils->InitNonLinearityParam();
72 fRecoUtils->Print("");
75 if (!fCreateHisto) return;
77 fEnergyDistBefore = new TH1F("hEnergyDistBefore","hEnergyDistBefore;E_{clus} (GeV)",1500,0,150);
78 fOutput->Add(fEnergyDistBefore);
79 fEtaPhiDistBefore = new TH2F("hEtaPhiDistBefore","hEtaPhiDistBefore;#eta;#phi",280,-0.7,0.7,800,1.3,3.3);
80 fOutput->Add(fEtaPhiDistBefore);
81 fEnergyTimeHistBefore = new TH2F("hEnergyTimeDistBefore","hEnergyTimeDistBefore;E_{clus} (GeV);time",60,0,30,500,0,1e-6);
82 fOutput->Add(fEnergyTimeHistBefore);
83 fEnergyDistAfter = new TH1F("hEnergyDistAfter","hEnergyDistAfter;E_{clus} (GeV)",1500,0,150);
84 fOutput->Add(fEnergyDistAfter);
85 fEtaPhiDistAfter = new TH2F("hEtaPhiDistAfter","hEtaPhiDistAfter;#eta;#phi",280,-0.7,0.7,800,1.3,3.3);
86 fOutput->Add(fEtaPhiDistAfter);
87 fEnergyTimeHistAfter = new TH2F("hEnergyTimeDistAfter","hEnergyTimeDistAfter;E_{clus} (GeV);time",60,0,30,500,0,1e-6);
88 fOutput->Add(fEnergyTimeHistAfter);
92 //________________________________________________________________________
93 void AliEmcalClusterMaker::ExecOnce()
95 // Initialize the analysis.
97 // Do base class initializations and if it fails -> bail out
98 AliAnalysisTaskEmcal::ExecOnce();
102 if (dynamic_cast<AliAODEvent*>(InputEvent()))
106 fOutClusters = new TClonesArray("AliESDCaloCluster");
108 fOutClusters = new TClonesArray("AliAODCaloCluster");
110 fOutClusters->SetName(fOutCaloName);
112 // post output in event if not yet present
113 if (!(InputEvent()->FindListObject(fOutCaloName))) {
114 InputEvent()->AddObject(fOutClusters);
116 fInitialized = kFALSE;
117 AliFatal(Form("%s: Container with same name %s already present. Aborting", GetName(), fOutCaloName.Data()));
122 //________________________________________________________________________
123 Bool_t AliEmcalClusterMaker::Run()
125 // Run the hadronic correction
128 fOutClusters->Delete();
130 // loop over clusters
132 Int_t entries = fCaloClusters->GetEntries();
133 for (Int_t i=0; i<entries; ++i) {
134 AliVCluster *clus = static_cast<AliVCluster*>(fCaloClusters->At(i));
135 if (!clus || !clus->IsEMCAL())
139 fEnergyDistBefore->Fill(clus->E());
140 Float_t pos[3] ={0,0,0};
141 clus->GetPosition(pos);
143 fEtaPhiDistBefore->Fill(vec.Eta(),vec.Phi());
144 fEnergyTimeHistBefore->Fill(clus->E(),clus->GetTOF());
149 AliESDCaloCluster *ec = dynamic_cast<AliESDCaloCluster*>(clus);
151 oc = new ((*fOutClusters)[clusCount]) AliESDCaloCluster(*ec);
153 AliAODCaloCluster *ac = dynamic_cast<AliAODCaloCluster*>(clus);
155 oc = new ((*fOutClusters)[clusCount]) AliAODCaloCluster(*ac);
158 if (fRecoUtils->IsRejectExoticCluster()) {
159 if (fRecoUtils->IsExoticCluster(oc,fCaloCells))
162 if (fRecoUtils->GetNonLinearityFunction()!=AliEMCALRecoUtils::kNoCorrection) {
163 Double_t energy = fRecoUtils->CorrectClusterEnergyLinearity(oc);
167 if (!AcceptCluster(oc))
172 fEnergyDistAfter->Fill(oc->E());
173 Float_t pos[3] ={0,0,0};
174 oc->GetPosition(pos);
176 fEtaPhiDistAfter->Fill(vec.Eta(),vec.Phi());
177 fEnergyTimeHistAfter->Fill(oc->E(),oc->GetTOF());
181 if ((clusCount>0) && (clusCount==fOutClusters->GetEntries()))
182 fOutClusters->RemoveAt(clusCount);