CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
PrepareDMRTrends Class Reference

#include <PrepareDMRTrends.h>

Public Member Functions

void compileDMRTrends (std::vector< int > IOVlist, TString Variable, std::vector< std::string > inputFiles, std::vector< TString > structures, const std::map< TString, int > nlayers, bool FORCE=false)
 
TString getName (TString structure, int layer, TString geometry)
 
 PrepareDMRTrends (const char *outputFileName, boost::property_tree::ptree &json)
 
 ~PrepareDMRTrends ()
 

Private Attributes

std::vector< std::string > geometries
 
const char * outputFileName_
 

Detailed Description

Definition at line 148 of file PrepareDMRTrends.h.

Constructor & Destructor Documentation

◆ PrepareDMRTrends()

PrepareDMRTrends::PrepareDMRTrends ( const char *  outputFileName,
boost::property_tree::ptree &  json 
)

Definition at line 7 of file PrepareDMRTrends.cc.

References geometries, and AlCaHLTBitMon_QueryRunRegistry::string.

8  geometries.clear();
9  for (const auto &childTree : json) {
10  geometries.push_back(childTree.second.get<std::string>("title"));
11  }
12 }
std::vector< std::string > geometries
nlohmann::json json
const char * outputFileName_

◆ ~PrepareDMRTrends()

PrepareDMRTrends::~PrepareDMRTrends ( )
inline

Definition at line 151 of file PrepareDMRTrends.h.

151 {}

Member Function Documentation

◆ compileDMRTrends()

void PrepareDMRTrends::compileDMRTrends ( std::vector< int >  IOVlist,
TString  Variable,
std::vector< std::string >  inputFiles,
std::vector< TString >  structures,
const std::map< TString, int >  nlayers,
bool  FORCE = false 
)

Definition at line 36 of file PrepareDMRTrends.cc.

References gather_cfg::cout, Geometry::DeltaMu(), DMRFactor, f, groupFilesInBlocks::fout, g, relativeConstraints::geom, geometries, getName(), timingPdfMaker::histo, mps_fire::i, crabTemplate::inputFiles, utils::is_empty(), nano_mu_digi_cff::layer, Geometry::Mu(), Geometry::MuMinus(), Geometry::MuPlus(), create_idmaps::n, mergeVDriftHistosByStation::name, outputFileName_, point, writedatasetfile::runs, Geometry::Sigma(), Geometry::SigmaDeltaMu(), Geometry::SigmaMinus(), Geometry::SigmaPlus(), trends(), and EcalPhiSymFlatTableProducers_cfi::variables.

Referenced by trends().

