CMS 3D CMS Logo

List of all members | Classes | Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes
PlotAlignmentValidation Class Reference

Class PlotAlignmentValidation Class used as the last step for Offline Track Validation tool. The main goal of this class is creating the plots regarding DMRs and Surface Deformations for modules and substructures. More...

#include <PlotAlignmentValidation.h>

Classes

struct  DMRPlotInfo
 

Public Member Functions

THStack * addHists (const TString &selection, const TString &residType="xPrime", TLegend **myLegend=nullptr, bool printModuleIds=false, bool validforphase0=false)
 
void legendOptions (TString options)
 
void loadFileList (const char *inputFile, std::string fileName="", int lineColor=2, int lineStyle=1)
 
int maxNumberOfLayers (int subdetector)
 
int numberOfLayers (int phase, int subdetector)
 
 PlotAlignmentValidation (bool bigtext=false)
 
 PlotAlignmentValidation (const char *inputFile, std::string fileName="", int lineColor=1, int lineStyle=1, bool bigtext=false)
 
void plotChi2 (const char *inputFile)
 
void plotDMR (const std::string &plotVar="medianX", Int_t minHits=50, const std::string &options="plain", const std::string &filterName="", Float_t maxBadLumiPixel=0.5, Float_t maxBadLumiStrip=7.0)
 
void plotHitMaps ()
 
void plotOutlierModules (const char *outputFileName="OutlierModules.ps", std::string plotVariable="chi2PerDofX", float chi2_cut=10, unsigned int minHits=50)
 
void plotSubDetResiduals (bool plotNormHisto=false, unsigned int subDetId=7)
 
void plotSurfaceShapes (const std::string &options="layers", const std::string &variable="")
 
void residual_by_moduleID (unsigned int moduleid)
 
void setOutputDir (std::string dir)
 
void setTreeBaseDir (std::string dir="TrackerOfflineValidation")
 
float twotailedStudentTTestEqualMean (float t, float v)
 
void useFitForDMRplots (bool usefit=false)
 
 ~PlotAlignmentValidation ()
 

Private Member Functions

std::vector< TH1 * > findmodule (TFile *f, unsigned int moduleid)
 
TObject * findObjectFromCanvas (TCanvas *canv, const char *className, Int_t n=1)
 
TF1 * fitGauss (TH1 *hist, int color)
 
std::string getSelectionForDMRPlot (int minHits, int subDetId, int direction=0, int layer=0)
 
TList * getTreeList ()
 
std::string getVariableForDMRPlot (const std::string &histoname, const std::string &variable, int nbins, double min, double max)
 
void modifySSHistAndLegend (THStack *hs, TLegend *legend)
 
void openSummaryFile ()
 
void plotDMRHistogram (DMRPlotInfo &plotinfo, int direction=0, int layer=0, std::string subdet="")
 
void plotSS (const std::string &options="layers", const std::string &variable="")
 
double resampleTestOfEqualMeans (TH1F *h1, TH1F *h2, int numSamples)
 
double resampleTestOfEqualRMS (TH1F *h1, TH1F *h2, int numSamples)
 
void scaleXaxis (TH1 *hist, Int_t scale)
 
void setCanvasStyle (TCanvas &canv)
 
void setDMRHistStyleAndLegend (TH1F *h, DMRPlotInfo &plotinfo, int direction=0, int layer=0)
 
void setHistStyle (TH1 &hist, const char *titleX, const char *titleY, int color)
 
void setLegendStyle (TLegend &leg)
 
void setNiceStyle ()
 
void setTitleStyle (TNamed &h, const char *titleX, const char *titleY, int subDetId, bool isSurfaceDeformation=false, TString secondline="")
 
void storeHistogramInRootfile (TH1 *hist)
 

Private Attributes

bool bigtext_
 
int fileCounter
 
std::string fileNames [10]
 
bool moreThanOneSource
 
bool openedsummaryfile = false
 
std::string outputDir
 
TString outputFile
 
TFile * rootsummaryfile
 
bool showMean_
 
bool showMeanError_
 
bool showModules_
 
bool showRMS_
 
bool showRMSError_
 
bool showUnderOverFlow_
 
TList * sourcelist
 
std::vector< TkOfflineVariables * > sourceList
 
std::ofstream summaryfile
 
std::string treeBaseDir
 
bool twolines_
 
bool useFit_
 
std::vector< double > vAlignmentUncertainty
 
std::vector< double > vdeltamean
 
std::vector< double > vmean
 
std::vector< double > vmeanerror
 
std::vector< double > vPValueEqualSplitMeans
 
std::vector< double > vPValueMeanEqualIdeal
 
std::vector< double > vPValueRMSEqualIdeal
 
std::vector< double > vrms
 

Static Private Attributes

static const TString summaryfilename = "OfflineValidationSummary"
 

Detailed Description

Class PlotAlignmentValidation Class used as the last step for Offline Track Validation tool. The main goal of this class is creating the plots regarding DMRs and Surface Deformations for modules and substructures.

Definition at line 105 of file PlotAlignmentValidation.h.

Constructor & Destructor Documentation

◆ PlotAlignmentValidation() [1/2]

PlotAlignmentValidation::PlotAlignmentValidation ( bool  bigtext = false)

Definition at line 14 of file PlotAlignmentValidation.cc.

References TkAlStyle::legendoptions, legendOptions(), moreThanOneSource, setOutputDir(), setTreeBaseDir(), sourcelist, and useFit_.

14  : bigtext_(bigtext) {
15  setOutputDir(".");
17  sourcelist = nullptr;
18 
19  moreThanOneSource = false;
20  useFit_ = false;
21 
22  // Force ROOT to use scientific notation even with smaller datasets
23  TGaxis::SetMaxDigits(4);
24  // (This sets a static variable: correct in .eps images but must be set
25  // again manually when viewing the .root files)
26 
27  // Make ROOT calculate histogram statistics using all data,
28  // regardless of displayed range
29  TH1::StatOverflows(kTRUE);
30 
31  //show all information in the legend by default
33 }
void legendOptions(TString options)
static TString legendoptions
Definition: TkAlStyle.h:102
void setOutputDir(std::string dir)
void setTreeBaseDir(std::string dir="TrackerOfflineValidation")

◆ PlotAlignmentValidation() [2/2]

PlotAlignmentValidation::PlotAlignmentValidation ( const char *  inputFile,
std::string  fileName = "",
int  lineColor = 1,
int  lineStyle = 1,
bool  bigtext = false 
)

◆ ~PlotAlignmentValidation()

PlotAlignmentValidation::~PlotAlignmentValidation ( )

Definition at line 49 of file PlotAlignmentValidation.cc.

References ALPAKA_ACCELERATOR_NAMESPACE::vertexFinder::it, sourcelist, and sourceList.

49  {
50  for (std::vector<TkOfflineVariables*>::iterator it = sourceList.begin(); it != sourceList.end(); ++it) {
51  delete (*it);
52  }
53 
54  delete sourcelist;
55 }
std::vector< TkOfflineVariables * > sourceList

Member Function Documentation

◆ addHists()

THStack * PlotAlignmentValidation::addHists ( const TString &  selection,
const TString &  residType = "xPrime",
TLegend **  myLegend = nullptr,
bool  printModuleIds = false,
bool  validforphase0 = false 
)

add hists fulfilling 'selection' on TTree; residType: xPrime,yPrime,xPrimeNorm,yPrimeNorm,x,y,xNorm; if (printModuleIds): cout DetIds

Definition at line 1354 of file PlotAlignmentValidation.cc.

References nano_mu_local_reco_cff::bool, gather_cfg::cout, TkOffTreeVariables::entries, f, h, TkOffTreeVariables::histNameLocalX, TkOffTreeVariables::histNameLocalY, TkOffTreeVariables::histNameNormLocalX, TkOffTreeVariables::histNameNormX, TkOffTreeVariables::histNameNormY, TkOffTreeVariables::histNameX, TkOffTreeVariables::histNameY, mps_fire::i, testProducerWithPsetDescEmpty_cfi::i2, TkOffTreeVariables::moduleId, mergeVDriftHistosByStation::name, TkOffTreeVariables::profileNameResXvsX, TkOffTreeVariables::profileNameResXvsY, TkOffTreeVariables::profileNameResYvsX, TkOffTreeVariables::profileNameResYvsY, alignCSCRings::s, corrVsCorr::selection, and sourceList.

Referenced by plotSS().

1355  {
1356  enum ResidType {
1357  xPrimeRes,
1358  yPrimeRes,
1359  xPrimeNormRes,
1360  yPrimeNormRes,
1361  xRes,
1362  yRes,
1363  xNormRes, /*yResNorm*/
1364  ResXvsXProfile,
1365  ResXvsYProfile,
1366  ResYvsXProfile,
1367  ResYvsYProfile
1368  };
1369  ResidType rType = xPrimeRes;
1370  if (residType == "xPrime")
1371  rType = xPrimeRes;
1372  else if (residType == "yPrime")
1373  rType = yPrimeRes;
1374  else if (residType == "xPrimeNorm")
1375  rType = xPrimeNormRes;
1376  else if (residType == "yPrimeNorm")
1377  rType = yPrimeNormRes;
1378  else if (residType == "x")
1379  rType = xRes;
1380  else if (residType == "y")
1381  rType = yRes;
1382  else if (residType == "xNorm")
1383  rType = xNormRes;
1384  // else if (residType == "yNorm") rType = yResNorm;
1385  else if (residType == "ResXvsXProfile")
1386  rType = ResXvsXProfile;
1387  else if (residType == "ResYvsXProfile")
1388  rType = ResYvsXProfile;
1389  else if (residType == "ResXvsYProfile")
1390  rType = ResXvsYProfile;
1391  else if (residType == "ResYvsYProfile")
1392  rType = ResYvsYProfile;
1393  else {
1394  std::cout << "PlotAlignmentValidation::addHists: Unknown residual type " << residType << std::endl;
1395  return nullptr;
1396  }
1397 
1398  std::cout << "PlotAlignmentValidation::addHists: using selection " << selection << std::endl;
1399  THStack* retHistoStack = new THStack("hstack", "");
1400  if (myLegend != nullptr)
1401  if (*myLegend == nullptr) {
1402  *myLegend = new TLegend(0.17, 0.80, 0.85, 0.88);
1403  }
1404 
1405  for (std::vector<TkOfflineVariables*>::iterator itSourceFile = sourceList.begin(); itSourceFile != sourceList.end();
1406  ++itSourceFile) {
1407  std::vector<TString> histnames;
1408 
1409  TFile* f = (*itSourceFile)->getFile();
1410  TTree* tree = (*itSourceFile)->getTree();
1411  int myLineColor = (*itSourceFile)->getLineColor();
1412  int myLineStyle = (*itSourceFile)->getLineStyle();
1413  TString myLegendName = (*itSourceFile)->getName();
1414  TH1* h = nullptr; // becomes result
1415  UInt_t nEmpty = 0; // selected, but empty hists
1416  Long64_t nentries = tree->GetEntriesFast();
1417  if (!f || !tree) {
1418  std::cout << "PlotAlignmentValidation::addHists: no tree or no file" << std::endl;
1419  return nullptr;
1420  }
1421 
1422  bool histnamesfilled = false;
1423  int phase = (bool)(f->Get("TrackerOfflineValidation/Pixel/P1PXBBarrel_1"));
1424  if (residType.Contains("Res") && residType.Contains("Profile")) {
1425  TString basename = TString(residType)
1426  .ReplaceAll("Res", "p_res")
1427  .ReplaceAll("vs", "")
1428  .ReplaceAll("Profile", "_"); //gives e.g.: p_resXX_
1429  if (selection == "subDetId==1") {
1430  if (phase == 1)
1431  histnames.push_back(TString(basename) += "P1PXBBarrel_1");
1432  else
1433  histnames.push_back(TString(basename) += "TPBBarrel_1");
1434  histnamesfilled = true;
1435  } else if (selection == "subDetId==2") {
1436  if (phase == 1) {
1437  histnames.push_back(TString(basename) += "P1PXECEndcap_2");
1438  histnames.push_back(TString(basename) += "P1PXECEndcap_3");
1439  } else {
1440  histnames.push_back(TString(basename) += "TPEEndcap_2");
1441  histnames.push_back(TString(basename) += "TPEEndcap_3");
1442  }
1443  histnamesfilled = true;
1444  } else if (selection == "subDetId==3") {
1445  histnames.push_back(TString(basename) += "TIBBarrel_1");
1446  histnamesfilled = true;
1447  } else if (selection == "subDetId==4") {
1448  histnames.push_back(TString(basename) += "TIDEndcap_2");
1449  histnames.push_back(TString(basename) += "TIDEndcap_3");
1450  histnamesfilled = true;
1451  } else if (selection == "subDetId==5") {
1452  histnames.push_back(TString(basename) += "TOBBarrel_4");
1453  histnamesfilled = true;
1454  } else if (selection == "subDetId==6") { //whole TEC - doesn't happen by default but easy enough to account for
1455  histnames.push_back(TString(basename) += "TECEndcap_5");
1456  histnames.push_back(TString(basename) += "TECEndcap_6");
1457  histnamesfilled = true;
1458  } else if (selection == "subDetId==6 && ring <= 4") {
1459  //There are multiple with the same name and all are needed, so give the full path. For these TFile::Get is used later instead of FindKeyAny.
1460  for (int iEndcap = 5; iEndcap <= 6; iEndcap++)
1461  for (int iDisk = 1; iDisk <= 9; iDisk++)
1462  for (int iSide = 1; iSide <= 2; iSide++)
1463  for (int iPetal = 1; iPetal <= 8; iPetal++)
1464  for (int iRing = 1; iRing <= 4 - (iDisk >= 4) - (iDisk >= 7) - (iDisk >= 9); iRing++)
1465  //in the higher disks, the inner rings go away. But the numbering in the file structure removes the higher numbers
1466  // so the numbers there do not correspond to the actual ring numbers
1467  {
1468  std::stringstream s;
1469  s << "TrackerOfflineValidation/Strip/TECEndcap_" << iEndcap << "/TECDisk_" << iDisk << "/TECSide_"
1470  << iSide << "/TECPetal_" << iPetal << "/" << basename << "TECRing_" << iRing;
1471  histnames.push_back(TString(s.str()));
1472  }
1473  histnamesfilled = true;
1474  } else if (selection == "subDetId==6 && ring > 4") {
1475  //There are multiple with the same name and all are needed, so give the full path. For these TFile::Get is used later instead of FindKeyAny.
1476  for (int iEndcap = 5; iEndcap <= 6; iEndcap++)
1477  for (int iDisk = 1; iDisk <= 9; iDisk++)
1478  for (int iSide = 1; iSide <= 2; iSide++)
1479  for (int iPetal = 1; iPetal <= 8; iPetal++)
1480  for (int iRing = 5 - (iDisk >= 4) - (iDisk >= 7) - (iDisk >= 9);
1481  iRing <= 7 - (iDisk >= 4) - (iDisk >= 7) - (iDisk >= 9);
1482  iRing++)
1483  //in the higher disks, the inner rings go away. But the numbering in the file structure removes the higher numbers
1484  // so the numbers there do not correspond to the actual ring numbers
1485  {
1486  std::stringstream s;
1487  s << "TrackerOfflineValidation/Strip/TECEndcap_" << iEndcap << "/TECDisk_" << iDisk << "/TECSide_"
1488  << iSide << "/TECPetal_" << iPetal << "/" << basename << "TECRing_" << iRing;
1489  histnames.push_back(TString(s.str()));
1490  }
1491  histnamesfilled = true;
1492  }
1493  }
1494 
1495  Long64_t nSel = 0;
1496  if (histnamesfilled && !histnames.empty()) {
1497  nSel = (Long64_t)histnames.size();
1498  }
1499  if (!histnamesfilled) {
1500  // first loop on tree to find out which entries (i.e. modules) fulfill the selection
1501  // 'Entry$' gives the entry number in the tree
1502  nSel = tree->Draw("Entry$", selection, "goff");
1503  if (nSel == -1)
1504  return nullptr; // error in selection
1505  if (nSel == 0) {
1506  std::cout << "PlotAlignmentValidation::addHists: no selected module." << std::endl;
1507  return nullptr;
1508  }
1509  // copy entry numbers that fulfil the selection
1510  const std::vector<double> selected(tree->GetV1(), tree->GetV1() + nSel);
1511 
1512  std::vector<double>::const_iterator iterEnt = selected.begin();
1513 
1514  // second loop on tree:
1515  // for each selected entry get the hist from the file and merge
1516  TkOffTreeVariables* treeMem = nullptr; // ROOT will initialise
1517  tree->SetBranchAddress("TkOffTreeVariables", &treeMem);
1518  for (Long64_t i = 0; i < nentries; i++) {
1519  if (i < *iterEnt - 0.1 // smaller index (with tolerance): skip
1520  || iterEnt == selected.end()) { // at the end: skip
1521  continue;
1522  } else if (TMath::Abs(i - *iterEnt) < 0.11) {
1523  ++iterEnt; // take this entry!
1524  } else
1525  std::cout << "Must not happen: " << i << " " << *iterEnt << std::endl;
1526 
1527  tree->GetEntry(i);
1528  if (printModuleIds) {
1529  std::cout << treeMem->moduleId << ": " << treeMem->entries << " entries" << std::endl;
1530  }
1531  if (treeMem->entries <= 0) { // little speed up: skip empty hists
1532  ++nEmpty;
1533  continue;
1534  }
1535  TString hName;
1536  switch (rType) {
1537  case xPrimeRes:
1538  hName = treeMem->histNameX.c_str();
1539  break;
1540  case yPrimeRes:
1541  hName = treeMem->histNameY.c_str();
1542  break;
1543  case xPrimeNormRes:
1544  hName = treeMem->histNameNormX.c_str();
1545  break;
1546  case yPrimeNormRes:
1547  hName = treeMem->histNameNormY.c_str();
1548  break;
1549  case xRes:
1550  hName = treeMem->histNameLocalX.c_str();
1551  break;
1552  case yRes:
1553  hName = treeMem->histNameLocalY.c_str();
1554  break;
1555  case xNormRes:
1556  hName = treeMem->histNameNormLocalX.c_str();
1557  break;
1558  /*case yResNorm: hName = treeMem->histNameNormLocalY.c_str(); break;*/
1559  case ResXvsXProfile:
1560  hName = treeMem->profileNameResXvsX.c_str();
1561  break;
1562  case ResXvsYProfile:
1563  hName = treeMem->profileNameResXvsY.c_str();
1564  break;
1565  case ResYvsXProfile:
1566  hName = treeMem->profileNameResYvsX.c_str();
1567  break;
1568  case ResYvsYProfile:
1569  hName = treeMem->profileNameResYvsY.c_str();
1570  break;
1571  }
1572  histnames.push_back(hName);
1573  }
1574  }
1575 
1576  for (std::vector<TString>::iterator ithistname = histnames.begin(); ithistname != histnames.end(); ++ithistname) {
1577  if (phase == 0 && !validforphase0)
1578  break;
1579  TH1* newHist;
1580  if (ithistname->Contains("/")) {
1581  newHist = (TH1*)f->Get(*ithistname);
1582  } else {
1583  TKey* histKey = f->FindKeyAny(*ithistname);
1584  newHist = (histKey ? static_cast<TH1*>(histKey->ReadObj()) : nullptr);
1585  }
1586  if (!newHist) {
1587  std::cout << "Hist " << *ithistname << " not found in file, break loop." << std::endl;
1588  break;
1589  }
1590  if (newHist->GetEntries() == 0) {
1591  nEmpty++;
1592  continue;
1593  }
1594  newHist->SetLineColor(myLineColor);
1595  newHist->SetLineStyle(myLineStyle);
1596  if (!h) { // first hist: clone, but rename keeping only first part of name
1597  TString name(newHist->GetName());
1598  Ssiz_t pos_ = 0;
1599  for (UInt_t i2 = 0; i2 < 3; ++i2)
1600  pos_ = name.Index("_", pos_ + 1);
1601  name = name(0, pos_); // only up to three '_'
1602  h = static_cast<TH1*>(newHist->Clone("summed_" + name));
1603  // TString myTitle = Form("%s: %lld modules", selection, nSel);
1604  // h->SetTitle( myTitle );
1605  } else { // otherwise just add
1606  h->Add(newHist);
1607  }
1608  delete newHist;
1609  }
1610 
1611  std::cout << "PlotAlignmentValidation::addHists"
1612  << "Result is merged from " << nSel - nEmpty << " hists, " << nEmpty << " hists were empty." << std::endl;
1613 
1614  if (nSel - nEmpty == 0)
1615  continue;
1616 
1617  if (myLegend != nullptr)
1618  (*myLegend)->AddEntry(h, myLegendName, "L");
1619 
1620  retHistoStack->Add(h);
1621  }
1622 
1623  return retHistoStack;
1624 }
container to hold data to be written into TTree
std::string profileNameResXvsX
selection
main part
Definition: corrVsCorr.py:100
std::string profileNameResYvsX
double f[11][100]
std::string histNameLocalY
std::string histNameNormLocalX
std::string histNameLocalX
std::vector< TkOfflineVariables * > sourceList
std::string profileNameResXvsY
Definition: tree.py:1
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4
std::string profileNameResYvsY

