CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes
PatternOptimizerBase Class Reference

#include <PatternOptimizerBase.h>

Inheritance diagram for PatternOptimizerBase:
EmulationObserverBase IOMTFEmulationObserver PatternGenerator

Public Member Functions

void endJob () override
 
void observeEventEnd (const edm::Event &iEvent, std::unique_ptr< l1t::RegionalMuonCandBxCollection > &finalCandidates) override
 
 PatternOptimizerBase (const edm::ParameterSet &edmCfg, const OMTFConfiguration *omtfConfig, GoldenPatternVec< GoldenPatternWithStat > &gps)
 
 ~PatternOptimizerBase () override
 
- Public Member Functions inherited from EmulationObserverBase
 EmulationObserverBase (const edm::ParameterSet &edmCfg, const OMTFConfiguration *omtfConfig)
 
const std::vector< const reco::GenParticle * > findGenMuon (const edm::Event &event)
 
const SimTrackfindSimMuon (const edm::Event &event, const SimTrack *previous=nullptr)
 
void observeEventBegin (const edm::Event &iEvent) override
 
void observeProcesorEmulation (unsigned int iProcessor, l1t::tftype mtfType, const std::shared_ptr< OMTFinput > &input, const AlgoMuons &algoCandidates, const AlgoMuons &gbCandidates, const std::vector< l1t::RegionalMuonCand > &candMuons) override
 
 ~EmulationObserverBase () override
 
- Public Member Functions inherited from IOMTFEmulationObserver
virtual void addProcesorData (std::string key, boost::property_tree::ptree &procDataTree)
 
virtual void beginRun (edm::EventSetup const &eventSetup)
 
 IOMTFEmulationObserver ()
 
virtual void observeProcesorBegin (unsigned int iProcessor, l1t::tftype mtfType)
 
virtual ~IOMTFEmulationObserver ()
 

Static Public Member Functions

static double vxIntegMuRate (double pt_GeV, double dpt, double etaFrom, double etaTo)
 
static double vxMuRate (double pt_GeV)
 

Protected Member Functions

virtual double getEventRateWeight (double pt)
 
void printPatterns ()
 
virtual void saveHists (TFile &outfile)
 
void savePatternsInRoot (std::string rootFileName)
 

Protected Attributes

GoldenPatternVec< GoldenPatternWithStat > & goldenPatterns
 
TH1I * simMuFoundByOmtfPt = nullptr
 
TH1I * simMuPt = nullptr
 
TH1F * simMuPtSpectrum = nullptr
 
TH2I * simMuPtVsDispl = nullptr
 
TH2I * simMuPtVsRho = nullptr
 
bool writeLayerStat = false
 
- Protected Attributes inherited from EmulationObserverBase
unsigned int candProcIndx = 0
 
edm::ParameterSet edmCfg
 
AlgoMuons::value_type omtfCand
 
const OMTFConfigurationomtfConfig
 
l1t::RegionalMuonCand regionalMuonCand
 
const SimTracksimMuon = nullptr
 

Detailed Description

Definition at line 25 of file PatternOptimizerBase.h.

Constructor & Destructor Documentation

◆ PatternOptimizerBase()

PatternOptimizerBase::PatternOptimizerBase ( const edm::ParameterSet edmCfg,
const OMTFConfiguration omtfConfig,
GoldenPatternVec< GoldenPatternWithStat > &  gps 
)

Definition at line 66 of file PatternOptimizerBase.cc.

References EmulationObserverBase::edmCfg, edm::ParameterSet::exists(), goldenPatterns, simMuFoundByOmtfPt, simMuPt, simMuPtSpectrum, simMuPtVsDispl, and simMuPtVsRho.

