1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
19 /// \file MUONefficiency.C
20 /// \brief add brief description
22 /// Macro (upgraded version of MUONmassPlot_ESD.C, better handling of Jpsi) to make :
23 /// - Ntuple (Ktuple) containing Upsilon kinematics variables (from kinematics.root files)
24 /// - Ntuple (ESDtuple) containing Upsilon kinematics variables from reconstruction and
25 /// combinations of 2 muons with opposite charges (ESDtupleBck will be used later)
26 /// - Some QA histograms
27 /// Ntuple are stored in the file MUONefficiency.root and ESD tree and QA histograms in AliESDs.root
29 /// \author Christophe Suire, IPN Orsay
33 #if !defined(__CINT__) || defined(__MAKECINT__)
36 #include "AliMUONTrackParam.h"
37 #include "AliMUONTrackExtrap.h"
38 #include "AliMUONESDInterface.h"
42 #include "AliRunLoader.h"
43 #include "AliHeader.h"
44 #include "AliLoader.h"
46 #include "AliMagFMaps.h"
47 #include "AliESDEvent.h"
48 #include "AliESDVertex.h"
49 #include "AliTracker.h"
50 #include "AliCDBManager.h"
51 #include "AliESDMuonTrack.h"
57 #include "TClonesArray.h"
58 #include "TLorentzVector.h"
62 #include "TParticle.h"
65 #include <Riostream.h>
66 #include <TGeoManager.h>
72 Bool_t MUONefficiency( char* filename = "galice.root", char* geoFilename = "geometry.root", char* esdFileName = "AliESDs.root",
73 Int_t ExtrapToVertex = -1, Int_t ResType = 553, Int_t FirstEvent = 0, Int_t LastEvent = 1000000 )
75 /// \param ExtrapToVertex (default -1)
76 /// - <0: no extrapolation;
77 /// - =0: extrapolation to (0,0,0);
78 /// - >0: extrapolation to ESDVertex if available, else to (0,0,0)
79 /// \param ResType 553 for Upsilon, 443 for J/Psi (default 553)
80 /// \param FirstEvent (default 0)
81 /// \param LastEvent (default 1.e6)
82 /// \param Chi2Cut to keep only tracks with chi2 per d.o.f. < Chi2Cut (default 100)
85 // MUONefficiency starts
87 // Set default CDB storage
88 AliCDBManager* man = AliCDBManager::Instance();
89 man->SetDefaultStorage("local://$ALICE_ROOT");
91 Double_t MUON_MASS = 0.105658369;
92 Double_t UPSILON_MASS = 9.4603 ;
93 Double_t JPSI_MASS = 3.097;
95 // Upper and lower bound for counting entries in the mass peak
96 // +/- 300 MeV/c^2 in this case.
97 Float_t countingRange = 0.300 ;
99 Float_t massResonance = 5.;
100 Float_t invMassMinInPeak = 0. ;
101 Float_t invMassMaxInPeak = 0. ;
103 Float_t nBinsPerGev = 40 ;
104 Float_t invMassMin = 0; Float_t invMassMax = 20;
105 Float_t ptMinResonance = 0 ; Float_t ptMaxResonance = 20 ; Int_t ptBinsResonance = 100;
108 massResonance = JPSI_MASS ;
109 invMassMinInPeak = JPSI_MASS - countingRange ; invMassMaxInPeak = JPSI_MASS + countingRange ;
110 //limits for histograms
111 invMassMin = 0 ; invMassMax = 6.;
112 ptMinResonance = 0 ; ptMaxResonance = 20 ; ptBinsResonance = 100;
115 massResonance = UPSILON_MASS;
116 invMassMinInPeak = UPSILON_MASS - countingRange ; invMassMaxInPeak = UPSILON_MASS + countingRange;
117 //limits for histograms
118 invMassMin = 0 ; invMassMax = 12.;
119 ptMinResonance = 0 ; ptMaxResonance = 20 ; ptBinsResonance = 100;
122 // Single Tracks muon cuts
123 Float_t Chi2Cut = 100.;
124 Float_t PtCutMin = 0. ;
125 Float_t PtCutMax = 10000. ;
128 // Limits for histograms
129 Float_t ptMinMuon = 0. ; Float_t ptMaxMuon = 20.; Int_t ptBinsMuon = 100 ;
130 Float_t pMinMuon = 0. ; Float_t pMaxMuon = 200.; Int_t pBinsMuon = 100 ;
133 //Reset ROOT and connect tree file
137 Int_t PRINTLEVEL = 0 ;
139 //for kinematic, i.e. reference tracks
140 TNtuple *Ktuple = new TNtuple("Ktuple","Kinematics NTuple","ev:npart:id:idmo:idgdmo:p:pt:y:theta:pseudorap:vx:vy:vz");
143 TH1F *hPtMuon = new TH1F("hPtMuon", "Muon Pt (GeV/c)", ptBinsMuon, ptMinMuon, ptMaxMuon);
144 TH1F *hPtMuonPlus = new TH1F("hPtMuonPlus", "Muon+ Pt (GeV/c)", ptBinsMuon, ptMinMuon, ptMaxMuon);
145 TH1F *hPtMuonMinus = new TH1F("hPtMuonMinus", "Muon- Pt (GeV/c)", ptBinsMuon, ptMinMuon, ptMaxMuon);
146 TH1F *hPMuon = new TH1F("hPMuon", "Muon P (GeV/c)", pBinsMuon, pMinMuon, pMaxMuon);
150 TH2F *hInvMassAll_vs_Pt;
151 TH2F *hInvMassBgk_vs_Pt;
155 hInvMassAll = new TH1F("hInvMassAll", "Mu+Mu- invariant mass (GeV/c2)", (Int_t) (nBinsPerGev*(invMassMax - invMassMin)), invMassMin, invMassMax);
156 hInvMassBg = new TH1F("hInvMassBg", "Mu+Mu- invariant mass BG(GeV/c2)", (Int_t) (nBinsPerGev*(invMassMax- invMassMin)), invMassMin, invMassMax);
157 hInvMassAll_vs_Pt = new TH2F("hInvMassAll_vs_Pt","hInvMassAll_vs_Pt",(Int_t) (nBinsPerGev*(invMassMax- invMassMin)), invMassMin, invMassMax,ptBinsResonance,ptMinResonance,ptMaxResonance);
158 hInvMassBgk_vs_Pt = new TH2F("hInvMassBgk_vs_Pt","hInvMassBgk_vs_Pt",(Int_t) (nBinsPerGev*(invMassMax- invMassMin)), invMassMin, invMassMax,ptBinsResonance,ptMinResonance,ptMaxResonance);
160 hInvMassRes = new TH1F("hInvMassRes", "Mu+Mu- invariant mass (GeV/c2) around Resonance",(Int_t) (nBinsPerGev*3*countingRange*2),massResonance-3*countingRange,massResonance+3*countingRange);
162 TH1F *hPrimaryVertex = new TH1F("hPrimaryVertex","SPD reconstructed Z vertex",150,-15,15);
163 TH1F *hChi2PerDof = new TH1F("hChi2PerDof", "Muon track chi2/d.o.f.", 100, 0., 20.);
164 TH1F *hNumberOfTrack = new TH1F("hNumberOfTrack","nb of track /evt ",20,-0.5,19.5);
165 TH1F *hRapMuon = new TH1F("hRapMuon"," Muon Rapidity",50,-4.5,-2);
166 TH1F *hRapResonance = new TH1F("hRapResonance"," Resonance Rapidity",50,-4.5,-2);
167 TH1F *hPtResonance = new TH1F("hPtResonance", "Resonance Pt (GeV/c)", 100, 0., 20.);
168 TH2F *hThetaPhiPlus = new TH2F("hThetaPhiPlus", "Theta vs Phi +", 760, -190., 190., 400, 160., 180.);
169 TH2F *hThetaPhiMinus = new TH2F("hThetaPhiMinus", "Theta vs Phi -", 760, -190., 190., 400, 160., 180.);
171 TNtuple *ESDtuple = new TNtuple("ESDtuple","Reconstructed Mu+Mu- pairs and Upsilon","ev:tw:pt:y:theta:minv:pt1:y1:theta1:q1:trig1:pt2:y2:theta2:q2:trig2");
172 TNtuple *ESDtupleBck = new TNtuple("ESDtupleBck","Reconstructed Mu+Mu- pairs for Background","ev:pt:y:theta:minv:pt1:y1:theta1:pt2:y2:theta2");
176 Int_t EventInMass = 0;
177 Int_t EventInMassMatch = 0;
187 Double_t fPxRec1, fPyRec1, fPzRec1, fE1;
188 Double_t fPxRec2, fPyRec2, fPzRec2, fE2;
189 Int_t fCharge1, fCharge2;
191 Int_t ntrackhits, nevents;
192 Int_t nprocessedevents = 0 ;
195 TLorentzVector fV1, fV2, fVtot;
197 // Import TGeo geometry (needed by AliMUONTrackExtrap::ExtrapToVertex)
199 TGeoManager::Import(geoFilename);
201 Error("MUONmass_ESD", "getting geometry from file %s failed", filename);
207 // waiting for mag field in CDB
208 printf("Loading field map...\n");
209 AliMagFMaps* field = new AliMagFMaps("Maps","Maps", 1, 1., 10., AliMagFMaps::k5kG);
210 AliTracker::SetFieldMap(field, kFALSE);
212 // open run loader and load gAlice, kinematics and header
213 AliRunLoader* runLoader = AliRunLoader::Open(filename);
215 Error("MUONefficiency", "getting run loader from file %s failed", filename);
219 runLoader->LoadgAlice();
220 gAlice = runLoader->GetAliRun();
222 Error("MUONefficiency", "no galice object found");
227 TFile* esdFile = TFile::Open(esdFileName);
228 if (!esdFile || !esdFile->IsOpen()) {
229 Error("MUONefficiency", "opening ESD file %s failed", esdFileName);
233 AliESDEvent* esd = new AliESDEvent();
234 TTree* tree = (TTree*) esdFile->Get("esdTree");
236 Error("CheckESD", "no ESD tree found");
239 esd->ReadFromTree(tree);
241 runLoader->LoadHeader();
242 Int_t runNumber = runLoader->GetHeader()->GetRun();
243 AliCDBManager::Instance()->SetRun(runNumber);
245 nevents = runLoader->GetNumberOfEvents();
246 AliMUONTrackParam trackParam;
248 // to access the particle Stack
249 runLoader->LoadKinematics("READ");
251 Int_t numberOfGeneratedResonances = 0 ;
255 Int_t track1Trigger = 0 ;
256 Float_t track1TriggerChi2 = 0 ;
257 Int_t track2Trigger = 0 ;
258 Float_t track2TriggerChi2 = 0 ;
262 for (Int_t iEvent = FirstEvent; iEvent <= TMath::Min(LastEvent, nevents - 1); iEvent++) { // Start event loop
264 if (iEvent%1000 == 0 )
265 printf("\n Nb of events analysed: %d \n",iEvent);
268 runLoader->GetEvent(iEvent);
271 // get the stack and fill the kine tree
272 AliStack *theStack = runLoader->Stack();
273 if (PRINTLEVEL > 0) theStack->DumpPStack ();
275 Int_t nparticles = (Int_t)runLoader->TreeK()->GetEntries();
276 Int_t nprimarypart = theStack->GetNprimary();
277 Int_t ntracks = theStack->GetNtrack();
279 if (PRINTLEVEL || (iEvent%100==0)) printf("\n >>> Event %d \n",iEvent);
280 if (PRINTLEVEL) cout << nprimarypart << " Particles generated (total is " << ntracks << ")"<< endl ;
282 for(Int_t iparticle=0; iparticle<nparticles; iparticle++) { // Start loop over particles
283 particle = theStack->Particle(iparticle);
285 Int_t muId = particle->GetPdgCode();
286 Int_t muM = particle->GetFirstMother();
288 Float_t muP = particle->P();
289 Float_t muPt = TMath::Sqrt(particle->Px()*particle->Px()+particle->Py()*particle->Py());
290 Float_t muY = 0.5*TMath::Log((particle->Energy()+particle->Pz()+1.e-13)/(particle->Energy()-particle->Pz()+1.e-13));
292 TParticle *theMum = theStack->Particle(muM);
293 muM = theMum->GetPdgCode();
294 muGM = theMum->GetFirstMother() ;
296 TParticle *grandMa = theStack->Particle(muGM);
297 muGM = grandMa->GetPdgCode();
303 if (muId==ResType) numberOfGeneratedResonances++;
306 Float_t muT = particle->Theta()*180/TMath::Pi();
307 Float_t muE = particle->Eta();
309 Float_t muVx = particle->Vx();
310 Float_t muVy = particle->Vy();
311 Float_t muVz = particle->Vz();
313 // If a write error occurs, the number of bytes returned is -1.
314 // If no data are written, because e.g. the branch is disabled,
315 // the number of bytes returned is 0.
316 Int_t errCode = Ktuple->Fill(iEvent,nparticles,muId,muM,muGM,muP,muPt,muY,muT,muE,muVx,muVy,muVz);
317 if (PRINTLEVEL || errCode < 1) printf("iEvent %d,nparticles %d,muId %d,muM %d,muGM %d,muP %.2f,muPt %.2f,muY %.2f,muT %.2f,muE %.2f,muVx %.2f,muVy %.2f,muVz %.2f \n", iEvent,nparticles,muId,muM,muGM,muP,muPt,muY,muT,muE,muVx,muVy,muVz);
319 } // End loop over particles
323 // get the event summary data
324 tree->GetEvent(iEvent);
326 Error("CheckESD", "no ESD object found for event %d", iEvent);
330 // get the SPD reconstructed vertex (vertexer) and fill the histogram
331 AliESDVertex* Vertex = (AliESDVertex*) esd->GetVertex();
332 if (Vertex->GetNContributors()) {
333 fZVertex = Vertex->GetZv();
334 fYVertex = Vertex->GetYv();
335 fXVertex = Vertex->GetXv();
336 errXVtx = Vertex->GetXRes();
337 errYVtx = Vertex->GetYRes();
339 hPrimaryVertex->Fill(fZVertex);
341 Int_t triggerWord = esd->GetTriggerMask();
342 Int_t nTracks = (Int_t)esd->GetNumberOfMuonTracks() ;
345 printf("\n Nb of events analysed: %d \n",iEvent);
346 cout << " number of tracks: " << nTracks <<endl;
349 // set the magnetic field for track extrapolations
350 AliMUONTrackExtrap::SetField(AliTracker::GetFieldMap());
351 // loop over all reconstructed tracks (also first track of combination)
352 for (Int_t iTrack = 0; iTrack < nTracks; iTrack++) {
355 if (!esd->GetMuonTrack(iTrack)->ContainTrackerData()) continue;
357 AliESDMuonTrack* muonTrack = new AliESDMuonTrack(*(esd->GetMuonTrack(iTrack)));
359 // extrapolate to vertex if required and available
360 if (ExtrapToVertex > 0 && Vertex->GetNContributors()) {
361 AliMUONESDInterface::GetParamAtFirstCluster(*muonTrack, trackParam);
362 AliMUONTrackExtrap::ExtrapToVertex(&trackParam, fXVertex, fYVertex, fZVertex, errXVtx, errYVtx);
363 AliMUONESDInterface::SetParamAtVertex(trackParam, *muonTrack); // put the new parameters in this copy of AliESDMuonTrack
364 } else if ((ExtrapToVertex > 0 && !Vertex->GetNContributors()) || ExtrapToVertex == 0){
365 AliMUONESDInterface::GetParamAtFirstCluster(*muonTrack, trackParam);
366 AliMUONTrackExtrap::ExtrapToVertex(&trackParam, 0., 0., 0., 0., 0.);
367 AliMUONESDInterface::SetParamAtVertex(trackParam, *muonTrack); // put the new parameters in this copy of AliESDMuonTrack
371 if (PRINTLEVEL > 5) cout << "MatchTrigger " << muonTrack->GetMatchTrigger() << " and Chi2 of matching tracks " << track1TriggerChi2 << endl ;
372 track1Trigger = muonTrack->GetMatchTrigger();
374 track1TriggerChi2 = muonTrack->GetChi2MatchTrigger();
376 track1TriggerChi2 = 0. ;
378 fCharge1 = Int_t(TMath::Sign(1.,muonTrack->GetInverseBendingMomentum()));
380 muonTrack->LorentzP(fV1);
382 ntrackhits = muonTrack->GetNHit();
383 fitfmin = muonTrack->GetChi2();
385 // transverse momentum
386 Float_t pt1 = fV1.Pt();
389 Float_t p1 = fV1.P();
392 Float_t rapMuon1 = fV1.Rapidity();
396 Float_t ch1 = fitfmin / (2.0 * ntrackhits - 5);
397 if (PRINTLEVEL > 5 ) printf(" px %f py %f pz %f pt %f NHits %d Norm.chi2 %f charge %d\n",fV1.Px(), fV1.Py(), fV1.Pz(), pt1, ntrackhits, ch1, fCharge1);
400 if ((ch1 < Chi2Cut) && (pt1 > PtCutMin) && (pt1 < PtCutMax)) { // condition for good track (Chi2Cut and PtCut)
401 if (PRINTLEVEL > 8) cout << "inside pt and chi2 cuts " << endl ;
403 // fill histos hPtMuon and hChi2PerDof
406 hChi2PerDof->Fill(ch1);
407 hRapMuon->Fill(rapMuon1);
410 hPtMuonPlus->Fill(pt1);
411 hThetaPhiPlus->Fill(fV1.Phi()*180./TMath::Pi(),fV1.Theta()*180./TMath::Pi());
413 hPtMuonMinus->Fill(pt1);
414 hThetaPhiMinus->Fill(fV1.Phi()*180./TMath::Pi(),fV1.Theta()*180./TMath::Pi());
417 // loop over second track of combination
418 for (Int_t iTrack2 = iTrack + 1; iTrack2 < nTracks; iTrack2++) {
421 if (!esd->GetMuonTrack(iTrack2)->ContainTrackerData()) continue;
423 AliESDMuonTrack* muonTrack2 = new AliESDMuonTrack(*(esd->GetMuonTrack(iTrack2)));
425 // extrapolate to vertex if required and available
426 if (ExtrapToVertex > 0 && Vertex->GetNContributors()) {
427 AliMUONESDInterface::GetParamAtFirstCluster(*muonTrack2, trackParam);
428 AliMUONTrackExtrap::ExtrapToVertex(&trackParam, fXVertex, fYVertex, fZVertex, errXVtx, errYVtx);
429 AliMUONESDInterface::SetParamAtVertex(trackParam, *muonTrack2); // put the new parameters in this copy of AliESDMuonTrack
430 } else if ((ExtrapToVertex > 0 && !Vertex->GetNContributors()) || ExtrapToVertex == 0){
431 AliMUONESDInterface::GetParamAtFirstCluster(*muonTrack2, trackParam);
432 AliMUONTrackExtrap::ExtrapToVertex(&trackParam, 0., 0., 0., 0., 0.);
433 AliMUONESDInterface::SetParamAtVertex(trackParam, *muonTrack2); // put the new parameters in this copy of AliESDMuonTrack
436 track2Trigger = muonTrack2->GetMatchTrigger();
438 track2TriggerChi2 = muonTrack2->GetChi2MatchTrigger();
440 track2TriggerChi2 = 0. ;
442 fCharge2 = Int_t(TMath::Sign(1.,muonTrack2->GetInverseBendingMomentum()));
444 muonTrack2->LorentzP(fV2);
446 ntrackhits = muonTrack2->GetNHit();
447 fitfmin = muonTrack2->GetChi2();
449 // transverse momentum
450 Float_t pt2 = fV2.Pt();
453 Float_t ch2 = fitfmin / (2.0 * ntrackhits - 5);
456 // condition for good track (Chi2Cut and PtCut)
457 if ((ch2 < Chi2Cut) && (pt2 > PtCutMin) && (pt2 < PtCutMax)) {
459 // condition for opposite charges
460 if ((fCharge1 * fCharge2) == -1) {
462 if (PRINTLEVEL > 8) cout << "---------> Now filling the Ntuple " << endl ;
466 Float_t invMass = fVtot.M();
468 if (fCharge1 < 0){ //mu_minus is index 1 in the ntuple
469 Float_t ESDFill[16] = {iEvent,triggerWord,fVtot.Pt(),fVtot.Rapidity(),fVtot.Theta()/TMath::Pi()*180,invMass,fV1.Pt(),fV1.Rapidity(),fV1.Theta()/TMath::Pi()*180,fCharge1,track1TriggerChi2,fV2.Pt(),fV2.Rapidity(),fV2.Theta()/TMath::Pi()*180,fCharge2,track2TriggerChi2};
470 ESDtuple->Fill(ESDFill);
473 Float_t ESDFill[16] = {iEvent,triggerWord,fVtot.Pt(),fVtot.Rapidity(),fVtot.Theta()/TMath::Pi()*180,invMass,fV2.Pt(),fV2.Rapidity(),fV2.Theta()/TMath::Pi()*180,fCharge2,track2TriggerChi2,fV1.Pt(),fV1.Rapidity(),fV1.Theta()/TMath::Pi()*180,fCharge1,track1TriggerChi2};
474 ESDtuple->Fill(ESDFill);
477 // fill histos hInvMassAll and hInvMassRes
478 hInvMassAll->Fill(invMass);
479 hInvMassRes->Fill(invMass);
480 hInvMassAll_vs_Pt->Fill(invMass,fVtot.Pt());
484 ptTrig = 0x08;// mask for Hpt unlike sign pair
485 else if (ResType == 443)
486 ptTrig = 0x04;// mask for Lpt unlike sign pair
489 if (esd->GetTriggerMask() & ptTrig) NbTrigger++;
491 if (invMass > invMassMinInPeak && invMass < invMassMaxInPeak) {
493 hRapResonance->Fill(fVtot.Rapidity());
494 hPtResonance->Fill(fVtot.Pt());
496 // match with trigger
497 if (muonTrack2->GetMatchTrigger()>=0 && (esd->GetTriggerMask() & ptTrig)) EventInMassMatch++;
501 } // if (fCharge1 * fCharge2) == -1)
502 } // if ((ch2 < Chi2Cut) && (pt2 > PtCutMin) && (pt2 < PtCutMax))
504 } // for (Int_t iTrack2 = iTrack + 1; iTrack2 < iTrack; iTrack2++)
505 } // if (ch1 < Chi2Cut) && (pt1 > PtCutMin)&& (pt1 < PtCutMax) )
507 } // for (Int_t iTrack = 0; iTrack < nrectracks; iTrack++)
509 hNumberOfTrack->Fill(nTracks);
510 // esdFile->Delete();
512 } // End of event loop
515 // Loop over events for bg event
517 Double_t thetaPlus, phiPlus;
518 Double_t thetaMinus, phiMinus;
519 Float_t PtMinus, PtPlus;
521 for (Int_t iEvent = 0; iEvent < hInvMassAll->Integral(); iEvent++) { // Loop over events for bg event
522 // according to Christian a 3d phi-theta-pt random pick would take better care
523 // of all correlations
525 hThetaPhiPlus->GetRandom2(phiPlus, thetaPlus);
526 hThetaPhiMinus->GetRandom2(phiMinus,thetaMinus);
527 PtPlus = hPtMuonPlus->GetRandom();
528 PtMinus = hPtMuonMinus->GetRandom();
530 fPxRec1 = PtPlus * TMath::Cos(TMath::Pi()/180.*phiPlus);
531 fPyRec1 = PtPlus * TMath::Sin(TMath::Pi()/180.*phiPlus);
532 fPzRec1 = PtPlus / TMath::Tan(TMath::Pi()/180.*thetaPlus);
534 fE1 = TMath::Sqrt(MUON_MASS * MUON_MASS + fPxRec1 * fPxRec1 + fPyRec1 * fPyRec1 + fPzRec1 * fPzRec1);
535 fV1.SetPxPyPzE(fPxRec1, fPyRec1, fPzRec1, fE1);
537 fPxRec2 = PtMinus * TMath::Cos(TMath::Pi()/180.*phiMinus);
538 fPyRec2 = PtMinus * TMath::Sin(TMath::Pi()/180.*phiMinus);
539 fPzRec2 = PtMinus / TMath::Tan(TMath::Pi()/180.*thetaMinus);
541 fE2 = TMath::Sqrt(MUON_MASS * MUON_MASS + fPxRec2 * fPxRec2 + fPyRec2 * fPyRec2 + fPzRec2 * fPzRec2);
542 fV2.SetPxPyPzE(fPxRec2, fPyRec2, fPzRec2, fE2);
547 // fill histos hInvMassAll and hInvMassRes
548 hInvMassBg->Fill(fVtot.M());
549 hInvMassBgk_vs_Pt->Fill( fVtot.M(), fVtot.Pt() );
551 // Ntuple for background... more convenient
552 ESDtupleBck->Fill(iEvent,fVtot.Pt(),fVtot.Rapidity(),fVtot.Theta()/TMath::Pi()*180,fVtot.M(),fV2.Pt(),fV2.Rapidity(),fV2.Theta()/TMath::Pi()*180,fV1.Pt(),fV1.Rapidity(),fV1.Theta()/TMath::Pi()*180);
554 } // End loop over events for background
557 // File for histograms and histogram booking
558 TString outfilename = "MUONefficiency.root";
559 TFile *ntupleFile = new TFile(outfilename.Data(), "RECREATE");
563 ESDtupleBck->Write();
567 TFile *histoFile = new TFile("MUONhistos.root", "RECREATE");
568 hPrimaryVertex->Write();
570 hPtMuonPlus->Write();
571 hPtMuonMinus->Write();
573 hChi2PerDof->Write();
574 hInvMassAll->Write();
576 hInvMassAll_vs_Pt ->Write();
577 hInvMassBgk_vs_Pt->Write();
578 hInvMassRes->Write();
579 hNumberOfTrack->Write();
581 hRapResonance ->Write();
582 hPtResonance ->Write();
583 hThetaPhiPlus ->Write();
584 hThetaPhiMinus ->Write();
588 cout << "*************************************************" << endl;
590 cout << "MUONefficiency : " << nprocessedevents << " events processed" << endl;
592 cout << "Number of generated J/Psi (443) : " << numberOfGeneratedResonances << endl ;
594 cout << "Number of generated Upsilon (553) :" << numberOfGeneratedResonances << endl ;
595 cout << "Chi2Cut for muon tracks = " << Chi2Cut << endl;
596 cout << "PtCutMin for muon tracks = " << PtCutMin << endl;
597 cout << "PtCutMax for muon tracks = " << PtCutMax << endl;
599 hInvMassAll->Fit("gaus","q0");
601 TF1* f1 = hInvMassAll->GetFunction("gaus");
603 cout << "Entries (unlike sign dimuons) : " << hInvMassAll->GetEntries()
604 << Form(". Rough sigma = %7.2f MeV/c2",f1->GetParameter(2)*1000.0) << endl;
606 cout << "Entries (unlike sign dimuons) in the mass range ["<<invMassMinInPeak<<";"<<invMassMaxInPeak<<"] : " << EventInMass <<endl;
608 if (ptTrig==0x800) cout << "Unlike Pair - All Pt" ;
609 if (ptTrig==0x400) cout << "Unlike Pair - High Pt" ;
610 if (ptTrig==0x200) cout << "Unlike Pair - Low Pt" ;
611 cout << " triggers : " << NbTrigger << endl;
613 cout << "Entries in the mass range with matching between reconstructed tracks and trigger tracks " << EventInMassMatch << endl;