◆ findmodule()

std::vector< TH1 * > PlotAlignmentValidation::findmodule ( TFile *  f,
unsigned int  moduleid 
)
private

Definition at line 2352 of file PlotAlignmentValidation.cc.

References f, h, mps_fire::i, submitPVValidationJobs::t, and EcalPhiSymFlatTableProducers_cfi::variables.

Referenced by residual_by_moduleID().

2352  {
2353  //TFile *f = TFile::Open(filename, "READ");
2354  TString histnamex;
2355  TString histnamey;
2356  //read necessary branch/folder
2357  auto t = (TTree*)f->Get("TrackerOfflineValidation/TkOffVal");
2358 
2359  TkOffTreeVariables* variables = nullptr;
2360  t->SetBranchAddress("TkOffTreeVariables", &variables);
2361  unsigned int number_of_entries = t->GetEntries();
2362  for (unsigned int i = 0; i < number_of_entries; i++) {
2363  t->GetEntry(i);
2364  if (variables->moduleId == moduleid) {
2365  histnamex = variables->histNameX;
2366  histnamey = variables->histNameY;
2367  break;
2368  }
2369  }
2370 
2371  std::vector<TH1*> h;
2372 
2373  auto h1 = (TH1*)f->FindObjectAny(histnamex);
2374  auto h2 = (TH1*)f->FindObjectAny(histnamey);
2375 
2376  h1->SetDirectory(nullptr);
2377  h2->SetDirectory(nullptr);
2378 
2379  h.push_back(h1);
2380  h.push_back(h2);
2381 
2382  return h;
2383 }
container to hold data to be written into TTree
double f[11][100]
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4

◆ findObjectFromCanvas()

TObject * PlotAlignmentValidation::findObjectFromCanvas ( TCanvas *  canv,
const char *  className,
Int_t  n = 1 
)
private

Definition at line 1679 of file PlotAlignmentValidation.cc.

References className(), newFWLiteAna::found, create_idmaps::n, GetRecoTauVFromDQM_MC_cff::next, and getGTfromDQMFile::obj.

1679  {
1680  // Finds the n-th instance of the given class from the canvas
1681  TIter next(canv->GetListOfPrimitives());
1682  TObject* obj = nullptr;
1683  Int_t found = 0;
1684  while ((obj = next())) {
1685  if (strncmp(obj->ClassName(), className, 10) == 0) {
1686  if (++found == n)
1687  return obj;
1688  }
1689  }
1690 
1691  return nullptr;
1692 }
std::string className(const T &t)
Definition: ClassName.h:31

◆ fitGauss()

TF1 * PlotAlignmentValidation::fitGauss ( TH1 *  hist,
int  color 
)
private

void plotBoxOverview(TCanvas &c1, TList &treeList,std::string plot_Var1a,std::string plot_Var1b, std::string plot_Var2, Int_t filenumber,Int_t minHits); void plot1DDetailsSubDet(TCanvas &c1, TList &treeList, std::string plot_Var1a,std::string plot_Var1b, std::string plot_Var2, Int_t minHits); void plot1DDetailsBarrelLayer(TCanvas &c1, TList &treeList, std::string plot_Var1a,std::string plot_Var1b, Int_t minHits); void plot1DDetailsDiskWheel(TCanvas &c1, TList &treelist, std::string plot_Var1a,std::string plot_Var1b, Int_t minHits);

Definition at line 1630 of file PlotAlignmentValidation.cc.

References EcalMonitorTask_cff::func, compareTotals::hist, SiStripPI::mean, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by setDMRHistStyleAndLegend().

1630  {
1631  //1. fits a Gauss function to the inner range of abs(2 rms)
1632  //2. repeates the Gauss fit in a 2 sigma range around mean of first fit
1633  //returns mean and sigma from fit in micron
1634  if (!hist || hist->GetEntries() < 20)
1635  return nullptr;
1636 
1637  float mean = hist->GetMean();
1638  float sigma = hist->GetRMS();
1639  std::string functionname = "gaussian_";
1640  functionname += hist->GetName();
1641  TF1* func = new TF1(functionname.c_str(), "gaus", mean - 2. * sigma, mean + 2. * sigma);
1642 
1643  func->SetLineColor(color);
1644  func->SetLineStyle(2);
1645  if (0 == hist->Fit(func, "QNR")) { // N: do not blow up file by storing fit!
1646  mean = func->GetParameter(1);
1647  sigma = func->GetParameter(2);
1648  // second fit: three sigma of first fit around mean of first fit
1649  func->SetRange(mean - 3. * sigma, mean + 3. * sigma);
1650  // I: integral gives more correct results if binning is too wide
1651  // L: Likelihood can treat empty bins correctly (if hist not weighted...)
1652  if (0 == hist->Fit(func, "Q0ILR")) {
1653  if (hist->GetFunction(func->GetName())) { // Take care that it is later on drawn:
1654  //hist->GetFunction(func->GetName())->ResetBit(TF1::kNotDraw);
1655  }
1656  }
1657  }
1658  return func;
1659 }

◆ getSelectionForDMRPlot()

std::string PlotAlignmentValidation::getSelectionForDMRPlot ( int  minHits,
int  subDetId,
int  direction = 0,
int  layer = 0 
)
private

Definition at line 1825 of file PlotAlignmentValidation.cc.

References nano_mu_digi_cff::layer, reco_skim_cfg_mod::minHits, and GeomDetEnumerators::subDetId.

Referenced by plotDMRHistogram().

1825  {
1826  std::ostringstream builder;
1827  builder << "entries >= " << minHits;
1828  builder << " && subDetId == " << subDetId;
1829  if (direction != 0) {
1830  if (subDetId == 2) { // FPIX is split by zDirection
1831  builder << " && zDirection == " << direction;
1832  } else {
1833  builder << " && rDirection == " << direction;
1834  }
1835  }
1836  if (layer > 0) {
1837  builder << " && layer == " << layer;
1838  }
1839  return builder.str();
1840 }
constexpr unsigned int subDetId[21]

◆ getTreeList()

TList * PlotAlignmentValidation::getTreeList ( )
private

Definition at line 442 of file PlotAlignmentValidation.cc.

References gather_cfg::cout, ztail::d, moreThanOneSource, sourcelist, treeBaseDir, and mps_merge::treeList.

442  {
443  TList* treeList = new TList();
444  TFile* first_source = (TFile*)sourcelist->First();
445  std::cout << first_source->GetName() << std::endl;
446  TDirectoryFile* d = (TDirectoryFile*)first_source->Get(treeBaseDir.c_str());
447  treeList->Add((TTree*)(*d).Get("TkOffVal"));
448 
449  if (moreThanOneSource == true) {
450  TFile* nextsource = (TFile*)sourcelist->After(first_source);
451  while (nextsource) {
452  std::cout << nextsource->GetName() << std::endl;
453  d = (TDirectoryFile*)nextsource->Get("TrackerOfflineValidation");
454 
455  treeList->Add((TTree*)(*d).Get("TkOffVal"));
456 
457  nextsource = (TFile*)sourcelist->After(nextsource);
458  }
459  }
460  return treeList;
461 }
d
Definition: ztail.py:151
string treeList
Definition: mps_merge.py:107

◆ getVariableForDMRPlot()

std::string PlotAlignmentValidation::getVariableForDMRPlot ( const std::string &  histoname,
const std::string &  variable,
int  nbins,
double  min,
double  max 
)
private

Definition at line 1842 of file PlotAlignmentValidation.cc.

References WZElectronSkims53X_cff::max, SiStripPI::min, LaserClient_cfi::nbins, and HPSPFTaus_cff::variable.

Referenced by plotDMRHistogram().

1843  {
1844  std::ostringstream builder;
1845  builder << variable << ">>" << histoname << "(" << nbins << "," << min << "," << max << ")";
1846  return builder.str();
1847 }

◆ legendOptions()

void PlotAlignmentValidation::legendOptions ( TString  options)

Definition at line 162 of file PlotAlignmentValidation.cc.

References bigtext_, showMean_, showMeanError_, showModules_, showRMS_, showRMSError_, showUnderOverFlow_, and twolines_.

Referenced by PlotAlignmentValidation().

162  {
163  showMean_ = false;
164  showRMS_ = false;
165  showMeanError_ = false;
166  showRMSError_ = false;
167  showModules_ = false;
168  showUnderOverFlow_ = false;
169  options.ReplaceAll(" ", "").ToLower();
170  if (options.Contains("mean") || options.Contains("all"))
171  showMean_ = true;
172  if (options.Contains("meanerror") || options.Contains("all"))
173  showMeanError_ = true;
174  if (options.Contains("rms") || options.Contains("all"))
175  showRMS_ = true;
176  if (options.Contains("rmserror") || options.Contains("all"))
177  showRMSError_ = true;
178  if (options.Contains("modules") || options.Contains("all"))
179  showModules_ = true;
180  if (options.Contains("under") || options.Contains("over") || options.Contains("outside") || options.Contains("all"))
181  showUnderOverFlow_ = true;
182 
184 }

◆ loadFileList()

void PlotAlignmentValidation::loadFileList ( const char *  inputFile,
std::string  fileName = "",
int  lineColor = 2,
int  lineStyle = 1 
)

◆ maxNumberOfLayers()

int PlotAlignmentValidation::maxNumberOfLayers ( int  subdetector)

Definition at line 150 of file PlotAlignmentValidation.cc.

References ALPAKA_ACCELERATOR_NAMESPACE::vertexFinder::it, WZElectronSkims53X_cff::max, numberOfLayers(), mps_fire::result, sourceList, and subdetector.

Referenced by plotDMR(), and plotSS().

150  {
151  int result = 0;
152  for (auto it = sourceList.begin(); it != sourceList.end(); ++it) {
153  result = std::max(result, numberOfLayers((*it)->getPhase(), subdetector));
154  }
155  return result;
156 }
TString subdetector
std::vector< TkOfflineVariables * > sourceList
int numberOfLayers(int phase, int subdetector)

◆ modifySSHistAndLegend()

void PlotAlignmentValidation::modifySSHistAndLegend ( THStack *  hs,
TLegend *  legend 
)
private

Definition at line 2201 of file PlotAlignmentValidation.cc.

References bigtext_, DMR_cfg::cerr, gather_cfg::cout, mps_splice::entry, alignBH_cfg::fixed, compareTotals::legend, TkAlStyle::legendheader, GetRecoTauVFromDQM_MC_cff::next, isotrackNtupler::scale, dqmMemoryStats::stats, and TkAlStyle::textSize.

Referenced by plotSS().

