3 #include "AliForwardCreateResponseMatrices.h"
4 #include "AliForwardMultiplicityDistribution.h"
5 #include "AliAODForwardMult.h"
6 #include "AliAODCentralMult.h"
7 #include "AliAODEvent.h"
8 #include "AliFMDMCEventInspector.h"
9 #include "AliAODMCHeader.h"
10 #include "AliAODMCParticle.h"
14 ClassImp(AliForwardCreateResponseMatrices)
16 ; // This is for Emacs - do not delete
18 //_____________________________________________________________________
19 AliForwardCreateResponseMatrices::AliForwardCreateResponseMatrices()
20 : AliBasedNdetaTask(),
26 // Default Constructor
30 //_____________________________________________________________________
31 AliForwardCreateResponseMatrices::AliForwardCreateResponseMatrices(const char* name)
32 : AliBasedNdetaTask(name),
40 DefineOutput(1, TList::Class());
43 //_____________________________________________________________________
44 void AliForwardCreateResponseMatrices::UserCreateOutputObjects()
47 // Create Output Objects
51 fOutput->SetName(GetName());
53 TH1D* dndetaSumForward = new TH1D("dndetaSumForward","dndetaSumForward", 200,-4,6);
54 TH1D* dndetaSumCentral = new TH1D("dndetaSumCentral","dndetaSumCentral", 200,-4,6);
55 TH1D* dndetaSumMC = new TH1D("dndetaSumMC","dndetaSumMC", 200,-4,6);
57 fOutput->Add(dndetaSumForward);
58 fOutput->Add(dndetaSumCentral);
59 fOutput->Add(dndetaSumMC);
61 TH1D* dndetaEventForward = new TH1D();
62 TH1D* dndetaEventCentral = new TH1D();
63 TH1D* dndetaEventMC = new TH1D();
65 fOutput->Add(dndetaEventForward);
66 fOutput->Add(dndetaEventCentral);
67 fOutput->Add(dndetaEventMC);
69 // make trigger diagnostics histogram
71 fTrigger= AliAODForwardMult::MakeTriggerHistogram("triggerHist");
72 fOutput->Add(fTrigger);
75 //Loop over all individual eta bins, and define their hisograms
78 while ((bin = static_cast<Bin*>(next()))) {
79 bin->CreateOutputObjectss(fOutput, 400);
87 //_____________________________________________________________________
88 void AliForwardCreateResponseMatrices::UserExec(Option_t */*option*/)
93 AliAODEvent* aod = dynamic_cast<AliAODEvent*>(InputEvent());
95 AliError("Cannot get the AOD event");
97 AliAODForwardMult* AODforward = static_cast<AliAODForwardMult*>(aod->FindListObject("Forward"));
99 AliError("Cannot get the AODforwardMult object");
102 // Check the AOD event
103 Bool_t selectedTrigger = AODforward->CheckEvent(fTriggerMask, fVtxMin, fVtxMax,0,0,fTrigger);
109 // Get 2D eta-phi histograms for each event
110 GetHistograms(aod, forward, central);
112 //check if event is NSD according to either MC truth or analysis (ESD)
113 Bool_t isMCNSD=kFALSE;
114 Bool_t isESDNSD=kFALSE;
115 if(AODforward->IsTriggerBits(AliAODForwardMult::kMCNSD))
117 if(AODforward->IsTriggerBits(AliAODForwardMult::kNSD))
120 //primary dndeta dist
122 TObject* oPrimary = aod->FindListObject("primary");
123 primHist = static_cast<TH2D*>(oPrimary);
125 TH1D* dndetaSumForward = (TH1D*)fOutput->FindObject("dndetaSumForward");
126 TH1D* dndetaSumCentral = (TH1D*)fOutput->FindObject("dndetaSumCentral");
127 TH1D* dndetaSumMC = (TH1D*)fOutput->FindObject("dndetaSumMC");
128 TH1D* dndetaEventForward = (TH1D*)fOutput->FindObject("dndetaEventForward");
129 TH1D* dndetaEventCentral = (TH1D*)fOutput->FindObject("dndetaEventCentral");
130 TH1D* dndetaEventMC = (TH1D*)fOutput->FindObject("dndetaEventMC");
132 dndetaEventForward = forward.ProjectionX("dndetaForward",1,forward.GetNbinsY(),"");
133 dndetaEventCentral = central.ProjectionX("dndetaCentral",1,central.GetNbinsY(),"");
134 dndetaEventMC = primHist->ProjectionX("dndetaMC",1,primHist->GetNbinsY(),"");
136 // underflow eta bin of forward/central carry information on whether
137 // there is acceptance. 1= acceptance, 0= no acceptance
138 TH1D* normEventForward = 0;
139 TH1D* normEventCentral = 0;
140 // TH1D* normEventMC = 0;
141 normEventForward = forward.ProjectionX("dndetaEventForwardNorm",0,0,"");
142 normEventCentral = central.ProjectionX("dndetaEventCentralNorm",0,0,"");
143 // normEventMC = primHist->ProjectionX("dndetaEventNormMC",0,0,"");
145 dndetaSumForward->Add(dndetaEventForward);
146 dndetaSumCentral->Add(dndetaEventCentral);
147 dndetaSumMC->Add(dndetaEventMC);
150 Double_t VtxZ = AODforward->GetIpZ();
152 // loop over all eta bins, and create response matrices,
153 // trigger-vertex bias histograms etc
156 while ((bin = static_cast<Bin*>(next()))) {
157 bin->Process(dndetaEventForward, dndetaEventCentral,
158 normEventForward, normEventCentral,
159 dndetaEventMC, VtxZ, selectedTrigger,
160 isMCNSD, isESDNSD, aod);
163 PostData(1, fOutput);
168 //_____________________________________________________________________
169 void AliForwardCreateResponseMatrices::Terminate(Option_t */*option*/)
176 //_________________________________________________________________-
177 TH2D* AliForwardCreateResponseMatrices::GetHistogram(const AliAODEvent*, Bool_t )
180 // implementation of pure virtual function, always returning 0
185 void AliForwardCreateResponseMatrices::GetHistograms(const AliAODEvent* aod, TH2D& forward, TH2D& central)
188 // Get single event forward and central d²N/dEta dPhi histograms
190 TObject* forwardObj = 0;
191 TObject* centralObj = 0;
193 forwardObj = aod->FindListObject("ForwardMC");
194 centralObj = aod->FindListObject("CentralClusters");
197 AliWarning("No MC forward object found in AOD");
200 AliWarning("No MC central object found in AOD");
203 AliAODForwardMult* AODforward = static_cast<AliAODForwardMult*>(forwardObj);
204 AliAODCentralMult* AODcentral = static_cast<AliAODCentralMult*>(centralObj);
206 forward= AODforward->GetHistogram();
207 central= AODcentral->GetHistogram();
213 //=====================================================================
214 AliForwardCreateResponseMatrices::Bin::Bin(Double_t etaLow, Double_t etaHigh)
216 fEtaLow(etaLow), // low eta limit
217 fEtaHigh(etaHigh), // high eta limit
218 fHist(), // multiplicity histogram
219 fHistMC(), // multiplicity histogram MC truth primaries
220 fAcceptance(), // histogram showing the 'holes' in acceptance. BinContent of 1 shows a hole, and BinContent of 10 shows data coverage
221 fVtxZvsNdataBins(), // VtxZ vs. number of data acceptance bins (normalised to the eta range)
222 fResponseMatrix(), // Response matrix (MC truth vs. analysed multiplicity)
223 fResponseMatrixPlus05(), // Response matrix with analysed multiplicity scaled up by 5%
224 fResponseMatrixPlus075(), // Response matrix with analysed multiplicity scaled up by 7.5%
225 fResponseMatrixPlus10(), // Response matrix with analysed multiplicity scaled up by 10%
226 fResponseMatrixMinus05(), // Response matrix with analysed multiplicity scaled down by 5%
227 fResponseMatrixMinus075(),// Response matrix with analysed multiplicity scaled down by 7.55%
228 fResponseMatrixMinus10(), // Response matrix with analysed multiplicity scaled down by 10%
229 fResponseMatrixMinusSys(),// Response matrix with analysed multiplicity scaled up by event mult uncertainty
230 fResponseMatrixPlusSys(), // Response matrix with analysed multiplicity scaled down by event mult uncertainty
231 fESDNSD(), // number of events found as NSD by the analysis vs. multiplicity
232 fMCNSD(), // number of events found as NSD by the MC truth vs. multiplicity
233 fMCESDNSD(), // number of events found as NSD by both analysis and MC truth vs. multiplicity
234 fTriggerBias() // histogram for trigger vertex bias correction
239 const char* name = AliForwardMultiplicityDistribution::FormBinName(etaLow,etaHigh);
242 SetTitle(Form("%+4.1f < #eta < %+4.1f", fEtaLow, fEtaHigh));
245 //_____________________________________________________________________
246 AliForwardCreateResponseMatrices::Bin::Bin()
248 fEtaLow(), // low eta limit
249 fEtaHigh(), // high eta limit
250 fHist(), // multiplicity histogram
251 fHistMC(), // multiplicity histogram MC truth primaries
252 fAcceptance(), // histogram showing the 'holes' in acceptance. BinContent of 1 shows a hole, and BinContent of 10 shows data coverage
253 fVtxZvsNdataBins(), // VtxZ vs. number of data acceptance bins (normalised to the eta range)
254 fResponseMatrix(), // Response matrix (MC truth vs. analysed multiplicity)
255 fResponseMatrixPlus05(), // Response matrix with analysed multiplicity scaled up by 5%
256 fResponseMatrixPlus075(), // Response matrix with analysed multiplicity scaled up by 7.5%
257 fResponseMatrixPlus10(), // Response matrix with analysed multiplicity scaled up by 10%
258 fResponseMatrixMinus05(), // Response matrix with analysed multiplicity scaled down by 5%
259 fResponseMatrixMinus075(),// Response matrix with analysed multiplicity scaled down by 7.55%
260 fResponseMatrixMinus10(), // Response matrix with analysed multiplicity scaled down by 10%
261 fResponseMatrixMinusSys(),// Response matrix with analysed multiplicity scaled up by event mult uncertainty
262 fResponseMatrixPlusSys(), // Response matrix with analysed multiplicity scaled down by event mult uncertainty
263 fESDNSD(), // number of events found as NSD by the analysis vs. multiplicity
264 fMCNSD(), // number of events found as NSD by the MC truth vs. multiplicity
265 fMCESDNSD(), // number of events found as NSD by both analysis and MC truth vs. multiplicity
266 fTriggerBias() // histogram for trigger vertex bias correction
269 // Default Constructor
272 //_____________________________________________________________________
273 void AliForwardCreateResponseMatrices::Bin::CreateOutputObjectss(TList* cont, Int_t max)
276 // Define eta bin output histos
278 TList* out = new TList;
279 out->SetName(GetName());
282 fHist = new TH1D("mult", GetTitle(), max, -0.5, max-.5);
283 fHistMC = new TH1D("multTruth", GetTitle(), max, -0.5, max-.5);
284 fVtxZvsNdataBins = new TH2D("VtxZvsNdataBins", "VtxZ vs dataAcceptance/etaRange;z-vtz;dataAcceptance/etaRange", 20, -10,10, 130,0,1.3);
285 fAcceptance = new TH2D("Acceptance","Acceptance;#eta;z-vtx",200,-4, 6 , 20,-10,10);
286 fResponseMatrix = new TH2D("responseMatrix","Response Matrix;MC_{truth};MC_{measured}", max, -0.5, max-.5, max, -0.5, max-.5);
287 fResponseMatrixPlus05 = new TH2D("responseMatrixPlus05","Response Matrix;MC_{truth};MC_{measured}", max, -0.5, max-.5, max, -0.5, max-.5);
288 fResponseMatrixPlus075 = new TH2D("responseMatrixPlus075","Response Matrix;MC_{truth};MC_{measured}", max, -0.5, max-.5, max, -0.5, max-.5);
289 fResponseMatrixPlus10 = new TH2D("responseMatrixPlus10","Response Matrix;MC_{truth};MC_{measured}", max, -0.5, max-.5, max, -0.5, max-.5);
290 fResponseMatrixMinus05 = new TH2D("responseMatrixMinus05","Response Matrix;MC_{truth};MC_{measured}", max, -0.5, max-.5, max, -0.5, max-.5);
291 fResponseMatrixMinus075 = new TH2D("responseMatrixMinus075","Response Matrix;MC_{truth};MC_{measured}", max, -0.5, max-.5, max, -0.5, max-.5);
292 fResponseMatrixMinus10 = new TH2D("responseMatrixMinus10","Response Matrix;MC_{truth};MC_{measured}", max, -0.5, max-.5, max, -0.5, max-.5);
293 fResponseMatrixMinusSys = new TH2D("responseMatrixMinusSys","Response Matrix;MC_{truth};MC_{measured}", max, -0.5, max-.5, max, -0.5, max-.5);
294 fResponseMatrixPlusSys = new TH2D("responseMatrixPlusSys","Response Matrix;MC_{truth};MC_{measured}", max, -0.5, max-.5, max, -0.5, max-.5);
295 fTriggerBias = new TH1D("triggerBias","triggerBias;MC_{truth};Correction}", max, -0.5, max-.5);
296 fMCNSD = new TH1D("fMCNSD","fMCNSD", 300,-0.5,299.5);
297 fESDNSD = new TH1D("fESDNSD","fESDNSD", 300,-0.5,299.5);
298 fMCESDNSD = new TH1D("fMCESDNSD","fMCESDNSD", 300,-0.5,299.5);
305 out->Add(fVtxZvsNdataBins);
306 out->Add(fAcceptance);
307 out->Add(fResponseMatrix);
308 out->Add(fResponseMatrixPlus05);
309 out->Add(fResponseMatrixPlus075);
310 out->Add(fResponseMatrixPlus10);
311 out->Add(fResponseMatrixMinus05);
312 out->Add(fResponseMatrixMinus075);
313 out->Add(fResponseMatrixMinus10);
314 out->Add(fResponseMatrixPlusSys);
315 out->Add(fResponseMatrixMinusSys);
316 out->Add(fTriggerBias);
321 //_____________________________________________________________________
322 void AliForwardCreateResponseMatrices::Bin::Process(TH1D* dndetaForward, TH1D* dndetaCentral,
323 TH1D* normForward, TH1D* normCentral, TH1D* mc, Double_t VtxZ, Bool_t selectedTrigger, Bool_t isMCNSD, Bool_t isESDNSD, AliAODEvent* aodevent)
326 // Process a single eta bin
329 // Diagnostics on event acceptance
330 Int_t first = dndetaForward->GetXaxis()->FindBin(fEtaLow);
331 Int_t last = dndetaForward->GetXaxis()->FindBin(fEtaHigh-.0001);
332 Double_t acceptanceBins=0;
333 for(Int_t n= first;n<=last;n++){
334 if(normForward->GetBinContent(n)>0||normCentral->GetBinContent(n)>0){
337 fAcceptance->SetBinContent(n, fAcceptance->GetYaxis()->FindBin(VtxZ), 1);
338 if(normForward->GetBinContent(n)>0||normCentral->GetBinContent(n)>0)
339 fAcceptance->SetBinContent(n, fAcceptance->GetYaxis()->FindBin(VtxZ),10);
341 fVtxZvsNdataBins->Fill(VtxZ, (Double_t)acceptanceBins/(last-first+1));
347 Double_t cPrimary = 0;
348 Double_t e2Primary= 0;
350 for (Int_t i = first; i <= last; i++){
351 Double_t cForward = 0;
352 Double_t cCentral = 0;
353 Double_t e2Forward = 0;
354 Double_t e2Central = 0;
357 cMC= mc->GetBinContent(i);
358 e2MC= mc->GetBinError(i) * mc->GetBinError(i);
361 if (normForward->GetBinContent(i) > 0) {
362 cForward = dndetaForward->GetBinContent(i);
363 e2Forward = dndetaForward->GetBinError(i) * dndetaForward->GetBinError(i);
365 if (normCentral->GetBinContent(i) > 0) {
366 cCentral = dndetaCentral->GetBinContent(i);
367 e2Central = dndetaCentral->GetBinError(i) * dndetaCentral->GetBinError(i);
371 if (cCentral > 0 && cForward > 0) {
372 cc = 0.5 * (cForward + cCentral);
373 ee2 = 0.5 * (e2Forward + e2Central);
375 else if (cCentral > 0) {
379 else if (cForward > 0) {
387 //retreive MC particles from event
388 TClonesArray* mcArray = (TClonesArray*)aodevent->FindListObject(AliAODMCParticle::StdBranchName());
390 AliWarning("No MC array found in AOD. Try making it again.");
393 AliAODMCHeader* header = dynamic_cast<AliAODMCHeader*>(aodevent->FindListObject(AliAODMCHeader::StdBranchName()));
395 AliWarning("No header file found.");
399 Int_t ntracks = mcArray->GetEntriesFast();
400 // Track loop: find MC truth multiplicity in selected eta bin
402 for (Int_t it = 0; it < ntracks; it++) {
403 AliAODMCParticle* particle = (AliAODMCParticle*)mcArray->At(it);
405 AliError(Form("Could not receive track %d", it));
408 if (!particle->IsPhysicalPrimary()) continue;
409 if (particle->Charge() == 0) continue;
410 if(particle->Eta()>fEtaLow&&particle->Eta()<fEtaHigh-0.0001)
413 //fill fMCNSD with multiplicity of MC truth NSD events with MC truth |vtxz|<4
414 if(header->GetVtxZ()>-4&&header->GetVtxZ()<4){
419 //fill fESDNSD with multiplicity from events with a reconstructed NSD trigger and reconstructed |vtxz|<4
425 // fullfilling both requirements of fMCNSD and fESDNSD
426 if(header->GetVtxZ()>-4&&header->GetVtxZ()<4&&VtxZ>-4&&VtxZ<4&&isMCNSD&&isESDNSD){
427 fMCESDNSD->Fill(mult);
432 //Systematic errors from here
438 // number of eta bins in fmd, spd and overlap respectively
439 for(Int_t i = first;i<=last;i++){
440 if(normForward->GetBinContent(i)>0&&normCentral->GetBinContent(i)<1)
442 if(normForward->GetBinContent(i)>0&&normCentral->GetBinContent(i)>0)
444 if(normCentral->GetBinContent(i)>0&&normForward->GetBinContent(i)<1)
448 Double_t sysErrorSquared = 0;
450 // estimate of systematic uncertainty on the event multiplicity - hardcoded :(. estimates taken from Hans Hjersing Dalsgaard or Casper Nygaard phd theses.
451 Double_t fmdSysError= 0.08;
452 Double_t spdSysError= 0.04;
454 total= fmd + spd + overlap;
456 // Combined systematc event uncertainty, by weighting with the number of eta-bins of fmd-only, spd-only and the overlap.
457 sysErrorSquared= (fmd*TMath::Power(fmdSysError,2)+ spd*TMath::Power(spdSysError,2)+
458 0.5*overlap*TMath::Power(fmdSysError,2)+ 0.5*overlap*TMath::Power(spdSysError,2))/total;
464 fHistMC->Fill(cPrimary);
465 fResponseMatrix->Fill(cPrimary, c);
466 fResponseMatrixPlusSys->Fill(cPrimary,(1+TMath::Sqrt(sysErrorSquared))*c);
467 fResponseMatrixMinusSys->Fill(cPrimary,(1-TMath::Sqrt(sysErrorSquared))*c);
468 fResponseMatrixPlus05->Fill(cPrimary, 1.05*c);
469 fResponseMatrixPlus075->Fill(cPrimary, 1.075*c);
470 fResponseMatrixPlus10->Fill(cPrimary, 1.1*c);
471 fResponseMatrixMinus05->Fill(cPrimary, 0.95*c);
472 fResponseMatrixMinus075->Fill(cPrimary, 0.925*c);
473 fResponseMatrixMinus10->Fill(cPrimary, 0.9*c);
482 //_____________________________________________________________________