StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
RunElectronAnalysis.C
1 #include <iostream>
2 #include <fstream>
3 #include <set>
4 
5 using namespace std;
6 
7 void RunElectronAnalysis(Int_t nEntries = 1e5,
8  const Char_t* listname="test.list",
9  const Char_t* mipFile="/star/u/jkadkins/bemcCalib2012/StRoot/StEmcOfflineCalibrationMaker/macros/mip.gains",
10  const Char_t* geantFile="/star/u/jkadkins/bemcCalib2012/StRoot/StEmcOfflineCalibrationMaker/macros/geant_fits.root",
11  const Char_t* outfile="testElectronFile.root")
12 {
13  gROOT->Macro("LoadLogger.C");
14  gROOT->Macro("loadMuDst.C");
15  gSystem->Load("StTpcDb");
16  gSystem->Load("StDaqLib");
17  gSystem->Load("StDetectorDbMaker");
18  gSystem->Load("St_db_Maker");
19  gSystem->Load("StDbUtilities");
20  gSystem->Load("StEmcRawMaker");
21  gSystem->Load("StMcEvent");
22  gSystem->Load("StMcEventMaker");//***
23  gSystem->Load("StEmcSimulatorMaker");//***
24  gSystem->Load("StEmcADCtoEMaker");
25  gSystem->Load("StEpcMaker");
26  gSystem->Load("StDbBroker");
27  gSystem->Load("StEEmcUtil");
28  gSystem->Load("StAssociationMaker");
29  gSystem->Load("StTriggerUtilities");
30  gSystem->Load("StEmcOfflineCalibrationMaker");
31 
32  //Instantiate StChain
33  StChain *chain = new StChain;
34 
35  TChain *ElectronChain = new TChain("calibTree");
36  Char_t file[300];
37  ifstream filelist(listname,ifstream::in);
38  while(1){
39  filelist >> file;
40  if (!filelist.good()) break;
41  cout << file << endl;
42  ElectronChain->Add(file);
43  }
44 
45  /* Since we're not using MuDst files, the StEmcADCtoEMaker class fails to
46  make BEMC detector. We are only using this for access to the BEMC tables,
47  so we turn off this annoying message with these two lines */
48  StMessMgr *msg = StMessMgr::Instance();
49  msg->SwitchOff("Could not make BEMC detector");
50 
51  St_db_Maker *dbMaker = new St_db_Maker("StarDb","MySQL:StarDb");
52  dbMaker->SetDateTime(20120501,200000);
54 
55  StEmcOfflineCalibrationElectronAnalysis *mipAnalysis = new StEmcOfflineCalibrationElectronAnalysis("StEmcOfflineCalibrationElectronAnalysis",outfile,mipFile,geantFile,ElectronChain);
56 
57  //Initialize chain
58  chain->Init();
59  cout << "Successful Init" << endl;
60 
61  //Loop over all Make() in Chain
62  for (Int_t iEntry = 0; iEntry < ElectronChain->GetEntries(); ++iEntry){
63  if (ElectronChain->GetEvent(iEntry) <= 0){
64  cout << "BROKEN!" << endl;
65  break;
66  }
67 
68  if (iEntry%10000 == 0)
69  cout << "Working on event: " << iEntry << endl;
70 
71  chain->Clear();
72  Int_t iret = chain->Make(iEntry);
73  if(iret){
74  cout << "Bad return code" << endl;
75  break;
76  }
77  }
78 
79  chain->Finish();
80 }
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