1 #include "AliAnalysisMuMuMinv.h"
5 * \ingroup pwg-muon-mumu
7 * \class AliAnalysisMuMuMinv
9 * Analysis which fills a bunch of histograms for invariant mass analysis of J/psi
11 * Can be used on real data and/or simulated (for instance to get Acc x Eff)
13 * Can optionally use as input an already computed Acc x Eff matrix that will be applied
14 * when filling the invariant mass histograms.
20 #include "TObjArray.h"
21 #include "AliAnalysisMuMuBinning.h"
23 #include "TLorentzVector.h"
25 #include "AliMCEvent.h"
26 #include "AliMergeableCollection.h"
27 #include "AliAnalysisMuonUtility.h"
28 #include "TParameter.h"
31 ClassImp(AliAnalysisMuMuMinv)
33 //_____________________________________________________________________________
34 AliAnalysisMuMuMinv::AliAnalysisMuMuMinv(TH2* accEffHisto, Bool_t computeMeanPt, Int_t systLevel)
35 : AliAnalysisMuMuBase(),
36 fcomputeMeanPt(computeMeanPt),
40 // FIXME : find the AccxEff histogram from HistogramCollection()->Histo("/EXCHANGE/JpsiAccEff")
44 fAccEffHisto = static_cast<TH2F*>(accEffHisto->Clone());
45 fAccEffHisto->SetDirectory(0);
49 //_____________________________________________________________________________
50 AliAnalysisMuMuMinv::~AliAnalysisMuMuMinv()
56 //_____________________________________________________________________________
58 AliAnalysisMuMuMinv::DefineHistogramCollection(const char* eventSelection,
59 const char* triggerClassName,
60 const char* centrality)
62 /// Define the histograms this analysis will use
64 if ( Histo(eventSelection,triggerClassName,centrality,"AliAnalysisMuMuMinv") )
69 // dummy histogram to signal that we already defined all our histograms (see above)
70 CreateEventHistos(kHistoForData | kHistoForMCInput,eventSelection,triggerClassName,centrality,"AliAnalysisMuMuMinv","Dummy semaphore",1,0,1);
72 /// Create invariant mass histograms
75 Double_t minvMax = 16;
76 Int_t nMinvBins = GetNbins(minvMin,minvMax,0.025);
78 Int_t nMCMinvBins = GetNbins(minvMin,minvMax,0.1);
80 Double_t rapidityMin = -5;
81 Double_t rapidityMax = -2;
82 Int_t nbinsRapidity = GetNbins(rapidityMin,rapidityMax,0.05);
86 Int_t nbinsEta = GetNbins(etaMin,etaMax,0.05);
88 TObjArray* bins = Binning()->CreateBinObjArray("psi","integrated,ptvsy,yvspt,pt,y,phi,nch,dnchdeta,ntrcorr,ntrcorrpt,ntrcorry,relntrcorr","");//We may include ,v0a,v0acent
90 CreatePairHistos(kHistoForData | kHistoForMCInput,eventSelection,triggerClassName,centrality,"Pt","#mu+#mu- Pt distribution",
93 CreatePairHistos(kHistoForData | kHistoForMCInput,eventSelection,triggerClassName,centrality,"Y","#mu+#mu- Y distribution",
94 nbinsRapidity,rapidityMin,rapidityMax,-2);
96 CreatePairHistos(kHistoForData | kHistoForMCInput,eventSelection,triggerClassName,centrality,"Eta","#mu+#mu- Eta distribution",
97 nbinsEta,etaMin,etaMax);
100 //___Histos for pure MC
101 CreateEventHistos(kHistoForMCInput,eventSelection,triggerClassName,centrality,"Pt","MCINPUT #mu+#mu- Pt distribution",
104 CreateEventHistos(kHistoForMCInput,eventSelection,triggerClassName,centrality,"Y","MCINPUT #mu+#mu- Y distribution",
105 nbinsRapidity,rapidityMin,rapidityMax,-2);
107 CreateEventHistos(kHistoForMCInput,eventSelection,triggerClassName,centrality,"Eta","MCINPUT #mu+#mu- Eta distribution",
108 nbinsEta,etaMin,etaMax);
110 CreateEventHistos(kHistoForMCInput,eventSelection,triggerClassName,Form("%s/INYRANGE",centrality),"Pt","MCINPUT #mu+#mu- Pt distribution",
113 CreateEventHistos(kHistoForMCInput,eventSelection,triggerClassName,Form("%s/INYRANGE",centrality),"Y","MCINPUT #mu+#mu- Y distribution",
114 nbinsRapidity,rapidityMin,rapidityMax,-2);
116 CreateEventHistos(kHistoForMCInput,eventSelection,triggerClassName,Form("%s/INYRANGE",centrality),"Eta","MCINPUT #mu+#mu- Eta distribution",
117 nbinsEta,etaMin,etaMax);
120 // CreatePairHistos(eventSelection,triggerClassName,centrality,"BinFlowPt","#mu+#mu- BinFlowPt distribution",
123 CreatePairHistos(kHistoForData,eventSelection,triggerClassName,centrality,"PtRecVsSim","#mu+#mu- Pt distribution rec vs sim",
127 AliAnalysisMuMuBinning::Range* r;
130 while ( ( r = static_cast<AliAnalysisMuMuBinning::Range*>(next()) ) )
132 TString minvName(GetMinvHistoName(*r,kFALSE));
136 if ( !IsHistogramDisabled(minvName.Data()) )
139 AliDebug(1,Form("bin %d %s histoname = %s",nb,r->AsString().Data(),minvName.Data()));
141 CreatePairHistos(kHistoForData | kHistoForMCInput,eventSelection,triggerClassName,centrality,minvName.Data(),
142 Form("#mu+#mu- inv. mass %s;M_{#mu^{+}#mu^{-}} (GeV/c^2);Counts",
143 r->AsString().Data()),
144 nMinvBins,minvMin,minvMax,-2);
146 CreateEventHistos(kHistoForMCInput,eventSelection,triggerClassName,centrality,minvName.Data(),
147 Form("MCINPUT #mu+#mu- inv. mass %s;M_{#mu^{+}#mu^{-}} (GeV/c^2);Counts",
148 r->AsString().Data()),
149 nMCMinvBins,minvMin,minvMax,-2); // Pure MC histo
151 CreateEventHistos(kHistoForMCInput,eventSelection,triggerClassName,Form("%s/INYRANGE",centrality),minvName.Data(),
152 Form("MCINPUT #mu+#mu- inv. mass %s;M_{#mu^{+}#mu^{-}} (GeV/c^2);Counts",
153 r->AsString().Data()),
154 nMCMinvBins,minvMin,minvMax,-2); // Pure MC histo
157 if ( fcomputeMeanPt )
159 TString mPtName(Form("MeanPtVs%s",minvName.Data()));
160 CreatePairHistos(kHistoForData | kHistoForMCInput,eventSelection,triggerClassName,centrality,mPtName.Data(),
161 Form("#mu+#mu- mean p_{T} %s;M_{#mu^{+}#mu^{-}} (GeV/c^2);<p_{T}^{#mu^{+}#mu^{-} (GeV/c^2)}>",
162 r->AsString().Data()),
163 nMinvBins,minvMin,minvMax,0);
165 CreateEventHistos(kHistoForMCInput,eventSelection,triggerClassName,centrality,mPtName.Data(),
166 Form("#mu+#mu- mean p_{T} %s;M_{#mu^{+}#mu^{-}} (GeV/c^2);<p_{T}^{#mu^{+}#mu^{-} (GeV/c^2)}>",
167 r->AsString().Data()),
168 nMinvBins,minvMin,minvMax,0); //Pure MC Histo
170 CreateEventHistos(kHistoForMCInput,eventSelection,triggerClassName,Form("%s/INYRANGE",centrality),mPtName.Data(),
171 Form("#mu+#mu- mean p_{T} %s;M_{#mu^{+}#mu^{-}} (GeV/c^2);<p_{T}^{#mu^{+}#mu^{-} (GeV/c^2)}>",
172 r->AsString().Data()),
173 nMinvBins,minvMin,minvMax,0); //Pure MC Histo
178 // TH1* h = new TH1F(minvName.Data(),Form("MC #mu+#mu- inv. mass %s",r->AsString().Data()),
179 // nMCMinvBins,minvMin,minvMax);
181 // HistogramCollection()->Adopt(Form("/%s/ALL",MCInputPrefix()),h);
183 // HistogramCollection()->Adopt(Form("/%s/INYRANGE",MCInputPrefix()),static_cast<TH1*>(h->Clone()));
187 if ( ShouldCorrectDimuonForAccEff() )
189 minvName = GetMinvHistoName(*r,kTRUE);
191 if ( !IsHistogramDisabled(minvName.Data()) )
194 AliDebug(1,Form("bin %d %s histoname = %s",nb,r->AsString().Data(),minvName.Data()));
196 CreatePairHistos(kHistoForData | kHistoForMCInput,eventSelection,triggerClassName,centrality,minvName.Data(),
197 Form("#mu+#mu- inv. mass %s (Acc #times Eff Corrected);M_{#mu^{+}#mu^{-}}(GeV/c^2);Counts",
198 r->AsString().Data()),
199 nMinvBins,minvMin,minvMax,-2);
201 CreateEventHistos(kHistoForMCInput,eventSelection,triggerClassName,centrality,minvName.Data(),
202 Form("#mu+#mu- inv. mass %s (Acc #times Eff Corrected);M_{#mu^{+}#mu^{-}} (GeV/c^2);Counts",
203 r->AsString().Data()),
204 nMCMinvBins,minvMin,minvMax,-2); // Pure MC histo
206 CreateEventHistos(kHistoForMCInput,eventSelection,triggerClassName,Form("%s/INYRANGE",centrality),minvName.Data(),
207 Form("#mu+#mu- inv. mass %s (Acc #times Eff Corrected);M_{#mu^{+}#mu^{-}} (GeV/c^2);Counts",
208 r->AsString().Data()),
209 nMCMinvBins,minvMin,minvMax,-2); // Pure MC histo
211 if ( fcomputeMeanPt )
213 TString mPtName(Form("MeanPtVs%s",minvName.Data()));
214 CreatePairHistos(kHistoForData | kHistoForMCInput,eventSelection,triggerClassName,centrality,mPtName.Data(),
215 Form("#mu+#mu- mean p_{T} %s (Acc #times Eff Corrected);M_{#mu^{+}#mu^{-}} (GeV/c^2);<p_{T}^{#mu^{+}#mu^{-}}>",
216 r->AsString().Data()),
217 nMinvBins,minvMin,minvMax,0);
222 // TH1* h = new TH1F(minvName.Data(),Form("MC #mu+#mu- inv. mass %s",r->AsString().Data()),
223 // nMCMinvBins,minvMin,minvMax);
227 // HistogramCollection()->Adopt(Form("/%s/ALL",MCInputPrefix()),h);
229 // HistogramCollection()->Adopt(Form("/%s/INYRANGE",MCInputPrefix()),static_cast<TH1*>(h->Clone()));
238 //_____________________________________________________________________________
239 void AliAnalysisMuMuMinv::FillHistosForPair(const char* eventSelection, const char* triggerClassName,
240 const char* centrality, const char* pairCutName,
241 const AliVParticle& tracki,
242 const AliVParticle& trackj)
245 TLorentzVector pi(tracki.Px(),tracki.Py(),tracki.Pz(),
246 TMath::Sqrt(AliAnalysisMuonUtility::MuonMass2()+tracki.P()*tracki.P()));
248 if (!AliAnalysisMuonUtility::IsMuonTrack(&tracki) ) return;
249 if (!AliAnalysisMuonUtility::IsMuonTrack(&trackj) ) return;
251 TLorentzVector pair4Momentum(trackj.Px(),trackj.Py(),trackj.Pz(),
252 TMath::Sqrt(AliAnalysisMuonUtility::MuonMass2()+trackj.P()*trackj.P()));
257 //// if (!IsHistogramDisabled("Chi12"))
259 //// Histo(eventSelection,triggerClassName,centrality,pairCutName,"Chi12")
261 //// AliAnalysisMuonUtility::GetChi2perNDFtracker(&tracki),
262 //// AliAnalysisMuonUtility::GetChi2perNDFtracker(&trackj));
265 //// if (!IsHistogramDisabled("Rabs12"))
267 //// Histo(eventSelection,triggerClassName,centrality,pairCutName,"Rabs12")
268 //// ->Fill(AliAnalysisMuonUtility::GetRabs(&tracki),
269 //// AliAnalysisMuonUtility::GetRabs(&trackj));
272 if ( ( tracki.Charge() != trackj.Charge() ) )
274 Double_t inputWeight = WeightDistribution(pair4Momentum.Pt(),pair4Momentum.Rapidity());
276 if ( !IsHistogramDisabled("Pt") )
278 Histo(eventSelection,triggerClassName,centrality,pairCutName,"Pt")->Fill(pair4Momentum.Pt(),inputWeight);
280 if ( !IsHistogramDisabled("Y") )
282 Histo(eventSelection,triggerClassName,centrality,pairCutName,"Y")->Fill(pair4Momentum.Rapidity(),inputWeight);
284 if ( !IsHistogramDisabled("Eta") )
286 Histo(eventSelection,triggerClassName,centrality,pairCutName,"Eta")->Fill(pair4Momentum.Eta());
289 TLorentzVector* pair4MomentumMC(0x0);
290 Double_t inputWeightMC(1.);
293 Int_t labeli = tracki.GetLabel();
294 Int_t labelj = trackj.GetLabel();
296 if ( labeli < 0 || labelj < 0 )
298 AliError("Got negative labels!");
302 AliVParticle* mcTracki = MCEvent()->GetTrack(labeli);
303 AliVParticle* mcTrackj = MCEvent()->GetTrack(labelj);
305 TLorentzVector mcpi(mcTracki->Px(),mcTracki->Py(),mcTracki->Pz(),
306 TMath::Sqrt(AliAnalysisMuonUtility::MuonMass2()+mcTracki->P()*mcTracki->P()));
307 TLorentzVector mcpj(mcTrackj->Px(),mcTrackj->Py(),mcTrackj->Pz(),
308 TMath::Sqrt(AliAnalysisMuonUtility::MuonMass2()+mcTrackj->P()*mcTrackj->P()));
312 inputWeightMC = WeightDistribution(mcpj.Pt(),mcpj.Rapidity());
314 Histo(eventSelection,triggerClassName,centrality,pairCutName,"PtRecVsSim")->Fill(mcpj.Pt(),pair4Momentum.Pt());
316 if ( !IsHistogramDisabled("Pt") )
318 MCHisto(eventSelection,triggerClassName,centrality,pairCutName,"Pt")->Fill(mcpj.Pt(),inputWeightMC);
320 if ( !IsHistogramDisabled("Y") )
322 MCHisto(eventSelection,triggerClassName,centrality,pairCutName,"Y")->Fill(mcpj.Rapidity(),inputWeightMC);
324 if ( !IsHistogramDisabled("Eta") )
326 MCHisto(eventSelection,triggerClassName,centrality,pairCutName,"Eta")->Fill(mcpj.Eta());
328 pair4MomentumMC = &mcpj;
334 TObjArray* bins = Binning()->CreateBinObjArray("psi","integrated,ptvsy,yvspt,pt,y,phi,nch,dnchdeta,ntrcorr,ntrcorrpt,ntrcorry,relntrcorr",""); // We may include: ,v0a,v0acent
336 AliAnalysisMuMuBinning::Range* r;
338 while ( ( r = static_cast<AliAnalysisMuMuBinning::Range*>(nextBin()) ) )
343 if ( r->IsIntegrated() )
346 if ( pair4MomentumMC ) okMC = kTRUE;
348 else if ( r->Is2D() )
350 if ( r->AsString().BeginsWith("PTVSY") )
352 ok = r->IsInRange(pair4Momentum.Rapidity(),pair4Momentum.Pt());
353 if ( pair4MomentumMC ) okMC = r->IsInRange(pair4MomentumMC->Rapidity(),pair4MomentumMC->Pt());
355 else if ( r->AsString().BeginsWith("YVSPT") )
357 ok = r->IsInRange(pair4Momentum.Pt(),pair4Momentum.Rapidity());
358 if ( pair4MomentumMC ) okMC = r->IsInRange(pair4MomentumMC->Pt(),pair4MomentumMC->Rapidity());
360 else if ( r->Quantity() == "NTRCORRPT" )
362 TList* list = static_cast<TList*>(Event()->FindListObject("NCH"));
366 Bool_t parFound(kFALSE);
367 while ( i < list->GetEntries() - 1 && !parFound )
370 while ( list->At(i)->IsA() != TParameter<Double_t>::Class() && i < list->GetEntries() - 1 ) // In case there is a diferent object, just to skip it
375 TParameter<Double_t>* p = static_cast<TParameter<Double_t>*>(list->At(i));
377 if ( TString(p->GetName()).Contains("NtrCorr") )
380 ok = r->IsInRange(p->GetVal(),pair4Momentum.Pt());
386 else if ( r->Quantity() == "NTRCORRY" )
388 TList* list = static_cast<TList*>(Event()->FindListObject("NCH"));
392 Bool_t parFound(kFALSE);
393 while ( i < list->GetEntries() - 1 && !parFound )
396 while ( list->At(i)->IsA() != TParameter<Double_t>::Class() && i < list->GetEntries() - 1 ) // In case there is a diferent object, just to skip it
401 TParameter<Double_t>* p = static_cast<TParameter<Double_t>*>(list->At(i));
403 if ( TString(p->GetName()).Contains("NtrCorr") )
406 ok = r->IsInRange(p->GetVal(),pair4Momentum.Rapidity());
415 AliError(Form("Don't know how to deal with 2D bin %s",r->AsString().Data()));
420 if ( r->Quantity() == "PT" )
422 ok = r->IsInRange(pair4Momentum.Pt());
423 if ( pair4MomentumMC ) okMC = r->IsInRange(pair4MomentumMC->Pt());
425 else if ( r->Quantity() == "Y" )
427 ok = r->IsInRange(pair4Momentum.Rapidity());
428 if ( pair4MomentumMC ) okMC = r->IsInRange(pair4MomentumMC->Rapidity());
430 else if ( r->Quantity() == "PHI" )
432 ok = r->IsInRange(pair4Momentum.Phi());
433 if ( pair4MomentumMC ) okMC = r->IsInRange(pair4MomentumMC->Phi());
435 else if ( r->Quantity() == "DNCHDETA" )
437 TList* list = static_cast<TList*>(Event()->FindListObject("NCH"));
441 Bool_t parFound(kFALSE);
442 while ( i < list->GetEntries() - 1 && !parFound )
445 while ( list->At(i)->IsA() != TParameter<Double_t>::Class() && i < list->GetEntries() - 1 ) // In case there is a diferent object, just to skip it
450 TParameter<Double_t>* p = static_cast<TParameter<Double_t>*>(list->At(i));
452 if ( TString(p->GetName()).Contains("dNchdEta") )
455 ok = r->IsInRange(p->GetVal());
459 // else AliFatal("No dNchdEta info on Event");
462 else if ( r->Quantity() == "NTRCORR" || r->Quantity() == "RELNTRCORR" )
464 TList* list = static_cast<TList*>(Event()->FindListObject("NCH"));
468 Bool_t parFound(kFALSE);
469 while ( i < list->GetEntries() - 1 && !parFound )
472 while ( list->At(i)->IsA() != TParameter<Double_t>::Class() && i < list->GetEntries() - 1 ) // In case there is a diferent object, just to skip it
477 TParameter<Double_t>* p = static_cast<TParameter<Double_t>*>(list->At(i));
479 if ( TString(p->GetName()).Contains("NtrCorr") )
482 if ( r->Quantity() == "NTRCORR" ) ok = r->IsInRange(p->GetVal());
483 else ok = r->IsInRange(p->GetVal()/5.97);
487 // else AliFatal("No ntrcorr info on Event");
494 TString minvName = GetMinvHistoName(*r,kFALSE);
496 if (!IsHistogramDisabled(minvName.Data()))
501 h = Histo(eventSelection,triggerClassName,centrality,pairCutName,minvName.Data());
505 AliError(Form("Could not get %s",minvName.Data()));
508 else h->Fill(pair4Momentum.M(),inputWeight);
512 h = MCHisto(eventSelection,triggerClassName,centrality,pairCutName,minvName.Data());
516 AliError(Form("Could not get MC %s",minvName.Data()));
519 else h->Fill(pair4MomentumMC->M(),inputWeightMC);
522 if ( fcomputeMeanPt )
524 TString hprofName("");
528 hprofName= Form("MeanPtVs%s",minvName.Data());
530 TProfile* hprof = Prof(eventSelection,triggerClassName,centrality,pairCutName,hprofName.Data());
534 AliError(Form("Could not get %s",hprofName.Data()));
539 // hprof->Approximate(); //I dont think its necessary here
540 hprof->Fill(pair4Momentum.M(),pair4Momentum.Pt(),inputWeight);
545 hprofName= Form("MeanPtVs%s",minvName.Data());
547 TProfile* hprof = MCProf(eventSelection,triggerClassName,centrality,pairCutName,hprofName.Data());
551 AliError(Form("Could not get MC %s",hprofName.Data()));
556 // hprof->Approximate(); //I dont think its necessary here
557 hprof->Fill(pair4MomentumMC->M(),pair4MomentumMC->Pt(),inputWeightMC);
565 if ( ShouldCorrectDimuonForAccEff() )
569 Bool_t okAccEff(kFALSE);
572 AccxEff = GetAccxEff(pair4Momentum.Pt(),pair4Momentum.Rapidity());
573 if ( AccxEff <= 0.0 )
575 AliError(Form("AccxEff < 0 for pt = %f & y = %f ",pair4Momentum.Pt(),pair4Momentum.Rapidity()));
578 else okAccEff = kTRUE;
581 Double_t AccxEffMC(0);
582 Bool_t okAccEffMC(kFALSE);
585 AccxEffMC= GetAccxEff(pair4MomentumMC->Pt(),pair4MomentumMC->Rapidity());
586 if ( AccxEffMC <= 0.0 )
588 AliError(Form("AccxEff < 0 for MC pair with pt = %f & y = %f ",pair4MomentumMC->Pt(),pair4MomentumMC->Rapidity()));
591 else okAccEffMC = kTRUE;
594 minvName = GetMinvHistoName(*r,kTRUE);
596 if (!IsHistogramDisabled(minvName.Data()))
598 TH1* hCorr = Histo(eventSelection,triggerClassName,centrality,pairCutName,minvName.Data());
602 AliError(Form("Could not get %sr",minvName.Data()));
605 else if ( okAccEff ) hCorr->Fill(pair4Momentum.M(),inputWeight/AccxEff);
609 hCorr = MCHisto(eventSelection,triggerClassName,centrality,pairCutName,minvName.Data());
613 AliError(Form("Could not get MC %s",minvName.Data()));
616 else hCorr->Fill(pair4MomentumMC->M(),inputWeightMC/AccxEffMC);
619 if ( fcomputeMeanPt )
621 TString hprofCorrName("");
624 hprofCorrName = Form("MeanPtVs%s",minvName.Data());
626 TProfile* hprofCorr = Prof(eventSelection,triggerClassName,centrality,pairCutName,hprofCorrName.Data());
630 AliError(Form("Could not get %s",hprofCorrName.Data()));
634 // hprofCorr->Approximate(); //I dont know if its necessary here
635 hprofCorr->Fill(pair4Momentum.M(),pair4Momentum.Pt(),inputWeight/AccxEff);
640 hprofCorrName = Form("MeanPtVs%s",minvName.Data());
642 TProfile* hprofCorr = MCProf(eventSelection,triggerClassName,centrality,pairCutName,hprofCorrName.Data());
646 AliError(Form("Could not get MC %s",hprofCorrName.Data()));
648 else if ( okAccEffMC )
650 // hprofCorr->Approximate(); //I dont know if its necessary here
651 hprofCorr->Fill(pair4MomentumMC->M(),pair4MomentumMC->Pt(),inputWeightMC/AccxEffMC);
669 //_____________________________________________________________________________
670 void AliAnalysisMuMuMinv::FillHistosForMCEvent(const char* eventSelection,const char* triggerClassName,const char* centrality)
672 // Fill the input Monte-Carlo histograms related to muons. Intended to be used on pure simulations so we wont use eventSelection, triggerClassName and centrality variables.
674 if ( !HasMC() ) return;
676 // Specific things for MC // These histos should go in the AliAnalysisMuMuGlobal task, but then we have to loop 2 times on the MCTracks...
677 // if (!Histo(MCInputPrefix(),"ALL","Pt"))
679 // HistogramCollection()->Adopt(Form("/%s/ALL",MCInputPrefix()),new TH1F("Pt","Pt",200,0,25));
680 // HistogramCollection()->Adopt(Form("/%s/INYRANGE",MCInputPrefix()),new TH1F("Pt","Pt",200,0,25));
682 // Double_t rapidityMin = -5;
683 // Double_t rapidityMax = -2;
684 // Int_t nbinsRapidity = GetNbins(rapidityMin,rapidityMax,0.05);
686 // HistogramCollection()->Adopt(Form("/%s/ALL",MCInputPrefix()),new TH1F("Y","Y",nbinsRapidity,rapidityMin,rapidityMax));
687 // HistogramCollection()->Adopt(Form("/%s/INYRANGE",MCInputPrefix()),new TH1F("Y","Y",nbinsRapidity,rapidityMin,rapidityMax));
689 // Double_t etaMin = -5;
690 // Double_t etaMax = -2;
691 // Int_t nbinsEta = GetNbins(etaMin,etaMax,0.05);
693 // HistogramCollection()->Adopt(Form("/%s/ALL",MCInputPrefix()),new TH1F("Eta","Eta",nbinsEta,etaMin,etaMax));
694 // HistogramCollection()->Adopt(Form("/%s/INYRANGE",MCInputPrefix()),new TH1F("Eta","Eta",nbinsEta,etaMin,etaMax));
697 Int_t nMCTracks = MCEvent()->GetNumberOfTracks();
699 TObjArray* bins = Binning()->CreateBinObjArray("psi","integrated,ptvsy,yvspt,pt,y,phi,nch,dnchdeta,ntrcorr,ntrcorrpt,ntrcorry,relntrcorr","");//We may include: ,v0a,v0acent.
701 AliAnalysisMuMuBinning::Range* r;
703 for ( Int_t i = 0; i < nMCTracks; ++i )
705 AliVParticle* part = MCEvent()->GetTrack(i);
707 if (AliAnalysisMuonUtility::IsPrimary(part,MCEvent()) &&
708 AliAnalysisMuonUtility::GetMotherIndex(part)==-1)
710 Double_t inputWeight = WeightDistribution(part->Pt(),part->Y());
712 MCHisto(eventSelection,triggerClassName,centrality,"Pt")->Fill(part->Pt(),inputWeight);
713 MCHisto(eventSelection,triggerClassName,centrality,"Y")->Fill(part->Y(),inputWeight);
714 MCHisto(eventSelection,triggerClassName,centrality,"Eta")->Fill(part->Eta());
716 if ( part->Y() < -2.5 && part->Y() > -4.0 )
718 MCHisto(eventSelection,triggerClassName,Form("%s/INYRANGE",centrality),"Pt")->Fill(part->Pt(),inputWeight);
719 MCHisto(eventSelection,triggerClassName,Form("%s/INYRANGE",centrality),"Y")->Fill(part->Y(),inputWeight);
720 MCHisto(eventSelection,triggerClassName,Form("%s/INYRANGE",centrality),"Eta")->Fill(part->Eta());
725 while ( ( r = static_cast<AliAnalysisMuMuBinning::Range*>(nextBin()) ) )
729 if ( r->IsIntegrated() )
733 else if ( r->Is2D() )
735 if ( r->AsString().BeginsWith("PTVSY") )
737 ok = r->IsInRange(part->Y(),part->Pt());
739 else if ( r->AsString().BeginsWith("YVSPT") )
741 ok = r->IsInRange(part->Pt(),part->Y());
745 AliError(Form("Don't know how to deal with 2D bin %s",r->AsString().Data()));
750 if ( r->Quantity() == "PT" )
752 ok = r->IsInRange(part->Pt());
754 else if ( r->Quantity() == "Y" )
756 ok = r->IsInRange(part->Y());
758 else if ( r->Quantity() == "PHI" )
760 ok = r->IsInRange(part->Phi());
766 TString hname = GetMinvHistoName(*r,kFALSE);
768 if (!IsHistogramDisabled(hname.Data()))
771 TH1* h = MCHisto(eventSelection,triggerClassName,centrality,hname.Data());
775 AliError(Form("Could not get /%s/%s/%s/%s/ %s",MCInputPrefix(),eventSelection,triggerClassName,centrality,hname.Data()));
779 h->Fill(part->M(),inputWeight);
781 if ( part->Y() < -2.5 && part->Y() > -4.0 )
783 h = MCHisto(eventSelection,triggerClassName,Form("%s/INYRANGE",centrality),hname.Data());
786 AliError(Form("Could not get /%s/%s/%s/%s/INYRANGE %s",MCInputPrefix(),eventSelection,triggerClassName,centrality,hname.Data()));
789 h->Fill(part->M(),inputWeight);
794 if ( fcomputeMeanPt )
796 TString hprofName= Form("MeanPtVs%s",hname.Data());
798 TProfile* hprof = MCProf(eventSelection,triggerClassName,centrality,hprofName.Data());
802 AliError(Form("Could not get %s",hprofName.Data()));
806 // hprof->Approximate(); //I dont think its necessary here
807 hprof->Fill(part->M(),part->Pt(),inputWeight);
810 if ( part->Y() < -2.5 && part->Y() > -4.0 )
812 hprof = MCProf(eventSelection,triggerClassName,Form("%s/INYRANGE",centrality),hprofName.Data());
816 AliError(Form("Could not get %s",hprofName.Data()));
820 // hprof->Approximate(); //I dont think its necessary here
821 hprof->Fill(part->M(),part->Pt(),inputWeight);
829 // if ( ShouldCorrectDimuonForAccEff() ) //What is the sense of this?? We should not correct the input
831 // Double_t AccxEff = GetAccxEff(part->Pt(),part->Y());
832 // if ( AccxEff <= 0.0 )
834 // AliError(Form("AccxEff < 0 for pt = %f & y = %f ",part->Pt(),part->Y()));
837 // hname = GetMinvHistoName(*r,kTRUE);
839 // if (!IsHistogramDisabled(hname.Data()))
842 // TH1* h = MCHisto(eventSelection,triggerClassName,centrality,hname.Data());
846 // AliError(Form("Could not get /%s/%s/%s/%s/ %s",MCInputPrefix(),eventSelection,triggerClassName,centrality,hname.Data()));
850 // h->Fill(part->M(),inputWeight/AccxEff);
852 // if ( part->Y() < -2.5 && part->Y() > -4.0 )
854 // h = MCHisto(eventSelection,triggerClassName,Form("%s/INYRANGE",centrality),hname.Data());
857 // AliError(Form("Could not get /%s/%s/%s/%s/INYRANGE %s",MCInputPrefix(),eventSelection,triggerClassName,Form("%s/INYRANGE",centrality),hname.Data()));
860 // h->Fill(part->M(),inputWeight./AccxEff);
875 // for ( Int_t i = 0; i < nMCTracks; ++i )
877 // AliVParticle* part = MCEvent()->GetTrack(i);
879 // if (AliAnalysisMuonUtility::IsPrimary(part,MCEvent()) &&
880 // AliAnalysisMuonUtility::GetMotherIndex(part)==-1)
883 // Histo(MCInputPrefix(),"ALL","Pt")->Fill(part->Pt());
884 // Histo(MCInputPrefix(),"ALL","Y")->Fill(part->Y());
885 // Histo(MCInputPrefix(),"ALL","Eta")->Fill(part->Eta());
887 // if ( part->Y() < -2.5 && part->Y() > -4.0 )
889 // Histo(MCInputPrefix(),"INYRANGE","Pt")->Fill(part->Pt());
890 // Histo(MCInputPrefix(),"INYRANGE","Y")->Fill(part->Y());
891 // Histo(MCInputPrefix(),"INYRANGE","Eta")->Fill(part->Eta());
896 // while ( ( r = static_cast<AliAnalysisMuMuBinning::Range*>(nextBin()) ) )
898 // Bool_t ok(kFALSE);
900 // if ( r->IsIntegrated() )
904 // else if ( r->Is2D() )
906 // if ( r->AsString().BeginsWith("PTVSY") )
908 // ok = r->IsInRange(part->Y(),part->Pt());
910 // else if ( r->AsString().BeginsWith("YVSPT") )
912 // ok = r->IsInRange(part->Pt(),part->Y());
916 // AliError(Form("Don't know how to deal with 2D bin %s",r->AsString().Data()));
921 // if ( r->Quantity() == "PT" )
923 // ok = r->IsInRange(part->Pt());
925 // else if ( r->Quantity() == "Y" )
927 // ok = r->IsInRange(part->Y());
929 // else if ( r->Quantity() == "PHI" )
931 // ok = r->IsInRange(part->Phi());
937 // TString hname = GetMinvHistoName(*r,kFALSE);
939 // if (!IsHistogramDisabled(hname.Data()))
942 // TH1* h = Histo(MCInputPrefix(),"ALL",hname.Data());
946 // AliError(Form("Could not get ALL %s",hname.Data()));
950 // h->Fill(part->M());
952 // if ( part->Y() < -2.5 && part->Y() > -4.0 )
954 // h = Histo(MCInputPrefix(),"INYRANGE",hname.Data());
957 // AliError(Form("Could not get INYRANGE %s",hname.Data()));
960 // h->Fill(part->M());
965 // if ( ShouldCorrectDimuonForAccEff() )
967 // Double_t AccxEff = GetAccxEff(part->Pt(),part->Y());
968 // if ( AccxEff <= 0.0 )
970 // AliError(Form("AccxEff < 0 for pt = %f & y = %f ",part->Pt(),part->Y()));
973 // hname = GetMinvHistoName(*r,kTRUE);
975 // if (!IsHistogramDisabled(hname.Data()))
978 // TH1* h = Histo(MCInputPrefix(),"ALL",hname.Data());
982 // AliError(Form("Could not get ALL %s",hname.Data()));
986 // h->Fill(part->M(),1./AccxEff);
988 // if ( part->Y() < -2.5 && part->Y() > -4.0 )
990 // h = Histo(MCInputPrefix(),"INYRANGE",hname.Data());
993 // AliError(Form("Could not get INYRANGE %s",hname.Data()));
996 // h->Fill(part->M(),1./AccxEff);
1011 //_____________________________________________________________________________
1012 TString AliAnalysisMuMuMinv::GetMinvHistoName(const AliAnalysisMuMuBinning::Range& r, Bool_t accEffCorrected) const
1014 return TString::Format("MinvUS%s%s",r.AsString().Data(),
1015 accEffCorrected ? "_AccEffCorr" : "");
1019 //_____________________________________________________________________________
1020 Double_t AliAnalysisMuMuMinv::GetAccxEff(Double_t pt,Double_t rapidity)
1024 AliError("ERROR: No AccxEff histo");
1027 Int_t bin = fAccEffHisto->FindBin(pt,rapidity);
1028 Double_t accXeff = fAccEffHisto->GetBinContent(bin);
1033 //_____________________________________________________________________________
1034 Double_t AliAnalysisMuMuMinv::WeightDistribution(Double_t pt,Double_t rapidity)
1036 //Return a weight for a dimuon pt and y, which depend on the varied distributions.
1037 // FIXME: hard coded, find a clean way to fix the distribution parameters from outside
1039 if (!HasMC() ) return 1.;
1041 //================ p-Pb ==============//
1042 //value for input distribution: this is the nominal pt and y distribution
1043 Double_t paryPPB[2] = {1.0,0.174};
1044 Double_t parptPPB[3] = {1.0,0.0557,3.52};
1046 Double_t paryHardPPB = 0.1344, parySoftPPB = 0.1971;
1047 Double_t par1ptHardPPB = 5.51e-2, par2ptHardPPB = 3.47,
1048 par1ptSoftPPB = 5.67e-2, par2ptSoftPPB = 3.68;
1049 //systematic 1: hardest in y x softest in pt
1050 Double_t pary1[2] = {1.0,paryHardPPB};
1051 Double_t parpt1[3] = {1.0,par1ptSoftPPB,par2ptSoftPPB};
1052 //systematic 2: hardest in y x hardest in pt
1053 Double_t pary2[2] = {1.0,paryHardPPB};
1054 Double_t parpt2[3] = {1.0,par1ptHardPPB,par2ptHardPPB};
1055 //systematic 3: softest in y x softest in pt
1056 Double_t pary3[2] = {1.0, parySoftPPB};
1057 Double_t parpt3[3] = {1.0,par1ptSoftPPB,par2ptSoftPPB};
1058 //systematic 4: softest in y x hardest in pt
1059 Double_t pary4[2] = {1.0,parySoftPPB};
1060 Double_t parpt4[3] = {1.0,par1ptHardPPB,par2ptHardPPB};
1062 Double_t funcptvalPPB = powerLaw3Par(&pt,parptPPB);
1063 Double_t funcyvalPPB = normPol12Par(&rapidity,paryPPB);
1065 //================ Pb-p ==============//
1066 //value for input distribution
1067 Double_t paryPBP[2] = {1.0,0.189};
1068 Double_t parptPBP[3] = {1.0,0.0592,3.92};
1070 Double_t paryHardPBP = 0.1517, parySoftPBP = 0.2191;
1071 Double_t par1ptHardPBP = 5.58e-2, par2ptHardPBP = 3.83,
1072 par1ptSoftPBP = 5.59e-2, par2ptSoftPBP = 4.31;
1073 //systematic 5: hardest in y x softest in pt
1074 Double_t pary5[2] = {1.0,paryHardPBP};
1075 Double_t parpt5[3] = {1.0,par1ptSoftPBP,par2ptSoftPBP};
1076 //systematic 6: hardest in y x hardest in pt
1077 Double_t pary6[2] = {1.0,paryHardPBP};
1078 Double_t parpt6[3] = {1.0,par1ptHardPBP,par2ptHardPBP};
1079 //systematic 7: softest in y x softest in pt
1080 Double_t pary7[2] = {1.0, parySoftPBP};
1081 Double_t parpt7[3] = {1.0,par1ptSoftPBP,par2ptSoftPBP};
1082 //systematic 8: softest in y x hardest in pt
1083 Double_t pary8[2] = {1.0,parySoftPBP};
1084 Double_t parpt8[3] = {1.0,par1ptHardPBP,par2ptHardPBP};
1086 Double_t funcptvalPBP = powerLaw3Par(&pt,parptPBP);
1087 Double_t funcyvalPBP = normPol12Par(&rapidity,paryPBP);
1089 //================ pp ==============//
1090 //value for input distribution
1091 Double_t paryPP[2] = {3.0,0.514/3.};
1092 Double_t parptPP[3] = {1.0,0.0546,3.90};
1094 Double_t paryHardPP = 0.4125/3., parySoftPP = 0.5958/3.;
1095 Double_t par1ptHardPP = 4.78e-2, par2ptHardPP = 3.65,//4.84e-2/3.45
1096 par1ptSoftPP = 6.12e-2, par2ptSoftPP = 4.31;//5.47e-2//4.29
1097 //systematic 9: hardest in y x softest in pt
1098 Double_t pary9[2] = {3.0,paryHardPP};
1099 Double_t parpt9[3] = {1.0,par1ptSoftPP,par2ptSoftPP};
1100 //systematic 10: hardest in y x hardest in pt
1101 Double_t pary10[2] = {3.0,paryHardPP};
1102 Double_t parpt10[3] = {1.0,par1ptHardPP,par2ptHardPP};
1103 //systematic 11: softest in y x softest in pt
1104 Double_t pary11[2] = {3.0, parySoftPP};
1105 Double_t parpt11[3] = {1.0,par1ptSoftPP,par2ptSoftPP};
1106 //systematic 12: softest in y x hardest in pt
1107 Double_t pary12[2] = {3.0,parySoftPP};
1108 Double_t parpt12[3] = {1.0,par1ptHardPP,par2ptHardPP};
1110 Double_t funcptvalPP = powerLaw3Par(&pt,parptPP);
1111 Double_t funcyvalPP = normPol12Par(&rapidity,paryPP);
1114 Double_t weight(1.),funcptsyst(0.),funcysyst(0.);
1115 switch ( fsystLevel )
1121 funcptsyst = powerLaw3Par(&pt,parpt1);
1122 if ( funcptvalPPB > 0 && funcptsyst > 0 ) weight = funcptsyst/funcptvalPPB;
1124 funcysyst = normPol12Par(&rapidity,pary1);
1125 if ( funcyvalPPB > 0 && funcysyst > 0 ) weight *= funcysyst/funcyvalPPB;
1128 funcptsyst = powerLaw3Par(&pt,parpt2);
1129 if ( funcptvalPPB > 0 && funcptsyst > 0 ) weight = funcptsyst/funcptvalPPB;
1131 funcysyst = normPol12Par(&rapidity,pary2);
1132 if ( funcyvalPPB > 0 && funcysyst > 0 ) weight *= funcysyst/funcyvalPPB;
1135 funcptsyst = powerLaw3Par(&pt,parpt3);
1136 if ( funcptvalPPB > 0 && funcptsyst > 0 ) weight = funcptsyst/funcptvalPPB;
1138 funcysyst = normPol12Par(&rapidity,pary3);
1139 if ( funcyvalPPB > 0 && funcysyst > 0 ) weight *= funcysyst/funcyvalPPB;
1142 funcptsyst = powerLaw3Par(&pt,parpt4);
1143 if ( funcptvalPPB > 0 && funcptsyst > 0 ) weight = funcptsyst/funcptvalPPB;
1145 funcysyst = normPol12Par(&rapidity,pary4);
1146 if ( funcyvalPPB > 0 && funcysyst > 0 ) weight *= funcysyst/funcyvalPPB;
1149 funcptsyst = powerLaw3Par(&pt,parpt5);
1150 if ( funcptvalPBP > 0 && funcptsyst > 0 ) weight = funcptsyst/funcptvalPBP;
1152 funcysyst = normPol12Par(&rapidity,pary5);
1153 if ( funcyvalPBP > 0 && funcysyst > 0 ) weight *= funcysyst/funcyvalPBP;
1156 funcptsyst = powerLaw3Par(&pt,parpt6);
1157 if ( funcptvalPBP > 0 && funcptsyst > 0 ) weight = funcptsyst/funcptvalPBP;
1159 funcysyst = normPol12Par(&rapidity,pary6);
1160 if ( funcyvalPBP > 0 && funcysyst > 0 ) weight *= funcysyst/funcyvalPBP;
1163 funcptsyst = powerLaw3Par(&pt,parpt7);
1164 if ( funcptvalPBP > 0 && funcptsyst > 0 ) weight = funcptsyst/funcptvalPBP;
1166 funcysyst = normPol12Par(&rapidity,pary7);
1167 if ( funcyvalPBP > 0 && funcysyst > 0 ) weight *= funcysyst/funcyvalPBP;
1170 funcptsyst = powerLaw3Par(&pt,parpt8);
1171 if ( funcptvalPBP > 0 && funcptsyst > 0 ) weight = funcptsyst/funcptvalPBP;
1173 funcysyst = normPol12Par(&rapidity,pary8);
1174 if ( funcyvalPBP > 0 && funcysyst > 0 ) weight *= funcysyst/funcyvalPBP;
1177 funcptsyst = powerLaw3Par(&pt,parpt9);
1178 if ( funcptvalPP > 0 && funcptsyst > 0 ) weight = funcptsyst/funcptvalPP;
1180 funcysyst = normPol12Par(&rapidity,pary9);
1181 if ( funcyvalPP > 0 && funcysyst > 0 ) weight *= funcysyst/funcyvalPP;
1184 funcptsyst = powerLaw3Par(&pt,parpt10);
1185 if ( funcptvalPP > 0 && funcptsyst > 0 ) weight = funcptsyst/funcptvalPP;
1187 funcysyst = normPol12Par(&rapidity,pary10);
1188 if ( funcyvalPP > 0 && funcysyst > 0 ) weight *= funcysyst/funcyvalPP;
1191 funcptsyst = powerLaw3Par(&pt,parpt11);
1192 if ( funcptvalPP > 0 && funcptsyst > 0 ) weight = funcptsyst/funcptvalPP;
1194 funcysyst = normPol12Par(&rapidity,pary11);
1195 if ( funcyvalPP > 0 && funcysyst > 0 ) weight *= funcysyst/funcyvalPP;
1198 funcptsyst = powerLaw3Par(&pt,parpt12);
1199 if ( funcptvalPP > 0 && funcptsyst > 0 ) weight = funcptsyst/funcptvalPP;
1201 funcysyst = normPol12Par(&rapidity,pary12);
1202 if ( funcyvalPP > 0 && funcysyst > 0 ) weight *= funcysyst/funcyvalPP;
1209 //________________________________________________________________________
1210 Double_t AliAnalysisMuMuMinv::powerLaw3Par(Double_t *x, Double_t *par)
1215 arg = par[0]*x[0] / TMath::Power( 1 + par[1]*x[0]*x[0], par[2]);
1221 //________________________________________________________________________
1222 Double_t AliAnalysisMuMuMinv::normPol12Par(Double_t *x, Double_t *par)
1227 arg1 = par[0] * ( 1 + par[1]*x[0] );
1233 //_____________________________________________________________________________
1234 Bool_t AliAnalysisMuMuMinv::IsPtInRange(const AliVParticle& t1, const AliVParticle& t2, Double_t& ptmin, Double_t& ptmax) const
1236 /// Whether the pair passes the rapidity cut
1238 TLorentzVector p1(t1.Px(),t1.Py(),t1.Pz(),TMath::Sqrt(AliAnalysisMuonUtility::MuonMass2()+t1.P()*t1.P()));
1239 TLorentzVector p2(t2.Px(),t2.Py(),t2.Pz(),TMath::Sqrt(AliAnalysisMuonUtility::MuonMass2()+t2.P()*t2.P()));
1241 TLorentzVector total(p1+p2);
1243 Double_t pt = total.Pt();
1245 return ( pt < ptmax && pt > ptmin );
1248 //_____________________________________________________________________________
1249 void AliAnalysisMuMuMinv::NameOfIsPtInRange(TString& name, Double_t& ptmin, Double_t& ptmax) const
1251 name.Form("PAIRPTIN%2.1f-%2.1f",ptmin,ptmax);
1254 //_____________________________________________________________________________
1255 Bool_t AliAnalysisMuMuMinv::IsRapidityInRange(const AliVParticle& t1, const AliVParticle& t2) const
1257 TLorentzVector p1(t1.Px(),t1.Py(),t1.Pz(),TMath::Sqrt(AliAnalysisMuonUtility::MuonMass2()+t1.P()*t1.P()));
1258 TLorentzVector p2(t2.Px(),t2.Py(),t2.Pz(),TMath::Sqrt(AliAnalysisMuonUtility::MuonMass2()+t2.P()*t2.P()));
1260 TLorentzVector total(p1+p2);
1262 Double_t y = total.Rapidity();
1264 return ( y < -2.5 && y > -4.0 );