//-------------------------------------------------------- // tscalevt_main.C // // Test of the ROC10/11 scalers which are read in the datastream // every synch event (typ. every 100 events). // // R. Michaels, Jan 2002 //-------------------------------------------------------- #include #include #include "THaScaler.h" #include "THaCodaFile.h" #include "THaEvData.h" #ifndef __CINT__ #include "TROOT.h" #include "TFile.h" #include "TH1.h" #include "TH2.h" #include "TProfile.h" #include "TNtuple.h" #include "TRandom.h" #endif #define DEBUG 0 #define SKIPEVENT 0 // How many scaler events to skip // (This reduces effect of clock granularity) #define MYROC 11 // Needed for the SKIPEVENT trick #define BCM_CUT1 3000 // cut on BCM (x1 gain) to require beam on. #define BCM_CUT3 10000 // cut on BCM (x3 gain) to require beam on. #define BCM_CUT10 30000 // cut on BCM (x10 gain) to require beam on. #define NBCM 6 // number of BCM signals using namespace std; int main(int argc, char* argv[]) { int i,iev,evnum,trig,iskip,status; Int_t clkp, clkm, lastclkp, lastclkm; Float_t sum,asy; TString filename = "run.dat"; char bank[100] = "EvLeft"; // Event stream, Left HRS cout << "Analyzing CODA file "<codaRead(); if (status != 0) { cout << "coda status nonzero. assume EOF"<getEvBuffer()); // Dirty trick to average over larger time intervals (depending on // SKIPEVENT) to reduce the fluctuations due to clock. if (evdata.GetRocLength(MYROC) > 16) iskip++; if (SKIPEVENT != 0 && iskip < SKIPEVENT) continue; iskip = 0; scaler->LoadData(evdata); // Not every trigger has new scaler data, so skip if not new. if ( !scaler->IsRenewed() ) continue; if (iev++ > evnum) goto quit; // Fill the ntuple here // Note, we must average the two helicities here to get non-helicity rates Double_t time = (scaler->GetPulser(1,"clock") + scaler->GetPulser(-1,"clock"))/1024; farray_ntup[0] = time; farray_ntup[1] = 0.5*(scaler->GetBcmRate(1,"bcm_u1") + scaler->GetBcmRate(-1,"bcm_u1")); farray_ntup[2] = 0.5*(scaler->GetBcmRate(1,"bcm_u3") + scaler->GetBcmRate(-1,"bcm_u3")); farray_ntup[3] = 0.5*(scaler->GetBcmRate(1,"bcm_u10") + scaler->GetBcmRate(-1,"bcm_u10")); farray_ntup[4] = 0.5*(scaler->GetBcmRate(1,"bcm_d1") + scaler->GetBcmRate(-1,"bcm_d1")); farray_ntup[5] = 0.5*(scaler->GetBcmRate(1,"bcm_d3") + scaler->GetBcmRate(-1,"bcm_d3")); farray_ntup[6] = 0.5*(scaler->GetBcmRate(1,"bcm_d10") + scaler->GetBcmRate(-1,"bcm_d10")); for (trig = 1; trig <= 5; trig++) { farray_ntup[6+trig] = 0.5*(scaler->GetTrigRate(1,trig) + scaler->GetTrigRate(-1,trig)); } clkp = scaler->GetNormData(1,"clock"); clkm = scaler->GetNormData(-1,"clock"); farray_ntup[12] = clkp - lastclkp; farray_ntup[13] = clkm - lastclkm; lastclkp = clkp; lastclkm = clkm; farray_ntup[14] = 0.5*(scaler->GetNormRate(1,"TS-accept") + scaler->GetNormRate(-1,"TS-accept")); string bcms[] = {"bcm_u1", "bcm_u3", "bcm_u10", "bcm_d1", "bcm_d3", "bcm_d10"}; for (int ibcm = 0; ibcm < 6; ibcm++ ) { sum = scaler->GetBcmRate(1,bcms[ibcm].c_str()) - bcmped[ibcm] + scaler->GetBcmRate(-1,bcms[ibcm].c_str()) - bcmped[ibcm]; asy = -999; if (sum != 0) { asy = (scaler->GetBcmRate(1,bcms[ibcm].c_str()) - scaler->GetBcmRate(-1,bcms[ibcm].c_str())) / sum; } farray_ntup[15+ibcm] = asy; } for (trig = 1; trig <= 5; trig++) { asy = -999; if (scaler->GetBcmRate(1,"bcm_u3") > BCM_CUT3 && scaler->GetBcmRate(-1,"bcm_u3") > BCM_CUT3) { sum = scaler->GetTrigRate(1,trig)/scaler->GetBcmRate(1,"bcm_u3") + scaler->GetTrigRate(-1,trig)/scaler->GetBcmRate(-1,"bcm_u3"); if (sum != 0) { asy = (scaler->GetTrigRate(1,trig)/scaler->GetBcmRate(1,"bcm_u3") - scaler->GetTrigRate(-1,trig)/scaler->GetBcmRate(-1,"bcm_u3")) / sum; } } farray_ntup[20+trig] = asy; } sum = scaler->GetPulser(1,"clock") + scaler->GetPulser(-1,"clock"); asy = -999; if (sum != 0) { asy = (scaler->GetPulser(1,"clock") - scaler->GetPulser(-1,"clock")) / sum; } farray_ntup[26] = asy; if (DEBUG) { cout << "event type "<Print(); if (farray_ntup[12] < 1000) cout << "Low clock"<GetNormRate(1,"clock"); cout << " clock(-) "<GetNormRate(-1,"clock")<0.005||farray_ntup[16]<-0.005) cout << "Big asy"<Fill(farray_ntup); } quit: hfile.Write(); hfile.Close(); exit(0); }