Hall-D Software  alpha
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
RFMacro_ROCTITimes.C
Go to the documentation of this file.
2 {
3  //Each tdc-tick of the TI-time corresponds to 4 ns, so max deviation from average allowed is 3.9
4  //3.9 instead of 0: is average of all other ROCs. If a ROC is out of time, it will throw off the average when analyzing the other ROCs
5  double locMaxDeviation = 3.9;
6 
7  gDirectory->cd("/"); //return to file base directory
8 
9  //Goto Beam Path
10  TDirectory *locDirectory = (TDirectory*)gDirectory->FindObjectAny("RF");
11  if(!locDirectory)
12  return 0;
13  locDirectory->cd();
14 
15  //Get RF DeltaT Histograms
16  gDirectory->cd("ROCTIs");
17 
18  TList* locListOfKeys = gDirectory->GetListOfKeys();
19  TKey* locPreviousKey = NULL;
20 
21  // loop over all keys in this directory
22  for(int loc_i = 0; loc_i < locListOfKeys->GetEntries(); ++loc_i)
23  {
24  TKey* locKey = (TKey*)locListOfKeys->At(loc_i);
25  if(locKey == NULL)
26  continue;
27  string locKeyName = locKey->GetName();
28 
29  //use only the first cycle number for each key
30  if(locPreviousKey != NULL)
31  {
32  string locPreviousKeyName = locPreviousKey->GetName();
33  if(locPreviousKeyName == locKeyName)
34  continue;
35  }
36  locPreviousKey = locKey;
37 
38  TH1I* locHist = (TH1I*)gDirectory->Get(locKeyName.c_str());
39  double locMean = locHist->GetMean();
40  if(fabs(locMean) < locMaxDeviation)
41  continue;
42 
43  //extract the roc # from the hist name
44  size_t locROCIndex = locKeyName.rfind("ROC") + 3;
45  string locROCNumString = locKeyName.substr(locROCIndex);
46  cout << "ROC " << locROCNumString << " TI-time disagrees with the other ROCs." << endl;
47 
48  string locCanvasName = locKeyName + string("_Canvas");
49  TCanvas* locCanvas = new TCanvas(locCanvasName.c_str(), locCanvasName.c_str(), 1200, 800);
50  locHist->Draw();
51  }
52 
53  return 1;
54 }
int RFMacro_ROCTITimes(void)
char string[256]
TDirectory * locDirectory
TH2D * locHist
TCanvas * locCanvas