CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Classes | Functions
Utilities.h File Reference
#include <string>
#include <vector>
#include <cassert>
#include <iomanip>
#include <iostream>
#include <sstream>
#include <fstream>
#include <map>
#include <cmath>
#include <TFile.h>
#include <TH1F.h>
#include <TF1.h>
#include <TStyle.h>
#include <TMath.h>

Go to the source code of this file.

Classes

class  CommandLine
 

Functions

void CalculateCorrection (bool UseRatioForResponse, double x, double ex, double y, double ey, double &c, double &e)
 
void CalculateResponse (bool UseRatioForResponse, double x, double ex, double y, double ey, double &r, double &e)
 
int getBin (double x, std::vector< double > boundaries)
 
void GetMEAN (TH1F *histo, double &peak, double &error, double &sigma)
 
void GetMPV (char name[100], TH1F *histo, TDirectory *Dir, double &peak, double &error, double &sigma, double &err_sigma)
 
bool HistoExists (std::vector< std::string > LIST, std::string hname)
 
void Invert (TF1 *f, double Min, double Max, double y, double &x)
 

Function Documentation

void CalculateCorrection ( bool  UseRatioForResponse,
double  x,
double  ex,
double  y,
double  ey,
double &  c,
double &  e 
)

Definition at line 474 of file Utilities.h.

References funct::pow(), mathSSE::sqrt(), and detailsBasic3DVector::y.

Referenced by main().

475 {
476  if (x>0 && fabs(y)>0)
477  {
478  if (UseRatioForResponse)
479  {
480  c = 1./y;
481  e = ey/(y*y);
482  }
483  else
484  {
485  c = x/(x+y);
486  e = (fabs(x*y)/pow(x+y,2))*sqrt(pow(ey/y,2)+pow(ex/x,2));
487  }
488  }
489  else
490  {
491  c = 0;
492  e = 0;
493  }
494 }
T sqrt(T t)
Definition: SSEVec.h:46
x
Definition: VDTMath.h:216
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40
void CalculateResponse ( bool  UseRatioForResponse,
double  x,
double  ex,
double  y,
double  ey,
double &  r,
double &  e 
)

Definition at line 452 of file Utilities.h.

References funct::pow(), mathSSE::sqrt(), and detailsBasic3DVector::y.

Referenced by main().

453 {
454  if (x>0 && fabs(y)>0)
455  {
456  if (UseRatioForResponse)
457  {
458  r = y;
459  e = ey;
460  }
461  else
462  {
463  r = (x+y)/x;
464  e = fabs(r-1.)*sqrt(pow(ey/y,2)+pow(ex/x,2));
465  }
466  }
467  else
468  {
469  r = 0;
470  e = 0;
471  }
472 }
T sqrt(T t)
Definition: SSEVec.h:46
x
Definition: VDTMath.h:216
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40
int getBin ( double  x,
std::vector< double >  boundaries 
)

Definition at line 512 of file Utilities.h.

References i, and n.

Referenced by main(), L1TTestsSummary::updateL1TOccupancyMonitor(), L1TTestsSummary::updateL1TRateMonitor(), and L1TTestsSummary::updateL1TSyncMonitor().

513 {
514  int i;
515  int n = boundaries.size()-1;
516  if (n<=0) return -1;
517  if (x<boundaries[0] || x>=boundaries[n])
518  return -1;
519  for(i=0;i<n;i++)
520  {
521  if (x>=boundaries[i] && x<boundaries[i+1])
522  return i;
523  }
524  return 0;
525 }
int i
Definition: DBlmapReader.cc:9
x
Definition: VDTMath.h:216
void GetMEAN ( TH1F *  histo,
double &  peak,
double &  error,
double &  sigma 
)

Definition at line 435 of file Utilities.h.

References N.

Referenced by main().

436 {
437  double N = histo->Integral();
438  if (N>2)
439  {
440  peak = histo->GetMean();
441  sigma = histo->GetRMS();
442  error = histo->GetMeanError();
443  }
444  else
445  {
446  peak = 0;
447  sigma = 0;
448  error = 0;
449  }
450 }
#define N
Definition: blowfish.cc:9
void GetMPV ( char  name[100],
TH1F *  histo,
TDirectory *  Dir,
double &  peak,
double &  error,
double &  sigma,
double &  err_sigma 
)

Definition at line 368 of file Utilities.h.

References a, gather_cfg::cout, g, funct::integral(), gen::k, siStripFEDMonitor_P5_cff::Max, timingPdfMaker::mean, siStripFEDMonitor_P5_cff::Min, and plotscripts::rms().

Referenced by main().

369 {
370  double norm,mean,rms,integral,lowlimit,highlimit,LowResponse,HighResponse,a;
371  int k;
372  LowResponse = histo->GetXaxis()->GetXmin();
373  HighResponse = histo->GetXaxis()->GetXmax();
374  Dir->cd();
375  TF1 *g;
376  TStyle *myStyle = new TStyle("mystyle","mystyle");
377  myStyle->Reset();
378  myStyle->SetOptFit(1111);
379  myStyle->SetOptStat(2200);
380  myStyle->SetStatColor(0);
381  myStyle->SetTitleFillColor(0);
382  myStyle->cd();
383  integral = histo->Integral();
384  mean = histo->GetMean();
385  rms = histo->GetRMS();
386  a = 1.5;
387  if (integral>0)
388  {
389  lowlimit = TMath::Max(LowResponse,mean-a*rms);
390  highlimit= TMath::Min(mean+a*rms,HighResponse);
391  norm = histo->GetMaximumStored();
392  peak = mean;
393  sigma = rms;
394  for (k=0; k<3; k++)
395  {
396  g = new TF1("g","gaus",lowlimit, highlimit);
397  g->SetParNames("N","#mu","#sigma");
398  g->SetParameter(0,norm);
399  g->SetParameter(1,peak);
400  g->SetParameter(2,sigma);
401  lowlimit = TMath::Max(LowResponse,peak-a*sigma);
402  highlimit= TMath::Min(peak+a*sigma,HighResponse);
403  g->SetRange(lowlimit,highlimit);
404  histo->Fit(g,"RQ");
405  norm = g->GetParameter(0);
406  peak = g->GetParameter(1);
407  sigma = g->GetParameter(2);
408  }
409  if (g->GetNDF()>5)
410  {
411  peak = g->GetParameter(1);
412  sigma = g->GetParameter(2);
413  error = g->GetParError(1);
414  err_sigma = g->GetParError(2);
415  }
416  else
417  {
418  std::cout<<"FIT FAILURE: histogram "<<name<<"...Using MEAN and RMS."<<std::endl;
419  peak = mean;
420  sigma = rms;
421  error = histo->GetMeanError();
422  err_sigma = histo->GetRMSError();
423  }
424  }
425  else
426  {
427  peak = 0;
428  sigma = 0;
429  error = 0;
430  err_sigma = 0;
431  }
432  histo->Write();
433 }
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
Integral< F, X >::type integral(const F &f)
Definition: Integral.h:69
int k[5][pyjets_maxn]
double a
Definition: hdecay.h:121
tuple cout
Definition: gather_cfg.py:121
bool HistoExists ( std::vector< std::string >  LIST,
std::string  hname 
)

Definition at line 496 of file Utilities.h.

References gather_cfg::cout, newFWLiteAna::found, i, and N.

Referenced by main().

497 {
498  unsigned int i,N;
499  bool found(false);
500  N = LIST.size();
501  if (N==0)
502  std::cout<<"WARNING: empty file histogram list!!!!"<<std::endl;
503  else
504  for(i=0;i<N;i++)
505  if (hname==LIST[i])
506  found = true;
507  if (!found)
508  std::cout<<"Histogram: "<<hname<<" NOT FOUND!!! Check list of existing objects."<<std::endl;
509  return found;
510 }
int i
Definition: DBlmapReader.cc:9
#define N
Definition: blowfish.cc:9
tuple cout
Definition: gather_cfg.py:121
void Invert ( TF1 *  f,
double  Min,
double  Max,
double  y,
double &  x 
)