ATLAS Offline Software
Classes | Typedefs | Functions | Variables
dqutils Namespace Reference

Classes

class  CoolMdt
 
class  CoolRpc
 
class  CoolTgc
 
class  HanOutputFile
 
class  HistogramDataCOOL
 
class  MonitoringFile
 
class  StatusFlagCommentCOOL
 
class  StatusFlagCOOL
 
class  StatusFlagCOOLBase
 

Typedefs

typedef std::map< std::string, std::vector< int > > keycyclemap
 

Functions

void populateKeyMapping (TDirectory *, keycyclemap &)
 
std::string getInputDirectory (const std::string &outputDirName, TFile *input, bool has_multiple_runs, std::map< TFile *, std::string > *prefixes)
 
std::string getOutputDirectory (const std::string &inputDirName, TFile *input, bool has_multiple_runs, std::map< TFile *, std::string > *prefixes)
 
std::string getOutputDirectory (TKey *key, TFile *input, bool has_multiple_runs, std::map< TFile *, std::string > *prefixes)
 
void getImageBuffer ATLAS_NOT_THREAD_SAFE (TImage **img, TCanvas *myC, char **x, int *y)
 
void plotResolution (const TString &coordinate, const TString &versus)
 
void plotEfficiency ()
 
double error_func (float x, const Double_t *par)
 
double scaleFactorFitFcn (double *x, double *par)
 
std::vector< float > stableGaussianFit (TH1 *histo)
 
int updateHists (const std::string &inFileName, const std::string &inStem, const std::string &outFileName="", const std::string &outStem="")
 
bool makeDirectories (const std::string &dirName)
 
bool makeDir (const std::string &dirName)
 
void Copy (TFile *source, TFile *target, const std::string &inDir, const std::string &outDir, const std::string &inHist="", const std::string &outHist="")
 
void CopyHist (TFile *source, TFile *target, const std::string &inDir, const std::string &outDir, const std::string &inHist, const std::string &outHist)
 

Variables

std::vector< int > root_color_choices
 
std::atomic< int > padding = 0
 

Typedef Documentation

◆ keycyclemap

typedef std::map<std::string, std::vector<int> > dqutils::keycyclemap

Definition at line 51 of file MonitoringFile.h.

Function Documentation

◆ ATLAS_NOT_THREAD_SAFE()

void getImageBuffer dqutils::ATLAS_NOT_THREAD_SAFE ( TImage **  img,
TCanvas *  myC,
char **  x,
int *  y 
)

Definition at line 1130 of file HanOutputFile.cxx.

1130  {
1131  gVirtualPS->Open(myC->GetName(), 114);
1132  myC->Paint();
1133  auto pImgDump = dynamic_cast<TImageDump*>(gVirtualPS);
1134  if (pImgDump) {
1135  (*img) = pImgDump->GetImage();
1136  if (*img) {
1137  (*img)->GetImageBuffer(x, y, TImage::kPng);
1138  }
1139  }
1140  }

◆ Copy()

void dqutils::Copy ( TFile *  source,
TFile *  target,
const std::string &  inDir,
const std::string &  outDir,
const std::string &  inHist = "",
const std::string &  outHist = "" 
)

Definition at line 253 of file MonitoringFile_MoveVertexMonitoring.cxx.

254  {
255  padding += 3;
256 
257  if (!inHist.empty()) {
258  CopyHist(source, target, inDir, outDir, inHist, outHist);
259  } else {
260  TDirectory* sourceDir = source->GetDirectory(inDir.c_str());
261  TDirectory* targetDir = target->GetDirectory(outDir.c_str());
262 
263  TIter nextKey(sourceDir->GetListOfKeys());
264 
265  TKey* key;
266  while ((key = (TKey*) nextKey())) {
267  std::string keyName = key->GetName();
268  std::string className(key->GetClassName());
269 
270  if (className == "TDirectoryFile") {
271  std::string newInDir = inDir;
272  newInDir += '/';
273  newInDir += keyName;
274 
275  std::string newOutDir = outDir;
276  newOutDir += '/';
277  newOutDir += keyName;
278 
279  if (!targetDir->FindKey(keyName.c_str())) {
280  /*
281  std::cout << std::setw(padding) << " ";
282  std::cout << "creating Dir " << newOutDir << std::endl;
283  */
284  targetDir->mkdir(keyName.c_str());
285  }
286  /*
287  std::cout << std::setw(padding) << " ";
288  std::cout << "moving to " << newInDir << ", a " << className << std::endl;
289  */
290  Copy(source, target, newInDir, newOutDir);
291  } else {
292  CopyHist(source, target, inDir, outDir, keyName, keyName);
293  }
294  }
295  }
296 
297  padding -= 3;
298  }

◆ CopyHist()

void dqutils::CopyHist ( TFile *  source,
TFile *  target,
const std::string &  inDir,
const std::string &  outDir,
const std::string &  inHist,
const std::string &  outHist 
)

Definition at line 300 of file MonitoringFile_MoveVertexMonitoring.cxx.

