Skip to content

Commit

Permalink
Merge pull request #25466 from CMSTrackerDPG/StuckTBM_from-CMSSW_10_4…
Browse files Browse the repository at this point in the history
…_X_2018-12-07-2300

Simulation of the pixel bad components on the FED channel basis
  • Loading branch information
cmsbuild authored Dec 18, 2018
2 parents 3c23965 + 9873103 commit b8365c6
Show file tree
Hide file tree
Showing 47 changed files with 2,083 additions and 39 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#ifndef CALIBTRACKER_RECORDS_SIPIXELFEDCHANNELCONTAINERESPRODUCERRCD_H
#define CALIBTRACKER_RECORDS_SIPIXELFEDCHANNELCONTAINERESPRODUCERRCD_H

#include "FWCore/Framework/interface/EventSetupRecordImplementation.h"
#include "FWCore/Framework/interface/DependentRecordImplementation.h"
#include "boost/mpl/vector.hpp"
#include "CondFormats/DataRecord/interface/SiPixelStatusScenariosRcd.h"

class SiPixelFEDChannelContainerESProducerRcd : public edm::eventsetup::DependentRecordImplementation<SiPixelFEDChannelContainerESProducerRcd,boost::mpl::vector<SiPixelStatusScenariosRcd> > {};

#endif
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#include "CalibTracker/Records/interface/SiPixelFEDChannelContainerESProducerRcd.h"
#include "FWCore/Framework/interface/eventsetuprecord_registration_macro.h"
#include "FWCore/Utilities/interface/typelookup.h"

EVENTSETUP_RECORD_REG(SiPixelFEDChannelContainerESProducerRcd);
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
// -*- C++ -*-
//
// Package: CalibTracker/PixelFEDChannelCollectionProducer
// Class: PixelFEDChannelCollectionProducer
//
/**\class PixelFEDChannelCollectionProducer
Description: [one line class summary]
Implementation:
[Notes on implementation]
*/
//
// Original Author: Marco Musich
// Created: Thu, 13 Dec 2018 08:48:22 GMT
//
//

// system include files
#include <memory>

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

#include "FWCore/Framework/interface/ESHandle.h"
#include "CondFormats/DataRecord/interface/SiPixelStatusScenariosRcd.h"
#include "CondFormats/SiPixelObjects/interface/SiPixelFEDChannelContainer.h"
#include "CalibTracker/Records/interface/SiPixelFEDChannelContainerESProducerRcd.h"

// Need to add #include statements for definitions of
// the data type and record type here

//
// class declaration
//

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

typedef std::unordered_map<std::string,PixelFEDChannelCollection> PixelFEDChannelCollectionMap;
using ReturnType = std::unique_ptr<PixelFEDChannelCollectionMap>;

ReturnType produce(const SiPixelFEDChannelContainerESProducerRcd &);
private:
// ----------member data ---------------------------
};


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

//now do what ever other initialization is needed
}


PixelFEDChannelCollectionProducer::~PixelFEDChannelCollectionProducer()
{

// do anything here that needs to be done at destruction time
// (e.g. close files, deallocate resources etc.)

}

//
// member functions
//

// ------------ method called to produce the data ------------
PixelFEDChannelCollectionProducer::ReturnType
PixelFEDChannelCollectionProducer::produce(const SiPixelFEDChannelContainerESProducerRcd& iRecord)
{
edm::ESHandle<SiPixelFEDChannelContainer> qualityCollectionHandle;
iRecord.getRecord<SiPixelStatusScenariosRcd>().get(qualityCollectionHandle);

PixelFEDChannelCollectionMap out;

for(const auto& it : qualityCollectionHandle->getScenarioMap()){

std::string scenario = it.first;
PixelFEDChannelCollection disabled_channelcollection;
auto SiPixelBadFedChannels = it.second;
for(const auto &entry : SiPixelBadFedChannels){
disabled_channelcollection.insert(entry.first, entry.second.data(), entry.second.size());
}
out.emplace(scenario,disabled_channelcollection);
}

auto product = std::make_unique<PixelFEDChannelCollectionMap>(out);
return product;
}

