]> git.uio.no Git - u/mrichter/AliRoot.git/blob - JETAN/AliJetMCReader.cxx
Coding rule violations corrected
[u/mrichter/AliRoot.git] / JETAN / AliJetMCReader.cxx
1 /**************************************************************************
2  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3  *                                                                        *
4  * Author: The ALICE Off-line Project.                                    *
5  * Contributors are mentioned in the code where appropriate.              *
6  *                                                                        *
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  **************************************************************************/
15  
16 // Jet MC Reader 
17 // MC reader for jet analysis
18 // Author: Mercedes Lopez Noriega (mercedes.lopez.noriega@cern.ch)
19
20 // From root ...
21 #include <TClonesArray.h>
22 #include <TPDGCode.h>
23 #include <TParticle.h>
24 #include <TParticlePDG.h>
25 #include <TVector3.h>
26 #include <TLorentzVector.h>
27 #include <TSystem.h>
28 #include <TChain.h>
29 // From AliRoot ...
30 #include "AliJetMCReader.h"
31 #include "AliJetMCReaderHeader.h"
32 #include "AliESDEvent.h"
33 #include "AliESDtrack.h"
34
35 ClassImp(AliJetMCReader)
36
37
38 AliJetMCReader::AliJetMCReader():
39     AliJetESDReader(),
40     fChainMC(0x0)
41 {
42   // Constructor
43 }
44
45 //____________________________________________________________________________
46
47 AliJetMCReader::~AliJetMCReader()
48 {
49   // Destructor
50     delete fChainMC;
51 }
52
53 //____________________________________________________________________________
54
55
56 Bool_t AliJetMCReader::FillMomentumArray(Int_t event)
57 {
58 // Fill momentum array
59   TClonesArray &arrayMC = *fArrayMC;
60   Int_t goodTrack = 0;
61   Int_t nt = 0;
62   Float_t pt, e;
63   TVector3 p;
64
65   // clear array
66   ClearArray();
67   // get event from chains
68   fChain->GetEntry(event);
69   fChainMC->GetEntry(event);
70   // get number of tracks in event (for the loop)
71   nt = fESD->GetNumberOfTracks();
72
73   // get cuts set by user
74   Double_t ptMin = ((AliJetMCReaderHeader*) fReaderHeader)->GetPtCut();
75
76   //loop over particles
77   for (Int_t it = 0; it < nt; it++) {
78     AliESDtrack *track = fESD->GetTrack(it); //track
79     UInt_t status = track->GetStatus();
80     if ((status & AliESDtrack::kITSrefit) == 0) continue; // quality check
81     //    track->GetImpactParameters(dca,z);
82     // if (dca > dcaMax) continue; // check track is reasonable 
83     Int_t label = TMath::Abs(track->GetLabel());
84     TParticle *part = (TParticle*)arrayMC[label]; //particle
85     pt = part->Pt(); // pt of the particle
86     if (pt < ptMin) continue; //check  cuts 
87     p = part->P();
88     e = part->Energy();
89    // fill momentum array
90     new ((*fMomentumArray)[goodTrack]) TLorentzVector(p.X(), p.Y(), p.Z(), e);
91     goodTrack++;
92   }
93   printf("\nNumber of good tracks %d \n", goodTrack);
94   return kTRUE;
95 }
96
97