301  {
302  TDirectory* sourceDir = source->GetDirectory(inDir.c_str());
303  TDirectory* targetDir = target->GetDirectory(outDir.c_str());
304 
305  targetDir->cd();
306  TKey* key = sourceDir->FindKey(inHist.c_str());
307  TObject* object = key->ReadObj();
308  bool permission = true;
309 
310  if (targetDir->FindKey(outHist.c_str())) permission = false;
311  if (permission) object->Write(outHist.c_str(), TObject::kOverwrite);
312  }

◆ error_func()

double dqutils::error_func ( float  x,
const Double_t *  par 
)

Definition at line 451 of file MonitoringFile_IDEnhancedPrimaryVertex.cxx.

451  {
452 //calculating the square of the propagated error on the fit values
453  return(TMath::Power(par[0], 2) + x * TMath::Power(par[1], 2) + TMath::Power(x * par[2], 2));
454  }

◆ getInputDirectory()

std::string dqutils::getInputDirectory ( const std::string &  outputDirName,
TFile *  input,
bool  has_multiple_runs,
std::map< TFile *, std::string > *  prefixes 
)

◆ getOutputDirectory() [1/2]

std::string dqutils::getOutputDirectory ( const std::string &  inputDirName,
TFile *  input,
bool  has_multiple_runs,
std::map< TFile *, std::string > *  prefixes 
)

◆ getOutputDirectory() [2/2]

std::string dqutils::getOutputDirectory ( TKey *  key,
TFile *  input,
bool  has_multiple_runs,
std::map< TFile *, std::string > *  prefixes 
)

◆ makeDir()

bool dqutils::makeDir ( const std::string &  dirName)

Definition at line 239 of file MonitoringFile_MoveVertexMonitoring.cxx.

239  {
240  padding += 3;
241  std::cout << std::setw(padding) << " ";
242 
243  if (!gDirectory->FindKey(dirName.c_str())) {
244  gDirectory->mkdir(dirName.c_str());
245 // std::cout << "makeDir=" << dirName << std::endl;
246  } else
247 // std::cout << "object " << dirName << " already exists in directory " << gDirectory->GetName() <<
248 // std::endl;
249  padding -= 3;
250  return gDirectory->cd(dirName.c_str());
251  }

◆ makeDirectories()

bool dqutils::makeDirectories ( const std::string &  dirName)

Definition at line 221 of file MonitoringFile_MoveVertexMonitoring.cxx.

221  {
222  bool success = true;
223 
224  if (!dirName.empty()) {
225  std::string::size_type firstSlash = dirName.find('/');
226  if (firstSlash == std::string::npos) {
227  success &= makeDir(dirName);
228  } else {
229  std::string subdir(dirName, 0, firstSlash);
230  if (!subdir.empty()) success &= makeDir(subdir);
231 
232  std::string newSubdir(dirName, firstSlash + 1, dirName.size() - firstSlash);
233  success &= makeDirectories(newSubdir);
234  }
235  }
236  return success;
237  }

◆ plotEfficiency()

void dqutils::plotEfficiency ( )

Definition at line 375 of file MonitoringFile_IDEnhancedPrimaryVertex.cxx.

375  {
376 // cout << "Creating and writing histos for efficiency" << endl;
377 
378  // get histos but return if any histo is not there in input
379  TH1F* h_Vrt_split_tag_ntrk = (TH1F*) gDirectory->Get("Vrt_split_tag_ntrk");
380 
381  if (h_Vrt_split_tag_ntrk == 0) return;
382 
383  TH1F* h_Vrt_split_probe_ntrk = (TH1F*) gDirectory->Get("Vrt_split_probe_ntrk");
384  if (h_Vrt_split_probe_ntrk == 0) return;
385 
386  TH1F* h_Vrt_split_matched_tag_ntrk = (TH1F*) gDirectory->Get("Vrt_split_matched_tag_ntrk");
387  if (h_Vrt_split_matched_tag_ntrk == 0) return;
388 
389  TH1F* h_Vrt_split_matched_probe_ntrk = (TH1F*) gDirectory->Get("Vrt_split_matched_probe_ntrk");
390  if (h_Vrt_split_matched_probe_ntrk == 0) return;
391 
392  TH1F* h_Vrt_split_dist_tag = (TH1F*) gDirectory->Get("Vrt_split_dist_tag");
393  if (h_Vrt_split_dist_tag == 0) return;
394 
395  TH1F* h_Vrt_split_dist_probe = (TH1F*) gDirectory->Get("Vrt_split_dist_probe");
396  if (h_Vrt_split_dist_probe == 0) return;
397 
398  // Use BayesDivide routing of TGraphAsymmErrors
399  TGraphAsymmErrors* g_Vrt_rec_eff_m1_split_vs_ntrk = new TGraphAsymmErrors();
400 
401  g_Vrt_rec_eff_m1_split_vs_ntrk->BayesDivide(h_Vrt_split_probe_ntrk, h_Vrt_split_tag_ntrk);
402  g_Vrt_rec_eff_m1_split_vs_ntrk->SetName("g_RecEff_M1");
403 
404  TGraphAsymmErrors* g_Vrt_sel_eff_m1_split_vs_ntrk = new TGraphAsymmErrors();
405  g_Vrt_sel_eff_m1_split_vs_ntrk->BayesDivide(h_Vrt_split_matched_probe_ntrk, h_Vrt_split_matched_tag_ntrk);
406  g_Vrt_sel_eff_m1_split_vs_ntrk->SetName("g_SelEff_M1");
407 
408  // formatting and writing out
409  g_Vrt_rec_eff_m1_split_vs_ntrk->GetHistogram()->GetXaxis()->SetTitle("Number of tracks");
410  g_Vrt_rec_eff_m1_split_vs_ntrk->GetHistogram()->GetYaxis()->SetTitle("Reconstruction efficiency");
411  g_Vrt_rec_eff_m1_split_vs_ntrk->SetMarkerStyle(20);
412  g_Vrt_rec_eff_m1_split_vs_ntrk->Write("", TObject::kOverwrite);
413  delete g_Vrt_rec_eff_m1_split_vs_ntrk;
414 
415  g_Vrt_sel_eff_m1_split_vs_ntrk->GetHistogram()->GetXaxis()->SetTitle("Number of tracks");
416  g_Vrt_sel_eff_m1_split_vs_ntrk->GetHistogram()->GetYaxis()->SetTitle("Selection Efficiency");
417  g_Vrt_sel_eff_m1_split_vs_ntrk->SetMarkerStyle(20);
418  g_Vrt_sel_eff_m1_split_vs_ntrk->Write("", TObject::kOverwrite);
419  delete g_Vrt_sel_eff_m1_split_vs_ntrk;
420 
421  return;
422  }