2201  {
2202  // Add mean-y-values to the legend and scale the histograms.
2203 
2204  Double_t legendY = 0.80;
2205  bool hasheader = (TkAlStyle::legendheader != "");
2206  if (hasheader)
2207  legend->SetHeader(TkAlStyle::legendheader);
2208  legend->SetFillStyle(0);
2209  int legendsize = hs->GetHists()->GetSize() + hasheader;
2210 
2211  if (legendsize > 3)
2212  legendY -= 0.01 * (legendsize - 3);
2213  if (bigtext_) {
2214  legendY -= 0.05;
2215  }
2216  if (legendY < 0.6) {
2217  std::cerr << "Warning: Huge legend!" << std::endl;
2218  legendY = 0.6;
2219  }
2220  legend->SetY1(legendY);
2221  if (bigtext_)
2222  legend->SetTextSize(TkAlStyle::textSize);
2223 
2224  // Loop over all profiles
2225  TProfile* prof = nullptr;
2226  TIter next(hs->GetHists());
2227  Int_t index = hasheader; //if hasheader, first entry is the header itself
2228  while ((prof = (TProfile*)next())) {
2229  //Scaling: from cm to um
2230  Double_t scale = 10000;
2231  prof->Scale(scale);
2232 
2233  Double_t stats[6] = {0};
2234  prof->GetStats(stats);
2235 
2236  std::ostringstream legendtext;
2237  legendtext.precision(3);
2238  legendtext << std::fixed; // to always show 3 decimals
2239  legendtext << ": y mean = " << stats[4] / stats[0] * scale << " #mum";
2240 
2241  TLegendEntry* entry = (TLegendEntry*)legend->GetListOfPrimitives()->At(index);
2242  if (entry == nullptr)
2243  std::cout << "PlotAlignmentValidation::PlotAlignmentValidation::modifySSLegend: Bad legend!" << std::endl;
2244  else
2245  entry->SetLabel((entry->GetLabel() + legendtext.str()).c_str());
2246  index++;
2247  }
2248 
2249  // Make some room for the legend
2250  hs->SetMaximum(hs->GetMaximum("nostack PE") * 1.3);
2251 }
static double textSize
Definition: TkAlStyle.h:103
static TString legendheader
Definition: TkAlStyle.h:101

◆ numberOfLayers()

int PlotAlignmentValidation::numberOfLayers ( int  phase,
int  subdetector 
)

Definition at line 104 of file PlotAlignmentValidation.cc.

References cms::cuda::assert(), and subdetector.

Referenced by maxNumberOfLayers(), plotDMR(), and plotSS().

104  {
105  switch (phase) {
106  case 0:
107  switch (subdetector) {
108  case 1:
109  return 3;
110  case 2:
111  return 2;
112  case 3:
113  return 4;
114  case 4:
115  return 3;
116  case 5:
117  return 6;
118  case 6:
119  return 9;
120  default:
121  assert(false);
122  }
123  case 1:
124  switch (subdetector) {
125  case 1:
126  return 4;
127  case 2:
128  return 3;
129  case 3:
130  return 4;
131  case 4:
132  return 3;
133  case 5:
134  return 6;
135  case 6:
136  return 9;
137  default:
138  assert(false);
139  }
140  default:
141  assert(false);
142  }
143  return 0;
144 }
TString subdetector
assert(be >=bs)

◆ openSummaryFile()

void PlotAlignmentValidation::openSummaryFile ( )
private

Definition at line 63 of file PlotAlignmentValidation.cc.

References openedsummaryfile, outputDir, rootsummaryfile, sourceList, summaryfile, and summaryfilename.

Referenced by plotChi2(), and plotDMR().

63  {
64  if (!openedsummaryfile) {
65  openedsummaryfile = true;
66  summaryfile.open(outputDir + "/" + summaryfilename + ".txt");
67  //Rootfile introduced to store the DMR histograms
68  rootsummaryfile = new TFile(outputDir + "/" + summaryfilename + ".root", "RECREATE");
69 
70  for (auto vars : sourceList) {
71  summaryfile << "\t" << vars->getName();
72  }
73  summaryfile << "\tformat={}\n";
74  } else {
75  //Check for the rootfile to be open, and open it in case it is not already.
76  if (!rootsummaryfile->IsOpen())
77  rootsummaryfile->Open(outputDir + "/" + summaryfilename + ".root", "UPDATE");
78  }
79 }
vars
Definition: DeepTauIdBase.h:60
static const TString summaryfilename
std::vector< TkOfflineVariables * > sourceList

◆ plotChi2()

void PlotAlignmentValidation::plotChi2 ( const char *  inputFile)

plotSurfaceShapes: options="split","layers"/"layer","subdet"

Definition at line 1259 of file PlotAlignmentValidation.cc.

References myMessageLogger_cff::alignment, cms::cuda::assert(), gather_cfg::cout, mps_splice::entry, h, makeListRunsInFiles::inputFile, compareTotals::legend, openSummaryFile(), outputDir, funct::primitive(), sourceList, summaryfile, and runGCPTkAlMap::title.

1259  {
1260  // Opens the file (it should be OfflineValidation(Parallel)_result.root)
1261  // and reads and plots the norm_chi^2 and h_chi2Prob -distributions.
1262 
1263  Bool_t errorflag = kFALSE;
1264  TFile* fi1 = TFile::Open(inputFile, "read");
1265  if (fi1 != nullptr) {
1266  if (fi1->GetDirectory("TrackerOfflineValidation/GlobalTrackVariables") == nullptr) {
1267  errorflag = kTRUE;
1268  }
1269  } else {
1270  errorflag = kTRUE;
1271  }
1272  if (errorflag) {
1273  std::cout << "PlotAlignmentValidation::plotChi2: Can't find GlobalTrackVariables given file,"
1274  << " no chi^2-plots produced" << std::endl;
1275  return;
1276  }
1277 
1278  auto normchi = fi1->Get<TCanvas>("TrackerOfflineValidation/GlobalTrackVariables/h_normchi2");
1279  // please remove following line once bug is fixed with ROOT Version: >6.27/01
1280  normchi->GetFrame()->ResetBit(kCanDelete);
1281 
1282  auto chiprob = fi1->Get<TCanvas>("TrackerOfflineValidation/GlobalTrackVariables/h_chi2Prob");
1283  // please remove following line once bug is fixed with ROOT Version: >6.27/01
1284  chiprob->GetFrame()->ResetBit(kCanDelete);
1285 
1286  if (normchi == nullptr || chiprob == nullptr) {
1287  errorflag = kTRUE;
1288  }
1289  if (errorflag) {
1290  std::cout << "PlotAlignmentValidation::plotChi2: Can't find data from given file,"
1291  << " no chi^2-plots produced" << std::endl;
1292  return;
1293  }
1294 
1295  TLegend* legend = nullptr;
1296  for (auto primitive : *normchi->GetListOfPrimitives()) {
1297  legend = dynamic_cast<TLegend*>(primitive);
1298  if (legend)
1299  break;
1300  }
1301  if (legend) {
1302  openSummaryFile();
1303  summaryfile << "ntracks";
1304  for (auto alignment : sourceList) {
1305  summaryfile << "\t";
1306  TString title = alignment->getName();
1307  int color = alignment->getLineColor();
1308  int style = alignment->getLineStyle();
1309  bool foundit = false;
1310  for (auto entry : *legend->GetListOfPrimitives()) {
1311  TLegendEntry* legendentry = dynamic_cast<TLegendEntry*>(entry);
1312  assert(legendentry);
1313  TH1* h = dynamic_cast<TH1*>(legendentry->GetObject());
1314  if (!h)
1315  continue;
1316  if (legendentry->GetLabel() == title && h->GetLineColor() == color && h->GetLineStyle() == style) {
1317  foundit = true;
1318  summaryfile << h->GetEntries();
1319  break;
1320  }
1321  }
1322  if (!foundit) {
1323  summaryfile << 0;
1324  }
1325  }
1326  summaryfile << "\n";
1327  }
1328 
1329  chiprob->Draw();
1330  normchi->Draw();
1331 
1332  // PNG,EPS,PDF files
1333  normchi->Print((outputDir + "/h_normchi2.png").c_str());
1334  chiprob->Print((outputDir + "/h_chi2Prob.png").c_str());
1335  normchi->Print((outputDir + "/h_normchi2.eps").c_str());
1336  chiprob->Print((outputDir + "/h_chi2Prob.eps").c_str());
1337  normchi->Print((outputDir + "/h_normchi2.pdf").c_str());
1338  chiprob->Print((outputDir + "/h_chi2Prob.pdf").c_str());
1339 
1340  // ROOT files
1341  TFile fi2((outputDir + "/h_normchi2.root").c_str(), "recreate");
1342  normchi->Write();
1343  fi2.Close();
1344 
1345  TFile fi3((outputDir + "/h_chi2Prob.root").c_str(), "recreate");
1346  chiprob->Write();
1347  fi3.Close();
1348 
1349  fi1->Close();
1350  delete fi1;
1351 }
assert(be >=bs)
Primitive< F, X >::type primitive(const F &f)
Definition: Primitive.h:41
Definition: style.py:1
std::vector< TkOfflineVariables * > sourceList
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4

◆ plotDMR()

void PlotAlignmentValidation::plotDMR ( const std::string &  plotVar = "medianX",
Int_t  minHits = 50,
const std::string &  options = "plain",
const std::string &  filterName = "",
Float_t  maxBadLumiPixel = 0.5,
Float_t  maxBadLumiStrip = 7.0 
)

plotVar=mean,meanX,meanY,median,rms etc., comma-separated list can be given; minHits=the minimum hits needed for module to appear in plot; options="plain" for regular DMR, "split" for inwards/outwards split, "layers" for layerwise DMR, "layer=N" for Nth layer, or combination of the previous (e.g. "split layers") filterName=rootfile containing tree with module ids to be skipped in plotting (to be used for averaged plots or in debugging) maxBadLumiPixel and maxBadLumiStrip place cuts on maximum luminosity for which module wont be skipped if it does not satisfy condition for guaranteed number of hits

plotinfo.plotLayers &&

Definition at line 687 of file PlotAlignmentValidation.cc.

References bigtext_, DummyCfis::c, DMR_cfg::cerr, f, dtDQMMerge_cfg::filterName, PlotAlignmentValidation::DMRPlotInfo::filterName, PlotAlignmentValidation::DMRPlotInfo::firsthisto, alignBH_cfg::fixed, TkOfflineVariables::getName(), TkOfflineVariables::getPhase(), PlotAlignmentValidation::DMRPlotInfo::h, PlotAlignmentValidation::DMRPlotInfo::h1, PlotAlignmentValidation::DMRPlotInfo::h2, PlotAlignmentValidation::DMRPlotInfo::hstack, mps_fire::i, ALPAKA_ACCELERATOR_NAMESPACE::vertexFinder::it, nano_mu_digi_cff::layer, PlotAlignmentValidation::DMRPlotInfo::legend, compareTotals::legend, TkAlStyle::legendheader, PlotAlignmentValidation::DMRPlotInfo::max, PlotAlignmentValidation::DMRPlotInfo::maxBadLumiPixel, PlotAlignmentValidation::DMRPlotInfo::maxBadLumiStrip, maxNumberOfLayers(), PlotAlignmentValidation::DMRPlotInfo::maxY, PlotAlignmentValidation::DMRPlotInfo::min, PlotAlignmentValidation::DMRPlotInfo::minHits, reco_skim_cfg_mod::minHits, amptDefaultParameters_cff::mu, dqmiodatasetharvest::nan, PlotAlignmentValidation::DMRPlotInfo::nbins, numberOfLayers(), openSummaryFile(), outputDir, plotDMRHistogram(), PlotAlignmentValidation::DMRPlotInfo::plotLayers, L1TEGammaDiff_cfi::plotName, PlotAlignmentValidation::DMRPlotInfo::plotPlain, PlotAlignmentValidation::DMRPlotInfo::plotSplits, scaleXaxis(), setDMRHistStyleAndLegend(), setHistStyle(), setTitleStyle(), sourceList, AlCaHLTBitMon_QueryRunRegistry::string, PlotAlignmentValidation::DMRPlotInfo::subDetId, summaryfile, TkAlStyle::textSize, twolines_, unit(), vAlignmentUncertainty, PlotAlignmentValidation::DMRPlotInfo::variable, HPSPFTaus_cff::variable, PlotAlignmentValidation::DMRPlotInfo::vars, vdeltamean, vmean, vmeanerror, vPValueEqualSplitMeans, vPValueMeanEqualIdeal, vPValueRMSEqualIdeal, and vrms.

