44 #include "CLHEP/Random/RandGauss.h" 45 #include "CLHEP/Random/RandFlat.h" 87 std::map<int, CalParameters, std::less<int> >
calmap_;
94 : appendMode_(iConfig.getUntrackedParameter<
bool>(
"appendMode",
true)),
96 SiPixelGainCalibration_(nullptr),
97 SiPixelGainCalibrationService_(iConfig, consumesCollector()),
98 recordName_(iConfig.getParameter<
std::
string>(
"record")),
99 meanPed_(iConfig.getParameter<double>(
"meanPed")),
100 rmsPed_(iConfig.getParameter<double>(
"rmsPed")),
101 meanGain_(iConfig.getParameter<double>(
"meanGain")),
102 rmsGain_(iConfig.getParameter<double>(
"rmsGain")),
103 meanPedFPix_(iConfig.getUntrackedParameter<double>(
"meanPedFPix", meanPed_)),
104 rmsPedFPix_(iConfig.getUntrackedParameter<double>(
"rmsPedFPix", rmsPed_)),
105 meanGainFPix_(iConfig.getUntrackedParameter<double>(
"meanGainFPix", meanGain_)),
106 rmsGainFPix_(iConfig.getUntrackedParameter<double>(
"rmsGainFPix", rmsGain_)),
107 deadFraction_(iConfig.getParameter<double>(
"deadFraction")),
108 noisyFraction_(iConfig.getParameter<double>(
"noisyFraction")),
109 secondRocRowGainOffset_(iConfig.getParameter<double>(
"secondRocRowGainOffset")),
110 secondRocRowPedOffset_(iConfig.getParameter<double>(
"secondRocRowPedOffset")),
111 numberOfModules_(iConfig.getParameter<
int>(
"numberOfModules")),
112 fromFile_(iConfig.getParameter<
bool>(
"fromFile")),
113 fileName_(iConfig.getParameter<
std::
string>(
"fileName")),
114 generateColumns_(iConfig.getUntrackedParameter<
bool>(
"generateColumns",
true)) {
115 ::putenv((
char*)
"CORAL_AUTH_USER=me");
116 ::putenv((
char*)
"CORAL_AUTH_PASSWORD=test");
123 uint32_t nchannels = 0;
128 <<
"... creating dummy SiPixelGainCalibration Data for Run " <<
run <<
"\n " << std::endl;
141 edm::LogInfo(
"SiPixelCondObjOfflineBuilder") <<
" There are " << pDD->dets().size() <<
" detectors" << std::endl;
143 for (TrackerGeometry::DetContainer::const_iterator
it = pDD->dets().begin();
it != pDD->dets().end();
it++) {
144 if (dynamic_cast<PixelGeomDetUnit const*>((*
it)) !=
nullptr) {
145 uint32_t detid = ((*it)->geographicalId()).
rawId();
155 int nrows = topol.
nrows();
164 if (
detId.subdetId() == 2) {
173 std::vector<char> theSiPixelGainCalibration;
177 float totalGain = 0.0;
178 for (
int j = 0;
j < nrows;
j++) {
181 bool isNoisy =
false;
182 float ped = 0.0,
gain = 0.0;
186 int chipIndex = 0, colROC = 0, rowROC = 0;
191 std::map<int, CalParameters, std::less<int> >::const_iterator
it =
calmap_.find(chanROC);
193 ped = theCalParameters.
p0;
194 gain = theCalParameters.
p1;
198 double val = CLHEP::RandFlat::shoot();
205 double val = CLHEP::RandFlat::shoot();
212 if (rmsPedWork > 0) {
213 ped = CLHEP::RandGauss::shoot(meanPedWork, rmsPedWork);
214 while (ped < minped || ped > maxped)
215 ped = CLHEP::RandGauss::shoot(meanPedWork, rmsPedWork);
218 if (rmsGainWork > 0) {
219 gain = CLHEP::RandGauss::shoot(meanGainWork, rmsGainWork);
220 while (gain < mingain || gain > maxgain)
221 gain = CLHEP::RandGauss::shoot(meanGainWork, rmsGainWork);
241 else if (
gain < mingain)
246 else if (ped < minped)
252 if (!isDead && !isNoisy) {
260 if ((
j + 1) % 80 == 0)
262 float averageGain = totalGain /
static_cast<float>(80);
278 <<
"[SiPixelCondObjOfflineBuilder::analyze] detid already exists" << std::endl;
281 edm::LogPrint(
"SiPixelCondObjOfflineBuilder") <<
" ---> PIXEL Modules " << nmodules << std::endl;
282 edm::LogPrint(
"SiPixelCondObjOfflineBuilder") <<
" ---> PIXEL Channels " << nchannels << std::endl;
301 edm::LogError(
"SiPixelCondOfflineBuilder") <<
" db service unavailable";
304 edm::LogInfo(
"SiPixelCondOfflineBuilder") <<
" DB service OK";
319 edm::LogError(
"SiPixelCondObjOfflineBuilder") <<
"caught std::exception " << er.what() << std::endl;
321 edm::LogError(
"SiPixelCondObjOfflineBuilder") <<
"Funny error" << std::endl;
329 edm::LogInfo(
"SiPixelCondObjOfflineBuilder") <<
" Calibration loaded: Map size " <<
calmap_.size() <<
" max " 343 edm::LogError(
"SiPixelCondObjOfflineBuilder") <<
"Input file not found" << std::endl;
347 <<
" " <<
in_file.good() <<
" end of file " << std::endl;
352 for (
int i = 0;
i < 3;
i++) {
357 for (
int i = 0;
i < (52 * 80);
i++) {
361 <<
" Col " << colid <<
" Row " << rowid <<
" P0 " <<
par0 <<
" P1 " <<
par1 << std::endl;
369 calmap_.insert(std::pair<int, CalParameters>(
chan, onePix));
const int numberOfModules_
Base exception class for the object to relational access.
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
const double deadFraction_
virtual int ncolumns() const =0
cond::Time_t beginOfTime() const
const double secondRocRowGainOffset_
virtual int nrows() const =0
Log< level::Error, false > LogError
std::pair< ContainerIterator, ContainerIterator > Range
const double secondRocRowPedOffset_
std::unique_ptr< SiPixelGainCalibrationOffline > SiPixelGainCalibration_
void createOneIOV(const T &payload, cond::Time_t firstSinceTime, const std::string &recordName)
SiPixelGainCalibrationOfflineService SiPixelGainCalibrationService_
void appendOneIOV(const T &payload, cond::Time_t sinceTime, const std::string &recordName)
int transformToROC(const int col, const int row, int &rocId, int &colROC, int &rowROC) const
void analyze(const edm::Event &, const edm::EventSetup &) override
const double meanGainFPix_
bool isNewTagRequest(const std::string &recordName)
cond::Time_t currentTime() const
const std::string recordName_
std::map< int, CalParameters, std::less< int > > calmap_
SiPixelCondObjOfflineBuilder(const edm::ParameterSet &iConfig)
static int pixelToChannelROC(const int rowROC, const int colROC)
const double rmsGainFPix_
#define DEFINE_FWK_MODULE(type)
Log< level::Warning, true > LogPrint
PixelIndices * pIndexConverter_
const double meanPedFPix_
Namespace of DDCMS conversion namespace.
Log< level::Info, false > LogInfo
const bool generateColumns_
const edm::ESGetToken< TrackerGeometry, TrackerDigiGeometryRecord > pddToken_
const double noisyFraction_
chan
lumi = TPaveText(lowX+0.38, lowY+0.061, lowX+0.45, lowY+0.161, "NDC") lumi.SetBorderSize( 0 ) lumi...
virtual const PixelTopology & specificTopology() const
Returns a reference to the pixel proxy topology.
const std::string fileName_
char const * what() const noexcept override