◆ plotResolution()

void dqutils::plotResolution ( const TString &  coordinate = "Z",
const TString &  versus = "Ntrk" 
)

Definition at line 107 of file MonitoringFile_IDEnhancedPrimaryVertex.cxx.

107  {
108 // cout << "Creating and writing histos for resolution " << coordinate << " versus " << versus << endl;
109 
110  TH2F* h_Vrt_pullVsSomething_split(0);
111  TH2F* h_Vrt_err_vs_Something(0);
112 // TH2F* h_Vrt_Tag_err_vs_Something(0);
113  TString xAxisLabel("");
114 
115  if (versus == "Ntrk") {
116  h_Vrt_pullVsSomething_split = (TH2F*) gDirectory->Get("Vrt_" + coordinate + "pullVsNtrkAverage_split");
117  h_Vrt_err_vs_Something = (TH2F*) gDirectory->Get("Vrt_" + coordinate + "err_vs_ntrk");
118 // h_Vrt_Tag_err_vs_Something = (TH2F*)gDirectory->Get("Vrt_Tag_"+coordinate+"err_vs_ntrk");
119  xAxisLabel = "Number of fitted tracks";
120  } else if (versus == "SumPt2") {
121  h_Vrt_pullVsSomething_split = (TH2F*) gDirectory->Get("Vrt_" + coordinate + "pullVsPt2Average_split");
122  h_Vrt_err_vs_Something = (TH2F*) gDirectory->Get("Vrt_" + coordinate + "err_vs_pt2");
123 // h_Vrt_Tag_err_vs_Something = (TH2F*)gDirectory->Get("Vrt_Tag_"+coordinate+"err_vs_pt2");
124  xAxisLabel = "#sqrt{#sum p_{T}^{2}} [GeV]";
125  } else return;
126 
127  //if (h_Vrt_pullVsSomething_split == 0) std::cout << "h_Vrt_pullVsSomething_split has zero pointer!" << std::endl;
128  //if (h_Vrt_err_vs_Something == 0) std::cout << "h_Vrt_err_vs_Something has zero pointer!" << std::endl;
129  if (h_Vrt_pullVsSomething_split == 0 or h_Vrt_err_vs_Something == 0) return;
130 
131  int n_bins = h_Vrt_pullVsSomething_split->GetNbinsX();
132  std::vector<float> rms_z;
133  std::vector<float> rms_z_er;
134  std::vector<float> sigma_z;
135  std::vector<float> sigma_z_er;
136  std::vector<float> bins_z_nt;
137  std::vector<float> bins_z_nt_er;
138 
139 // root starts counting the bins at 1, i.e. bin 1 holds NTrk = 0. or sqrt(sumpt2) = 0. - 0.25. GeV
140 // std::cout << "n bins: " << n_bins << "\tTotal entries: " << h_Vrt_pullVsSomething_split->GetEntries() << std::endl;
141 // TH1D * nTrksPerVertex = h_Vrt_pullVsSomething_split->ProjectionX("projectionNTrks_"+coordinate+"_"+versus);
142 
143 // TH1D * profileZFull = h_Vrt_pullVsSomething_split->ProjectionY("projectionPullsFull_"+coordinate+"_"+versus);
144 
145  Int_t startBin = 0;
146  TH1D* profileZ = 0;
147  const Int_t minEntriesForKFactorBin = 1000;
148  for (int bin_count = 1; bin_count < n_bins + 1; bin_count++) {
149  //Fixed binning
150 // TH1D *profileZ = h_Vrt_pullVsSomething_split->ProjectionY("projectionPulls", bin_count, bin_count,"e");
151 // Double_t binCenter = h_Vrt_pullVsSomething_split->GetXaxis()->GetBinCenter(bin_count);
152 // Double_t binWidth = h_Vrt_pullVsSomething_split->GetXaxis()->GetBinWidth(bin_count)/2.;
153 
154  //Variable binning
155  TH1D* profileZTmp = h_Vrt_pullVsSomething_split->ProjectionY("projectionPulls", bin_count, bin_count, "e");
156  //cout << "Bin: " << bin_count << ", Entries: " << profileZTmp->GetEntries() << endl;
157  if (profileZ == 0) {
158  startBin = bin_count;
159  profileZ = (TH1D*) profileZTmp->Clone("projectionPulls_Integrated");
160  //cout << "StartBin = " << startBin << endl;
161  } else {
162  profileZ->Add(profileZTmp);
163  }
164  delete profileZTmp;
165  profileZTmp = 0;
166  if ((profileZ->GetEntries() < minEntriesForKFactorBin) && (bin_count < n_bins)) //not enough entries, not last bin
167  continue;
168 
169  Double_t lowEdge = h_Vrt_pullVsSomething_split->GetXaxis()->GetBinLowEdge(startBin);
170  Double_t highEdge = h_Vrt_pullVsSomething_split->GetXaxis()->GetBinLowEdge(bin_count) +
171  h_Vrt_pullVsSomething_split->GetXaxis()->GetBinWidth(bin_count);
172  Double_t binCenter = (lowEdge + highEdge) / 2;
173  Double_t binWidth = (highEdge - lowEdge) / 2; //half of the bin width
174  //cout << "Bin done: " << binCenter << " +/- " << binWidth << ", Entries: " << profileZ->GetEntries() << endl;
175  // variable binning end
176 
177  bins_z_nt.push_back(binCenter);
178  bins_z_nt_er.push_back(binWidth); // dummy error of binwidth for now
179 
180  rms_z.push_back(profileZ->GetRMS());
181  rms_z_er.push_back(profileZ->GetRMSError());
182 
183  //making a gaussian fit if there is anough entries
184  if (profileZ->GetEntries() > 100.) {
185  std::vector<float> fit_res = stableGaussianFit(profileZ);
186  sigma_z.push_back(fit_res[0]);
187  sigma_z_er.push_back(fit_res[1]);
188  } else {
189  sigma_z.push_back(0.);
190  sigma_z_er.push_back(0.);
191  }//end of good number of bins selection
192 
193  delete profileZ; // must keep this to delete the projection from memory (next one has same name!)
194  profileZ = 0;
195  }//end of loop over all the ntrk bins
196 
197  TGraphErrors* krms_z_vs_ntrk = new TGraphErrors(
198  bins_z_nt.size(), &(bins_z_nt[0]), &(rms_z[0]), &(bins_z_nt_er[0]), &(rms_z_er[0]));
199  krms_z_vs_ntrk->GetYaxis()->SetTitle(coordinate + " scale factor from RMS");
200  krms_z_vs_ntrk->GetXaxis()->SetTitle(xAxisLabel);
201  krms_z_vs_ntrk->SetTitle("scaleFactor" + coordinate + "_RMS");
202  krms_z_vs_ntrk->SetName("scaleFactor" + coordinate + "_" + versus + "_RMS");
203 
204  TGraphErrors* kgs_z_vs_ntrk = new TGraphErrors(
205  bins_z_nt.size(), &(bins_z_nt[0]), &(sigma_z[0]), &(bins_z_nt_er[0]), &(sigma_z_er[0]));
206  kgs_z_vs_ntrk->GetYaxis()->SetTitle(coordinate + " scale factor from gauss fit");
207  kgs_z_vs_ntrk->GetXaxis()->SetTitle(xAxisLabel);
208  kgs_z_vs_ntrk->SetTitle("scaleFactor" + coordinate + "_Fit");
209  kgs_z_vs_ntrk->SetName("scaleFactor_" + coordinate + "_" + versus + "_Fit");
210 
211 // approximating the graph with 2nd order polynomial.
212  float maxFitRange(100.);
213  float minFitRange(2.);
214  if (versus == "SumPt2") {
215  minFitRange = 0.5;
216  maxFitRange = 20.;
217  }
218  TF1* kgs_z_ntrk_fit;
219  const Double_t* kgs_z_ntrk_fit_er;
220  int fitResKFactorMethod = 2; // set by hand for now
221  if (fitResKFactorMethod == 1) {
222  //Fit with a pol2
223  kgs_z_vs_ntrk->Fit("pol2", "Q", "", minFitRange, maxFitRange);
224  kgs_z_vs_ntrk->GetFunction("pol2")->SetLineColor(kRed);
225  kgs_z_ntrk_fit = kgs_z_vs_ntrk->GetFunction("pol2");
226  kgs_z_ntrk_fit_er = kgs_z_ntrk_fit->GetParErrors();
227  } else if (fitResKFactorMethod == 2) {
228  //Fit with a pol1
229  kgs_z_vs_ntrk->Fit("pol1", "Q", "", minFitRange, maxFitRange);
230  kgs_z_vs_ntrk->GetFunction("pol1")->SetLineColor(kRed);
231  kgs_z_ntrk_fit = kgs_z_vs_ntrk->GetFunction("pol1");
232  kgs_z_ntrk_fit_er = kgs_z_ntrk_fit->GetParErrors();
233  } else if (fitResKFactorMethod == 3) {
234  TF1* kgsFitFcn = new TF1("kgsFitFcn", scaleFactorFitFcn, minFitRange, maxFitRange, 3);
235  kgsFitFcn->SetParameter(0, minFitRange);
236  kgsFitFcn->SetParameter(1, 1.0);
237  kgsFitFcn->SetParameter(2, 1.0);
238  for (int ifit = 0; ifit < 1; ifit++) //initial estimation of best parameters
239  kgs_z_vs_ntrk->Fit(kgsFitFcn, "Q");
240  kgs_z_vs_ntrk->Fit(kgsFitFcn, "Q"); //perform actual fit
241  kgs_z_ntrk_fit = kgsFitFcn;
242  kgs_z_ntrk_fit_er = kgsFitFcn->GetParErrors();
243 /* cout << "ScaleFactor fit for " << coordinate << " vs " << versus << " (method " << fitResKFactorMethod << ")= "
244  << kgsFitFcn->GetParameter(0) << " +/- " << kgsFitFcn->GetParError(0) << " "
245  << kgsFitFcn->GetParameter(1) << " +/- " << kgsFitFcn->GetParError(1) << " "
246  << kgsFitFcn->GetParameter(2) << " +/- " << kgsFitFcn->GetParError(2) << endl; */
247  } else if (fitResKFactorMethod == 4) {
248  //constant fit
249  kgs_z_vs_ntrk->Fit("pol0", "Q", "", minFitRange, maxFitRange);
250  kgs_z_vs_ntrk->GetFunction("pol0")->SetLineColor(kRed);
251  kgs_z_ntrk_fit = kgs_z_vs_ntrk->GetFunction("pol0");
252  kgs_z_ntrk_fit_er = kgs_z_ntrk_fit->GetParErrors();
253 /* cout << "ScaleFactor fit for " << coordinate << " vs " << versus << " (method " << fitResKFactorMethod << ")= "
254  << kgs_z_ntrk_fit->GetParameter(0) << " +/- " << kgs_z_ntrk_fit->GetParError(0) << endl; */
255  }
256 
257 // plotting the fit error of the unconstrained primary vertex and correcting them
258  int nbins_z_err_ntrk = h_Vrt_err_vs_Something->GetNbinsX();
259 
260  std::vector<float> av_err_z;
261  std::vector<float> av_err_z_er;
262 // std::vector<float> av_err_tag_z;
263 // std::vector<float> av_err_tag_z_er;
264  std::vector<float> err_bins_z_nt;
265  std::vector<float> err_bins_z_nt_er;
266  std::vector<float> res_z;
267  std::vector<float> res_z_er;
268 // std::vector<float> res_tag_z;
269 // std::vector<float> res_tag_z_er;
270 
271  for (int bin_count = 1; bin_count <= nbins_z_err_ntrk; ++bin_count) {
272  err_bins_z_nt.push_back(h_Vrt_err_vs_Something->GetXaxis()->GetBinCenter(bin_count));
273  err_bins_z_nt_er.push_back(h_Vrt_err_vs_Something->GetXaxis()->GetBinWidth(bin_count) / 2.);
274 
275  TH1D* profileY = h_Vrt_err_vs_Something->ProjectionY("projectionErrors", bin_count, bin_count, "e");
276 // TH1D * profileYTag(0);
277 // if (h_Vrt_Tag_err_vs_Something)
278 // profileYTag = h_Vrt_Tag_err_vs_Something->ProjectionY("projectionErrorsTag",bin_count,bin_count,"e");
279 
280  float mean = profileY->GetMean();
281  float mean_error = profileY->GetMeanError();
282 // float meanTag(0);
283 // float mean_errorTag(0);
284 // if (profileYTag) {
285 // meanTag = profileYTag->GetMean();
286 // mean_errorTag = profileYTag->GetMeanError();
287 // }
288  delete profileY;
289 // delete profileYTag;
290 
291  av_err_z.push_back(mean);
292  av_err_z_er.push_back(mean_error);
293 // av_err_tag_z.push_back(meanTag);
294 // av_err_tag_z_er.push_back(mean_errorTag);
295 
296  //estimating the approximate k-factor and the error value
297  double pr_er = 0.0;
298  float val(0.);
299  if (fitResKFactorMethod == 1) {
300  pr_er = error_func(bin_count, kgs_z_ntrk_fit_er);
301  } else if (fitResKFactorMethod == 2) {
302  val = h_Vrt_err_vs_Something->GetXaxis()->GetBinCenter(bin_count);
303  pr_er = TMath::Power(kgs_z_ntrk_fit_er[1] * val, 2) + TMath::Power(kgs_z_ntrk_fit_er[0], 2);
304  pr_er = TMath::Sqrt(pr_er);
305 // cout << "val = " << val << ", pr_er = " << pr_er << ", p0er = " << kgs_z_ntrk_fit_er[0] << ", p1er = "<<
306 // kgs_z_ntrk_fit_er[1] << endl;
307  } else if (fitResKFactorMethod == 3) {
308  val = h_Vrt_err_vs_Something->GetXaxis()->GetBinCenter(bin_count);
309  //approximately the error on the plateau
310  pr_er = kgs_z_ntrk_fit_er[2];
311  } else if (fitResKFactorMethod == 4) {
312  pr_er = kgs_z_ntrk_fit_er[0];
313  }
314 
315  res_z.push_back(mean * kgs_z_ntrk_fit->Eval(h_Vrt_err_vs_Something->GetXaxis()->GetBinCenter(bin_count)));
316  res_z_er.push_back(TMath::Sqrt(TMath::Power(mean_error *
317  kgs_z_ntrk_fit->Eval(h_Vrt_err_vs_Something->GetXaxis()->GetBinCenter(
318  bin_count)),
319  2) + TMath::Power(pr_er * mean, 2)));
320 // res_tag_z.push_back(meanTag * kgs_z_ntrk_fit->Eval(h_Vrt_err_vs_Something->GetXaxis()->GetBinCenter(bin_count)));
321 // res_tag_z_er.push_back(TMath::Sqrt(TMath::Power(mean_errorTag *
322 // kgs_z_ntrk_fit->Eval(h_Vrt_err_vs_Something->GetXaxis()->GetBinCenter(bin_count)),2) + TMath::Power( pr_er * mean
323 // ,2)));
324  }
325  TGraphErrors* res_z_vs_ntrk =
326  new TGraphErrors(err_bins_z_nt.size(), &(err_bins_z_nt[0]), &(res_z[0]), &(err_bins_z_nt_er[0]), &(res_z_er[0]));
327  res_z_vs_ntrk->GetYaxis()->SetTitle(coordinate + " Vertex Resolution [mm]");
328  res_z_vs_ntrk->GetXaxis()->SetTitle(xAxisLabel);
329  res_z_vs_ntrk->SetTitle(coordinate + " Vertex Resolution");
330  res_z_vs_ntrk->SetName("resolution_" + coordinate + "_" + versus);
331 
332 // TGraphErrors * res_tag_z_vs_ntrk = new TGraphErrors(err_bins_z_nt.size(),
333 // &(err_bins_z_nt[0]),&(res_tag_z[0]),&(err_bins_z_nt_er[0]), &(res_tag_z_er[0]) );
334 // res_tag_z_vs_ntrk->GetYaxis()->SetTitle(coordinate+" Tagged Vertex Resolution [mm]");
335 // res_tag_z_vs_ntrk->GetXaxis()->SetTitle(xAxisLabel);
336 // res_tag_z_vs_ntrk->SetTitle(coordinate+" Tagged Vertex Resolution");
337 // res_tag_z_vs_ntrk->SetName("resolution_tag_"+coordinate+"_"+versus);
338 
339 // TGraphErrors * mean_err_z_vs_ntrk = new TGraphErrors(err_bins_z_nt.size(),
340 // &(err_bins_z_nt[0]),&(av_err_z[0]),&(err_bins_z_nt_er[0]), &(av_err_z_er[0]) );
341 // mean_err_z_vs_ntrk->GetYaxis()->SetTitle(coordinate+" mean vertex error [mm]");
342 // mean_err_z_vs_ntrk->GetXaxis()->SetTitle(xAxisLabel);
343 // mean_err_z_vs_ntrk->SetTitle(coordinate+" Mean Vertex Error");
344 // mean_err_z_vs_ntrk->SetName("resolution_"+coordinate+"_"+versus+"_Uncorrected"); //not corrected with k-factor
345 
347  // Writing out
349  if (versus == "Ntrk") res_z_vs_ntrk->GetXaxis()->SetRangeUser(0., 100.);
350  else res_z_vs_ntrk->GetXaxis()->SetRangeUser(0., 20.);
351  res_z_vs_ntrk->GetYaxis()->SetRangeUser(0.0025, 1.);
352  res_z_vs_ntrk->Write("", TObject::kOverwrite);
353  delete res_z_vs_ntrk;
354 
355  if (versus == "Ntrk") krms_z_vs_ntrk->GetXaxis()->SetRangeUser(0., 100.);
356  else krms_z_vs_ntrk->GetXaxis()->SetRangeUser(0., 20.);
357  krms_z_vs_ntrk->GetYaxis()->SetRangeUser(0.5, 1.3);
358  krms_z_vs_ntrk->Write("", TObject::kOverwrite);
359  delete krms_z_vs_ntrk;
360 
361  if (versus == "Ntrk") kgs_z_vs_ntrk->GetXaxis()->SetRangeUser(0., 100.);
362  else kgs_z_vs_ntrk->GetXaxis()->SetRangeUser(0., 20.);
363  kgs_z_vs_ntrk->GetYaxis()->SetRangeUser(0.5, 1.3);
364  kgs_z_vs_ntrk->Write("", TObject::kOverwrite);
365  delete kgs_z_vs_ntrk;
366 
367 // nTrksPerVertex->GetYaxis()->SetTitle("Entries");
368 // nTrksPerVertex->Draw();
369 // nTrksPerVertex->Write("", TObject::kOverwrite);
370 
371  return;
372  }

