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),
32 fEnergyExoticClusters(0)
34 // Default constructor.
37 //________________________________________________________________________
38 AliEmcalClusterMaker::AliEmcalClusterMaker(const char *name, Bool_t histo) :
39 AliAnalysisTaskEmcal(name, histo),
40 fOutCaloName("EmcClusters"),
46 fEnergyTimeHistBefore(0),
49 fEnergyTimeHistAfter(0),
50 fEnergyExoticClusters(0)
52 // Standard constructor.
54 SetMakeGeneralHistograms(histo);
56 fBranchNames="ESD:AliESDRun.,AliESDHeader.,PrimaryVertex.";
59 //________________________________________________________________________
60 AliEmcalClusterMaker::~AliEmcalClusterMaker()
65 //________________________________________________________________________
66 void AliEmcalClusterMaker::UserCreateOutputObjects()
68 // Create my user objects.
70 AliAnalysisTaskEmcal::UserCreateOutputObjects();
73 fRecoUtils->InitNonLinearityParam();
74 fRecoUtils->Print("");
77 if (!fCreateHisto) return;
79 fEnergyDistBefore = new TH1F("hEnergyDistBefore","hEnergyDistBefore;E_{clus} (GeV)",1500,0,150);
80 fOutput->Add(fEnergyDistBefore);
81 fEtaPhiDistBefore = new TH2F("hEtaPhiDistBefore","hEtaPhiDistBefore;#eta;#phi",280,-0.7,0.7,800,1.3,3.3);
82 fOutput->Add(fEtaPhiDistBefore);
83 fEnergyTimeHistBefore = new TH2F("hEnergyTimeDistBefore","hEnergyTimeDistBefore;E_{clus} (GeV);time",60,0,30,500,0,1e-6);
84 fOutput->Add(fEnergyTimeHistBefore);
85 fEnergyDistAfter = new TH1F("hEnergyDistAfter","hEnergyDistAfter;E_{clus} (GeV)",1500,0,150);
86 fOutput->Add(fEnergyDistAfter);
87 fEtaPhiDistAfter = new TH2F("hEtaPhiDistAfter","hEtaPhiDistAfter;#eta;#phi",280,-0.7,0.7,800,1.3,3.3);
88 fOutput->Add(fEtaPhiDistAfter);
89 fEnergyTimeHistAfter = new TH2F("hEnergyTimeDistAfter","hEnergyTimeDistAfter;E_{clus} (GeV);time",60,0,30,500,0,1e-6);
90 fOutput->Add(fEnergyTimeHistAfter);
91 fEnergyExoticClusters = new TH1F("fEnergyExoticClusters","fEnergyExoticClusters;E_{ex clus} (GeV)",60,0,30);
92 fOutput->Add(fEnergyExoticClusters);
96 //________________________________________________________________________
97 void AliEmcalClusterMaker::ExecOnce()
99 // Initialize the analysis.
101 // Do base class initializations and if it fails -> bail out
102 AliAnalysisTaskEmcal::ExecOnce();
106 if (dynamic_cast<AliAODEvent*>(InputEvent()))
110 fOutClusters = new TClonesArray("AliESDCaloCluster");
112 fOutClusters = new TClonesArray("AliAODCaloCluster");
114 fOutClusters->SetName(fOutCaloName);
116 // post output in event if not yet present
117 if (!(InputEvent()->FindListObject(fOutCaloName))) {
118 InputEvent()->AddObject(fOutClusters);
120 fInitialized = kFALSE;
121 AliFatal(Form("%s: Container with same name %s already present. Aborting", GetName(), fOutCaloName.Data()));
126 //________________________________________________________________________
127 Bool_t AliEmcalClusterMaker::Run()
129 // Run the cluster maker
132 fOutClusters->Delete();
134 // loop over clusters
136 Int_t entries = fCaloClusters->GetEntries();
137 for (Int_t i=0; i<entries; ++i) {
138 AliVCluster *clus = static_cast<AliVCluster*>(fCaloClusters->At(i));
139 if (!clus || !clus->IsEMCAL())
143 fEnergyDistBefore->Fill(clus->E());
144 Float_t pos[3] ={0,0,0};
145 clus->GetPosition(pos);
147 fEtaPhiDistBefore->Fill(vec.Eta(),vec.Phi());
148 fEnergyTimeHistBefore->Fill(clus->E(),clus->GetTOF());
153 AliESDCaloCluster *ec = dynamic_cast<AliESDCaloCluster*>(clus);
155 oc = new ((*fOutClusters)[clusCount]) AliESDCaloCluster(*ec);
157 AliAODCaloCluster *ac = dynamic_cast<AliAODCaloCluster*>(clus);
159 oc = new ((*fOutClusters)[clusCount]) AliAODCaloCluster(*ac);
162 if (fRecoUtils->IsRejectExoticCluster()) {
163 Bool_t exRemoval = fRecoUtils->IsRejectExoticCell();
164 fRecoUtils->SwitchOnRejectExoticCell(); //switch on temporarily
165 Bool_t exResult = fRecoUtils->IsExoticCluster(oc,fCaloCells);
166 if (!exRemoval) fRecoUtils->SwitchOffRejectExoticCell(); //switch back off
168 fEnergyExoticClusters->Fill(oc->E());
172 if (fRecoUtils->GetNonLinearityFunction()!=AliEMCALRecoUtils::kNoCorrection) {
173 Double_t energy = fRecoUtils->CorrectClusterEnergyLinearity(oc);
177 if (!AcceptCluster(oc))
182 fEnergyDistAfter->Fill(oc->E());
183 Float_t pos[3] ={0,0,0};
184 oc->GetPosition(pos);
186 fEtaPhiDistAfter->Fill(vec.Eta(),vec.Phi());
187 fEnergyTimeHistAfter->Fill(oc->E(),oc->GetTOF());
191 if ((clusCount>0) && (clusCount==fOutClusters->GetEntries()))
192 fOutClusters->RemoveAt(clusCount);