AliPhysics  a0db429 (a0db429)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
AliEmcalClusterMaker.cxx
Go to the documentation of this file.
1 //
2 // Cluster maker task.
3 //
4 // Author: C.Loizides, S.Aiola
5 
6 #include <TChain.h>
7 #include <TClonesArray.h>
8 #include "AliAODCaloCluster.h"
9 #include "AliAODEvent.h"
10 #include "AliAnalysisManager.h"
11 #include "AliEMCALRecoUtils.h"
12 #include "AliESDCaloCluster.h"
13 #include "AliESDEvent.h"
14 #include "AliEmcalClusterMaker.h"
15 
17 
18 //________________________________________________________________________
21  fOutCaloName(),
22  fRecoUtils(0),
23  fEsdMode(kTRUE),
24  fOutClusters(0),
25  fEnergyDistBefore(0),
26  fEtaPhiDistBefore(0),
27  fEnergyTimeHistBefore(0),
28  fEnergyDistAfter(0),
29  fEtaPhiDistAfter(0),
30  fEnergyTimeHistAfter(0),
31  fEnergyExoticClusters(0)
32 {
33  // Default constructor.
34 }
35 
36 //________________________________________________________________________
37 AliEmcalClusterMaker::AliEmcalClusterMaker(const char *name, Bool_t histo) :
38  AliAnalysisTaskEmcal(name, histo),
39  fOutCaloName("EmcClusters"),
40  fRecoUtils(0),
41  fEsdMode(kTRUE),
42  fOutClusters(0),
43  fEnergyDistBefore(0),
44  fEtaPhiDistBefore(0),
45  fEnergyTimeHistBefore(0),
46  fEnergyDistAfter(0),
47  fEtaPhiDistAfter(0),
48  fEnergyTimeHistAfter(0),
49  fEnergyExoticClusters(0)
50 {
51  // Standard constructor.
52 
54 
55  fBranchNames="ESD:AliESDRun.,AliESDHeader.,PrimaryVertex.";
56 }
57 
58 //________________________________________________________________________
60 {
61  // Destructor
62 }
63 
64 //________________________________________________________________________
66 {
67  // Create my user objects.
68 
70 
71  if (fRecoUtils) {
72  fRecoUtils->InitNonLinearityParam();
73  fRecoUtils->Print("");
74  }
75 
76  if (!fCreateHisto) return;
77 
78  fEnergyDistBefore = new TH1F("hEnergyDistBefore","hEnergyDistBefore;E_{clus} (GeV)",1500,0,150);
80  fEtaPhiDistBefore = new TH2F("hEtaPhiDistBefore","hEtaPhiDistBefore;#eta;#phi",280,-0.7,0.7,800,1.3,3.3);
82  fEnergyTimeHistBefore = new TH2F("hEnergyTimeDistBefore","hEnergyTimeDistBefore;E_{clus} (GeV);time",1500,0,150,500,0,1e-6);
84  fEnergyDistAfter = new TH1F("hEnergyDistAfter","hEnergyDistAfter;E_{clus} (GeV)",1500,0,150);
86  fEtaPhiDistAfter = new TH2F("hEtaPhiDistAfter","hEtaPhiDistAfter;#eta;#phi",280,-0.7,0.7,800,1.3,3.3);
88  fEnergyTimeHistAfter = new TH2F("hEnergyTimeDistAfter","hEnergyTimeDistAfter;E_{clus} (GeV);time",1500,0,150,500,0,1e-6);
90  fEnergyExoticClusters = new TH1F("fEnergyExoticClusters","fEnergyExoticClusters;E_{ex clus} (GeV)",1500,0,150);
92  PostData(1, fOutput);
93 }
94 
95 //________________________________________________________________________
97 {
98  // Initialize the analysis.
99 
100  // Do base class initializations and if it fails -> bail out
102  if (!fInitialized) {
103  return;
104  }
105 
106  if (dynamic_cast<AliAODEvent*>(InputEvent())) {
107  fEsdMode = kFALSE;
108  }
109 
110  if (!fOutCaloName.IsNull()) { // if empty updates old clusters instead of creating a new collection
111  if (fEsdMode) {
112  fOutClusters = new TClonesArray("AliESDCaloCluster");
113  }
114  else {
115  fOutClusters = new TClonesArray("AliAODCaloCluster");
116  }
117  fOutClusters->SetName(fOutCaloName);
118 
119  // post output in event if not yet present
120  if (!(InputEvent()->FindListObject(fOutCaloName))) {
121  InputEvent()->AddObject(fOutClusters);
122  }
123  else {
124  fInitialized = kFALSE;
125  AliFatal(Form("%s: Container with same name %s already present. Aborting", GetName(), fOutCaloName.Data()));
126  return;
127  }
128  }
129 }
130 
131 //________________________________________________________________________
133 {
134  // Run the cluster maker
135 
136  // delete output
137  if (fOutClusters) fOutClusters->Delete();
138 
139  // loop over clusters
140  Int_t clusCount = 0;
141  Int_t entries = fCaloClusters->GetEntries();
142  for (Int_t i = 0; i < entries; ++i) {
143  AliVCluster *clus = static_cast<AliVCluster*>(fCaloClusters->At(i));
144  if (!clus || !clus->IsEMCAL()) {
145  continue;
146  }
147 
148  if (fCreateHisto) {
149  fEnergyDistBefore->Fill(clus->E());
150  Float_t pos[3] = {0.};
151  clus->GetPosition(pos);
152  TVector3 vec(pos);
153  fEtaPhiDistBefore->Fill(vec.Eta(),vec.Phi());
154  fEnergyTimeHistBefore->Fill(clus->E(), clus->GetTOF());
155  }
156 
157  AliVCluster *oc = 0;
158  if (fOutClusters) {
159  if (fEsdMode) {
160  AliESDCaloCluster *ec = dynamic_cast<AliESDCaloCluster*>(clus);
161  if (!ec) continue;
162  oc = new ((*fOutClusters)[clusCount]) AliESDCaloCluster(*ec);
163  }
164  else {
165  AliAODCaloCluster *ac = dynamic_cast<AliAODCaloCluster*>(clus);
166  if (!ac) continue;
167  oc = new ((*fOutClusters)[clusCount]) AliAODCaloCluster(*ac);
168  }
169  }
170 
171  Bool_t exResult = kFALSE;
172 
173  if (fRecoUtils) {
174  if (fRecoUtils->IsRejectExoticCluster()) {
175  Bool_t exRemoval = fRecoUtils->IsRejectExoticCell();
176  fRecoUtils->SwitchOnRejectExoticCell(); //switch on temporarily
177  exResult = fRecoUtils->IsExoticCluster(clus, fCaloCells);
178  if (!exRemoval) fRecoUtils->SwitchOffRejectExoticCell(); //switch back off
179 
180  clus->SetIsExotic(exResult);
181 
182  if (exResult) {
183  fEnergyExoticClusters->Fill(clus->E());
184  }
185  }
186  if (fRecoUtils->GetNonLinearityFunction() != AliEMCALRecoUtils::kNoCorrection) {
187  Double_t energy = fRecoUtils->CorrectClusterEnergyLinearity(clus);
188  clus->SetNonLinCorrEnergy(energy);
189 
190  if (oc) oc->SetE(energy);
191  }
192  }
193 
194  if (!AcceptCluster(oc) || exResult) {
195  continue;
196  }
197 
198  if (fOutClusters) {
199  clusCount++;
200  }
201 
202  if (fCreateHisto) {
203  fEnergyDistAfter->Fill(clus->GetNonLinCorrEnergy());
204  Float_t pos[3] = {0.};
205  clus->GetPosition(pos);
206  TVector3 vec(pos);
207  fEtaPhiDistAfter->Fill(vec.Eta(), vec.Phi());
208  fEnergyTimeHistAfter->Fill(clus->GetNonLinCorrEnergy(), clus->GetTOF());
209  }
210  }
211 
212  if (fOutClusters && (clusCount > 0) && (clusCount == fOutClusters->GetEntries())) {
213  fOutClusters->RemoveAt(clusCount);
214  }
215 
216 
217  return kTRUE;
218 }
TH2F * fEtaPhiDistBefore
energy distribution before
Bool_t AcceptCluster(AliVCluster *clus, Int_t c=0) const
TList * fOutput
x-section from pythia header
TClonesArray * fCaloClusters
tracks
TH2F * fEnergyTimeHistAfter
eta/phi distribution after
energy
AliVCaloCells * fCaloCells
clusters
AliEMCALRecoUtils * fRecoUtils
TH1F * fEnergyDistBefore
output cluster collection
TH1F * fEnergyDistAfter
energy/time distribution before
void SetMakeGeneralHistograms(Bool_t g)
TH1F * fEnergyExoticClusters
energy/time distribution after
TH2F * fEtaPhiDistAfter
energy distribution after
ClassImp(AliEmcalClusterMaker) AliEmcalClusterMaker
TClonesArray * fOutClusters
ESD/AOD mode.
TH2F * fEnergyTimeHistBefore
eta/phi distribution before