StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
FindVtxSeeds.C
1 // //
3 // FindVtxSeeds.C macro //
4 // Author: G. Van Buren, BNL //
5 // Description: uses StVertexSeedMaker to perform vertex seed-finding //
6 // Usage: Input is either event.root or MuDst.root file, //
7 // Output is root ntuple, and possibly a .C table file //
8 // in StarDb/Calibrations/rhic subdirectoru //
9 // //
11 
12 void load() {
13  gROOT->LoadMacro("$STAR/StRoot/StMuDSTMaker/COMMON/macros/loadSharedLibraries.C");
14  loadSharedLibraries();
15 
16  gSystem->Load("StDbBroker.so");
17  gSystem->Load("St_db_Maker");
18  gSystem->Load("StDetectorDbMaker");
19  gSystem->Load("StTpcDb");
20  gSystem->Load("StDbUtilities");
21  gSystem->Load("StdEdxY2Maker");
22  gSystem->Load("StPicoEvent");
23  gSystem->Load("StPicoDstMaker");
24  gSystem->Load("StPass0CalibMaker");
25 }
26 
27 void FindVtxSeeds(
28  const Int_t nevents=10,
29  const Char_t *path="/star/data13/reco/dev/2001/10/",
30  const Char_t *file="st_physics_2304060_raw_0303.event.root",
31  const Char_t* outDir="./"){
32 
33  load();
34 
35  // Create a chain
36  StChain chain("myChain");
37 
38 
39  // Set up VertexSeedMaker
40  StVertexSeedMaker* vtxSeedMk=0;
41  St_db_Maker* dbMaker=0;
42  TString pstr = path;
43  if (pstr.Length() > 0 && !(pstr.EndsWith("/"))) pstr.Append("/");
44  TString fstr = file;
45  if (fstr.EndsWith("event.root")) {
46  pstr += fstr;
47  StIOMaker* IOMaker = new StIOMaker("IO","r",pstr.Data(),"bfcTree");
48  IOMaker->SetBranch("*",0,"0"); //deactivate all branches
49  IOMaker->SetBranch("runcoBranch",0,"r"); //activate runco Branch
50  IOMaker->SetBranch("eventBranch",0,"r"); //activate Event Branch
51  new St_db_Maker("db","MySQL:StarDb","$STAR/StarDb","StarDb");
52  vtxSeedMk = (StVertexSeedMaker*) (new StEvtVtxSeedMaker());
53  } else if (fstr.EndsWith("MuDst.root")) {
54  dstMaker = new StMuDstMaker(0,0,pstr.Data(),file,"MuDst.root");
55  dstMaker->SetStatus("*",0);
56  dstMaker->SetStatus("MuEvent",1);
57  dstMaker->SetStatus("PrimaryVertices",1);
58  dstMaker->SetStatus("PrimaryTracks",1);
59  dstMaker->SetStatus("GlobalTracks",1);
60  dstMaker->SetStatus("BTofHeader",1);
61  new St_db_Maker("db","MySQL:StarDb","$STAR/StarDb","StarDb");
62  vtxSeedMk = (StVertexSeedMaker*) (new StMuDstVtxSeedMaker());
63  } else if (fstr.EndsWith("picoDst.root")) {
64  pstr += fstr;
65  dstMaker = new StPicoDstMaker(2,pstr.Data());
66  dstMaker->SetStatus("Event",1);
67  dstMaker->SetStatus("Track",1);
68  dbMaker = new St_db_Maker("db","MySQL:StarDb","$STAR/StarDb","StarDb");
69  vtxSeedMk = (StVertexSeedMaker*) (new StPicoDstVtxSeedMaker());
70  } else if (fstr.EndsWith("daq")) {
71  cout << "Please process with a BFC chain. Stopping." << endl;
72  return;
73  } else {
74  cout << "Unknown file type. Stopping." << endl;
75  return;
76  }
77  vtxSeedMk->SetDefDir(outDir);
78 
79  // Do init
80  int status = chain.Init();
81  if (status) { chain.Fatal(status,"on init"); return; }
82 
83  // Attempt to determine the run number, and if necessary,
84  // set the date/time
85  if (fstr.BeginsWith("st_")) {
86  fstr.ReplaceAll("adc_","");
87  fstr.Remove(0,fstr.Index('_',fstr.First('_')+1)+1);
88  int run = fstr.Atoi();
89  if (run > 0) {
90  cout << "Guessing run number from filename to be: " << run << endl;
91  chain.InitRun(run);
92  if (dbMaker) {
93  int port = (((run/1000) - 1273)/1000) + 3400;
94  TMySQLServer serv(Form("mysql://dbbak.starp.bnl.gov:%d/RunLog",port),"","");
95  TSQLResult* result = serv.Query(Form("SELECT FLOOR(1e-6*(FROM_UNIXTIME(firstEventTime)+0)),FLOOR(FROM_UNIXTIME(firstEventTime)+0)%1000000 FROM daqSummary WHERE runNumber=%d",run));
96  if (result) {
97  TSQLRow* row = result->Next();
98  if (row) {
99  int date = atoi(row->GetField(0));
100  int time = atoi(row->GetField(1));
101  dbMaker->SetDateTime(date,time);
102  }
103  }
104  }
105  } else {
106  cout << "Unable to guess run number...skipping InitRun()" << endl;
107  }
108  }
109 
110 
111  // Loop over events
112  for( Int_t i=0; i<nevents; i++ ) {
113  chain.Clear();
114  status = chain.Make();
115  if (status) break;
116  }
117 
118  // Finish
119  chain.Finish();
120 
121 }
122 
123 // $Id: FindVtxSeeds.C,v 1.4 2017/09/15 14:49:38 genevb Exp $
124 // $Log: FindVtxSeeds.C,v $
125 // Revision 1.4 2017/09/15 14:49:38 genevb
126 // Allow use of PicoDsts
127 //
128 // Revision 1.3 2015/05/23 02:39:21 genevb
129 // Reduce number of MuDst branches to read
130 //
131 // Revision 1.2 2015/05/11 21:51:41 genevb
132 // Removed some bugs, added dEdx maker dependence
133 //
134 // Revision 1.1 2005/07/01 23:57:40 genevb
135 // Allow use of StEvent/MuDst in finding vertex seed
136 //
137 //
Class that converts MuDst into PicoDst.
virtual void Remove(TDataSet *set)
Remiove the &quot;set&quot; from this TDataSet.
Definition: TDataSet.cxx:641
virtual void Clear(Option_t *option="")
User defined functions.
Definition: StChain.cxx:77
void SetStatus(char const *branchNameRegex, int enable)
Enables or disables branches matching a simple regex pattern in reading mode.
virtual Int_t Finish()
Definition: StChain.cxx:85
virtual Int_t Make()
Definition: StChain.cxx:110
void SetStatus(const char *arrType, int status)
BeamLine Constraint calibration base class.