128 <<
"=>=>=>=> Starting the function fillDatabase()" << endl;
130 if (
record_ !=
"SiPixelGainCalibrationOfflineRcd" &&
record_ !=
"SiPixelGainCalibrationForHLTRcd") {
132 <<
record_ <<
" : this record can't be used !" << std::endl;
134 <<
"Please select SiPixelGainCalibrationForHLTRcd or SiPixelGainCalibrationOfflineRcd" << std::endl;
139 if (
record_ ==
"SiPixelGainCalibrationOfflineRcd")
141 if (
record_ ==
"SiPixelGainCalibrationForHLTRcd")
146 edm::LogInfo(
"SiPixelCondObjOfflineBuilder") <<
" There are " << pDD->
dets().size() <<
" detectors" << std::endl;
148 if (
record_ ==
"SiPixelGainCalibrationOfflineRcd") {
153 }
else if (
record_ ==
"SiPixelGainCalibrationForHLTRcd") {
169 <<
"New payload will have pedlow,hi " <<
pedlow_ <<
"," <<
pedhi_ <<
" and gainlow,hi " <<
gainlow_ <<
"," 171 if (
record_ ==
"SiPixelGainCalibrationOfflineRcd")
174 if (
record_ ==
"SiPixelGainCalibrationForHLTRcd")
185 bool willNoisyPixBeInserted;
189 willNoisyPixBeInserted =
false;
190 for (TrackerGeometry::DetContainer::const_iterator
mod = pDD->
dets().begin();
mod != pDD->
dets().end();
mod++) {
192 if (dynamic_cast<PixelGeomDetUnit const*>((*
mod)) !=
nullptr)
193 detid = ((*mod)->geographicalId()).rawId();
194 if (detid == it->first) {
195 willNoisyPixBeInserted =
true;
199 if (!willNoisyPixBeInserted)
201 <<
"All Noisy Pixels in detid " << it->first
202 <<
"won't be inserted, check the TrackerGeometry you are using !! You are missing some modules" << endl;
206 edm::LogPrint(
"SiPixelGainCalibrationRejectNoisyAndDead") <<
"=>=>=>=> Starting Loop over all modules" << endl;
209 for (TrackerGeometry::DetContainer::const_iterator it = pDD->
dets().begin(); it != pDD->
dets().end(); it++) {
211 if (dynamic_cast<PixelGeomDetUnit const*>((*it)) !=
nullptr)
212 detid = ((*it)->geographicalId()).rawId();
220 edm::LogPrint(
"SiPixelGainCalibrationRejectNoisyAndDead") <<
"=>=>=>=> We are in module " << detid << endl;
225 int nrows = topol.
nrows();
229 float gainforthiscol[2];
230 float pedforthiscol[2];
233 if (
record_ ==
"SiPixelGainCalibrationOfflineRcd")
235 if (
record_ ==
"SiPixelGainCalibrationForHLTRcd")
238 std::vector<char> theSiPixelGainCalibrationGainPerColPedPerPixel;
239 std::vector<char> theSiPixelGainCalibrationPerCol;
242 edm::LogPrint(
"SiPixelGainCalibrationRejectNoisyAndDead") <<
"=>=>=>=> Starting Loop for each rows/cols " << endl;
244 for (
int icol = 0; icol <=
ncols - 1; icol++) {
246 edm::LogPrint(
"SiPixelGainCalibrationRejectNoisyAndDead") <<
"=>=>=>=> Starting a new column" << endl;
248 nusedrows[0] = nusedrows[1] = 0;
249 gainforthiscol[0] = gainforthiscol[1] = 0;
250 pedforthiscol[0] = pedforthiscol[1] = 0;
252 for (
int jrow = 0; jrow <= nrows - 1; jrow++) {
255 <<
"=>=>=>=> We are in col,row " << icol <<
"," << jrow << endl;
259 size_t iglobalrow = 0;
260 int noisyPixInRow = 0;
261 if (jrow > nrowsrocsplit) {
266 bool isPixelDeadOld =
false;
267 bool isColumnDeadOld =
false;
271 bool isPixelNoisyOld =
false;
272 bool isColumnNoisyOld =
false;
273 bool isPixelNoisyNew =
false;
274 bool isColumnNoisyNew =
false;
276 bool isColumnDead =
false;
277 bool isColumnNoisy =
false;
278 bool isPixelDead =
false;
279 bool isPixelNoisy =
false;
282 edm::LogPrint(
"SiPixelGainCalibrationRejectNoisyAndDead") <<
"=>=>=>=> Trying to get gain/ped " << endl;
285 if (
record_ ==
"SiPixelGainCalibrationOfflineRcd") {
291 if (
record_ ==
"SiPixelGainCalibrationForHLTRcd") {
295 if (!isColumnDeadOld && !isColumnNoisyOld) {
296 if (
record_ ==
"SiPixelGainCalibrationOfflineRcd")
298 if (
record_ ==
"SiPixelGainCalibrationForHLTRcd") {
303 if (!isPixelDeadOld && !isPixelNoisyOld)
304 if (
record_ ==
"SiPixelGainCalibrationOfflineRcd")
308 <<
"Problem trying to catch gain/ped from DETID " << detid <<
" @ col,row " << icol <<
"," << jrow
315 <<
"=>=>=>=> Found gain " << gainforthiscol[iglobalrow] <<
" and ped " << pedforthiscol[iglobalrow]
322 for (
unsigned int i = 0;
i < (it->second).
size();
i++)
323 if (it->first == detid && (it->second.at(
i)).
first == icol && (it->second.at(
i)).
second == jrow)
324 isPixelNoisyNew =
true;
326 isColumnDead = isColumnDeadOld;
327 isPixelDead = isPixelDeadOld;
331 if (noisyPixInRow == nrowsrocsplit)
332 isColumnNoisyNew =
true;
335 isColumnNoisy = isColumnNoisyOld;
336 isPixelNoisy = isPixelNoisyOld;
338 isPixelNoisy = isPixelNoisyNew;
339 isColumnNoisy = isColumnNoisyNew;
341 isPixelNoisy = isPixelNoisyNew || isPixelNoisyOld;
342 isColumnNoisy = isColumnNoisyNew || isColumnNoisyOld;
347 <<
"Inserting a noisy pixel in " << detid <<
" at col,row " << icol <<
"," << jrow << endl;
350 <<
"Inserting a noisy column in " << detid <<
" at col,row " << icol <<
"," << jrow << endl;
357 edm::LogPrint(
"SiPixelGainCalibrationRejectNoisyAndDead") <<
"=>=>=>=> Now Starting to fill the DB" << endl;
363 <<
"=>=>=>=> Filling Pixel Level Calibration" << endl;
366 if (
record_ ==
"SiPixelGainCalibrationOfflineRcd") {
369 else if (isPixelNoisy)
376 if ((jrow + 1) % nrowsrocsplit == 0) {
379 <<
"=>=>=>=> Filling Column Level Calibration" << endl;
382 if (
record_ ==
"SiPixelGainCalibrationOfflineRcd")
384 theSiPixelGainCalibrationGainPerColPedPerPixel);
385 if (
record_ ==
"SiPixelGainCalibrationForHLTRcd")
387 }
else if (isColumnNoisy) {
388 if (
record_ ==
"SiPixelGainCalibrationOfflineRcd")
390 theSiPixelGainCalibrationGainPerColPedPerPixel);
391 if (
record_ ==
"SiPixelGainCalibrationForHLTRcd")
394 if (
record_ ==
"SiPixelGainCalibrationOfflineRcd")
396 gainforthiscol[iglobalrow], nrowsrocsplit, theSiPixelGainCalibrationGainPerColPedPerPixel);
397 if (
record_ ==
"SiPixelGainCalibrationForHLTRcd")
399 pedforthiscol[iglobalrow], gainforthiscol[iglobalrow], theSiPixelGainCalibrationPerCol);
405 <<
"=>=>=>=> This pixel is finished inserting" << endl;
411 <<
"=>=>=>=> This column is finished inserting" << endl;
416 edm::LogPrint(
"SiPixelGainCalibrationRejectNoisyAndDead") <<
"=>=>=>=> Loop over rows/cols is finished" << endl;
418 if (
record_ ==
"SiPixelGainCalibrationOfflineRcd") {
420 theSiPixelGainCalibrationGainPerColPedPerPixel.end());
423 <<
"warning: detid already exists for Offline (gain per col, ped per pixel) calibration database" 426 if (
record_ ==
"SiPixelGainCalibrationForHLTRcd") {
428 theSiPixelGainCalibrationPerCol.end());
431 <<
"warning: detid already exists for HLT (gain per col, ped per col) calibration database" << std::endl;
435 edm::LogPrint(
"SiPixelGainCalibrationRejectNoisyAndDead") <<
"=>=>=>=> This detid is finished inserting" << endl;
439 edm::LogPrint(
"SiPixelGainCalibrationRejectNoisyAndDead") <<
" --- writing to DB!" << std::endl;
445 if (
record_ ==
"SiPixelGainCalibrationOfflineRcd") {
447 <<
"now doing SiPixelGainCalibrationOfflineRcd payload..." << std::endl;
448 if (mydbservice->
isNewTagRequest(
"SiPixelGainCalibrationOfflineRcd")) {
456 if (
record_ ==
"SiPixelGainCalibrationForHLTRcd") {
458 <<
"now doing SiPixelGainCalibrationForHLTRcd payload..." << std::endl;
469 edm::LogPrint(
"SiPixelGainCalibrationRejectNoisyAndDead") <<
" ---> SUMMARY :" << std::endl;
471 <<
" File had " <<
nnoisyininput <<
" noisy pixels" << std::endl;
473 edm::LogPrint(
"SiPixelGainCalibrationRejectNoisyAndDead") <<
" DB has now " << nnoisy <<
" noisy pixels" << std::endl;
474 edm::LogPrint(
"SiPixelGainCalibrationRejectNoisyAndDead") <<
" DB has now " << ndead <<
" dead pixels" << std::endl;
bool isNoisyColumn(const uint32_t &detID, const int &col, const int &row) override
const int insertnoisypixelsindb_
const edm::ESGetToken< TrackerGeometry, TrackerDigiGeometryRecord > pddToken_
virtual int ncolumns() const =0
float getPedestal(const uint32_t &detID, const int &col, const int &row) override
cond::Time_t beginOfTime() const
double getGainLow() override
virtual int nrows() const =0
std::unique_ptr< SiPixelGainCalibrationOffline > theGainCalibrationDbInputOffline_
std::map< int, std::vector< std::pair< int, int > > > noisypixelkeeper
const DetContainer & dets() const override
Returm a vector of all GeomDet (including all GeomDetUnits)
Log< level::Error, false > LogError
std::pair< ContainerIterator, ContainerIterator > Range
double getGainHigh() override
void createOneIOV(const T &payload, cond::Time_t firstSinceTime, const std::string &recordName)
U second(std::pair< T, U > const &p)
void appendOneIOV(const T &payload, cond::Time_t sinceTime, const std::string &recordName)
std::unique_ptr< SiPixelGainCalibrationForHLT > theGainCalibrationDbInputForHLT_
float getGain(const uint32_t &detID, const int &col, const int &row) override
bool isNewTagRequest(const std::string &recordName)
double getPedLow() override
cond::Time_t currentTime() const
SiPixelGainCalibrationForHLTService SiPixelGainCalibrationForHLTService_
void setESObjects(const edm::EventSetup &es) override
bool isDeadColumn(const uint32_t &detID, const int &col, const int &row) override
bool isDead(const uint32_t &detID, const int &col, const int &row) override
bool getData(T &iHolder) const
Log< level::Warning, true > LogPrint
SiPixelGainCalibrationOfflineService SiPixelGainCalibrationOfflineService_
bool isNoisy(const uint32_t &detID, const int &col, const int &row) override
Log< level::Info, false > LogInfo
double getPedHigh() override
virtual const PixelTopology & specificTopology() const
Returns a reference to the pixel proxy topology.
const std::string record_
bool isDeadColumn(const uint32_t &detID, const int &col, const int &row) override
bool isNoisyColumn(const uint32_t &detID, const int &col, const int &row) override
float getPedestal(const uint32_t &detID, const int &col, const int &row) override
T mod(const T &a, const T &b)
float getGain(const uint32_t &detID, const int &col, const int &row) override