CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Functions
InvMatrixUtils.h File Reference
#include <string>
#include <map>
#include "TObject.h"
#include "TF1.h"
#include "TH2.h"
#include "TProfile.h"
#include "TCanvas.h"
#include "CLHEP/Geometry/Point3D.h"
#include "CLHEP/Matrix/GenMatrix.h"
#include "CLHEP/Matrix/Matrix.h"
#include "CLHEP/Matrix/Vector.h"
#include "TFile.h"
#include "Calibration/Tools/interface/InvMatrixCommonDefs.h"

Go to the source code of this file.

Functions

double effectiveSigma (TH1F &histogram, int vSteps=100)
 
double etaCorrE1E25 (int eta)
 
double etaCorrE1E49 (int eta)
 
double etaCorrE1E9 (int eta)
 
int etaFromXtal (const int &xtal)
 
int extract (std::vector< int > *output, const std::string &dati)
 
std::pair< int, int > findSupport (TH1F &histogram, double thres=0.)
 
double get3x3 (const Float_t energy[7][7])
 
double get5x5 (const Float_t energy[7][7])
 
TCanvas * getGlobalCanvas (std::string name="Inv MatrixCanvas")
 
TFile * getGlobalTFile (std::string name="Inv MatrixTFile.root")
 
CLHEP::HepMatrix * getSavedMatrix (const std::string &name)
 
int ietaFromXtal (const int &xtal)
 
int iphiFromXtal (const int &xtal)
 
template<class Type >
void mtrReset (Type superModules[85][20], const Type val)
 
void mtrTransfer (double output[85][20], CLHEP::HepMatrix *input, double Default)
 
int parseConfigFile (const TString &config)
 
int phiFromXtal (const int &xtal)
 
int readCMSSWcoeff (CLHEP::HepMatrix &calibcoeff, const std::string &inputFileName, double defaultVal=1.)
 
int readCMSSWcoeffForComparison (CLHEP::HepMatrix &calibcoeff, const std::string &inputFileName)
 
int saveGlobalTFile (std::string name="Inv MatrixFile.root")
 
void setStyle ()
 
TH1D * smartError (TH1D *strip)
 
TH1D * smartGausProfile (TH2F *strip, double width)
 
TH1D * smartProfile (TH2F *strip, double width)
 
HepGeom::Point3D< Float_t > TBposition (const Float_t amplit[7][7], const Float_t beamEne, const Float_t w0=4.0, const Float_t x0=8.9, const Float_t a0=6.2, const Float_t sideX=24.06, const Float_t sideY=22.02)
 
int translateCoeff (const CLHEP::HepMatrix &calibcoeff, const CLHEP::HepMatrix &sigmaMatrix, const CLHEP::HepMatrix &statisticMatrix, std::string SMnumber="1", double calibThres=0.01, std::string fileName="calibOutput.txt", std::string genTag="CAL_GENTAG", std::string method="CAL_METHOD", std::string version="CAL_VERSION", std::string type="CAL_TYPE")
 
int writeCalibTxt (const CLHEP::HepMatrix &AmplitudeMatrix, const CLHEP::HepMatrix &SigmaMatrix, const CLHEP::HepMatrix &StatisticMatrix, std::string fileName="calibOutput.txt")
 
int writeCMSSWCoeff (const CLHEP::HepMatrix &amplMatrix, double calibThres, float ERef, const CLHEP::HepMatrix &sigmaMatrix, const CLHEP::HepMatrix &statisticMatrix, std::string fileName="calibOutput.txt", std::string genTag="CAL_GENTAG", std::string method="CAL_METHOD", std::string version="CAL_VERSION", std::string type="CAL_TYPE")
 
int writeCMSSWCoeff (const CLHEP::HepMatrix &amplMatrix, double calibThres, int etaRef, int phiRef, const CLHEP::HepMatrix &sigmaMatrix, const CLHEP::HepMatrix &statisticMatrix, std::string fileName="calibOutput.txt", std::string genTag="CAL_GENTAG", std::string method="CAL_METHOD", std::string version="CAL_VERSION", std::string type="CAL_TYPE")
 
int xtalFromEtaPhi (const int &myEta, const int &myPhi)
 
int xtalFromiEtaiPhi (const int &iEta, const int &iPhi)
 

Function Documentation

double effectiveSigma ( TH1F &  histogram,
int  vSteps = 100 
)

find the effective sigma as the half width of the sub-distribution containing 68.3% of the total distribution

Definition at line 619 of file InvMatrixUtils.cc.

References cms::cuda::allocator::maxBin, and dtDQMClient_cfg::threshold.

