]>
Commit | Line | Data |
---|---|---|
99e5fe42 | 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 | ||
99e5fe42 | 16 | // Jet ESD Reader |
17 | // ESD reader for jet analysis | |
83a444b1 | 18 | // Author: Mercedes Lopez Noriega (mercedes.lopez.noriega@cern.ch) |
99e5fe42 | 19 | |
20 | #include <Riostream.h> | |
21 | #include <TSystem.h> | |
22 | #include <TLorentzVector.h> | |
83a444b1 | 23 | #include <TVector3.h> |
99e5fe42 | 24 | #include "AliJetESDReader.h" |
25 | #include "AliJetESDReaderHeader.h" | |
26 | #include "AliESD.h" | |
27 | #include "AliESDtrack.h" | |
28 | ||
29 | ClassImp(AliJetESDReader) | |
30 | ||
31 | AliJetESDReader::AliJetESDReader() | |
32 | { | |
33 | // Constructor | |
83a444b1 | 34 | printf("\nIn reader constructor\n"); |
99e5fe42 | 35 | fReaderHeader = 0x0; |
36 | fMass = 0; | |
37 | fSign = 0; | |
38 | } | |
39 | ||
40 | //____________________________________________________________________________ | |
41 | ||
42 | AliJetESDReader::~AliJetESDReader() | |
43 | { | |
44 | // Destructor | |
99e5fe42 | 45 | } |
46 | ||
47 | //____________________________________________________________________________ | |
48 | ||
49 | void AliJetESDReader::OpenInputFiles() | |
99e5fe42 | 50 | { |
83a444b1 | 51 | // Open input files |
52 | printf("\nOpening files\n"); | |
99e5fe42 | 53 | // chain for the ESDs |
54 | fChain = new TChain("esdTree"); | |
55 | fChainMC = new TChain("mcStackTree"); | |
56 | ||
57 | // get directory and pattern name from the header | |
58 | const char* dirName=fReaderHeader->GetDirectory(); | |
59 | const char* pattern=fReaderHeader->GetPattern(); | |
60 | ||
61 | // Add files matching patters to the chain | |
62 | void *dir = gSystem->OpenDirectory(dirName); | |
63 | const char *name = 0x0; | |
64 | while ((name = gSystem->GetDirEntry(dir))){ | |
65 | if (strstr(name,pattern)){ | |
66 | printf("Adding %s\n",name); | |
67 | char path[256]; | |
68 | sprintf(path,"%s/%s",dirName,name); | |
83a444b1 | 69 | fChain->AddFile(path,-1); |
70 | fChainMC->AddFile(path,-1); | |
99e5fe42 | 71 | } |
72 | } | |
73 | ||
74 | gSystem ->FreeDirectory(dir); | |
75 | fChain ->SetBranchAddress("ESD", &fESD); | |
76 | fChainMC->SetBranchAddress("Header", &fAliHeader); | |
77 | fChainMC->SetBranchAddress("Stack", &fArrayMC); | |
78 | ||
79 | int nMax = fChain->GetEntries(); | |
80 | printf("\nTotal number of events in chain= %d",nMax); | |
81 | ||
82 | // set number of events in header | |
83 | if (fReaderHeader->GetLastEvent() == -1) | |
84 | fReaderHeader->SetLastEvent(nMax); | |
85 | else { | |
86 | Int_t nUsr = fReaderHeader->GetLastEvent(); | |
87 | fReaderHeader->SetLastEvent(TMath::Min(nMax,nUsr)); | |
88 | } | |
89 | } | |
90 | ||
91 | //____________________________________________________________________________ | |
92 | ||
93 | void AliJetESDReader::FillMomentumArray(Int_t event) | |
94 | { | |
83a444b1 | 95 | // Fill the momentum array for each track |
99e5fe42 | 96 | Int_t goodTrack = 0; |
97 | Int_t nt = 0; | |
83a444b1 | 98 | Float_t pt, eta; |
99 | TVector3 p3; | |
99e5fe42 | 100 | |
101 | // clear momentum array | |
102 | ClearArray(); | |
83a444b1 | 103 | |
99e5fe42 | 104 | // get event from chain |
105 | fChain->GetEntry(event); | |
106 | fChainMC->GetEntry(event); | |
83a444b1 | 107 | |
99e5fe42 | 108 | // get number of tracks in event (for the loop) |
109 | nt = fESD->GetNumberOfTracks(); | |
83a444b1 | 110 | |
111 | // temporary storage of signal and pt cut flag | |
112 | Int_t* sflag = new Int_t[nt]; | |
113 | Int_t* cflag = new Int_t[nt]; | |
8011d399 | 114 | |
99e5fe42 | 115 | // get cuts set by user |
83a444b1 | 116 | Float_t ptMin = fReaderHeader->GetPtCut(); |
117 | Float_t etaMin = fReaderHeader->GetFiducialEtaMin(); | |
118 | Float_t etaMax = fReaderHeader->GetFiducialEtaMax(); | |
99e5fe42 | 119 | |
120 | //loop over tracks | |
121 | for (Int_t it = 0; it < nt; it++) { | |
122 | AliESDtrack *track = fESD->GetTrack(it); | |
123 | UInt_t status = track->GetStatus(); | |
83a444b1 | 124 | p3 = track->P3(); |
125 | pt = p3.Pt(); | |
126 | if (((status & AliESDtrack::kITSrefit) == 0) || | |
127 | ((status & AliESDtrack::kTPCrefit) == 0)) continue; // quality check | |
8011d399 | 128 | if (((AliJetESDReaderHeader*) fReaderHeader)->ReadSignalOnly() |
83a444b1 | 129 | && TMath::Abs(track->GetLabel()) > 10000) continue; // quality check |
130 | if (((AliJetESDReaderHeader*) fReaderHeader)->ReadBkgdOnly() | |
131 | && TMath::Abs(track->GetLabel()) < 10000) continue; // quality check | |
132 | eta = p3.Eta(); | |
133 | if ( (eta > etaMax) || (eta < etaMin)) continue; // checking eta cut | |
134 | ||
135 | new ((*fMomentumArray)[goodTrack]) TLorentzVector(p3,p3.Mag()); | |
136 | sflag[goodTrack]=0; | |
137 | if (TMath::Abs(track->GetLabel()) < 10000) sflag[goodTrack]=1; | |
138 | cflag[goodTrack]=0; | |
139 | if (pt > ptMin) cflag[goodTrack]=1; // pt cut | |
99e5fe42 | 140 | goodTrack++; |
141 | } | |
8011d399 | 142 | // set the signal flags |
83a444b1 | 143 | fSignalFlag.Set(goodTrack,sflag); |
144 | fCutFlag.Set(goodTrack,cflag); | |
99e5fe42 | 145 | |
83a444b1 | 146 | //printf("\nIn event %d, number of good tracks %d \n", event, goodTrack); |
99e5fe42 | 147 | } |
148 | ||
149 |