StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
makeHistFromMuDst.C
1 class StChain;
2 class StMuDstMaker;
3 class St_db_Maker;
4 class StEmcADCtoEMaker;
5 class TH1F;
6 
7 //--
8 //-- globals
9 //--
10 StChain *mChain = 0;
11 StMuDstMaker *mMuDstMaker = 0;
12 St_db_Maker *mDb = 0;
13 StEmcADCtoEMaker *bemcAdc2E = 0;
14 
15 Int_t count = 0;
16 Int_t stat = 0;
17 
18 Int_t prescale = 1;
19 
20 void makeHistFromMuDst( Int_t nevents = -1,
21  // Char_t *name = "6149020.lis",
22  // Char_t *ofile= "6149020.root",
23  //Char_t *name="10103044.lis",
24  Char_t *name="10097097.lis",
25  Char_t *ofile="temp.hist.root",
26  Char_t *path = "",
27  Int_t nfiles = 100
28  )
29 {
30  int mRunNo=10103044;
31  //int mRunNo=10097097;
32  //int triggerChoice=1;//ZDC
33  int triggerChoice=230531;//BHT3
34  //int triggerChoice=230010;//BBC
35 
36 
37  //gROOT -> LoadMacro("$STAR/StRoot/StMuDSTMaker/COMMON/macros/loadSharedLibraries.C");
38  //loadSharedLibraries();
39  //gSystem->Load("TH1F");
40  // gSystem->Load("libgeometry_Tables");
41  // gSystem->Load("StDaqLib");
42  //gSystem->Load("StEmcRawMaker");
43  //gSystem->Load("StEmcADCtoEMaker");
44 
45  gROOT->Macro("loadMuDst.C");
46  gSystem->Load("StDaqLib");
47  gSystem->Load("StDetectorDbMaker");
48  gSystem->Load("St_db_Maker");
49  gSystem->Load("StDbUtilities");
50  gSystem->Load("StEmcRawMaker");
51  gSystem->Load("StEmcADCtoEMaker");
52  gSystem->Load("StDbBroker");
53 
54 
55  gMessMgr -> SwitchOff("D");
56  gMessMgr -> SwitchOff("I");
57  TString pathname = path;
58  pathname += name;
59  mChain = new StChain("chain");
60 
61 
62 
63  mMuDstMaker = new StMuDstMaker(0,0,path,name,"MuDst",nfiles);
64  mDb = new St_db_Maker("StarDb", "MySQL:StarDb", "$STAR/StarDb");
65  bemcAdc2E = new StEmcADCtoEMaker();
66 
67 #if 0
68  mMuDstMaker->SetStatus("*",0);
69  mMuDstMaker->SetStatus("MuEvent",1);
70  mMuDstMaker->SetStatus("EmcAll",1);
71  mMuDstMaker->SetStatus("PrimaryTracks",1);
72 #endif
73 
74  //StMuDbReader *db = StMuDbReader::instance();
75  //StDetectorDbMaker *detdb = new StDetectorDbMaker();
76  // mStarDatabase = new St_db_Maker("StarDb", "MySQL:StarDb");
77  // mStarDatabase = new St_db_Maker("StarDb", "MySQL:StarDb", "$STAR/StarDb");
78 
79  //get BEMC calibration
80  // StEmcADCtoEMaker *bemcAdc2E = new StEmcADCtoEMaker(); // this will just convert what's in MuDst to ADC, use for data only!
81  // bemcAdc2E->setPrint(true);
82 
83 
84  mChain->ls(3);
85  mChain->Init();
86 
87  int seconds=1500;
88  int bins=1500;
89  TH1F *hTime=new TH1F("time","timing plot;t (s);hz",bins,0,seconds);
90  TH2F *hModuleTime=new TH2F("moduleTime","module hits per second;t(s);module #",bins,0,seconds,120,0,120);
91  TH2F *hPatchTime=new TH2F("patchTime","patch hits per second;t(s);module #",bins,0,seconds,300,0,300);
92  TH1F *hNoHotTowers=new TH1F("noHotTowers","rate plot for good towers;t(s);hz",bins,0,seconds);
93  TH2F *hPatch=new TH2F("patchADC","HT ADC spectrum per patch;ADC;Patch ID",80,-10,70,300,0,300);
94  TH3F *hPatchXing=new TH3F("patchX","hits by time, patch, and bXing",bins,0,seconds,300,0,300,120,0,120);
95  TH2F *hXingTime=new TH2F("timeX","hits by time and bXing",bins,0,seconds,120,0,120);
96  TH2F *hZTime=new TH2F("zX","hits by time and BBC vertex z",bins,0,seconds,20,-100,100);
97 
98  //-----------------------------------------------------------------
99  //--
100  Int_t stat = 0; // error flag
101  Int_t count = 0; // event count
102  Int_t baseTime=0;
103  Int_t BHT3_trigger_id=230531;
104  while ( stat == 0 ) {
105 
106  if (count%1000==0)
107  {
108  std::cout << "------------------------------------------------";
109  std::cout << "event=" << count << std::endl;
110  }
111 
112  if ( count++ >= nevents ) if ( nevents > 0 ) break;
113 
114  mChain -> Clear();
115  stat = mChain -> Make();
116  StMuDst *mudst=mMuDstMaker->muDst();
117  //rezero at the time of the first event:
118  if (count == 1 ) baseTime=mudst->event()->eventInfo().time();
119 
120  if ( mMuDstMaker->muDst()->event()->triggerIdCollection().nominal()->isTrigger(triggerChoice)){
121  int eventTime=mudst->event()->eventInfo().time()-baseTime;
122  hTime->Fill(eventTime,bins*1.0/(1.0*seconds));
123  hZTime->Fill(eventTime,mudst->event()->bbcTriggerDetector().zVertex());
124  //hXingTime->Fill(eventTime,mudst->event()->l0Trigger().bunchCrossingId7bit(mRunNo));
125 
126  // TH3F *hPatchXing=new TH3F("patchX","hits by time, patch, and bXing",bins,0,seconds,300,0,300,120,0,120);
127 
128  if (triggerChoice==230531){//only makes sense to check high towers if we're using the BHT3 trig.
129  for (int m=0;m<300;m++)
130  {
131  hPatch->Fill(mudst->event()->emcTriggerDetector().highTower(m),m);
132  if (mudst->event()->emcTriggerDetector().highTower(m)>30)
133  {
134  //printf("trigger on %d. bXing=%d\n",m,mudst->event()->l0Trigger().bunchCrossingId7bit(mRunNo));
135  hPatchXing->Fill(eventTime,m,mudst->event()->l0Trigger().bunchCrossingId7bit(mRunNo));
136  hPatchTime->Fill(eventTime,m);
137  }
138  }
139  }
140  else {
141  hPatchXing->Fill(eventTime,1,mudst->event()->l0Trigger().bunchCrossingId7bit(mRunNo));
142  }
143 
144 
145 
146  }
147  }
148  printf("Total events: %d\n",count);
149  //--
150  //-----------------------------------------------------------------
151 
152  mChain -> Finish();
153 
154  // hTime->Draw();
155 
156  /* TH1F *hdHzdT=new TH1F("dHzdT","Rate change in each bin (bin+1)-(bin-1);dHz;t(s)",bins,0,seconds);
157 
158  for (int i=1;i<bins;i++)
159  {
160  hdHzdT->SetBinContent(i,hTime->GetBinContent(i+1)-hTime->GetBinContent(i-1));
161  }
162 
163  hdHzdT->Draw();
164  */
165  TFile *out=new TFile(ofile,"recreate");
166  out->cd();
167  hTime->Write();
168  hPatchTime->Write();
169  hPatch->Write();
170  hPatchXing->Write();
171  hZTime->Write();
172  //hdHzdT->Write();
173 
174  return;
175 
176 }
177 
StMuDst * muDst()
Definition: StMuDstMaker.h:425
virtual void ls(Option_t *option="") const
Definition: TDataSet.cxx:495
static StMuEvent * event()
returns pointer to current StMuEvent (class holding the event wise information, e.g. event number, run number)
Definition: StMuDst.h:320
void SetStatus(const char *arrType, int status)