692  {
693  // If several, comma-separated values are given in 'variable',
694  // call plotDMR with each value separately.
695  // If a comma is found, the string is divided to two.
696  // (no space allowed)
697  std::size_t findres = variable.find(',');
698  if (findres != std::string::npos) {
699  std::string substring1 = variable.substr(0, findres);
700  std::string substring2 = variable.substr(findres + 1, std::string::npos);
701  plotDMR(substring1, minHits, options, filterName, maxBadLumiPixel, maxBadLumiStrip);
702  plotDMR(substring2, minHits, options, filterName, maxBadLumiPixel, maxBadLumiStrip);
703  return;
704  }
705 
706  // Variable name should end with X or Y. If it doesn't, recursively calls plotDMR twice with
707  // X and Y added, respectively
708  if (variable == "mean" || variable == "median" || variable == "meanNorm" || variable == "rms" ||
709  variable == "rmsNorm") {
710  plotDMR(variable + "X", minHits, options, filterName, maxBadLumiPixel, maxBadLumiStrip);
711  plotDMR(variable + "Y", minHits, options, filterName, maxBadLumiPixel, maxBadLumiStrip);
712  return;
713  }
714 
715  // options:
716  // -plain (default, the whole distribution)
717  // -split (distribution splitted to two)
718  // -layers (plain db for each layer/disc superimposed in one plot)
719  // -layersSeparate (plain db for each layer/disc in separate plots)
720  // -layersSplit (splitted db for each layers/disc in one plot)
721  // -layersSplitSeparate (splitted db, for each layers/disc in separate plots)
722 
723  TRegexp layer_re("layer=[0-9]+");
724  bool plotPlain = false, plotSplits = false, plotLayers = false;
725  int plotLayerN = 0;
726  Ssiz_t index, len;
727  if (options.find("plain") != std::string::npos) {
728  plotPlain = true;
729  }
730  if (options.find("split") != std::string::npos) {
731  plotSplits = true;
732  }
733  if (options.find("layers") != std::string::npos) {
734  plotLayers = true;
735  }
736  if ((index = layer_re.Index(options, &len)) != -1) {
737  if (plotLayers) {
738  std::cerr << "Warning: option 'layers' overrides 'layer=N'" << std::endl;
739  } else {
740  std::string substr = options.substr(index + 6, len - 6);
741  plotLayerN = atoi(substr.c_str());
742  }
743  }
744 
745  // Defaults to plotting only plain plot if empty (or invalid)
746  // option string is given
747  if (!plotPlain && !plotSplits) {
748  plotPlain = true;
749  }
750 
751  // This boolean array tells for which detector modules to plot split DMR plots
752  // They are plotted for BPIX, FPIX, TIB and TOB
753  static bool plotSplitsFor[6] = {true, true, true, false, true, false};
754 
755  DMRPlotInfo plotinfo;
756 
757  gStyle->SetOptStat(0);
758 
759  TCanvas c("canv", "canv");
760 
761  plotinfo.variable = variable;
762  plotinfo.minHits = minHits;
763  plotinfo.plotPlain = plotPlain;
764  plotinfo.plotLayers = plotLayers;
765  plotinfo.filterName = filterName;
766  plotinfo.maxBadLumiPixel = maxBadLumiPixel;
767  plotinfo.maxBadLumiStrip = maxBadLumiStrip;
768 
769  // width in cm
770  // for DMRS, use 100 bins in range +-10 um, bin width 0.2um
771  // if modified, check also TrackerOfflineValidationSummary_cfi.py and TrackerOfflineValidation_Standalone_cff.py
772  if (variable == "meanX") {
773  plotinfo.nbins = 50;
774  plotinfo.min = -0.001;
775  plotinfo.max = 0.001;
776  } else if (variable == "meanY") {
777  plotinfo.nbins = 50;
778  plotinfo.min = -0.005;
779  plotinfo.max = 0.005;
780  } else if (variable == "medianX")
781  if (plotSplits) {
782  plotinfo.nbins = 50;
783  plotinfo.min = -0.0005;
784  plotinfo.max = 0.0005;
785  } else {
786  plotinfo.nbins = 100;
787  plotinfo.min = -0.001;
788  plotinfo.max = 0.001;
789  }
790  else if (variable == "medianY")
791  if (plotSplits) {
792  plotinfo.nbins = 50;
793  plotinfo.min = -0.0005;
794  plotinfo.max = 0.0005;
795  } else {
796  plotinfo.nbins = 100;
797  plotinfo.min = -0.001;
798  plotinfo.max = 0.001;
799  }
800  else if (variable == "meanNormX") {
801  plotinfo.nbins = 100;
802  plotinfo.min = -2.0;
803  plotinfo.max = 2.0;
804  } else if (variable == "meanNormY") {
805  plotinfo.nbins = 100;
806  plotinfo.min = -2.0;
807  plotinfo.max = 2.0;
808  } else if (variable == "rmsX") {
809  plotinfo.nbins = 100;
810  plotinfo.min = 0.0;
811  plotinfo.max = 0.1;
812  } else if (variable == "rmsY") {
813  plotinfo.nbins = 100;
814  plotinfo.min = 0.0;
815  plotinfo.max = 0.1;
816  } else if (variable == "rmsNormX") {
817  plotinfo.nbins = 100;
818  plotinfo.min = 0.3;
819  plotinfo.max = 1.8;
820  } else if (variable == "rmsNormY") {
821  plotinfo.nbins = 100;
822  plotinfo.min = 0.3;
823  plotinfo.max = 1.8;
824  } else {
825  std::cerr << "Unknown variable " << variable << std::endl;
826  plotinfo.nbins = 100;
827  plotinfo.min = -0.1;
828  plotinfo.max = 0.1;
829  }
830  //Begin loop on structures
831  for (int i = 1; i <= 6; ++i) {
832  // Preferred binning in case of averaged DMR disributions
833  if (!plotinfo.filterName.empty()) {
834  if (i == 1 || i == 2) {
835  if (variable == "medianX") {
836  if (plotSplits) {
837  plotinfo.nbins = 50;
838  } else {
839  plotinfo.nbins = 50;
840  }
841  } else if (variable == "medianY") {
842  if (plotSplits) {
843  plotinfo.nbins = 50;
844  } else {
845  plotinfo.nbins = 25;
846  }
847  }
848  } else if (i == 3 || i == 4 || i == 5 || i == 6) {
849  if (variable == "medianX" || variable == "medianY") {
850  if (plotSplits) {
851  plotinfo.nbins = 50;
852  } else {
853  plotinfo.nbins = 25;
854  }
855  }
856  }
857  }
858 
859  // Skip strip detectors if plotting any "Y" variable
860  if (i != 1 && i != 2 && variable.length() > 0 && variable[variable.length() - 1] == 'Y') {
861  continue;
862  }
863 
864  // Skips plotting too high layers
865  if (plotLayerN > maxNumberOfLayers(i)) {
866  continue;
867  }
868 
869  plotinfo.plotSplits = plotSplits && plotSplitsFor[i - 1];
870  if (!plotinfo.plotPlain && !plotinfo.plotSplits) {
871  continue;
872  }
873 
874  // Sets dimension of legend according to the number of plots
875 
876  bool hasheader = (TkAlStyle::legendheader != "");
877 
878  int nPlots = 1;
879  if (plotinfo.plotSplits) {
880  nPlots = 3;
881  }
882  // This will make the legend a bit bigger than necessary if there is a mixture of phase 0 and phase 1.
883  // Not worth it to implement more complicated logic.
884  if (plotinfo.plotLayers) {
885  nPlots *= maxNumberOfLayers(i);
886  }
887  nPlots *= sourceList.size();
888  if (twolines_) {
889  nPlots *= 2;
890  }
891  nPlots += hasheader;
892 
893  double legendY = 0.80;
894  if (nPlots > 3) {
895  legendY -= 0.01 * (nPlots - 3);
896  }
897  if (bigtext_) {
898  legendY -= 0.05;
899  }
900  if (legendY < 0.6) {
901  std::cerr << "Warning: Huge legend!" << std::endl;
902  legendY = 0.6;
903  }
904 
905  THStack hstack("hstack", "hstack");
906  plotinfo.maxY = 0;
907  plotinfo.subDetId = i;
908  plotinfo.legend = new TLegend(0.17, legendY, 0.85, 0.88);
909  plotinfo.legend->SetNColumns(2);
910  if (hasheader)
911  plotinfo.legend->SetHeader(TkAlStyle::legendheader);
912  if (bigtext_)
913  plotinfo.legend->SetTextSize(TkAlStyle::textSize);
914  plotinfo.legend->SetFillStyle(0);
915  plotinfo.hstack = &hstack;
916  plotinfo.h = plotinfo.h1 = plotinfo.h2 = nullptr;
917  plotinfo.firsthisto = true;
918 
919  openSummaryFile();
920  vmean.clear();
921  vrms.clear();
922  vdeltamean.clear();
923  vmeanerror.clear();
925  vPValueMeanEqualIdeal.clear();
926  vPValueRMSEqualIdeal.clear();
927 
928  std::string stringsubdet;
929  switch (i) {
930  case 1:
931  stringsubdet = "BPIX";
932  break;
933  case 2:
934  stringsubdet = "FPIX";
935  break;
936  case 3:
937  stringsubdet = "TIB";
938  break;
939  case 4:
940  stringsubdet = "TID";
941  break;
942  case 5:
943  stringsubdet = "TOB";
944  break;
945  case 6:
946  stringsubdet = "TEC";
947  break;
948  }
949 
950  for (std::vector<TkOfflineVariables*>::iterator it = sourceList.begin(); it != sourceList.end(); ++it) {
951  plotinfo.vars = *it;
952  plotinfo.h1 = plotinfo.h2 = plotinfo.h = nullptr;
953 
954  int minlayer = plotLayers ? 1 : plotLayerN;
955  //Layer 0 is associated to the entire structure, this check ensures that even when both the plotLayers and the plotPlain options are active, also the histogram for the entire structure is made.
956  if (plotinfo.plotPlain)
957  minlayer = 0;
958  int maxlayer = plotLayers ? numberOfLayers(plotinfo.vars->getPhase(), plotinfo.subDetId) : plotLayerN;
959 
960  for (int layer = minlayer; layer <= maxlayer; layer++) {
961  if (plotinfo.plotPlain) {
962  plotDMRHistogram(plotinfo, 0, layer, stringsubdet);
963  }
964 
965  if (plotinfo.plotSplits) {
966  plotDMRHistogram(plotinfo, -1, layer, stringsubdet);
967  plotDMRHistogram(plotinfo, 1, layer, stringsubdet);
968  }
969 
970  if (plotinfo.plotPlain) {
971  if (plotinfo.h) {
972  setDMRHistStyleAndLegend(plotinfo.h, plotinfo, 0, layer);
973  } else {
974  if ((plotinfo.variable == "medianX" || plotinfo.variable == "medianY") && layer == 0) {
976  vmean.push_back(nan(""));
977  vrms.push_back(nan(""));
978  vmeanerror.push_back(nan(""));
979  vAlignmentUncertainty.push_back(nan(""));
980  vPValueMeanEqualIdeal.push_back(nan(""));
981  vPValueRMSEqualIdeal.push_back(nan(""));
982  if (plotinfo.plotSplits && plotinfo.plotPlain) {
983  vdeltamean.push_back(nan(""));
984  vPValueEqualSplitMeans.push_back(nan(""));
985  }
986  }
987  }
988  }
989 
990  if (plotinfo.plotSplits) {
991  // Add delta mu to the histogram
992  if (plotinfo.h1 != nullptr && plotinfo.h2 != nullptr && !plotinfo.plotPlain) {
993  std::ostringstream legend;
994  std::string unit = " #mum";
995  legend.precision(3);
996  legend << std::fixed; // to always show 3 decimals
997  float factor = 10000.0f;
998  if (plotinfo.variable == "meanNormX" || plotinfo.variable == "meanNormY" ||
999  plotinfo.variable == "rmsNormX" || plotinfo.variable == "rmsNormY") {
1000  factor = 1.0f;
1001  unit = "";
1002  }
1003  float deltamu = factor * (plotinfo.h2->GetMean(1) - plotinfo.h1->GetMean(1));
1004  legend << plotinfo.vars->getName();
1005  if (layer > 0) {
1006  // TEC and TID have discs, the rest have layers
1007  if (i == 4 || i == 6)
1008  legend << ", disc ";
1009  else
1010  legend << ", layer ";
1011  legend << layer;
1012  }
1013  plotinfo.legend->AddEntry(static_cast<TObject*>(nullptr), legend.str().c_str(), "");
1014  legend.str("");
1015  legend << "#Delta#mu = " << deltamu << unit;
1016  plotinfo.legend->AddEntry(static_cast<TObject*>(nullptr), legend.str().c_str(), "");
1017 
1018  if ((plotinfo.variable == "medianX" || plotinfo.variable == "medianY") && !plotLayers && layer == 0) {
1019  vdeltamean.push_back(deltamu);
1020  }
1021  }
1022  if (plotinfo.h1) {
1023  setDMRHistStyleAndLegend(plotinfo.h1, plotinfo, -1, layer);
1024  }
1025  if (plotinfo.h2) {
1026  setDMRHistStyleAndLegend(plotinfo.h2, plotinfo, 1, layer);
1027  }
1028  }
1029  }
1030  }
1031 
1032  if (hstack.GetHists() != nullptr && hstack.GetHists()->GetSize() != 0) {
1033  hstack.Draw("nostack");
1034  hstack.SetMaximum(plotinfo.maxY * 1.3);
1035  setTitleStyle(hstack, variable.c_str(), "#modules", plotinfo.subDetId);
1036  setHistStyle(*hstack.GetHistogram(), variable.c_str(), "#modules", 1);
1037 
1038  plotinfo.legend->Draw();
1039  } else {
1040  // Draw an empty default histogram
1041  plotinfo.h = new TH1F("defhist", "Empty default histogram", plotinfo.nbins, plotinfo.min, plotinfo.max);
1042  plotinfo.h->SetMaximum(10);
1043  if (plotinfo.variable.find("Norm") == std::string::npos)
1044  scaleXaxis(plotinfo.h, 10000);
1045  setTitleStyle(*plotinfo.h, variable.c_str(), "#modules", plotinfo.subDetId);
1046  setHistStyle(*plotinfo.h, variable.c_str(), "#modules", 1);
1047  plotinfo.h->Draw();
1048  }
1049 
1050  std::ostringstream plotName;
1051  plotName << outputDir << "/D";
1052 
1053  if (variable == "medianX")
1054  plotName << "medianR_";
1055  else if (variable == "medianY")
1056  plotName << "medianYR_";
1057  else if (variable == "meanX")
1058  plotName << "meanR_";
1059  else if (variable == "meanY")
1060  plotName << "meanYR_";
1061  else if (variable == "meanNormX")
1062  plotName << "meanNR_";
1063  else if (variable == "meanNormY")
1064  plotName << "meanNYR_";
1065  else if (variable == "rmsX")
1066  plotName << "rmsR_";
1067  else if (variable == "rmsY")
1068  plotName << "rmsYR_";
1069  else if (variable == "rmsNormX")
1070  plotName << "rmsNR_";
1071  else if (variable == "rmsNormY")
1072  plotName << "rmsNYR_";
1073 
1074  TString subdet;
1075  switch (i) {
1076  case 1:
1077  subdet = "BPIX";
1078  break;
1079  case 2:
1080  subdet = "FPIX";
1081  break;
1082  case 3:
1083  subdet = "TIB";
1084  break;
1085  case 4:
1086  subdet = "TID";
1087  break;
1088  case 5:
1089  subdet = "TOB";
1090  break;
1091  case 6:
1092  subdet = "TEC";
1093  break;
1094  }
1095 
1096  plotName << subdet;
1097 
1098  if (plotPlain && !plotSplits) {
1099  plotName << "_plain";
1100  } else if (!plotPlain && plotSplits) {
1101  plotName << "_split";
1102  }
1103  if (plotLayers) {
1104  // TEC and TID have discs, the rest have layers
1105  if (i == 4 || i == 6)
1106  plotName << "_discs";
1107  else
1108  plotName << "_layers";
1109  }
1110  if (plotLayerN > 0) {
1111  // TEC and TID have discs, the rest have layers
1112  if (i == 4 || i == 6)
1113  plotName << "_disc";
1114  else
1115  plotName << "_layer";
1116  plotName << plotLayerN;
1117  }
1118 
1119  // PNG,EPS,PDF files
1120  c.Update();
1121  c.Print((plotName.str() + ".png").c_str());
1122  c.Print((plotName.str() + ".eps").c_str());
1123  c.Print((plotName.str() + ".pdf").c_str());
1124 
1125  // ROOT file
1126  TFile f((plotName.str() + ".root").c_str(), "recreate");
1127  c.Write();
1128  f.Close();
1129 
1130  // Free allocated memory.
1131  delete plotinfo.h;
1132  delete plotinfo.h1;
1133  delete plotinfo.h2;
1134 
1135  if (!vmean.empty()) {
1136  summaryfile << " mu_" << subdet;
1137  if (plotinfo.variable == "medianY")
1138  summaryfile << "_y";
1139  summaryfile << " (um)\t"
1140  << "latexname=$\\mu_\\text{" << subdet << "}";
1141  if (plotinfo.variable == "medianY")
1142  summaryfile << "^{y}";
1143  summaryfile << "$ ($\\mu$m)\t"
1144  << "format={:.3g}\t"
1145  << "latexformat=${:.3g}$";
1146  for (auto mu : vmean)
1147  summaryfile << "\t" << mu;
1148  summaryfile << "\n";
1149  }
1150  if (!vrms.empty()) {
1151  summaryfile << "sigma_" << subdet;
1152  if (plotinfo.variable == "medianY")
1153  summaryfile << "_y";
1154  summaryfile << " (um)\t"
1155  << "latexname=$\\sigma_\\text{" << subdet << "}";
1156  if (plotinfo.variable == "medianY")
1157  summaryfile << "^{y}";
1158  summaryfile << "$ ($\\mu$m)\t"
1159  << "format={:.3g}\t"
1160  << "latexformat=${:.3g}$";
1161  for (auto sigma : vrms)
1162  summaryfile << "\t" << sigma;
1163  summaryfile << "\n";
1164  }
1165  if (!vdeltamean.empty()) {
1166  summaryfile << " dmu_" << subdet;
1167  if (plotinfo.variable == "medianY")
1168  summaryfile << "_y";
1169  summaryfile << " (um)\t"
1170  << "latexname=$\\Delta\\mu_\\text{" << subdet << "}";
1171  if (plotinfo.variable == "medianY")
1172  summaryfile << "^{y}";
1173  summaryfile << "$ ($\\mu$m)\t"
1174  << "format={:.3g}\t"
1175  << "latexformat=${:.3g}$";
1176  for (auto dmu : vdeltamean)
1177  summaryfile << "\t" << dmu;
1178  summaryfile << "\n";
1179  }
1180  if (!vmeanerror.empty()) {
1181  summaryfile << " sigma_mu_" << subdet;
1182  if (plotinfo.variable == "medianY")
1183  summaryfile << "_y";
1184  summaryfile << " (um)\t"
1185  << "latexname=$\\sigma\\mu_\\text{" << subdet << "}";
1186  if (plotinfo.variable == "medianY")
1187  summaryfile << "^{y}";
1188  summaryfile << "$ ($\\mu$m)\t"
1189  << "format={:.3g}\t"
1190  << "latexformat=${:.3g}$";
1191  for (auto dmu : vmeanerror)
1192  summaryfile << "\t" << dmu;
1193  summaryfile << "\n";
1194  }
1195  if (!vPValueEqualSplitMeans.empty()) {
1196  summaryfile << " p_delta_mu_equal_zero_" << subdet;
1197  if (plotinfo.variable == "medianY")
1198  summaryfile << "_y";
1199  summaryfile << "\t"
1200  << "latexname=$P(\\delta\\mu_\\text{" << subdet << "}=0)";
1201  if (plotinfo.variable == "medianY")
1202  summaryfile << "^{y}";
1203  summaryfile << "$\t"
1204  << "format={:.3g}\t"
1205  << "latexformat=${:.3g}$";
1206  for (auto dmu : vPValueEqualSplitMeans)
1207  summaryfile << "\t" << dmu;
1208  summaryfile << "\n";
1209  }
1210  if (!vAlignmentUncertainty.empty()) {
1211  summaryfile << " alignment_uncertainty_" << subdet;
1212  if (plotinfo.variable == "medianY")
1213  summaryfile << "_y";
1214  summaryfile << " (um)\t"
1215  << "latexname=$\\sigma_\\text{align}_\\text{" << subdet << "}";
1216  if (plotinfo.variable == "medianY")
1217  summaryfile << "^{y}";
1218  summaryfile << "$ ($\\mu$m)\t"
1219  << "format={:.3g}\t"
1220  << "latexformat=${:.3g}$";
1221  for (auto dmu : vAlignmentUncertainty)
1222  summaryfile << "\t" << dmu;
1223  summaryfile << "\n";
1224  }
1225  if (!vPValueMeanEqualIdeal.empty()) {
1226  summaryfile << " p_mean_equals_ideal_" << subdet;
1227  if (plotinfo.variable == "medianY")
1228  summaryfile << "_y";
1229  summaryfile << "\t"
1230  << "latexname=$P(\\mu_\\text{" << subdet << "}=\\mu_\\text{ideal})";
1231  if (plotinfo.variable == "medianY")
1232  summaryfile << "^{y}";
1233  summaryfile << "$\t"
1234  << "format={:.3g}\t"
1235  << "latexformat=${:.3g}$";
1236  for (auto dmu : vPValueMeanEqualIdeal)
1237  summaryfile << "\t" << dmu;
1238  summaryfile << "\n";
1239  }
1240  if (!vPValueRMSEqualIdeal.empty()) {
1241  summaryfile << " p_RMS_equals_ideal_" << subdet;
1242  if (plotinfo.variable == "medianY")
1243  summaryfile << "_y";
1244  summaryfile << "\t"
1245  << "latexname=$P(\\sigma_\\text{" << subdet << "}=\\sigma_\\text{ideal})";
1246  if (plotinfo.variable == "medianY")
1247  summaryfile << "^{y}";
1248  summaryfile << "$\t"
1249  << "format={:.3g}\t"
1250  << "latexformat=${:.3g}$";
1251  for (auto dmu : vPValueRMSEqualIdeal)
1252  summaryfile << "\t" << dmu;
1253  summaryfile << "\n";
1254  }
1255  }
1256 }
std::vector< double > vAlignmentUncertainty
std::vector< double > vmeanerror
void scaleXaxis(TH1 *hist, Int_t scale)
void setHistStyle(TH1 &hist, const char *titleX, const char *titleY, int color)
std::vector< double > vPValueMeanEqualIdeal
std::vector< double > vPValueRMSEqualIdeal
static double textSize
Definition: TkAlStyle.h:103
int maxNumberOfLayers(int subdetector)
void setTitleStyle(TNamed &h, const char *titleX, const char *titleY, int subDetId, bool isSurfaceDeformation=false, TString secondline="")
static TString legendheader
Definition: TkAlStyle.h:101
double f[11][100]
void setDMRHistStyleAndLegend(TH1F *h, DMRPlotInfo &plotinfo, int direction=0, int layer=0)
Basic3DVector unit() const
std::vector< double > vPValueEqualSplitMeans
std::vector< TkOfflineVariables * > sourceList
void plotDMR(const std::string &plotVar="medianX", Int_t minHits=50, const std::string &options="plain", const std::string &filterName="", Float_t maxBadLumiPixel=0.5, Float_t maxBadLumiStrip=7.0)
int numberOfLayers(int phase, int subdetector)
void plotDMRHistogram(DMRPlotInfo &plotinfo, int direction=0, int layer=0, std::string subdet="")
std::vector< double > vdeltamean

