-
Notifications
You must be signed in to change notification settings - Fork 4.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DeDxCalibration
as SiStrip
gains and fixes to the APV gain payload inspector
#46826
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
107 changes: 107 additions & 0 deletions
107
CondTools/SiStrip/plugins/SiStripApvGainFromDeDxCalibration.cc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
// system include files | ||
#include <fstream> | ||
#include <iostream> | ||
|
||
// user include files | ||
#include "CalibTracker/SiStripCommon/interface/SiStripDetInfoFileReader.h" | ||
#include "CondCore/DBOutputService/interface/PoolDBOutputService.h" | ||
#include "CondFormats/SiStripObjects/interface/SiStripApvGain.h" | ||
#include "CondFormats/PhysicsToolsObjects/interface/DeDxCalibration.h" | ||
#include "CondFormats/DataRecord/interface/DeDxCalibrationRcd.h" | ||
#include "FWCore/Framework/interface/one/EDAnalyzer.h" | ||
#include "FWCore/Framework/interface/Event.h" | ||
#include "FWCore/Framework/interface/EventSetup.h" | ||
#include "FWCore/MessageLogger/interface/MessageLogger.h" | ||
#include "FWCore/ParameterSet/interface/FileInPath.h" | ||
#include "FWCore/ParameterSet/interface/ParameterSet.h" | ||
#include "FWCore/ParameterSet/interface/ParameterSetDescription.h" | ||
#include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h" | ||
#include "FWCore/ServiceRegistry/interface/Service.h" | ||
#include "FWCore/Utilities/interface/Exception.h" | ||
|
||
class SiStripApvGainFromDeDxCalibration : public edm::one::EDAnalyzer<> { | ||
public: | ||
explicit SiStripApvGainFromDeDxCalibration(const edm::ParameterSet& iConfig); | ||
|
||
~SiStripApvGainFromDeDxCalibration() override = default; | ||
|
||
void analyze(const edm::Event&, const edm::EventSetup&) override; | ||
|
||
static void fillDescriptions(edm::ConfigurationDescriptions&); | ||
|
||
typedef std::pair<uint32_t, unsigned char> ChipId; | ||
|
||
private: | ||
const edm::ESGetToken<DeDxCalibration, DeDxCalibrationRcd> dedxCalibToken_; | ||
const edm::FileInPath fp_; | ||
const bool printdebug_; | ||
}; | ||
|
||
SiStripApvGainFromDeDxCalibration::SiStripApvGainFromDeDxCalibration(const edm::ParameterSet& iConfig) | ||
: dedxCalibToken_(esConsumes<DeDxCalibration, DeDxCalibrationRcd>()), | ||
fp_(iConfig.getUntrackedParameter<edm::FileInPath>("file", | ||
edm::FileInPath(SiStripDetInfoFileReader::kDefaultFile))), | ||
printdebug_(iConfig.getUntrackedParameter<uint32_t>("printDebug", 1)) {} | ||
|
||
void SiStripApvGainFromDeDxCalibration::analyze(const edm::Event& evt, const edm::EventSetup& iSetup) { | ||
unsigned int run = evt.id().run(); | ||
|
||
edm::LogInfo("SiStripApvGainFromDeDxCalibration") | ||
<< "... creating dummy SiStripApvGain Data for Run " << run << "\n " << std::endl; | ||
|
||
SiStripApvGain obj; | ||
|
||
const auto& reader = SiStripDetInfoFileReader::read(fp_.fullPath()); | ||
const auto& DetInfos = reader.getAllData(); | ||
const auto& dedxCalib = iSetup.getData(dedxCalibToken_); | ||
|
||
int count = -1; | ||
for (const auto& it : DetInfos) { | ||
const auto& nAPVs = it.second.nApvs; | ||
count++; | ||
//Generate Gain for det detid | ||
std::vector<float> theSiStripVector; | ||
for (unsigned short j = 0; j < nAPVs; j++) { | ||
const auto& chipId = ChipId(it.first, j); | ||
const auto& g = dedxCalib.gain().find(chipId); | ||
|
||
if (g == dedxCalib.gain().end()) | ||
continue; | ||
|
||
if (count < printdebug_) | ||
edm::LogInfo("SiStripApvGainFromDeDxCalibration") << "detid " << it.first << " \t" | ||
<< " apv " << j << " \t" << g->second << " \t" << std::endl; | ||
theSiStripVector.push_back(g->second); | ||
} | ||
|
||
SiStripApvGain::Range range(theSiStripVector.begin(), theSiStripVector.end()); | ||
if (!obj.put(it.first, range)) | ||
edm::LogError("SiStripApvGainFromDeDxCalibration") | ||
<< "[SiStripApvGainFromDeDxCalibration::analyze] detid already exists" << std::endl; | ||
} | ||
|
||
//End now write sistripnoises data in DB | ||
edm::Service<cond::service::PoolDBOutputService> mydbservice; | ||
|
||
if (mydbservice.isAvailable()) { | ||
if (mydbservice->isNewTagRequest("SiStripApvGainRcd")) { | ||
mydbservice->createOneIOV<SiStripApvGain>(obj, mydbservice->beginOfTime(), "SiStripApvGainRcd"); | ||
} else { | ||
mydbservice->appendOneIOV<SiStripApvGain>(obj, mydbservice->currentTime(), "SiStripApvGainRcd"); | ||
} | ||
} else { | ||
edm::LogError("SiStripApvGainFromDeDxCalibration") << "Service is unavailable" << std::endl; | ||
} | ||
} | ||
|
||
void SiStripApvGainFromDeDxCalibration::fillDescriptions(edm::ConfigurationDescriptions& descriptions) { | ||
edm::ParameterSetDescription desc; | ||
desc.addUntracked<edm::FileInPath>("file", edm::FileInPath(SiStripDetInfoFileReader::kDefaultFile)); | ||
desc.addUntracked<uint32_t>("printDebug", 1); | ||
descriptions.addWithDefaultLabel(desc); | ||
} | ||
|
||
#include "FWCore/PluginManager/interface/ModuleDef.h" | ||
#include "FWCore/Framework/interface/MakerMacros.h" | ||
|
||
DEFINE_FWK_MODULE(SiStripApvGainFromDeDxCalibration); |
65 changes: 65 additions & 0 deletions
65
CondTools/SiStrip/test/SiStripApvGainFromDeDxCalibration_cfg.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import FWCore.ParameterSet.Config as cms | ||
|
||
process = cms.Process("ICALIB") | ||
process.source = cms.Source("EmptyIOVSource", | ||
firstValue = cms.uint64(1), | ||
lastValue = cms.uint64(1), | ||
timetype = cms.string('runnumber'), | ||
interval = cms.uint64(1) | ||
) | ||
|
||
process.load('FWCore.MessageService.MessageLogger_cfi') | ||
process.MessageLogger.cerr.enable = False | ||
process.MessageLogger.SiStripApvGainFromDeDxCalibration=dict() | ||
process.MessageLogger.cout = cms.untracked.PSet( | ||
enable = cms.untracked.bool(True), | ||
threshold = cms.untracked.string("DEBUG"), | ||
default = cms.untracked.PSet(limit = cms.untracked.int32(0)), | ||
FwkReport = cms.untracked.PSet(limit = cms.untracked.int32(-1), | ||
reportEvery = cms.untracked.int32(1000) | ||
), | ||
SiStripApvGainFromDeDxCalibration = cms.untracked.PSet( limit = cms.untracked.int32(-1)), | ||
enableStatistics = cms.untracked.bool(True) | ||
) | ||
|
||
|
||
process.load("Configuration.Geometry.GeometryExtended2024_cff") | ||
process.load("Geometry.TrackerGeometryBuilder.trackerParameters_cfi") | ||
process.TrackerTopologyEP = cms.ESProducer("TrackerTopologyEP") | ||
|
||
#Setup the SiSTripFedCabling and the SiStripDetCabling | ||
process.load("CondCore.CondDB.CondDB_cfi") | ||
process.CondDB.connect='frontier://FrontierProd/CMS_CONDITIONS' | ||
|
||
process.poolDBESSource = cms.ESSource('PoolDBESSource', | ||
process.CondDB, | ||
BlobStreamerName = cms.untracked.string('TBufferBlobStreamingService'), | ||
toGet = cms.VPSet( cms.PSet(record = cms.string('DeDxCalibrationRcd'), | ||
tag = cms.string('DeDxCalibration_HI_2024_prompt_v2') | ||
) | ||
) | ||
) | ||
|
||
process.maxEvents = cms.untracked.PSet( | ||
input = cms.untracked.int32(1) | ||
) | ||
|
||
process.PoolDBOutputService = cms.Service("PoolDBOutputService", | ||
BlobStreamerName = cms.untracked.string('TBufferBlobStreamingService'), | ||
DBParameters = cms.PSet( | ||
authenticationPath = cms.untracked.string('/afs/cern.ch/cms/DB/conddb') | ||
), | ||
timetype = cms.untracked.string('runnumber'), | ||
connect = cms.string('sqlite_file:SiStripApvGainFromDeDxCalibration_HI_2024_prompt_v2.db'), | ||
toPut = cms.VPSet(cms.PSet( | ||
record = cms.string('SiStripApvGainRcd'), | ||
tag = cms.string('SiStripApvGainFromDeDxCalibration_HI_2024_prompt_v2') | ||
)) | ||
) | ||
|
||
from CondTools.SiStrip.siStripApvGainFromDeDxCalibration_cfi import siStripApvGainFromDeDxCalibration | ||
process.prod = siStripApvGainFromDeDxCalibration.clone( | ||
file = cms.untracked.FileInPath('CalibTracker/SiStripCommon/data/SiStripDetInfo.dat'), | ||
printDebug = cms.untracked.uint32(100) | ||
) | ||
process.p = cms.Path(process.prod) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would be more correct: