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

TH1I * candEta = nullptr
 
GoldenPatternVec< GoldenPatternWithStat > & goldenPatterns
 
TH1I * simMuEta = nullptr
 
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 candEta, EmulationObserverBase::edmCfg, edm::ParameterSet::exists(), goldenPatterns, simMuEta, 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  simMuEta = new TH1I("simMuEta", "simMuEta;eta;#events", 100, -2.1, 2.1);
77  candEta = new TH1I("candEta", "candEta;eta;#events", 100, -2.1, 2.1);
78 
79  simMuPtSpectrum = new TH1F("simMuPtSpectrum", "simMuPtSpectrum", 800, 0, 400);
80 
81  simMuPtVsDispl = new TH2I("simMuPtVsDispl", "simMuPtVsDispl;pt [GeV];dxy [cm]", 100, 0, 400, 100, 0, 400);
82  simMuPtVsRho = new TH2I("simMuPtVsRho", "simMuPtVsRho;pt [GeV];rho [cm]", 100, 0, 400, 100, 0, 400);
83 
84  if (edmCfg.exists("simTracksTag") == false)
85  edm::LogError("l1tOmtfEventPrint") << "simTracksTag not found !!!" << std::endl;
86 }
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 88 of file PatternOptimizerBase.cc.

88 {}

Member Function Documentation

◆ endJob()

void PatternOptimizerBase::endJob ( void  )
overridevirtual

Implements IOMTFEmulationObserver.

Definition at line 125 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().

125  {
126  std::string fName = edmCfg.getParameter<std::string>("optimisedPatsXmlFile");
127  edm::LogImportant("PatternOptimizer") << " Writing optimized patterns to " << fName << std::endl;
128  XMLConfigWriter xmlWriter(omtfConfig, false, false);
129  xmlWriter.writeGPs(goldenPatterns, fName);
130 
131  fName.replace(fName.find('.'), fName.length(), ".root");
133 }
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 108 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().

109  {
110  if (simMuon == nullptr || omtfCand->getGoldenPatern() == nullptr) //no sim muon or empty candidate
111  return;
112 
113  double ptSim = simMuon->momentum().pt();
114  int chargeSim = (std::abs(simMuon->type()) == 13) ? simMuon->type() / -13 : 0;
115 
116  //double muDxy = (-1 * genMuon->vx() * genMuon->py() + genMuon->vy() * genMuon->px()) / genMuon->pt();;
117 
118  unsigned int exptPatNum = omtfConfig->getPatternNum(ptSim, chargeSim);
119  GoldenPatternWithStat* exptCandGp = goldenPatterns.at(exptPatNum).get(); // expected pattern
120  simMuFoundByOmtfPt->Fill(exptCandGp->key().theNumber); //TODO add weight of the muons pt spectrum
121 
122  simMuPtSpectrum->Fill(ptSim, getEventRateWeight(ptSim));
123 }
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 90 of file PatternOptimizerBase.cc.

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

90  {
91  edm::LogVerbatim("l1tOmtfEventPrint") << __FUNCTION__ << ": " << __LINE__ << " called!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! "
92  << std::endl;
93  for (int patNum = goldenPatterns.size() - 1; patNum >= 0; patNum--) {
94  double pt = omtfConfig->getPatternPtRange(patNum).ptFrom;
95  if (pt > 0) {
96  edm::LogVerbatim("l1tOmtfEventPrint")
97  << "cmsRun runThresholdCalc.py " << patNum << " " << (patNum + 1) << " _" << RPCConst::iptFromPt(pt) << "_";
98  if (goldenPatterns[patNum]->key().theCharge == -1)
99  edm::LogVerbatim("l1tOmtfEventPrint") << "m_";
100  else
101  edm::LogVerbatim("l1tOmtfEventPrint") << "p_";
102 
103  edm::LogVerbatim("l1tOmtfEventPrint") << " > out" << patNum << ".txt" << std::endl;
104  }
105  }
106 }
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 135 of file PatternOptimizerBase.cc.

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

Referenced by endJob().

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

◆ candEta

TH1I* PatternOptimizerBase::candEta = nullptr
protected

◆ goldenPatterns

GoldenPatternVec<GoldenPatternWithStat>& PatternOptimizerBase::goldenPatterns
protected

◆ simMuEta

TH1I* PatternOptimizerBase::simMuEta = nullptr
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 62 of file PatternOptimizerBase.h.

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