StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
RedoSpaceCharge.C
1 //
2 // RedoSpaceCharge.C - macro to create new MuDst.root file from
3 // event.root file, with the ability to fix
4 // space charge distortion corrections
5 //
6 // Author: G. Van Buren, BNL
7 // June 11, 2003
8 //
9 // Usage:
10 // RedoSpaceCharge.C(firstEvt,NEvts,redo,"some_directory/some_file.event.root")
11 // RedoSpaceCharge.C(NEvts,redo,"some_directory/some_file.event.root")
12 // where redo=kTRUE to redo using new SpaceCharge,
13 // redo=kFALSE to use the current tracks as they are.
14 // RedoSpaceCharge.C(NEvts,"some_directory/some_file.event.root")
15 // where the new SpaceCharge is automatically done.
16 //
17 // Output:
18 // "./some_file.MuDst.root"
19 //
20 
21 //----------------------------------------------------------
22 
23 // Interface:
24 void RedoSpaceCharge(const int firstEvt,
25  const int NEvts,
26  const Bool_t redo,
27  const char* inputFiles);
28 void RedoSpaceCharge(const int NEvts,
29  const Bool_t redo,
30  const char* inputFiles);
31 void RedoSpaceCharge(const int NEvts=10000000,
32  const char* inputFiles=0);
33 void help();
34 void load();
35 void run(const int firstEvt,
36  const int NEvts,
37  const Bool_t redo,
38  const char* inputFiles,
39  const char* outDir=0);
40 
41 // Default files:
42 //const Char_t *defaultFiles = "/scr21/genevb/ev0/lam_100evt.event.root";
43 const Char_t *defaultFiles = "@o1.lis";
44 const Char_t *defaultOutDir = "./";
45 
46 //----------------------------------------------------------
47 
49 void help() {
50  cout << "Usage:\n" <<
51  " RedoSpaceCharge.C" <<
52  "(firstEvt,NEvts,redo,\"some_directory/some_file.event.root\")\n" <<
53  " RedoSpaceCharge.C" <<
54  "(NEvts,redo,\"some_directory/some_file.event.root\")\n" <<
55  " RedoSpaceCharge.C" <<
56  "(NEvts,\"some_directory/some_file.event.root\")\n" <<
57  endl;
58  cout << "where redo=kTRUE to redo using new SpaceCharge,\n" <<
59  " redo=kFALSE to use the current tracks as they are,\n" <<
60  " and the new SpaceCharge is used if redo is omitted." << endl;
61 }
62 
63 
64 void load() {
65  gSystem->Load("libTable");
66  gSystem->Load("libPhysics");
67  gSystem->Load("St_base");
68  gSystem->Load("StUtilities");
69  gSystem->Load("StChain");
70  gSystem->Load("StTreeMaker");
71  gSystem->Load("St_Tables");
72  gSystem->Load("StIOMaker");
73  gSystem->Load("StarClassLibrary");
74  gSystem->Load("StTriggerDataMaker");
75  gSystem->Load("StBichsel");
76  gSystem->Load("StEvent");
77  gSystem->Load("StSecondaryVertexMaker");
78  gSystem->Load("StarMagField");
79  gSystem->Load("StMagF");
80  gSystem->Load("StDbLib.so");
81  gSystem->Load("StDbBroker.so");
82  gSystem->Load("libglobal_Tables.so");
83  gSystem->Load("St_db_Maker.so");
84  gSystem->Load("StDetectorDbMaker");
85  gSystem->Load("StTpcDb");
86  gSystem->Load("StDbUtilities");
87  gSystem->Load("StEventUtilities");
88  gSystem->Load("StStrangeMuDstMaker");
89  gSystem->Load("StEmcUtil");
90  gSystem->Load("StMuDSTMaker");
91 }
92 
93 void run(const int firstEvt,
94  const int NEvts,
95  const Bool_t redo,
96  const char* inputFiles,
97  const char* outDir) {
98 
99  // Set I/O files/directories
100  const Char_t *file = ( (inputFiles) ? inputFiles : defaultFiles );
101  const Char_t *dir = ( (outDir) ? outDir : defaultOutDir );
102  StFile *files = new StFile();
103  files->AddFile(file);
104 
105  // Create a chain
106  StChain chain("myChain");
107 
108  // Create Makers
109  StIOMaker IOMaker("IOMaker","r",files,"bfcTree");
110  St_db_Maker dbMaker("db","MySQL:StarDb","$STAR/StarDb","StarDb");
111  StMagFMaker magfMk; // now required for StTpcDbMaker
112  StTpcDbMaker tpcDbMk("tpcDb");
113  StDetectorDbMaker detDbMk;
114  StRedoTracks redoMk;
115  StV0FinderMaker secondaryFinder;
116  StStrangeMuDstMaker strangeDst("strangeMuDst");
117  StMuDstMaker commonDst(1,1,dir);
118 
119  // Indicate input branches
120  IOMaker.SetBranch("*",0,"0"); //deactivate all branches
121  IOMaker.SetBranch("eventBranch",0,"r"); //activate Event Branch
122  IOMaker.SetBranch("runcoBranch",0,"r"); //activate runco Branch
123  IOMaker.SetBranch("emcBranch",0,"r"); //activate EMC Branch
124 
125  // Indicate strangeness DST settings
126  strangeDst.DoV0(); // Selects V0 vertices for micro-DST
127  strangeDst.DoXi(); // Selects Xi vertices for micro-DST
128  strangeDst.DoKink(); // Selects Kink vertices for micro-DST
129  strangeDst.SetNoKeep();// Sets "no keep" mode
130 
131  // Indicate common DST settings
132  commonDst.setProbabilityPidFile();
133  StMuL3Filter* l3Filter = new StMuL3Filter();
134  commonDst.setL3TrackFilter(l3Filter);
135  StMuFilter* filter = new StMuFilter();
136  commonDst.setTrackFilter(filter);
137 
138  // Indicate StRedoTracks maker settings
139  if (!redo) redoMk.DontDo();
140 
141  // Do init
142  Int_t istatus = chain.Init();
143  if( istatus ) { chain.Fatal(istatus,"on init"); return; }
144 
145  IOMaker.Skip(firstEvt);
146 
147  // Loop over events
148  for( Int_t i=0; (i<NEvts) && (istatus!=2); i++ ) {
149  chain.Clear();
150  switch (istatus = chain.Make()) {
151  case 0: break;
152  case 2: { gMessMgr->Info("Last event from input."); break; }
153  case 3: { gMessMgr->Error() << "Event " << i << " had error " <<
154  istatus << ". Now skipping event."; gMessMgr->Print(); break; }
155  default: { gMessMgr->Warning() << "Event " << i << " returned status " <<
156  istatus << ". Continuing."; gMessMgr->Print(); }
157  }
158  gMessMgr->Info() << "*** Finished processing event " << i;
159  gMessMgr->Print();
160  }
161 
162  // Finish
163  if( NEvts >= 1 ) chain.Finish();
164 }
165 
166 void RedoSpaceCharge(const int firstEvt,
167  const int NEvts,
168  const Bool_t redo,
169  const char* inputFiles) {
170  load();
171  run(firstEvt,NEvts,redo,inputFiles,defaultOutDir);
172 }
173 
174 void RedoSpaceCharge(const int NEvts,
175  const Bool_t redo,
176  const char* inputFiles) {
177  RedoSpaceCharge(0,NEvts,redo,inputFiles);
178 }
179 
180 void RedoSpaceCharge(const int NEvts,
181  const char* inputFiles) {
182  RedoSpaceCharge(0,NEvts,kTRUE,inputFiles);
183 }
184 
185 //----------------------------------------------------------
186 // $Id: RedoSpaceCharge.C,v 1.5 2015/07/27 15:29:56 jeromel Exp $
187 // $Log: RedoSpaceCharge.C,v $
188 // Revision 1.5 2015/07/27 15:29:56 jeromel
189 // LOad StrangeMuDstMkaer again (restored)
190 //
191 // Revision 1.4 2015/07/22 17:39:47 jeromel
192 // Comment out loading StStrangeMuDstMaker as disabled
193 //
194 // Revision 1.3 2010/02/22 20:05:16 genevb
195 // Using StTpcDbMaker now requires StMagFMaker
196 //
197 // Revision 1.2 2005/08/31 15:02:43 fisyak
198 // Add dependence StMagF vs StarMagField
199 //
200 // Revision 1.1 2003/07/11 20:26:54 genevb
201 // Introduction of RedoSpaceCharge.C macro
202 //
203 //
204 
Definition: StTree.h:125
virtual void Clear(Option_t *option="")
User defined functions.
Definition: StChain.cxx:77
virtual Int_t Finish()
Definition: StChain.cxx:85
virtual Int_t Make()
Definition: StChain.cxx:110