99 #if !defined(__CINT__) || defined(__MAKECINT__)
100 #include "iostream.h"
107 #include "TBenchmark.h"
108 #include "TStopwatch.h"
109 #include "TParticle.h"
111 #include "AliStack.h"
112 #include "AliTPCtrack.h"
115 #include "TParticle.h"
117 #include "AliDetector.h"
118 #include "AliTrackReference.h"
124 #include "AliTPCTracking.C"
142 #if !defined(__CINT__) || defined(__MAKECINT__)
143 #include "iostream.h"
155 TFile*
OpenAliceFile(
char *fn, Bool_t importgAlice = kFALSE,
char *mode =
"read");
166 Bool_t done = kFALSE;
167 TTimer *timer =
new TTimer(
"gSystem->ProcessEvents();", 50, kFALSE);
174 input = Getline(
"Type <return> to continue: ");
176 if (input) done = kTRUE;
188 void *dirp = gSystem->OpenDirectory(baseDir);
190 cerr<<
"Could not open base directory "<<baseDir.Data()<<endl;
194 Long_t id, size, flag, modTime;
197 while((afile = gSystem->GetDirEntry(dirp))) {
199 if (strstr(afile,subDirNameMask.Data())) {
200 sprintf(relName,
"%s/%s/%s",baseDir.Data(),afile,fn.Data());
202 if(!gSystem->GetPathInfo(relName, &
id, &size, &flag, &modTime)) {
203 rc += chain.Add(relName);
207 gSystem->FreeDirectory(dirp);
215 gAlice = (AliRun*)file->Get(
"gAlice");
216 if (!
gAlice)
return kFALSE;
222 if (!file->IsOpen()) {
223 cerr<<
"OpenAliceFile: cannot open file "<<fn<<
" in mode "
227 if (!importgAlice)
return file;
313 cerr<<
"digitRow::SetRow: index "<<row<<
" out of bounds."<<endl;
328 return TESTBIT(
fDig[iC],iB);
338 for (Int_t j = 0; j < 8; j++) {
339 if (i*8+j > upto)
return total;
340 if (TESTBIT(
fDig[i],j)) total++;
361 for (Int_t j = 7; j >= 0; j--) {
362 if TESTBIT(
fDig[i],j)
return i*8+j;
374 for (Int_t j = 0; j < 8; j++) {
375 if (TESTBIT(
fDig[i],j))
return i*8+j;
397 char* fnDigits =
"tpc.digits.root",
398 char* fnRes =
"genTracks.root",
399 Int_t nEvents=1, Int_t firstEvent=0);
403 Int_t
Exec(Int_t nEvents, Int_t firstEventNr);
413 Float_t
TR2LocalX(AliTrackReference *trackRef,
456 static const Double_t
kRaddeg = 180./TMath::Pi();
477 Int_t nEvents, Int_t firstEvent)
494 fFnRes =
"genTracks.root";
496 fFnDigits =
"rfio:its.tpc.trd.digits.root";
542 cerr<<
"Cannot open file "<<
fFnDigits<<endl;
548 cerr<<
"TPC parameters not found and could not be created"<<endl;
562 cout<<
"Start to process event "<<
fEventNr<<endl;
563 cout<<
"\tfNParticles = "<<fNParticles<<endl;
564 if (
fDebug>2) cout<<
"\tStart loop over TreeD"<<endl;
566 if (
fDebug>2) cout<<
"\tStart loop over TreeTR"<<endl;
568 if (
fDebug>2) cout<<
"\tStart loop over TreeK"<<endl;
570 if (
fDebug>2) cout<<
"\tEnd loop over TreeK"<<endl;
579 cerr<<
"Exec finished"<<endl;
594 cerr<<
"Error in CreateTreeGenTracks: cannot open file "<<
fFnRes<<endl;
600 cerr<<
"Error in CreateTreeGenTracks: cannot create branch."<<endl;
620 cerr<<
"File "<<
fFnRes<<
" not found as an open file."<<endl;
639 cout<<
"There are "<<
fNParticles<<
" primary and secondary particles in event "
642 AliStack * stack =
gAlice->Stack();
643 if (!stack) {cerr<<
"Stack was not found!\n";
return 1;}
652 for (Int_t iParticle = 0; iParticle <
fNParticles; iParticle++) {
656 if (
fIndexTR[iParticle] < 0)
continue;
657 fParticle = stack->ParticleFromTreeK(iParticle);
658 if (
fDebug > 3 && iParticle < 10) {
659 cout<<
"processing particle "<<iParticle<<
" ";
674 if (
fDebug > 2 && iParticle < 10) {
675 cerr<<
"Fill track with a label "<<iParticle<<endl;
697 if (
fDebug > 2) cerr<<
"end of TreeKLoop"<<endl;
716 sprintf(treeDName,
"TreeD_75x40_100x60_150x60_%d",
fEventNr);
717 TTree *treeD=(TTree*)
fFileTreeD->Get(treeDName);
719 treeD->GetBranch(
"Segment")->SetAddress(&digits);
721 Int_t sectorsByRows=(Int_t)treeD->GetEntries();
722 if (
fDebug > 1) cout<<
"\tsectorsByRows = "<<sectorsByRows<<endl;
723 for (Int_t i=0; i<sectorsByRows; i++) {
725 if (!treeD->GetEvent(i))
continue;
728 if (
fDebug > 1) cout<<sec<<
' '<<row<<
" \r";
740 if (digitValue >= zero) {
742 for (Int_t j = 0; j<3; j++) {
745 cerr<<
"particle label too big: fNParticles, label "
751 cout<<
"Inner loop: sector, iRow, iColumn, label, value, row "
753 <<iRow<<
" "<<iColumn<<
" "<<label<<
" "<<digitValue
760 }
while (digits->
Next());
763 if (
fDebug > 2) cerr<<
"end of TreeDLoop"<<endl;
773 TTree *treeTR=
gAlice->TreeTR();
775 cerr<<
"TreeTR not found"<<endl;
778 Int_t nPrimaries = (Int_t) treeTR->GetEntries();
779 if (
fDebug > 1) cout<<
"There are "<<nPrimaries<<
" entries in TreeTR"<<endl;
780 TBranch *TPCBranchTR = treeTR->GetBranch(
"TPC");
782 cerr<<
"TPC branch in TR not found"<<endl;
785 TClonesArray* TPCArrayTR =
new TClonesArray(
"AliTrackReference");
786 TPCBranchTR->SetAddress(&TPCArrayTR);
787 for (Int_t iPrimPart = 0; iPrimPart<nPrimaries; iPrimPart++) {
788 TPCBranchTR->GetEntry(iPrimPart);
789 for (Int_t iTrackRef = 0; iTrackRef < TPCArrayTR->GetEntriesFast(); iTrackRef++) {
790 AliTrackReference *trackRef = (AliTrackReference*)TPCArrayTR->At(iTrackRef);
791 Int_t label = trackRef->GetTrack();
795 cerr<<
"Wrong label: "<<label<<endl;
807 if (trackRef->Pt() <
fgPtCut)
continue;
812 cerr<<
"Too many tracks with track reference. Increase the constant"
813 <<
" fgMaxIndexTR"<<endl;
836 Float_t x[3] = { trackRef->X(),trackRef->Y(),trackRef->Z()};
857 char* fnGenTracks =
"genTracks.root",
858 char* fnCmpRes =
"cmpTracks.root",
859 char* fnGalice =
"galice.root",
860 Int_t nEvents=1, Int_t firstEvent=0);
864 Int_t
Exec(Int_t nEvents, Int_t firstEventNr);
875 Float_t
TR2LocalX(AliTrackReference *trackRef,
943 Int_t nEvents, Int_t firstEvent)
961 fFnCmp =
"cmpTracks.root";
1004 cerr<<
"output tree not created"<<endl;
1009 cerr<<
"Cannot open file with gAlice object "<<
fFnHits<<endl;
1017 cerr<<
"TPC parameters not found and could not be created"<<endl;
1022 cerr<<
"Cannot connect tree with generated tracks"<<endl;
1036 cout<<
"Start to process event "<<
fEventNr<<endl;
1037 cout<<
"\tfNParticles = "<<fNParticles<<endl;
1038 if (
fDebug>2) cout<<
"\tStart loop over TreeT"<<endl;
1041 if (
fDebug>2) cout<<
"\tStart loop over tree genTracks"<<endl;
1043 if (
fDebug>2) cout<<
"\tEnd loop over tree genTracks"<<endl;
1052 cerr<<
"Exec finished"<<endl;
1070 cerr<<
"Error in ConnectGenTree: cannot open file "<<
fFnGenTracks<<endl;
1075 cerr<<
"Error in ConnectGenTree: cannot find genTracksTree in the file "
1090 cout<<
"Number of gen. tracks with TR: "<<
fTreeGenTracks->GetEntries()<<endl;
1101 cerr<<
"Error in CreateTreeCmp: cannot open file "<<
fFnCmp<<endl;
1104 fTreeCmp =
new TTree(
"TPCcmpTracks",
"TPCcmpTracks");
1105 TBranch *branchBits =
fTreeCmp->Branch(
"bitsBranch",
"digitRow", &
fDigitRow, 4000, 0);
1107 cerr<<
"Error in CreateTreeCmp: cannot create branch."<<endl;
1130 cerr<<
"File "<<
fFnCmp<<
" not found as an open file."<<endl;
1145 Float_t x[3] = { trackRef->X(),trackRef->Y(),trackRef->Z()};
1164 char treeNameBase[11] =
"TreeT_TPC_";
1166 sprintf(treeName,
"%s%d",treeNameBase,eventNr);
1170 cerr<<
"Can't get a tree with TPC rec. tracks named "<<treeName<<endl;
1175 if (
fDebug > 2) cout<<
"Event, rec. tracks: "<<eventNr<<
" "
1180 for (Int_t iEntry=0; iEntry<nEntries;iEntry++){
1181 br->GetEntry(iEntry);
1186 if (
fDebug > 2) cerr<<
"end of TreeTLoop"<<endl;
1199 cerr<<
"fNParticles, nParticlesTR, fNextTreeGenEntryToRead: "<<
fNParticles<<
" "
1201 while (entry < nParticlesTR) {
1208 cerr<<
"Fill track with a label "<<
fLabel<<endl;
1225 cerr<<
"Track local X before prolongation: "<<
fTPCTrack->GetX()<<endl;
1230 cerr<<
"Track local X after prolongation: "<<
fTPCTrack->GetX()<<endl;
1232 fTPCTrack->GetExternalParameters(Localx,par);
1237 fLambda = TMath::ATan(par[3]);
1250 if (
fDebug > 2) cerr<<
"end of TreeKLoop"<<endl;
Double_t fRecPhi
reconstructed phi angle (0;2*kPI)
Int_t fEventNr
current event number
Int_t fRowsWithDigitsInn
number of rows with digits in the inner sectors
Int_t fRowsWithDigits
number of rows with digits in the outer sectors
void CreateTreeGenTracks()
Int_t fEventNr
current event number
Int_t Transform0to1(Float_t *xyz, Int_t *index) const
TFile * Open(const char *filename, Long64_t &nevents)
TFile * fFileHits
input file with hits
AliTrackReference * fTrackRef
track reference saved in the output tree
char * fFnGenTracks
input file name with gen tracks
AliTrackReference * fTrackRef
track reference saved in the output tree
TFile * fFileRecTracks
input file with reconstructed tracks
TTree * fTreeCmp
output tree with cmp tracks
AliTrackReference * fTrackRef
track reference saved in the output tree
static const Int_t fgMaxParticles
maximum number of generated particles
digitRow * fDigitRow
pointer to the object saved in Branch
TFile * OpenAliceFile(char *fn, Bool_t importgAlice=kFALSE, char *mode="read")
Manager and of geomety classes for set: TPC.
Int_t fLastIndexTR
last used index in fIndexTR
Int_t fRowsTrackLength
last - first row with digit
char * fFnDigits
input file name with digits
AliTPCtrack * fTPCTrack
pointer to TPC track to connect branch
Double_t fVDist[4]
distance of the particle vertex from primary vertex
Int_t Chain(TString baseDir, TString subDirNameMask, TString fn, TChain &chain)
static const Double_t fgPtCut
do not store particles with generated pT less than this
static const Double_t kRaddeg
virtual ~TPCFindGenTracks()
virtual Int_t GetTrackID(Int_t row, Int_t column, Int_t level)
TFile * fFileGenTracks
output file with stored fTreeGenTracks
digitRow & operator=(const digitRow &digOld)
AliTPCParam * fParamTPC
AliTPCParam.
Bool_t ImportgAlice(TFile *file)
void SetFirstEventNr(Int_t i)
TFile * fFileCmp
output file with cmp tracks
Int_t fFirstEventNr
first event to process
static const Int_t seedRow12
nRowUp - 1 - (Int_t) 0.125*nRowUp
TFile * fFileHits
input file with gAlice
static const Float_t fgTrackRefLocalXMaxDelta
char * fFnCmp
output file name with cmp tracks
char * fFnRes
output file name with stored tracks
TTree * fTreeGenTracks
output tree with generated tracks
Double_t fLambda
reconstructed
TTree * fTreeRecTracks
tree with reconstructed tracks
AliTrackReference * fContainerTR
big container for partial information
AliTPCParam * fParamTPC
AliTPCParam.
Int_t fRowsWithDigitsInn
number of rows with digits in the inner sectors
TParticle * fParticle
generated particle
Float_t fdEdx
reconstructed dEdx
Int_t fRowsTrackLength
last - first row with digit
static const Int_t seedRow11
nRowUp - 1
Int_t TreeTLoop(Int_t eventNr)
Int_t fNEvents
number of events to process
Bool_t TestRow(Int_t row)
char * fFnHits
input file name with hits
static const Int_t fgMaxIndexTR
maximum number of tracks with a track ref
TFile * fFileTreeD
input file with digits
char * fFnHits
input file name with gAlice object (needed for B)
Double_t fVPrim[3]
primary vertex position
void SetDebug(Int_t level)
Bool_t AdjustSectorRow(Int_t index, Int_t §or, Int_t &row) const
digitRow * fContainerDigitRow
big container for partial information
static const Int_t seedRow21
seedRow11 - shift
Double_t fVDist[4]
distance of the particle vertex from primary vertex
Double_t fRecPt_1
reconstructed
Int_t fDigitsInSeed
digits in the default seed rows
Int_t fNParticles
number of particles in the input tree genTracks
TParticle * fParticle
generated particle
Int_t * fIndexRecTracks
index of particle label in the TreeT_TPC
Int_t RowsOn(Int_t upto=8 *kgRowBytes)
char * fFnRecTracks
input file name with tpc rec. tracks
Int_t fReconstructed
flag if track was reconstructed
void SetFirstEventNr(Int_t i)
Int_t TreeGenLoop(Int_t eventNr)
Int_t fNextTreeGenEntryToRead
last entry already read from genTracks tree
TPCGenInfo * fGenInfo
container for all the details
Int_t fRowsTrackLength
last - first row with digit
Int_t fRowsWithDigits
number of rows with digits in the outer sectors
static const Float_t fgTrackRefLocalXMax
void SetDebug(Int_t level)
Int_t fRowsWithDigits
number of rows with digits in the outer sectors
Int_t fFirstEventNr
first event to process
Int_t fRowsWithDigitsInn
number of rows with digits in the inner sectors
digitRow * fDigitRow
pointer to the object saved in Branch
Int_t * fIndexTR
index of particle label in the fContainerTR
Int_t fNEvents
number of events to process
Float_t TR2LocalX(AliTrackReference *trackRef, AliTPCParam *paramTPC)
void Transform1to2(Float_t *xyz, Int_t *index) const
Float_t TR2LocalX(AliTrackReference *trackRef, AliTPCParam *paramTPC)
Int_t fDigitsInSeed
digits in the default seed rows
Int_t fDigitsInSeed
digits in the default seed rows
Int_t GetNInnerSector() const
TParticle * fParticle
generated particle
static const Int_t seedRow22
seedRow12 - shift
Int_t fNParticles
number of particles in TreeK