CMS 3D CMS Logo

Classes | Typedefs | Enumerations | Functions
PVValHelper Namespace Reference

Classes

struct  histodetails
 

Typedefs

typedef std::tuple< std::string, std::string, std::string > plotLabels
 

Enumerations

enum  estimator {
  MEAN = 1, WIDTH = 2, MEDIAN = 3, MAD = 4,
  UNKWN = -1
}
 
enum  plotVariable {
  phi = 1, eta = 2, pT = 3, pTCentral = 4,
  ladder = 5, modZ = 6, END_OF_PLOTS = 7
}
 
enum  residualType {
  dxy = 1, dx = 2, dy = 3, dz = 4,
  IP2D = 5, resz = 6, IP3D = 7, d3D = 8,
  norm_dxy = 9, norm_dx = 10, norm_dy = 11, norm_dz = 12,
  norm_IP2D = 13, norm_resz = 14, norm_IP3D = 15, norm_d3D = 16,
  END_OF_TYPES = 17
}
 

Functions

void add (std::map< std::string, TH1 * > &h, TH1 *hist)
 
void fill (std::map< std::string, TH1 * > &h, const std::string &s, double x)
 
void fill (std::map< std::string, TH1 * > &h, const std::string &s, double x, double y)
 
void fillByIndex (std::vector< TH1F * > &h, unsigned int index, double x, std::string tag="")
 
std::pair< Measurement1D, Measurement1DfitResiduals (TH1 *hist)
 
std::vector< float > generateBins (int n, float start, float range)
 
Measurement1D getMAD (TH1F *histo)
 
Measurement1D getMedian (TH1F *histo)
 
plotLabels getTypeString (residualType type)
 
plotLabels getVarString (plotVariable var)
 
template<typename T , size_t N>
std::array< T, N+1 > makeLogBins (const T min, const T max)
 
void shrinkHistVectorToFit (std::vector< TH1F * > &h, unsigned int desired_size)
 

Typedef Documentation

typedef std::tuple<std::string,std::string,std::string> PVValHelper::plotLabels

Definition at line 112 of file PVValidationHelpers.h.

Enumeration Type Documentation

Enumerator
MEAN 
WIDTH 
MEDIAN 
MAD 
UNKWN 

Definition at line 34 of file PVValidationHelpers.h.

Enumerator
phi 
eta 
pT 
pTCentral 
ladder 
modZ 
END_OF_PLOTS 

Definition at line 63 of file PVValidationHelpers.h.

Enumerator
dxy 
dx 
dy 
dz 
IP2D 
resz 
IP3D 
d3D 
norm_dxy 
norm_dx 
norm_dy 
norm_dz 
norm_IP2D 
norm_resz 
norm_IP3D 
norm_d3D 
END_OF_TYPES 

Definition at line 42 of file PVValidationHelpers.h.

Function Documentation

void PVValHelper::add ( std::map< std::string, TH1 * > &  h,
TH1 *  hist 
)

Definition at line 12 of file PVValidationHelpers.cc.

References create_public_lumi_plots::hist.

Referenced by BPHRecoBuilder::add(), SiPixelQuality::addDisabledModule(), edm::eventsetup::EventSetupRecord::cacheIdentifier(), Folder::cd(), FastLineRecognition::Cluster::Cluster(), popcon::PopConSourceHandler< CastorPedestals >::convertFromOld(), CosmicHitPairGenerator::CosmicHitPairGenerator(), CosmicHitTripletGenerator::CosmicHitTripletGenerator(), edmStreamStallGrapher::createPDFImage(), BPHWriteSpecificDecay::fill(), evf::FastMonitoringService::Encoding::fillReserved(), CaloHitResponse::finalizeHits(), TrackerMap::find_layer(), symbols::get_libraries(), python.rootplot.core::get_plot_inputs(), symbols::get_symbols(), L1GctHfBitCountsLut::getThresholdsGct(), PixelForwardLayer::groupedCompatibleDetsV(), PixelForwardLayerPhase1::groupedCompatibleDetsV(), TIBRing::groupedCompatibleDetsV(), MillePedeVariables::increaseHitsX(), MillePedeVariables::increaseHitsY(), EBHitResponse::keepBlank(), CTPPSIncludeAlignmentsFromXML::Merge(), CSCCLCTData::nlines(), MtvClusterizer1D< T >::operator()(), FsmwClusterizer1D< T >::operator()(), muonisolation::NominalEfficiencyThresholds::locless::operator()(), amc13::Packet::Packet(), python.rootplot.core::plot_hists_mpl(), L1GctLut< NAddressBits, NDataBits >::printLine(), objects.VertexAnalyzer.VertexAnalyzer::process(), core.PileUpAnalyzer.PileUpAnalyzer::process(), fwlite::RunLumiSelector::RunLumiSelector(), TIBLayer::searchNeighbors(), CompositeTECWedge::searchNeighbors(), PixelForwardLayer::searchNeighbors(), TECLayer::searchNeighbors(), PixelForwardLayerPhase1::searchNeighbors(), TIDRing::searchNeighbors(), Phase2EndcapRing::searchNeighbors(), TOBRod::searchNeighbors(), TBPLayer::searchNeighbors(), PixelBlade::searchNeighbors(), Phase1PixelBlade::searchNeighbors(), Phase2OTBarrelRod::searchNeighbors(), TIBRing::searchNeighbors(), CompositeTECPetal::searchNeighbors(), AlignmentParameterSelector::selectedParameters(), edm::EventSetup::setKnownRecordsSupplier(), CSCBaseElectronicsSim::setSignalTimeRange(), MatrixReader.MatrixReader::showRaw(), CSCAnodeData2007::sizeInWords(), CSCAnodeData2006::sizeInWords(), CSCALCTs2006::sizeInWords(), conddb_migrate::tags_in_gts(), evf::FastMonitoringService::Encoding::update(), AlignmentParameterBuilder::~AlignmentParameterBuilder(), DTVDriftCalibration::cellInfo::~cellInfo(), PhysicsTools::Calibration::MVAComputerContainer::~MVAComputerContainer(), and pat::PATUserDataMerger< pat::pat::MET, pat::helper::AddUserInt >::~PATUserDataMerger().