◆ plotDMRHistogram()

void PlotAlignmentValidation::plotDMRHistogram ( PlotAlignmentValidation::DMRPlotInfo plotinfo,
int  direction = 0,
int  layer = 0,
std::string  subdet = "" 
)
private

Definition at line 2048 of file PlotAlignmentValidation.cc.

References gather_cfg::cout, PlotAlignmentValidation::DMRPlotInfo::filterName, TkOfflineVariables::getName(), getSelectionForDMRPlot(), TkOfflineVariables::getTree(), getVariableForDMRPlot(), h, PlotAlignmentValidation::DMRPlotInfo::h, PlotAlignmentValidation::DMRPlotInfo::h1, PlotAlignmentValidation::DMRPlotInfo::h2, mps_fire::i, nano_mu_digi_cff::layer, PlotAlignmentValidation::DMRPlotInfo::max, PlotAlignmentValidation::DMRPlotInfo::maxBadLumiPixel, PlotAlignmentValidation::DMRPlotInfo::maxBadLumiStrip, PlotAlignmentValidation::DMRPlotInfo::min, PlotAlignmentValidation::DMRPlotInfo::minHits, PlotAlignmentValidation::DMRPlotInfo::nbins, MillePedeFileConverter_cfg::out, SQLiteCheck_cfg::reader, corrVsCorr::selection, storeHistogramInRootfile(), AlCaHLTBitMon_QueryRunRegistry::string, PlotAlignmentValidation::DMRPlotInfo::subDetId, to_string(), parallelization::uint, PlotAlignmentValidation::DMRPlotInfo::variable, and PlotAlignmentValidation::DMRPlotInfo::vars.

Referenced by plotDMR().

2051  {
2052  TH1F* h = nullptr;
2053  //Create a name for the histogram that summarize all relevant information: name of the geometry, variable plotted, structure, layer, and whether the modules considered point inward or outward.
2054 
2055  TString histoname = "";
2056  if (plotinfo.variable == "medianX" || plotinfo.variable == "medianY")
2057  histoname = "median";
2058  else if (plotinfo.variable == "rmsNormX" || plotinfo.variable == "rmsNormY")
2059  histoname = "DrmsNR";
2060  histoname += "_";
2061  histoname += plotinfo.vars->getName();
2062  histoname.ReplaceAll(" ", "_");
2063  histoname += "_";
2064  histoname += subdet.c_str();
2065  if (plotinfo.variable == "medianY" || plotinfo.variable == "rmsNormY")
2066  histoname += "_y";
2067  if (layer != 0) {
2068  if (subdet == "TID" || subdet == "TEC")
2069  histoname += "_disc";
2070  else
2071  histoname += "_layer";
2072  histoname += std::to_string(layer);
2073  }
2074  if (direction == -1) {
2075  histoname += "_minus";
2076  } else if (direction == 1) {
2077  histoname += "_plus";
2078  } else {
2079  histoname += "";
2080  }
2081 
2082  //Plotting
2084  getVariableForDMRPlot(histoname.Data(), plotinfo.variable, plotinfo.nbins, plotinfo.min, plotinfo.max);
2085  std::string selection = "";
2086  if (plotinfo.filterName.empty()) {
2087  //Use only default selection and no filter
2088  selection = getSelectionForDMRPlot(plotinfo.minHits, plotinfo.subDetId, direction, layer);
2089  plotinfo.vars->getTree()->Draw(plotVariable.c_str(), selection.c_str(), "goff");
2090  if (gDirectory)
2091  gDirectory->GetObject(histoname.Data(), h);
2092  if (h && h->GetEntries() > 0) {
2093  if (direction == -1) {
2094  plotinfo.h1 = h;
2095  } else if (direction == 1) {
2096  plotinfo.h2 = h;
2097  } else {
2098  plotinfo.h = h;
2099  }
2100  }
2101  } else {
2102  plotinfo.vars->getTree()->Draw(
2103  plotVariable.c_str(), selection.c_str(), "goff"); //dummy to get the histogram structure
2104  if (gDirectory)
2105  gDirectory->GetObject(histoname.Data(), h);
2106  h->Reset();
2107  std::cout << "Module filter enabled." << std::endl;
2108  TTreeReader reader(plotinfo.vars->getTree());
2109  TTreeReaderValue<Float_t> varToPlot(reader, plotinfo.variable.c_str());
2110  TTreeReaderValue<unsigned int> _entries(reader, "entries");
2111  TTreeReaderValue<unsigned int> _subDetId(reader, "subDetId");
2112  TTreeReaderValue<unsigned int> _moduleId(reader, "moduleId");
2113  TTreeReaderValue<Float_t> _zDirection(reader, "zDirection");
2114  TTreeReaderValue<Float_t> _rDirection(reader, "rDirection");
2115  TTreeReaderValue<unsigned int> _layer(reader, "layer");
2116  std::string badModulesFile_ = plotinfo.filterName;
2117  TFile* fBadModules = new TFile(badModulesFile_.c_str(), "READ");
2118  TTree* tBadModules = (TTree*)fBadModules->Get("alignTree");
2119  TTreeReader readerBad(tBadModules);
2120  TTreeReaderValue<int> _valid(readerBad, "valid");
2121  TTreeReaderValue<int> _bad_id(readerBad, "id");
2122  TTreeReaderValue<double> _bad_lumi(readerBad, "lumi");
2123 
2124  //Record which modules were or were not used
2125  std::ofstream fUsedModules;
2126  std::ofstream fNotUsedModules;
2127  fUsedModules.open("usedModules.txt", std::ios::out | std::ios::app);
2128  fNotUsedModules.open("notUsedModules.txt", std::ios::out | std::ios::app);
2129 
2130  //Filter on modules by hand together with base selection
2131  for (uint i = 0; i < plotinfo.vars->getTree()->GetEntries(); i++) {
2132  reader.SetEntry(i);
2133  if (*_entries < uint(plotinfo.minHits))
2134  continue;
2135  if (*_subDetId != uint(plotinfo.subDetId))
2136  continue;
2137  if (direction != 0) {
2138  if (plotinfo.subDetId == 2) { // FPIX is split by zDirection
2139  if (*_zDirection != direction)
2140  continue;
2141  } else {
2142  if (*_rDirection != direction)
2143  continue;
2144  }
2145  }
2146  if (layer > 0) {
2147  if (*_layer != uint(layer))
2148  continue;
2149  }
2150  bool isBadModule = false;
2151  for (int ibad = 0; ibad < tBadModules->GetEntries(); ibad++) {
2152  readerBad.SetEntry(ibad);
2153  //if (*_valid == 0) {continue;} //only modules that failed 0 times are OK = very strict
2154  if (subdet == "BPIX" || subdet == "FPIX") {
2155  if (*_bad_lumi <= plotinfo.maxBadLumiPixel)
2156  continue;
2157  } else {
2158  if (*_bad_lumi <= plotinfo.maxBadLumiStrip)
2159  continue;
2160  }
2161  //modules that misbehave for less than XYZ are OK = mild strict
2162  if (*_moduleId == uint(*_bad_id))
2163  isBadModule = true;
2164  }
2165 
2166  if (isBadModule) {
2167  fNotUsedModules << *_moduleId << "\n";
2168  continue;
2169  }
2170  fUsedModules << *_moduleId << "\n";
2171  if (h) {
2172  h->Fill(*varToPlot);
2173  }
2174  }
2175 
2176  //Finalize
2177  fUsedModules.close();
2178  fNotUsedModules.close();
2179  fBadModules->Close();
2180  if (h) {
2181  h->SetName(histoname.Data());
2182  }
2183  }
2184 
2185  //Store histogram
2186  if (h && h->GetEntries() > 0) {
2187  if (direction == -1) {
2188  plotinfo.h1 = h;
2189  } else if (direction == 1) {
2190  plotinfo.h2 = h;
2191  } else {
2192  plotinfo.h = h;
2193  }
2194  }
2195  if (plotinfo.variable == "medianX" || plotinfo.variable == "medianY" || plotinfo.variable == "rmsNormX" ||
2196  plotinfo.variable == "rmsNormY") {
2198  }
2199 }
selection
main part
Definition: corrVsCorr.py:100
std::string getSelectionForDMRPlot(int minHits, int subDetId, int direction=0, int layer=0)
static std::string to_string(const XMLCh *ch)
std::string getVariableForDMRPlot(const std::string &histoname, const std::string &variable, int nbins, double min, double max)
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4

◆ plotHitMaps()

void PlotAlignmentValidation::plotHitMaps ( )

Definition at line 299 of file PlotAlignmentValidation.cc.

References DummyCfis::c, outputDir, sourceList, and AlCaHLTBitMon_QueryRunRegistry::string.

299  {
300  //gStyle->SetOptStat(0);
301 
302  TCanvas* c = new TCanvas("c", "c", 1200, 400);
303  c->Divide(3, 1);
304  //ps->NewPage();
305 
306  //-------------------------------------------------
307  //plot Hit map
308  //-------------------------------------------------
309  std::string histName_ = "Entriesprofile";
310  c->cd(1);
311  TTree* tree = (*sourceList.begin())->getTree();
312  tree->Draw("entries:posR:posZ", "", "COLZ2Prof");
313  c->cd(2);
314  tree->Draw("entries:posY:posX", "", "COLZ2Prof");
315  c->cd(3);
316  tree->Draw("entries:posR:posPhi", "", "COLZ2Prof");
317 
318  char PlotName[1000];
319  sprintf(PlotName, "%s/%s.png", outputDir.c_str(), histName_.c_str());
320  c->Print(PlotName);
321  sprintf(PlotName, "%s/%s.eps", outputDir.c_str(), histName_.c_str());
322  c->Print(PlotName);
323  sprintf(PlotName, "%s/%s.pdf", outputDir.c_str(), histName_.c_str());
324  c->Print(PlotName);
325  sprintf(PlotName, "%s/%s.root", outputDir.c_str(), histName_.c_str());
326  c->Print(PlotName);
327  // //c->Update();
328  c->Close();
329  //----------------------------------------------------
330 }
std::vector< TkOfflineVariables * > sourceList
Definition: tree.py:1

◆ plotOutlierModules()

void PlotAlignmentValidation::plotOutlierModules ( const char *  outputFileName = "OutlierModules.ps",
std::string  plotVariable = "chi2PerDofX",
float  chi2_cut = 10,
unsigned int  minHits = 50 
)

Definition at line 333 of file PlotAlignmentValidation.cc.

References alignmentValidation::c1, TkOffTreeVariables::chi2PerDofX, TkOffTreeVariables::chi2PerDofY, gather_cfg::cout, TkOffTreeVariables::entries, f, TkOffTreeVariables::fitMeanX, TkOffTreeVariables::fitMeanY, TkOffTreeVariables::fitSigmaX, TkOffTreeVariables::fitSigmaY, ws_sso_content_reader::getFile(), h, TkOffTreeVariables::histNameNormX, TkOffTreeVariables::histNameX, mps_fire::i, reco_skim_cfg_mod::minHits, outputDir, outputFile, makeListRunsInFiles::outputFileName, EnsembleCalibrationLA_cfg::path, sourceList, submitPVValidationJobs::text, and ALCARECOEcalPhiSym_cff::var.

336  {
337  Int_t counter = 0;
338 
339  gStyle->SetOptStat(111111);
340  gStyle->SetStatY(0.9);
341  //TList* treelist=getTreeList();
342 
343  TCanvas* c1 = new TCanvas("canv", "canv", 800, 500);
345  c1->Print((outputFile + '[').Data());
346 
347  c1->Divide(2, 1);
348 
349  TTree* tree = (*sourceList.begin())->getTree();
350  TkOffTreeVariables* treeMem = nullptr; // ROOT will initilise
351  tree->SetBranchAddress("TkOffTreeVariables", &treeMem);
352 
353  Long64_t nentries = tree->GetEntriesFast();
354 
355  for (Long64_t i = 0; i < nentries; i++) {
356  tree->GetEntry(i);
357  float var = 0;
358  if (plotVariable == "chi2PerDofX")
359  var = treeMem->chi2PerDofX;
360  else if (plotVariable == "chi2PerDofY")
361  var = treeMem->chi2PerDofY;
362  else if (plotVariable == "fitMeanX")
363  var = treeMem->fitMeanX;
364  else if (plotVariable == "fitMeanY")
365  var = treeMem->fitMeanY;
366  else if (plotVariable == "fitSigmaX")
367  var = treeMem->fitSigmaX;
368  else if (plotVariable == "fitSigmaY")
369  var = treeMem->fitSigmaY;
370  else {
371  std::cout << "There is no variable " << plotVariable << " included in the tree." << std::endl;
372  break;
373  }
374  // std::cout<<"treeMem->entries "<<treeMem->entries<<std::endl;
375  // std::cout<<"var "<<var<<std::endl;
376  // std::cout<<"plotVariable_cut "<<plotVariable_cut<<std::endl;
377 
378  if (var > plotVariable_cut && treeMem->entries > minHits) {
379  TFile* f = (*sourceList.begin())->getFile(); //(TFile*)sourcelist->First();
380 
381  if (f->FindKeyAny(treeMem->histNameX.c_str()) != nullptr) {
382  TH1* h =
383  (TH1*)f->FindKeyAny(treeMem->histNameX.c_str())->ReadObj(); //f->FindObjectAny(treeMem->histNameX.c_str());
384  gStyle->SetOptFit(0111);
385  std::cout << "hist name " << h->GetName() << std::endl;
386 
387  TString path = (char*)strstr(gDirectory->GetPath(), "TrackerOfflineValidation");
388  //std::cout<<"hist path "<<path<<std::endl;
389  //std::cout<<"wrote text "<<std::endl;
390  if (h)
391  std::cout << h->GetEntries() << std::endl;
392 
393  //modules' location as title
394  c1->cd(0);
395  TPaveText* text = new TPaveText(0, 0.95, 0.99, 0.99);
396  text->AddText(path);
397  text->SetFillColor(0);
398  text->SetShadowColor(0);
399  text->SetBorderSize(0);
400  text->Draw();
401 
402  //residual histogram
403  c1->cd(1);
404  TPad* subpad = (TPad*)c1->GetPad(1);
405  subpad->SetPad(0, 0, 0.5, 0.94);
406  h->Draw();
407 
408  //norm. residual histogram
409  h = (TH1*)f->FindObjectAny(treeMem->histNameNormX.c_str());
410  if (h)
411  std::cout << h->GetEntries() << std::endl;
412  c1->cd(2);
413  TPad* subpad2 = (TPad*)c1->GetPad(2);
414  subpad2->SetPad(0.5, 0, 0.99, 0.94);
415  h->Draw();
416 
417  c1->Print(outputFile);
418  counter++;
419  } else {
420  std::cout << "There are no residual histograms on module level stored!" << std::endl;
421  std::cout << "Please make sure that moduleLevelHistsTransient = cms.bool(False) in the validation job!"
422  << std::endl;
423  break;
424  }
425  }
426  }
427  c1->Print((outputFile + "]").Data());
428  if (counter == 0)
429  std::cout << "no bad modules found" << std::endl;
430 
431  //read the number of entries in the t3
432  //TTree* tree=0;
433  //tree=(TTree*)treeList->At(0);
434 
435  //c1->Close();
436 }
container to hold data to be written into TTree
double f[11][100]
std::vector< TkOfflineVariables * > sourceList
Definition: tree.py:1
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4