◆ populateKeyMapping()

void dqutils::populateKeyMapping ( TDirectory *  ,
keycyclemap  
)

◆ scaleFactorFitFcn()

double dqutils::scaleFactorFitFcn ( double *  x,
double *  par 
)

Definition at line 456 of file MonitoringFile_IDEnhancedPrimaryVertex.cxx.

456  {
457  // Truncated gaus-smeared step function
458  // par 0: mean of turn-on (and truncation point)
459  // par 1: slope of turn-on
460  // par 2: plateau
461  return (x[0] >= par[0]) * TMath::Erf(par[1] * x[0] - par[0]) * par[2];
462  }

◆ stableGaussianFit()

std::vector< float > dqutils::stableGaussianFit ( TH1 *  histo)

Definition at line 424 of file MonitoringFile_IDEnhancedPrimaryVertex.cxx.

424  {
425  std::vector<float> results;
426  if (histo) {
427  double sigmas = 2.;
428 
429  histo->Fit("gaus", "Q0", "", -2, 2);
430  TF1* func = histo->GetFunction("gaus");
431  double actualSigma = func->GetParameter(2);
432  double actualSigmaErr = func->GetParError(2);
433 
434  for (int u = 0; u < 10; u++) {
435  histo->Fit("gaus", "Q0", "", -sigmas * actualSigma, sigmas * actualSigma);
436  func = histo->GetFunction("gaus");
437  actualSigma = func->GetParameter(2);
438  actualSigmaErr = func->GetParError(2);
439  }//end of the fitting loop
440 
441  results.push_back(actualSigma);
442  results.push_back(actualSigmaErr);
443  } else {
444  results.push_back(0.);
445  results.push_back(0.);
446  }//end of protection against an empty histogram
447 
448  return results;
449  }//end of stableGaussian Fit function

