Skip to content

Commit

Permalink
Merge pull request #34494 from panoskatsoulis/kalmanParamsDev_onlyObjs
Browse files Browse the repository at this point in the history
Introduce L1TMuonBarrelKalmanParams and Record
  • Loading branch information
cmsbuild authored Jul 28, 2021
2 parents ca5eab5 + 18bc00e commit bec73cc
Show file tree
Hide file tree
Showing 16 changed files with 355 additions and 5 deletions.
3 changes: 3 additions & 0 deletions CondCore/L1TPlugins/src/UpgradeRecords2.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
#include "CondFormats/L1TObjects/interface/L1TMuonBarrelParams.h"
#include "CondFormats/DataRecord/interface/L1TMuonBarrelParamsRcd.h"
#include "CondFormats/DataRecord/interface/L1TMuonBarrelParamsO2ORcd.h"
#include "CondFormats/L1TObjects/interface/L1TMuonBarrelKalmanParams.h"
#include "CondFormats/DataRecord/interface/L1TMuonBarrelKalmanParamsRcd.h"

#include "CondFormats/L1TObjects/interface/L1TMuonGlobalParams.h"
#include "CondFormats/DataRecord/interface/L1TMuonGlobalParamsRcd.h"
Expand All @@ -32,6 +34,7 @@ REGISTER_PLUGIN(L1TMuonEndCapParamsRcd, L1TMuonEndCapParams);
REGISTER_PLUGIN(L1TMuonEndCapForestRcd, L1TMuonEndCapForest);
REGISTER_PLUGIN(L1TMuonOverlapParamsRcd, L1TMuonOverlapParams);
REGISTER_PLUGIN(L1TMuonBarrelParamsRcd, L1TMuonBarrelParams);
REGISTER_PLUGIN(L1TMuonBarrelKalmanParamsRcd, L1TMuonBarrelKalmanParams);
REGISTER_PLUGIN(L1TMuonGlobalParamsRcd, L1TMuonGlobalParams);

REGISTER_PLUGIN(L1TMuonEndCapParamsO2ORcd, L1TMuonEndCapParams);
Expand Down
16 changes: 16 additions & 0 deletions CondFormats/DataRecord/interface/L1TMuonBarrelKalmanParamsRcd.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#ifndef L1TBMTFKalmanParamsRcd_L1TBMTFKalmanParamsRcd_h
#define L1TBMTFKalmanParamsRcd_L1TBMTFKalmanParamsRcd_h
// -*- C++ -*-
//
// Class : L1TMuonBarrelKalmanParamsRcd
//
// Author: Panos Katsoulis
// Created:
//

#include "FWCore/Framework/interface/EventSetupRecordImplementation.h"

class L1TMuonBarrelKalmanParamsRcd
: public edm::eventsetup::EventSetupRecordImplementation<L1TMuonBarrelKalmanParamsRcd> {};

#endif
1 change: 1 addition & 0 deletions CondFormats/DataRecord/interface/L1TMuonBarrelParamsRcd.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
// Class : L1TMuonBarrelParamsRcd
//
// Author: Giannis Flouris
// Kalman Mod: Panos Katsoulis
// Created:
//

Expand Down
12 changes: 12 additions & 0 deletions CondFormats/DataRecord/src/L1TMuonBarrelKalmanParamsRcd.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// -*- C++ -*-
//
// Package: Subsystem/Package
// Class : L1TMuonBarrelKalmanParamsRcd
//
// Author: Panos Katsoulis
// Created:

#include "CondFormats/DataRecord/interface/L1TMuonBarrelKalmanParamsRcd.h"
#include "FWCore/Framework/interface/eventsetuprecord_registration_macro.h"

EVENTSETUP_RECORD_REG(L1TMuonBarrelKalmanParamsRcd);
45 changes: 45 additions & 0 deletions CondFormats/L1TObjects/interface/L1TMuonBarrelKalmanParams.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
///
/// \class L1TMuonBarrelKalmanParams
///
/// Description: Placeholder for Kalman BMTF parameters
///
///
/// \author: Panos Katsoulis
///

#ifndef L1TBMTFKalmanParams_h
#define L1TBMTFKalmanParams_h

#include <memory>
#include <iostream>
#include <vector>

#include "CondFormats/Serialization/interface/Serializable.h"
#include "CondFormats/L1TObjects/interface/L1MuDTTFMasks.h"
#include "CondFormats/L1TObjects/interface/LUT.h"

