StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
RunLuminosityMaker.C
1 #include <vector>
2 using namespace std;
3 class StChain;
4 StChain *chain;
5 int total=0;
6 
7 void RunLuminosityMaker(int nevents=10,
8  const char* file = "test.list",
9  //const char* file="st_physics_7156024_raw_1010001.MuDst.root",
10  const char* dir = "./",
11  const char *filter = "")
12 {
13  cout <<"MuDst chain file:\t"<<file<<endl;
14  //abort();
15  gROOT->Macro("LoadLogger.C");
16  gROOT->Macro("loadMuDst.C");
17  gSystem->Load("StDaqLib");
18  gSystem->Load("StDbBroker");
19  gSystem->Load("StDetectorDbMaker");
20  gSystem->Load("St_db_Maker");
21  gSystem->Load("StTriggerFilterMaker");
22  gSystem->Load("StEmcRawMaker");
23  gSystem->Load("StEmcADCtoEMaker");
24  gSystem->Load("StTriggerUtilities");
25  gSystem->Load("StLuminosityMaker");
26 
27 
28  double pi = atan(1.0)*4.0;
29  cout << " loading done " << endl;
30 
31  chain= new StChain("StChain");
32  chain->SetDebug(1);
33 
34 
35 
36  //Instantiate the MuDstReader
38  StMuDstMaker* muDstMaker = new StMuDstMaker(0,0,dir,file,filter,1000000,"MuDst");
39 
40  //Database
41  St_db_Maker *dbMk = new St_db_Maker("StarDb", "MySQL:StarDb");
42 
43  /*
44  StTriggerFilterMaker* trigfilt = new StTriggerFilterMaker();
45  trigfilt->addTrigger(96011);
46  trigfilt->addTrigger(96201);
47  trigfilt->addTrigger(96211);
48  trigfilt->addTrigger(96221);
49  trigfilt->addTrigger(96233);
50  */
51 
52  //Block for TriggerSimuMaker
53 
55 
56  StTriggerSimuMaker* trigsim = new StTriggerSimuMaker();
57  trigsim->useBbc();
58  trigsim->useBemc();
59  trigsim->bemc->setConfig(StBemcTriggerSimu::kOffline);
60  /*
61  StGenericL2Emulator* simL2Mk = new StL2_2006EmulatorMaker;
62  assert(simL2Mk);
63  simL2Mk->setSetupPath("./StRoot/StJetMaker/StarTrigSimuSetup/");
64  char outPath[200];
65  sprintf(outPath,"./out/");
66  simL2Mk->setOutPath(outPath);
67  trigsim->useL2(simL2Mk);
68  */
69 
70  //end TriggerSimuMaker block
71 
73  lum->setVertexCutcm(60);
74  //lum->setMode("pp2005");
75 /*
76  lum->addTrigger(96011);
77  lum->addTrigger(96201);
78  lum->addTrigger(96221);
79  lum->addTrigger(96211);
80  lum->addTrigger(96233);*/
81  lum->setCrossSectionNB(26.1e6);
82  //lum->getTriggersFromFilterMaker();
83  /*
84  lum->setMode("pp2006");//see StLuminosityMaker.cxx for accepted modes
85  */
86  lum->addTrigger(117001);//mb..this trigger must be added first
87  lum->addTrigger(137221);//bemc-jp1-mb
88  lum->addTrigger(137222);//bemc-jp1-mb
89  lum->addTrigger(137822);//bemc-http-mb-fast
90  lum->addTrigger(117300);//zb
91  lum->addTrigger(137571);//bemc-jp1
92  lum->addTrigger(137575);//bemc-jp0-etot
93  lum->addTrigger(137585);//bemc-jp2
94  lum->addTrigger(137586);//bemc-http
95  lum->addTrigger(137611);//bemc-http-mb-l2gamma
96  lum->addTrigger(137501);//bemc-jp0-mb
97  lum->addTrigger(137622);//bemc-jp0-etot-mb-L2jet
98  //lum->addTrigger(137461);//fpd1-tpcdead-fast
99 
100  chain->Init();
101 
102  chain->PrintInfo();
103 
104  for (Int_t iev=0;iev<nevents; iev++) {
105  /*
106  cout << "****************************************** " << endl;
107  cout << "Working on eventNumber " << iev << endl;
108  cout << "*************************1***************** " << endl;
109  */
110  chain->Clear();
111  int iret = chain->Make(iev);
112  total++;
113 
114  if (iret && iret!=kStSkip) {
115  cout << "Bad return code!" <<iret<< endl;
116  break;
117  }
118 
119  //Here's where you can do your analysis, for an example look in this method
120  }
121  chain->Finish();
122  cout << "****************************************** " << endl;
123  cout << "total number of events " << total << endl;
124  cout << "****************************************** " << endl;
125 
126  //vector<StLuminosityHolder> holder;
127  TClonesArray* holder = lum->getHolder();
128  StLuminosityHolder* dumlum;
129 
130  for(int i = 0; i < holder->GetEntries(); i++){
131  char name[100];
132  dumlum = (StLuminosityHolder*)holder->At(i);
133  int run1 = dumlum->getRunNumber();
134  sprintf(name,"lum%i.data",run1);
135  ofstream lumout(name);
136  vector<unsigned int> triggers = dumlum->getTriggers();
137  vector<unsigned int> NTotal = dumlum->getNTotal();
138  vector<unsigned int> NCuts = dumlum->getNCuts();
139  vector<unsigned int> NVert = dumlum->getNVertex();
140  vector<unsigned int> NTrig = dumlum->getNSoftTrig();
141  vector<float> LumTotal = dumlum->getLumTotal();
142  vector<float> LumCuts = dumlum->getLumCuts();
143  vector<float> LumVert = dumlum->getLumVertex();
144  vector<float> LumTrig = dumlum->getLumSoftTrig();
145  vector<float> Prescales = dumlum->getPrescales();
146  for(unsigned int j = 0; j < dumlum->getTriggers().size(); j++){
147  lumout<<run1<<"\t"<<triggers[j]<<"\t"<<Prescales[j]<<"\t"<<NTotal[j]<<"\t"<<NCuts[j]<<"\t"<<NVert[j]<<"\t"<<NTrig[j]<<"\t"<<LumTotal[j]<<"\t"<<LumCuts[j]<<"\t"<<LumVert[j]<<"\t"<<LumTrig[j]<<endl;
148  }
149  lumout.close();
150  }
151 
152 }
virtual void Clear(Option_t *option="")
User defined functions.
Definition: StChain.cxx:77
static void setLevel(unsigned int level)
sets the debug level
Definition: StMuDebug.h:74
virtual Int_t Finish()
Definition: StChain.cxx:85
Definition: Stypes.h:49
virtual Int_t Make()
Definition: StChain.cxx:110