StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
SkimPion.C
1 // Runs the Skim Pion maker for calibrations
2 // A. Hoffman 2007
3 
4 void SkimPion(const char* fileList, const char* fileId="Skim.root") {
5 
6  int flagMC=0; // 0== off, 1=Alan
7  int useEemc=1; // 0== off
8  int useBemc=1; // 0== off
9  int useL2=1; // 0== off
10  int L2ConfigYear=2006; // possible: 2006, 2008
11  int bemcConfig=2; // enum: kOnline=1, kOffline, kExpert
12  int playConfig=100; // jan:100_199
13  int emcEveDump=0; // extrating raw EMC data in a custom format
14  const char *dirIn="";
15  int nFiles = 100000; // make this big if you want to read all events from a run
16  char *eemcSetupPath="/afs/rhic.bnl.gov/star/users/kocolosk/public/StarTrigSimuSetup/";
17 
18  TString outDir="./out2/";
19 
20  gROOT->LoadMacro("$STAR/StRoot/StMuDSTMaker/COMMON/macros/loadSharedLibraries.C");
21 
22  loadSharedLibraries();
23 
24  gSystem->Load("StDetectorDbMaker");
25  gSystem->Load("StDbUtilities");
26  gSystem->Load("StDbBroker");
27  gSystem->Load("St_db_Maker");
28  gSystem->Load("StEEmcUtil");
29  gSystem->Load("StEEmcDbMaker");
30  gSystem->Load("StarMagField");
31  gSystem->Load("geometry");
32  gSystem->Load("St_g2t");
33  gSystem->Load("St_geant_Maker");
34  gSystem->Load("StDaqLib");
35  gSystem->Load("StEmcRawMaker");
36  gSystem->Load("StEmcADCtoEMaker");
37  gSystem->Load("StTriggerUtilities");
38  gSystem->Load("StEpcMaker");
39 
40  gSystem->Load("StSpinDbMaker");
41 
42  // Renees Trigger Maker
43  //gSystem->Load("StEmcTriggerMaker");
44 
45  // Mikes relative luminosity interface
46  gSystem->Load("StEsRelLum");
47 
48  //Load your maker here
49  gSystem->Load("StSkimPionMaker");
50 
51  gROOT->Macro("LoadLogger.C");
52  cout << "loading done " << endl;
53 
54  StChain *chain = new StChain("StChain");
55  StMuDstMaker *mudst_mk = new StMuDstMaker(0,0,"",fileList,"MuDst.root",999); // MuDST reader
56 
57  //StMuDbReader
58  StMuDbReader* db = StMuDbReader::instance();
59 
60  // Need St_db_Maker for Emc calibration
61  St_db_Maker *db1 = new St_db_Maker("StarDb","$STAR/StarDb","MySQL:StarDb");
62 
63  //Database interface, needed for prescales
64  StDetectorDbMaker* detDbMk = new StDetectorDbMaker();
65 
66  // Database for Spin data
67  StSpinDbMaker *spDb=new StSpinDbMaker("spinDb");
68 
69  //Endcap DB
70  if(useEemc || useL2) new StEEmcDbMaker("eemcDb");
71 
72  // Maker to apply calibration
73  StEmcADCtoEMaker *adc_to_e=new StEmcADCtoEMaker();
74  adc_to_e->setPrint(kFALSE);
75  //adc_to_e->saveAllStEvent(true);
76 
77  //Collect all output histograms
78  TObjArray* HList = new TObjArray;
79 
80  //Get TriggerMaker
81  StTriggerSimuMaker *simuTrig = new StTriggerSimuMaker("StarTrigSimu");
82  simuTrig->setHList(HList);
83  simuTrig->setMC(flagMC); // must be before individual detectors, to be passed
84  simuTrig->useBbc();
85 
86  if(useEemc)
87  {
88  simuTrig->useEemc(0);//default=0:just process ADC, 1,2:comp w/trgData,see .
89  simuTrig->eemc->setSetupPath(eemcSetupPath);
90  }
91  if(useBemc)
92  {
93  simuTrig->useBemc();
94  simuTrig->bemc->setConfig(bemcConfig);
95  }
96 
97 
98  if(1)
99  {
100  /*
101  reads all input/setup files from L2setup-yyyymmdd/
102  writes all output files to L2out-yyyymmdd
103  depending on the DB time stamp
104  both dierectiorie MUST exist, setup must be reasonable
105  */
106 
107  StGenericL2Emulator* simL2Mk=0;
108  if(L2ConfigYear==2006) simL2Mk= new StL2_2006EmulatorMaker;
109  else if(L2ConfigYear==2008) simL2Mk= new StL2_2008EmulatorMaker;
110  assert(simL2Mk);
111  simL2Mk->setSetupPath(eemcSetupPath);
112  simL2Mk->setOutPath(outDir.Data());
113  if (flagMC) simL2Mk->setMC();
114  //simL2Mk->useStEvent(); // default : use muDst
115  simuTrig->useL2(simL2Mk);
116  }
117 
118 
119  // Makers for clusterfinding
120  StPreEclMaker *pre_ecl=new StPreEclMaker();
121  pre_ecl->setPrint(kFALSE);
122  StEpcMaker *epc=new StEpcMaker();
123  epc->setPrint(kFALSE);
124 
125  //StEmcTrigger
126  //StEmcTriggerMaker *emcTrig = new StEmcTriggerMaker("StEmcTriggerMaker");
127  //emcTrig->setDbMaker(db1);
128 
129  // now add your analysis maker
130  StSkimPionMaker* analysis = new StSkimPionMaker("SkimPionMaker", 1, fileId);
131 
132  chain->ls(3);
133  chain->Init();
134 
135  //Tight cuts (esp. SMD)
136 
137  Int_t sizeMax = 4;
138  Float_t energySeed = 0.4; // default is 0.7, usually 0.35
139  Float_t energyAdd = 0.05; // default is 0.07, usually 0.035
140  pre_ecl->SetClusterConditions("bemc", sizeMax, energySeed, energyAdd, 0.02, kFALSE);
141  // defaults for SMDs are ("...", 5, 0.4, 0.001, 0.1, kFALSE)
142  pre_ecl->SetClusterConditions("bsmde", 5, 0.4,0.005, 0.1,kFALSE); // used 5, 0.2, 0.0005, 0.1
143  pre_ecl->SetClusterConditions("bsmdp", 5, 0.4,0.005, 0.1,kFALSE);
144  pre_ecl->SetClusterConditions("bprs", 1, 500., 500., 501., kFALSE);
145 
146  // TStopwatch totaltime;
147  TStopwatch timer;
148  TMemStat memory;
149 
150  Int_t n_event=100000000;
151  int total =0;
152 
153  cout << "Chain initialized, starting up... " << endl;
154 
155  for(Int_t iev=0;iev<n_event; iev++) {
156 
157  cout << "****************************************** " << endl;
158  cout << "\Processing Event " << iev << " of "<< n_event << endl;
159  cout << "*************************1***************** " << endl;
160 
161  chain->Clear();
162 
163  if(iev % 500 == 0){
164  cout<<"done with event "<<iev;
165  cout<<"\tcpu: "<<timer.CpuTime()<<"\treal: "<<timer.RealTime()<<"\tratio: "<<timer.CpuTime()/timer.RealTime()<<endl;
166  timer.Start();
167  memory.PrintMem(NULL);
168  }
169 
170  int iret = chain->Make(iev);
171  total++;
172 
173  if(iret % 10 == kStEOF || iret % 10 == kStFatal)
174  {
175  cout << "Bad return code!" << endl;
176  break;
177  }
178 
179  }
180 
181  chain->Finish();
182  cout << "****************************************** " << endl;
183  cout << "total number of events " << total << endl;
184  cout << "****************************************** " << endl;
185 
186 }
void setPrint(Bool_t)
Obsolete function; users can control messages with logger config file.
virtual void Clear(Option_t *option="")
User defined functions.
Definition: StChain.cxx:77
void setPrint(Bool_t a)
Obsolete function; users can control messages with logger config file.
Definition: StPreEclMaker.h:36
virtual Int_t Finish()
Definition: StChain.cxx:85
void SetClusterConditions(char *, Int_t, Float_t, Float_t, Float_t, Bool_t=kFALSE)
this is for background compatibility with the old finder
virtual void ls(Option_t *option="") const
Definition: TDataSet.cxx:495
Definition: Stypes.h:43
virtual Int_t Make()
Definition: StChain.cxx:110
void setPrint(Bool_t a)
Obsolete function; users can control messages with logger config file.
Definition: StEpcMaker.h:89