class L1TMuonBarrelKalmanParams {
public:
L1TMuonBarrelKalmanParams();
~L1TMuonBarrelKalmanParams() {}

enum { Version = 1 };
enum { CONFIG = 0, NUM_BMTF_PARAM_NODES = 2 };

class Node {
public:
std::string type_;
std::string kalmanLUTsPath_;
unsigned fwVersion_;
l1t::LUT LUT_;
COND_SERIALIZABLE;
};

L1MuDTTFMasks l1mudttfmasks;
unsigned version_;

std::vector<Node> pnodes_;
std::vector<L1MuDTTFMasks> l1mudttfmasks_;
COND_SERIALIZABLE;
};
#endif
7 changes: 7 additions & 0 deletions CondFormats/L1TObjects/src/L1TMuonBarrelKalmanParams.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#include "CondFormats/L1TObjects/interface/L1TMuonBarrelKalmanParams.h"

L1TMuonBarrelKalmanParams::L1TMuonBarrelKalmanParams() : pnodes_(NUM_BMTF_PARAM_NODES), l1mudttfmasks_(1) {
version_ = Version;
pnodes_[CONFIG].type_ = "unspecified";
pnodes_[CONFIG].fwVersion_ = 0; //default to recognize a RCD that is not filled
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#include "CondFormats/L1TObjects/interface/L1TMuonBarrelParams.h"
#include "CondFormats/L1TObjects/interface/L1TMuonBarrelKalmanParams.h"
#include "FWCore/Utilities/interface/typelookup.h"

TYPELOOKUP_DATA_REG(L1TMuonBarrelParams);
TYPELOOKUP_DATA_REG(L1TMuonBarrelKalmanParams);
3 changes: 3 additions & 0 deletions CondFormats/L1TObjects/src/classes.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
#include "CondFormats/L1TObjects/interface/L1TMuonOverlapParams.h"
#include "CondFormats/L1TObjects/interface/L1TMuonGlobalParams.h"
#include "CondFormats/L1TObjects/interface/L1TMuonBarrelParams.h"
#include "CondFormats/L1TObjects/interface/L1TMuonBarrelKalmanParams.h"
#include "CondFormats/L1TObjects/interface/L1TMuonEndCapParams.h"
#include "CondFormats/L1TObjects/interface/L1TMuonEndCapForest.h"

Expand Down Expand Up @@ -103,6 +104,8 @@ namespace CondFormats_L1TObjects {

L1TMuonBarrelParams dummy18;
std::vector<L1TMuonBarrelParams::Node> dummy18a;
L1TMuonBarrelKalmanParams dummy18b;
std::vector<L1TMuonBarrelKalmanParams::Node> dummy18c;

L1TMuonEndCapParams dummy19;

Expand Down
8 changes: 8 additions & 0 deletions CondFormats/L1TObjects/src/classes_def.xml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
<field name="sparams_" mapping="blob"/>
<field name="uparams_" mapping="blob"/>
</class>

<class name="std::vector<L1TMuonBarrelParams::Node>"/>
<class name="L1TMuonBarrelParams">
<field name="pnodes_" mapping="blob"/>
Expand All @@ -74,6 +75,13 @@
<field name="eta_lut_" mapping="blob"/>
<field name="ext_lut_" mapping="blob"/>
</class>

<class name="L1TMuonBarrelKalmanParams">
<field name="pnodes_" mapping="blob"/>
</class>
<class name="std::vector<L1TMuonBarrelKalmanParams::Node>"/>
<!-- <class name="std::vector<L1TMuonBarrelKalmanParams::LUT>"/> -->

<class name="L1MuScale"/>
<class name="L1MuBinnedScale">
<field name="m_Scale" mapping="blob" />
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
// -*- C++ -*-
//
// Class: L1TMuonBarrelKalmanParamsESProducer
//
// Original Author (of the base file): Giannis Flouris
// Kalman Mod & clean up: Panos Katsoulis
// Created:
//
//

// system include files
#include <memory>

// user include files
#include "FWCore/Framework/interface/ModuleFactory.h"
#include "FWCore/Framework/interface/ESProducer.h"

#include "CondFormats/L1TObjects/interface/L1TMuonBarrelKalmanParams.h"
#include "CondFormats/DataRecord/interface/L1TMuonBarrelKalmanParamsRcd.h"

// for future, LUTs implementaion
//#include "L1Trigger/L1TMuon/interface/MicroGMTLUTFactories.h"
// for future, masks
//#include "L1Trigger/L1TCommon/interface/Mask.h"

// class declaration
//

class L1TMuonBarrelKalmanParamsESProducer : public edm::ESProducer {
public:
L1TMuonBarrelKalmanParamsESProducer(const edm::ParameterSet&);
~L1TMuonBarrelKalmanParamsESProducer() override;

using ReturnType = std::unique_ptr<L1TMuonBarrelKalmanParams>;
ReturnType produce(const L1TMuonBarrelKalmanParamsRcd&);

private:
L1TMuonBarrelKalmanParams kalman_params;
};

//
// constants, enums and typedefs
//

//
// static data member definitions
//

//
// constructors and destructor
//
L1TMuonBarrelKalmanParamsESProducer::L1TMuonBarrelKalmanParamsESProducer(const edm::ParameterSet& iConfig) {
// the following line is needed to tell the framework what data is being produced
setWhatProduced(this);

// basic configurables needed (now set static)
kalman_params.pnodes_[kalman_params.CONFIG].fwVersion_ = iConfig.getParameter<unsigned>("fwVersion");

// the LUTs
kalman_params.pnodes_[kalman_params.CONFIG].kalmanLUTsPath_ = iConfig.getParameter<std::string>("LUTsPath");
}

L1TMuonBarrelKalmanParamsESProducer::~L1TMuonBarrelKalmanParamsESProducer() {}

//
// member functions
//

// ------------ method called to produce the data ------------
L1TMuonBarrelKalmanParamsESProducer::ReturnType L1TMuonBarrelKalmanParamsESProducer::produce(
const L1TMuonBarrelKalmanParamsRcd& iRecord) {
return std::make_unique<L1TMuonBarrelKalmanParams>(kalman_params);
}

//define this as a plug-in
DEFINE_FWK_EVENTSETUP_MODULE(L1TMuonBarrelKalmanParamsESProducer);
3 changes: 2 additions & 1 deletion L1Trigger/L1TMuonBarrel/python/fakeBmtfParams_cff.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
firstValid = cms.vuint32(1)
)

fakeBmtfParams = cms.ESProducer('L1TMuonBarrelParamsESProducer',
fakeBmtfParams = cms.ESProducer(
'L1TMuonBarrelParamsESProducer',
configFromXML = cms.bool(False),
hwXmlFile = cms.string('L1Trigger/L1TMuonBarell/test/BMTF_HW.xml'),
topCfgXmlFile = cms.string('L1Trigger/L1TMuonBarell/test/bmtf_top_config_p5.xml'),
Expand Down
14 changes: 14 additions & 0 deletions L1Trigger/L1TMuonBarrel/python/staticKBmtfParams_cff.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import FWCore.ParameterSet.Config as cms

kalmanParamsSource = cms.ESSource(
"EmptyESSource",
recordName = cms.string('L1TMuonBarrelKalmanParamsRcd'),
iovIsRunNotTime = cms.bool(True),
firstValid = cms.vuint32(1)
)

staticKBmtfParams = cms.ESProducer(
'L1TMuonBarrelKalmanParamsESProducer',
fwVersion = cms.uint32(0x95030160),
LUTsPath = cms.string("L1Trigger/L1TMuon/data/bmtf_luts/kalmanLUTs_v302.root")
)
77 changes: 77 additions & 0 deletions L1TriggerConfig/Utilities/src/L1TMuonBarrelKalmanParamsViewer.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
#include <iomanip>
#include <iostream>

#include "FWCore/Framework/interface/EDAnalyzer.h"

#include "FWCore/Framework/interface/Event.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"

#include "FWCore/Framework/interface/EventSetup.h"
#include "FWCore/Framework/interface/ESHandle.h"

#include "CondFormats/DataRecord/interface/L1TMuonBarrelKalmanParamsRcd.h"
#include "CondFormats/L1TObjects/interface/L1TMuonBarrelKalmanParams.h"
#include "FWCore/ServiceRegistry/interface/Service.h"
#include "CondCore/DBOutputService/interface/PoolDBOutputService.h"
#include "CondCore/CondDB/interface/Session.h"

#include <iostream>
using namespace std;

class L1TMuonBarrelKalmanParamsViewer : public edm::EDAnalyzer {
private:
std::string hash(void *buf, size_t len) const;

public:
void analyze(const edm::Event &, const edm::EventSetup &) override;

L1TMuonBarrelKalmanParamsViewer(const edm::ParameterSet &){};
~L1TMuonBarrelKalmanParamsViewer(void) override {}
};

#include <openssl/sha.h>
#include <cmath>
#include <iostream>
using namespace std;

std::string L1TMuonBarrelKalmanParamsViewer::hash(void *buf, size_t len) const {
char tmp[SHA_DIGEST_LENGTH * 2 + 1];
bzero(tmp, sizeof(tmp));
SHA_CTX ctx;
if (!SHA1_Init(&ctx))
throw cms::Exception("L1TMuonBarrelKalmanParamsViewer::hash") << "SHA1 initialization error";

if (!SHA1_Update(&ctx, buf, len))
throw cms::Exception("L1TMuonBarrelKalmanParamsViewer::hash") << "SHA1 processing error";

unsigned char hash[SHA_DIGEST_LENGTH];
if (!SHA1_Final(hash, &ctx))
throw cms::Exception("L1TMuonBarrelKalmanParamsViewer::hash") << "SHA1 finalization error";

// re-write bytes in hex
for (unsigned int i = 0; i < 20; i++)
::sprintf(&tmp[i * 2], "%02x", hash[i]);

tmp[20 * 2] = 0;
return std::string(tmp);
}

void L1TMuonBarrelKalmanParamsViewer::analyze(const edm::Event &iEvent, const edm::EventSetup &evSetup) {
edm::ESHandle<L1TMuonBarrelKalmanParams> handle1;
evSetup.get<L1TMuonBarrelKalmanParamsRcd>().get(handle1);
std::shared_ptr<L1TMuonBarrelKalmanParams> ptr(new L1TMuonBarrelKalmanParams(*(handle1.product())));

// Get the nodes and print out
auto pnodes = ptr->pnodes_[ptr->CONFIG];
cout << "version : " << ptr->version_ << endl;
cout << "fwVersion : " << hex << pnodes.fwVersion_ << dec << endl;
cout << "LUTsPath : " << pnodes.kalmanLUTsPath_ << endl;

// typedef std::map<short, short, std::less<short> > LUT;
}

#include "FWCore/PluginManager/interface/ModuleDef.h"
#include "FWCore/Framework/interface/MakerMacros.h"
#include "FWCore/Framework/interface/ModuleFactory.h"

DEFINE_FWK_MODULE(L1TMuonBarrelKalmanParamsViewer);
10 changes: 9 additions & 1 deletion L1TriggerConfig/Utilities/src/L1TMuonBarrelParamsWriter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
#include "CondFormats/DataRecord/interface/L1TMuonBarrelParamsO2ORcd.h"
#include "CondFormats/DataRecord/interface/L1TMuonBarrelParamsRcd.h"
#include "CondFormats/L1TObjects/interface/L1TMuonBarrelParams.h"
#include "CondFormats/DataRecord/interface/L1TMuonBarrelKalmanParamsRcd.h"
#include "CondFormats/L1TObjects/interface/L1TMuonBarrelKalmanParams.h"

#include "FWCore/ServiceRegistry/interface/Service.h"
#include "CondCore/DBOutputService/interface/PoolDBOutputService.h"
Expand All @@ -30,19 +32,25 @@ class L1TMuonBarrelParamsWriter : public edm::EDAnalyzer {

void L1TMuonBarrelParamsWriter::analyze(const edm::Event& iEvent, const edm::EventSetup& evSetup) {
edm::ESHandle<L1TMuonBarrelParams> handle1;
edm::ESHandle<L1TMuonBarrelKalmanParams> handle2;

if (isO2Opayload)
evSetup.get<L1TMuonBarrelParamsO2ORcd>().get(handle1);
else
else {
evSetup.get<L1TMuonBarrelParamsRcd>().get(handle1);
evSetup.get<L1TMuonBarrelKalmanParamsRcd>().get(handle2);
}

std::shared_ptr<L1TMuonBarrelParams> ptr1(new L1TMuonBarrelParams(*(handle1.product())));
std::shared_ptr<L1TMuonBarrelKalmanParams> ptr2(new L1TMuonBarrelKalmanParams(*(handle2.product())));

edm::Service<cond::service::PoolDBOutputService> poolDb;
if (poolDb.isAvailable()) {
cond::Time_t firstSinceTime = poolDb->beginOfTime();
poolDb->writeOne(
ptr1.get(), firstSinceTime, (isO2Opayload ? "L1TMuonBarrelParamsO2ORcd" : "L1TMuonBarrelParamsRcd"));
if (not isO2Opayload)
poolDb->writeOne(ptr2.get(), firstSinceTime, ("L1TMuonBarrelKalmanParamsRcd"));
}
}

Expand Down
Loading

0 comments on commit bec73cc

Please sign in to comment.