14 {
15  h[hist->GetName()]=hist;
16  hist->StatOverflows(kTRUE);
17 }
void PVValHelper::fill ( std::map< std::string, TH1 * > &  h,
const std::string &  s,
double  x 
)

Definition at line 20 of file PVValidationHelpers.cc.

References alignCSCRings::s.

Referenced by PrimaryVertexValidation::fillTrackHistos().

22 {
23  if(h.count(s)==0){
24  edm::LogWarning("PVValidationHelpers") << "Trying to fill non-existing Histogram named " << s << std::endl;
25  return;
26  }
27  h[s]->Fill(x);
28 }
void PVValHelper::fill ( std::map< std::string, TH1 * > &  h,
const std::string &  s,
double  x,
double  y 
)

Definition at line 31 of file PVValidationHelpers.cc.

References alignCSCRings::s.

33 {
34  if(h.count(s)==0){
35  edm::LogWarning("PVValidationHelpers") << "Trying to fill non-existing Histogram named " << s << std::endl;
36  return;
37  }
38  h[s]->Fill(x,y);
39 }
void PVValHelper::fillByIndex ( std::vector< TH1F * > &  h,
unsigned int  index,
double  x,
std::string  tag = "" 
)

Definition at line 42 of file PVValidationHelpers.cc.

Referenced by PrimaryVertexValidation::analyze().

44 {
45  assert(!h.empty());
46  if(index <= h.size()){
47  h[index]->Fill(x);
48  } else {
49  edm::LogWarning("PVValidationHelpers") << "Trying to fill non-existing Histogram with index " << index << " for array with size: "<<h.size()<<" tag: "<< tag<< std::endl;
50  return;
51  }
52 }
std::pair< Measurement1D, Measurement1D > PVValHelper::fitResiduals ( TH1 *  hist)

Definition at line 230 of file PVValidationHelpers.cc.

References RecoEcal_EventContent_cff::func, SiStripPI::mean, and mps_fire::result.

Referenced by PrimaryVertexValidation::fillMap(), PrimaryVertexValidation::fillTrendPlot(), and PrimaryVertexValidation::fillTrendPlotByIndex().

232 {
233  //float fitResult(9999);
234  //if (hist->GetEntries() < 20) return ;
235 
236  float mean = hist->GetMean();
237  float sigma = hist->GetRMS();
238 
239  TF1 func("tmp", "gaus", mean - 1.5*sigma, mean + 1.5*sigma);
240  if (0 == hist->Fit(&func,"QNR")) { // N: do not blow up file by storing fit!
241  mean = func.GetParameter(1);
242  sigma = func.GetParameter(2);
243  // second fit: three sigma of first fit around mean of first fit
244  func.SetRange(mean - 2*sigma, mean + 2*sigma);
245  // I: integral gives more correct results if binning is too wide
246  // L: Likelihood can treat empty bins correctly (if hist not weighted...)
247  if (0 == hist->Fit(&func, "Q0LR")) {
248  if (hist->GetFunction(func.GetName())) { // Take care that it is later on drawn:
249  hist->GetFunction(func.GetName())->ResetBit(TF1::kNotDraw);
250  }
251  }
252  }
253 
254  float res_mean = func.GetParameter(1);
255  float res_width = func.GetParameter(2);
256 
257  float res_mean_err = func.GetParError(1);
258  float res_width_err = func.GetParError(2);
259 
260  Measurement1D resultM(res_mean,res_mean_err);
261  Measurement1D resultW(res_width,res_width_err);
262 
263  std::pair<Measurement1D, Measurement1D> result;
264 
265  result = std::make_pair(resultM,resultW);
266  return result;
267 }
std::vector< float > PVValHelper::generateBins ( int  n,
float  start,
float  range 
)

Definition at line 164 of file PVValidationHelpers.cc.

References a, begin, end, and findQualityFiles::v.

Referenced by PrimaryVertexValidation::PrimaryVertexValidation().

166 {
167 
168  std::vector<float> v(n);
169  float interval = range/(n-1);
170  std::iota(v.begin(),v.end(),1.);
171 
172  //std::cout<<" interval:"<<interval<<std::endl;
173  //for(float &a : v) { std::cout<< a << " "; }
174  //std::cout<< "\n";
175 
176  std::for_each(begin(v), end(v), [&](float& a) { a = start+((a-1)*interval); });
177 
178  return v;
179 
180 }
Definition: start.py:1
#define end
Definition: vmac.h:39
#define begin
Definition: vmac.h:32
double a
Definition: hdecay.h:121
Measurement1D PVValHelper::getMAD ( TH1F *  histo)

Definition at line 200 of file PVValidationHelpers.cc.

References funct::abs(), getMedian(), pileupCalc::nbins, mps_fire::result, AlCaHLTBitMon_QueryRunRegistry::string, Measurement1D::value(), and create_public_lumi_plots::weights.

Referenced by PrimaryVertexValidation::fillMap(), PrimaryVertexValidation::fillTrendPlot(), and PrimaryVertexValidation::fillTrendPlotByIndex().

202 {
203 
204  int nbins = histo->GetNbinsX();
205  double median = getMedian(histo).value();
206  double x_lastBin = histo->GetBinLowEdge(nbins+1);
207  const char *HistoName =histo->GetName();
208  std::string Finalname = "resMed_";
209  Finalname.append(HistoName);
210  TH1F *newHisto = new TH1F(Finalname.c_str(),Finalname.c_str(),nbins,0.,x_lastBin);
211  double *residuals = new double[nbins];
212  const float *weights = histo->GetArray();
213 
214  for (int j = 0; j < nbins; j++) {
215  residuals[j] = std::abs(median - histo->GetBinCenter(j+1));
216  newHisto->Fill(residuals[j],weights[j]);
217  }
218 
219  double theMAD = (PVValHelper::getMedian(newHisto).value())*1.4826;
220 
221  delete[] residuals; residuals=nullptr;
222  newHisto->Delete("");
223 
224  Measurement1D result(theMAD,theMAD/histo->GetEntries());
225  return result;
226 }
Measurement1D getMedian(TH1F *histo)
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
double value() const
Definition: Measurement1D.h:28
std::string HistoName
Measurement1D PVValHelper::getMedian ( TH1F *  histo)

Definition at line 183 of file PVValidationHelpers.cc.

References lumiQueryAPI::q, and mps_fire::result.

Referenced by PrimaryVertexValidation::fillMap(), PrimaryVertexValidation::fillTrendPlot(), PrimaryVertexValidation::fillTrendPlotByIndex(), and getMAD().

185 {
186  double median=0.;
187  double q = 0.5; // 0.5 quantile for "median"
188  // protect against empty histograms
189  if(histo->Integral()!=0){
190  histo->GetQuantiles(1, &median, &q);
191  }
192 
193  Measurement1D result(median,median/TMath::Sqrt(histo->GetEntries()));
194 
195  return result;
196 
197 }
PVValHelper::plotLabels PVValHelper::getTypeString ( PVValHelper::residualType  type)

Definition at line 62 of file PVValidationHelpers.cc.

References d3D, dx, dxy, dy, dz, IP2D, IP3D, norm_d3D, norm_dx, norm_dxy, norm_dy, norm_dz, norm_IP2D, norm_IP3D, norm_resz, resz, and reco::returnType().

Referenced by PrimaryVertexValidation::bookResidualsHistogram(), and PrimaryVertexValidation::PrimaryVertexValidation().