◆ updateHists()

int dqutils::updateHists ( const std::string &  inFileName,
const std::string &  inStem,
const std::string &  outFileName = "",
const std::string &  outStem = "" 
)

Definition at line 149 of file MonitoringFile_MoveVertexMonitoring.cxx.

150  {
151  std::string outFileName = fileName;
152  std::string outStem = stem;
153  //open original file
154  TFile* source = TFile::Open(inFileName.c_str());
155  if (!source) {
156  //std::cout << "Couldn't open input file, " << inFileName << std::endl;
157  return 1;
158  }//else std::cout << "opening input file, " << inFileName << std::endl;
159 
160  //find out whether inStem is a histogram or a directory
161  bool isDir = true;
162  std::string path = inStem;
163  std::string hist;
164 
165  if (inStem[inStem.size() - 1] != '/') {
166  std::string::size_type lastSlash = inStem.find_last_of('/');
167  hist = inStem.substr(lastSlash + 1, inStem.size() - lastSlash - 1);
168  path = inStem.substr(0, lastSlash + 1);
169  isDir = (source->FindObjectAny(hist.c_str()))->InheritsFrom("TDirectory");
170  if (isDir) {
171  path = inStem;
172  hist.clear();
173  }
174  }
175 
176  if (path[path.size() - 1] == '/') path.resize(path.size() - 1);
177  if (!source->GetDirectory(path.c_str())) {
178  //std::cout << "path " << path << " directory doesn't exist in input file" << std::endl;
179  return 1;
180  }
181 
182  //open target file
183  std::cout.fill(' ');
184  if (outFileName.empty()) {
185  outFileName = std::string(inFileName, 0, inFileName.find(".root"));
186  outFileName += "_trimmed.root";
187  }
188 
189  TFile* target = TFile::Open(outFileName.c_str(), "update");
190  if (!target) {
191  //std::cout << "coundn't open output file " << outFileName << std::endl;
192  return 1;
193  }//else std::cout << "opening output file " << outFileName << std::endl;
194 
195  if (outStem.empty()) outStem = inStem;
196  std::string targetPath = outStem;
197  std::string targetHist;
198  if (!isDir) {
199  std::string::size_type lastSlash = outStem.find_last_of('/');
200  targetPath = outStem.substr(0, lastSlash + 1);
201  targetHist = outStem.substr(lastSlash + 1, outStem.size() - lastSlash - 1);
202  }
203 
204  if (targetPath[targetPath.size() - 1] == '/') targetPath.resize(targetPath.size() - 1);
205 
206  target->cd();
207  if (!makeDirectories(targetPath)) {
208  //std::cout << "couldn't create outStem directories in output" << std::endl;
209  return 1;
210  }
211  //copy relevant objects
212  if (!target->IsWritable()) return 1;
213 
214  Copy(source, target, path, targetPath, hist, targetHist);
215 
216  delete target;
217  delete source;
218  return 0;
219  }