◆ plotSS()

void PlotAlignmentValidation::plotSS ( const std::string &  options = "layers",
const std::string &  variable = "" 
)
private

Definition at line 487 of file PlotAlignmentValidation.cc.

References addHists(), DummyCfis::c, DMR_cfg::cerr, gather_cfg::cout, f, nano_mu_digi_cff::layer, compareTotals::legend, maxNumberOfLayers(), modifySSHistAndLegend(), numberOfLayers(), outputDir, L1TEGammaDiff_cfi::plotName, corrVsCorr::selection, setTitleStyle(), and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by plotSurfaceShapes().

487  {
488  if (residType.empty()) {
489  plotSS(options, "ResXvsXProfile");
490  plotSS(options, "ResXvsYProfile");
491  return;
492  }
493 
494  int bkperrorx = gStyle->GetErrorX();
495  gStyle->SetErrorX(1); //regardless of style settings, we want x error bars here
496 
497  int plotLayerN = 0;
498  // int plotRingN = 0;
499  // bool plotPlain = false;
500  bool plotLayers = false; // overrides plotLayerN
501  // bool plotRings = false; // Todo: implement this?
502  int plotSubDetN = 0; // if zero, plot all
503 
504  TRegexp layer_re("layer=[0-9]+");
505  Ssiz_t index, len;
506  if (options.find("layers") != std::string::npos) {
507  plotLayers = true;
508  }
509  if ((index = layer_re.Index(options, &len)) != -1) {
510  if (plotLayers) {
511  std::cerr << "Warning: option 'layers' overrides 'layer=N'" << std::endl;
512  } else {
513  std::string substr = options.substr(index + 6, len - 6);
514  plotLayerN = atoi(substr.c_str());
515  }
516  }
517 
518  TRegexp subdet_re("subdet=[1-6]+");
519  if ((index = subdet_re.Index(options, &len)) != -1) {
520  std::string substr = options.substr(index + 7, len - 7);
521  plotSubDetN = atoi(substr.c_str());
522  }
523 
524  gStyle->SetOptStat(0);
525 
526  TCanvas c("canv", "canv");
527 
528  // todo: title, min/max, nbins?
529 
530  // Loop over detectors
531  for (int iSubDet = 1; iSubDet <= 6; ++iSubDet) {
532  // TEC requires special care since rings 1-4 and 5-7 are plotted separately
533  bool isTEC = (iSubDet == 6);
534 
535  // if subdet is specified, skip other subdets
536  if (plotSubDetN != 0 && iSubDet != plotSubDetN)
537  continue;
538 
539  // Skips plotting too high layers
540  // if it's a mixture of phase 0 and 1, the phase 0 files will be skipped
541  // when plotting the higher layers of BPIX and FPIX
542  if (plotLayerN > maxNumberOfLayers(iSubDet)) {
543  continue;
544  }
545 
546  int minlayer = plotLayers ? 1 : plotLayerN;
547  int maxlayer = plotLayers ? maxNumberOfLayers(iSubDet) : plotLayerN;
548  // see later where this is used
549  int maxlayerphase0 = plotLayers ? numberOfLayers(0, iSubDet) : plotLayerN;
550 
551  for (int layer = minlayer; layer <= maxlayer; layer++) {
552  // two plots for TEC, skip first
553  for (int iTEC = 0; iTEC < 2; iTEC++) {
554  if (!isTEC && iTEC == 0)
555  continue;
556 
557  char selection[1000];
558  if (!isTEC) {
559  if (layer == 0)
560  sprintf(selection, "subDetId==%d", iSubDet);
561  else
562  sprintf(selection, "subDetId==%d && layer == %d", iSubDet, layer);
563  } else { // TEC
564  if (iTEC == 0) // rings
565  sprintf(selection, "subDetId==%d && ring <= 4", iSubDet);
566  else
567  sprintf(selection, "subDetId==%d && ring > 4", iSubDet);
568  }
569 
570  // Title for plot and name for the file
571 
572  TString subDetName;
573  switch (iSubDet) {
574  case 1:
575  subDetName = "BPIX";
576  break;
577  case 2:
578  subDetName = "FPIX";
579  break;
580  case 3:
581  subDetName = "TIB";
582  break;
583  case 4:
584  subDetName = "TID";
585  break;
586  case 5:
587  subDetName = "TOB";
588  break;
589  case 6:
590  subDetName = "TEC";
591  break;
592  }
593 
594  TString secondline = "";
595  if (layer != 0) {
596  // TEC and TID have discs, the rest have layers
597  if (iSubDet == 4 || iSubDet == 6)
598  secondline = "disc ";
599  else {
600  secondline = "layer ";
601  }
602  secondline += Form("%d", layer);
603  secondline += " ";
604  }
605  if (isTEC && iTEC == 0)
606  secondline += TString("R1-4");
607  if (isTEC && iTEC > 0)
608  secondline += TString("R5-7");
609 
610  // Generate histograms with selection
611  TLegend* legend = nullptr;
612  // Any file from phase 0 will be skipped if the last argument is false
613  THStack* hs = addHists(selection, residType, &legend, false, /*validforphase0 = */ layer <= maxlayerphase0);
614  if (!hs || hs->GetHists() == nullptr || hs->GetHists()->GetSize() == 0) {
615  std::cout << "No histogram for " << subDetName << ", perhaps not enough data? Creating default histogram."
616  << std::endl;
617  if (hs == nullptr)
618  hs = new THStack("hstack", "");
619 
620  TProfile* defhist = new TProfile("defhist", "Empty default histogram", 100, -1, 1, -1, 1);
621  hs->Add(defhist);
622  hs->Draw();
623  } else {
624  hs->Draw("nostack PE");
626  legend->Draw();
627  setTitleStyle(*hs, "", "", iSubDet, true, secondline);
628 
629  // Adjust Labels
630  TH1* firstHisto = (TH1*)hs->GetHists()->First();
631  TString xName = firstHisto->GetXaxis()->GetTitle();
632  TString yName = firstHisto->GetYaxis()->GetTitle();
633  hs->GetHistogram()->GetXaxis()->SetTitleColor(kBlack);
634  hs->GetHistogram()->GetXaxis()->SetTitle(xName);
635  hs->GetHistogram()->GetYaxis()->SetTitleColor(kBlack);
636  // micrometers:
637  yName.ReplaceAll("cm", "#mum");
638  hs->GetHistogram()->GetYaxis()->SetTitle(yName);
639  }
640 
641  // Save plot to file
642  std::ostringstream plotName;
643  plotName << outputDir << "/SurfaceShape_" << subDetName << "_";
644  plotName << residType;
645  if (layer != 0) {
646  plotName << "_";
647  // TEC and TID have discs, the rest have layers
648  if (iSubDet == 4 || iSubDet == 6)
649  plotName << "disc";
650  else {
651  plotName << "layer";
652  }
653  plotName << layer;
654  }
655  if (isTEC && iTEC == 0)
656  plotName << "_"
657  << "R1-4";
658  if (isTEC && iTEC > 0)
659  plotName << "_"
660  << "R5-7";
661 
662  // PNG,EPS,PDF files
663  c.Update();
664  c.Print((plotName.str() + ".png").c_str());
665  c.Print((plotName.str() + ".eps").c_str());
666  c.Print((plotName.str() + ".pdf").c_str());
667 
668  // ROOT file
669  TFile f((plotName.str() + ".root").c_str(), "recreate");
670  c.Write();
671  f.Close();
672 
673  delete legend;
674  delete hs;
675  }
676  }
677  }
678  gStyle->SetErrorX(bkperrorx);
679 
680  return;
681 }
selection
main part
Definition: corrVsCorr.py:100
void plotSS(const std::string &options="layers", const std::string &variable="")
int maxNumberOfLayers(int subdetector)
void setTitleStyle(TNamed &h, const char *titleX, const char *titleY, int subDetId, bool isSurfaceDeformation=false, TString secondline="")
THStack * addHists(const TString &selection, const TString &residType="xPrime", TLegend **myLegend=nullptr, bool printModuleIds=false, bool validforphase0=false)
void modifySSHistAndLegend(THStack *hs, TLegend *legend)
double f[11][100]
int numberOfLayers(int phase, int subdetector)

◆ plotSubDetResiduals()

void PlotAlignmentValidation::plotSubDetResiduals ( bool  plotNormHisto = false,
unsigned int  subDetId = 7 
)

subDetector number :1.TPB, 2.TBE+, 3.TBE-, 4.TIB, 5.TID+, 6.TID-, 7.TOB, 8.TEC+ or 9.TEC-

Definition at line 203 of file PlotAlignmentValidation.cc.

References DummyCfis::c, HLT_2024v14_cff::Class, f, HltBtagPostValidation_cff::histoName, ALPAKA_ACCELERATOR_NAMESPACE::vertexFinder::it, outputDir, sourceList, dqmMemoryStats::stats, and GeomDetEnumerators::subDetId.

203  {
204  gStyle->SetOptStat(11111);
205  gStyle->SetOptFit(0000);
206 
207  TCanvas* c = new TCanvas("c", "c");
208  c->SetTopMargin(0.15);
209  TString histoName = "";
210  if (plotNormHisto) {
211  histoName = "h_NormXprime";
212  } else
213  histoName = "h_Xprime_";
214  switch (subDetId) {
215  case 1:
216  histoName += "TPBBarrel_0";
217  break;
218  case 2:
219  histoName += "TPEendcap_1";
220  break;
221  case 3:
222  histoName += "TPEendcap_2";
223  break;
224  case 4:
225  histoName += "TIBBarrel_0";
226  break;
227  case 5:
228  histoName += "TIDEndcap_1";
229  break;
230  case 6:
231  histoName += "TIDEndcap_2";
232  break;
233  case 7:
234  histoName += "TOBBarrel_3";
235  break;
236  case 8:
237  histoName += "TECEndcap_4";
238  break;
239  case 9:
240  histoName += "TECEndcap_5";
241  break;
242  }
243  int tmpcounter = 0;
244  TH1* sumHisto = nullptr;
245  for (std::vector<TkOfflineVariables*>::iterator it = sourceList.begin(); it != sourceList.end(); ++it) {
246  if (tmpcounter == 0) {
247  TFile* f = (*it)->getFile();
248  sumHisto = (TH1*)f->FindKeyAny(histoName)->ReadObj(); //FindObjectAny(histoName.Data());
249  sumHisto->SetLineColor(tmpcounter + 1);
250  sumHisto->SetLineStyle(tmpcounter + 1);
251  sumHisto->GetFunction("tmp")->SetBit(TF1::kNotDraw);
252  sumHisto->Draw();
253 
254  //get statistic box coordinate to plot all boxes one below the other
255  //gStyle->SetStatY(0.91);
256  //gStyle->SetStatW(0.15);
257  //gStyle->SetStatBorderSize(1);
258  //gStyle->SetStatH(0.10);
259 
260  tmpcounter++;
261  } else {
262  sumHisto = (TH1*)(*it)->getFile()->FindObjectAny(histoName);
263  sumHisto->SetLineColor(tmpcounter + 1);
264  sumHisto->SetLineStyle(tmpcounter + 1);
265  sumHisto->GetFunction("tmp")->SetBit(TF1::kNotDraw);
266  //hstack->Add(sumHisto);
267 
268  c->Update();
269  tmpcounter++;
270  }
271  TObject* statObj = sumHisto->GetListOfFunctions()->FindObject("stats");
272  if (statObj && statObj->InheritsFrom(TPaveStats::Class())) {
273  TPaveStats* stats = static_cast<TPaveStats*>(statObj);
274  stats->SetLineColor(tmpcounter + 1);
275  stats->SetTextColor(tmpcounter + 1);
276  stats->SetFillColor(10);
277  stats->SetX1NDC(0.91 - tmpcounter * 0.1);
278  stats->SetX2NDC(0.15);
279  stats->SetY1NDC(1);
280  stats->SetY2NDC(0.10);
281  sumHisto->Draw("sames");
282  }
283  }
284  //hstack->Draw("nostack");
285  char PlotName[1000];
286  sprintf(PlotName, "%s/%s.png", outputDir.c_str(), histoName.Data());
287  c->Print(PlotName);
288  sprintf(PlotName, "%s/%s.eps", outputDir.c_str(), histoName.Data());
289  c->Print(PlotName);
290  sprintf(PlotName, "%s/%s.pdf", outputDir.c_str(), histoName.Data());
291  c->Print(PlotName);
292  sprintf(PlotName, "%s/%s.root", outputDir.c_str(), histoName.Data());
293  c->Print(PlotName);
294  //delete c;
295  //c=0;
296 }
constexpr unsigned int subDetId[21]
double f[11][100]
std::vector< TkOfflineVariables * > sourceList

◆ plotSurfaceShapes()

void PlotAlignmentValidation::plotSurfaceShapes ( const std::string &  options = "layers",
const std::string &  variable = "" 
)

Definition at line 467 of file PlotAlignmentValidation.cc.

References gather_cfg::cout, and plotSS().

467  {
468  std::cout << "-------- plotSurfaceShapes called with " << options << std::endl;
469  if (options == "none")
470  return;
471  else if (options == "coarse") {
472  plotSS("subdet=1");
473  plotSS("subdet=2");
474  plotSS("subdet=3");
475  plotSS("subdet=4");
476  plotSS("subdet=5");
477  plotSS("subdet=6");
478  }
479  // else if (options == "fine") ...
480  else
481  plotSS(options, residType);
482 
483  return;
484 }
void plotSS(const std::string &options="layers", const std::string &variable="")

◆ resampleTestOfEqualMeans()

double PlotAlignmentValidation::resampleTestOfEqualMeans ( TH1F *  h1,
TH1F *  h2,
int  numSamples 
)
private

Definition at line 2307 of file PlotAlignmentValidation.cc.

References funct::abs(), ztail::d, d1, change_name::diff, mps_fire::i, and AlCaHLTBitMon_ParallelJobs::p.

Referenced by setDMRHistStyleAndLegend().

2307  {
2308  //vector to store realization of random variable
2309  std::vector<double> diff;
2310  diff.clear();
2311  //"true" (in bootstrap terms) difference of the samples' means
2312  double meandiff = abs(h1->GetMean() - h2->GetMean());
2313  //realization of random variable
2314  double d1 = 0;
2315  double d2 = 0;
2316  //mean of random variable
2317  double test_mean = 0;
2318  for (int i = 0; i < numSamples; i++) {
2319  d1 = 0;
2320  d2 = 0;
2321  for (int i = 0; i < h1->GetEntries(); i++) {
2322  d1 += h1->GetRandom();
2323  }
2324  for (int i = 0; i < h2->GetEntries(); i++) {
2325  d2 += h2->GetRandom();
2326  }
2327  d1 /= h1->GetEntries();
2328  d2 /= h2->GetEntries();
2329  diff.push_back(abs(d1 - d2 - meandiff));
2330  test_mean += abs(d1 - d2 - meandiff);
2331  }
2332  test_mean /= numSamples;
2333  edm::LogPrint("") << "test mean:" << test_mean;
2334  //p-value
2335  double p = 0;
2336  for (double d : diff) {
2337  if (d > meandiff) {
2338  p += 1;
2339  }
2340  }
2341 
2342  p /= numSamples;
2343  return p;
2344 }
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
Log< level::Warning, true > LogPrint
d
Definition: ztail.py:151
static constexpr float d1