70  // TODO Auto-generated constructor stub
71 
72  simMuPt = new TH1I("simMuPt", "simMuPt", goldenPatterns.size(), -0.5, goldenPatterns.size() - 0.5);
74  new TH1I("simMuFoundByOmtfPt", "simMuFoundByOmtfPt", goldenPatterns.size(), -0.5, goldenPatterns.size() - 0.5);
75 
76  simMuPtSpectrum = new TH1F("simMuPtSpectrum", "simMuPtSpectrum", 800, 0, 400);
77 
78  simMuPtVsDispl = new TH2I("simMuPtVsDispl", "simMuPtVsDispl;pt [GeV];dxy [cm]", 100, 0, 400, 100, 0, 400);
79  simMuPtVsRho = new TH2I("simMuPtVsRho", "simMuPtVsRho;pt [GeV];rho [cm]", 100, 0, 400, 100, 0, 400);
80 
81  if (edmCfg.exists("simTracksTag") == false)
82  edm::LogError("l1tOmtfEventPrint") << "simTracksTag not found !!!" << std::endl;
83 }
EmulationObserverBase(const edm::ParameterSet &edmCfg, const OMTFConfiguration *omtfConfig)
bool exists(std::string const &parameterName) const
checks if a parameter exists
GoldenPatternVec< GoldenPatternWithStat > & goldenPatterns
const OMTFConfiguration * omtfConfig

◆ ~PatternOptimizerBase()

PatternOptimizerBase::~PatternOptimizerBase ( )
override

Definition at line 85 of file PatternOptimizerBase.cc.

85 {}

Member Function Documentation

◆ endJob()

void PatternOptimizerBase::endJob ( void  )
overridevirtual

Implements IOMTFEmulationObserver.

Definition at line 122 of file PatternOptimizerBase.cc.

References EmulationObserverBase::edmCfg, fileCollector2::fName, edm::ParameterSet::getParameter(), goldenPatterns, EmulationObserverBase::omtfConfig, savePatternsInRoot(), AlCaHLTBitMon_QueryRunRegistry::string, and XMLConfigWriter::writeGPs().

Referenced by PatternGenerator::endJob().

122  {
123  std::string fName = edmCfg.getParameter<std::string>("optimisedPatsXmlFile");
124  edm::LogImportant("PatternOptimizer") << " Writing optimized patterns to " << fName << std::endl;
125  XMLConfigWriter xmlWriter(omtfConfig, false, false);
126  xmlWriter.writeGPs(goldenPatterns, fName);
127 
128  fName.replace(fName.find('.'), fName.length(), ".root");
130 }
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
Log< level::Error, true > LogImportant
GoldenPatternVec< GoldenPatternWithStat > & goldenPatterns
void savePatternsInRoot(std::string rootFileName)
const OMTFConfiguration * omtfConfig

◆ getEventRateWeight()

virtual double PatternOptimizerBase::getEventRateWeight ( double  pt)
inlineprotectedvirtual

Definition at line 46 of file PatternOptimizerBase.h.

Referenced by observeEventEnd().

46 { return 1; }

◆ observeEventEnd()

void PatternOptimizerBase::observeEventEnd ( const edm::Event iEvent,
std::unique_ptr< l1t::RegionalMuonCandBxCollection > &  finalCandidates 
)
overridevirtual

Reimplemented from IOMTFEmulationObserver.

Definition at line 105 of file PatternOptimizerBase.cc.

References funct::abs(), getEventRateWeight(), OMTFConfiguration::getPatternNum(), goldenPatterns, GoldenPattern::key(), CoreSimTrack::momentum(), EmulationObserverBase::omtfCand, EmulationObserverBase::omtfConfig, simMuFoundByOmtfPt, EmulationObserverBase::simMuon, simMuPtSpectrum, Key::theNumber, and CoreSimTrack::type().

Referenced by PatternGenerator::observeEventEnd().