619  {
620  double totInt = histogram.Integral();
621  int maxBin = histogram.GetMaximumBin();
622  int maxBinVal = int(histogram.GetBinContent(maxBin));
623  int totBins = histogram.GetNbinsX();
624  double area = totInt;
625  double threshold = 0;
626  double vStep = maxBinVal / vSteps;
627  int leftBin = 1;
628  int rightBin = totBins - 1;
629  //loop over the vertical range
630  while (area / totInt > 0.683) {
631  threshold += vStep;
632  // loop toward the left
633  for (int back = maxBin; back > 0; --back) {
634  if (histogram.GetBinContent(back) < threshold) {
635  leftBin = back;
636  break;
637  }
638  } // loop toward the left
639 
640  // loop toward the right
641  for (int fwd = maxBin; fwd < totBins; ++fwd) {
642  if (histogram.GetBinContent(fwd) < threshold) {
643  rightBin = fwd;
644  break;
645  }
646  } // loop toward the right
647  area = histogram.Integral(leftBin, rightBin);
648  } //loop over the vertical range
649 
650  histogram.GetXaxis()->SetRange(leftBin, rightBin);
651  // double sigmaEff = histogram.GetRMS () ;
652  double halfWidthRange = 0.5 * (histogram.GetBinCenter(rightBin) - histogram.GetBinCenter(leftBin));
653  return halfWidthRange;
654 }
constexpr unsigned int maxBin
double etaCorrE1E25 ( int  eta)

correction for eta containment for 5*5 cluster

Definition at line 697 of file InvMatrixUtils.cc.

References alignCSCRings::corr, PVValHelper::eta, fireworks::p1, and fireworks::p2.

697  {
698  double p0 = 0.807883;
699  double p1 = 0.000182551;
700  double p2 = -5.76961e-06;
701  double p3 = 7.41903e-08;
702  double p4 = -2.25384e-10;
703 
704  double corr;
705  if (eta < 6)
706  corr = p0;
707  else
708  corr = p0 + p1 * eta + p2 * eta * eta + p3 * eta * eta * eta + p4 * eta * eta * eta * eta;
709  return corr / p0;
710 }
const TString p2
Definition: fwPaths.cc:13
const TString p1
Definition: fwPaths.cc:12
double etaCorrE1E49 ( int  eta)

correction for eta containment for 7*7 cluster

Definition at line 713 of file InvMatrixUtils.cc.

References alignCSCRings::corr, PVValHelper::eta, fireworks::p1, and fireworks::p2.

713  {
714  double p0 = 0.799895;
715  double p1 = 0.000235487;
716  double p2 = -8.26496e-06;
717  double p3 = 1.21564e-07;
718  double p4 = -4.83286e-10;
719 
720  double corr;
721  if (eta < 8)
722  corr = p0;
723  else
724  corr = p0 + p1 * eta + p2 * eta * eta + p3 * eta * eta * eta + p4 * eta * eta * eta * eta;
725  return corr / p0;
726 }
const TString p2
Definition: fwPaths.cc:13
const TString p1
Definition: fwPaths.cc:12
double etaCorrE1E9 ( int  eta)

correction for eta containment for 3*3 cluster

Definition at line 729 of file InvMatrixUtils.cc.

References alignCSCRings::corr, PVValHelper::eta, fireworks::p1, and fireworks::p2.

729  {
730  if (eta < 4)
731  return 1.0;
732  // grazie Paolo
733  double p0 = 0.834629;
734  double p1 = 0.00015254;
735  double p2 = -4.91784e-06;
736  double p3 = 6.54652e-08;
737  double p4 = -2.4894e-10;
738 
739  double corr;
740  if (eta < 6)
741  corr = p0;
742  else
743  corr = p0 + p1 * eta + p2 * eta * eta + p3 * eta * eta * eta + p4 * eta * eta * eta * eta;
744  return corr / p0;
745 }
const TString p2
Definition: fwPaths.cc:13
const TString p1
Definition: fwPaths.cc:12
int etaFromXtal ( const int &  xtal)

get the eta coord [0,84]

Definition at line 229 of file InvMatrixUtils.cc.

Referenced by ietaFromXtal(), phiFromXtal(), readCMSSWcoeff(), and readCMSSWcoeffForComparison().

229  {
230  // return floor (static_cast<double> ((xtal-1) / 20)) ;
231  return int(floor((xtal - 1) / 20));
232 }
int extract ( std::vector< int > *  output,
const std::string &  dati 
)
to read a file containing unserted integers

while avoiding comment lines

Definition at line 251 of file InvMatrixUtils.cc.

References edmScanValgrind::buffer, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by BeautifulSoup.PageElement::_invert(), SiStripCalibLorentzAngle::algoBeginJob(), clone(), CommissioningTask::HistoSet::histo(), PedsFullNoiseHistograms::histoAnalysis(), CalibrationHistograms::histoAnalysis(), NoiseHistograms::histoAnalysis(), OptoScanHistograms::histoAnalysis(), PedestalsHistograms::histoAnalysis(), ApvTimingHistograms::histoAnalysis(), VpspScanHistograms::histoAnalysis(), DaqScopeModeHistograms::histoAnalysis(), PedsOnlyHistograms::histoAnalysis(), FastFedCablingHistograms::histoAnalysis(), SamplingHistograms::histoAnalysis(), FedCablingHistograms::histoAnalysis(), CommissioningHistograms::histogram(), SummaryPlotFactory< CommissioningAnalysis * >::init(), PedestalsTask::update(), PedsOnlyTask::update(), PedsFullNoiseTask::update(), DaqScopeModeTask::update(), NoiseTask::update(), and CommissioningTask::updateHistoSet().

251  {
252  std::ifstream _dati(dati.c_str());
253  // loop over the file
254  while (!_dati.eof()) {
255  // get the line
256  std::string dataline;
257  do {
258  getline(_dati, dataline, '\n');
259  } while (*dataline.begin() == '#');
260  std::stringstream linea(dataline);
261  // loop over the line
262  while (!linea.eof()) {
263  int buffer = -1;
264  linea >> buffer;
265  if (buffer != -1)
266  output->push_back(buffer);
267  } // loop over the line
268  } // loop over the file
269  return output->size();
270 }
std::pair<int, int> findSupport ( TH1F &  histogram,
double  thres = 0. 
)

find the support of the histogram above a threshold return the min and max bins

Definition at line 658 of file InvMatrixUtils.cc.

References newFWLiteAna::bin.

658  {
659  int totBins = histogram.GetNbinsX();
660  if (thres >= histogram.GetMaximum())
661  return std::pair<int, int>(0, totBins);
662 
663  int leftBin = totBins - 1;
664  // search from left for the minimum
665  for (int bin = 1; bin < totBins; ++bin) {
666  if (histogram.GetBinContent(bin) > thres) {
667  leftBin = bin;
668  break;
669  }
670  } // search from left for the minimum
671  int rightBin = 1;
672  // search from right for the maximum
673  for (int bin = totBins - 1; bin > 0; --bin) {
674  if (histogram.GetBinContent(bin) > thres) {
675  rightBin = bin;
676  break;
677  }
678  } // search from right for the maximum
679  return std::pair<int, int>(leftBin, rightBin);
680 }
double get3x3 ( const Float_t  energy[7][7])
get the energy in the 3x3 

from the 7x7 array around the most energetic crystal

Definition at line 165 of file InvMatrixUtils.cc.

References PVValHelper::eta, PVValHelper::phi, and dqmMemoryStats::total.

Referenced by TBposition().

165  {
166  double total = 0.;
167 
168  for (int eta = 2; eta < 5; ++eta)
169  for (int phi = 2; phi < 5; ++phi)
170  total += energy[eta][phi];
171 
172  return total;
173 }
double get5x5 ( const Float_t  energy[7][7])
get the energy in the 5x5 

from the 7x7 array around the most energetic crystal

Definition at line 151 of file InvMatrixUtils.cc.

References PVValHelper::eta, PVValHelper::phi, and dqmMemoryStats::total.

151  {
152  double total = 0.;
153 
154  for (int eta = 1; eta < 6; ++eta)
155  for (int phi = 1; phi < 6; ++phi)
156  total += energy[eta][phi];
157 
158  return total;
159 }
TCanvas* getGlobalCanvas ( std::string  name = "Inv MatrixCanvas")
search for an existing canvas with the name 

and returns the poiter to it

Definition at line 39 of file InvMatrixUtils.cc.

References setStyle().

39  {
40  setStyle();
41  TCanvas *globalCanvas = static_cast<TCanvas *>(gROOT->FindObject(name.c_str()));
42  if (globalCanvas) {
43  globalCanvas->Clear();
44  globalCanvas->UseCurrentStyle();
45  globalCanvas->SetWindowSize(700, 600);
46 
47  } else {
48  globalCanvas = new TCanvas(name.c_str(), name.c_str(), 700, 600);
49  }
50  return globalCanvas;
51 }
void setStyle()
Definition: offsetStack.cc:165
TFile* getGlobalTFile ( std::string  name = "Inv MatrixTFile.root")
search for an existing TFile with the name 

and returns the poiter to it

Definition at line 55 of file InvMatrixUtils.cc.

55  {
56  // std::cout << "writing " << name << std::endl ;
57  // setStyle () ;
58  TFile *globalTFile = (TFile *)gROOT->FindObject(name.c_str());
59  if (!globalTFile) {
60  // std::cout << "does not exist. creating it " << std::endl;
61  globalTFile = new TFile(name.c_str(), "RECREATE");
62  }
63 
64  return globalTFile;
65 }
CLHEP::HepMatrix* getSavedMatrix ( const std::string &  name)
search for an existing calib matrix saved with the name 

and returns the poiter to it, the deletion is responsiblity of the user

Definition at line 81 of file InvMatrixUtils.cc.

References matrixSaver::getMatrix(), DQM::reader, SCMaxEta, SCMaxPhi, and matrixSaver::touch().

81  {
83  CLHEP::HepMatrix *savedMatrix;
84  if (reader.touch(name)) {
85  savedMatrix = static_cast<CLHEP::HepMatrix *>(reader.getMatrix(name));
86  } else {
87  savedMatrix = new CLHEP::HepMatrix(SCMaxEta, SCMaxPhi, 0);
88  }
89 
90  return savedMatrix;
91 }
#define SCMaxEta
#define SCMaxPhi
save (read) CLHEP::HepMatrix to (from) text files
Definition: matrixSaver.h:22
bool touch(std::string inputFileName)
Definition: matrixSaver.cc:103
tuple reader
Definition: DQM.py:105
CLHEP::HepGenMatrix * getMatrix(std::string inputFileName)
Definition: matrixSaver.cc:108
int ietaFromXtal ( const int &  xtal)

get the eta coord [1,85]

Definition at line 243 of file InvMatrixUtils.cc.

References etaFromXtal().

243 { return etaFromXtal(xtal) + 1; }
int etaFromXtal(const int &xtal)
int iphiFromXtal ( const int &  xtal)

get the phi coord [1,20]

Definition at line 247 of file InvMatrixUtils.cc.

References phiFromXtal().

247 { return phiFromXtal(xtal) + 1; }
int phiFromXtal(const int &xtal)
template<class Type >
void mtrReset ( Type  superModules[85][20],
const Type  val 
)

reset the matrices f the size of a supermodule

Definition at line 178 of file InvMatrixUtils.h.

References alignCSCRings::e, AlCaHLTBitMon_ParallelJobs::p, SCMaxEta, SCMaxPhi, and hgcalPerformanceValidation::val.

178  {
179  for (int e = 0; e < SCMaxEta; ++e)
180  for (int p = 0; p < SCMaxPhi; ++p) {
181  superModules[e][p] = val;
182  }
183 }
#define SCMaxEta
#define SCMaxPhi
void mtrTransfer ( double  output[85][20],
CLHEP::HepMatrix *  input,
double  Default 
)

transfers a CLHEP matrix into a double array with the size of a supermodule

Definition at line 684 of file InvMatrixUtils.cc.

References PVValHelper::eta, convertSQLitetoXML_cfg::output, PVValHelper::phi, SCMaxEta, and SCMaxPhi.

684  {
685  for (int eta = 0; eta < SCMaxEta; ++eta)
686  for (int phi = 0; phi < SCMaxPhi; ++phi) {
687  if ((*input)[eta][phi])
688  output[eta][phi] = (*input)[eta][phi];
689  else
690  output[eta][phi] = Default;
691  }
692  return;
693 }
#define SCMaxEta
#define SCMaxPhi
static std::string const input
Definition: EdmProvDump.cc:47
int parseConfigFile ( const TString &  config)

to get the parameters from a congiguration file

int phiFromXtal ( const int &  xtal)

get the phi coord [0,19]

Definition at line 236 of file InvMatrixUtils.cc.

References etaFromXtal(), and PVValHelper::phi.

Referenced by iphiFromXtal(), readCMSSWcoeff(), readCMSSWcoeffForComparison(), and xtalFromEtaPhi().

236  {
237  int phi = (xtal - 1) - 20 * etaFromXtal(xtal);
238  return (20 - phi - 1);
239 }
int etaFromXtal(const int &xtal)
int readCMSSWcoeff ( CLHEP::HepMatrix &  calibcoeff,
const std::string &  inputFileName,
double  defaultVal = 1. 
)

translates the calib coefficients format, from the CMSSW one to the TB06Studies one

Definition at line 443 of file InvMatrixUtils.cc.

References edmScanValgrind::buffer, etaFromXtal(), good, phiFromXtal(), and AlCaHLTBitMon_QueryRunRegistry::string.

443  {
444  std::ifstream CMSSWfile;
445  CMSSWfile.open(inputFileName.c_str());
447  CMSSWfile >> buffer;
448  CMSSWfile >> buffer;
449  CMSSWfile >> buffer;
450  CMSSWfile >> buffer;
451  CMSSWfile >> buffer;
452  CMSSWfile >> buffer;
453  while (!CMSSWfile.eof()) {
454  int xtalnum;
455  CMSSWfile >> xtalnum;
456  double coeff;
457  CMSSWfile >> coeff;
458  double buffer;
459  CMSSWfile >> buffer;
460  int good;
461  CMSSWfile >> good;
462  CMSSWfile >> good;
463  if (!good)
464  coeff = defaultVal; //FIXME 0 o 1?
465  calibcoeff[etaFromXtal(xtalnum)][phiFromXtal(xtalnum)] = coeff;
466  }
467  return 0;
468 }
int phiFromXtal(const int &xtal)
auto const good
min quality of good
int etaFromXtal(const int &xtal)
int readCMSSWcoeffForComparison ( CLHEP::HepMatrix &  calibcoeff,
const std::string &  inputFileName 
)

translates the calib coefficients format, from the CMSSW one to the TB06Studies one

Definition at line 472 of file InvMatrixUtils.cc.

References edmScanValgrind::buffer, etaFromXtal(), good, phiFromXtal(), and AlCaHLTBitMon_QueryRunRegistry::string.

472  {
473  std::ifstream CMSSWfile;
474  CMSSWfile.open(inputFileName.c_str());
476  CMSSWfile >> buffer;
477  CMSSWfile >> buffer;
478  CMSSWfile >> buffer;
479  CMSSWfile >> buffer;
480  CMSSWfile >> buffer;
481  CMSSWfile >> buffer;
482  while (!CMSSWfile.eof()) {
483  int xtalnum;
484  CMSSWfile >> xtalnum;
485  double coeff;
486  CMSSWfile >> coeff;
487  double buffer;
488  CMSSWfile >> buffer;
489  int good;
490  CMSSWfile >> good;
491  CMSSWfile >> good;
492  if (!good)
493  coeff = 0.; //FIXME 0 o 1?
494  calibcoeff[etaFromXtal(xtalnum)][phiFromXtal(xtalnum)] = coeff;
495  }
496  return 0;
497 }
int phiFromXtal(const int &xtal)
auto const good
min quality of good
int etaFromXtal(const int &xtal)
int saveGlobalTFile ( std::string  name = "Inv MatrixFile.root")
search for an existing TFile with the name 

and saves it to disk with his name

Definition at line 69 of file InvMatrixUtils.cc.

69  {
70  TFile *globalTFile = static_cast<TFile *>(gROOT->FindObject(name.c_str()));
71  if (!globalTFile)
72  return 1;
73  globalTFile->Write();
74  globalTFile->Close();
75  delete globalTFile;
76  return 0;
77 }
void setStyle ( )

set the style for the printout

Definition at line 165 of file offsetStack.cc.

Referenced by getGlobalCanvas(), and main().

165  {
166  gStyle->SetPadTopMargin(0.05);
167  gStyle->SetPadBottomMargin(0.1);
168  gStyle->SetPadLeftMargin(0.16);
169  gStyle->SetPadRightMargin(0.02);
170 
171  gStyle->SetOptStat(0);
172  gStyle->SetOptTitle(0);
173 
174  gStyle->SetTitleFont(42, "XYZ");
175  gStyle->SetTitleSize(0.05, "XYZ");
176  gStyle->SetTitleXOffset(0.9);
177  gStyle->SetTitleYOffset(1.4);
178 
179  gStyle->SetLabelFont(42, "XYZ");
180  gStyle->SetLabelOffset(0.007, "XYZ");
181  gStyle->SetLabelSize(0.04, "XYZ");
182 
183  gStyle->SetPadTickX(1);
184  gStyle->SetPadTickY(1);
185 }
TH1D* smartError ( TH1D *  strip)

Definition at line 598 of file InvMatrixUtils.cc.

References newFWLiteAna::bin, relativeConstraints::error, mergeVDriftHistosByStation::name, AlCaHLTBitMon_QueryRunRegistry::string, hlt_dqm_clientPB-live_cfg::xmax, and hlt_dqm_clientPB-live_cfg::xmin.

598  {
599  double xmin = strip->GetXaxis()->GetXmin();
600  double xmax = strip->GetXaxis()->GetXmax();
601  int stripsBins = strip->GetNbinsX();
602 
603  std::string name = strip->GetName();
604  name += "_error";
605  TH1D *error = new TH1D(name.c_str(), strip->GetTitle(), stripsBins, xmin, xmax);
606 
607  int binmin = 1;
608  int ngroup = 1; // bins per step
609  int binmax = stripsBins;
610  for (int bin = binmin; bin <= binmax; bin += ngroup) {
611  double dummyError = strip->GetBinError(bin);
612  error->SetBinContent(bin, dummyError);
613  }
614  return error;
615 }
TH1D* smartGausProfile ( TH2F *  strip,
double  width 
)

smart profiling by fixing gaussian parameters and range from a first averaging

Definition at line 546 of file InvMatrixUtils.cc.

References newFWLiteAna::bin, GOODCOLL_filter_cfg::cut, mergeVDriftHistosByStation::name, hlt_dqm_clientPB-live_cfg::nbins, AlCaHLTBitMon_QueryRunRegistry::string, hlt_dqm_clientPB-live_cfg::xmax, and hlt_dqm_clientPB-live_cfg::xmin.

546  {
547  TProfile *stripProfile = strip->ProfileX();
548 
549  // (from FitSlices of TH2.h)
550 
551  double xmin = stripProfile->GetXaxis()->GetXmin();
552  double xmax = stripProfile->GetXaxis()->GetXmax();
553  int profileBins = stripProfile->GetNbinsX();
554 
555  std::string name = strip->GetName();
556  name += "_smartGaus";
557  TH1D *prof = new TH1D(name.c_str(), strip->GetTitle(), profileBins, xmin, xmax);
558 
559  int cut = 0; // minimum number of entries per fitted bin
560  int nbins = strip->GetXaxis()->GetNbins();
561  int binmin = 1;
562  int ngroup = 1; // bins per step
563  int binmax = nbins;
564 
565  // loop over the strip bins
566  for (int bin = binmin; bin <= binmax; bin += ngroup) {
567  TH1D *hpy = strip->ProjectionY("_temp", bin, bin + ngroup - 1, "e");
568  if (hpy == nullptr)
569  continue;
570  int nentries = Int_t(hpy->GetEntries());
571  if (nentries == 0 || nentries < cut) {
572  delete hpy;
573  continue;
574  }
575 
576  Int_t biny = bin + ngroup / 2;
577 
578  TF1 *gaussian =
579  new TF1("gaussian", "gaus", hpy->GetMean() - width * hpy->GetRMS(), hpy->GetMean() + width * hpy->GetRMS());
580  gaussian->SetParameter(1, hpy->GetMean());
581  gaussian->SetParameter(2, hpy->GetRMS());
582  hpy->Fit("gaussian", "RQL");
583 
584  hpy->GetXaxis()->SetRangeUser(hpy->GetMean() - width * hpy->GetRMS(), hpy->GetMean() + width * hpy->GetRMS());
585  prof->Fill(strip->GetXaxis()->GetBinCenter(biny), gaussian->GetParameter(1));
586  prof->SetBinError(biny, gaussian->GetParameter(2));
587 
588  delete gaussian;
589  delete hpy;
590  } // loop over the bins
591 
592  delete stripProfile;
593  return prof;
594 }
TH1D* smartProfile ( TH2F *  strip,
double  width 
)

smart profiling by double averaging

Definition at line 501 of file InvMatrixUtils.cc.

References newFWLiteAna::bin, GOODCOLL_filter_cfg::cut, mergeVDriftHistosByStation::name, hlt_dqm_clientPB-live_cfg::nbins, AlCaHLTBitMon_QueryRunRegistry::string, hlt_dqm_clientPB-live_cfg::xmax, and hlt_dqm_clientPB-live_cfg::xmin.

501  {
502  TProfile *stripProfile = strip->ProfileX();
503 
504  // (from FitSlices of TH2.h)
505 
506  double xmin = stripProfile->GetXaxis()->GetXmin();
507  double xmax = stripProfile->GetXaxis()->GetXmax();
508  int profileBins = stripProfile->GetNbinsX();
509 
510  std::string name = strip->GetName();
511  name += "_smart";
512  TH1D *prof = new TH1D(name.c_str(), strip->GetTitle(), profileBins, xmin, xmax);
513 
514  int cut = 0; // minimum number of entries per fitted bin
515  int nbins = strip->GetXaxis()->GetNbins();
516  int binmin = 1;
517  int ngroup = 1; // bins per step
518  int binmax = nbins;
519 
520  // loop over the strip bins
521  for (int bin = binmin; bin <= binmax; bin += ngroup) {
522  TH1D *hpy = strip->ProjectionY("_temp", bin, bin + ngroup - 1, "e");
523  if (hpy == nullptr)
524  continue;
525  int nentries = Int_t(hpy->GetEntries());
526  if (nentries == 0 || nentries < cut) {
527  delete hpy;
528  continue;
529  }
530 
531  Int_t biny = bin + ngroup / 2;
532 
533  hpy->GetXaxis()->SetRangeUser(hpy->GetMean() - width * hpy->GetRMS(), hpy->GetMean() + width * hpy->GetRMS());
534  prof->Fill(strip->GetXaxis()->GetBinCenter(biny), hpy->GetMean());
535  prof->SetBinError(biny, hpy->GetRMS());
536 
537  delete hpy;
538  } // loop over the bins
539 
540  delete stripProfile;
541  return prof;
542 }
HepGeom::Point3D<Float_t> TBposition ( const Float_t  amplit[7][7],
const Float_t  beamEne,
const Float_t  w0,
const Float_t  x0,
const Float_t  a0,
const Float_t  sideX,
const Float_t  sideY 
)

return the impact position of the electron over ECAL

Definition at line 106 of file InvMatrixUtils.cc.

References a0, HLT_FULL_cff::depth, PVValHelper::eta, get3x3(), log, PVValHelper::phi, TBposition(), and histoStyle::weight.

Referenced by TBposition().

112  {
113  // variables
114  Float_t caloX = 0.;
115  Float_t caloY = 0.;
116  Float_t sumWeight = 0.;
117  Float_t depth = x0 * (log(beamEne) + a0); // shower depthh, in mm
118  Float_t sin3 = 0.052335956; // sin (3 degrees) , sin3 = sin(3.*3.141592654/180.)
119 
120  Float_t invE3x3 = 1. / get3x3(amplit);
121 
122  // loop over 3x3 crystals
123  for (int eta = 2; eta <= 4; eta++) {
124  for (int phi = 2; phi <= 4; phi++) {
125  Float_t weight = log(amplit[eta][phi] * invE3x3) + w0;
126  if (weight > 0) {
127  caloX += (eta - 3) * sideX * weight;
128  caloY -= (phi - 3) * sideY * weight;
129  sumWeight += weight;
130  }
131  }
132  }
133 
134  caloX /= sumWeight;
135  caloY /= sumWeight;
136 
137  // correction for shower depthh
138  caloX -= depth * sin3;
139  caloY -= depth * sin3;
140 
141  // FIXME the z set to zero
142  HepGeom::Point3D<Float_t> TBposition(caloX, caloY, 0);
143 
144  return TBposition;
145 }
static std::vector< std::string > checklist log
double get3x3(const Float_t energy[7][7])
static constexpr float a0
int weight
Definition: histoStyle.py:51
HepGeom::Point3D< Float_t > TBposition(const Float_t amplit[7][7], const Float_t beamEne, const Float_t w0=4.0, const Float_t x0=8.9, const Float_t a0=6.2, const Float_t sideX=24.06, const Float_t sideY=22.02)
int translateCoeff ( const CLHEP::HepMatrix &  calibcoeff,
const CLHEP::HepMatrix &  sigmaMatrix,
const CLHEP::HepMatrix &  statisticMatrix,
std::string  SMnumber = "1",
double  calibThres = 0.01,
std::string  fileName = "calibOutput.txt",
std::string  genTag = "CAL_GENTAG",
std::string  method = "CAL_METHOD",
std::string  version = "CAL_VERSION",
std::string  type = "CAL_TYPE" 
)

translates the calib coefficients format, from the TB06Studies one to the CMSSSW one

Definition at line 403 of file InvMatrixUtils.cc.

References gather_cfg::cout, PVValHelper::eta, PVValHelper::phi, SCMaxEta, SCMaxPhi, and xtalFromiEtaiPhi().

