StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StRccCounterMonitor.cxx
1 #include <stdlib.h>
2 
3 #include "StRccCounterMonitor.h"
4 #include "StMaker.h"
5 #include "StEventTypes.h"
6 #include "StEvent/StTriggerData.h"
7 
8 #include "TFile.h"
9 #include "TH1.h"
10 #include "TH2.h"
11 #include "TTree.h"
12 
13 static const int NCRATE=14;
14 static const char* CRATE[NCRATE]={"L1","BC1","MXQ","MIX","BCW","BCE","FEQ",
15  "BBC","BBQ","FMS","QT1","QT2","QT3","QT4"};
16 static const int MAX=pow(2.0,16)*2.0;
17 static const int NBIN=pow(2.0,12);
18 
19 unsigned int EVT;
20 unsigned int TCU;
21 unsigned int DIFF[NCRATE];
22 
23 ClassImp(StRccCounterMonitor)
24 
25 StRccCounterMonitor::StRccCounterMonitor(int run, const char *name):StMaker("rccqa",name){
26  LOG_INFO << "Constructing StRccCounterMonitor with name=" << name << endm;
27  mDebug=0;
28  mRun=run;
29  mEventCounter=0;
30 }
31 
32 Int_t StRccCounterMonitor::Init(){
33  int yearday=mRun/1000;
34  sprintf(mFilename,"%d/rccqa.%d.root",yearday,mRun);
35  mFile = new TFile(mFilename, "RECREATE");
36  if(mFile){
37  cout << "Creating " << mFilename << endl;
38  }else{
39  cout << "Could not create " << mFilename << endl;
40  return kStErr;
41  }
42  for(int i=0; i<NCRATE; i++){
43  mHist[i] = new TH1F(CRATE[i],CRATE[i],NBIN,0.0,MAX);
44  }
45  mTree = new TTree("RCC","RCC");
46  mTree->Branch("evt",&EVT,"evt/i");
47  mTree->Branch("tcu",&TCU,"tcu/i");
48  mTree->Branch("diff",&DIFF,"d[14]/i");
49  return kStOK;
50 }
51 
53  mFile->Write();
54  mFile->Close();
55  printf("StRccCounterMonitor::Finish - Closing %s\n",mFilename);
56  return kStOK;
57 }
58 
59 
61  cout << "StRccCounterMonitor Make() starting..."<<endl;
62  mEventCounter ++ ;
63 
64  TObjectSet *os = (TObjectSet*)GetDataSet("StTriggerData");
65  StTriggerData* trg;
66  if (os) {
67  trg = (StTriggerData*)os->GetObject();
68  if(trg){
69  //cout << "StRccCounterMonitor got StTriggerData"<<endl;
70  }else{
71  cout << "StRccCounterMonitor could not get StTriggerData from DataSet."<<endl;
72  return kStErr;
73  }
74  }else{
75  cout << "StRccCounterMonitor could not get StTriggerData DataSet."<<endl;
76  return kStErr;
77  }
78 
79  EVT=trg->eventNumber();
80  unsigned int tcu = TCU = trg->tcuCounter();
81  if(mDebug==1) {
82  static int first=0;
83  if(first==0){
84  cout << "RCCMon TCU ";
85  for(int i=0; i<NCRATE; i++){
86  cout << Form("%8s ",CRATE[i]);
87  }
88  cout << endl;
89  }
90  first=1;
91  cout << Form("RCCMon %10d ",tcu);
92  }
93  for(int i=0; i<NCRATE; i++){
94  unsigned int rcc = trg->rccCounter(i+1);
95  unsigned int diff = rcc-tcu;
96  //int diff = rcc-tcu;
97  if(rcc==0){
98  diff=0;
99  }else if(rcc < tcu) {
100  const long long one=1;
101  const long long m=one<<32;
102  long long r=rcc;
103  long long t=tcu;
104  diff=(unsigned int)(r+m-t);
105  //cout << "-- OVER!!!--";
106  }
107  DIFF[i]=diff;
108  if(mDebug>1) cout << Form("%3s=%10u tcu=%10u diff=%10u\n",CRATE[i],rcc,tcu,diff);
109  if(mDebug==1) cout << Form("%8u ",diff);
110  //if(mDebug==1 && (i==2 || i>=10) ) cout << Form("%8u ",diff);
111  mHist[i]->Fill(float(diff));
112  }
113  mTree->Fill();
114  if(mDebug==1) cout << endl;
115  return kStOK;
116 }
Definition: TCU.hh:18
Definition: Stypes.h:40
virtual TObject * GetObject() const
The depricated method (left here for the sake of the backward compatibility)
Definition: TObjectSet.h:56
Definition: Stypes.h:44