2 * @file AliForwardCreateResponseMatrices.cxx
3 * @author Christian Holm Christensen <cholm@master.hehi.nbi.dk>
4 * @date Thu Feb 7 01:01:24 2013
9 * @ingroup pwglf_forward_multdist
13 #include "AliForwardCreateResponseMatrices.h"
14 #include "AliForwardMultiplicityDistribution.h"
15 #include "AliAODForwardMult.h"
16 #include "AliAODCentralMult.h"
17 #include "AliAODEvent.h"
18 #include "AliFMDMCEventInspector.h"
19 #include "AliAODMCHeader.h"
20 #include "AliAODMCParticle.h"
23 ClassImp(AliForwardCreateResponseMatrices)
25 ; // This is for Emacs - do not delete
27 //_____________________________________________________________________
28 AliForwardCreateResponseMatrices::AliForwardCreateResponseMatrices()
34 // Default Constructor
38 //_____________________________________________________________________
39 AliForwardCreateResponseMatrices::AliForwardCreateResponseMatrices(const char* name)
40 : AliBaseAODTask(name,"AliForwardCreateResponseMatrices"),
49 //_____________________________________________________________________
51 AliForwardCreateResponseMatrices::CheckEvent(const AliAODForwardMult& fwd)
53 fIsSelected = AliBaseAODTask::CheckEvent(fwd);
54 // We always return true, so that we can process MC truth;
58 //_____________________________________________________________________
59 Bool_t AliForwardCreateResponseMatrices::Book()
62 // Create Output Objects
64 TH1D* dndetaSumForward = new TH1D("dndetaSumForward","dndetaSumForward",
66 TH1D* dndetaSumCentral = new TH1D("dndetaSumCentral","dndetaSumCentral",
68 TH1D* dndetaSumMC = new TH1D("dndetaSumMC","dndetaSumMC", 200,-4,6);
70 fSums->Add(dndetaSumForward);
71 fSums->Add(dndetaSumCentral);
72 fSums->Add(dndetaSumMC);
74 TH1D* dndetaEventForward = new TH1D();
75 TH1D* dndetaEventCentral = new TH1D();
76 TH1D* dndetaEventMC = new TH1D();
78 fSums->Add(dndetaEventForward);
79 fSums->Add(dndetaEventCentral);
80 fSums->Add(dndetaEventMC);
82 //Loop over all individual eta bins, and define their hisograms
85 while ((bin = static_cast<Bin*>(next()))) {
86 bin->CreateOutputObjectss(fSums, 400);
94 //_____________________________________________________________________
95 Bool_t AliForwardCreateResponseMatrices::Event(AliAODEvent& aod)
100 // Here, we used to get ForwardMC!
101 AliAODForwardMult* AODforward = GetForward(aod);
102 if (!AODforward) return false;
104 // Here, we used to get CentralClusters!
105 AliAODCentralMult* AODcentral = GetCentral(aod);
106 if (!AODcentral) return false;
108 TH2D& forward = AODforward->GetHistogram();
109 TH2D& central = AODcentral->GetHistogram();
111 //check if event is NSD according to either MC truth or analysis (ESD)
112 Bool_t isMCNSD = kFALSE;
113 Bool_t isESDNSD = kFALSE;
114 if(AODforward->IsTriggerBits(AliAODForwardMult::kMCNSD)) isMCNSD=kTRUE;
115 if(AODforward->IsTriggerBits(AliAODForwardMult::kNSD)) isESDNSD=kTRUE;
117 //primary dndeta dist
118 TH2D* primHist = GetPrimary(aod);
120 TH1D* dndetaSumForward = (TH1D*)fSums->FindObject("dndetaSumForward");
121 TH1D* dndetaSumCentral = (TH1D*)fSums->FindObject("dndetaSumCentral");
122 TH1D* dndetaSumMC = (TH1D*)fSums->FindObject("dndetaSumMC");
123 TH1D* dndetaEventForward = forward.ProjectionX("dndetaForward",1,
124 forward.GetNbinsY(),"");
125 TH1D* dndetaEventCentral = central.ProjectionX("dndetaCentral",1,
126 central.GetNbinsY(),"");
127 TH1D* dndetaEventMC = primHist->ProjectionX("dndetaMC",1,
128 primHist->GetNbinsY(),"");
130 // underflow eta bin of forward/central carry information on whether
131 // there is acceptance. 1= acceptance, 0= no acceptance
132 TH1D* normEventForward = 0;
133 TH1D* normEventCentral = 0;
134 normEventForward = forward.ProjectionX("dndetaEventForwardNorm",0,0,"");
135 normEventCentral = central.ProjectionX("dndetaEventCentralNorm",0,0,"");
137 dndetaSumForward->Add(dndetaEventForward);
138 dndetaSumCentral->Add(dndetaEventCentral);
139 dndetaSumMC->Add(dndetaEventMC);
142 Double_t VtxZ = AODforward->GetIpZ();
144 // loop over all eta bins, and create response matrices,
145 // trigger-vertex bias histograms etc
148 while ((bin = static_cast<Bin*>(next()))) {
149 bin->Process(dndetaEventForward, dndetaEventCentral,
150 normEventForward, normEventCentral,
151 dndetaEventMC, VtxZ, fIsSelected,
152 isMCNSD, isESDNSD, aod);
159 //=====================================================================
160 AliForwardCreateResponseMatrices::Bin::Bin(Double_t etaLow, Double_t etaHigh)
162 fEtaLow(etaLow), // low eta limit
163 fEtaHigh(etaHigh), // high eta limit
164 fHist(), // multiplicity histogram
165 fHistMC(), // multiplicity histogram MC truth primaries
166 fAcceptance(), // histogram showing the 'holes' in acceptance. BinContent of 1 shows a hole, and BinContent of 10 shows data coverage
167 fVtxZvsNdataBins(), // VtxZ vs. number of data acceptance bins (normalised to the eta range)
168 fResponseMatrix(), // Response matrix (MC truth vs. analysed multiplicity)
169 fResponseMatrixPlus05(), // Response matrix with analysed multiplicity scaled up by 5%
170 fResponseMatrixPlus075(), // Response matrix with analysed multiplicity scaled up by 7.5%
171 fResponseMatrixPlus10(), // Response matrix with analysed multiplicity scaled up by 10%
172 fResponseMatrixMinus05(), // Response matrix with analysed multiplicity scaled down by 5%
173 fResponseMatrixMinus075(),// Response matrix with analysed multiplicity scaled down by 7.55%
174 fResponseMatrixMinus10(), // Response matrix with analysed multiplicity scaled down by 10%
175 fResponseMatrixMinusSys(),// Response matrix with analysed multiplicity scaled up by event mult uncertainty
176 fResponseMatrixPlusSys(), // Response matrix with analysed multiplicity scaled down by event mult uncertainty
177 fESDNSD(), // number of events found as NSD by the analysis vs. multiplicity
178 fMCNSD(), // number of events found as NSD by the MC truth vs. multiplicity
179 fMCESDNSD(), // number of events found as NSD by both analysis and MC truth vs. multiplicity
180 fTriggerBias() // histogram for trigger vertex bias correction
185 const char* name = AliForwardMultiplicityDistribution::FormBinName(etaLow,etaHigh);
188 SetTitle(Form("%+4.1f < #eta < %+4.1f", fEtaLow, fEtaHigh));
191 //_____________________________________________________________________
192 AliForwardCreateResponseMatrices::Bin::Bin()
194 fEtaLow(), // low eta limit
195 fEtaHigh(), // high eta limit
196 fHist(), // multiplicity histogram
197 fHistMC(), // multiplicity histogram MC truth primaries
198 fAcceptance(), // histogram showing the 'holes' in acceptance. BinContent of 1 shows a hole, and BinContent of 10 shows data coverage
199 fVtxZvsNdataBins(), // VtxZ vs. number of data acceptance bins (normalised to the eta range)
200 fResponseMatrix(), // Response matrix (MC truth vs. analysed multiplicity)
201 fResponseMatrixPlus05(), // Response matrix with analysed multiplicity scaled up by 5%
202 fResponseMatrixPlus075(), // Response matrix with analysed multiplicity scaled up by 7.5%
203 fResponseMatrixPlus10(), // Response matrix with analysed multiplicity scaled up by 10%
204 fResponseMatrixMinus05(), // Response matrix with analysed multiplicity scaled down by 5%
205 fResponseMatrixMinus075(),// Response matrix with analysed multiplicity scaled down by 7.55%
206 fResponseMatrixMinus10(), // Response matrix with analysed multiplicity scaled down by 10%
207 fResponseMatrixMinusSys(),// Response matrix with analysed multiplicity scaled up by event mult uncertainty
208 fResponseMatrixPlusSys(), // Response matrix with analysed multiplicity scaled down by event mult uncertainty
209 fESDNSD(), // number of events found as NSD by the analysis vs. multiplicity
210 fMCNSD(), // number of events found as NSD by the MC truth vs. multiplicity
211 fMCESDNSD(), // number of events found as NSD by both analysis and MC truth vs. multiplicity
212 fTriggerBias() // histogram for trigger vertex bias correction
215 // Default Constructor
218 //_____________________________________________________________________
219 void AliForwardCreateResponseMatrices::Bin::CreateOutputObjectss(TList* cont, Int_t max)
222 // Define eta bin output histos
224 TList* out = new TList;
225 out->SetName(GetName());
228 fHist = new TH1D("mult", GetTitle(), max, -0.5, max-.5);
229 fHistMC = new TH1D("multTruth", GetTitle(), max, -0.5, max-.5);
230 fVtxZvsNdataBins = new TH2D("VtxZvsNdataBins", "VtxZ vs dataAcceptance/etaRange;z-vtz;dataAcceptance/etaRange", 20, -10,10, 130,0,1.3);
231 fAcceptance = new TH2D("Acceptance","Acceptance;#eta;z-vtx",200,-4, 6 , 20,-10,10);
232 fResponseMatrix = new TH2D("responseMatrix","Response Matrix;MC_{truth};MC_{measured}", max, -0.5, max-.5, max, -0.5, max-.5);
233 fResponseMatrixPlus05 = new TH2D("responseMatrixPlus05","Response Matrix;MC_{truth};MC_{measured}", max, -0.5, max-.5, max, -0.5, max-.5);
234 fResponseMatrixPlus075 = new TH2D("responseMatrixPlus075","Response Matrix;MC_{truth};MC_{measured}", max, -0.5, max-.5, max, -0.5, max-.5);
235 fResponseMatrixPlus10 = new TH2D("responseMatrixPlus10","Response Matrix;MC_{truth};MC_{measured}", max, -0.5, max-.5, max, -0.5, max-.5);
236 fResponseMatrixMinus05 = new TH2D("responseMatrixMinus05","Response Matrix;MC_{truth};MC_{measured}", max, -0.5, max-.5, max, -0.5, max-.5);
237 fResponseMatrixMinus075 = new TH2D("responseMatrixMinus075","Response Matrix;MC_{truth};MC_{measured}", max, -0.5, max-.5, max, -0.5, max-.5);
238 fResponseMatrixMinus10 = new TH2D("responseMatrixMinus10","Response Matrix;MC_{truth};MC_{measured}", max, -0.5, max-.5, max, -0.5, max-.5);
239 fResponseMatrixMinusSys = new TH2D("responseMatrixMinusSys","Response Matrix;MC_{truth};MC_{measured}", max, -0.5, max-.5, max, -0.5, max-.5);
240 fResponseMatrixPlusSys = new TH2D("responseMatrixPlusSys","Response Matrix;MC_{truth};MC_{measured}", max, -0.5, max-.5, max, -0.5, max-.5);
241 fTriggerBias = new TH1D("triggerBias","triggerBias;MC_{truth};Correction}", max, -0.5, max-.5);
242 fMCNSD = new TH1D("fMCNSD","fMCNSD", 300,-0.5,299.5);
243 fESDNSD = new TH1D("fESDNSD","fESDNSD", 300,-0.5,299.5);
244 fMCESDNSD = new TH1D("fMCESDNSD","fMCESDNSD", 300,-0.5,299.5);
251 out->Add(fVtxZvsNdataBins);
252 out->Add(fAcceptance);
253 out->Add(fResponseMatrix);
254 out->Add(fResponseMatrixPlus05);
255 out->Add(fResponseMatrixPlus075);
256 out->Add(fResponseMatrixPlus10);
257 out->Add(fResponseMatrixMinus05);
258 out->Add(fResponseMatrixMinus075);
259 out->Add(fResponseMatrixMinus10);
260 out->Add(fResponseMatrixPlusSys);
261 out->Add(fResponseMatrixMinusSys);
262 out->Add(fTriggerBias);
267 //_____________________________________________________________________
269 AliForwardCreateResponseMatrices::Bin::Process(TH1D* dndetaForward,
275 Bool_t selectedTrigger,
278 const AliAODEvent& aodevent)
281 // Process a single eta bin
284 // Diagnostics on event acceptance
285 Int_t first = dndetaForward->GetXaxis()->FindBin(fEtaLow);
286 Int_t last = dndetaForward->GetXaxis()->FindBin(fEtaHigh-.0001);
287 Double_t acceptanceBins=0;
288 for(Int_t n= first;n<=last;n++){
289 if(normForward->GetBinContent(n)>0||normCentral->GetBinContent(n)>0){
292 fAcceptance->SetBinContent(n, fAcceptance->GetYaxis()->FindBin(VtxZ), 1);
293 if(normForward->GetBinContent(n)>0||normCentral->GetBinContent(n)>0)
294 fAcceptance->SetBinContent(n, fAcceptance->GetYaxis()->FindBin(VtxZ),10);
296 fVtxZvsNdataBins->Fill(VtxZ, (Double_t)acceptanceBins/(last-first+1));
302 Double_t cPrimary = 0;
303 Double_t e2Primary= 0;
305 for (Int_t i = first; i <= last; i++){
306 Double_t cForward = 0;
307 Double_t cCentral = 0;
308 Double_t e2Forward = 0;
309 Double_t e2Central = 0;
312 cMC= mc->GetBinContent(i);
313 e2MC= mc->GetBinError(i) * mc->GetBinError(i);
316 if (normForward->GetBinContent(i) > 0) {
317 cForward = dndetaForward->GetBinContent(i);
318 e2Forward = dndetaForward->GetBinError(i) * dndetaForward->GetBinError(i);
320 if (normCentral->GetBinContent(i) > 0) {
321 cCentral = dndetaCentral->GetBinContent(i);
322 e2Central = dndetaCentral->GetBinError(i) * dndetaCentral->GetBinError(i);
326 if (cCentral > 0 && cForward > 0) {
327 cc = 0.5 * (cForward + cCentral);
328 ee2 = 0.5 * (e2Forward + e2Central);
330 else if (cCentral > 0) {
334 else if (cForward > 0) {
342 // retreive MC particles from event
343 TClonesArray* mcArray = (TClonesArray*)aodevent.FindListObject(AliAODMCParticle::StdBranchName());
345 AliWarning("No MC array found in AOD. Try making it again.");
348 AliAODMCHeader* header =
349 dynamic_cast<AliAODMCHeader*>(aodevent.
350 FindListObject(AliAODMCHeader::StdBranchName()));
352 AliWarning("No header file found.");
357 Int_t ntracks = mcArray->GetEntriesFast();
358 // Track loop: find MC truth multiplicity in selected eta bin
360 for (Int_t it = 0; it < ntracks; it++) {
361 AliAODMCParticle* particle = (AliAODMCParticle*)mcArray->At(it);
363 AliError(Form("Could not receive track %d", it));
366 if (!particle->IsPhysicalPrimary()) continue;
367 if (particle->Charge() == 0) continue;
368 if(particle->Eta()>fEtaLow&&particle->Eta()<fEtaHigh-0.0001)
371 //fill fMCNSD with multiplicity of MC truth NSD events with MC truth |vtxz|<4
372 if(header->GetVtxZ()>-4&&header->GetVtxZ()<4){
377 //fill fESDNSD with multiplicity from events with a reconstructed NSD trigger and reconstructed |vtxz|<4
383 // fullfilling both requirements of fMCNSD and fESDNSD
384 if(header->GetVtxZ()>-4&&header->GetVtxZ()<4&&VtxZ>-4&&VtxZ<4&&isMCNSD&&isESDNSD){
385 fMCESDNSD->Fill(mult);
390 //Systematic errors from here
396 // number of eta bins in fmd, spd and overlap respectively
397 for(Int_t i = first;i<=last;i++){
398 if(normForward->GetBinContent(i)>0&&normCentral->GetBinContent(i)<1)
400 if(normForward->GetBinContent(i)>0&&normCentral->GetBinContent(i)>0)
402 if(normCentral->GetBinContent(i)>0&&normForward->GetBinContent(i)<1)
406 Double_t sysErrorSquared = 0;
408 // estimate of systematic uncertainty on the event multiplicity - hardcoded :(. estimates taken from Hans Hjersing Dalsgaard or Casper Nygaard phd theses.
409 Double_t fmdSysError= 0.08;
410 Double_t spdSysError= 0.04;
412 total= fmd + spd + overlap;
414 // Combined systematc event uncertainty, by weighting with the number of eta-bins of fmd-only, spd-only and the overlap.
415 sysErrorSquared= (fmd*TMath::Power(fmdSysError,2)+ spd*TMath::Power(spdSysError,2)+
416 0.5*overlap*TMath::Power(fmdSysError,2)+ 0.5*overlap*TMath::Power(spdSysError,2))/total;
422 fHistMC->Fill(cPrimary);
423 fResponseMatrix->Fill(cPrimary, c);
424 fResponseMatrixPlusSys->Fill(cPrimary,(1+TMath::Sqrt(sysErrorSquared))*c);
425 fResponseMatrixMinusSys->Fill(cPrimary,(1-TMath::Sqrt(sysErrorSquared))*c);
426 fResponseMatrixPlus05->Fill(cPrimary, 1.05*c);
427 fResponseMatrixPlus075->Fill(cPrimary, 1.075*c);
428 fResponseMatrixPlus10->Fill(cPrimary, 1.1*c);
429 fResponseMatrixMinus05->Fill(cPrimary, 0.95*c);
430 fResponseMatrixMinus075->Fill(cPrimary, 0.925*c);
431 fResponseMatrixMinus10->Fill(cPrimary, 0.9*c);
440 //_____________________________________________________________________