412  {
413  // open the file for output
414  std::ofstream txt_outfile;
415  txt_outfile.open(fileName.c_str());
416  txt_outfile << SMnumber << "\n"; // super-module number
417  txt_outfile << "-1\n"; // number of events
418  txt_outfile << genTag << "\n";
419  txt_outfile << method << "\n";
420  txt_outfile << version << "\n";
421  txt_outfile << type << "\n";
422 
423  // loop over crystals
424  for (int eta = 0; eta < SCMaxEta; ++eta)
425  for (int phi = 0; phi < SCMaxPhi; ++phi) {
426  if (calibcoeff[eta][phi] < calibThres) {
427  txt_outfile << xtalFromiEtaiPhi(eta + 1, phi + 1) << "\t" << 1 << "\t" << -1 << "\t" << -1 << "\t" << 0 << "\n";
428  std::cout << "[translateCoefff][" << SMnumber << "]\t WARNING crystal " << xtalFromiEtaiPhi(eta + 1, phi + 1)
429  << " calib coeff below threshold: "
430  << "\t" << 1 << "\t" << -1 << "\t" << -1 << "\t" << 0 << "\n";
431  } else
432  txt_outfile << xtalFromiEtaiPhi(eta + 1, phi + 1) << "\t" << calibcoeff[eta][phi] << "\t"
433  << sigmaMatrix[eta][phi] << "\t" << statisticMatrix[eta][phi] << "\t" << 1 << "\n";
434  } // loop over crystals
435 
436  // save and close the file
437  txt_outfile.close();
438  return 0;
439 }
#define SCMaxEta
int xtalFromiEtaiPhi(const int &iEta, const int &iPhi)
#define SCMaxPhi
tuple cout
Definition: gather_cfg.py:144
int writeCalibTxt ( const CLHEP::HepMatrix &  AmplitudeMatrix,
const CLHEP::HepMatrix &  SigmaMatrix,
const CLHEP::HepMatrix &  StatisticMatrix,
std::string  fileName = "calibOutput.txt" 
)

to write the calibration constants file

Definition at line 276 of file InvMatrixUtils.cc.

References EcnaPython_AdcPeg12_S1_10_R170298_1_0_150_Dee0::cerr, gather_cfg::cout, PVValHelper::eta, PVValHelper::phi, RecoTauValidation_cfi::reference, SCMaxEta, SCMaxPhi, and xtalFromEtaPhi().

279  {
280  // look for the reference crystal
281  double reference = 0.;
282  for (int eta = 0; eta < SCMaxEta; ++eta)
283  for (int phi = 0; phi < SCMaxPhi; ++phi) {
284  if (AmplitudeMatrix[eta][phi] && SigmaMatrix[eta][phi] < 100 /*FIXME sigmaCut*/) {
285  reference = AmplitudeMatrix[eta][phi];
286  std::cout << "[InvMatrixUtils][writeCalibTxt] reference crystal: "
287  << "(" << eta << "," << phi << ") -> " << reference << "\n";
288  break;
289  }
290  }
291  if (!reference) {
292  std::cerr << "ERROR: no calibration coefficients found" << std::endl;
293  return 1;
294  }
295 
296  // open the file for output
297  std::ofstream txt_outfile;
298  txt_outfile.open(fileName.c_str());
299  txt_outfile << "# xtal\tcoeff\tsigma\tevt\tisGood\n";
300 
301  // loop over the crystals
302  for (int eta = 0; eta < SCMaxEta; ++eta)
303  for (int phi = 0; phi < SCMaxPhi; ++phi) {
304  int isGood = 1;
305  if (AmplitudeMatrix[eta][phi] == 0)
306  isGood = 0;
307  if (SigmaMatrix[eta][phi] > 100 /*FIXME sigmaCut*/)
308  isGood = 0;
309  txt_outfile << xtalFromEtaPhi(eta, phi) << "\t" << AmplitudeMatrix[eta][phi] / reference << "\t"
310  << SigmaMatrix[eta][phi] << "\t" << StatisticMatrix[eta][phi] << "\t" << isGood << "\n";
311  }
312 
313  // save and close the file
314  txt_outfile.close();
315  return 0;
316 }
#define SCMaxEta
#define SCMaxPhi
tuple cout
Definition: gather_cfg.py:144
int xtalFromEtaPhi(const int &myEta, const int &myPhi)
int writeCMSSWCoeff ( const CLHEP::HepMatrix &  amplMatrix,
double  calibThres,
float  ERef,
const CLHEP::HepMatrix &  sigmaMatrix,
const CLHEP::HepMatrix &  statisticMatrix,
std::string  fileName = "calibOutput.txt",
std::string  genTag = "CAL_GENTAG",
std::string  method = "CAL_METHOD",
std::string  version = "CAL_VERSION",
std::string  type = "CAL_TYPE" 
)

to write the file fpr the CMSSW in the DB compliant format (using Energy as reference)

Definition at line 320 of file InvMatrixUtils.cc.

References PVValHelper::eta, PVValHelper::phi, RecoTauValidation_cfi::reference, SCMaxEta, SCMaxPhi, and xtalFromiEtaiPhi().

