40 const double lum = 2.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;
50 ptlog10 = log10(pt_GeV);
51 double ex = (ptlog10 -
mu) * (ptlog10 -
mu) / s2;
52 double rate = (
a *
exp(-ex) * afactor);
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);
79 simMuPtSpectrum =
new TH1F(
"simMuPtSpectrum",
"simMuPtSpectrum", 800, 0, 400);
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);
85 edm::LogError(
"l1tOmtfEventPrint") <<
"simTracksTag not found !!!" << std::endl;
91 edm::LogVerbatim(
"l1tOmtfEventPrint") << __FUNCTION__ <<
": " << __LINE__ <<
" called!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! " 93 for (
int patNum =
goldenPatterns.size() - 1; patNum >= 0; patNum--) {
97 <<
"cmsRun runThresholdCalc.py " << patNum <<
" " << (patNum + 1) <<
" _" <<
RPCConst::iptFromPt(
pt) <<
"_";
103 edm::LogVerbatim(
"l1tOmtfEventPrint") <<
" > out" << patNum <<
".txt" << std::endl;
109 std::unique_ptr<l1t::RegionalMuonCandBxCollection>& finalCandidates) {
136 gStyle->SetOptStat(111111);
139 <<
" outfile->GetName() " <<
outfile.GetName() <<
" writeLayerStat " 152 outfile.mkdir(
"patternsPdfs")->cd();
153 outfile.mkdir(
"patternsPdfs/canvases");
154 outfile.mkdir(
"patternsPdfs/canvases2");
156 ostringstream ostrName;
157 ostringstream ostrTtle;
158 vector<TH1F*> classProbHists;
159 for (
unsigned int iRefLayer = 0; iRefLayer <
goldenPatterns[0]->getPdf()[0].size(); ++iRefLayer) {
161 ostrName <<
"Neg_RefLayer_" << iRefLayer;
163 ostrTtle <<
"Neg_RefLayer_" << iRefLayer;
164 classProbHists.push_back(
new TH1F(
168 ostrName <<
"Pos_RefLayer_" << iRefLayer;
170 ostrTtle <<
"Pos_RefLayer_" << iRefLayer;
171 classProbHists.push_back(
new TH1F(
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));
183 for (
unsigned int iLayer = 0; iLayer < layerCnt; ++iLayer) {
185 if (iLayer == 1 || iLayer == 3 || iLayer == 5)
188 for (
unsigned int iRefLayer = 0; iRefLayer < refLayerCnt; ++iRefLayer) {
190 ostrName <<
"distPhi_refLayer_" << iRefLayer <<
"_layer_" << iLayer;
192 ostrTtle <<
"distPhi refLayer " << iRefLayer <<
" layer " << iLayer;
194 distPhiLayerRefLayer[iLayer][iRefLayer] =
new TH2F(ostrName.str().c_str(),
195 ostrTtle.str().c_str(),
204 ostrName <<
"meanDistPhi_refLayer_" << iRefLayer <<
"_Layer_" << iLayer;
206 ostrTtle <<
"meanDistPhi refLayer " << iRefLayer <<
" Layer " << iLayer;
208 meanDistPhiLayerRefLayer[iLayer][iRefLayer] =
new TH2F(ostrName.str().c_str(),
209 ostrTtle.str().c_str(),
218 ostrName <<
"pdfs_refLayer_" << iRefLayer <<
"_layer_" << iLayer;
220 ostrTtle <<
"pdfs refLayer " << iRefLayer <<
" layer " << iLayer;
222 pdfsLayerRefLayer[iLayer][iRefLayer] =
new TH2F(ostrName.str().c_str(),
223 ostrTtle.str().c_str(),
235 if (
gp->key().thePt == 0)
239 ostrName <<
"PatNum_" <<
gp->key().theNumber;
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);
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());
250 ostrName <<
"PatNum_" <<
gp->key().theNumber <<
"_refLayer_" << iRefLayer <<
"_Layer_" << iLayer;
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);
257 TH1F*
hist =
new TH1F(
260 int pdfMiddle =
gp->getPdf()[iLayer][iRefLayer].size() / 2;
261 int shift =
gp->getDistPhiBitShift(iLayer, iRefLayer);
263 for (
unsigned int iPdf = 0; iPdf <
gp->getPdf()[iLayer][iRefLayer].size(); iPdf++) {
264 hist->Fill(iPdf,
gp->pdfAllRef[iLayer][iRefLayer][iPdf]);
266 distPhiLayerRefLayer[iLayer][iRefLayer]->Fill(
268 (((
int)iPdf - pdfMiddle) <<
shift) +
gp->meanDistPhi[iLayer][iRefLayer][0],
269 gp->pdfAllRef[iLayer][iRefLayer][iPdf]);
271 pdfsLayerRefLayer[iLayer][iRefLayer]->Fill(
272 gp->key().theNumber, (
int)iPdf,
gp->pdfAllRef[iLayer][iRefLayer][iPdf]);
275 hist->SetLineColor(kGreen);
277 meanDistPhiLayerRefLayer[iLayer][iRefLayer]->Fill(
278 gp->key().theNumber,
gp->meanDistPhi[iLayer][iRefLayer][0], 1);
288 bool saveTh2 =
false;
289 if (
gp->getStatistics()[iLayer][iRefLayer][0].size() > 1)
294 string histName =
"histLayerStat_" + ostrName.str();
295 unsigned int binCnt1 =
gp->getStatistics()[iLayer][iRefLayer].size();
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]);
301 histLayerStat->Write();
303 if (iRefLayer == 0 || iRefLayer == 2) {
304 unsigned int binCnt2 =
gp->getStatistics()[iLayer][iRefLayer][0].size();
306 double xmin = -0.5 - binCnt2 / 2;
307 double xmax = binCnt2 / 2 - 0.5;
310 xmax = binCnt2 - 0.5;
312 TH2I* histLayerStat =
new TH2I(histName.c_str(),
313 (histName +
";ref phiB;delta_phi").c_str(),
322 histLayerStat->GetXaxis()->SetTitle(
"ref phi");
324 for (
unsigned int iBin1 = 0; iBin1 < binCnt1; iBin1++) {
325 for (
unsigned int iBin2 = 0; iBin2 < binCnt2; iBin2++) {
327 histLayerStat->SetBinContent(
328 iBin2 + 1, iBin1 + 1,
gp->getStatistics()[iLayer][iRefLayer][iBin1][iBin2]);
331 histLayerStat->Write();
332 histLayerStat->Delete();
338 outfile.cd(
"patternsPdfs/canvases");
343 for (
unsigned int iRefLayer = 0; iRefLayer <
gp->getPdf()[0].size(); ++iRefLayer) {
345 if (
gp->key().theCharge == -1) {
346 classProbHists[2 * iRefLayer]->Fill(
gp->key().theNumber,
gp->pdfAllRef[refLayerLogicNumber][iRefLayer][iPdf]);
348 classProbHists[2 * iRefLayer + 1]->Fill(
gp->key().theNumber,
349 gp->pdfAllRef[refLayerLogicNumber][iRefLayer][iPdf]);
354 for (
auto& classProbHist : classProbHists) {
355 classProbHist->Write();
358 outfile.cd(
"patternsPdfs/canvases2");
359 for (
unsigned int iRefLayer = 0; iRefLayer <
goldenPatterns[0]->getPdf()[0].size(); ++iRefLayer) {
361 ostrName <<
"distPhiForPatterns_Reflayer_" << iRefLayer;
363 ostrTtle <<
"distPhiForPatterns Reflayer " << iRefLayer;
365 TCanvas*
canvas =
new TCanvas(ostrName.str().c_str(), ostrTtle.str().c_str(), 1200, 1000);
366 canvas->Divide(6, 3, 0, 0);
368 for (
unsigned int iLayer = 0; iLayer < distPhiLayerRefLayer.size(); ++iLayer) {
370 canvas->cd(iLayer + 1)->SetGridx();
371 canvas->cd(iLayer + 1)->SetGridy();
374 distPhiLayerRefLayer[iLayer][iRefLayer]->Draw(
"colz");
376 meanDistPhiLayerRefLayer[iLayer][iRefLayer]->SetLineColor(kRed);
377 meanDistPhiLayerRefLayer[iLayer][iRefLayer]->Draw(
"boxsame");
379 distPhiLayerRefLayer[iLayer][iRefLayer]->Write();
380 meanDistPhiLayerRefLayer[iLayer][iRefLayer]->Write();
381 pdfsLayerRefLayer[iLayer][iRefLayer]->Write();
387 ostrName <<
"pdfsForPatterns_Reflayer_" << iRefLayer;
389 ostrTtle <<
"pdfsForPatterns Reflayer " << iRefLayer;
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) {
395 canvas->cd(iLayer + 1)->SetGridx();
396 canvas->cd(iLayer + 1)->SetGridy();
398 pdfsLayerRefLayer[iLayer][iRefLayer]->Draw(
"colz");
Log< level::Info, true > LogVerbatim
~PatternOptimizerBase() override
T getParameter(std::string const &) const
AlgoMuons::value_type omtfCand
void writeGPs(const GoldenPatternVec< GoldenPatternType > &goldenPats, std::string fName)
bool exists(std::string const ¶meterName) const
checks if a parameter exists
unsigned int getPatternNum(double pt, int charge) const
charge: -1 - negative, +1 - positive
static double vxIntegMuRate(double pt_GeV, double dpt, double etaFrom, double etaTo)
TH1I * simMuFoundByOmtfPt
const math::XYZTLorentzVectorD & momentum() const
int type() const
particle type (HEP PDT convension)
void observeEventEnd(const edm::Event &iEvent, std::unique_ptr< l1t::RegionalMuonCandBxCollection > &finalCandidates) override
virtual double getEventRateWeight(double pt)
static double vxMuRate(double pt_GeV)
Abs< T >::type abs(const T &t)
Log< level::Error, true > LogImportant
key
prepare the HTCondor submission files and eventually submit them
const std::vector< int > & getRefToLogicNumber() const
virtual void saveHists(TFile &outfile)
std::vector< std::unique_ptr< GoldenPatternType > > GoldenPatternVec
GoldenPatternVec< GoldenPatternWithStat > & goldenPatterns
PatternPt getPatternPtRange(unsigned int patNum) const
PatternOptimizerBase(const edm::ParameterSet &edmCfg, const OMTFConfiguration *omtfConfig, GoldenPatternVec< GoldenPatternWithStat > &gps)
static unsigned int const shift
void savePatternsInRoot(std::string rootFileName)
static int iptFromPt(const double pt)
unsigned int nPdfBins() const
const OMTFConfiguration * omtfConfig