AliPhysics  9fe175b (9fe175b)
 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 //________________________________________________________________________
38 AliEmcalClusterMaker::AliEmcalClusterMaker(const char *name, Bool_t histo) :
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,800,1.3,3.3);
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,800,1.3,3.3);
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 (!fInitialized) {
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  fInitialized = 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  fEtaPhiDistBefore->Fill(vec.Eta(),vec.Phi());
157  fEnergyTimeHistBefore->Fill(clus->E(), clus->GetTOF());
158  }
159 
160  Bool_t exResult = kFALSE;
161 
162  if (fRecoUtils) {
163  if (fRecoUtils->IsRejectExoticCluster()) {
164  Bool_t exRemoval = fRecoUtils->IsRejectExoticCell();
165  fRecoUtils->SwitchOnRejectExoticCell(); //switch on temporarily
166  exResult = fRecoUtils->IsExoticCluster(clus, fCaloCells);
167  if (!exRemoval) fRecoUtils->SwitchOffRejectExoticCell(); //switch back off
168 
169  clus->SetIsExotic(exResult);
170  }
171  if (fRecoUtils->GetNonLinearityFunction() != AliEMCALRecoUtils::kNoCorrection) {
172  Double_t energy = fRecoUtils->CorrectClusterEnergyLinearity(clus);
173  clus->SetNonLinCorrEnergy(energy);
174  }
175  }
176 
177  if (fCreateHisto) {
178  if (exResult) {
179  fEnergyExoticClusters->Fill(clus->E());
180  }
181  else {
182  fEnergyDistAfter->Fill(clus->GetNonLinCorrEnergy());
183  Float_t pos[3] = {0.};
184  clus->GetPosition(pos);
185  TVector3 vec(pos);
186  fEtaPhiDistAfter->Fill(vec.Eta(), vec.Phi());
187  fEnergyTimeHistAfter->Fill(clus->GetNonLinCorrEnergy(), clus->GetTOF());
188  }
189  }
190 
191  UInt_t rejectionReason = 0;
192  if (fOutClusters && clusters->AcceptCluster(clus, rejectionReason) && !exResult) {
193 
194  AliVCluster *oc = 0;
195  if (fEsdMode) {
196  AliESDCaloCluster *ec = dynamic_cast<AliESDCaloCluster*>(clus);
197  if (!ec) continue;
198  oc = new ((*fOutClusters)[clusCount]) AliESDCaloCluster(*ec);
199  }
200  else {
201  AliAODCaloCluster *ac = dynamic_cast<AliAODCaloCluster*>(clus);
202  if (!ac) continue;
203  oc = new ((*fOutClusters)[clusCount]) AliAODCaloCluster(*ac);
204  }
205 
206  oc->SetE(clus->GetNonLinCorrEnergy());
207  oc->SetNonLinCorrEnergy(clus->GetNonLinCorrEnergy());
208  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
209  clusCount++;
210  }
211  }
212 
213  return kTRUE;
214 }
Bool_t fEsdMode
pointer to reco utils
Base task in the EMCAL framework.
TH2F * fEtaPhiDistBefore
!eta/phi distribution before
AliClusterContainer * GetClusterContainer(Int_t i=0) const
virtual Bool_t AcceptCluster(Int_t i, UInt_t &rejectionReason) const
AliVCluster * GetNextCluster()
TH2F * fEnergyTimeHistAfter
!energy/time distribution after
energy
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)
TH1F * fEnergyExoticClusters
!energy of exotic clusters
TH2F * fEtaPhiDistAfter
!eta/phi distribution after
ClassImp(AliEmcalClusterMaker) AliEmcalClusterMaker
Bool_t fInitialized
whether or not the task has been already initialized
Container structure for EMCAL clusters.
TClonesArray * fOutClusters
!output cluster collection
TH2F * fEnergyTimeHistBefore
!energy/time distribution before