64 {
66  switch(type)
67  {
68  // absoulte
69 
70  case PVValHelper::dxy :
71  returnType = std::make_tuple("dxy","d_{xy}","[#mum]");
72  break;
73  case PVValHelper::dx :
74  returnType = std::make_tuple("dx","d_{x}","[#mum]");
75  break;
76  case PVValHelper::dy :
77  returnType = std::make_tuple("dy","d_{y}","[#mum]");
78  break;
79  case PVValHelper::dz :
80  returnType = std::make_tuple("dz","d_{z}","[#mum]");
81  break;
82  case PVValHelper::IP2D :
83  returnType = std::make_tuple("IP2D","IP_{2D}","[#mum]");
84  break;
85  case PVValHelper::resz :
86  returnType = std::make_tuple("resz","z_{trk}-z_{vtx}","[#mum]");
87  break;
88  case PVValHelper::IP3D :
89  returnType = std::make_tuple("IP3D","IP_{3D}","[#mum]");
90  break;
91  case PVValHelper::d3D :
92  returnType = std::make_tuple("d3D","d_{3D}","[#mum]");
93  break;
94 
95  // normalized
96 
98  returnType = std::make_tuple("norm_dxy","d_{xy}/#sigma_{d_{xy}}","");
99  break;
100  case PVValHelper::norm_dx :
101  returnType = std::make_tuple("norm_dx","d_{x}/#sigma_{d_{x}}","");
102  break;
103  case PVValHelper::norm_dy :
104  returnType = std::make_tuple("norm_dy","d_{y}/#sigma_{d_{y}}","");
105  break;
106  case PVValHelper::norm_dz :
107  returnType = std::make_tuple("norm_dz","d_{z}/#sigma_{d_{z}}","");
108  break;
110  returnType = std::make_tuple("norm_IP2D","IP_{2D}/#sigma_{IP_{2D}}","");
111  break;
113  returnType = std::make_tuple("norm_resz","z_{trk}-z_{vtx}/#sigma_{res_{z}}","");
114  break;
116  returnType = std::make_tuple("norm_IP3D","IP_{3D}/#sigma_{IP_{3D}}","");
117  break;
118  case PVValHelper::norm_d3D :
119  returnType = std::make_tuple("norm_d3D","d_{3D}/#sigma_{d_{3D}}","");
120  break;
121 
122  default:
123  edm::LogWarning("PVValidationHelpers") <<" getTypeString() unknown residual type: "<<type<<std::endl;
124  }
125 
126  return returnType;
127 
128 }
type
Definition: HCALResponse.h:21
std::tuple< std::string, std::string, std::string > plotLabels
edm::TypeWithDict returnType(const edm::FunctionWithDict &func)
Definition: returnType.cc:16
PVValHelper::plotLabels PVValHelper::getVarString ( PVValHelper::plotVariable  var)

Definition at line 131 of file PVValidationHelpers.cc.

References eta, ladder, modZ, phi, pT, and pTCentral.

Referenced by PrimaryVertexValidation::bookResidualsHistogram(), and PrimaryVertexValidation::PrimaryVertexValidation().

133 {
134  PVValHelper::plotLabels returnVar;
135  switch(var)
136  {
137  case PVValHelper::phi :
138  returnVar = std::make_tuple("phi","#phi","[rad]");
139  break;
140  case PVValHelper::eta :
141  returnVar = std::make_tuple("eta","#eta","");
142  break;
143  case PVValHelper::pT :
144  returnVar = std::make_tuple("pT","p_{T}","[GeV]");
145  break;
147  returnVar = std::make_tuple("pTCentral","p_{T} |#eta|<1.","[GeV]");
148  break;
149  case PVValHelper::ladder :
150  returnVar = std::make_tuple("ladder","ladder number","");
151  break;
152  case PVValHelper::modZ :
153  returnVar = std::make_tuple("modZ","module number","");
154  break;
155  default:
156  edm::LogWarning("PVValidationHelpers") <<" getVarString() unknown plot variable: "<<var<<std::endl;
157  }
158 
159  return returnVar;
160 
161 }
std::tuple< std::string, std::string, std::string > plotLabels
template<typename T , size_t N>
std::array<T, N+1> PVValHelper::makeLogBins ( const T  min,
const T  max 
)

Definition at line 19 of file PVValidationHelpers.h.

References mps_fire::i, N, funct::pow(), and ApeEstimator_cff::width.

19  {
20  const T minLog10 = std::log10(min);
21  const T maxLog10 = std::log10(max);
22  const T width = (maxLog10-minLog10)/N;
23  std::array<T, N+1> ret;
24  ret[0] = std::pow(10, minLog10);
25  const T mult = std::pow(10, width);
26  for ( size_t i=1; i<=N; ++i) {
27  ret[i] = ret[i-1]*mult;
28  }
29  return ret;
30  }
T min(T a, T b)
Definition: MathUtil.h:58
#define N
Definition: blowfish.cc:9
long double T
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40
void PVValHelper::shrinkHistVectorToFit ( std::vector< TH1F * > &  h,
unsigned int  desired_size 
)

Definition at line 55 of file PVValidationHelpers.cc.

Referenced by PrimaryVertexValidation::analyze().

57 {
58  h.erase(h.begin()+desired_size,h.end());
59 }