|
|
Go to the documentation of this file.
24 #include "Fed9UUtils.hh"
34 m_tickmarkThreshold(static_cast<
float>(
pset.getUntrackedParameter<double>(
"TickmarkThreshold", 50.))),
35 m_gaincalibrationfactor(static_cast<
float>(
pset.getUntrackedParameter<double>(
"GainNormalizationFactor", 640.))),
36 m_defaultpedestalvalue(static_cast<
float>(
pset.getUntrackedParameter<double>(
"DefaultPedestal", 0.))),
37 m_defaultnoisevalue(static_cast<
float>(
pset.getUntrackedParameter<double>(
"DefaultNoise", 0.))),
38 m_defaultthresholdhighvalue(static_cast<
float>(
pset.getUntrackedParameter<double>(
"DefaultThresholdHigh", 0.))),
39 m_defaultthresholdlowvalue(static_cast<
float>(
pset.getUntrackedParameter<double>(
"DefaultThresholdLow", 0.))),
40 m_defaultapvmodevalue(static_cast<uint16_t>(
pset.getUntrackedParameter<uint32_t>(
"DefaultAPVMode", 37))),
41 m_defaultapvlatencyvalue(static_cast<uint16_t>(
pset.getUntrackedParameter<uint32_t>(
"DefaultAPVLatency", 142))),
42 m_defaulttickheightvalue(static_cast<
float>(
pset.getUntrackedParameter<double>(
"DefaultTickHeight", 690.))),
43 m_useanalysis(static_cast<
bool>(
pset.getUntrackedParameter<
bool>(
"UseAnalysis",
false))),
49 tTopo(buildTrackerTopology()) {
51 <<
" Constructing object...";
64 <<
" Constructing object...";
71 <<
" Destructing object...";
158 return new TrackerTopology(pxbVals_, pxfVals_, tecVals_, tibVals_, tidVals_, tobVals_);
163 std::stringstream&
output,
171 SiStripDbParams::SiStripPartitions::const_iterator ipart = partitionsRange.begin();
172 SiStripDbParams::SiStripPartitions::const_iterator ipartEnd = partitionsRange.end();
173 for (; ipart != ipartEnd; ++ipart) {
177 if (
label !=
"Cabling" &&
label !=
"ApvLatency")
179 if (
label ==
"Cabling")
182 if (
label ==
"ApvTiming")
184 if (
label ==
"ApvLatency")
188 if (!strcmp(
output.str().c_str(),
input.str().c_str()))
201 SiStripDbParams::SiStripPartitions::const_iterator ipart = partitionsRange.begin();
202 SiStripDbParams::SiStripPartitions::const_iterator ipartEnd = partitionsRange.end();
203 for (; ipart != ipartEnd; ++ipart) {
258 <<
" NULL pointer to DeviceFactory returned by SiStripConfigDb!"
259 <<
" Cannot build Pedestals object!";
263 <<
" NULL pointer to SiStripConfigDb returned by DB \"service\"!"
264 <<
" Cannot build Pedestals object!";
273 if (descriptions.empty()) {
275 <<
" No FED descriptions found!";
287 db->getAnalysisDescriptions(CommissioningAnalysisDescription::T_ANALYSIS_TIMING);
288 if (anal_descriptions.empty()) {
290 <<
" Unable to build SiStripApvGain object!"
291 <<
" No timing-scan analysis descriptions found!";
301 vector<uint32_t> det_ids;
303 if (det_ids.empty()) {
305 <<
" Unable to build Pedestals object!"
306 <<
" No DetIds found!";
310 <<
" Found " << det_ids.size() <<
" active DetIds";
319 vector<const FedChannelConnection*> conns = det_cabling.
getConnections(det_id);
322 <<
" Unable to build condition object!"
323 <<
" No FED channel connections found for detid " << det_id;
333 nApvPairs =
m_reader->getNumberOfApvsAndStripLength(det_id).first / 2;
359 if (apvPair * 2 <
range.second -
range.first) {
362 <<
" [ApvGain] Read gain value from last IOV for DetId: " << detid
363 <<
" ApvPair: " << apvPair <<
", value=" << height;
366 <<
" [ApvGain] Unable to read gain value from last IOV for DetId: " << detid
367 <<
" ApvPair: " << apvPair <<
", use dummy value=" << height;
371 <<
" [ApvGain] NULL pointer for last stored gain object in DB!!! "
372 <<
"Will use dummy value=" << height <<
" for DetId: " << detid
373 <<
" ApvPair: " << apvPair;
386 std::cout <<
"[SiStripCondObjBuilderFromDb::" << __func__ <<
"]: Set Default Latency for Detid: " << detid
387 <<
" ApvNr: " << apvnr << std::endl;
389 std::cout <<
"[SiStripCondObjBuilderFromDb::" << __func__ <<
"]: Unable to fill Latency for Detid: " << detid
390 <<
" ApvNr: " << apvnr << std::endl;
393 std::cout <<
"[SiStripCondObjBuilderFromDb::" << __func__ <<
"]: Unable to fill Latency for Detid: " << detid
394 <<
" ApvNr: " << apvnr << std::endl;
402 db->getAnalysisDescriptions(CommissioningAnalysisDescription::T_ANALYSIS_TIMING);
403 SiStripConfigDb::AnalysisDescriptionsV::const_iterator iii = anal_descriptions.begin();
404 SiStripConfigDb::AnalysisDescriptionsV::const_iterator jjj = anal_descriptions.end();
407 CommissioningAnalysisDescription*
tmp = *iii;
408 uint16_t fed_id =
tmp->getFedId();
410 if (fed_id == ipair.
fedId() && fed_ch == ipair.
fedCh()) {
416 TimingAnalysisDescription*
anal =
nullptr;
418 anal = dynamic_cast<TimingAnalysisDescription*>(*iii);
422 <<
" [ApvGain] Unable to find Timing Analysis Description from DB for DetId: "
427 bool is_whitelist =
false;
429 if (desc.isConsistent(ipair)) {
441 if (desc.isConsistent(ipair)) {
443 <<
" [ApvGain] Skip module with DetId:" << ipair.
detId()
444 <<
" ApvPair:" << ipair.
apvPairNumber() <<
" according to \n"
460 <<
" [ApvGain] Low tickmark height for DetId:" << ipair.
detId()
476 m_reader->getNumberOfApvsAndStripLength(detid);
478 SiStripConfigDb::DeviceDescriptionsV::const_iterator iapv = apvs.begin();
479 SiStripConfigDb::DeviceDescriptionsV::const_iterator japv = apvs.end();
482 for (; iapv != japv; ++iapv) {
483 apvDescription* apv = dynamic_cast<apvDescription*>(*iapv);
487 if ((apv->getCrateId()) != (ipair.
fecCrate()))
489 if ((apv->getFecSlot()) != (ipair.
fecSlot()))
491 if ((apv->getRingSlot()) != (ipair.
fecRing()))
493 if ((apv->getCcuAddress()) != (ipair.
ccuAddr()))
495 if ((apv->getChannel()) != (ipair.
ccuChan()))
498 if ((apv->getAddress()) == (ipair.
i2cAddr(0))) {
500 detid, apvnr, static_cast<uint16_t>(apv->getLatency()), static_cast<uint16_t>(apv->getApvMode()))) {
501 std::cout <<
"UNABLE APVLatency Put: Detid " <<
dec << detid <<
" APVNr.: " << apvnr
502 <<
" Latency Value: " << dec << static_cast<uint16_t>(apv->getLatency()) <<
" APV Mode: " <<
dec
503 << static_cast<uint16_t>(apv->getApvMode()) << std::endl;
509 if ((apv->getAddress()) == (ipair.
i2cAddr(1))) {
511 detid, apvnr, static_cast<uint16_t>(apv->getLatency()), static_cast<uint16_t>(apv->getApvMode()))) {
512 std::cout <<
"UNABLE APVLatency Put: Detid " <<
dec << detid <<
" APVNr.: " << apvnr
513 <<
" Latency Value: " << dec << static_cast<uint16_t>(apv->getLatency()) <<
" APV Mode: " <<
dec
514 << static_cast<uint16_t>(apv->getApvMode()) << std::endl;
532 SiStripConfigDb::FedDescriptionsV::const_iterator
description = descriptions.begin();
534 if ((*description)->getFedId() == ipair.
fedId()) {
543 const Fed9U::Fed9UStrips&
strips = (*description)->getFedStrips();
547 for (uint16_t iapv = 2 * ipair.
fedCh(); iapv < 2 * ipair.
fedCh() + 2; iapv++) {
549 Fed9U::Fed9UAddress
addr;
550 addr.setFedApv(iapv);
551 vector<Fed9U::Fed9UStripDescription>
strip =
strips.getApvStrips(
addr);
553 vector<Fed9U::Fed9UStripDescription>::const_iterator istrip =
strip.begin();
555 for (; istrip !=
strip.end(); istrip++) {
559 if (istrip->getDisable()) {
560 std::cout <<
"Found disabled strip! Detid: " << detid <<
" APVNr: " << iapv <<
" Strips: " << jstrip
576 std::cout <<
"[SiStripCondObjBuilderFromDb::" << __func__ <<
"]"
577 <<
" Unable to insert values into SiStripPedestals object!"
578 <<
" DetId already exists!" << std::endl;
589 std::cout <<
"[SiStripCondObjBuilderFromDb::" << __func__ <<
"]"
590 <<
" Unable to insert values into SiStripNoises object!"
591 <<
" DetId already exists!" << std::endl;
601 std::cout <<
"[SiStripCondObjBuilderFromDb::" << __func__ <<
"]"
602 <<
" Unable to insert values into SiStripThreshold object!"
603 <<
" DetId already exists!" << std::endl;
615 std::cout <<
"[SiStripCondObjBuilderFromDb::" << __func__ <<
"]"
616 <<
" Unable to insert values into SiStripQuality object!"
617 <<
" DetId already exists!" << std::endl;
630 <<
" [ApvGain] Unable to insert values into SiStripApvGain object!"
631 <<
" DetId already exists!";
642 vector<uint32_t>::const_iterator det_id;
643 vector<uint32_t> det_ids;
649 std::cout <<
"Found no FedDescription!" << std::endl;
654 if (det_ids.empty()) {
655 std::cout <<
"SiStripCondObjBuilderFromDb::" << __func__ <<
"]"
656 <<
" Unable to build Pedestals object!"
657 <<
" No DetIds found!" << std::endl;
660 std::cout <<
"\n\nSiStripCondObjBuilderFromDb::" << __func__ <<
"]"
661 <<
" Found " << det_ids.size() <<
" active DetIds";
664 det_id = det_ids.begin();
665 for (; det_id != det_ids.end(); det_id++) {
666 std::stringstream ssMessage;
677 const vector<const FedChannelConnection*>& conns =
buildConnections(det_cabling, *det_id);
679 vector<const FedChannelConnection*>::const_iterator ipair = conns.begin();
687 vector<vector<const FedChannelConnection*>::const_iterator> listConns(nApvPairs, conns.end());
689 for (; ipair != conns.end(); ++ipair) {
696 listConns[ipair - conns.begin()] = ipair;
698 std::cout <<
"\n impossible to assign connection position in listConns " << std::endl;
706 for (uint16_t apvPair = 0; apvPair < listConns.size(); ++apvPair) {
707 ipair = listConns[apvPair];
708 if (ipair == conns.end()) {
711 <<
" Unable to find FED connection for detid : " <<
std::dec << *det_id <<
" APV pair number "
712 << apvPair <<
" Writing default values" << std::endl;
716 std::cout <<
" Put apvPair+100:" << apvPair <<
" into vector!" << std::endl;
721 apvPair = apvPair - 100;
724 p_apvpcon = std::make_pair(apvPair, **ipair);
737 std::cout <<
"Entering [SiStripCondObjBuilderFromDb::" << __func__ <<
"]" << std::endl;
744 <<
" NULL pointer to AnalysisDescriptions returned by SiStripConfigDb!"
745 <<
" Cannot build Analysis object! QUIT";
750 const std::map<uint32_t, SiStripDetInfoFileReader::DetInfo>& DetInfos =
m_reader->getAllData();
752 for (
auto it = DetInfos.begin(); it != DetInfos.end(); ++it) {
756 <<
"Invalid detid: " << it->first <<
" ... neglecting!" << std::endl;
760 uint32_t detid = it->first;
763 std::find_if(tc.begin(), tc.end(), [detid](
const pair_detcon&
p) {
return p.first == detid; });
764 if (det_iter == tc.end()) {
770 for (
i_apvpairconn connections = det_iter->second.begin(); connections != det_iter->second.end(); connections++) {
771 uint32_t apvPair = (*connections).first;
775 if (apvPair >= 100) {
788 uint32_t nApvPairs = it->second.nApvs / 2;
789 for (uint32_t apvPair = 0; apvPair < nApvPairs; ++apvPair) {
799 std::stringstream
ss;
805 <<
" modules are in the whitelist, updates will be ensured: " <<
ss.str();
812 <<
" [ApvGainSummary] Skipped " <<
skippedDetIds.size() <<
" modules: " <<
ss.str();
819 std::cout <<
"Entering [SiStripCondObjBuilderFromDb::" << __func__ <<
"]" << std::endl;
830 for (
i_trackercon detids = tc.begin(); detids != detids_end; detids++) {
831 uint32_t detid = (*detids).first;
836 for (
i_apvpairconn connections = ((*detids).second).begin(); connections != connections_end; connections++) {
837 uint32_t apvPair = (*connections).first;
841 if (apvPair >= 100) {
843 std::cout <<
"[SiStripCondObjBuilderFromDb::" << __func__ <<
"] No FEDConnection for DetId " << detid
844 <<
" ApvPair " << apvPair - 100 <<
" found, skipping Latency Insertion!" << std::endl;
851 <<
" Unable to find FEC Description"
852 <<
" Skipping Insertion for DetId: " << detid << std::endl;
861 std::stringstream
ss;
872 std::cout <<
"Entering [SiStripCondObjBuilderFromDb::" << __func__ <<
"]" << std::endl;
886 for (
i_trackercon detids = tc.begin(); detids != detids_end; detids++) {
887 uint32_t detid = (*detids).first;
891 for (
i_apvpairconn connections = ((*detids).second).begin(); connections != connections_end; connections++) {
892 uint32_t apvPair = (*connections).first;
896 if (apvPair >= 100) {
897 std::cout <<
"[SiStripCondObjBuilderFromDb::" << __func__ <<
"]"
898 <<
" Unable to find FED description for FED id: " << ipair.
fedId() <<
" detid : " << detid
899 <<
" APV pair number " << apvPair <<
" Writing default values" << std::endl;
905 std::cout <<
"[SiStripCondObjBuilderFromDb::" << __func__ <<
"]"
906 <<
" Unable to find FED description for FED id: " << ipair.
fedId() <<
" detid : " << detid
907 <<
" APV pair number " << apvPair <<
" Writing default values" << std::endl;
935 throw cms::Exception(
"InvalidPSet") <<
"None of FEC coordinates/FED coordinates/detids are valid in this PSet!\n"
941 auto comp = [](uint16_t desc, uint16_t device) {
return desc == 0 || desc == device; };
944 if (fec_.isValid()) {
945 return comp(fec_.fecCrate(),
fc.fecCrate()) &&
comp(fec_.fecSlot(),
fc.fecSlot()) &&
946 comp(fec_.fecRing(),
fc.fecRing()) &&
comp(fec_.ccuAddr(),
fc.ccuAddr()) &&
947 comp(fec_.ccuChan(),
fc.ccuChan()) &&
comp(fec_.lldChan(),
fc.lldChannel()) &&
948 (
comp(fec_.i2cAddr(),
fc.i2cAddr(0)) ||
949 comp(fec_.i2cAddr(),
fc.i2cAddr(1)));
953 if (fed_.isValid()) {
961 return detid_ ==
fc.detId();
968 std::stringstream
ss;
973 ss <<
"detid=" << detid_;
SiStripQuality * quality_
SiStripLatency * latency_
const SiStripDbParams & dbParams() const
void addActiveDetectorsRawIds(std::vector< uint32_t > &) const
unsigned int layerStartBit_
unsigned int sideStartBit_
std::vector< uint32_t > skippedDetIds
const uint16_t & fecCrate() const
unsigned int moduleStartBit_
bool setValuesCabling(SiStripConfigDb::FedDescriptionsRange &descriptions, FedChannelConnection &ipair, uint32_t detid)
static const std::string input
void storeQuality(uint32_t det_id)
unsigned int ladderStartBit_
unsigned int sterStartBit_
DeviceDescriptions::range DeviceDescriptionsRange
uint16_t retrieveNumberAPVPairs(uint32_t det_id)
uint16_t m_defaultapvlatencyvalue
std::vector< SkipDeviceDescription > whitelistedDevices
unsigned int panelStartBit_
bool setValuesApvTiming(SiStripConfigDb *const db, FedChannelConnection &ipair)
unsigned int sterStartBit_
unsigned int sterStartBit_
static const uint32_t invalid32_
Container class for database partition parameters.
bool isValid() const override
unsigned int ringStartBit_
bool put(const uint32_t &detID, const InputVector &input)
bool put(const uint32_t &detID, InputVector &input)
const uint16_t & fedCh() const
std::shared_ptr< SiStripApvGain > gain_last_
std::vector< pair_apvpairconn >::iterator i_apvpairconn
void buildFECRelatedObjects(SiStripConfigDb *const db, const trackercon &tc)
unsigned int diskStartBit_
void setData(float ped, InputVector &vped)
void storeNoise(uint32_t det_id)
const uint16_t & i2cAddr(const uint16_t &apv0_or_1) const
bool checkForCompatibility(std::stringstream &input, std::stringstream &output, std::string &label)
Versions cabVersion() const
static void getFedCabling(const SiStripFecCabling &in, SiStripFedCabling &out)
std::vector< ParameterSet > VParameterSet
unsigned int rodStartBit_
unsigned int petal_fw_bwStartBit_
void setDefaultValuesApvTiming(uint32_t detid, uint32_t apvPair)
SiStripDbParams dbParams_
bool put(const uint32_t &detID, const InputVector &vect)
unsigned int petalStartBit_
Contains cabling info at the device level, including DetId, APV pair numbers, hardware addresses,...
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
unsigned int layerStartBit_
float m_tickmarkThreshold
const uint16_t & fecSlot() const
unsigned int layerStartBit_
unsigned int bladeStartBit_
unsigned int strStartBit_
SiStripNoises::InputVector inputNoises
FedDescriptions::range FedDescriptionsRange
float m_defaultpedestalvalue
std::unique_ptr< const SiStripDetInfoFileReader > m_reader
uint16_t m_defaultapvmodevalue
unsigned int petal_fw_bwMask_
float m_defaultnoisevalue
DeviceFactory *const deviceFactory(std::string method_name="") const
vector< const FedChannelConnection * > buildConnections(const SiStripDetCabling &det_cabling, uint32_t det_id)
void printDebug(std::stringstream &ss, const TrackerTopology *trackerTopo) const
Prints the full list of all ranges and corresponding values of latency and mode.
void compact(unsigned int &, std::vector< unsigned int > &)
bool put(const uint32_t &detID, Range input)
unsigned int sterStartBit_
TrackerTopology * buildTrackerTopology()
unsigned int str_int_extMask_
edm::Service< SiStripConfigDb > db_
unsigned int rod_fw_bwMask_
SiStripPedestals::InputVector inputPedestals
unsigned int moduleStartBit_
An interface class to the DeviceFactory.
SiStripFedCabling * fed_cabling_
std::pair< uint32_t, v_apvpairconn > pair_detcon
void setData(float noise_, InputVector &vped)
SiStripThreshold::InputVector inputThreshold
unsigned int str_fw_bwStartBit_
bool retrieveFedDescriptions(SiStripConfigDb *const db)
Class containning control, module, detector and connection information, at the level of a FED channel...
std::vector< pair_detcon > trackercon
unsigned int wheelStartBit_
bool put(const uint32_t detId, const uint16_t apv, const uint16_t latency, const uint16_t mode)
void printSummary(std::stringstream &ss, const TrackerTopology *trackerTopo) const
Prints the number of ranges as well as the value of singleLatency and singleMode.
static void buildFecCabling(SiStripConfigDb *const, SiStripFecCabling &, const sistrip::CablingSource &)
virtual ~SiStripCondObjBuilderFromDb()
const uint16_t & ccuAddr() const
const uint32_t & detId() const
unsigned int moduleStartBit_
bool put(const uint32_t &detID, const InputVector &vect)
unsigned int module_fw_bwStartBit_
DbClient *const databaseCache(std::string method_name="") const
unsigned int rod_fw_bwStartBit_
static const uint16_t STRIPS_PER_FEDCH
const_iterator_range partitions() const
const uint16_t & feUnit() const
void setDefaultValuesApvLatency(SiStripLatency &latency_, const FedChannelConnection &ipair, uint32_t detid, uint16_t apvnr)
float m_gaincalibrationfactor
void buildFEDRelatedObjects(SiStripConfigDb *const db, const trackercon &tc)
std::vector< pair_detcon >::iterator i_trackercon
Versions apvTimingVersion() const
unsigned int sideStartBit_
static const uint16_t invalid_
void storeTiming(uint32_t det_id)
AnalysisDescriptions::range AnalysisDescriptionsRange
boost::iterator_range< SiStripPartitions::const_iterator > const_iterator_range
unsigned int moduleStartBit_
static const char mlESSources_[]
SiStripQuality::InputVector inputQuality
SiStripPedestals * pedestals_
const uint16_t & fedId() const
static uint16_t fedCh(const uint16_t &fe_unit, const uint16_t &fe_chan)
unsigned int moduleStartBit_
unsigned int moduleStartBit_
Versions fedVersion() const
bool setValuesApvLatency(SiStripLatency &latency_, SiStripConfigDb *const db, FedChannelConnection &ipair, uint32_t detid, uint16_t apvnr, SiStripConfigDb::DeviceDescriptionsRange apvs)
void setDefaultValuesCabling(uint16_t apvPair)
std::pair< ContainerIterator, ContainerIterator > Range
void storeThreshold(uint32_t det_id)
vector< uint32_t > retrieveActiveDetIds(const SiStripDetCabling &det_cabling)
Versions maskVersion() const
bool isConsistent(const FedChannelConnection &fc) const
unsigned int ringStartBit_
float m_defaulttickheightvalue
SiStripApvGain::InputVector inputApvGain
std::string getConfigString(const std::type_info &typeInfo)
uint16_t apvPairNumber() const
std::string partitionName() const
Versions fecVersion() const
float m_defaultthresholdlowvalue
void buildStripRelatedObjects(SiStripConfigDb *const db, const SiStripDetCabling &det_cabling)
unsigned int wheelStartBit_
const uint16_t & ccuChan() const
SiStripCondObjBuilderFromDb()
SiStripThreshold * threshold_
unsigned int encode(const unsigned short &first, const unsigned short &NconsecutiveBadStrips, const unsigned short &flag=0)
float m_defaultthresholdhighvalue
void buildAnalysisRelatedObjects(SiStripConfigDb *const db, const trackercon &tc)
std::vector< uint32_t > whitelistedDetIds
void storePedestals(uint32_t det_id)
unsigned int module_fw_bwMask_
strips
#turn off noise in all subdetectors simHcalUnsuppressedDigis.doNoise = False mix.digitizers....
std::vector< SkipDeviceDescription > skippedDevices
const std::vector< const FedChannelConnection * > & getConnections(uint32_t det_id) const
edm::VParameterSet m_whitelistedDevices
pair_apvpairconn p_apvpcon
const uint16_t & fecRing() const
void setData(const uint16_t &strip, const float &lTh, const float &hTh, Container &vthr)
const uint16_t & feChan() const
bool isValid() const override
unsigned int sideStartBit_
unsigned int str_int_extStartBit_
edm::VParameterSet m_skippedDevices
unsigned int str_fw_bwMask_
bool retrieveTimingAnalysisDescriptions(SiStripConfigDb *const db)