//define this as a plug-in
DEFINE_FWK_EVENTSETUP_MODULE(PixelFEDChannelCollectionProducer);
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import FWCore.ParameterSet.Config as cms

SiPixelFEDChannelContainerESProducer = cms.ESProducer("PixelFEDChannelCollectionProducer")
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
#include <string>
#include <iostream>
#include <map>
#include "FWCore/Framework/interface/one/EDAnalyzer.h"
#include "FWCore/Framework/interface/ESHandle.h"
#include "FWCore/Framework/interface/Event.h"
#include "FWCore/Framework/interface/EventSetup.h"
#include "FWCore/Framework/interface/MakerMacros.h"
#include "FWCore/Framework/interface/Frameworkfwd.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "DataFormats/SiPixelDetId/interface/PixelFEDChannel.h"
#include "CalibTracker/Records/interface/SiPixelFEDChannelContainerESProducerRcd.h"

class PixelFEDChannelCollectionMapTestReader : public edm::one::EDAnalyzer<> {
public:

typedef std::unordered_map<std::string,PixelFEDChannelCollection> PixelFEDChannelCollectionMap;
explicit PixelFEDChannelCollectionMapTestReader(edm::ParameterSet const& p);
~PixelFEDChannelCollectionMapTestReader();

static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);

private:

virtual void analyze(const edm::Event& e, const edm::EventSetup& c) override;

// ----------member data ---------------------------
const bool printdebug_;
const std::string formatedOutput_;

};

PixelFEDChannelCollectionMapTestReader::PixelFEDChannelCollectionMapTestReader(edm::ParameterSet const& p):
printdebug_(p.getUntrackedParameter<bool>("printDebug",true)),
formatedOutput_(p.getUntrackedParameter<std::string>("outputFile",""))
{
edm::LogInfo("PixelFEDChannelCollectionMapTestReader")<<"PixelFEDChannelCollectionMapTestReader"<<std::endl;
}

PixelFEDChannelCollectionMapTestReader::~PixelFEDChannelCollectionMapTestReader() {
edm::LogInfo("PixelFEDChannelCollectionMapTestReader")<<"~PixelFEDChannelCollectionMapTestReader "<<std::endl;
}

void
PixelFEDChannelCollectionMapTestReader::analyze(const edm::Event& e, const edm::EventSetup& context){

edm::LogInfo("PixelFEDChannelCollectionMapTestReader") <<"### PixelFEDChannelCollectionMapTestReader::analyze ###"<<std::endl;
edm::LogInfo("PixelFEDChannelCollectionMapTestReader") <<" I AM IN RUN NUMBER "<<e.id().run() <<std::endl;
edm::LogInfo("PixelFEDChannelCollectionMapTestReader") <<" ---EVENT NUMBER "<<e.id().event() <<std::endl;

edm::eventsetup::EventSetupRecordKey recordKey(edm::eventsetup::EventSetupRecordKey::TypeTag::findType("'SiPixelFEDChannelContainerESProducerRcd"));

if( recordKey.type() == edm::eventsetup::EventSetupRecordKey::TypeTag()) {
//record not found
edm::LogInfo("PixelFEDChannelCollectionMapTestReader") <<"Record \"SiPixelFEDChannelContainerESProducerRcd"<<"\" does not exist "<<std::endl;
}

//this part gets the handle of the event source and the record (i.e. the Database)
edm::ESHandle<PixelFEDChannelCollectionMap> PixelFEDChannelCollectionMapHandle;
edm::LogInfo("PixelFEDChannelCollectionMapTestReader") <<"got eshandle"<<std::endl;

context.get<SiPixelFEDChannelContainerESProducerRcd>().get(PixelFEDChannelCollectionMapHandle);
edm::LogInfo("PixelFEDChannelCollectionMapTestReader") <<"got context"<<std::endl;

const PixelFEDChannelCollectionMap* quality_map=PixelFEDChannelCollectionMapHandle.product();
edm::LogInfo("PixelFEDChannelCollectionMapTestReader") <<"got SiPixelFEDChannelContainer* "<< std::endl;
edm::LogInfo("PixelFEDChannelCollectionMapTestReader") << "print pointer address : " ;
//edm::LogInfo("PixelFEDChannelCollectionMapTestReader") << quality_map << std::endl;

edm::LogInfo("PixelFEDChannelCollectionMapTestReader") << "Size " << quality_map->size() << std::endl;
edm::LogInfo("PixelFEDChannelCollectionMapTestReader") <<"Content of myQuality_Map "<<std::endl;

}

