StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
rdMu2binL2eve.C
1 /* This macro is set up to convert muDst to ETOW & BTOW data blocks
2  in the format 'StJanEvent'
3  needed by stand-alne L2-algos, run by multiTest.c
4  This macro runs on real data (flagMC=0) and MC files (flagMC=1)
5 */
6 
7 int total=0;
8 
9 void rdMu2binL2eve( int nevents = 100,
10  int flagMC=0, // 0== data, 1==M-C
11  char *file="R9067013.lis")
12 {
13 
14  if (flagMC) file="mit0029.lis";
15 
16 
17  int nFiles = 100; // make this big if you want to read all events from a run
18 
19  char *eemcSetupPath="/star/institutions/mit/balewski/StarTrigSimuSetup2008/";
20  TString outDir="./out2/";
21  char *dirIn ="./";
22 
23 
24  gROOT->LoadMacro("$STAR/StRoot/StMuDSTMaker/COMMON/macros/loadSharedLibraries.C");
25  loadSharedLibraries();
26  assert( !gSystem->Load("StDetectorDbMaker"));
27  assert( !gSystem->Load("StDbUtilities"));
28  assert( !gSystem->Load("StDbBroker"));
29  assert( !gSystem->Load("St_db_Maker"));
30  assert( !gSystem->Load("StEEmcUtil")); // needed by eemcDb
31  assert( !gSystem->Load("StEEmcDbMaker"));
32  assert( !gSystem->Load("StDaqLib")); // needed by bemcDb
33  assert( !gSystem->Load("StEmcRawMaker"));
34  assert( !gSystem->Load("StEmcADCtoEMaker"));
35  if (flagMC) {
36  assert( !gSystem->Load("StMcEvent"));
37  assert( !gSystem->Load("StMcEventMaker"));
38  assert( !gSystem->Load("StEmcSimulatorMaker"));
39  assert( !gSystem->Load("StEpcMaker"));
40  }
41  assert( !gSystem->Load("StTriggerUtilities"));
42 
43  gROOT->Macro("LoadLogger.C");
44  cout << " loading done " << endl;
45 
46  StChain *chain= new StChain("StChain");
47 
48  //Need MuDstMaker to get data
49  printf(" dirIn=%s= file=%s=\n",dirIn,file);
50  StMuDstMaker* muDstMaker =new StMuDstMaker(0,0,dirIn,file,"MuDst.root",nFiles);
51 
52  TChain* tree=muDstMaker->chain(); assert(tree); int nEntries=(int) tree->GetEntries();
53  cout << "Avaliable number of events " << nEntries << endl;
54 
55  //Database -- get a real calibration from the database
56  St_db_Maker* dbMk = new St_db_Maker("StarDb","MySQL:StarDb","MySQL:StarDb","$STAR/StarDb");
57 
58  //If MC then must set database time and date
59  // if Endcap fast simu is used tower gains in DB do not matter,JB
60  if(flagMC) {
61  dbMk->SetDateTime(20080307, 83000);//timestamp R9067013
62  }
63 
64  //Endcap DB
65  new StEEmcDbMaker("eemcDb");
66 
67  //Get BEMC adc values
68  StEmcADCtoEMaker *a2eMk = new StEmcADCtoEMaker();
69  a2eMk->saveAllStEvent(true);
70 
71  /*
72  reads all input/setup files from L2setup-yyyymmdd/
73  writes all output files to L2out-yyyymmdd
74  depending on the DB time stamp
75  both dierectiorie MUST exist, setup must be reasonable
76  */
78  assert(simL2Mk);
79  simL2Mk->setSetupPath(eemcSetupPath);
80  simL2Mk->setOutPath(outDir.Data());
81  if (flagMC) simL2Mk->setMC();
82  //simL2Mk->useStEvent(); // default : use muDst
83 
84 
85  new StJanEventMaker; // produces binary event file - the main goal of this macro
86 
87  chain->ls(3);
88  chain->Init();
89 
90  int t1=time(0);
91 
92  for (Int_t iev=0;iev<nevents; iev++) {
93  cout << "\n****************************************** " << endl;
94  cout << "Working on eventNumber:\t" << iev <<"\tof:\t"<<nevents<<endl;
95  cout << "****************************************** " << endl;
96  chain->Clear();
97  int iret = chain->Make(iev);
98  total++;
99  if (iret % 10 == kStEOF || iret % 10 == kStFatal) {
100  cout << "Bad return code!" << endl;
101  break;
102  }
103  }
104  int t2=time(0);
105  if(t2==t1) t2=t1+1;
106  float tMnt=(t2-t1)/60.;
107  float rate=1.*total/(t2-t1);
108 
109  chain->Finish();
110  cout << "****************************************** " << endl;
111  cout << "total number of events " << total << endl;
112  cout << "****************************************** " << endl;
113 
114 
115  TString fileMu=file;
116  printf("=%s=\n",fileMu.Data());
117  if(fileMu.Contains(".lis")) fileMu.ReplaceAll(".lis",".trgSim");
118  if(fileMu.Contains(".MuDst.root")) fileMu.ReplaceAll(".MuDst.root",".trgSim");
119  cout <<Form("sorting done %d of nEve=%d, CPU rate=%.1f Hz, total time %.1f minute(s) \n\n",total,nEntries,rate,tMnt)<<endl;
120 
121 }
122 
virtual void Clear(Option_t *option="")
User defined functions.
Definition: StChain.cxx:77
virtual Int_t Finish()
Definition: StChain.cxx:85
virtual void ls(Option_t *option="") const
Definition: TDataSet.cxx:495
Definition: Stypes.h:43
virtual Int_t Make()
Definition: StChain.cxx:110
TChain * chain()
In read mode, returns pointer to the chain of .MuDst.root files that where selected.
Definition: StMuDstMaker.h:426
void saveAllStEvent(Bool_t a)
Set to kTRUE if all hits are to be saved on StEvent.