Variable Documentation

◆ padding

std::atomic<int> dqutils::padding = 0

Definition at line 20 of file MonitoringFile_MoveVertexMonitoring.cxx.

◆ root_color_choices

std::vector<int> dqutils::root_color_choices
Initial value:
= {
kBlue, kRed, kGray, kOrange, kViolet, kGreen + 1
}

Definition at line 86 of file HanOutputFile.cxx.

verify_menu_config.results
results
Definition: verify_menu_config.py:67
mean
void mean(std::vector< double > &bins, std::vector< double > &values, const std::vector< std::string > &files, const std::string &histname, const std::string &tplotname, const std::string &label="")
Definition: dependence.cxx:254
athena.path
path
python interpreter configuration --------------------------------------—
Definition: athena.py:128
plotmaker.hist
hist
Definition: plotmaker.py:148
dqutils::Copy
void Copy(TFile *source, TFile *target, const std::string &inDir, const std::string &outDir, const std::string &inHist="", const std::string &outHist="")
Definition: MonitoringFile_MoveVertexMonitoring.cxx:253
NSWL1::coordinate
float coordinate(const Vertex &v)
Definition: GeoUtils.h:56
python.TrigEgammaMonitorHelper.TH2F
def TH2F(name, title, nxbins, bins_par2, bins_par3, bins_par4, bins_par5=None, bins_par6=None, path='', **kwargs)
Definition: TrigEgammaMonitorHelper.py:45
x
#define x
dqutils::makeDirectories
bool makeDirectories(const std::string &dirName)
Definition: MonitoringFile_MoveVertexMonitoring.cxx:221
Trk::u
@ u
Enums for curvilinear frames.
Definition: ParamDefs.h:77
dqutils::padding
std::atomic< int > padding
Definition: MonitoringFile_MoveVertexMonitoring.cxx:20
binWidth
void binWidth(TH1 *h)
Definition: listroot.cxx:80
MakeTH3DFromTH2Ds.outHist
dictionary outHist
Definition: MakeTH3DFromTH2Ds.py:104
JetTagCalibConfig.className
string className
Definition: JetTagCalibConfig.py:36
DumpGeoConfig.outFileName
string outFileName
Definition: DumpGeoConfig.py:252
FortranAlgorithmOptions.fileName
fileName
Definition: FortranAlgorithmOptions.py:13
ParseInputs.gDirectory
gDirectory
Definition: Final2012/ParseInputs.py:133
dqutils::scaleFactorFitFcn
double scaleFactorFitFcn(double *x, double *par)
Definition: MonitoringFile_IDEnhancedPrimaryVertex.cxx:456
IDTPMcnv.inFileName
inFileName
Definition: IDTPMcnv.py:17
plotmaker.keyName
keyName
Definition: plotmaker.py:145
dqutils::CopyHist
void CopyHist(TFile *source, TFile *target, const std::string &inDir, const std::string &outDir, const std::string &inHist, const std::string &outHist)
Definition: MonitoringFile_MoveVertexMonitoring.cxx:300
createCoolChannelIdFile.par
par
Definition: createCoolChannelIdFile.py:29
runegammaMonitoring.isDir
isDir
Definition: runegammaMonitoring.py:37
dqutils::stableGaussianFit
std::vector< float > stableGaussianFit(TH1 *histo)
Definition: MonitoringFile_IDEnhancedPrimaryVertex.cxx:424
y
#define y
copySelective.target
string target
Definition: copySelective.py:37
Pythia8_RapidityOrderMPI.val
val
Definition: Pythia8_RapidityOrderMPI.py:14
copySelective.source
string source
Definition: copySelective.py:32
python.TrigEgammaMonitorHelper.TH1F
def TH1F(name, title, nxbins, bins_par2, bins_par3=None, path='', **kwargs)
Definition: TrigEgammaMonitorHelper.py:24
dqutils::makeDir
bool makeDir(const std::string &dirName)
Definition: MonitoringFile_MoveVertexMonitoring.cxx:239
python.LumiCalcRecover.subdir
subdir
Definition: LumiCalcRecover.py:25
plotBeamSpotCompare.histo
histo
Definition: plotBeamSpotCompare.py:415
dqutils::error_func
double error_func(float x, const Double_t *par)
Definition: MonitoringFile_IDEnhancedPrimaryVertex.cxx:451
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37