106  {
107  if (simMuon == nullptr || omtfCand->getGoldenPatern() == nullptr) //no sim muon or empty candidate
108  return;
109 
110  double ptSim = simMuon->momentum().pt();
111  int chargeSim = (std::abs(simMuon->type()) == 13) ? simMuon->type() / -13 : 0;
112 
113  //double muDxy = (-1 * genMuon->vx() * genMuon->py() + genMuon->vy() * genMuon->px()) / genMuon->pt();;
114 
115  unsigned int exptPatNum = omtfConfig->getPatternNum(ptSim, chargeSim);
116  GoldenPatternWithStat* exptCandGp = goldenPatterns.at(exptPatNum).get(); // expected pattern
117  simMuFoundByOmtfPt->Fill(exptCandGp->key().theNumber); //TODO add weight of the muons pt spectrum
118 
119  simMuPtSpectrum->Fill(ptSim, getEventRateWeight(ptSim));
120 }
unsigned int theNumber
Definition: GoldenPattern.h:37
AlgoMuons::value_type omtfCand
unsigned int getPatternNum(double pt, int charge) const
charge: -1 - negative, +1 - positive
const math::XYZTLorentzVectorD & momentum() const
Definition: CoreSimTrack.h:19
int type() const
particle type (HEP PDT convension)
Definition: CoreSimTrack.h:22
Key key() const
Definition: GoldenPattern.h:56
virtual double getEventRateWeight(double pt)
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
GoldenPatternVec< GoldenPatternWithStat > & goldenPatterns
const OMTFConfiguration * omtfConfig

◆ printPatterns()

void PatternOptimizerBase::printPatterns ( )
protected

Definition at line 87 of file PatternOptimizerBase.cc.

References OMTFConfiguration::getPatternPtRange(), goldenPatterns, RPCConst::iptFromPt(), submitPVResolutionJobs::key, EmulationObserverBase::omtfConfig, DiDispStaMuonMonitor_cfi::pt, and OMTFConfiguration::PatternPt::ptFrom.

87  {
88  edm::LogVerbatim("l1tOmtfEventPrint") << __FUNCTION__ << ": " << __LINE__ << " called!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! "
89  << std::endl;
90  for (int patNum = goldenPatterns.size() - 1; patNum >= 0; patNum--) {
91  double pt = omtfConfig->getPatternPtRange(patNum).ptFrom;
92  if (pt > 0) {
93  edm::LogVerbatim("l1tOmtfEventPrint")
94  << "cmsRun runThresholdCalc.py " << patNum << " " << (patNum + 1) << " _" << RPCConst::iptFromPt(pt) << "_";
95  if (goldenPatterns[patNum]->key().theCharge == -1)
96  edm::LogVerbatim("l1tOmtfEventPrint") << "m_";
97  else
98  edm::LogVerbatim("l1tOmtfEventPrint") << "p_";
99 
100  edm::LogVerbatim("l1tOmtfEventPrint") << " > out" << patNum << ".txt" << std::endl;
101  }
102  }
103 }
Log< level::Info, true > LogVerbatim
key
prepare the HTCondor submission files and eventually submit them
GoldenPatternVec< GoldenPatternWithStat > & goldenPatterns
PatternPt getPatternPtRange(unsigned int patNum) const
static int iptFromPt(const double pt)
Definition: RPCConst.cc:10
const OMTFConfiguration * omtfConfig

◆ saveHists()

virtual void PatternOptimizerBase::saveHists ( TFile &  outfile)
inlineprotectedvirtual

Reimplemented in PatternGenerator.

Definition at line 48 of file PatternOptimizerBase.h.

Referenced by savePatternsInRoot().

48 {};

◆ savePatternsInRoot()

void PatternOptimizerBase::savePatternsInRoot ( std::string  rootFileName)
protected

Definition at line 132 of file PatternOptimizerBase.cc.

References svgfig::canvas(), EmulationObserverBase::edmCfg, edm::ParameterSet::getParameter(), OMTFConfiguration::getPatternPtRange(), OMTFConfiguration::getRefToLogicNumber(), goldenPatterns, runTauDisplay::gp, compareTotals::hist, createfilelist::int, OMTFConfiguration::nPdfBins(), EmulationObserverBase::omtfConfig, timingPdfMaker::outfile, OMTFConfiguration::pdfMaxValue(), OMTFConfiguration::PatternPt::ptFrom, OMTFConfiguration::PatternPt::ptTo, CSCSkim_cfi::rootFileName, saveHists(), edm::shift, simMuFoundByOmtfPt, simMuPtSpectrum, simMuPtVsDispl, simMuPtVsRho, writeLayerStat, TrackerOfflineValidation_Dqm_cff::xmax, and TrackerOfflineValidation_Dqm_cff::xmin.

