AliPhysics  1168478 (1168478)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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 #include "AliClusterContainer.h"
16 
18 
19 //________________________________________________________________________
22  fOutCaloName(),
23  fRecoUtils(0),
24  fEsdMode(kTRUE),
25  fOutClusters(0),
26  fEnergyDistBefore(0),
27  fEtaPhiDistBefore(0),
28  fEnergyTimeHistBefore(0),
29  fEnergyDistAfter(0),
30  fEtaPhiDistAfter(0),
31  fEnergyTimeHistAfter(0),
32  fEnergyExoticClusters(0)
33 {
34  // Default constructor.
35 }
36 
37 //________________________________________________________________________
39  AliAnalysisTaskEmcal(name, histo),
40  fOutCaloName("EmcClusters"),
41  fRecoUtils(0),
42  fEsdMode(kTRUE),
43  fOutClusters(0),
44  fEnergyDistBefore(0),
45  fEtaPhiDistBefore(0),
46  fEnergyTimeHistBefore(0),
47  fEnergyDistAfter(0),
48  fEtaPhiDistAfter(0),
49  fEnergyTimeHistAfter(0),
50  fEnergyExoticClusters(0)
51 {
52  // Standard constructor.
53 
55 
56  fBranchNames="ESD:AliESDRun.,AliESDHeader.,PrimaryVertex.";
57 }
58 
59 //________________________________________________________________________
61 {
62  // Destructor
63 }
64 
65 //________________________________________________________________________
67 {
68  // Create my user objects.
69 
71 
72  if (fRecoUtils) {
73  fRecoUtils->InitNonLinearityParam();
74  fRecoUtils->Print("");
75  }
76 
77  if (!fCreateHisto) return;
78 
79  fEnergyDistBefore = new TH1F("hEnergyDistBefore","hEnergyDistBefore;E_{clus} (GeV)",1500,0,150);
81  fEtaPhiDistBefore = new TH2F("hEtaPhiDistBefore","hEtaPhiDistBefore;#eta;#phi",280,-0.7,0.7,200*3.14,0,2*3.14);
83  fEnergyTimeHistBefore = new TH2F("hEnergyTimeDistBefore","hEnergyTimeDistBefore;E_{clus} (GeV);time",1500,0,150,500,0,1e-6);
85  fEnergyDistAfter = new TH1F("hEnergyDistAfter","hEnergyDistAfter;E_{clus} (GeV)",1500,0,150);
87  fEtaPhiDistAfter = new TH2F("hEtaPhiDistAfter","hEtaPhiDistAfter;#eta;#phi",280,-0.7,0.7,200*3.14,0,2*3.14);
89  fEnergyTimeHistAfter = new TH2F("hEnergyTimeDistAfter","hEnergyTimeDistAfter;E_{clus} (GeV);time",1500,0,150,500,0,1e-6);
91  fEnergyExoticClusters = new TH1F("fEnergyExoticClusters","fEnergyExoticClusters;E_{ex clus} (GeV)",1500,0,150);
93  PostData(1, fOutput);
94 }
95 
96 //________________________________________________________________________
98 {
99  // Initialize the analysis.
100 
101  // Do base class initializations and if it fails -> bail out
103  if (!fLocalInitialized) {
104  return;
105  }
106 
107  if (dynamic_cast<AliAODEvent*>(InputEvent())) {
108  fEsdMode = kFALSE;
109  }
110 
111  if (!fOutCaloName.IsNull()) { // if empty updates old clusters instead of creating a new collection
112  if (fEsdMode) {
113  fOutClusters = new TClonesArray("AliESDCaloCluster");
114  }
115  else {
116  fOutClusters = new TClonesArray("AliAODCaloCluster");
117  }
118  fOutClusters->SetName(fOutCaloName);
119 
120  // post output in event if not yet present
121  if (!(InputEvent()->FindListObject(fOutCaloName))) {
122  InputEvent()->AddObject(fOutClusters);
123  }
124  else {
125  fLocalInitialized = kFALSE;
126  AliFatal(Form("%s: Container with same name %s already present. Aborting", GetName(), fOutCaloName.Data()));
127  return;
128  }
129  }
130 }
131 
132 //________________________________________________________________________
134 {
135  // Run the cluster maker
136 
137  // delete output
138  if (fOutClusters) fOutClusters->Delete();
139 
141  if (!clusters) return kFALSE;
142 
143  // loop over clusters
144  Int_t clusCount = 0;
145  //Int_t entries = fCaloClusters->GetEntries();
146  AliVCluster *clus = 0;
147  clusters->ResetCurrentID();
148  while ((clus = clusters->GetNextCluster())) {
149  if (!clus->IsEMCAL()) continue;
150 
151  if (fCreateHisto) {
152  fEnergyDistBefore->Fill(clus->E());
153  Float_t pos[3] = {0.};
154  clus->GetPosition(pos);
155  TVector3 vec(pos);
156  // Phi needs to be in 0 to 2 Pi
157  fEtaPhiDistBefore->Fill(vec.Eta(), TVector2::Phi_0_2pi(vec.Phi()));
158  fEnergyTimeHistBefore->Fill(clus->E(), clus->GetTOF());
159  }
160 
161  Bool_t exResult = kFALSE;
162 
163  if (fRecoUtils) {
164  if (fRecoUtils->IsRejectExoticCluster()) {
165  Bool_t exRemoval = fRecoUtils->IsRejectExoticCell();
166  fRecoUtils->SwitchOnRejectExoticCell(); //switch on temporarily
167  exResult = fRecoUtils->IsExoticCluster(clus, fCaloCells);
168  if (!exRemoval) fRecoUtils->SwitchOffRejectExoticCell(); //switch back off
169 
170  clus->SetIsExotic(exResult);
171  }
172  if (fRecoUtils->GetNonLinearityFunction() != AliEMCALRecoUtils::kNoCorrection) {
173  Double_t energy = fRecoUtils->CorrectClusterEnergyLinearity(clus);
174  clus->SetNonLinCorrEnergy(energy);
175  }
176  }
177 
178  if (fCreateHisto) {
179  if (exResult) {
180  fEnergyExoticClusters->Fill(clus->E());
181  }
182  else {
183  fEnergyDistAfter->Fill(clus->GetNonLinCorrEnergy());
184  Float_t pos[3] = {0.};
185  clus->GetPosition(pos);
186  TVector3 vec(pos);
187  // Phi needs to be in 0 to 2 Pi
188  fEtaPhiDistAfter->Fill(vec.Eta(), TVector2::Phi_0_2pi(vec.Phi()));
189  fEnergyTimeHistAfter->Fill(clus->GetNonLinCorrEnergy(), clus->GetTOF());
190  }
191  }
192 
193  UInt_t rejectionReason = 0;
194  if (fOutClusters && clusters->AcceptCluster(clus, rejectionReason) && !exResult) {
195 
196  AliVCluster *oc = 0;
197  if (fEsdMode) {
198  AliESDCaloCluster *ec = dynamic_cast<AliESDCaloCluster*>(clus);
199  if (!ec) continue;
200  oc = new ((*fOutClusters)[clusCount]) AliESDCaloCluster(*ec);
201  }
202  else {
203  AliAODCaloCluster *ac = dynamic_cast<AliAODCaloCluster*>(clus);
204  if (!ac) continue;
205  oc = new ((*fOutClusters)[clusCount]) AliAODCaloCluster(*ac);
206  }
207 
208  oc->SetE(clus->GetNonLinCorrEnergy());
209  oc->SetNonLinCorrEnergy(clus->GetNonLinCorrEnergy());
210  oc->SetHadCorrEnergy(0);//just to make sure that in this container version there is no hadronic correction applied - can be set at a later stage
211  clusCount++;
212  }
213  }
214 
215  return kTRUE;
216 }
double Double_t
Definition: External.C:58
Definition: External.C:236
Bool_t Run()
Run function. This is the core function of the analysis and contains the user code. Therefore users have to implement this function.
Bool_t fEsdMode
pointer to reco utils
Base task in the EMCAL framework.
Bool_t fLocalInitialized
whether or not the task has been already initialized
TH2F * fEtaPhiDistBefore
!eta/phi distribution before
energy
Definition: HFPtSpectrum.C:44
int Int_t
Definition: External.C:63
unsigned int UInt_t
Definition: External.C:33
float Float_t
Definition: External.C:68
AliClusterContainer * GetClusterContainer(Int_t i=0) const
Get cluster container attached to this task.
virtual Bool_t AcceptCluster(Int_t i, UInt_t &rejectionReason) const
AliVCluster * GetNextCluster()
TH2F * fEnergyTimeHistAfter
!energy/time distribution after
AliVCaloCells * fCaloCells
!cells
AliEMCALRecoUtils * fRecoUtils
name of output clusters; if empty updates old clusters instead of creating a new collection ...
TH1F * fEnergyDistBefore
!energy distribution before
AliEmcalList * fOutput
!output list
TH1F * fEnergyDistAfter
!energy distribution after
Bool_t fCreateHisto
whether or not create histograms
void SetMakeGeneralHistograms(Bool_t g)
virtual void ExecOnce()
Perform steps needed to initialize the analysis.
void ExecOnce()
Perform steps needed to initialize the analysis.
TH1F * fEnergyExoticClusters
!energy of exotic clusters
void UserCreateOutputObjects()
Main initialization function on the worker.
TH2F * fEtaPhiDistAfter
!eta/phi distribution after
bool Bool_t
Definition: External.C:53
ClassImp(AliEmcalClusterMaker) AliEmcalClusterMaker
Container structure for EMCAL clusters.
TClonesArray * fOutClusters
!output cluster collection
TH2F * fEnergyTimeHistBefore
!energy/time distribution before