◆ resampleTestOfEqualRMS()

double PlotAlignmentValidation::resampleTestOfEqualRMS ( TH1F *  h1,
TH1F *  h2,
int  numSamples 
)
private

Definition at line 2259 of file PlotAlignmentValidation.cc.

References funct::abs(), ztail::d, d1, change_name::diff, mps_fire::i, callgraph::m2, and AlCaHLTBitMon_ParallelJobs::p.

Referenced by setDMRHistStyleAndLegend().

2259  {
2260  //vector to store realizations of random variable
2261  std::vector<double> diff;
2262  diff.clear();
2263  //"true" (in bootstrap terms) difference of the samples' RMS
2264  double rmsdiff = abs(h1->GetRMS() - h2->GetRMS());
2265  //means of the samples to calculate RMS
2266  double m1 = h1->GetMean();
2267  double m2 = h2->GetMean();
2268  //realization of random variable
2269  double d1 = 0;
2270  double d2 = 0;
2271  //mean of random variable
2272  double test_mean = 0;
2273  for (int i = 0; i < numSamples; i++) {
2274  d1 = 0;
2275  d2 = 0;
2276  for (int i = 0; i < h1->GetEntries(); i++) {
2277  d1 += h1->GetRandom() - m1;
2278  }
2279  for (int i = 0; i < h2->GetEntries(); i++) {
2280  d2 += h2->GetRandom() + m2;
2281  }
2282  d1 /= h1->GetEntries();
2283  d2 /= h2->GetEntries();
2284  diff.push_back(abs(d1 - d2 - rmsdiff));
2285  test_mean += abs(d1 - d2 - rmsdiff);
2286  }
2287  test_mean /= numSamples;
2288  edm::LogPrint("") << "test mean:" << test_mean;
2289  //p value
2290  double p = 0;
2291  for (double d : diff) {
2292  if (d > rmsdiff) {
2293  p += 1;
2294  }
2295  }
2296 
2297  p /= numSamples;
2298  return p;
2299 }
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
Log< level::Warning, true > LogPrint
d
Definition: ztail.py:151
static constexpr float d1

◆ residual_by_moduleID()

void PlotAlignmentValidation::residual_by_moduleID ( unsigned int  moduleid)

Definition at line 2385 of file PlotAlignmentValidation.cc.

References geometryDiff::file, findmodule(), compareTotals::hist, ALPAKA_ACCELERATOR_NAMESPACE::vertexFinder::it, outputDir, sourceList, and to_string().

2385  {
2386  TCanvas* cx = new TCanvas("x_residual");
2387  TCanvas* cy = new TCanvas("y_residual");
2388  TLegend* legendx = new TLegend(0.55, 0.7, 1, 0.9);
2389  TLegend* legendy = new TLegend(0.55, 0.7, 1, 0.9);
2390 
2391  legendx->SetTextSize(0.016);
2392  legendx->SetTextAlign(12);
2393  legendy->SetTextSize(0.016);
2394  legendy->SetTextAlign(12);
2395 
2396  for (auto it : sourceList) {
2397  TFile* file = it->getFile();
2398  int color = it->getLineColor();
2399  int linestyle = it->getLineStyle(); //this you set by doing h->SetLineStyle(linestyle)
2400  TString legendname = it->getName(); //this goes in the legend
2401  std::vector<TH1*> hist = findmodule(file, moduleid);
2402 
2403  TString histnamex = legendname + " NEntries: " + std::to_string(int(hist[0]->GetEntries()));
2404  hist[0]->SetTitle(histnamex);
2405  hist[0]->SetStats(false);
2406  hist[0]->Rebin(50);
2407  hist[0]->SetBit(TH1::kNoTitle);
2408  hist[0]->SetLineColor(color);
2409  hist[0]->SetLineStyle(linestyle);
2410  cx->cd();
2411  hist[0]->Draw("Same");
2412  legendx->AddEntry(hist[0], histnamex, "l");
2413 
2414  TString histnamey = legendname + " NEntries: " + std::to_string(int(hist[1]->GetEntries()));
2415  hist[1]->SetTitle(histnamey);
2416  hist[1]->SetStats(false);
2417  hist[1]->Rebin(50);
2418  hist[1]->SetBit(TH1::kNoTitle);
2419  hist[1]->SetLineColor(color);
2420  hist[1]->SetLineStyle(linestyle);
2421  cy->cd();
2422  hist[1]->Draw("Same");
2423  legendy->AddEntry(hist[1], histnamey, "l");
2424  }
2425 
2426  TString filenamex = "x_residual_" + std::to_string(moduleid);
2427  TString filenamey = "y_residual_" + std::to_string(moduleid);
2428  cx->cd();
2429  legendx->Draw();
2430  cx->SaveAs(outputDir + "/" + filenamex + ".root");
2431  cx->SaveAs(outputDir + "/" + filenamex + ".pdf");
2432  cx->SaveAs(outputDir + "/" + filenamex + ".png");
2433  cx->SaveAs(outputDir + "/" + filenamex + ".eps");
2434 
2435  cy->cd();
2436  legendy->Draw();
2437  cy->SaveAs(outputDir + "/" + filenamey + ".root");
2438  cy->SaveAs(outputDir + "/" + filenamey + ".pdf");
2439  cy->SaveAs(outputDir + "/" + filenamey + ".png");
2440  cy->SaveAs(outputDir + "/" + filenamey + ".eps");
2441 }
std::vector< TH1 * > findmodule(TFile *f, unsigned int moduleid)
static std::string to_string(const XMLCh *ch)
std::vector< TkOfflineVariables * > sourceList

◆ scaleXaxis()

void PlotAlignmentValidation::scaleXaxis ( TH1 *  hist,
Int_t  scale 
)
private

◆ setCanvasStyle()

void PlotAlignmentValidation::setCanvasStyle ( TCanvas &  canv)
private

◆ setDMRHistStyleAndLegend()

void PlotAlignmentValidation::setDMRHistStyleAndLegend ( TH1F *  h,
PlotAlignmentValidation::DMRPlotInfo plotinfo,
int  direction = 0,
int  layer = 0 
)
private

plotinfo.plotLayers &&
plotinfo.plotLayers &&

Definition at line 1850 of file PlotAlignmentValidation.cc.

References PlotAlignmentValidation::DMRPlotInfo::firsthisto, fitGauss(), alignBH_cfg::fixed, ALCARECOEcalPhiSym_cff::float, TkOfflineVariables::getLineColor(), TkOfflineVariables::getLineStyle(), TkOfflineVariables::getName(), h, PlotAlignmentValidation::DMRPlotInfo::h, PlotAlignmentValidation::DMRPlotInfo::h1, PlotAlignmentValidation::DMRPlotInfo::h2, PlotAlignmentValidation::DMRPlotInfo::hstack, createfilelist::int, nano_mu_digi_cff::layer, PlotAlignmentValidation::DMRPlotInfo::legend, compareTotals::legend, PlotAlignmentValidation::DMRPlotInfo::maxY, SiStripPI::mean, dqmiodatasetharvest::nan, AlCaHLTBitMon_ParallelJobs::p, PlotAlignmentValidation::DMRPlotInfo::plotLayers, PlotAlignmentValidation::DMRPlotInfo::plotPlain, PlotAlignmentValidation::DMRPlotInfo::plotSplits, funct::pow(), resampleTestOfEqualMeans(), resampleTestOfEqualRMS(), SiStripPI::rms, scaleXaxis(), setHistStyle(), showMean_, showMeanError_, showModules_, showRMS_, showRMSError_, showUnderOverFlow_, mathSSE::sqrt(), PlotAlignmentValidation::DMRPlotInfo::subDetId, twolines_, units(), useFit_, vAlignmentUncertainty, PlotAlignmentValidation::DMRPlotInfo::variable, PlotAlignmentValidation::DMRPlotInfo::vars, vdeltamean, vmean, vmeanerror, vPValueEqualSplitMeans, vPValueMeanEqualIdeal, vPValueRMSEqualIdeal, and vrms.

Referenced by plotDMR().

1853  {
1854  TF1* fitResults = nullptr;
1855 
1856  h->SetDirectory(nullptr);
1857 
1858  // The whole DMR plot is plotted with wider line than the split plots
1859  // If only split plots are plotted, they will be stronger too, though
1860  h->SetLineWidth((direction == 0 || (plotinfo.plotSplits && !plotinfo.plotPlain)) ? 2 : 1);
1861 
1862  // These lines determine the style of the plots according to rules:
1863  // -If the plot is for direction != 0, +1 or +2 is added to the given style for distinction
1864  // -However if only direction split plots are to be plotted, the additions should be 0 and +1 respectively
1865  // -Modulo 4 arithmetic, because the styles run from 1..4
1866  int linestyle = plotinfo.vars->getLineStyle() - 1, linestyleplus = 0;
1867  if (direction == 1) {
1868  linestyleplus = 1;
1869  }
1870  if (direction == -1) {
1871  linestyleplus = 2;
1872  }
1873  if (direction != 0 && plotinfo.plotSplits && !plotinfo.plotPlain) {
1874  linestyleplus--;
1875  }
1876  linestyle = (linestyle + linestyleplus) % 4 + 1;
1877 
1878  int linecolor = plotinfo.vars->getLineColor();
1879  if (plotinfo.plotLayers && layer > 0) {
1880  linecolor += layer - 1;
1881  }
1882 
1883  if (plotinfo.firsthisto) {
1884  setHistStyle(*h, plotinfo.variable.c_str(), "#modules", 1); //set color later
1885  plotinfo.firsthisto = false;
1886  }
1887 
1888  h->SetLineColor(linecolor);
1889  h->SetLineStyle(linestyle);
1890 
1891  if (plotinfo.maxY < h->GetMaximum()) {
1892  plotinfo.maxY = h->GetMaximum();
1893  }
1894 
1895  //fit histogram for median and mean
1896  if (plotinfo.variable == "medianX" || plotinfo.variable == "meanX" || plotinfo.variable == "medianY" ||
1897  plotinfo.variable == "meanY") {
1898  fitResults = fitGauss(h, linecolor);
1899  }
1900 
1901  plotinfo.hstack->Add(h);
1902 
1903  std::ostringstream legend;
1904  legend.precision(3);
1905  legend << std::fixed; // to always show 3 decimals
1906 
1907  // Legend: header part
1908  if (direction == -1 && plotinfo.subDetId != 2) {
1909  legend << "rDirection < 0";
1910  } else if (direction == 1 && plotinfo.subDetId != 2) {
1911  legend << "rDirection > 0";
1912  } else if (direction == -1 && plotinfo.subDetId == 2) {
1913  legend << "zDirection < 0";
1914  } else if (direction == 1 && plotinfo.subDetId == 2) {
1915  legend << "zDirection > 0";
1916  } else {
1917  legend << plotinfo.vars->getName();
1918  if (layer > 0) {
1919  // TEC and TID have discs, the rest have layers
1920  if (plotinfo.subDetId == 4 || plotinfo.subDetId == 6)
1921  legend << ", disc ";
1922  else
1923  legend << ", layer ";
1924  legend << layer << "";
1925  }
1926  }
1927 
1928  plotinfo.legend->AddEntry(h, legend.str().c_str(), "l");
1929  legend.str("");
1930 
1931  // Legend: Statistics
1932  double mean = 0.0, meanerror = 0.0, rms = 0.0, rmserror = 0.0;
1933  TString rmsname, units;
1934  bool showdeltamu =
1935  (plotinfo.h1 != nullptr && plotinfo.h2 != nullptr && plotinfo.plotSplits && plotinfo.plotPlain && direction == 0);
1936  if (plotinfo.variable == "medianX" || plotinfo.variable == "meanX" || plotinfo.variable == "medianY" ||
1937  plotinfo.variable == "meanY" || plotinfo.variable == "rmsX" || plotinfo.variable == "rmsY") {
1938  if (useFit_ && fitResults) {
1939  mean = fitResults->GetParameter(1) * 10000;
1940  meanerror = fitResults->GetParError(1) * 10000;
1941  rms = fitResults->GetParameter(2) * 10000;
1942  rmserror = fitResults->GetParError(2) * 10000;
1943  rmsname = "#sigma";
1944  delete fitResults;
1945  } else {
1946  mean = h->GetMean(1) * 10000;
1947  meanerror = h->GetMeanError(1) * 10000;
1948  rms = h->GetRMS(1) * 10000;
1949  rmserror = h->GetRMSError(1) * 10000;
1950  rmsname = "rms";
1951  }
1952  units = " #mum";
1953  } else if (plotinfo.variable == "meanNormX" || plotinfo.variable == "meanNormY" || plotinfo.variable == "rmsNormX" ||
1954  plotinfo.variable == "rmsNormY") {
1955  mean = h->GetMean(1);
1956  meanerror = h->GetMeanError(1);
1957  rms = h->GetRMS(1);
1958  rmserror = h->GetRMSError(1);
1959  rmsname = "rms";
1960  units = "";
1961  }
1962  if (showMean_) {
1963  legend << " #mu = " << mean;
1964  if (showMeanError_)
1965  legend << " #pm " << meanerror;
1966  legend << units;
1967  if (showRMS_ || showdeltamu || ((showModules_ || showUnderOverFlow_) && !twolines_))
1968  legend << ", ";
1969  }
1970  if (showRMS_) {
1971  legend << " " << rmsname << " = " << rms;
1972  if (showRMSError_)
1973  legend << " #pm " << rmserror;
1974  legend << units;
1975  if (showdeltamu || ((showModules_ || showUnderOverFlow_) && !twolines_))
1976  legend << ", ";
1977  }
1978 
1979  if ((plotinfo.variable == "medianX" || plotinfo.variable == "medianY") && layer == 0 &&
1980  direction == 0) {
1981  vmean.push_back(mean);
1982  vrms.push_back(rms);
1983  vmeanerror.push_back(meanerror);
1984  TH1F* ideal = (TH1F*)plotinfo.hstack->GetHists()->At(0);
1985  TH1F* h = plotinfo.h;
1986  if (h->GetRMS() >= ideal->GetRMS()) {
1987  vAlignmentUncertainty.push_back(sqrt(pow(h->GetRMS(), 2) - pow(ideal->GetRMS(), 2)));
1988  } else {
1989  vAlignmentUncertainty.push_back(nan(""));
1990  }
1991  float p = (float)resampleTestOfEqualMeans(ideal, h, 10000);
1992  vPValueMeanEqualIdeal.push_back(p);
1993  p = resampleTestOfEqualRMS(ideal, h, 10000);
1994  vPValueRMSEqualIdeal.push_back(p);
1995  }
1996 
1997  // Legend: Delta mu for split plots
1998  if (showdeltamu) {
1999  float factor = 10000.0f;
2000  if (plotinfo.variable == "meanNormX" || plotinfo.variable == "meanNormY" || plotinfo.variable == "rmsNormX" ||
2001  plotinfo.variable == "rmsNormY") {
2002  factor = 1.0f;
2003  }
2004  float deltamu = factor * (plotinfo.h2->GetMean(1) - plotinfo.h1->GetMean(1));
2005  legend << "#Delta#mu = " << deltamu << units;
2007  legend << ", ";
2008 
2009  if ((plotinfo.variable == "medianX" || plotinfo.variable == "medianY") && layer == 0 &&
2010  direction == 0) {
2011  vdeltamean.push_back(deltamu);
2012  if (plotinfo.h1->GetEntries() && plotinfo.h2->GetEntries()) {
2013  float p = (float)resampleTestOfEqualMeans(plotinfo.h1, plotinfo.h2, 10000);
2014  vPValueEqualSplitMeans.push_back(p);
2015  }
2016  }
2017  }
2018 
2019  if (twolines_) {
2020  plotinfo.legend->AddEntry((TObject*)nullptr, legend.str().c_str(), "");
2021  plotinfo.legend->AddEntry((TObject*)nullptr, "", "");
2022  legend.str("");
2023  }
2024 
2025  if (!showUnderOverFlow_ && showModules_) {
2026  legend << (int)h->GetEntries() << " modules";
2027  }
2028  if (showUnderOverFlow_) {
2029  if (showModules_) {
2030  legend << (int)h->GetEntries() << " modules ("
2031  << (int)h->GetBinContent(0) + (int)h->GetBinContent(h->GetNbinsX() + 1) << " outside range)";
2032  } else {
2033  legend << (int)h->GetBinContent(0) + (int)h->GetBinContent(h->GetNbinsX() + 1) << " modules outside range";
2034  }
2035  }
2036  plotinfo.legend->AddEntry((TObject*)nullptr, legend.str().c_str(), "");
2037 
2038  // Scale the x-axis (cm to um), if needed
2039  if (plotinfo.variable.find("Norm") == std::string::npos)
2040  scaleXaxis(h, 10000);
2041 }
std::vector< double > vAlignmentUncertainty
std::vector< double > vmeanerror
void scaleXaxis(TH1 *hist, Int_t scale)
void setHistStyle(TH1 &hist, const char *titleX, const char *titleY, int color)
std::vector< double > vPValueMeanEqualIdeal
std::vector< double > vPValueRMSEqualIdeal
TF1 * fitGauss(TH1 *hist, int color)
T sqrt(T t)
Definition: SSEVec.h:23
double resampleTestOfEqualMeans(TH1F *h1, TH1F *h2, int numSamples)
std::vector< double > vPValueEqualSplitMeans
TString units(TString variable, Char_t axis)
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4
std::vector< double > vdeltamean
double resampleTestOfEqualRMS(TH1F *h1, TH1F *h2, int numSamples)
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:29

