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))),
48 tTopo(buildTrackerTopology()) {
50 <<
" Constructing object...";
63 <<
" Constructing object...";
70 <<
" Destructing object...";
157 return new TrackerTopology(pxbVals_, pxfVals_, tecVals_, tibVals_, tidVals_, tobVals_);
162 std::stringstream&
output,
170 SiStripDbParams::SiStripPartitions::const_iterator ipart = partitionsRange.begin();
171 SiStripDbParams::SiStripPartitions::const_iterator ipartEnd = partitionsRange.end();
172 for (; ipart != ipartEnd; ++ipart) {
175 <<
" Partition " <<
partition.partitionName();
176 if (
label !=
"Cabling" &&
label !=
"ApvLatency")
178 if (
label ==
"Cabling")
181 if (
label ==
"ApvTiming")
183 if (
label ==
"ApvLatency")
187 if (!strcmp(
output.str().c_str(),
input.str().c_str()))
200 SiStripDbParams::SiStripPartitions::const_iterator ipart = partitionsRange.begin();
201 SiStripDbParams::SiStripPartitions::const_iterator ipartEnd = partitionsRange.end();
202 for (; ipart != ipartEnd; ++ipart) {
205 <<
"Partition: " <<
partition.partitionName();
221 output <<
" ApvTimingVersion: " <<
partition.apvTimingVersion().first <<
"." 257 <<
" NULL pointer to DeviceFactory returned by SiStripConfigDb!" 258 <<
" Cannot build Pedestals object!";
262 <<
" NULL pointer to SiStripConfigDb returned by DB \"service\"!" 263 <<
" Cannot build Pedestals object!";
272 if (descriptions.empty()) {
274 <<
" No FED descriptions found!";
286 db->getAnalysisDescriptions(CommissioningAnalysisDescription::T_ANALYSIS_TIMING);
287 if (anal_descriptions.empty()) {
289 <<
" Unable to build SiStripApvGain object!" 290 <<
" No timing-scan analysis descriptions found!";
300 vector<uint32_t> det_ids;
302 if (det_ids.empty()) {
304 <<
" Unable to build Pedestals object!" 305 <<
" No DetIds found!";
309 <<
" Found " << det_ids.size() <<
" active DetIds";
318 vector<const FedChannelConnection*> conns = det_cabling.
getConnections(det_id);
321 <<
" Unable to build condition object!" 322 <<
" No FED channel connections found for detid " << det_id;
358 if (apvPair * 2 <
range.second -
range.first) {
361 <<
" [ApvGain] Read gain value from last IOV for DetId: " << detid
362 <<
" ApvPair: " << apvPair <<
", value=" << height;
365 <<
" [ApvGain] Unable to read gain value from last IOV for DetId: " << detid
366 <<
" ApvPair: " << apvPair <<
", use dummy value=" << height;
370 <<
" [ApvGain] NULL pointer for last stored gain object in DB!!! " 371 <<
"Will use dummy value=" << height <<
" for DetId: " << detid
372 <<
" ApvPair: " << apvPair;
385 std::cout <<
"[SiStripCondObjBuilderFromDb::" << __func__ <<
"]: Set Default Latency for Detid: " << detid
386 <<
" ApvNr: " << apvnr << std::endl;
388 std::cout <<
"[SiStripCondObjBuilderFromDb::" << __func__ <<
"]: Unable to fill Latency for Detid: " << detid
389 <<
" ApvNr: " << apvnr << std::endl;
392 std::cout <<
"[SiStripCondObjBuilderFromDb::" << __func__ <<
"]: Unable to fill Latency for Detid: " << detid
393 <<
" ApvNr: " << apvnr << std::endl;
401 db->getAnalysisDescriptions(CommissioningAnalysisDescription::T_ANALYSIS_TIMING);
402 SiStripConfigDb::AnalysisDescriptionsV::const_iterator iii = anal_descriptions.begin();
403 SiStripConfigDb::AnalysisDescriptionsV::const_iterator jjj = anal_descriptions.end();
406 CommissioningAnalysisDescription*
tmp = *iii;
407 uint16_t fed_id =
tmp->getFedId();
409 if (fed_id == ipair.
fedId() && fed_ch == ipair.
fedCh()) {
415 TimingAnalysisDescription*
anal =
nullptr;
417 anal =
dynamic_cast<TimingAnalysisDescription*
>(*iii);
421 <<
" [ApvGain] Unable to find Timing Analysis Description from DB for DetId: " 426 bool is_whitelist =
false;
428 if (
desc.isConsistent(ipair)) {
440 if (
desc.isConsistent(ipair)) {
442 <<
" [ApvGain] Skip module with DetId:" << ipair.
detId()
443 <<
" ApvPair:" << ipair.
apvPairNumber() <<
" according to \n" 459 <<
" [ApvGain] Low tickmark height for DetId:" << ipair.
detId()
477 SiStripConfigDb::DeviceDescriptionsV::const_iterator iapv = apvs.begin();
478 SiStripConfigDb::DeviceDescriptionsV::const_iterator japv = apvs.end();
481 for (; iapv != japv; ++iapv) {
482 apvDescription* apv =
dynamic_cast<apvDescription*
>(*iapv);
486 if ((apv->getCrateId()) != (ipair.
fecCrate()))
488 if ((apv->getFecSlot()) != (ipair.
fecSlot()))
490 if ((apv->getRingSlot()) != (ipair.
fecRing()))
492 if ((apv->getCcuAddress()) != (ipair.
ccuAddr()))
494 if ((apv->getChannel()) != (ipair.
ccuChan()))
497 if ((apv->getAddress()) == (ipair.
i2cAddr(0))) {
499 detid, apvnr, static_cast<uint16_t>(apv->getLatency()), static_cast<uint16_t>(apv->getApvMode()))) {
500 std::cout <<
"UNABLE APVLatency Put: Detid " <<
dec << detid <<
" APVNr.: " << apvnr
501 <<
" Latency Value: " << dec << static_cast<uint16_t>(apv->getLatency()) <<
" APV Mode: " <<
dec 502 << static_cast<uint16_t>(apv->getApvMode()) << std::endl;
508 if ((apv->getAddress()) == (ipair.
i2cAddr(1))) {
510 detid, apvnr, static_cast<uint16_t>(apv->getLatency()), static_cast<uint16_t>(apv->getApvMode()))) {
511 std::cout <<
"UNABLE APVLatency Put: Detid " <<
dec << detid <<
" APVNr.: " << apvnr
512 <<
" Latency Value: " << dec << static_cast<uint16_t>(apv->getLatency()) <<
" APV Mode: " <<
dec 513 << static_cast<uint16_t>(apv->getApvMode()) << std::endl;
531 SiStripConfigDb::FedDescriptionsV::const_iterator
description = descriptions.begin();
533 if ((*description)->getFedId() == ipair.
fedId()) {
542 const Fed9U::Fed9UStrips&
strips = (*description)->getFedStrips();
546 for (uint16_t iapv = 2 * ipair.
fedCh(); iapv < 2 * ipair.
fedCh() + 2; iapv++) {
548 Fed9U::Fed9UAddress
addr;
549 addr.setFedApv(iapv);
550 vector<Fed9U::Fed9UStripDescription>
strip =
strips.getApvStrips(
addr);
552 vector<Fed9U::Fed9UStripDescription>::const_iterator istrip =
strip.begin();
554 for (; istrip !=
strip.end(); istrip++) {
558 if (istrip->getDisable()) {
559 std::cout <<
"Found disabled strip! Detid: " << detid <<
" APVNr: " << iapv <<
" Strips: " << jstrip
575 std::cout <<
"[SiStripCondObjBuilderFromDb::" << __func__ <<
"]" 576 <<
" Unable to insert values into SiStripPedestals object!" 577 <<
" DetId already exists!" << std::endl;
588 std::cout <<
"[SiStripCondObjBuilderFromDb::" << __func__ <<
"]" 589 <<
" Unable to insert values into SiStripNoises object!" 590 <<
" DetId already exists!" << std::endl;
600 std::cout <<
"[SiStripCondObjBuilderFromDb::" << __func__ <<
"]" 601 <<
" Unable to insert values into SiStripThreshold object!" 602 <<
" DetId already exists!" << std::endl;
614 std::cout <<
"[SiStripCondObjBuilderFromDb::" << __func__ <<
"]" 615 <<
" Unable to insert values into SiStripQuality object!" 616 <<
" DetId already exists!" << std::endl;
629 <<
" [ApvGain] Unable to insert values into SiStripApvGain object!" 630 <<
" DetId already exists!";
641 vector<uint32_t>::const_iterator det_id;
642 vector<uint32_t> det_ids;
648 std::cout <<
"Found no FedDescription!" << std::endl;
653 if (det_ids.empty()) {
654 std::cout <<
"SiStripCondObjBuilderFromDb::" << __func__ <<
"]" 655 <<
" Unable to build Pedestals object!" 656 <<
" No DetIds found!" << std::endl;
659 std::cout <<
"\n\nSiStripCondObjBuilderFromDb::" << __func__ <<
"]" 660 <<
" Found " << det_ids.size() <<
" active DetIds";
663 det_id = det_ids.begin();
664 for (; det_id != det_ids.end(); det_id++) {
665 std::stringstream ssMessage;
676 const vector<const FedChannelConnection*>& conns =
buildConnections(det_cabling, *det_id);
678 vector<const FedChannelConnection*>::const_iterator ipair = conns.begin();
686 vector<vector<const FedChannelConnection*>::const_iterator> listConns(nApvPairs, conns.end());
688 for (; ipair != conns.end(); ++ipair) {
695 listConns[ipair - conns.begin()] = ipair;
697 std::cout <<
"\n impossible to assign connection position in listConns " << std::endl;
705 for (uint16_t apvPair = 0; apvPair < listConns.size(); ++apvPair) {
706 ipair = listConns[apvPair];
707 if (ipair == conns.end()) {
710 <<
" Unable to find FED connection for detid : " <<
std::dec << *det_id <<
" APV pair number " 711 << apvPair <<
" Writing default values" << std::endl;
715 std::cout <<
" Put apvPair+100:" << apvPair <<
" into vector!" << std::endl;
720 apvPair = apvPair - 100;
723 p_apvpcon = std::make_pair(apvPair, **ipair);
736 std::cout <<
"Entering [SiStripCondObjBuilderFromDb::" << __func__ <<
"]" << std::endl;
743 <<
" NULL pointer to AnalysisDescriptions returned by SiStripConfigDb!" 744 <<
" Cannot build Analysis object! QUIT";
753 <<
"Invalid detid: " <<
it.first <<
" ... neglecting!" << std::endl;
757 uint32_t detid =
it.first;
760 std::find_if(tc.begin(), tc.end(), [detid](
const pair_detcon&
p) {
return p.first == detid; });
761 if (det_iter == tc.end()) {
767 for (
i_apvpairconn connections = det_iter->second.begin(); connections != det_iter->second.end(); connections++) {
768 uint32_t apvPair = (*connections).first;
772 if (apvPair >= 100) {
785 uint32_t nApvPairs =
it.second.nApvs / 2;
786 for (uint32_t apvPair = 0; apvPair < nApvPairs; ++apvPair) {
796 std::stringstream
ss;
802 <<
" modules are in the whitelist, updates will be ensured: " <<
ss.str();
809 <<
" [ApvGainSummary] Skipped " <<
skippedDetIds.size() <<
" modules: " <<
ss.str();
816 std::cout <<
"Entering [SiStripCondObjBuilderFromDb::" << __func__ <<
"]" << std::endl;
827 for (
i_trackercon detids = tc.begin(); detids != detids_end; detids++) {
828 uint32_t detid = (*detids).first;
833 for (
i_apvpairconn connections = ((*detids).second).begin(); connections != connections_end; connections++) {
834 uint32_t apvPair = (*connections).first;
838 if (apvPair >= 100) {
840 std::cout <<
"[SiStripCondObjBuilderFromDb::" << __func__ <<
"] No FEDConnection for DetId " << detid
841 <<
" ApvPair " << apvPair - 100 <<
" found, skipping Latency Insertion!" << std::endl;
848 <<
" Unable to find FEC Description" 849 <<
" Skipping Insertion for DetId: " << detid << std::endl;
858 std::stringstream
ss;
869 std::cout <<
"Entering [SiStripCondObjBuilderFromDb::" << __func__ <<
"]" << std::endl;
883 for (
i_trackercon detids = tc.begin(); detids != detids_end; detids++) {
884 uint32_t detid = (*detids).first;
888 for (
i_apvpairconn connections = ((*detids).second).begin(); connections != connections_end; connections++) {
889 uint32_t apvPair = (*connections).first;
893 if (apvPair >= 100) {
894 std::cout <<
"[SiStripCondObjBuilderFromDb::" << __func__ <<
"]" 895 <<
" Unable to find FED description for FED id: " << ipair.
fedId() <<
" detid : " << detid
896 <<
" APV pair number " << apvPair <<
" Writing default values" << std::endl;
902 std::cout <<
"[SiStripCondObjBuilderFromDb::" << __func__ <<
"]" 903 <<
" Unable to find FED description for FED id: " << ipair.
fedId() <<
" detid : " << detid
904 <<
" APV pair number " << apvPair <<
" Writing default values" << std::endl;
932 throw cms::Exception(
"InvalidPSet") <<
"None of FEC coordinates/FED coordinates/detids are valid in this PSet!\n" 938 auto comp = [](uint16_t
desc, uint16_t device) {
return desc == 0 ||
desc == device; };
941 if (fec_.isValid()) {
950 if (fed_.isValid()) {
958 return detid_ == fc.
detId();
965 std::stringstream
ss;
970 ss <<
"detid=" << detid_;
unsigned int sterStartBit_
bool put(const uint32_t &detID, const InputVector &vect)
const uint16_t & fecCrate() const
vector< uint32_t > retrieveActiveDetIds(const SiStripDetCabling &det_cabling)
unsigned int ringStartBit_
SiStripPedestals::InputVector inputPedestals
unsigned int layerStartBit_
const uint16_t & ccuAddr() const
unsigned int str_int_extStartBit_
bool put(const uint32_t detId, const uint16_t apv, const uint16_t latency, const uint16_t mode)
unsigned int wheelStartBit_
float m_tickmarkThreshold
SiStripLatency * latency_
SiStripFedCabling * fed_cabling_
unsigned int sterStartBit_
const uint16_t & feChan() const
edm::VParameterSet m_skippedDevices
unsigned int layerStartBit_
const std::vector< const FedChannelConnection * > & getConnections(uint32_t det_id) const
SiStripCondObjBuilderFromDb()
const uint16_t & feUnit() const
SiStripThreshold * threshold_
void buildAnalysisRelatedObjects(SiStripConfigDb *const db, const trackercon &tc)
static const uint32_t invalid32_
SiStripQuality::InputVector inputQuality
DbClient *const databaseCache(std::string method_name="") const
pair_apvpairconn p_apvpcon
std::vector< ParameterSet > VParameterSet
void printDebug(std::stringstream &ss, const TrackerTopology *trackerTopo) const
Prints the full list of all ranges and corresponding values of latency and mode.
std::pair< uint32_t, v_apvpairconn > pair_detcon
FedDescriptions::range FedDescriptionsRange
unsigned int layerStartBit_
const uint16_t & i2cAddr(const uint16_t &apv0_or_1) const
const uint16_t & fecSlot() const
SiStripThreshold::InputVector inputThreshold
Log< level::Error, false > LogError
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
unsigned int rodStartBit_
float m_defaultthresholdhighvalue
std::vector< SkipDeviceDescription > whitelistedDevices
const_iterator_range partitions() const
unsigned int petal_fw_bwStartBit_
unsigned int ladderStartBit_
bool isConsistent(const FedChannelConnection &fc) const
unsigned int petal_fw_bwMask_
void setDefaultValuesCabling(uint16_t apvPair)
static std::string const input
edm::Service< SiStripConfigDb > db_
bool put(const uint32_t &detID, Range input)
void buildFECRelatedObjects(SiStripConfigDb *const db, const trackercon &tc)
bool setValuesApvLatency(SiStripLatency &latency_, SiStripConfigDb *const db, FedChannelConnection &ipair, uint32_t detid, uint16_t apvnr, SiStripConfigDb::DeviceDescriptionsRange apvs)
float m_defaultpedestalvalue
unsigned int petalStartBit_
bool retrieveFedDescriptions(SiStripConfigDb *const db)
void buildStripRelatedObjects(SiStripConfigDb *const db, const SiStripDetCabling &det_cabling)
bool checkForCompatibility(std::stringstream &input, std::stringstream &output, std::string &label)
std::shared_ptr< SiStripApvGain > gain_last_
unsigned int strStartBit_
float m_defaulttickheightvalue
unsigned int moduleStartBit_
static void buildFecCabling(SiStripConfigDb *const, SiStripFecCabling &, const sistrip::CablingSource &)
Class containning control, module, detector and connection information, at the level of a FED channel...
DeviceDescriptions::range DeviceDescriptionsRange
const uint16_t & ccuChan() const
void compact(uint32_t detid, std::vector< unsigned int > &)
const uint16_t & fedId() const
unsigned int sterStartBit_
float m_gaincalibrationfactor
float m_defaultnoisevalue
An interface class to the DeviceFactory.
void buildFEDRelatedObjects(SiStripConfigDb *const db, const trackercon &tc)
unsigned int rod_fw_bwStartBit_
unsigned int rod_fw_bwMask_
std::pair< ContainerIterator, ContainerIterator > Range
const SiStripDbParams & dbParams() const
uint16_t retrieveNumberAPVPairs(uint32_t det_id)
std::vector< pair_detcon > trackercon
Container class for database partition parameters.
std::vector< uint32_t > skippedDetIds
const uint16_t & fecRing() const
uint16_t m_defaultapvmodevalue
unsigned int str_fw_bwStartBit_
unsigned int moduleStartBit_
float m_defaultthresholdlowvalue
unsigned int moduleStartBit_
void storeThreshold(uint32_t det_id)
uint16_t m_defaultapvlatencyvalue
unsigned int wheelStartBit_
vector< const FedChannelConnection * > buildConnections(const SiStripDetCabling &det_cabling, uint32_t det_id)
SiStripNoises::InputVector inputNoises
unsigned int str_int_extMask_
bool put(const uint32_t &detID, const InputVector &input)
const uint32_t & detId() const
unsigned int moduleStartBit_
SiStripDbParams dbParams_
unsigned int sideStartBit_
Log< level::Info, false > LogInfo
bool setValuesCabling(SiStripConfigDb::FedDescriptionsRange &descriptions, FedChannelConnection &ipair, uint32_t detid)
static void getFedCabling(const SiStripFecCabling &in, SiStripFedCabling &out)
static const uint16_t STRIPS_PER_FEDCH
bool isValid() const override
bool put(const uint32_t &detID, InputVector &input)
const std::pair< unsigned short, double > getNumberOfApvsAndStripLength(uint32_t detId) const
TrackerTopology * buildTrackerTopology()
bool retrieveTimingAnalysisDescriptions(SiStripConfigDb *const db)
AnalysisDescriptions::range AnalysisDescriptionsRange
unsigned int bladeStartBit_
unsigned int module_fw_bwStartBit_
static const uint16_t invalid_
std::string getConfigString(const std::type_info &typeInfo)
unsigned int moduleStartBit_
void setDefaultValuesApvLatency(SiStripLatency &latency_, const FedChannelConnection &ipair, uint32_t detid, uint16_t apvnr)
void setData(const uint16_t &strip, const float &lTh, const float &hTh, Container &vthr)
uint16_t apvPairNumber() const
Contains cabling info at the device level, including DetId, APV pair numbers, hardware addresses...
boost::iterator_range< SiStripPartitions::const_iterator > const_iterator_range
SiStripApvGain::InputVector inputApvGain
unsigned int sideStartBit_
void setData(float ped, InputVector &vped)
const std::map< uint32_t, DetInfo > & getAllData() const noexcept
std::vector< uint32_t > whitelistedDetIds
unsigned int module_fw_bwMask_
unsigned int diskStartBit_
unsigned int panelStartBit_
edm::VParameterSet m_whitelistedDevices
void printSummary(std::stringstream &ss, const TrackerTopology *trackerTopo) const
Prints the number of ranges as well as the value of singleLatency and singleMode. ...
void storeTiming(uint32_t det_id)
uint16_t lldChannel() const
strips
#turn off noise in all subdetectors simHcalUnsuppressedDigis.doNoise = False mix.digitizers.hcal.doNoise = False simEcalUnsuppressedDigis.doNoise = False mix.digitizers.ecal.doNoise = False simEcalUnsuppressedDigis.doESNoise = False simSiPixelDigis.AddNoise = False mix.digitizers.pixel.AddNoise = False simSiStripDigis.Noise = False mix.digitizers.strip.AddNoise = False
void storePedestals(uint32_t det_id)
void setDefaultValuesApvTiming(uint32_t detid, uint32_t apvPair)
static uint16_t fedCh(const uint16_t &fe_unit, const uint16_t &fe_chan)
Log< level::Warning, false > LogWarning
static const char mlESSources_[]
void storeNoise(uint32_t det_id)
std::vector< SkipDeviceDescription > skippedDevices
unsigned int moduleStartBit_
const uint16_t & fedCh() const
bool put(const uint32_t &detID, const InputVector &vect)
unsigned int sideStartBit_
std::vector< pair_detcon >::iterator i_trackercon
unsigned int sterStartBit_
virtual ~SiStripCondObjBuilderFromDb()
SiStripQuality * quality_
std::vector< pair_apvpairconn >::iterator i_apvpairconn
SiStripPedestals * pedestals_
unsigned int encode(const unsigned short &first, const unsigned short &NconsecutiveBadStrips, const unsigned short &flag=0)
void setData(float noise_, InputVector &vped)
unsigned int str_fw_bwMask_
unsigned int ringStartBit_
bool setValuesApvTiming(SiStripConfigDb *const db, FedChannelConnection &ipair)
DeviceFactory *const deviceFactory(std::string method_name="") const
void addActiveDetectorsRawIds(std::vector< uint32_t > &) const
bool isValid() const override
void storeQuality(uint32_t det_id)