StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
fwd_tracking.C
1 //usr/bin/env root4star -l -b -q $0; exit $?
2 // that is a valid shebang to run script as executable, but with only one arg
3 
4 
5 // Run very fast fwd tracking
6 // generate some input data using genfzd
7 
8 TFile *output = 0;
9 
10 void fwd_tracking( int n = 500,
11  const char *inFile = "simu/seed.fzd",
12  std::string configFile = "simu/seed.xml",
13  const char *geom = "y2023") {
14  TString _geom = geom;
15  bool SiIneff = false;
16  bool useConstBz = false;
17  bool useFCS = true;
18 
19  // Setup the chain for reading an FZD
20  TString _chain;
21  if ( useFCS )
22  _chain = Form("fzin %s sdt20211016 fstFastSim fcsSim fcsWFF fcsCluster fwdTrack MakeEvent StEvent ReverseField agml usexgeom bigbig evout cmudst tree", _geom.Data());
23  else
24  _chain = Form("fzin %s sdt20211016 MakeEvent StEvent ReverseField agml usexgeom bigbig fstFastSim fcsSim fwdTrack evout cmudst tree", _geom.Data());
25 
26  //_chain = Form("fzin %s sdt20230202 MakeEvent StEvent ReverseField agml usexgeom bigbig evout cmudst tree", _geom.Data());
27 
28  gSystem->Load( "libStarRoot.so" );
29  gROOT->SetMacroPath(".:/star-sw/StRoot/macros/:./StRoot/macros:./StRoot/macros/graphics:./StRoot/macros/analysis:./StRoot/macros/test:./StRoot/macros/examples:./StRoot/macros/html:./StRoot/macros/qa:./StRoot/macros/calib:./StRoot/macros/mudst:/afs/rhic.bnl.gov/star/packages/DEV/StRoot/macros:/afs/rhic.bnl.gov/star/packages/DEV/StRoot/macros/graphics:/afs/rhic.bnl.gov/star/packages/DEV/StRoot/macros/analysis:/afs/rhic.bnl.gov/star/packages/DEV/StRoot/macros/test:/afs/rhic.bnl.gov/star/packages/DEV/StRoot/macros/examples:/afs/rhic.bnl.gov/star/packages/DEV/StRoot/macros/html:/afs/rhic.bnl.gov/star/packages/DEV/StRoot/macros/qa:/afs/rhic.bnl.gov/star/packages/DEV/StRoot/macros/calib:/afs/rhic.bnl.gov/star/packages/DEV/StRoot/macros/mudst:/afs/rhic.bnl.gov/star/ROOT/36/5.34.38/.sl73_x8664_gcc485/rootdeb/macros:/afs/rhic.bnl.gov/star/ROOT/36/5.34.38/.sl73_x8664_gcc485/rootdeb/tutorials");
30  gROOT->LoadMacro("bfc.C");
31  bfc(-1, _chain, inFile);
32 
33  if ( useConstBz )
34  StarMagField::setConstBz(true);
35 
36 
37  gSystem->Load( "libStFttSimMaker" );
38 
39  gSystem->Load( "libStFcsTrackMatchMaker" );
40 // StFttSlowSimMaker *fttSlowSim = new StFttSlowSimMaker();
41 // cout << "Adding StFttSlowSimMaker to chain" << endl;
42 // chain->AddMaker(fttSlowSim);
43 //goto chain_loop;
44 
45  if (useFCS) {
46 
47  StFcsDbMaker* fcsdbmkr = (StFcsDbMaker*) chain->GetMaker("fcsDbMkr");
48  cout << "fcsdbmkr="<<fcsdbmkr<<endl;
49  StFcsDb* fcsdb = (StFcsDb*) chain->GetDataSet("fcsDb");
50  cout << "fcsdb="<<fcsdb<<endl;
51  //fcsdbmkr->setDbAccess(1);
52 
53  // Configure FCS simulator
54  StFcsFastSimulatorMaker *fcssim = (StFcsFastSimulatorMaker*) chain->GetMaker("fcsSim");
55  fcssim->setDebug(1);
56  //fcssim->setLeakyHcal(0);
57 
58  StFcsWaveformFitMaker *fcsWFF= (StFcsWaveformFitMaker*) chain->GetMaker("StFcsWaveformFitMaker");
59  fcsWFF->setEnergySelect(0);
60 
61  StFcsClusterMaker *fcsclu = (StFcsClusterMaker*) chain->GetMaker("StFcsClusterMaker");
62  fcsclu->setDebug(1);
63  }
64 
65  // Configure FTT FastSim
66  // StFttFastSimMaker *fttFastSim = (StFttFastSimMaker*) chain->GetMaker( "fttSim" );
67  // cout << "Adding StFttFastSimMaker to chain" << endl;
68  // chain->AddMaker(fttFastSim);
69 
70  // Configure FST FastSim
71  TString qaoutname(gSystem->BaseName(inFile));
72  qaoutname.ReplaceAll(".fzd", ".FastSimu.QA.root");
73  StFstFastSimMaker *fstFastSim = (StFstFastSimMaker*) chain->GetMaker( "fstFastSim" );;
74 
75  if (SiIneff)
76  fstFastSim->SetInEfficiency(0.1); // inefficiency of Si
77 
78  fstFastSim->SetQAFileName(qaoutname);
79 
80  cout << "Adding StFstFastSimMaker to chain" << endl;
81  chain->AddMaker(fstFastSim);
82 
83 
84  // Configure the Forward Tracker
85  StFwdTrackMaker * fwdTrack = (StFwdTrackMaker*) chain->GetMaker( "fwdTrack" );
86 
87  // config file set here overides chain opt
88  cout << "Running FwdTracking with config: " << configFile << endl;
89  fwdTrack->SetConfigFile( configFile );
90  fwdTrack->SetGenerateTree( true );
91  fwdTrack->SetGenerateHistograms( true );
92  fwdTrack->SetDebug();
93 
94  gSystem->Load("StFwdUtils.so");
95  if (!useFCS){
96  StFwdAnalysisMaker *fwdAna = new StFwdAnalysisMaker();
97  fwdAna->SetDebug();
98  chain->AddAfter("fwdTrack", fwdAna);
99  }
100 
101  if (useFCS) {
102  // FwdTrack and FcsCluster assciation
103  gSystem->Load("StFcsTrackMatchMaker");
105  match->setMaxDistance(6,10);
106  match->setFileName("fcstrk.root");
107  match->SetDebug();
108  chain->AddMaker(match);
109 
110  StFwdAnalysisMaker *fwdAna = new StFwdAnalysisMaker();
111  fwdAna->SetDebug();
112  chain->AddAfter("FcsTrkMatch", fwdAna);
113  }
114 
115  StMuDstMaker * muDstMaker = (StMuDstMaker*)chain->GetMaker( "MuDst" );
116  chain->AddAfter( "FcsTrkMatch", muDstMaker );
117 
118 chain_loop:
119  chain->Init();
120 
121  //_____________________________________________________________________________
122  //
123  // MAIN EVENT LOOP
124  //_____________________________________________________________________________
125  for (int i = 0; i < n; i++) {
126 
127  cout << "--------->START EVENT: " << i << endl;
128 
129  chain->Clear();
130  if (kStOK != chain->Make())
131  break;
132 
133 
134  // StMuDst * mds = muDstMaker->muDst();
135  // StMuFwdTrackCollection * ftc = mds->muFwdTrackCollection();
136  // cout << "Number of StMuFwdTracks: " << ftc->numberOfFwdTracks() << endl;
137  // for ( size_t iTrack = 0; iTrack < ftc->numberOfFwdTracks(); iTrack++ ){
138  // StMuFwdTrack * muFwdTrack = ftc->getFwdTrack( iTrack );
139  // cout << "muFwdTrack->mPt = " << muFwdTrack->momentum().Pt() << endl;
140 
141  // }
142 
143  cout << "<---------- END EVENT" << endl;
144  }
145 
146 }
virtual void Clear(Option_t *option="")
User defined functions.
Definition: StChain.cxx:77
virtual Int_t Make()
Definition: StChain.cxx:110
Definition: Stypes.h:40