◆ setHistStyle()

void PlotAlignmentValidation::setHistStyle ( TH1 &  hist,
const char *  titleX,
const char *  titleY,
int  color 
)
private

Definition at line 1754 of file PlotAlignmentValidation.cc.

References pileupCalc::binning, HLT_2024v14_cff::Class, and compareTotals::hist.

Referenced by plotDMR(), and setDMRHistStyleAndLegend().

1754  {
1755  std::stringstream title_Xaxis;
1756  std::stringstream title_Yaxis;
1757  TString titleXAxis = titleX;
1758  TString titleYAxis = titleY;
1759 
1760  if (titleXAxis.Contains("Phi"))
1761  title_Xaxis << titleX << "[rad]";
1762  else if (titleXAxis.Contains("meanX"))
1763  title_Xaxis << "#LTx'_{pred}-x'_{hit}#GT[#mum]";
1764  else if (titleXAxis.Contains("meanY"))
1765  title_Xaxis << "#LTy'_{pred}-y'_{hit}#GT[#mum]";
1766  else if (titleXAxis.Contains("rmsX"))
1767  title_Xaxis << "RMS(x'_{pred}-x'_{hit})[#mum]";
1768  else if (titleXAxis.Contains("rmsY"))
1769  title_Xaxis << "RMS(y'_{pred}-y'_{hit})[#mum]";
1770  else if (titleXAxis.Contains("meanNormX"))
1771  title_Xaxis << "#LTx'_{pred}-x'_{hit}/#sigma#GT";
1772  else if (titleXAxis.Contains("meanNormY"))
1773  title_Xaxis << "#LTy'_{pred}-y'_{hit}/#sigma#GT";
1774  else if (titleXAxis.Contains("rmsNormX"))
1775  title_Xaxis << "RMS(x'_{pred}-x'_{hit}/#sigma)";
1776  else if (titleXAxis.Contains("rmsNormY"))
1777  title_Xaxis << "RMS(y'_{pred}-y'_{hit}/#sigma)";
1778  else if (titleXAxis.Contains("meanLocalX"))
1779  title_Xaxis << "#LTx_{pred}-x_{hit}#GT[#mum]";
1780  else if (titleXAxis.Contains("rmsLocalX"))
1781  title_Xaxis << "RMS(x_{pred}-x_{hit})[#mum]";
1782  else if (titleXAxis.Contains("meanNormLocalX"))
1783  title_Xaxis << "#LTx_{pred}-x_{hit}/#sigma#GT[#mum]";
1784  else if (titleXAxis.Contains("rmsNormLocalX"))
1785  title_Xaxis << "RMS(x_{pred}-x_{hit}/#sigma)[#mum]";
1786  else if (titleXAxis.Contains("medianX"))
1787  title_Xaxis << "median(x'_{pred}-x'_{hit})[#mum]";
1788  else if (titleXAxis.Contains("medianY"))
1789  title_Xaxis << "median(y'_{pred}-y'_{hit})[#mum]";
1790  else
1791  title_Xaxis << titleX << "[cm]";
1792 
1793  if (hist.IsA()->InheritsFrom(TH1F::Class()))
1794  hist.SetLineColor(color);
1795  if (hist.IsA()->InheritsFrom(TProfile::Class())) {
1796  hist.SetMarkerStyle(20);
1797  hist.SetMarkerSize(0.8);
1798  hist.SetMarkerColor(color);
1799  }
1800 
1801  hist.GetXaxis()->SetTitle((title_Xaxis.str()).c_str());
1802 
1803  double binning = (hist.GetXaxis()->GetXmax() - hist.GetXaxis()->GetXmin()) / hist.GetNbinsX();
1804  title_Yaxis.precision(2);
1805 
1806  if (((titleYAxis.Contains("layer") || titleYAxis.Contains("ring")) && titleYAxis.Contains("subDetId")) ||
1807  titleYAxis.Contains("#modules")) {
1808  title_Yaxis << "number of modules";
1809  if (TString(title_Xaxis.str()).Contains("[#mum]"))
1810  title_Yaxis << " / " << binning << " #mum";
1811  else if (TString(title_Xaxis.str()).Contains("[cm]"))
1812  title_Yaxis << " / " << binning << " cm";
1813  else
1814  title_Yaxis << " / " << binning;
1815  } else
1816  title_Yaxis << titleY << "[cm]";
1817 
1818  hist.GetYaxis()->SetTitle((title_Yaxis.str()).c_str());
1819 
1820  hist.GetXaxis()->SetTitleFont(42);
1821  hist.GetYaxis()->SetTitleFont(42);
1822 }

◆ setLegendStyle()

void PlotAlignmentValidation::setLegendStyle ( TLegend &  leg)
private

◆ setNiceStyle()

void PlotAlignmentValidation::setNiceStyle ( )
private

◆ setOutputDir()

void PlotAlignmentValidation::setOutputDir ( std::string  dir)

Definition at line 190 of file PlotAlignmentValidation.cc.

References cms::cuda::assert(), gather_cfg::cout, DeadROC_duringRun::dir, openedsummaryfile, and outputDir.

Referenced by PlotAlignmentValidation().

190  {
191  if (openedsummaryfile) {
192  std::cout << "Can't set the output dir after opening the summary file!" << std::endl;
193  assert(0);
194  }
195  outputDir = dir;
196  gSystem->mkdir(outputDir.data(), true);
197 }
assert(be >=bs)

◆ setTitleStyle()

void PlotAlignmentValidation::setTitleStyle ( TNamed &  h,
const char *  titleX,
const char *  titleY,
int  subDetId,
bool  isSurfaceDeformation = false,
TString  secondline = "" 
)
private

Definition at line 1695 of file PlotAlignmentValidation.cc.

References gather_cfg::cout, TkAlStyle::drawStandardTitle(), compareTotals::hist, and GeomDetEnumerators::subDetId.

Referenced by plotDMR(), and plotSS().

1696  {
1697  std::stringstream title_Xaxis;
1698  std::stringstream title_Yaxis;
1699  TString titleXAxis = titleX;
1700  TString titleYAxis = titleY;
1701  if (titleXAxis != "" && titleYAxis != "")
1702  std::cout << "plot " << titleXAxis << " vs " << titleYAxis << std::endl;
1703 
1704  hist.SetTitle("");
1706 
1707  //Thanks Candice!
1708  TString subD;
1709  switch (subDetId) {
1710  case 1:
1711  subD = "BPIX";
1712  break;
1713  case 2:
1714  subD = "FPIX";
1715  break;
1716  case 3:
1717  subD = "TIB";
1718  break;
1719  case 4:
1720  subD = "TID";
1721  break;
1722  case 5:
1723  subD = "TOB";
1724  break;
1725  case 6:
1726  subD = "TEC";
1727  break;
1728  }
1729 
1730  TPaveText* text2;
1731  if (!isSurfaceDeformation) {
1732  text2 = new TPaveText(0.7, 0.3, 0.9, 0.6, "brNDC");
1733  } else {
1734  std::cout << "Surface Deformation" << std::endl;
1735  text2 = new TPaveText(0.8, 0.75, 0.9, 0.9, "brNDC");
1736  }
1737  text2->SetTextSize(0.06);
1738  text2->SetTextFont(42);
1739  text2->SetFillStyle(0);
1740  text2->SetBorderSize(0);
1741  text2->SetMargin(0.01);
1742  text2->SetTextAlign(12); // align left
1743  text2->AddText(0.01, 0.75, subD);
1744  if (secondline != "") {
1745  text2->AddText(0.01, 0.25, secondline);
1746  }
1747  text2->Draw();
1748 }
constexpr unsigned int subDetId[21]
static void drawStandardTitle()
Definition: TkAlStyle.h:75

◆ setTreeBaseDir()

void PlotAlignmentValidation::setTreeBaseDir ( std::string  dir = "TrackerOfflineValidation")

◆ storeHistogramInRootfile()

void PlotAlignmentValidation::storeHistogramInRootfile ( TH1 *  hist)
private

Definition at line 1665 of file PlotAlignmentValidation.cc.

References compareTotals::hist, and rootsummaryfile.

Referenced by plotDMRHistogram().

1665  {
1666  //Store histogram and fit function in the root summary file
1667  rootsummaryfile->cd();
1668  hist->Write();
1669 }

◆ twotailedStudentTTestEqualMean()

float PlotAlignmentValidation::twotailedStudentTTestEqualMean ( float  t,
float  v 
)

These are helpers for DMR plotting

Definition at line 2346 of file PlotAlignmentValidation.cc.

References funct::abs(), submitPVValidationJobs::t, and findQualityFiles::v.

2346  {
2347  return 2 * (1 - ROOT::Math::tdistribution_cdf(abs(t), v));
2348 }
Abs< T >::type abs(const T &t)
Definition: Abs.h:22

◆ useFitForDMRplots()

void PlotAlignmentValidation::useFitForDMRplots ( bool  usefit = false)

Definition at line 97 of file PlotAlignmentValidation.cc.

References useFit_.

Member Data Documentation

◆ bigtext_

bool PlotAlignmentValidation::bigtext_
private

Definition at line 191 of file PlotAlignmentValidation.h.

Referenced by legendOptions(), modifySSHistAndLegend(), and plotDMR().

◆ fileCounter

int PlotAlignmentValidation::fileCounter
private

Definition at line 230 of file PlotAlignmentValidation.h.

◆ fileNames

std::string PlotAlignmentValidation::fileNames[10]
private

Definition at line 229 of file PlotAlignmentValidation.h.

◆ moreThanOneSource

bool PlotAlignmentValidation::moreThanOneSource
private

Definition at line 228 of file PlotAlignmentValidation.h.

Referenced by getTreeList(), and PlotAlignmentValidation().

◆ openedsummaryfile

bool PlotAlignmentValidation::openedsummaryfile = false
private

Definition at line 194 of file PlotAlignmentValidation.h.

Referenced by loadFileList(), openSummaryFile(), and setOutputDir().

◆ outputDir

std::string PlotAlignmentValidation::outputDir
private

◆ outputFile

TString PlotAlignmentValidation::outputFile
private

◆ rootsummaryfile

TFile* PlotAlignmentValidation::rootsummaryfile
private

Definition at line 195 of file PlotAlignmentValidation.h.

Referenced by openSummaryFile(), and storeHistogramInRootfile().

◆ showMean_

bool PlotAlignmentValidation::showMean_
private

Definition at line 184 of file PlotAlignmentValidation.h.

Referenced by legendOptions(), and setDMRHistStyleAndLegend().

◆ showMeanError_

bool PlotAlignmentValidation::showMeanError_
private

Definition at line 186 of file PlotAlignmentValidation.h.

Referenced by legendOptions(), and setDMRHistStyleAndLegend().

◆ showModules_

bool PlotAlignmentValidation::showModules_
private

Definition at line 188 of file PlotAlignmentValidation.h.

Referenced by legendOptions(), and setDMRHistStyleAndLegend().

◆ showRMS_

bool PlotAlignmentValidation::showRMS_
private

Definition at line 185 of file PlotAlignmentValidation.h.

Referenced by legendOptions(), and setDMRHistStyleAndLegend().

◆ showRMSError_

bool PlotAlignmentValidation::showRMSError_
private

Definition at line 187 of file PlotAlignmentValidation.h.

Referenced by legendOptions(), and setDMRHistStyleAndLegend().

◆ showUnderOverFlow_

bool PlotAlignmentValidation::showUnderOverFlow_
private

Definition at line 189 of file PlotAlignmentValidation.h.

Referenced by legendOptions(), and setDMRHistStyleAndLegend().

◆ sourcelist

TList* PlotAlignmentValidation::sourcelist
private

◆ sourceList

std::vector<TkOfflineVariables*> PlotAlignmentValidation::sourceList
private

◆ summaryfile

std::ofstream PlotAlignmentValidation::summaryfile
private

Definition at line 193 of file PlotAlignmentValidation.h.

Referenced by openSummaryFile(), plotChi2(), and plotDMR().

◆ summaryfilename

const TString PlotAlignmentValidation::summaryfilename = "OfflineValidationSummary"
staticprivate

Definition at line 192 of file PlotAlignmentValidation.h.

Referenced by openSummaryFile().

◆ treeBaseDir

std::string PlotAlignmentValidation::treeBaseDir
private

Definition at line 181 of file PlotAlignmentValidation.h.

Referenced by getTreeList(), loadFileList(), and setTreeBaseDir().

◆ twolines_

bool PlotAlignmentValidation::twolines_
private

Definition at line 190 of file PlotAlignmentValidation.h.

Referenced by legendOptions(), plotDMR(), and setDMRHistStyleAndLegend().

◆ useFit_

bool PlotAlignmentValidation::useFit_
private

◆ vAlignmentUncertainty

std::vector<double> PlotAlignmentValidation::vAlignmentUncertainty
private

Definition at line 197 of file PlotAlignmentValidation.h.

Referenced by plotDMR(), and setDMRHistStyleAndLegend().

◆ vdeltamean

std::vector<double> PlotAlignmentValidation::vdeltamean
private

Definition at line 197 of file PlotAlignmentValidation.h.

Referenced by plotDMR(), and setDMRHistStyleAndLegend().

◆ vmean

std::vector<double> PlotAlignmentValidation::vmean
private

Definition at line 197 of file PlotAlignmentValidation.h.

Referenced by plotDMR(), and setDMRHistStyleAndLegend().

◆ vmeanerror

std::vector<double> PlotAlignmentValidation::vmeanerror
private

Definition at line 197 of file PlotAlignmentValidation.h.

Referenced by plotDMR(), and setDMRHistStyleAndLegend().

◆ vPValueEqualSplitMeans

std::vector<double> PlotAlignmentValidation::vPValueEqualSplitMeans
private

Definition at line 197 of file PlotAlignmentValidation.h.

Referenced by plotDMR(), and setDMRHistStyleAndLegend().

◆ vPValueMeanEqualIdeal

std::vector<double> PlotAlignmentValidation::vPValueMeanEqualIdeal
private

Definition at line 197 of file PlotAlignmentValidation.h.

Referenced by plotDMR(), and setDMRHistStyleAndLegend().

◆ vPValueRMSEqualIdeal

std::vector<double> PlotAlignmentValidation::vPValueRMSEqualIdeal
private

Definition at line 197 of file PlotAlignmentValidation.h.

Referenced by plotDMR(), and setDMRHistStyleAndLegend().

◆ vrms

std::vector<double> PlotAlignmentValidation::vrms
private

Definition at line 197 of file PlotAlignmentValidation.h.

Referenced by plotDMR(), and setDMRHistStyleAndLegend().