1 #include "AliAnalysisMuMuNch.h"
5 * \ingroup pwg-muon-mumu
7 * \class AliAnalysisMuMuNch
9 * SPD tracklet to Nch analysis
11 * The idea is that this sub-analysis is used first (within the AliAnalysisTaskMuMu sub-framework)
12 * in order to compute the number of charged particles within an event, so that information
13 * can be used in subsequent sub-analysis, like the invariant mass or mean pt ones.
17 #include "AliAODTracklets.h"
18 #include "AliAnalysisMuonUtility.h"
20 #include "AliAODEvent.h"
21 #include "AliESDUtils.h"
23 #include "AliAnalysisMuMuCutRegistry.h"
24 #include "AliAnalysisMuMuCutElement.h"
25 #include "Riostream.h"
26 #include "TParameter.h"
29 #include "AliMergeableCollection.h"
30 #include "AliMCEvent.h"
31 #include "AliAODMCParticle.h"
37 #include "TObjString.h"
42 Double_t SPDgeomR(Double_t* x,Double_t* par) // Eta position of the SPD right edge eta as "seen" from a z vertex position
44 // par[0] = radius of SPD layer
53 theta = TMath::ATan(par[0]/z);
56 else if( d > 14.09999 )
59 theta = TMath::Pi() - TMath::ATan(par[0]/z);
62 return -TMath::Log(TMath::Tan(theta/2.));
65 Double_t SPDgeomL(Double_t* x,Double_t* par) // Eta position of the SPD left edge eta as "seen" from a z vertex position
67 // par[0] = radius of SPD layer
76 theta = TMath::Pi() - TMath::ATan(par[0]/z);
82 theta = TMath::ATan(par[0]/z);
85 return -TMath::Log(TMath::Tan(theta/2.));
90 //_____________________________________________________________________________
91 AliAnalysisMuMuNch::AliAnalysisMuMuNch(TH2* spdCorrection, Double_t etaMin, Double_t etaMax
92 , Double_t zMin, Double_t zMax,Bool_t disableHistos, Bool_t computeResolution)
93 : AliAnalysisMuMuBase(),
95 fEtaAxis(new TAxis(TMath::Nint(10./0.1),-5.,5.)),
96 fZAxis(new TAxis(TMath::Nint(80/0.25),-40.,40.)),
102 fResolution(computeResolution)
106 fSPDCorrection = static_cast<TH2F*>(spdCorrection->Clone());
107 fSPDCorrection->SetDirectory(0);
109 DefineSPDAcceptance();
113 DisableHistograms("*");
117 //_____________________________________________________________________________
118 AliAnalysisMuMuNch::~AliAnalysisMuMuNch()
120 delete fSPDCorrection;
129 //_____________________________________________________________________________
130 void AliAnalysisMuMuNch::DefineHistogramCollection(const char* eventSelection,
131 const char* triggerClassName,
132 const char* centrality)
134 // Define multiplicity histos
136 if ( Histo(eventSelection,triggerClassName,centrality,"AliAnalysisMuMuNch") )
141 // dummy histogram to signal that we already defined all our histograms (see above)
142 CreateEventHistos(kHistoForData | kHistoForMCInput,eventSelection,triggerClassName,centrality,"AliAnalysisMuMuNch","Dummy semaphore",1,0,1);
144 Double_t multMin = 0.; //Tracklets multiplicity range
145 Double_t multMax = 500.;
146 Int_t nbinsMult = GetNbins(multMin,multMax,1.);
148 Double_t phimin = 0.; //Phi range
149 Double_t phimax = 2*TMath::Pi();
150 Int_t nphibins = GetNbins(phimin,phimax,0.05);
152 if ( !fSPDCorrection && fResolution ) // Resolution histos
154 CreateEventHistos(kHistoForMCInput,eventSelection,triggerClassName,centrality,"EtaRes","#eta resolution;#eta_{Reco} - #eta_{MC};Counts",(fEtaAxis->GetNbins())*2,fEtaAxis->GetXmin(),fEtaAxis->GetXmax());
156 CreateEventHistos(kHistoForMCInput,eventSelection,triggerClassName,centrality,"PhiRes","#phi resolution;#phi_{Reco} - #phi_{MC};Counts",nphibins*2,-phimax,phimax);
158 CreateEventHistos(kHistoForMCInput,eventSelection,triggerClassName,centrality,"PhiResShifted","#phi resolution;#phi_{Reco} - #phi_{MC};Counts",nphibins*4,-phimax/4,phimax/4);
160 CreateEventHistos(kHistoForMCInput,eventSelection,triggerClassName,centrality,"EtaResVsZ","#eta resolution vs MC Zvertex;ZVertex (cm);#eta_{Reco} - #eta_{MC}",(fZAxis->GetNbins())*20,fZAxis->GetXmin(),fZAxis->GetXmax(),(fEtaAxis->GetNbins())*8,fEtaAxis->GetXmin(),fEtaAxis->GetXmax());
162 CreateEventHistos(kHistoForMCInput,eventSelection,triggerClassName,centrality,"PhiResVsZ","#phi resolution vs MC Zvertex;ZVertex (cm);#phi_{Reco} - #phi_{MC}",(fZAxis->GetNbins())*20,fZAxis->GetXmin(),fZAxis->GetXmax(),nphibins*4,-phimax/4,phimax/4);
164 CreateEventHistos(kHistoForMCInput,eventSelection,triggerClassName,centrality,"EtaResVsnC","#eta resolution vs Nof contributors to SPD vertex;NofContributors;#eta_{Reco} - #eta_{MC}",200,0,200,(fEtaAxis->GetNbins())*8,fEtaAxis->GetXmin(),fEtaAxis->GetXmax());
166 CreateEventHistos(kHistoForMCInput,eventSelection,triggerClassName,centrality,"PhiResVsnC","#phi resolution vs Nof contributors to SPD vertex;NofContributors;#phi_{Reco} - #phi_{MC}",200,0,200,nphibins*4,-phimax/4,phimax/4);
168 CreateEventHistos(kHistoForMCInput,eventSelection,triggerClassName,centrality,"SPDZvResVsnC","SPD Zvertex resolution vs Nof contributors;NofContributors;Zvertex_{Reco} - Zvertex_{MC} (cm)",200,0,200,(fZAxis->GetNbins())*20,fZAxis->GetXmin(),fZAxis->GetXmax());
170 CreateEventHistos(kHistoForMCInput,eventSelection,triggerClassName,centrality,"SPDZvResVsMCz","SPD Zvertex resolution vs MC z vertex;MC Zvertex (cm);Zvertex_{Reco} - Zvertex_{MC} (cm)",(fZAxis->GetNbins())*20,fZAxis->GetXmin(),fZAxis->GetXmax(),(fZAxis->GetNbins())*10,fZAxis->GetXmin(),fZAxis->GetXmax());
172 CreateEventHistos(kHistoForMCInput,eventSelection,triggerClassName,centrality,"Phi","Reco #phi distribution;#phi;Counts",nphibins,phimin,phimax);
174 CreateEventHistos(kHistoForMCInput,eventSelection,triggerClassName,centrality,"MCPhi","MC #phi distribution;#phi;Counts",nphibins,phimin,phimax);
176 CreateEventHistos(kHistoForMCInput,eventSelection,triggerClassName,centrality,"Eta","Reco #eta distribution;#phi;Counts",(fEtaAxis->GetNbins())*2,fEtaAxis->GetXmin(),fEtaAxis->GetXmax());
178 CreateEventHistos(kHistoForMCInput,eventSelection,triggerClassName,centrality,"MCEta","MC #eta distribution;#phi;Counts",(fEtaAxis->GetNbins())*2,fEtaAxis->GetXmin(),fEtaAxis->GetXmax());
180 return; // When computing resolutions we don't want to create the rest of histos
183 CreateEventHistos(kHistoForData | kHistoForMCInput,eventSelection,triggerClassName,centrality,"TrackletsVsZVertexVsPhi","Number of tracklets vs Z vertex vs #phi;Z vertex;#phi",fZAxis->GetNbins(),fZAxis->GetXmin(),fZAxis->GetXmax(),nphibins,phimin,phimax);
184 AttachSPDAcceptance(kHistoForData | kHistoForMCInput,eventSelection,triggerClassName,centrality,"TrackletsVsZVertexVsPhi");// Attach the SPD acc curves
186 CreateEventHistos(kHistoForData | kHistoForMCInput,eventSelection,triggerClassName,centrality,"TrackletsVsZVertexVsEta","Number of tracklets vs ZVertex vs #eta;ZVertex;#eta",fZAxis->GetNbins(),fZAxis->GetXmin(),fZAxis->GetXmax(),fEtaAxis->GetNbins(),fEtaAxis->GetXmin(),fEtaAxis->GetXmax());
187 AttachSPDAcceptance(kHistoForData | kHistoForMCInput,eventSelection,triggerClassName,centrality,"TrackletsVsZVertexVsEta");
189 CreateEventHistos(kHistoForData | kHistoForMCInput,eventSelection,triggerClassName,centrality,"Tracklets","Number of tracklets distribution;N_{Tracklets};N_{events}",nbinsMult,multMin,multMax);
191 CreateEventHistos(kHistoForMCInput,eventSelection,triggerClassName,centrality,"NBkgTrackletsVsZVertexVsEta","Number of background tracklets vs ZVertex vs #eta;ZVertex;#eta",fZAxis->GetNbins(),fZAxis->GetXmin(),fZAxis->GetXmax(),fEtaAxis->GetNbins(),fEtaAxis->GetXmin(),fEtaAxis->GetXmax());
192 AttachSPDAcceptance(kHistoForMCInput,eventSelection,triggerClassName,centrality,"NBkgTrackletsVsZVertexVsEta");
194 CreateEventHistos(kHistoForData | kHistoForMCInput,eventSelection,triggerClassName,centrality,"NchVsZVertexVsEta","Number of charged particles vs ZVertex vs #eta;ZVertex;#eta",fZAxis->GetNbins(),fZAxis->GetXmin(),fZAxis->GetXmax(),fEtaAxis->GetNbins(),fEtaAxis->GetXmin(),fEtaAxis->GetXmax());
195 AttachSPDAcceptance(kHistoForData | kHistoForMCInput,eventSelection,triggerClassName,centrality,"NchVsZVertexVsEta");
197 CreateEventHistos(kHistoForMCInput,eventSelection,triggerClassName,centrality,"NchVsZVertexVsPhi","Number of charged particles vs ZVertex vs #phi;ZVertex;#eta",fZAxis->GetNbins(),fZAxis->GetXmin(),fZAxis->GetXmax(),nphibins,phimin,phimax);
199 CreateEventHistos(kHistoForData | kHistoForMCInput,eventSelection,triggerClassName,centrality,"EventsVsZVertexVsEta","Effective number of events vs ZVertex vs #eta;ZVertex;#eta",fZAxis->GetNbins(),fZAxis->GetXmin(),fZAxis->GetXmax(),fEtaAxis->GetNbins(),fEtaAxis->GetXmin(),fEtaAxis->GetXmax()); // Fill 1 unit in each "touched" eta bin per event (represents the eta bins in which each event contributes)
200 AttachSPDAcceptance(kHistoForData | kHistoForMCInput,eventSelection,triggerClassName,centrality,"EventsVsZVertexVsEta");
202 CreateEventHistos(kHistoForData | kHistoForMCInput,eventSelection,triggerClassName,centrality,"Nch","Number of charged particles distribution;N_{ch};N_{events}",nbinsMult,multMin,multMax);
204 CreateEventHistos(kHistoForData | kHistoForMCInput,eventSelection,triggerClassName,centrality,"dNchdEta","<dNchdEta> distribution;dN_{ch}/d#eta;N_{events}",nbinsMult,multMin,multMax);
206 CreateEventHistos(kHistoForData,eventSelection,triggerClassName,centrality,"TrackletsVsNch","Number of tracklets vs Number of charged particles;N_{ch};N_{tracklets}",nbinsMult,multMin,multMax,nbinsMult,multMin,multMax); //Response matrix
208 CreateEventHistos(kHistoForData | kHistoForMCInput,eventSelection,triggerClassName,centrality,"V0AMultVsNch","V0A multiplicity vs Number of charged particles;N_{ch};V0A Mult",nbinsMult,multMin,multMax,nbinsMult,multMin,multMax);
210 CreateEventHistos(kHistoForData | kHistoForMCInput,eventSelection,triggerClassName,centrality,"V0CMultVsNch","V0C multiplicity vs Number of charged particles;N_{ch};V0C Mult",nbinsMult,multMin,multMax,nbinsMult,multMin,multMax);
212 // profile histograms
214 CreateEventHistos(kHistoForData,eventSelection,triggerClassName,centrality,"MeanTrackletsVsEta","Mean number of tracklets vs #eta;#eta;<N_{Tracklets}>",fEtaAxis->GetNbins(),fEtaAxis->GetXmin(),fEtaAxis->GetXmax(),0);
216 CreateEventHistos(kHistoForData,eventSelection,triggerClassName,centrality,"MeanTrackletsVsZVertex","Mean number of tracklets vs Z vertex;Z vertex;<N_{Tracklets}>",fZAxis->GetNbins(),fZAxis->GetXmin(),fZAxis->GetXmax(),0);
218 CreateEventHistos(kHistoForData | kHistoForMCInput,eventSelection,triggerClassName,centrality,"MeanNchVsEta","Mean number of charged particles vs #eta;#eta;<N_{ch}>",fEtaAxis->GetNbins(),fEtaAxis->GetXmin(),fEtaAxis->GetXmax(),0); // Each bin has to be divided by the binwidth to became dNch/dEta (Done in the terminate and stored in MeandNchdEta histo)
220 CreateEventHistos(kHistoForData | kHistoForMCInput,eventSelection,triggerClassName,centrality,"MeanNchVsZVertex","Mean number of charged particles vs Z vertex;Z vertex;<N_{ch}>",fZAxis->GetNbins(),fZAxis->GetXmin(),fZAxis->GetXmax(),0);
224 //_____________________________________________________________________________
225 void AliAnalysisMuMuNch::DefineSPDAcceptance()
227 // Defines the functions ( eta = f(z) )of the edges (right/left) of the inner and outer SPD layers
228 // R_in = 3.9 cm ; R_out = 7.6 cm
229 fSPD1LR = new TF1("fSPD1LR",SPDgeomR,-40,40,1);
230 fSPD1LR->SetParameter(0,3.9);
231 fSPD1LL = new TF1("fSPD1LL",SPDgeomL,-40,40,1);
232 fSPD1LL->SetParameter(0,3.9);
233 fSPD2LR = new TF1("fSPD2LR",SPDgeomR,-40,40,1);
234 fSPD2LR->SetParameter(0,7.6);
235 fSPD2LL = new TF1("fSPD2LL",SPDgeomL,-40,40,1);
236 fSPD2LL->SetParameter(0,7.6);
240 //_____________________________________________________________________________
241 void AliAnalysisMuMuNch::AddHisto(const char* eventSelection,
242 const char* triggerClassName,
243 const char* centrality,
244 const char* histoname,
248 // Adds the content of a 1D histo to a 2D histo a the z position
250 Int_t zbin = fZAxis->FindBin(z);
252 if (isMC) h2 = static_cast<TH2F*>(MCHisto(eventSelection,triggerClassName,centrality,histoname));
253 else h2 = static_cast<TH2F*>(Histo(eventSelection,triggerClassName,centrality,histoname));
255 for ( Int_t i = 1; i <= h->GetXaxis()->GetNbins(); ++i )
257 Double_t content = h2->GetCellContent(zbin,i);
259 if ( h->GetBinContent(i) > 0 )
261 h2->SetCellContent(zbin,i,content + h->GetBinContent(i));
265 h2->SetEntries(h2->GetSumOfWeights());
269 //_____________________________________________________________________________
270 void AliAnalysisMuMuNch::AttachSPDAcceptance(UInt_t dataType,
271 const char* eventSelection,
272 const char* triggerClassName,
273 const char* centrality,const char* histoname)
275 if ( dataType & kHistoForData )
277 if( !Histo(eventSelection,triggerClassName,centrality,histoname) )
279 AliError(Form("ERROR: SPD Acceptance curves attach failed. Histo /%s/%s/%s/%s not found",eventSelection,triggerClassName,centrality,histoname));
283 Histo(eventSelection,triggerClassName,centrality,histoname)->GetListOfFunctions()->Add(fSPD1LR);
284 Histo(eventSelection,triggerClassName,centrality,histoname)->GetListOfFunctions()->Add(fSPD1LL);
285 Histo(eventSelection,triggerClassName,centrality,histoname)->GetListOfFunctions()->Add(fSPD2LR);
286 Histo(eventSelection,triggerClassName,centrality,histoname)->GetListOfFunctions()->Add(fSPD2LL);
288 if ( dataType & kHistoForMCInput )
290 if( !MCHisto(eventSelection,triggerClassName,centrality,histoname) )
292 AliError(Form("ERROR: SPD Acceptance curves attach failed. MC Histo /%s/%s/%s/%s not found",eventSelection,triggerClassName,centrality,histoname));
296 MCHisto(eventSelection,triggerClassName,centrality,histoname)->GetListOfFunctions()->Add(fSPD1LR);
297 MCHisto(eventSelection,triggerClassName,centrality,histoname)->GetListOfFunctions()->Add(fSPD1LL);
298 MCHisto(eventSelection,triggerClassName,centrality,histoname)->GetListOfFunctions()->Add(fSPD2LR);
299 MCHisto(eventSelection,triggerClassName,centrality,histoname)->GetListOfFunctions()->Add(fSPD2LL);
305 //_____________________________________________________________________________
306 void AliAnalysisMuMuNch::FillHistosForEvent(const char* eventSelection,
307 const char* triggerClassName,
308 const char* centrality)
310 // Fills the data (or reco if simu) multiplicity histos
312 if ( IsHistogrammingDisabled() ) return;
314 if ( fResolution ) return; //When computing resolutions we skip this method
316 if ( !AliAnalysisMuonUtility::IsAODEvent(Event()) )
318 AliError("Don't know how to deal with ESDs...");
322 if ( HasMC() && !fSPDCorrection ) // We have MC but no correction (SPD correction computation mode)so we skip the method
327 AliAODEvent* aod = static_cast<AliAODEvent*>(Event());
329 AliVVertex* vertex = aod->GetPrimaryVertexSPD();
331 TList* nchList = static_cast<TList*>(Event()->FindListObject("NCH"));
333 if (!nchList || nchList->IsEmpty() ) // Empty NCH means that there is no SPD vertex ( see SetEvent() ) when runing on data.
340 if ( !vertex || vertex->GetZ() == 0.0 ) // Running in Simu the spdZ == 0 means no SPD info. In data, avoid breaks in events w/o SPD vertex
345 else SPDZv = vertex->GetZ();
347 TH1* hSPDcorrectionVsEta = static_cast<TH1*>(nchList->FindObject("SPDcorrectionVsEta"));
348 TH1* hNTrackletVsEta = static_cast<TH1*>(nchList->FindObject("NTrackletVsEta"));
349 TH1* hNTrackletVsPhi = static_cast<TH1*>(nchList->FindObject("NTrackletVsPhi"));
351 TH1* hNchVsEta =static_cast<TH1*>(hNTrackletVsEta->Clone("NchVsEta"));
353 TProfile* hMeanTrackletsVsEta = static_cast<TProfile*>(Histo(eventSelection,triggerClassName,centrality,"MeanTrackletsVsEta"));
354 TProfile* hMeanNchVsEta = static_cast<TProfile*>(Histo(eventSelection,triggerClassName,centrality,"MeanNchVsEta"));
356 TH2* hEventsVsZVertexVsEta = static_cast<TH2*>(Histo(eventSelection,triggerClassName,centrality,"EventsVsZVertexVsEta"));
361 Double_t nTracklets(0.0);
363 for (Int_t j = 1 ; j <= fEtaAxis->GetNbins() ; j++) // Loop over eta bins
365 Double_t correction = hSPDcorrectionVsEta->GetBinContent(j);
367 Double_t eta = fEtaAxis->GetBinCenter(j);
369 if ( correction < 0 ) continue;
370 else if ( correction == 0.0 ) // No tracklets found in this eta bin.
372 correction = GetSPDCorrection(SPDZv,eta);
374 if ( correction == 0. || correction > 2.5) continue; // We need to know if the eta bin is in a region we want to take into account to count or not the zero
377 Double_t ntr = hNTrackletVsEta->GetBinContent(j); // Tracklets in eta bin
379 nch += ntr * correction; // Number of charged particles (corrected tracklets)
383 hMeanTrackletsVsEta->Fill(eta,ntr); // Fill the number of tracklets of each eta bin in the profile
385 hMeanNchVsEta->Fill(eta,ntr*correction);
387 ++nBins; // We sum up the number of bins entering in the computation
389 // Fill the number of charged particles of each eta bin in the profile
390 hNchVsEta->SetBinContent( j, hNchVsEta->GetBinContent(j) * correction );
392 hEventsVsZVertexVsEta->Fill(SPDZv,eta,1.0); // Fill 1 count each eta bin where the events contributes
395 AddHisto(eventSelection,triggerClassName,centrality,"TrackletsVsZVertexVsPhi",SPDZv,hNTrackletVsPhi);
396 AddHisto(eventSelection,triggerClassName,centrality,"TrackletsVsZVertexVsEta",SPDZv,hNTrackletVsEta);
398 AddHisto(eventSelection,triggerClassName,centrality,"NchVsZVertexVsEta",SPDZv,hNchVsEta);
400 Histo(eventSelection,triggerClassName,centrality,"Tracklets")->Fill(nTracklets);
401 Histo(eventSelection,triggerClassName,centrality,"MeanTrackletsVsZVertex")->Fill(SPDZv,nTracklets);
402 Histo(eventSelection,triggerClassName,centrality,"MeanNchVsZVertex")->Fill(SPDZv,nch);
404 Histo(eventSelection,triggerClassName,centrality,"TrackletsVsNch")->Fill(nTracklets,nch);
405 Histo(eventSelection,triggerClassName,centrality,"Nch")->Fill(nch);
407 Double_t V0AMult = 0.;
408 Double_t V0CMult = 0.;
410 AliVVZERO* vzero = aod->GetVZEROData();
413 Double_t multV0A = vzero->GetMTotV0A();
414 V0AMult = AliESDUtils::GetCorrV0A(multV0A,SPDZv);
415 Double_t multV0C = vzero->GetMTotV0C();
416 V0CMult = AliESDUtils::GetCorrV0C(multV0C,SPDZv);
418 Histo(eventSelection,triggerClassName,centrality,"V0AMultVsNch")->Fill(V0AMult,nch);
419 Histo(eventSelection,triggerClassName,centrality,"V0CMultVsNch")->Fill(V0CMult,nch);
426 // Mean dNch/dEta computation
427 Double_t meandNchdEta(0.);
431 meandNchdEta = nch / (nBins*fEtaAxis->GetBinWidth(5)); // Divide by nBins to get the mean and by the binWidht to get the d/dEta
434 Histo(eventSelection,triggerClassName,centrality,"dNchdEta")->Fill(meandNchdEta);
440 //_____________________________________________________________________________
441 void AliAnalysisMuMuNch::FillHistosForMCEvent(const char* eventSelection,const char* triggerClassName,const char* centrality)
443 /// Fill input MC multiplicity histos
445 if ( IsHistogrammingDisabled() ) return;
447 TList* nchList = static_cast<TList*>(Event()->FindListObject("NCH"));
449 if (!nchList || nchList->IsEmpty())
454 Double_t MCZv = AliAnalysisMuonUtility::GetMCVertexZ(Event(),MCEvent()); // Definition of MC generated z vertex
455 AliVVertex* vertex = static_cast<AliAODEvent*>(Event())->GetPrimaryVertexSPD();
459 //____Resolution Histos___
460 if ( !fSPDCorrection && fResolution )
462 Int_t nContributors(0);
465 nContributors = vertex->GetNContributors();
466 SPDZv = vertex->GetZ();
468 MCHisto(eventSelection,triggerClassName,centrality,"SPDZvResVsnC")->Fill(nContributors,SPDZv - MCZv);
469 MCHisto(eventSelection,triggerClassName,centrality,"SPDZvResVsMCz")->Fill(MCZv,SPDZv - MCZv);
471 Double_t EtaReco(0.),EtaMC(0.),PhiReco(0.),PhiMC(0.);
472 Int_t i(-1),labelEtaReco(-1),labelEtaMC(-1),labelPhiReco(-1),labelPhiMC(-1);
474 while ( i < nchList->GetEntries() - 1 )
477 while ( nchList->At(i)->IsA() != TObjString::Class() ) // In case there is a diferent object, just to skip it
482 TParameter<Double_t>* p = static_cast<TParameter<Double_t>*>(nchList->At(i));
486 if ( TString(p->GetName()).Contains("EtaReco") ) // We take the reco eta
488 sscanf(p->GetName(),"EtaReco%d",&labelEtaReco);
489 EtaReco = p->GetVal();
490 MCHisto(eventSelection,triggerClassName,centrality,"Eta")->Fill(EtaReco);
492 else if ( TString(p->GetName()).Contains("EtaMC") ) // We take the generated eta
494 sscanf(p->GetName(),"EtaMC%d",&labelEtaMC);
496 MCHisto(eventSelection,triggerClassName,centrality,"MCEta")->Fill(EtaMC);
498 if ( labelEtaReco > 0 && labelEtaReco == labelEtaMC ) // To be sure we compute the difference for the same particle
500 labelEtaReco = -1; // Restart of the label value to avoid double count the eta difference when computing the phi one
501 Double_t EtaDif = EtaReco - EtaMC;
502 MCHisto(eventSelection,triggerClassName,centrality,"EtaRes")->Fill(EtaDif);
503 MCHisto(eventSelection,triggerClassName,centrality,"EtaResVsZ")->Fill(MCZv,EtaDif);
504 MCHisto(eventSelection,triggerClassName,centrality,"EtaResVsnC")->Fill(nContributors,EtaDif);
508 else if ( TString(p->GetName()).Contains("PhiReco") ) // We take the reco phi
510 sscanf(p->GetName(),"PhiReco%d",&labelPhiReco);
511 PhiReco = p->GetVal();
512 MCHisto(eventSelection,triggerClassName,centrality,"Phi")->Fill(PhiReco);
514 else if ( TString(p->GetName()).Contains("PhiMC") ) // We take the generated phi
516 sscanf(p->GetName(),"PhiMC%d",&labelPhiMC);
518 MCHisto(eventSelection,triggerClassName,centrality,"MCPhi")->Fill(PhiMC);
521 if ( labelPhiReco > 0 && labelPhiReco == labelPhiMC ) // To be sure we compute the difference for the same particle
523 labelPhiReco = -1; // Restart of the label value to avoid double count the phi difference when computing the eta one
524 Double_t PhiDif = PhiReco - PhiMC;
525 MCHisto(eventSelection,triggerClassName,centrality,"PhiRes")->Fill(PhiDif);
527 //___With the following algorithm we refer the differences to the interval [-Pi/2,Pi/2]
528 if ( PhiDif < -TMath::PiOver2() && PhiDif > -TMath::Pi() )
530 PhiDif = -TMath::Pi() - PhiDif;
532 else if ( PhiDif < -TMath::Pi() )
534 PhiDif = -2.*TMath::Pi() - PhiDif;
535 if ( PhiDif < -TMath::PiOver2() )
537 PhiDif = -TMath::Pi() - PhiDif;
541 else if ( PhiDif > TMath::PiOver2() && PhiDif < TMath::Pi() )
543 PhiDif = TMath::Pi() - PhiDif;
545 else if ( PhiDif > TMath::Pi() )
547 PhiDif = 2.*TMath::Pi() - PhiDif;
548 if ( PhiDif > TMath::PiOver2() )
550 PhiDif = TMath::Pi() - PhiDif;
555 MCHisto(eventSelection,triggerClassName,centrality,"PhiResVsZ")->Fill(MCZv,PhiDif);
556 MCHisto(eventSelection,triggerClassName,centrality,"PhiResShifted")->Fill(PhiDif);
557 MCHisto(eventSelection,triggerClassName,centrality,"PhiResVsnC")->Fill(nContributors,PhiDif);
561 return; // When computing resolutions we skip the rest of the method
566 //___Multiplicity histos (just when not computing resolutions)___
567 TH1* hSPDcorrectionVsEta = static_cast<TH1*>(nchList->FindObject("MCSPDcorrectionVsEta"));
568 TH1* hNBkgTrackletsVSEta = static_cast<TH1*>(nchList->FindObject("NBkgTrackletsVSEta"));
569 TH1* hNchVsPhi = static_cast<TH1*>(nchList->FindObject("MCNchVsPhi"));
570 TH1* hNchVsEta = static_cast<TH1*>(nchList->FindObject("MCNchVsEta"));
571 TH1* hNTrackletVsEta = static_cast<TH1*>(nchList->FindObject("MCNTrackletVsEta"));
572 TH1* hNTrackletVsPhi = static_cast<TH1*>(nchList->FindObject("MCNTrackletVsPhi"));
574 TProfile* hMeanNchVsEta = static_cast<TProfile*>(MCHisto(eventSelection,triggerClassName,centrality,"MeanNchVsEta"));
576 TH2* hEventsVsZVertexVsEta = static_cast<TH2*>(MCHisto(eventSelection,triggerClassName,centrality,"EventsVsZVertexVsEta"));
580 Double_t nchSum(0.),nTracklets(0.);
581 for (Int_t j = 1 ; j <= fEtaAxis->GetNbins() ; j++) //Loop over eta bins
583 Double_t correction = hSPDcorrectionVsEta->GetBinContent(j);
585 if ( correction < 0 ) continue; // We count just the particles in the SPD acceptance.
587 nTracklets += hNTrackletVsEta->GetBinContent(j); // Reco tracklets
589 ++nBins; // We sum up the number of bins entering in the computation
591 Double_t eta = fEtaAxis->GetBinCenter(j);
592 Double_t nch = hNchVsEta->GetBinContent(j); // Generated particles
596 hMeanNchVsEta->Fill(eta,nch); // Fill the number of charged particles of each eta bin in the profile
598 hEventsVsZVertexVsEta->Fill(MCZv,eta,1.0); // Fill 1 count each eta bin where the events contributes
601 MCHisto(eventSelection,triggerClassName,centrality,"Tracklets")->Fill(nTracklets);
605 SPDZv = vertex->GetZ();
608 Bool_t isMChisto = kTRUE; // Used to get the MC histos in the Add method
610 AddHisto(eventSelection,triggerClassName,centrality,"NBkgTrackletsVsZVertexVsEta",SPDZv,hNBkgTrackletsVSEta,isMChisto);
611 AddHisto(eventSelection,triggerClassName,centrality,"NchVsZVertexVsPhi",MCZv,hNchVsPhi,isMChisto);
612 AddHisto(eventSelection,triggerClassName,centrality,"NchVsZVertexVsEta",MCZv,hNchVsEta,isMChisto);
613 AddHisto(eventSelection,triggerClassName,centrality,"TrackletsVsZVertexVsEta",SPDZv,hNTrackletVsEta,isMChisto);
614 AddHisto(eventSelection,triggerClassName,centrality,"TrackletsVsZVertexVsPhi",SPDZv,hNTrackletVsPhi,isMChisto);
616 MCHisto(eventSelection,triggerClassName,centrality,"MeanNchVsZVertex")->Fill(MCZv,nchSum);
617 MCHisto(eventSelection,triggerClassName,centrality,"Nch")->Fill(nchSum);
620 // Mean dNch/dEta computation
621 Double_t meandNchdEta(0.);
625 meandNchdEta = nchSum / (nBins*fEtaAxis->GetBinWidth(5)); // Divide by nBins to get the mean and by the binWidht to get the d/dEta
628 MCHisto(eventSelection,triggerClassName,centrality,"dNchdEta")->Fill(meandNchdEta);
630 Double_t V0AMult = 0.;
631 Double_t V0CMult = 0.;
633 AliVVZERO* vzero = Event()->GetVZEROData();
636 Double_t multV0A = vzero->GetMTotV0A();
637 V0AMult = AliESDUtils::GetCorrV0A(multV0A,MCZv);
638 Double_t multV0C = vzero->GetMTotV0C();
639 V0CMult = AliESDUtils::GetCorrV0C(multV0C,MCZv);
641 MCHisto(eventSelection,triggerClassName,centrality,"V0AMultVsNch")->Fill(V0AMult,nchSum);
642 MCHisto(eventSelection,triggerClassName,centrality,"V0CMultVsNch")->Fill(V0CMult,nchSum);
649 //_____________________________________________________________________________
650 void AliAnalysisMuMuNch::GetEtaRangeSPD(Double_t spdZVertex, Double_t etaRange[])
652 // Returns the SPD eta range for a given z vertex.
654 Double_t etaMax(fEtaMax),etaMin(fEtaMin);
656 Double_t vf1LR = fSPD1LR->Eval(spdZVertex); //Eta values for the z vertex over the SPD acceptance curves
657 Double_t vf2LR = fSPD2LR->Eval(spdZVertex);
658 Double_t vf1LL = fSPD1LL->Eval(spdZVertex);
659 Double_t vf2LL = fSPD2LL->Eval(spdZVertex);
661 //____We start by asigning the eta range as the eta values in the SPD acceptance curve
662 if ( spdZVertex < 0. )
665 etaMin = TMath::Max(vf1LL,vf2LL);
669 etaMax = TMath::Min(vf1LR,vf2LR);
675 //____Algorithm to avoid taking bins which are crossed by the SPD acceptance curves
676 Int_t binYMin = fEtaAxis->FindBin(etaMin); // Find the corresponding bins for eta max & min and z vertex
677 Int_t binYMax = fEtaAxis->FindBin(etaMax);
678 Int_t binX = fZAxis->FindBin(spdZVertex);
680 // Define the values for the relevant edges of the eta and z bins
681 Double_t upEdge = fEtaAxis->GetBinUpEdge(binYMax); // up edge of the top eta bin
682 Double_t lowEdge = fEtaAxis->GetBinLowEdge(binYMin); // low edge of the bottom eta bin
683 Double_t leftEdge = fZAxis->GetBinLowEdge(binX); // left edge of the z bin
684 Double_t rightEdge = fZAxis->GetBinUpEdge(binX); // right edge of the z bin
686 Double_t etaMaxTemp(0.),etaMinTemp(0.);
687 if ( spdZVertex < 0. )
689 etaMaxTemp = fSPD2LR->Eval(rightEdge); // Define the temporary eta max as the value of the curve int the righ edge of the bin
690 etaMinTemp = TMath::Max(fSPD1LL->Eval(leftEdge),fSPD2LL->Eval(leftEdge));
694 etaMaxTemp = TMath::Min(fSPD1LR->Eval(rightEdge),fSPD2LR->Eval(rightEdge));
695 etaMinTemp = fSPD2LL->Eval(leftEdge);
698 while ( upEdge > etaMaxTemp ) //We take eta max as the up edge of the 1st bin which is inside the SPD acceptance but not crossed by the curve
700 binYMax = binYMax - 1; // Since the up edge of the current bin is bigger than the SPD acc curve we move 1 bin below
701 upEdge = fEtaAxis->GetBinUpEdge(binYMax); // Take the up edge of the new bin
702 etaMax = upEdge - 1E-6; // We substract 1E-6 cause the up edge of the a bin belongs to the bin+1
706 //We take eta min as the low edge of the 1st bin which is inside the SPD acceptance but not crossed by the curve
707 while ( lowEdge < etaMinTemp )
709 binYMin = binYMin + 1; // Since the low edge of the current bin is smaller than the SPD acc curve we move 1 bin above
710 lowEdge = fEtaAxis->GetBinLowEdge(binYMin); // Take the low edge of the new bin
711 etaMin = lowEdge + 1E-6;
715 // In case the eta range we want (given in the constructor) is smaller than the one found by the algorithm (max range) we redefine the values
716 if ( etaMin < fEtaMin ) etaMin = fEtaMin + 1E-6;
717 if ( etaMax > fEtaMax ) etaMax = fEtaMax - 1E-6;
719 etaRange[0] = etaMin;
720 etaRange[1] = etaMax;
723 //_____________________________________________________________________________
724 Double_t AliAnalysisMuMuNch::GetSPDCorrection(Double_t zvert, Double_t eta) const
728 AliFatal("ERROR: No SPD Correction");
731 Int_t bin = fSPDCorrection->FindBin(zvert,eta);
732 return fSPDCorrection->GetBinContent(bin);
736 //==============================These methods are useless here, anyway they should go in the EventCutterClass=================
737 //_____________________________________________________________________________
738 Bool_t AliAnalysisMuMuNch::HasAtLeastNTrackletsInEtaRange(const AliVEvent& event, Int_t n, Double_t& etaMin, Double_t& etaMax) const
740 if ( event.IsA() != AliAODEvent::Class() )
745 AliAODTracklets* tracklets = static_cast<const AliAODEvent&>(event).GetTracklets();
752 Int_t nTrackletsInRange(0);
754 Int_t nTracklets = tracklets->GetNumberOfTracklets();
756 for (Int_t i = 0 ; i < nTracklets && nTrackletsInRange < n; i++)
758 Double_t eta = -TMath::Log(TMath::Tan(tracklets->GetTheta(i)/2.0));
760 if ( eta > etaMin && eta < etaMax )
766 return (nTrackletsInRange>=n);
769 //_____________________________________________________________________________
770 void AliAnalysisMuMuNch::NameOfHasAtLeastNTrackletsInEtaRange(TString& name, Int_t n, Double_t& etaMin, Double_t& etaMax) const
772 if ( TMath::AreEqualAbs(TMath::Abs(etaMin),TMath::Abs(etaMax),1E-9 ) )
774 name.Form("ATLEAST%dTRKLINABSETALT%3.1f",n,TMath::Abs(etaMin));
778 name.Form("ATLEAST%dTRKLINETA%3.1f-%3.1f",n,etaMin,etaMax);
782 //_____________________________________________________________________________
783 void AliAnalysisMuMuNch::SetEvent(AliVEvent* event, AliMCEvent* mcEvent)
785 /// Set the event, compute multiplicities and add them to the event
787 if ( event->IsA() != AliAODEvent::Class() )
789 AliError("Only working for AODs for the moment.");
793 AliAnalysisMuMuBase::SetEvent(event,mcEvent); // To have Event() and MCEvent() method working
795 TList* nchList = static_cast<TList*>(event->FindListObject("NCH")); // Define the list with the NCH info for each event
799 nchList->SetOwner(kTRUE);
800 nchList->SetName("NCH");
801 event->AddObject(nchList);
804 const AliAODVertex* vertexSPD = static_cast<const AliAODEvent*>(Event())->GetPrimaryVertexSPD(); // SPD vertex object
805 AliAODTracklets* tracklets = static_cast<const AliAODEvent*>(Event())->GetTracklets(); // Tracklets object
807 TH1* hSPDcorrectionVsEta(0x0); // Pointers for the individual event histos
809 TH1* hNTrackletVsEta(0x0);
810 TH1* hNTrackletVsPhi(0x0);
812 //_______Create once the histos with the individual event "properties" (cleared at the beginning of each new event)_______
813 if ( !fResolution ) // When computing resolutions we dont do anything else
815 if ( !Histo("AliAnalysisMuMuNch","SPDcorrectionVsEta") )
817 CreateEventHistos(kHistoForData | kHistoForMCInput,"AliAnalysisMuMuNch","SPDcorrectionVsEta","SPD correction-like vs #eta;#eta",fEtaAxis->GetNbins(),fEtaAxis->GetXmin(),fEtaAxis->GetXmax());
819 CreateEventHistos(kHistoForMCInput,"AliAnalysisMuMuNch","NchVsEta","Nch vs #eta;#eta",fEtaAxis->GetNbins(),fEtaAxis->GetXmin(),fEtaAxis->GetXmax());
821 CreateEventHistos(kHistoForData | kHistoForMCInput,"AliAnalysisMuMuNch","NTrackletVsEta","Ntracklet vs #eta;#eta",fEtaAxis->GetNbins(),fEtaAxis->GetXmin(),fEtaAxis->GetXmax());
823 CreateEventHistos(kHistoForData,"AliAnalysisMuMuNch","NBkgTrackletsVSEta","NBkg Tracklets vs #eta;#eta",fEtaAxis->GetNbins(),fEtaAxis->GetXmin(),fEtaAxis->GetXmax());
825 Double_t phimin = 0.; //Phi range
826 Double_t phimax = 2*TMath::Pi();
827 Int_t nphibins = GetNbins(phimin,phimax,0.05);
829 CreateEventHistos(kHistoForData | kHistoForMCInput,"AliAnalysisMuMuNch","NTrackletVsPhi","Ntracklet vs #phi;#phi",nphibins,phimin,phimax);
831 CreateEventHistos(kHistoForMCInput,"AliAnalysisMuMuNch","NchVsPhi","Nch vs #phi;#phi",nphibins,phimin,phimax);
833 CreateEventHistos(kHistoForData | kHistoForMCInput,"AliAnalysisMuMuNch","test","test",fZAxis->GetNbins(),fZAxis->GetXmin(),fZAxis->GetXmax(),fEtaAxis->GetNbins(),fEtaAxis->GetXmin(),fEtaAxis->GetXmax());
835 Histo("AliAnalysisMuMuNch","test")->GetListOfFunctions()->Add(fSPD1LR);
836 Histo("AliAnalysisMuMuNch","test")->GetListOfFunctions()->Add(fSPD1LL);
837 Histo("AliAnalysisMuMuNch","test")->GetListOfFunctions()->Add(fSPD2LR);
838 Histo("AliAnalysisMuMuNch","test")->GetListOfFunctions()->Add(fSPD2LL);
843 hSPDcorrectionVsEta = Histo("AliAnalysisMuMuNch","SPDcorrectionVsEta"); // Set the individual event histos
844 hNTrackletVsEta = Histo("AliAnalysisMuMuNch","NTrackletVsEta");
845 hNTrackletVsPhi = Histo("AliAnalysisMuMuNch","NTrackletVsPhi");
848 hSPDcorrectionVsEta->Reset(); // Reset of the individual event histos
849 hNTrackletVsEta->Reset();
850 hNTrackletVsPhi->Reset();
853 Double_t etaRange[2]; // Variables we will use in the multiplicity computation
856 Double_t thetaTracklet(0.),phiTracklet(0.),etaTracklet(0.);
861 //____Data (or Reco if simu) multiplicity computation___
862 if ( fSPDCorrection && !fResolution ) // When computing resolutions we dont do anything else
864 if ( tracklets && vertexSPD )
866 Double_t SPDZv = vertexSPD->GetZ();
868 GetEtaRangeSPD(SPDZv,etaRange);
870 Histo("AliAnalysisMuMuNch","test")->Fill(SPDZv,etaRange[1]);
871 Histo("AliAnalysisMuMuNch","test")->Fill(SPDZv,etaRange[0]);
873 nTracklets = tracklets->GetNumberOfTracklets();
876 for (Int_t i = 0 ; i < nTracklets ; i++)
878 thetaTracklet = tracklets->GetTheta(i);
879 etaTracklet = -TMath::Log(TMath::Tan(thetaTracklet/2.));
880 if ( etaTracklet < etaRange[0] || etaTracklet > etaRange[1] ) continue; // Avoid tracklets out of the eta SPD acceptance or out of the eta cut
882 SPDr = GetSPDCorrection(SPDZv,etaTracklet);
884 Int_t bin = fEtaAxis->FindBin(etaTracklet);
886 if ( SPDr!=0. && SPDr <= 2.5) // Threshold to reduce border effects
888 hSPDcorrectionVsEta->SetBinContent(bin,SPDr);
889 hNTrackletVsEta->Fill(etaTracklet);
890 hNTrackletVsPhi->Fill(tracklets->GetPhi(i));
892 else // If the correction is above the threshold we store a -1 in the correction to skip this eta bin int the fill method
894 hSPDcorrectionVsEta->SetBinContent(bin,-1.0);
898 //___ Fill the out-of-eta-range bins with -1.0
900 binMin = fEtaAxis->FindBin(etaRange[0]);
901 binMax = fEtaAxis->FindBin(etaRange[1]);
903 for ( Int_t i = 1; i < binMin; ++i )
905 hSPDcorrectionVsEta->SetBinContent(i,-1.0);
907 for ( Int_t i = binMax + 1 ; i <= fEtaAxis->GetNbins(); ++i )
909 hSPDcorrectionVsEta->SetBinContent(i,-1.0);
912 nchList->Clear(); // We clear the NCH list for this new event
914 if ( !IsHistogrammingDisabled() )
916 nchList->Add(hSPDcorrectionVsEta->Clone());
917 nchList->Add(hNTrackletVsEta->Clone());
918 nchList->Add(hNTrackletVsPhi->Clone());
921 //----- Mean dNchdEta computation to set it into the event
922 for (Int_t j = 1 ; j <= fEtaAxis->GetNbins() ; j++) // Loop over eta bins
924 Double_t correction = hSPDcorrectionVsEta->GetBinContent(j);
926 Double_t eta = fEtaAxis->GetBinCenter(j);
928 if ( correction < 0 ) continue; // If the correction is < 0 we skip that eta bin
929 else if ( correction == 0.0 ) // If the correction is 0 we have no tracklets in that eta bin
931 Double_t spdCorrection = GetSPDCorrection(SPDZv,eta);
932 if ( spdCorrection == 0. || spdCorrection > 2.5) continue; // If the correction in the eta bin is not within the threshold we do not count the "0"(that eta bin will not count for nBins)
935 nch += hNTrackletVsEta->GetBinContent(j) * correction; // Number of charged particles (tracklets*SPDcorrection)
937 ++nBins; // We sum up the number of bins entering in the computation
940 Double_t meandNchdEta(0.); // We compute the mean dNch/dEta in the event
943 meandNchdEta = nch / (nBins*fEtaAxis->GetBinWidth(5));
946 nchList->Add(new TParameter<Double_t>("MeandNchdEta",meandNchdEta)); // We add the mean dNch/dEta to the event. It will serve us as a multiplicity estimator.
951 else nchList->Clear(); //To clear the NCH list for MC in case the event has no reconstructed SPD vertex
955 else nchList->Clear(); // To clear the NCH list for MC in case we have MC and no correction (SPD correction computation mode)
958 //____Input MC multiplicity computation ___
961 if ( !fResolution ) //When computing resolutions we dont do anything else
963 Double_t MCZv = AliAnalysisMuonUtility::GetMCVertexZ(Event(),MCEvent());
964 GetEtaRangeSPD(MCZv,etaRange);
966 hNchVsEta = MCHisto("AliAnalysisMuMuNch","NchVsEta");
967 hSPDcorrectionVsEta = MCHisto("AliAnalysisMuMuNch","SPDcorrectionVsEta");
968 TH1* hNchVsPhi = MCHisto("AliAnalysisMuMuNch","NchVsPhi");
969 hNTrackletVsEta = MCHisto("AliAnalysisMuMuNch","NTrackletVsEta");
970 hNTrackletVsPhi = MCHisto("AliAnalysisMuMuNch","NTrackletVsPhi");
972 hNTrackletVsEta->Reset();
975 hSPDcorrectionVsEta->Reset();
976 hNTrackletVsPhi->Reset();
978 //___ Fill the out-of-eta-range bins with -1.0
979 binMin = fEtaAxis->FindBin(etaRange[0]);
980 binMax = fEtaAxis->FindBin(etaRange[1]);
982 for ( Int_t i = 1; i < binMin; ++i )
984 hSPDcorrectionVsEta->SetBinContent(i,-1.0);
986 for ( Int_t i = binMax + 1 ; i <= fEtaAxis->GetNbins(); ++i )
988 hSPDcorrectionVsEta->SetBinContent(i,-1.0);
990 for ( Int_t i = binMin; i <= binMax; ++i ) // Fill the bins inside the eta range with +1
992 hSPDcorrectionVsEta->SetBinContent(i,1.0);
996 Int_t nMCTracks = MCEvent()->GetNumberOfTracks(); // MC number of MC tracks
998 for ( Int_t i = 0; i < nMCTracks ; ++i ) //Loop over generated tracks
1000 AliAODMCParticle* AODpart = static_cast<AliAODMCParticle*>(mcEvent->GetTrack(i));
1002 if ( AODpart->IsPhysicalPrimary() ) // We take only particles produced in the collision (Particles produced in the collision including products of strong and electromagnetic decay and excluding feed-down from weak decays of strange particles)
1004 if ( AODpart->Charge()!=0 ) // We take only charged particles
1006 hNchVsEta->Fill(AODpart->Eta());
1007 hNchVsPhi->Fill(AODpart->Phi());
1013 nchList->Add(hNchVsEta->Clone("MCNchVsEta"));
1014 nchList->Add(hNchVsPhi->Clone("MCNchVsPhi"));
1015 nchList->Add(hSPDcorrectionVsEta->Clone("MCSPDcorrectionVsEta"));
1017 //__Bkg tracklets and Resolution estimation __
1018 if ( tracklets ) // We can compute the Bkg tracklets and resolution only if we have the tracklets object in the event
1020 TH1* hNBkgTrackletsVSEta(0x0); // Pointer for the Bkg histo
1023 hNBkgTrackletsVSEta = Histo("AliAnalysisMuMuNch","NBkgTrackletsVSEta");
1025 hNBkgTrackletsVSEta->Reset();
1028 nTracklets = tracklets->GetNumberOfTracklets();
1030 for (Int_t i = 0 ; i < nTracklets ; i++) // Loop over tracklets to check if they come or not from the same MC particle
1032 thetaTracklet = tracklets->GetTheta(i);
1033 etaTracklet = -TMath::Log(TMath::Tan(thetaTracklet/2.));
1034 phiTracklet = tracklets->GetPhi(i);
1039 hNTrackletVsEta->Fill(etaTracklet);
1040 hNTrackletVsPhi->Fill(phiTracklet);
1043 Int_t label1 = tracklets->GetLabel(i,0);
1044 Int_t label2 = tracklets->GetLabel(i,1);
1046 if (label1 != label2 ) // Tracklets not comming from the same MC particle are Bkg
1048 if (!fResolution ) hNBkgTrackletsVSEta->Fill(etaTracklet);
1050 else if ( !fSPDCorrection && fResolution ) // Compute the resolutions with the tracklets comming from the same MC particle
1052 AliAODMCParticle* AODpartMC = static_cast<AliAODMCParticle*>(MCEvent()->GetTrack(label1));
1053 Double_t etaTrackletMC = AODpartMC->Eta();
1054 Double_t phiTrackletMC = AODpartMC->Phi();
1056 // Resolution variables
1057 nchList->Add(new TParameter<Double_t>(Form("EtaReco%d",label1),etaTracklet));
1058 nchList->Add(new TParameter<Double_t>(Form("EtaMC%d",label1),etaTrackletMC));
1060 nchList->Add(new TParameter<Double_t>(Form("PhiReco%d",label1),phiTracklet));
1061 nchList->Add(new TParameter<Double_t>(Form("PhiMC%d",label1),phiTrackletMC));
1068 nchList->Add(hNTrackletVsEta->Clone("MCNTrackletVsEta"));
1069 nchList->Add(hNTrackletVsPhi->Clone("MCNTrackletVsPhi"));
1070 nchList->Add(hNBkgTrackletsVSEta->Clone());
1080 //_____________________________________________________________________________
1081 void AliAnalysisMuMuNch::Terminate(Option_t *)
1083 /// Called once at the end of the query
1084 if ( !HistogramCollection() ) return;
1086 if ( HistogramCollection()->FindObject("/MCINPUT/AliAnalysisMuMuNch/NTrackletVsEta") )
1088 HistogramCollection()->Remove("/MCINPUT/AliAnalysisMuMuNch/NTrackletVsEta");
1089 HistogramCollection()->Remove("/MCINPUT/AliAnalysisMuMuNch/NTrackletVsPhi");
1090 HistogramCollection()->Remove("/MCINPUT/AliAnalysisMuMuNch/NchVsEta");
1091 HistogramCollection()->Remove("/MCINPUT/AliAnalysisMuMuNch/NchVsPhi");
1092 HistogramCollection()->Remove("/MCINPUT/AliAnalysisMuMuNch/SPDcorrectionVsEta");
1093 HistogramCollection()->Remove("/AliAnalysisMuMuNch/NBkgTrackletsVSEta");
1096 if ( HistogramCollection()->FindObject("/AliAnalysisMuMuNch/NTrackletVsEta") )
1098 HistogramCollection()->Remove("/AliAnalysisMuMuNch/NTrackletVsEta");
1099 HistogramCollection()->Remove("/AliAnalysisMuMuNch/test");
1100 HistogramCollection()->Remove("/AliAnalysisMuMuNch/NTrackletVsPhi");
1101 HistogramCollection()->Remove("/AliAnalysisMuMuNch/SPDcorrectionVsEta");
1103 //____ Compute dNchdEta histo
1104 TObjArray* idArr = HistogramCollection()->SortAllIdentifiers();
1109 while ( (id = static_cast<TObjString*>(next())) )
1111 TProfile* p = static_cast<TProfile*>(HistogramCollection()->FindObject(Form("%s%s",id->GetName(),"MeanNchVsEta")));
1115 TH1* h = new TH1F("MeandNchdEta","Event averaged dN_{ch}/d#eta ;#eta;<dN_{ch}/d#eta>",fEtaAxis->GetNbins(),fEtaAxis->GetXmin(),fEtaAxis->GetXmax());
1117 if ( p->GetNbinsX() != h->GetNbinsX() || p->GetXaxis()->GetXmin() != h->GetXaxis()->GetXmin() || p->GetXaxis()->GetXmax() != h->GetXaxis()->GetXmax() )
1119 AliError("ERROR: Cannot compute MeandNchdEta since the binning doesn't match with MeanNchVsEta histo");
1123 for ( Int_t i = 1 ; i < h->GetNbinsX() ; i++ )
1125 h->SetBinContent(i,p->GetBinContent(i)/p->GetBinWidth(i));
1126 h->SetBinError(i,p->GetBinError(i)/p->GetBinWidth(i));
1127 h->SetEntries(p->GetEntries());
1130 HistogramCollection()->Adopt(Form("%s",id->GetName()),h);