Skip to content

Commit

Permalink
Merge branch 'cms-sw:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
kskovpen authored Apr 27, 2022
2 parents 5f36cc9 + 0b3455d commit f0a5580
Show file tree
Hide file tree
Showing 143 changed files with 5,302 additions and 3,541 deletions.
12 changes: 6 additions & 6 deletions CalibTracker/SiStripChannelGain/src/SiStripGainsPCLHarvester.cc
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,7 @@ namespace {

sprintf(FunName, "Fitfcn_%s", his->GetName());

TF1* ffitold = (TF1*)gROOT->GetListOfFunctions()->FindObject(FunName);
TF1* ffitold = dynamic_cast<TF1*>(gROOT->GetListOfFunctions()->FindObject(FunName));
if (ffitold)
delete ffitold;

Expand Down Expand Up @@ -488,7 +488,7 @@ namespace {
//********************************************************************************//
void SiStripGainsPCLHarvester::algoComputeMPVandGain(const MonitorElement* Charge_Vs_Index) {
unsigned int I = 0;
TH1F* Proj = nullptr;
TH1D* Proj = nullptr;
static constexpr double DEF_F = -9999.;
double FitResults[6] = {DEF_F, DEF_F, DEF_F, DEF_F, DEF_F, DEF_F};
double MPVmean = 300;
Expand Down Expand Up @@ -522,8 +522,8 @@ void SiStripGainsPCLHarvester::algoComputeMPVandGain(const MonitorElement* Charg
continue;
}

Proj = (TH1F*)(chvsidx->ProjectionY(
"", chvsidx->GetXaxis()->FindBin(APV->Index), chvsidx->GetXaxis()->FindBin(APV->Index), "e"));
Proj = chvsidx->ProjectionY(
"", chvsidx->GetXaxis()->FindBin(APV->Index), chvsidx->GetXaxis()->FindBin(APV->Index), "e");
if (!Proj)
continue;

Expand All @@ -538,7 +538,7 @@ void SiStripGainsPCLHarvester::algoComputeMPVandGain(const MonitorElement* Charg
std::shared_ptr<stAPVGain> APV2 = APVsColl[(APV->DetId << 4) | SecondAPVId];
if (APV2->Bin < 0)
APV2->Bin = chvsidx->GetXaxis()->FindBin(APV2->Index);
TH1F* Proj2 = (TH1F*)(chvsidx->ProjectionY("", APV2->Bin, APV2->Bin, "e"));
TH1D* Proj2 = chvsidx->ProjectionY("", APV2->Bin, APV2->Bin, "e");
if (Proj2) {
Proj->Add(Proj2, 1);
delete Proj2;
Expand All @@ -553,7 +553,7 @@ void SiStripGainsPCLHarvester::algoComputeMPVandGain(const MonitorElement* Charg
continue;
if (APV2->Bin < 0)
APV2->Bin = chvsidx->GetXaxis()->FindBin(APV2->Index);
TH1F* Proj2 = (TH1F*)(chvsidx->ProjectionY("", APV2->Bin, APV2->Bin, "e"));
TH1D* Proj2 = chvsidx->ProjectionY("", APV2->Bin, APV2->Bin, "e");
if (Proj2) {
Proj->Add(Proj2, 1);
delete Proj2;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@
photon2pf = cms.InputTag("particleBasedIsolation","gedPhotons"),
pf2pf = cms.InputTag("FILLME")
)

pfEGammaToCandidateRemapperCleaned = pfEGammaToCandidateRemapper.clone(pf2pf = "cleanedParticleFlow")
8 changes: 4 additions & 4 deletions CondTools/Hcal/interface/BoostIODBReader.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,17 +50,17 @@ class BoostIODBReader : public edm::one::EDAnalyzer<> {
private:
void analyze(const edm::Event&, const edm::EventSetup&) override;

std::string outputFile_;
const std::string outputFile_;
const edm::ESGetToken<DataType, RecordType> tok_;
};

template <class DataType, class RecordType>
BoostIODBReader<DataType, RecordType>::BoostIODBReader(const edm::ParameterSet& ps)
: outputFile_(ps.getParameter<std::string>("outputFile")) {}
: outputFile_(ps.getParameter<std::string>("outputFile")), tok_(esConsumes<DataType, RecordType>()) {}

template <class DataType, class RecordType>
void BoostIODBReader<DataType, RecordType>::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) {
edm::ESGetToken<DataType, RecordType> tok = esConsumes<DataType, RecordType>();
const DataType* p = &iSetup.getData(tok);
const DataType* p = &iSetup.getData(tok_);

std::ofstream of(outputFile_.c_str(), std::ios_base::binary);
if (!of.is_open())
Expand Down
8 changes: 7 additions & 1 deletion CondTools/Hcal/test/BuildFile.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<library name="PMTParams" file="make_*cc">
</library>

<bin file="write_HFPhase1PMTParams.cc">
<bin name="write_HFPhase1PMTParams" file="write_HFPhase1PMTParams.cc">
<lib name="PMTParams"/>
</bin>

Expand All @@ -27,6 +27,12 @@
<lib name="PMTParams"/>
</bin>

<bin file="HFPhase1PMTParams_unittest.cc">
<flags PRE_TEST = "write_HFPhase1PMTParams"/>
<flags TEST_RUNNER_ARGS = "/bin/bash CondTools/Hcal/test testHFPhase1PMTParams.sh"/>
<use name="FWCore/Utilities"/>
</bin>

<library file="HcalConditionsTest.cc" name="testCondToolsConTHcal">
<flags EDM_PLUGIN="1"/>
</library>
2 changes: 2 additions & 0 deletions CondTools/Hcal/test/HFPhase1PMTParams_unittest.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#include "FWCore/Utilities/interface/TestHelper.h"
RUNTEST()
15 changes: 15 additions & 0 deletions CondTools/Hcal/test/testHFPhase1PMTParams.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/sh

function die { echo $1: status $2 ; exit $2; }

echo "TESTING HFPhase1PMTParams generation code ..."
write_HFPhase1PMTParams 1 HFPhase1PMTParams_V00_mc.bbin || die "Failure running write_HFPhase1PMTParams" $?

echo "TESTING HFPhase1PMTParams database creation code ..."
cmsRun ${LOCAL_TEST_DIR}/HFPhase1PMTParamsDBWriter_cfg.py || die "Failure running HFPhase1PMTParamsDBWriter_cfg.py" $?

echo "TESTING HFPhase1PMTParams database reading code ..."
cmsRun ${LOCAL_TEST_DIR}/HFPhase1PMTParamsDBReader_cfg.py || die "Failure running HFPhase1PMTParamsDBReader_cfg.py" $?

echo "TESTING that we can restore HFPhase1PMTParams from the database ..."
diff HFPhase1PMTParams_V00_mc.bbin dbread.bbin || die "Database contents differ from the original" $?
20 changes: 13 additions & 7 deletions CondTools/L1Trigger/interface/WriterProxy.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

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

#include "FWCore/PluginManager/interface/PluginFactory.h"

Expand Down Expand Up @@ -32,6 +33,8 @@ namespace l1t {
* methods here.
*/

virtual void setToken(edm::ConsumesCollector cc) = 0;

virtual std::string save(const edm::EventSetup& setup) const = 0;

protected:
Expand All @@ -42,20 +45,24 @@ namespace l1t {
*/
template <class Record, class Type>
class WriterProxyT : public WriterProxy {
private:
edm::ESGetToken<Type, Record> rcdToken;

public:
~WriterProxyT() override {}

void setToken(edm::ConsumesCollector cc) override { rcdToken = cc.esConsumes(); }

/* This method requires that Record and Type supports copy constructor */
std::string save(const edm::EventSetup& setup) const override {
// load record and type from EventSetup and save them in db
edm::ESHandle<Type> handle;

try {
setup.get<Record>().get(handle);
handle = setup.getHandle(rcdToken);
} catch (l1t::DataAlreadyPresentException& ex) {
return std::string();
}

// If handle is invalid, then data is already in DB

edm::Service<cond::service::PoolDBOutputService> poolDb;
Expand All @@ -64,14 +71,13 @@ namespace l1t {
}
poolDb->forceInit();
cond::persistency::Session session = poolDb->session();
cond::persistency::TransactionScope tr(session.transaction());
// if throw transaction will unroll
/// tr.start(false);
if (not session.transaction().isActive())
session.transaction().start(false); // true: read only, false: read-write

std::shared_ptr<Type> pointer = std::make_shared<Type>(*(handle.product()));
std::string payloadToken = session.storePayload(*pointer);
/// tr.commit();
tr.close();

session.transaction().commit();
return payloadToken;
}
};
Expand Down
13 changes: 11 additions & 2 deletions CondTools/L1TriggerExt/interface/DataWriterExt.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,19 @@ namespace l1t {
* REGISTER_PLUGIN(record, type) from registration_macros.h found in PluginSystem.
*/

typedef std::unique_ptr<WriterProxy> WriterProxyPtr;

class DataWriterExt {
public:
DataWriterExt();
DataWriterExt(const std::string&);
~DataWriterExt();

// Payload and IOV writing functions.

// Get payload from EventSetup and write to DB with no IOV
// recordType = "record@type", return value is payload token
std::string writePayload(const edm::EventSetup& setup);
std::string writePayload(const edm::EventSetup& setup, const std::string& recordType);

// Use PoolDBOutputService to append IOV with sinceRun to IOV sequence
Expand All @@ -65,6 +69,11 @@ namespace l1t {

bool fillLastTriggerKeyList(L1TriggerKeyListExt& output);

WriterProxy* getWriter() { return writer_.get(); }

private:
WriterProxyPtr writer_;

protected:
};

Expand All @@ -77,12 +86,12 @@ namespace l1t {

poolDb->forceInit();
cond::persistency::Session session = poolDb->session();
/// session.transaction().start(true);
session.transaction().start(true);

// Get object from CondDB
std::shared_ptr<T> ref = session.fetchPayload<T>(payloadToken);
outputObject = *ref;
/// session.transaction().commit ();
session.transaction().commit();
}

} // namespace l1t
Expand Down
Loading

0 comments on commit f0a5580

Please sign in to comment.