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 **************************************************************************/
17 // Jet kinematics reader
18 // MC reader for jet analysis
19 // Author: Andreas Morsch
20 // andreas.morsch@cern.ch
24 #include <TClonesArray.h>
26 #include <TParticle.h>
27 #include <TParticlePDG.h>
29 #include <TLorentzVector.h>
31 #include <TDatabasePDG.h>
34 #include "AliJetKineReaderHeader.h"
35 #include "AliJetKineReader.h"
36 #include "AliRunLoader.h"
39 ClassImp(AliJetKineReader)
41 AliJetKineReader::AliJetKineReader()
50 //____________________________________________________________________________
52 AliJetKineReader::~AliJetKineReader()
58 //____________________________________________________________________________
60 void AliJetKineReader::OpenInputFiles()
62 // Opens the input file using the run loader
63 const char* dirName = fReaderHeader->GetDirectory();
65 sprintf(path, "%s/galice.root",dirName);
66 fRunLoader = AliRunLoader::Open(path);
67 fRunLoader->LoadKinematics();
68 fRunLoader->LoadHeader();
70 Int_t nMax = fRunLoader->GetNumberOfEvents();
71 printf("\nTotal number of events = %d", nMax);
73 // set number of events in header
74 if (fReaderHeader->GetLastEvent() == -1)
75 fReaderHeader->SetLastEvent(nMax);
77 Int_t nUsr = fReaderHeader->GetLastEvent();
78 fReaderHeader->SetLastEvent(TMath::Min(nMax, nUsr));
82 //____________________________________________________________________________
84 void AliJetKineReader::FillMomentumArray(Int_t event)
87 // Fill momentum array for event
93 fRunLoader->GetEvent(event);
94 AliStack* stack = fRunLoader->Stack();
95 Int_t nt = stack->GetNprimary();
96 // Get cuts set by user
97 Double_t ptMin = ((AliJetKineReaderHeader*) fReaderHeader)->GetPtCut();
98 fAliHeader = fRunLoader->GetHeader();
100 // Loop over particles
101 for (Int_t it = 0; it < nt; it++) {
102 TParticle *part = stack->Particle(it);
103 Int_t status = part->GetStatusCode();
104 Int_t pdg = TMath::Abs(part->GetPdgCode());
105 Float_t pt = part->Pt();
109 || (pdg == 12 || pdg == 14)
113 if (((AliJetKineReaderHeader*)fReaderHeader)->FastSimTPC()) {
114 Float_t charge = TDatabasePDG::Instance()->GetParticle(pdg)->Charge();
117 || (gRandom->Rndm() < 0.1)
121 fMass = part->GetCalcMass();
122 fPdgC = part->GetPdgCode();
123 // Fill momentum array
125 new ((*fMomentumArray)[goodTrack])
126 TLorentzVector(part->Px(),part->Py(),part->Pz(), part->Energy());
129 printf("\nNumber of good tracks %d \n", goodTrack);