void
PixelFEDChannelCollectionMapTestReader::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
edm::ParameterSetDescription desc;
desc.setComment("Reads payloads of type SiPixelFEDChannelContainer");
desc.addUntracked<bool>("printDebug",true);
desc.addUntracked<std::string>("outputFile","");
descriptions.add("PixelFEDChannelCollectionMapTestReader",desc);
}

DEFINE_FWK_MODULE(PixelFEDChannelCollectionMapTestReader);
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
import FWCore.ParameterSet.Config as cms

process = cms.Process("ProcessOne")

##
## MessageLogger
##
process.load('FWCore.MessageService.MessageLogger_cfi')
process.MessageLogger.categories.append("SiPixelFEDChannelContainer")
process.MessageLogger.categories.append("PixelFEDChannelCollectionMapTestReader")
process.MessageLogger.destinations = cms.untracked.vstring("cout")
process.MessageLogger.cout = cms.untracked.PSet(
threshold = cms.untracked.string("INFO"),
default = cms.untracked.PSet(limit = cms.untracked.int32(0)),
FwkReport = cms.untracked.PSet(limit = cms.untracked.int32(-1),
reportEvery = cms.untracked.int32(1000)
),
SiPixelFEDChannelContainer = cms.untracked.PSet( limit = cms.untracked.int32(-1)),
PixelFEDChannelCollectionMapTestReader = cms.untracked.PSet( limit = cms.untracked.int32(-1))
)
process.MessageLogger.statistics.append('cout')

##
## Empty Source
##
process.source = cms.Source("EmptyIOVSource",
timetype = cms.string('runnumber'),
firstValue = cms.uint64(1),
lastValue = cms.uint64(1),
interval = cms.uint64(1)
)
##
## Get the payload
##
from CondCore.CondDB.CondDB_cfi import *
CondDBQualityCollection = CondDB.clone(connect = cms.string("sqlite_file:SiPixelStatusScenarios_v1.db"))

process.dbInput = cms.ESSource("PoolDBESSource",
CondDBQualityCollection,
toGet = cms.VPSet(cms.PSet(record = cms.string('SiPixelStatusScenariosRcd'),
tag = cms.string('SiPixelFEDChannelContainer_StuckTBM_2018_v1_mc') # choose tag you want
)
)
)

#from CalibTracker.SiPixelESProducers.PixelFEDChannelCollectionProducer_cfi import *
process.load("CalibTracker.SiPixelESProducers.PixelFEDChannelCollectionProducer_cfi")
#process.SiPixelFEDChannelContainerESProducer = cms.ESProducer("PixelFEDChannelCollectionProducer")


## Retrieve it and check it's available in the ES
##
process.get = cms.EDAnalyzer("EventSetupRecordDataGetter",
toGet = cms.VPSet(cms.PSet(record = cms.string('SiPixelFEDChannelContainerESProducerRcd'),
data = cms.vstring('PixelFEDChannelCollectionMap')
)
),
verbose = cms.untracked.bool(True)
)

##
## Retrieve it and check it's available in the ES
##
# process.get = cms.EDAnalyzer("EventSetupRecordDataGetter",
# toGet = cms.VPSet(cms.PSet(record = cms.string('SiPixelStatusScenariosRcd'),
# data = cms.vstring('SiPixelFEDChannelContainer')
# )
# ),
# verbose = cms.untracked.bool(True)
# )

##
## Read it back
##
process.ReadDB = cms.EDAnalyzer("PixelFEDChannelCollectionMapTestReader")
process.ReadDB.printDebug = cms.untracked.bool(True)
process.ReadDB.outputFile = cms.untracked.string('PixelFEDChannelCollectionMap.log')