329  {
330  // open the file for output
331  std::ofstream txt_outfile;
332  txt_outfile.open(fileName.c_str());
333  txt_outfile << "1\n"; // super-module number
334  txt_outfile << "-1\n"; // number of events
335  txt_outfile << genTag << "\n";
336  txt_outfile << method << "\n";
337  txt_outfile << version << "\n";
338  txt_outfile << type << "\n";
339 
340  double reference = ERef;
341 
342  // loop over crystals
343  for (int eta = 0; eta < SCMaxEta; ++eta)
344  for (int phi = 0; phi < SCMaxPhi; ++phi) {
345  if (amplMatrix[eta][phi] <= calibThres)
346  txt_outfile << xtalFromiEtaiPhi(eta + 1, phi + 1) << "\t" << 1 << "\t" << -1 << "\t" << -1 << "\t" << 0 << "\n";
347  else
348  txt_outfile << xtalFromiEtaiPhi(eta + 1, phi + 1) << "\t" << reference / amplMatrix[eta][phi] << "\t"
349  << sigmaMatrix[eta][phi] << "\t" << statisticMatrix[eta][phi] << "\t" << 1 << "\n";
350  } // loop over crystals
351 
352  // save and close the file
353  txt_outfile.close();
354  return 0;
355 }
#define SCMaxEta
int xtalFromiEtaiPhi(const int &iEta, const int &iPhi)
#define SCMaxPhi
int writeCMSSWCoeff ( const CLHEP::HepMatrix &  amplMatrix,
double  calibThres,
int  etaRef,
int  phiRef,
const CLHEP::HepMatrix &  sigmaMatrix,
const CLHEP::HepMatrix &  statisticMatrix,
std::string  fileName = "calibOutput.txt",
std::string  genTag = "CAL_GENTAG",
std::string  method = "CAL_METHOD",
std::string  version = "CAL_VERSION",
std::string  type = "CAL_TYPE" 
)

to write the file fpr the CMSSW in the DB compliant format (using Crystal as reference)

Definition at line 359 of file InvMatrixUtils.cc.

References EcnaPython_AdcPeg12_S1_10_R170298_1_0_150_Dee0::cerr, PVValHelper::eta, PVValHelper::phi, RecoTauValidation_cfi::reference, SCMaxEta, SCMaxPhi, and xtalFromiEtaiPhi().

369  {
370  // open the file for output
371  std::ofstream txt_outfile;
372  txt_outfile.open(fileName.c_str());
373  txt_outfile << "1\n"; // super-module number
374  txt_outfile << "-1\n"; // number of events
375  txt_outfile << genTag << "\n";
376  txt_outfile << method << "\n";
377  txt_outfile << version << "\n";
378  txt_outfile << type << "\n";
379 
380  if (amplMatrix[etaRef - 1][phiRef - 1] == 0) {
381  std::cerr << "The reference crystal: (" << etaRef << "," << phiRef << ") is out of range\n";
382  return 1;
383  }
384  double reference = amplMatrix[etaRef - 1][phiRef - 1];
385 
386  // loop over crystals
387  for (int eta = 0; eta < SCMaxEta; ++eta)
388  for (int phi = 0; phi < SCMaxPhi; ++phi) {
389  if (amplMatrix[eta][phi] <= calibThres)
390  txt_outfile << xtalFromiEtaiPhi(eta + 1, phi + 1) << "\t" << 1 << "\t" << -1 << "\t" << -1 << "\t" << 0 << "\n";
391  else
392  txt_outfile << xtalFromiEtaiPhi(eta + 1, phi + 1) << "\t" << reference / amplMatrix[eta][phi] << "\t"
393  << sigmaMatrix[eta][phi] << "\t" << statisticMatrix[eta][phi] << "\t" << 1 << "\n";
394  } // loop over crystals
395 
396  // save and close the file
397  txt_outfile.close();
398  return 0;
399 }
#define SCMaxEta
int xtalFromiEtaiPhi(const int &iEta, const int &iPhi)
#define SCMaxPhi
int xtalFromEtaPhi ( const int &  myEta,
const int &  myPhi 
)

to get the crystal number from eta and phi

to get the parameters from a congiguration file

Definition at line 204 of file InvMatrixUtils.cc.

References phiFromXtal(), and gpuClustering::x.

Referenced by writeCalibTxt().

204  {
205  int xMin = 20 * myEta + 1;
206  int xMax = 20 * (myEta + 1) + 1;
207 
208  int myCryst = 999999;
209 
210  for (int x = xMin; x < xMax; x++) {
211  if (phiFromXtal(x) == myPhi)
212  myCryst = x;
213  }
214  return myCryst;
215 }
int phiFromXtal(const int &xtal)
uint16_t const *__restrict__ x
Definition: gpuClustering.h:39
int xtalFromiEtaiPhi ( const int &  iEta,
const int &  iPhi 
)

to get the crystal number from iEta and iPhi iEta runs from 1 to 85 iPhi runs from 1 to 20

Definition at line 219 of file InvMatrixUtils.cc.

References cms::cuda::assert().

Referenced by translateCoeff(), and writeCMSSWCoeff().

219  {
220  assert(iEta >= 1);
221  assert(iEta <= 85);
222  assert(iPhi >= 1);
223  assert(iPhi <= 20);
224  return 20 * (iEta - 1) + 21 - iPhi;
225 }
assert(be >=bs)