StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
RunTriggerSimu2015.C
1 void RunTriggerSimu2015(
2 //int nevents = 10,
3 //data test file:
4 const char* indir = "root://xrdstar.rcf.bnl.gov:1095//home/starlib/home/starreco/reco/production_pp200trans_2015/ReversedFullField/P16id/2015/085/16085026/st_physics_16085026_raw_1000019.MuDst.root"
5 //const char* indir = "root://xrdstar.rcf.bnl.gov:1095//home/starlib/home/starreco/reco/dAu200_production_2016/ReversedFullField/P17ib/2016/136/17136038/st_upc_17136038_raw_4000004.MuDst.root"
6 //embedding test file:
7 //const char* indir = "/gpfs01/star/pwg/ztu/STARlight/starsim/output/slight16dAu_zerobias_incohVM_100k_Emb_v6/0004/out/output.MuDst.root"
8 )
9 {
10 // cout<<"MuDst file is "<<MuDst<<endl;
11 
12  gROOT->Macro("loadMuDst.C");
13  gROOT->Macro("LoadLogger.C");
14 
15  gSystem->Load("StDetectorDbMaker");
16  gSystem->Load("StDaqLib");
17  gSystem->Load("StEmcRawMaker");
18  gSystem->Load("StEmcADCtoEMaker");
19  gSystem->Load("StDbBroker");
20  gSystem->Load("St_db_Maker");
21  gSystem->Load("StEEmcUtil");
22  gSystem->Load("StEEmcDbMaker");
23  gSystem->Load("StEmcTriggerMaker");
24  gSystem->Load("StTriggerUtilities");
25  gSystem->Load("StTriggerFilterMaker");
26 
27  StChain *chain = new StChain;
28 
29  StMuDstMaker* muDstMaker = new StMuDstMaker(0,0,indir, "","",1000);
30 
31  StMuDbReader* muDstDb = StMuDbReader::instance();
32 
33  St_db_Maker* starDb = new St_db_Maker("StarDb","MySQL:StarDb");
34 
35  StEEmcDbMaker* eemcDb = new StEEmcDbMaker;
36 
37  // StSpinDbMaker* spinDb = new StSpinDbMaker;
38 
40  adc->saveAllStEvent(true);
41 
42  StTriggerSimuMaker* simuTrig = new StTriggerSimuMaker("StarTrigSimu");
43  //use online or offline option
44  //simuTrig->useOnlineDB();
45  simuTrig->useOfflineDB();
46  simuTrig->setMC(0);
47 
48  //bbc is not used in run12 analysis
49  //simuTrig->useBbc();
50  simuTrig->useBemc();
51  simuTrig->useEemc();
52  //use online or offline bemc tower pedestals and statuses
53  simuTrig->bemc->setConfig(StBemcTriggerSimu::kOnline);
54  //un-comment out the following two lines to test DSM algorithm with raw MuDst files
55  //simuTrig->bemc->mTestMode = true;
56  //simuTrig->eemc->mTestMode = true;
57  //define triggers with trigger index, trigger name, offline Id, onbits, offbits, onbits1, onbits2, onbits3, offbits1, offbits2, offbits3
58  //this method need to be called only when the trigger definitions in online and offline are not correct
59  //simuTrig->emc->defineTrigger(8, "JP0", 380401, 0x0, 0x0, 0x80000000, 0x0, 0x0, 0x0, 0x0, 0x1);
60  //set jet patch thresholds only used when the jet patch thresholds in online and offline database not correct
61  //jp-th0 set to 28
62  //simuTrig->setBarrelJetPatchTh(0,28);
63  //simuTrig->setOverlapJetPatchTh(0,28);
64  //simuTrig->setEndcapJetPatchTh(0,28);
65  //set high tower thresholds only used when the jet patch thresholds in online and offline database not correct
66  //simuTrig->setBarrelHighTowerTh(0, 11);
67  //simuTrig->setEndcapHighTowerTh(0, 25);
68  // Run
69  chain->Init();
70  TFile *fout = new TFile("out.simu.2015.root", "recreate");
71  TH1F *hh = new TH1F("hh", "; fired", 2, 0, 2);
72  TH2F *h2d =new TH2F("h2d", "; data ;simu", 2, 0, 2, 2, 0, 2);
73  TH2F *hhtdiff = new TH2F("hhtdiff", "; patch; ht diff", 300, 0, 300, 253, -126, 127);
74  TH2F *hht = new TH2F("hht", "; patch; ht", 300,0,300, 64, 0, 64);
75  TH2F *hpadiff = new TH2F("hpadiff", "; patch; pa diff", 300, 0, 300, 253, -126, 127);
76  TH2F *hpa = new TH2F("hpa", "; patch; pa", 300,0,300, 64, 0, 64);
77 
78  //TH2F *hlayer1 = new TH2F("hlayer1", ";channel; bit", 48, 0, 48, 16,0, 16);
79  int nEvents = muDstMaker->chain()->GetEntries();
80  int trigId_1 = 480411;
81  int trigId_2 = 480411;
82  cout << "number of events ~ " << nEvents << endl;
83  //nEvents = 1000;
84  for(int iEvent = 0; iEvent < nEvents; iEvent++)
85  {
86  chain->Clear();
87  int status = chain->Make(iEvent);
88  if(status == kStSkip) continue;
89  if(status % 10 == kStEOF || status % 10 == kStFatal) break;
90  //std::cout<<"trigger simulator: UPC-Jpsi fired = "<< simuTrig->isTrigger(trigId) <<endl;
91  bool did_1 = StMuDst::event()->triggerIdCollection().nominal().isTrigger(trigId_1);
92  bool did_2 = StMuDst::event()->triggerIdCollection().nominal().isTrigger(trigId_2);
93  //bool did_2 = 0;
94  bool did = did_1 || did_2;
95  //bool fire = simuTrig->emc->EHT0();
96  bool fire = simuTrig->isTrigger(trigId_1);
97  hh->Fill(fire);
98  h2d->Fill(did, fire);
99  if(did && !fire){
100  Printf("iEvent=%d", iEvent);
101 
102  StEmcTriggerDetector emc = StMuDst::event()->emcTriggerDetector();
103  int *stpht = simuTrig->bemc->getBEMC_FEE_HT_ADC();
104  int *stppa = simuTrig->bemc->getBEMC_FEE_TP_ADC();
105  for(int ip = 0; ip < 300; ip++){
106  int ht = emc.highTower(ip);
107  int sht = stpht[ip];
108  int diffht = ht - sht;
109  //if(diffht > 0){
110  hhtdiff->Fill(ip, diffht);
111  hht->Fill(ip, ht);
112  //}
113 
114  int pa = emc.patch(ip);
115  int spa = stppa[ip];
116  int diffpa = pa -spa;
117  //if(diffpa > 0){
118  hpadiff->Fill(ip, diffpa);
119  hpa->Fill(ip, ht);
120  //}
121  }
122  }
123  }
124  //chain->EventLoop(nevents);
125  fout->Write();
126  fout->Close();
127 }
virtual void Clear(Option_t *option="")
User defined functions.
Definition: StChain.cxx:77
Definition: Stypes.h:49
Definition: Stypes.h:43
virtual Int_t Make()
Definition: StChain.cxx:110
static StMuEvent * event()
returns pointer to current StMuEvent (class holding the event wise information, e.g. event number, run number)
Definition: StMuDst.h:320
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.