process.p = cms.Path(process.get+process.ReadDB)
6 changes: 6 additions & 0 deletions CondCore/SiPixelPlugins/src/plugin.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@
#include "CondFormats/SiPixelObjects/interface/SiPixelQuality.h"
#include "CondFormats/DataRecord/interface/SiPixelQualityFromDbRcd.h"
#include "CondFormats/DataRecord/interface/SiPixelQualityRcd.h"
#include "CondFormats/SiPixelObjects/interface/SiPixelFEDChannelContainer.h"
#include "CondFormats/DataRecord/interface/SiPixelStatusScenariosRcd.h"
#include "CondFormats/SiPixelObjects/interface/SiPixelQualityProbabilities.h"
#include "CondFormats/DataRecord/interface/SiPixelStatusScenarioProbabilityRcd.h"
#include "CondFormats/SiPixelObjects/interface/SiPixelCPEGenericErrorParm.h"
#include "CondFormats/DataRecord/interface/SiPixelCPEGenericErrorParmRcd.h"

Expand Down Expand Up @@ -61,6 +65,8 @@ REGISTER_PLUGIN(SiPixelDynamicInefficiencyRcd,SiPixelDynamicInefficiency);
REGISTER_PLUGIN(SiPixelCalibConfigurationRcd,SiPixelCalibConfiguration);
REGISTER_PLUGIN(SiPixelPerformanceSummaryRcd,SiPixelPerformanceSummary);
REGISTER_PLUGIN(SiPixelQualityFromDbRcd,SiPixelQuality);
REGISTER_PLUGIN(SiPixelStatusScenariosRcd,SiPixelFEDChannelContainer);
REGISTER_PLUGIN(SiPixelStatusScenarioProbabilityRcd,SiPixelQualityProbabilities);
REGISTER_PLUGIN(SiPixelCPEGenericErrorParmRcd,SiPixelCPEGenericErrorParm);
REGISTER_PLUGIN(SiPixelTemplateDBObjectRcd,SiPixelTemplateDBObject);
REGISTER_PLUGIN(SiPixelTemplateDBObject38TRcd,SiPixelTemplateDBObject);
Expand Down
2 changes: 2 additions & 0 deletions CondCore/Utilities/plugins/Module_2XML.cc
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,8 @@ PAYLOAD_2XML_MODULE( pluginUtilities_payload2xml ){
PAYLOAD_2XML_CLASS( SiPixelGenErrorDBObject );
PAYLOAD_2XML_CLASS( SiPixelLorentzAngle );
PAYLOAD_2XML_CLASS( SiPixelQuality );
PAYLOAD_2XML_CLASS( SiPixelFEDChannelContainer );
PAYLOAD_2XML_CLASS( SiPixelQualityProbabilities );
PAYLOAD_2XML_CLASS( SiPixelTemplateDBObject );
PAYLOAD_2XML_CLASS( SiStripApvGain );
PAYLOAD_2XML_CLASS( SiStripBackPlaneCorrection );
Expand Down
2 changes: 2 additions & 0 deletions CondCore/Utilities/src/CondDBFetch.cc
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,8 @@ namespace cond {
FETCH_PAYLOAD_CASE( SiPixelLorentzAngle )
FETCH_PAYLOAD_CASE( SiPixelDynamicInefficiency )
FETCH_PAYLOAD_CASE( SiPixelQuality )
FETCH_PAYLOAD_CASE( SiPixelFEDChannelContainer )
FETCH_PAYLOAD_CASE( SiPixelQualityProbabilities )
FETCH_PAYLOAD_CASE( SiPixelTemplateDBObject )
FETCH_PAYLOAD_CASE( SiPixel2DTemplateDBObject )
FETCH_PAYLOAD_CASE( SiStripApvGain )
Expand Down
2 changes: 2 additions & 0 deletions CondCore/Utilities/src/CondDBImport.cc
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,8 @@ namespace cond {
IMPORT_PAYLOAD_CASE( SiPixelLorentzAngle )
IMPORT_PAYLOAD_CASE( SiPixelDynamicInefficiency )
IMPORT_PAYLOAD_CASE( SiPixelQuality )
IMPORT_PAYLOAD_CASE( SiPixelFEDChannelContainer )
IMPORT_PAYLOAD_CASE( SiPixelQualityProbabilities )
IMPORT_PAYLOAD_CASE( SiPixelTemplateDBObject )
IMPORT_PAYLOAD_CASE( SiPixel2DTemplateDBObject )
IMPORT_PAYLOAD_CASE( SiStripApvGain )
Expand Down
2 changes: 2 additions & 0 deletions CondCore/Utilities/src/CondFormats.h
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,8 @@
#include "CondFormats/SiPixelObjects/interface/SiPixelLorentzAngle.h"
#include "CondFormats/SiPixelObjects/interface/SiPixelDynamicInefficiency.h"
#include "CondFormats/SiPixelObjects/interface/SiPixelQuality.h"
#include "CondFormats/SiPixelObjects/interface/SiPixelFEDChannelContainer.h"
#include "CondFormats/SiPixelObjects/interface/SiPixelQualityProbabilities.h"
#include "CondFormats/SiPixelObjects/interface/SiPixelTemplateDBObject.h"
#include "CondFormats/SiPixelObjects/interface/SiPixel2DTemplateDBObject.h"
#include "CondFormats/SiPixelObjects/interface/SiPixelGenErrorDBObject.h"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#ifndef SiPixelStatusScenarioProbabilityRcd_SiPixelStatusScenarioProbabilityRcd_h
#define SiPixelStatusScenarioProbabilityRcd_SiPixelStatusScenarioProbabilityRcd_h
// -*- C++ -*-
//
// Package: CondFormats/DataRecord
// Class : SiPixelStatusScenarioProbabilityRcd
//
/**\class SiPixelStatusScenarioProbabilityRcd SiPixelStatusScenarioProbabilityRcd.h CondFormats/DataRecord/interface/SiPixelStatusScenarioProbabilityRcd.h
Description: [one line class summary]
Usage:
<usage>
*/
//
// Author: Marco Musich
// Created: Wed, 30 Nov 2018 11:44:30 GMT
//
#include "FWCore/Framework/interface/EventSetupRecordImplementation.h"
class SiPixelStatusScenarioProbabilityRcd : public edm::eventsetup::EventSetupRecordImplementation<SiPixelStatusScenarioProbabilityRcd> {};
#endif
19 changes: 19 additions & 0 deletions CondFormats/DataRecord/interface/SiPixelStatusScenariosRcd.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#ifndef SiPixelStatusScenariosRcd_SiPixelStatusScenariosRcd_h
#define SiPixelStatusScenariosRcd_SiPixelStatusScenariosRcd_h
// -*- C++ -*-
//
// Package: CondFormats/DataRecord
// Class : SiPixelStatusScenariosRcd
//
/**\class SiPixelStatusScenariosRcd SiPixelStatusScenariosRcd.h CondFormats/DataRecord/interface/SiPixelStatusScenariosRcd.h
Description: [one line class summary]
Usage:
<usage>
*/
//
// Author: Marco Musich
// Created: Wed, 28 Nov 2018 10:31:30 GMT
//
#include "FWCore/Framework/interface/EventSetupRecordImplementation.h"
class SiPixelStatusScenariosRcd : public edm::eventsetup::EventSetupRecordImplementation<SiPixelStatusScenariosRcd> {};
#endif
13 changes: 13 additions & 0 deletions CondFormats/DataRecord/src/SiPixelStatusScenarioProbabilityRcd.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// -*- C++ -*-
//
// Package: CondFormats/DataRecord
// Class : SiPixelStatusScenarioProbabilityRcd
//
// Implementation:
// [Notes on implementation]
//
// Author: Marco Musich
// Created: Wed, 22 Feb 2017 10:31:30 GMT
#include "CondFormats/DataRecord/interface/SiPixelStatusScenarioProbabilityRcd.h"
#include "FWCore/Framework/interface/eventsetuprecord_registration_macro.h"
EVENTSETUP_RECORD_REG(SiPixelStatusScenarioProbabilityRcd);
Loading

0 comments on commit b8365c6

Please sign in to comment.