44 #include "CLHEP/Random/RandGauss.h"
45 #include "CLHEP/Random/RandFlat.h"
88 std::map<int, CalParameters, std::less<int> >
calmap_;
96 appendMode_(iConfig.getUntrackedParameter<bool>(
"appendMode",
true)),
97 SiPixelGainCalibration_(nullptr),
98 SiPixelGainCalibrationService_(iConfig, consumesCollector()),
99 recordName_(iConfig.getParameter<std::
string>(
"record")),
100 meanPed_(iConfig.getParameter<double>(
"meanPed")),
101 rmsPed_(iConfig.getParameter<double>(
"rmsPed")),
102 meanGain_(iConfig.getParameter<double>(
"meanGain")),
103 rmsGain_(iConfig.getParameter<double>(
"rmsGain")),
104 meanPedFPix_(iConfig.getUntrackedParameter<double>(
"meanPedFPix", meanPed_)),
105 rmsPedFPix_(iConfig.getUntrackedParameter<double>(
"rmsPedFPix", rmsPed_)),
106 meanGainFPix_(iConfig.getUntrackedParameter<double>(
"meanGainFPix", meanGain_)),
107 rmsGainFPix_(iConfig.getUntrackedParameter<double>(
"rmsGainFPix", rmsGain_)),
108 deadFraction_(iConfig.getParameter<double>(
"deadFraction")),
109 noisyFraction_(iConfig.getParameter<double>(
"noisyFraction")),
110 secondRocRowGainOffset_(iConfig.getParameter<double>(
"secondRocRowGainOffset")),
111 secondRocRowPedOffset_(iConfig.getParameter<double>(
"secondRocRowPedOffset")),
112 numberOfModules_(iConfig.getParameter<int>(
"numberOfModules")),
113 fromFile_(iConfig.getParameter<bool>(
"fromFile")),
114 fileName_(iConfig.getParameter<std::
string>(
"fileName")),
115 generateColumns_(iConfig.getUntrackedParameter<bool>(
"generateColumns",
true))
118 ::putenv((
char*)
"CORAL_AUTH_USER=me");
119 ::putenv((
char*)
"CORAL_AUTH_PASSWORD=test");
124 unsigned int run = iEvent.
id().
run();
126 uint32_t nchannels = 0;
131 <<
"... creating dummy SiPixelGainCalibration Data for Run " <<
run <<
"\n " << std::endl;
144 edm::LogInfo(
"SiPixelCondObjForHLTBuilder") <<
" There are " << pDD->dets().size() <<
" detectors" << std::endl;
146 for (TrackerGeometry::DetContainer::const_iterator it = pDD->dets().begin(); it != pDD->dets().end(); it++) {
147 if (dynamic_cast<PixelGeomDetUnit const*>((*it)) !=
nullptr) {
148 uint32_t detid = ((*it)->geographicalId()).rawId();
158 int nrows = topol.
nrows();
176 std::vector<char> theSiPixelGainCalibration;
179 for (
int i = 0;
i < ncols;
i++) {
180 float totalPed = 0.0;
181 float totalGain = 0.0;
182 for (
int j = 0;
j < nrows;
j++) {
185 bool isNoisy =
false;
186 float ped = 0.0, gain = 0.0;
190 int chipIndex = 0, colROC = 0, rowROC = 0;
195 std::map<int, CalParameters, std::less<int> >::const_iterator it =
calmap_.find(chanROC);
197 ped = theCalParameters.
p0;
198 gain = theCalParameters.
p1;
202 double val = CLHEP::RandFlat::shoot();
209 double val = CLHEP::RandFlat::shoot();
216 if (rmsPedWork > 0) {
217 ped = CLHEP::RandGauss::shoot(meanPedWork, rmsPedWork);
218 while (ped < minped || ped > maxped)
219 ped = CLHEP::RandGauss::shoot(meanPedWork, rmsPedWork);
222 if (rmsGainWork > 0) {
223 gain = CLHEP::RandGauss::shoot(meanGainWork, rmsGainWork);
224 while (gain < mingain || gain > maxgain)
225 gain = CLHEP::RandGauss::shoot(meanGainWork, rmsGainWork);
243 else if (gain < mingain)
248 else if (ped < minped)
255 if ((
j + 1) % 80 == 0) {
257 float averagePed = totalPed /
static_cast<float>(80);
258 float averageGain = totalGain /
static_cast<float>(80);
265 if (!isDead && !isNoisy)
281 <<
"[SiPixelCondObjForHLTBuilder::analyze] detid already exists" << std::endl;
284 edm::LogPrint(
"SiPixelCondObjForHLTBuilder") <<
" ---> PIXEL Modules " << nmodules << std::endl;
285 edm::LogPrint(
"SiPixelCondObjForHLTBuilder") <<
" ---> PIXEL Channels " << nchannels << std::endl;
303 if (!mydbservice.isAvailable()) {
335 edm::LogError(
"SiPixelCondObjForHLTBuilder") <<
"caught std::exception " << er.what() << std::endl;
337 edm::LogError(
"SiPixelCondObjForHLTBuilder") <<
"Funny error" << std::endl;
345 edm::LogInfo(
"SiPixelCondObjForHLTBuilder") <<
" Calibration loaded: Map size " <<
calmap_.size() <<
" max "
356 std::ifstream in_file;
359 edm::LogError(
"SiPixelCondObjForHLTBuilder") <<
"Input file not found" << std::endl;
361 if (in_file.eof() != 0) {
362 edm::LogError(
"SiPixelCondObjForHLTBuilder") << in_file.eof() <<
" " << in_file.gcount() <<
" " << in_file.fail()
363 <<
" " << in_file.good() <<
" end of file " << std::endl;
368 for (
int i = 0;
i < 3;
i++) {
369 in_file.getline(line, 500,
'\n');
370 edm::LogInfo(
"SiPixelCondObjForHLTBuilder") << line << std::endl;
373 for (
int i = 0;
i < (52 * 80);
i++) {
374 in_file >> par0 >> par1 >> name >> colid >> rowid;
377 <<
" Col " << colid <<
" Row " << rowid <<
" P0 " << par0 <<
" P1 " << par1 << std::endl;
385 calmap_.insert(std::pair<int, CalParameters>(chan, onePix));
SiPixelCondObjForHLTBuilder(const edm::ParameterSet &iConfig)
~SiPixelCondObjForHLTBuilder() override=default
Base exception class for the object to relational access.
const double secondRocRowPedOffset_
std::unique_ptr< SiPixelGainCalibrationForHLT > SiPixelGainCalibration_
virtual int ncolumns() const =0
const std::string fileName_
#define DEFINE_FWK_MODULE(type)
tuple chan
lumi = TPaveText(lowX+0.38, lowY+0.061, lowX+0.45, lowY+0.161, "NDC") lumi.SetBorderSize( 0 ) lumi...
virtual int nrows() const =0
int transformToROC(const int col, const int row, int &rocId, int &colROC, int &rowROC) const
Log< level::Error, false > LogError
std::pair< ContainerIterator, ContainerIterator > Range
PixelIndices * pIndexConverter_
SiPixelGainCalibrationForHLTService SiPixelGainCalibrationService_
const uint16_t range(const Frame &aFrame)
bool getData(T &iHolder) const
void analyze(const edm::Event &, const edm::EventSetup &) override
const bool generateColumns_
const double meanGainFPix_
const double meanPedFPix_
static int pixelToChannelROC(const int rowROC, const int colROC)
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum) ...
char const * what() const noexceptoverride
std::map< int, CalParameters, std::less< int > > calmap_
Log< level::Warning, true > LogPrint
const edm::ESGetToken< TrackerGeometry, TrackerDigiGeometryRecord > tkGeometryToken_
Log< level::Info, false > LogInfo
const int numberOfModules_
virtual const PixelTopology & specificTopology() const
Returns a reference to the pixel proxy topology.
const double rmsGainFPix_
const std::string recordName_
const double secondRocRowGainOffset_
const double noisyFraction_
const double deadFraction_