Referenced by endJob().

132  {
133  gStyle->SetOptStat(111111);
134  TFile outfile(rootFileName.c_str(), "RECREATE");
135  edm::LogVerbatim("l1tOmtfEventPrint") << __FUNCTION__ << ": " << __LINE__ << " out fileName " << rootFileName
136  << " outfile->GetName() " << outfile.GetName() << " writeLayerStat "
137  << writeLayerStat << endl;
138 
139  outfile.cd();
140  simMuFoundByOmtfPt->Write();
141 
142  simMuPtSpectrum->Write();
143  simMuPtVsDispl->Write();
144  simMuPtVsRho->Write();
145 
146  outfile.mkdir("patternsPdfs")->cd();
147  outfile.mkdir("patternsPdfs/canvases");
148  outfile.mkdir("patternsPdfs/canvases2");
149  outfile.mkdir("layerStats");
150  ostringstream ostrName;
151  ostringstream ostrTtle;
152  vector<TH1F*> classProbHists;
153  for (unsigned int iRefLayer = 0; iRefLayer < goldenPatterns[0]->getPdf()[0].size(); ++iRefLayer) {
154  ostrName.str("");
155  ostrName << "Neg_RefLayer_" << iRefLayer;
156  ostrTtle.str("");
157  ostrTtle << "Neg_RefLayer_" << iRefLayer;
158  classProbHists.push_back(new TH1F(
159  ostrName.str().c_str(), ostrTtle.str().c_str(), goldenPatterns.size(), -0.5, goldenPatterns.size() - 0.5));
160 
161  ostrName.str("");
162  ostrName << "Pos_RefLayer_" << iRefLayer;
163  ostrTtle.str("");
164  ostrTtle << "Pos_RefLayer_" << iRefLayer;
165  classProbHists.push_back(new TH1F(
166  ostrName.str().c_str(), ostrTtle.str().c_str(), goldenPatterns.size(), -0.5, goldenPatterns.size() - 0.5));
167  }
168 
169  auto gpsCnt = goldenPatterns.size();
170  auto layerCnt = goldenPatterns[0]->getPdf().size();
171  auto refLayerCnt = goldenPatterns[0]->getPdf().size();
172 
173  vector<vector<TH2F*> > distPhiLayerRefLayer(layerCnt, vector<TH2F*>(refLayerCnt, nullptr));
174  vector<vector<TH2F*> > meanDistPhiLayerRefLayer(layerCnt, vector<TH2F*>(refLayerCnt, nullptr));
175  vector<vector<TH2F*> > pdfsLayerRefLayer(layerCnt, vector<TH2F*>(refLayerCnt, nullptr));
176 
177  for (unsigned int iLayer = 0; iLayer < layerCnt; ++iLayer) {
178  int rangeFactor = 1;
179  if (iLayer == 1 || iLayer == 3 || iLayer == 5)
180  rangeFactor = 2;
181 
182  for (unsigned int iRefLayer = 0; iRefLayer < refLayerCnt; ++iRefLayer) {
183  ostrName.str("");
184  ostrName << "distPhi_refLayer_" << iRefLayer << "_layer_" << iLayer;
185  ostrTtle.str("");
186  ostrTtle << "distPhi refLayer " << iRefLayer << " layer " << iLayer;
187  //edm::LogVerbatim("l1tOmtfEventPrint") <<__FUNCTION__<<": "<<__LINE__<<" creating hist "<<ostrTtle.str()<<std::endl;
188  distPhiLayerRefLayer[iLayer][iRefLayer] = new TH2F(ostrName.str().c_str(),
189  ostrTtle.str().c_str(),
190  gpsCnt,
191  0,
192  gpsCnt,
193  omtfConfig->nPdfBins() * rangeFactor * 2,
194  (int)(omtfConfig->nPdfBins()) * (-rangeFactor) - 0.5,
195  omtfConfig->nPdfBins() * rangeFactor - 0.5);
196 
197  ostrName.str("");
198  ostrName << "meanDistPhi_refLayer_" << iRefLayer << "_Layer_" << iLayer;
199  ostrTtle.str("");
200  ostrTtle << "meanDistPhi refLayer " << iRefLayer << " Layer " << iLayer;
201  //edm::LogVerbatim("l1tOmtfEventPrint") <<__FUNCTION__<<": "<<__LINE__<<" creating hist "<<ostrTtle.str()<<std::endl;
202  meanDistPhiLayerRefLayer[iLayer][iRefLayer] = new TH2F(ostrName.str().c_str(),
203  ostrTtle.str().c_str(),
204  gpsCnt,
205  0,
206  gpsCnt,
207  omtfConfig->nPdfBins() * rangeFactor * 2,
208  (int)(omtfConfig->nPdfBins()) * (-rangeFactor) - 0.5,
209  omtfConfig->nPdfBins() * rangeFactor - 0.5);
210 
211  ostrName.str("");
212  ostrName << "pdfs_refLayer_" << iRefLayer << "_layer_" << iLayer;
213  ostrTtle.str("");
214  ostrTtle << "pdfs refLayer " << iRefLayer << " layer " << iLayer;
215  //edm::LogVerbatim("l1tOmtfEventPrint") <<__FUNCTION__<<": "<<__LINE__<<" creating hist "<<ostrTtle.str()<<std::endl;
216  pdfsLayerRefLayer[iLayer][iRefLayer] = new TH2F(ostrName.str().c_str(),
217  ostrTtle.str().c_str(),
218  gpsCnt,
219  0,
220  gpsCnt,
221  omtfConfig->nPdfBins(),
222  -0.5,
223  omtfConfig->nPdfBins() - 0.5);
224  }
225  }
226 
227  for (auto& gp : goldenPatterns) {
228  OMTFConfiguration::PatternPt patternPt = omtfConfig->getPatternPtRange(gp->key().theNumber);
229  if (gp->key().thePt == 0)
230  continue;
231  //edm::LogVerbatim("l1tOmtfEventPrint") <<__FUNCTION__<<": "<<__LINE__<<" "<<gp->key()<<std::endl;
232  ostrName.str("");
233  ostrName << "PatNum_" << gp->key().theNumber;
234  ostrTtle.str("");
235  ostrTtle << "PatNum_" << gp->key().theNumber << "_ptCode_" << gp->key().thePt << "_Pt_" << patternPt.ptFrom << "_"
236  << patternPt.ptTo << "_GeV";
237  TCanvas* canvas = new TCanvas(ostrName.str().c_str(), ostrTtle.str().c_str(), 1200, 1000);
238  canvas->Divide(gp->getPdf().size(), gp->getPdf()[0].size(), 0, 0);
239 
240  for (unsigned int iRefLayer = 0; iRefLayer < gp->getPdf()[0].size(); ++iRefLayer) {
241  for (unsigned int iLayer = 0; iLayer < gp->getPdf().size(); ++iLayer) {
242  canvas->cd(1 + iLayer + iRefLayer * gp->getPdf().size());
243  ostrName.str("");
244  ostrName << "PatNum_" << gp->key().theNumber << "_refLayer_" << iRefLayer << "_Layer_" << iLayer;
245  ostrTtle.str("");
246  ostrTtle << "PatNum " << gp->key().theNumber << " ptCode " << gp->key().thePt << " refLayer " << iRefLayer
247  << " Layer " << iLayer << " meanDistPhi " << gp->meanDistPhi[iLayer][iRefLayer][0]
248  << " distPhiBitShift "
249  << gp->getDistPhiBitShift(iLayer, iRefLayer); //"_Pt_"<<patternPt.ptFrom<<"_"<<patternPt.ptTo<<"_GeV
250  //edm::LogVerbatim("l1tOmtfEventPrint") <<__FUNCTION__<<": "<<__LINE__<<" creating hist "<<ostrTtle.str()<<std::endl;
251  TH1F* hist = new TH1F(
252  ostrName.str().c_str(), ostrTtle.str().c_str(), omtfConfig->nPdfBins(), -0.5, omtfConfig->nPdfBins() - 0.5);
253 
254  int pdfMiddle = gp->getPdf()[iLayer][iRefLayer].size() / 2;
255  int shift = gp->getDistPhiBitShift(iLayer, iRefLayer);
256 
257  for (unsigned int iPdf = 0; iPdf < gp->getPdf()[iLayer][iRefLayer].size(); iPdf++) {
258  hist->Fill(iPdf, gp->pdfAllRef[iLayer][iRefLayer][iPdf]);
259 
260  distPhiLayerRefLayer[iLayer][iRefLayer]->Fill(
261  gp->key().theNumber,
262  (((int)iPdf - pdfMiddle) << shift) + gp->meanDistPhi[iLayer][iRefLayer][0],
263  gp->pdfAllRef[iLayer][iRefLayer][iPdf]);
264 
265  pdfsLayerRefLayer[iLayer][iRefLayer]->Fill(
266  gp->key().theNumber, (int)iPdf, gp->pdfAllRef[iLayer][iRefLayer][iPdf]);
267  }
268  if ((int)iLayer == (omtfConfig->getRefToLogicNumber()[iRefLayer]))
269  hist->SetLineColor(kGreen);
270 
271  meanDistPhiLayerRefLayer[iLayer][iRefLayer]->Fill(
272  gp->key().theNumber, gp->meanDistPhi[iLayer][iRefLayer][0], 1);
273 
274  hist->GetYaxis()->SetRangeUser(0, omtfConfig->pdfMaxValue() + 1);
275  hist->Draw("hist");
276 
277  outfile.cd("patternsPdfs");
278  hist->Write();
279 
281  if (writeLayerStat) {
282  bool saveTh2 = false;
283  if (gp->getStatistics()[iLayer][iRefLayer][0].size() > 1)
284  saveTh2 = true;
285 
286  outfile.cd("layerStats");
287 
288  string histName = "histLayerStat_" + ostrName.str();
289  unsigned int binCnt1 = gp->getStatistics()[iLayer][iRefLayer].size();
290  if (!saveTh2) {
291  TH1I* histLayerStat = new TH1I(histName.c_str(), histName.c_str(), binCnt1, -0.5, binCnt1 - 0.5);
292  for (unsigned int iBin = 0; iBin < binCnt1; iBin++) {
293  histLayerStat->Fill(iBin, gp->getStatistics()[iLayer][iRefLayer][iBin][0]);
294  }
295  histLayerStat->Write();
296  } else {
297  if (iRefLayer == 0 || iRefLayer == 2) { //TODO!!!!!!!!!!!!!!!!!!!!!!!!
298  unsigned int binCnt2 = gp->getStatistics()[iLayer][iRefLayer][0].size();
299  //TH2I* histLayerStat = new TH2I(histName.c_str(), (histName + ";ref phiB;delta_phi").c_str(), binCnt2, -0.5, binCnt2 - 0.5, binCnt1, -0.5, binCnt1 - 0.5);
300  double xmin = -0.5 - binCnt2 / 2;
301  double xmax = binCnt2 / 2 - 0.5;
302  if (edmCfg.getParameter<string>("patternGenerator") == "deltaPhiVsPhiRef") {
303  xmin = -0.5;
304  xmax = binCnt2 - 0.5;
305  }
306  TH2I* histLayerStat = new TH2I(histName.c_str(),
307  (histName + ";ref phiB;delta_phi").c_str(),
308  binCnt2,
309  xmin,
310  xmax,
311  binCnt1,
312  -0.5 - binCnt1 / 2,
313  binCnt1 / 2 - 0.5);
314 
315  if (edmCfg.getParameter<string>("patternGenerator") == "deltaPhiVsPhiRef")
316  histLayerStat->GetXaxis()->SetTitle("ref phi");
317 
318  for (unsigned int iBin1 = 0; iBin1 < binCnt1; iBin1++) { //deltaPhi
319  for (unsigned int iBin2 = 0; iBin2 < binCnt2; iBin2++) { //phiB
320  //histLayerStat->Fill(iBin2, iBin1, gp->getStatistics()[iLayer][iRefLayer][iBin1][iBin2]); //looks that using Fill leads to huge memory cosumption
321  histLayerStat->SetBinContent(
322  iBin2 + 1, iBin1 + 1, gp->getStatistics()[iLayer][iRefLayer][iBin1][iBin2]);
323  }
324  }
325  histLayerStat->Write();
326  histLayerStat->Delete();
327  }
328  }
329  }
330  }
331  }
332  outfile.cd("patternsPdfs/canvases");
333  canvas->Write();
334  delete canvas;
335 
336  unsigned int iPdf = omtfConfig->nPdfBins() / 2;
337  for (unsigned int iRefLayer = 0; iRefLayer < gp->getPdf()[0].size(); ++iRefLayer) {
338  unsigned int refLayerLogicNumber = omtfConfig->getRefToLogicNumber()[iRefLayer];
339  if (gp->key().theCharge == -1) {
340  classProbHists[2 * iRefLayer]->Fill(gp->key().theNumber, gp->pdfAllRef[refLayerLogicNumber][iRefLayer][iPdf]);
341  } else
342  classProbHists[2 * iRefLayer + 1]->Fill(gp->key().theNumber,
343  gp->pdfAllRef[refLayerLogicNumber][iRefLayer][iPdf]);
344  }
345  }
346 
347  outfile.cd();
348  for (auto& classProbHist : classProbHists) {
349  classProbHist->Write();
350  }
351 
352  outfile.cd("patternsPdfs/canvases2");
353  for (unsigned int iRefLayer = 0; iRefLayer < goldenPatterns[0]->getPdf()[0].size(); ++iRefLayer) {
354  ostrName.str("");
355  ostrName << "distPhiForPatterns_Reflayer_" << iRefLayer;
356  ostrTtle.str("");
357  ostrTtle << "distPhiForPatterns Reflayer " << iRefLayer;
358 
359  TCanvas* canvas = new TCanvas(ostrName.str().c_str(), ostrTtle.str().c_str(), 1200, 1000);
360  canvas->Divide(6, 3, 0, 0);
361 
362  for (unsigned int iLayer = 0; iLayer < distPhiLayerRefLayer.size(); ++iLayer) {
363  canvas->cd(iLayer + 1);
364  canvas->cd(iLayer + 1)->SetGridx();
365  canvas->cd(iLayer + 1)->SetGridy();
366 
367  //distPhiLayerRefLayer[iLayer][iRefLayer]->SetLineColor(kBlack);
368  distPhiLayerRefLayer[iLayer][iRefLayer]->Draw("colz");
369 
370  meanDistPhiLayerRefLayer[iLayer][iRefLayer]->SetLineColor(kRed);
371  meanDistPhiLayerRefLayer[iLayer][iRefLayer]->Draw("boxsame");
372 
373  distPhiLayerRefLayer[iLayer][iRefLayer]->Write();
374  meanDistPhiLayerRefLayer[iLayer][iRefLayer]->Write();
375  pdfsLayerRefLayer[iLayer][iRefLayer]->Write();
376  }
377 
378  canvas->Write();
379 
380  ostrName.str("");
381  ostrName << "pdfsForPatterns_Reflayer_" << iRefLayer;
382  ostrTtle.str("");
383  ostrTtle << "pdfsForPatterns Reflayer " << iRefLayer;
384 
385  canvas = new TCanvas(ostrName.str().c_str(), ostrTtle.str().c_str(), 1200, 1000);
386  canvas->Divide(6, 3, 0, 0);
387  for (unsigned int iLayer = 0; iLayer < distPhiLayerRefLayer.size(); ++iLayer) {
388  canvas->cd(iLayer + 1);
389  canvas->cd(iLayer + 1)->SetGridx();
390  canvas->cd(iLayer + 1)->SetGridy();
391 
392  pdfsLayerRefLayer[iLayer][iRefLayer]->Draw("colz");
393  }
394 
395  canvas->Write();
396  }
397 
399 
400  outfile.Close();
401 }
Log< level::Info, true > LogVerbatim
int pdfMaxValue() const
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
pattern pt range in Gev
const std::vector< int > & getRefToLogicNumber() const
virtual void saveHists(TFile &outfile)
GoldenPatternVec< GoldenPatternWithStat > & goldenPatterns
PatternPt getPatternPtRange(unsigned int patNum) const
def canvas(sub, attr)
Definition: svgfig.py:482
static unsigned int const shift
unsigned int nPdfBins() const
const OMTFConfiguration * omtfConfig

◆ vxIntegMuRate()

double PatternOptimizerBase::vxIntegMuRate ( double  pt_GeV,
double  dpt,
double  etaFrom,
double  etaTo 
)
static

Definition at line 57 of file PatternOptimizerBase.cc.

References RPCpg::rate(), and vxMuRate().

Referenced by PatternGenerator::modifyClassProb().

57  {
58  //integration using trapeze method - not exact but good enough
59  double rate = 0.5 * (vxMuRate(pt_GeV) + vxMuRate(pt_GeV + dpt)) * dpt;
60 
61  rate = rate * (etaTo - etaFrom);
62  //edm::LogError("l1tOmtfEventPrint")<<ptCode<<" "<<rate;//<<<<<<<<<<<<<<<<<<<<<<<<
63  return rate;
64 }
static double vxMuRate(double pt_GeV)
double rate(double x)
Definition: Constants.cc:3

◆ vxMuRate()

double PatternOptimizerBase::vxMuRate ( double  pt_GeV)
static

Definition at line 37 of file PatternOptimizerBase.cc.

References a, JetChargeProducer_cfi::exp, amptDefaultParameters_cff::mu, and RPCpg::rate().

Referenced by vxIntegMuRate().

37  {
38  if (pt_GeV == 0)
39  return 0.0;
40  const double lum = 2.0e34; //defoult is 1.0e34;
41  const double dabseta = 1.0;
42  const double dpt = 1.0;
43  const double afactor = 1.0e-34 * lum * dabseta * dpt;
44  const double a = 2 * 1.3084E6;
45  const double mu = -0.725;
46  const double sigma = 0.4333;
47  const double s2 = 2 * sigma * sigma;
48 
49  double ptlog10;
50  ptlog10 = log10(pt_GeV);
51  double ex = (ptlog10 - mu) * (ptlog10 - mu) / s2;
52  double rate = (a * exp(-ex) * afactor);
53  //edm::LogError("l1tOmtfEventPrint")<<ptCode<<" "<<rate;//<<<<<<<<<<<<<<<<<<<<<<<<
54  return rate;
55 }
double rate(double x)
Definition: Constants.cc:3
double a
Definition: hdecay.h:121

Member Data Documentation

◆ goldenPatterns

GoldenPatternVec<GoldenPatternWithStat>& PatternOptimizerBase::goldenPatterns
protected

◆ simMuFoundByOmtfPt

TH1I* PatternOptimizerBase::simMuFoundByOmtfPt = nullptr
protected

◆ simMuPt

TH1I* PatternOptimizerBase::simMuPt = nullptr
protected

Definition at line 52 of file PatternOptimizerBase.h.

Referenced by PatternOptimizerBase().

◆ simMuPtSpectrum

TH1F* PatternOptimizerBase::simMuPtSpectrum = nullptr
protected

◆ simMuPtVsDispl

TH2I* PatternOptimizerBase::simMuPtVsDispl = nullptr
protected

◆ simMuPtVsRho

TH2I* PatternOptimizerBase::simMuPtVsRho = nullptr
protected

◆ writeLayerStat

bool PatternOptimizerBase::writeLayerStat = false
protected

Definition at line 59 of file PatternOptimizerBase.h.

Referenced by PatternGenerator::endJob(), and savePatternsInRoot().