41  {
42  gROOT->SetBatch();
43 
44  float ScaleFactor = DMRFactor;
45  if (Variable == "DrmsNR")
46  ScaleFactor = 1;
47 
48  map<pair<pair<TString, int>, TString>, Geometry> mappoints; // pair = (structure, layer), geometry
49  Point *point = nullptr;
50  TFile *f = nullptr;
51 
52  for (unsigned int i = 0; i < inputFiles.size(); ++i) {
53  if (fs::is_empty(inputFiles.at(i).c_str())) {
54  cout << "ERROR: Empty file " << inputFiles.at(i).c_str() << endl;
55  continue;
56  }
57 
58  int runN = IOVlist.at(i);
59 
60  f = new TFile(inputFiles.at(i).c_str(), "READ");
61  std::cout << inputFiles.at(i) << std::endl;
62 
63  for (TString &structure : structures) {
64  TString structname = structure;
65  structname.ReplaceAll("_y", "");
66  size_t layersnumber = nlayers.at(structname);
67  for (size_t layer = 0; layer <= layersnumber; layer++) {
68  for (const string &geometry : geometries) {
69  TString name = Variable + "_" + getName(structure, layer, geometry);
70  TH1F *histo = dynamic_cast<TH1F *>(f->Get(name));
71 
72  // Three possibilities:
73  // - All histograms are produced correctly
74  // - Only the non-split histograms are produced
75  // - No histogram is produced correctly
76  // FORCE means that the Point is not added to the points collection in the chosen geometry for that structure
77  // If FORCE is not enabled a default value for the Point is used (-9999) which will appear in the plots
78  if (!histo) {
79  //cout << "Run" << runN << " Histogram: " << name << " not found" << endl;
80  if (FORCE)
81  continue;
82  point = new Point(runN, ScaleFactor);
83  } else if (structure != "TID" && structure != "TEC") {
84  TH1F *histoplus = dynamic_cast<TH1F *>(f->Get((name + "_plus")));
85  TH1F *histominus = dynamic_cast<TH1F *>(f->Get((name + "_minus")));
86  if (!histoplus || !histominus) {
87  //cout << "Run" << runN << " Histogram: " << name << " plus or minus not found" << endl;
88  if (FORCE)
89  continue;
90  point = new Point(runN, ScaleFactor, histo);
91  } else
92  point = new Point(runN, ScaleFactor, histo, histoplus, histominus);
93 
94  } else
95  point = new Point(runN, ScaleFactor, histo);
96  mappoints[make_pair(make_pair(structure, layer), geometry)].points.push_back(*point);
97  }
98  }
99  }
100  f->Close();
101  }
102 
103  TFile *fout = TFile::Open(outputFileName_, "RECREATE");
104  TGraphErrors *g = nullptr;
105  for (TString &structure : structures) {
106  TString structname = structure;
107  structname.ReplaceAll("_y", "");
108  size_t layersnumber = nlayers.at(structname);
109  for (size_t layer = 0; layer <= layersnumber; layer++) {
110  for (const string &geometry : geometries) {
111  TString name = Variable + "_" + getName(structure, layer, geometry);
112  Geometry geom = mappoints[make_pair(make_pair(structure, layer), geometry)];
113  using Trend = vector<float> (Geometry::*)() const;
114  vector<Trend> trends{&Geometry::Mu,
122  vector<TString> variables{
123  "mu", "sigma", "muplus", "sigmaplus", "muminus", "sigmaminus", "deltamu", "sigmadeltamu"};
124  vector<float> runs = geom.Run();
125  size_t n = runs.size();
126  vector<float> emptyvec;
127  for (size_t i = 0; i < runs.size(); i++)
128  emptyvec.push_back(0.);
129  for (size_t iVar = 0; iVar < variables.size(); iVar++) {
130  Trend trend = trends.at(iVar);
131  g = new TGraphErrors(n, runs.data(), (geom.*trend)().data(), emptyvec.data(), emptyvec.data());
132  g->SetTitle(geometry.c_str());
133  g->Write(name + "_" + variables.at(iVar));
134  }
135  vector<pair<Trend, Trend>> trendspair{make_pair(&Geometry::Mu, &Geometry::Sigma),
139  vector<pair<TString, TString>> variablepairs{make_pair("mu", "sigma"),
140  make_pair("muplus", "sigmaplus"),
141  make_pair("muminus", "sigmaminus"),
142  make_pair("deltamu", "sigmadeltamu")};
143  for (size_t iVar = 0; iVar < variablepairs.size(); iVar++) {
144  Trend meantrend = trendspair.at(iVar).first;
145  Trend sigmatrend = trendspair.at(iVar).second;
146  g = new TGraphErrors(
147  n, runs.data(), (geom.*meantrend)().data(), emptyvec.data(), (geom.*sigmatrend)().data());
148  g->SetTitle(geometry.c_str());
149  TString graphname = name + "_" + variablepairs.at(iVar).first;
150  graphname += variablepairs.at(iVar).second;
151  g->Write(graphname);
152  }
153  }
154  }
155  }
156  fout->Close();
157 
158  delete point;
159  delete f;
160  delete g;
161 }
std::vector< float > MuPlus() const
std::vector< float > DeltaMu() const
#define DMRFactor
TString getName(TString structure, int layer, TString geometry)
std::vector< std::string > geometries
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e g
Definition: Activities.doc:4
std::vector< float > MuMinus() const
std::vector< float > Sigma() const
Definition: Trend.h:78
std::vector< float > SigmaPlus() const
Class Geometry Contains vector for fit parameters (mean, sigma, etc.) obtained from multiple IOVs See...
int trends(int argc, char *argv[])
Definition: DMRtrends.cc:42
std::vector< float > SigmaDeltaMu() const
std::vector< float > Mu() const
math::XYZPoint Point
double f[11][100]
def is_empty(h)
Definition: utils.py:179
Structure Point Contains parameters of Gaussian fits to DMRs.
const char * outputFileName_
std::vector< float > SigmaMinus() const
*vegas h *****************************************************used in the default bin number in original ***version of VEGAS is ***a higher bin number might help to derive a more precise ***grade subtle point
Definition: invegas.h:5

◆ getName()

TString PrepareDMRTrends::getName ( TString  structure,
int  layer,
TString  geometry 
)

Definition at line 18 of file PrepareDMRTrends.cc.

References nano_mu_digi_cff::layer, and mergeVDriftHistosByStation::name.

Referenced by compileDMRTrends(), and plotting.Plot::draw().

18  {
19  geometry.ReplaceAll(" ", "_");
20  TString name = geometry + "_" + structure;
21  if (layer != 0) {
22  if (structure == "TID" || structure == "TEC")
23  name += "_disc";
24  else
25  name += "_layer";
26  name += layer;
27  }
28 
29  return name;
30 };

Member Data Documentation

◆ geometries

std::vector<std::string> PrepareDMRTrends::geometries
private

Definition at line 163 of file PrepareDMRTrends.h.

Referenced by compileDMRTrends(), and PrepareDMRTrends().

◆ outputFileName_

const char* PrepareDMRTrends::outputFileName_
private

Definition at line 162 of file PrepareDMRTrends.h.

Referenced by compileDMRTrends().