24 #include "Fed9UUtils.hh"
27 using namespace sistrip;
34 m_gaincalibrationfactor(static_cast<float>(pset.getUntrackedParameter<double>(
"GainNormalizationFactor",690.))),
35 m_defaultpedestalvalue(static_cast<float>(pset.getUntrackedParameter<double>(
"DefaultPedestal",0.))),
36 m_defaultnoisevalue(static_cast<float>(pset.getUntrackedParameter<double>(
"DefaultNoise",0.))),
37 m_defaultthresholdhighvalue(static_cast<float>(pset.getUntrackedParameter<double>(
"DefaultThresholdHigh",0.))),
38 m_defaultthresholdlowvalue(static_cast<float>(pset.getUntrackedParameter<double>(
"DefaultThresholdLow",0.))),
39 m_defaultapvmodevalue(static_cast<uint16_t>(pset.getUntrackedParameter<uint32_t>(
"DefaultAPVMode",37))),
40 m_defaultapvlatencyvalue(static_cast<uint16_t>(pset.getUntrackedParameter<uint32_t>(
"DefaultAPVLatency",142))),
41 m_defaulttickheightvalue(static_cast<float>(pset.getUntrackedParameter<double>(
"DefaultTickHeight",690.))),
42 m_useanalysis(static_cast<bool>(pset.getUntrackedParameter<bool>(
"UseAnalysis",
false))),
43 m_usefed(static_cast<bool>(pset.getUntrackedParameter<bool>(
"UseFED",
false))),
44 m_usefec(static_cast<bool>(pset.getUntrackedParameter<bool>(
"UseFEC",
false))),
45 m_debug(static_cast<bool>(pset.getUntrackedParameter<bool>(
"DebugMode",
false))),
46 tTopo(buildTrackerTopology())
49 <<
"[SiStripCondObjBuilderFromDb::" << __func__ <<
"]"
50 <<
" Constructing object...";
58 <<
"[SiStripCondObjBuilderFromDb::" << __func__ <<
"]"
59 <<
" Constructing object...";
66 <<
"[SiStripCondObjBuilderFromDb::" << __func__ <<
"]"
67 <<
" Destructing object...";
154 return new TrackerTopology(pxbVals_, pxfVals_, tecVals_, tibVals_, tidVals_, tobVals_);
165 SiStripDbParams::SiStripPartitions::const_iterator ipart = partitionsRange.begin();
166 SiStripDbParams::SiStripPartitions::const_iterator ipartEnd = partitionsRange.end();
167 for ( ; ipart != ipartEnd; ++ipart ) {
171 if (label!=
"Cabling" && label !=
"ApvLatency")
176 if(label==
"ApvTiming")
178 if(label==
"ApvLatency")
179 output<<
" FecVersion " << partition.
fecVersion().first <<
"." << partition.
fecVersion().second;
182 if (!strcmp(output.str().c_str(),input.str().c_str()))
192 <<
"[SiStripCondObjBuilderFromDb::" << __func__ <<
"]";
222 <<
"[SiStripCondObjBuilderFromDb::" << __func__ <<
"]"
223 <<
" NULL pointer to DeviceFactory returned by SiStripConfigDb!"
224 <<
" Cannot build Pedestals object!";
228 <<
"[SiStripCondObjBuilderFromDb::" << __func__ <<
"]"
229 <<
" NULL pointer to SiStripConfigDb returned by DB \"service\"!"
230 <<
" Cannot build Pedestals object!";
239 if ( descriptions.empty() ) {
241 <<
"SiStripCondObjBuilderFromDb::" << __func__ <<
"]"
242 <<
" No FED descriptions found!";
255 if ( anal_descriptions.empty() ) {
257 <<
"SiStripCondObjBuilderFromDb::" << __func__ <<
"]"
258 <<
" Unable to build SiStripApvGain object!"
259 <<
" No timing-scan analysis descriptions found!";
269 vector<uint32_t> det_ids;
271 if ( det_ids.empty() ) {
273 <<
"SiStripCondObjBuilderFromDb::" << __func__ <<
"]"
274 <<
" Unable to build Pedestals object!"
275 <<
" No DetIds found!";
279 <<
"\n\nSiStripCondObjBuilderFromDb::" << __func__ <<
"]"
280 <<
" Found " << det_ids.size() <<
" active DetIds";
288 vector<const FedChannelConnection *> conns = det_cabling.
getConnections(det_id);
289 if (conns.size()==0){
291 <<
"SiStripCondObjBuilderFromDb::" << __func__ <<
"]"
292 <<
" Unable to build condition object!"
293 <<
" No FED channel connections found for detid "<< det_id;
313 std::cout <<
"Found disabled FedConnection! APVPair: " << apvPair <<
" Strips: " << sistrip::STRIPS_PER_FEDCH << std::endl;
315 for ( ;istrip < (apvPair+1)*sistrip::STRIPS_PER_FEDCH; ++istrip ){
332 std::cout <<
"[SiStripCondObjBuilderFromDb::"<<__func__<<
"]: Set Default Latency for Detid: " << detid <<
" ApvNr: " << apvnr << std::endl;
335 std::cout <<
"[SiStripCondObjBuilderFromDb::"<<__func__<<
"]: Unable to fill Latency for Detid: " << detid <<
" ApvNr: " << apvnr << std::endl;
339 std::cout <<
"[SiStripCondObjBuilderFromDb::"<<__func__<<
"]: Unable to fill Latency for Detid: " << detid <<
" ApvNr: " << apvnr << std::endl;
350 SiStripConfigDb::AnalysisDescriptionsV::const_iterator iii = anal_descriptions.begin();
351 SiStripConfigDb::AnalysisDescriptionsV::const_iterator jjj = anal_descriptions.end();
353 while ( iii != jjj ) {
354 CommissioningAnalysisDescription*
tmp = *iii;
355 uint16_t fed_id = tmp->getFedId();
357 if ( fed_id == ipair.
fedId() && fed_ch == ipair.
fedCh() ) {
break; }
361 TimingAnalysisDescription *anal=0;
362 if ( iii != jjj ) { anal =
dynamic_cast<TimingAnalysisDescription*
>(*iii); }
382 SiStripConfigDb::DeviceDescriptionsV::const_iterator iapv = apvs.begin();
383 SiStripConfigDb::DeviceDescriptionsV::const_iterator japv = apvs.end();
384 if(iapv==japv)
return false;
385 for ( ; iapv != japv; ++iapv ) {
386 apvDescription* apv =
dynamic_cast<apvDescription*
>( *iapv );
387 if ( !apv ) {
continue; }
388 if((apv->getCrateId()) != (ipair.
fecCrate()))
continue;
389 if((apv->getFecSlot()) != (ipair.
fecSlot()))
continue;
390 if((apv->getRingSlot()) != (ipair.
fecRing()))
continue;
391 if((apv->getCcuAddress()) != (ipair.
ccuAddr()))
continue;
392 if((apv->getChannel()) != (ipair.
ccuChan()))
continue;
394 if((apv->getAddress()) == (ipair.
i2cAddr(0))) {
395 if(!latency_.
put( detid, apvnr, static_cast<uint16_t>(apv->getLatency()), static_cast<uint16_t>(apv->getApvMode()))){
396 std::cout <<
"UNABLE APVLatency Put: Detid "<<
dec<<detid
397 <<
" APVNr.: " << apvnr
398 <<
" Latency Value: " << dec <<static_cast<uint16_t>(apv->getLatency())
399 <<
" APV Mode: " <<
dec<< static_cast<uint16_t>(apv->getApvMode())
404 if((apv->getAddress()) == (ipair.
i2cAddr(1))) {
405 if(!latency_.
put( detid, apvnr, static_cast<uint16_t>(apv->getLatency()), static_cast<uint16_t>(apv->getApvMode()))){
406 std::cout <<
"UNABLE APVLatency Put: Detid "<<
dec<< detid
407 <<
" APVNr.: " << apvnr
408 <<
" Latency Value: " << dec <<static_cast<uint16_t>(apv->getLatency())
409 <<
" APV Mode: " <<
dec <<static_cast<uint16_t>(apv->getApvMode())
424 SiStripConfigDb::FedDescriptionsV::const_iterator
description = descriptions.begin();
425 while ( description != descriptions.end() ) {
426 if ( (*description)->getFedId() ==ipair.
fedId() ) {
break; }
429 if ( description == descriptions.end() ) {
return false;}
431 const Fed9U::Fed9UStrips&
strips = (*description)->getFedStrips();
436 for ( uint16_t iapv = 2*ipair.
fedCh(); iapv < 2*ipair.
fedCh()+2; iapv++ ) {
439 Fed9U::Fed9UAddress addr;
440 addr.setFedApv(iapv);
441 vector<Fed9U::Fed9UStripDescription> strip = strips.getApvStrips(addr);
443 vector<Fed9U::Fed9UStripDescription>::const_iterator istrip = strip.begin();
445 for ( ; istrip != strip.end(); istrip++ ) {
450 if(istrip->getDisable()){
451 std::cout <<
"Found disabled strip! Detid: " << detid <<
" APVNr: " << iapv <<
" Strips: " << jstrip << std::endl;
468 <<
"[SiStripCondObjBuilderFromDb::" << __func__ <<
"]"
469 <<
" Unable to insert values into SiStripPedestals object!"
470 <<
" DetId already exists!" << std::endl;
485 <<
"[SiStripCondObjBuilderFromDb::" << __func__ <<
"]"
486 <<
" Unable to insert values into SiStripNoises object!"
487 <<
" DetId already exists!" << std::endl;
499 <<
"[SiStripCondObjBuilderFromDb::" << __func__ <<
"]"
500 <<
" Unable to insert values into SiStripThreshold object!"
501 <<
" DetId already exists!" << std::endl;
514 <<
"[SiStripCondObjBuilderFromDb::" << __func__ <<
"]"
515 <<
" Unable to insert values into SiStripQuality object!"
516 <<
" DetId already exists!" << std::endl;
527 if ( !
gain_->
put( det_id, range ) ) {
529 <<
"[SiStripCondObjBuilderFromDb::" << __func__ <<
"]"
530 <<
" Unable to insert values into SiStripApvGain object!"
531 <<
" DetId already exists!";
542 vector<uint32_t>::const_iterator det_id;
543 vector<uint32_t> det_ids;
546 <<
"\n[SiStripCondObjBuilderFromDb::" << __func__ <<
"] first call to this method";
552 if ( det_ids.empty() ) {
554 <<
"SiStripCondObjBuilderFromDb::" << __func__ <<
"]"
555 <<
" Unable to build Pedestals object!"
556 <<
" No DetIds found!" << std::endl;
559 std::cout <<
"\n\nSiStripCondObjBuilderFromDb::" << __func__ <<
"]"
560 <<
" Found " << det_ids.size() <<
" active DetIds";
563 det_id = det_ids.begin();
564 for ( ; det_id != det_ids.end(); det_id++ ) {
565 std::stringstream ssMessage;
568 if ( !(*det_id) ) {
continue; }
573 const vector<const FedChannelConnection *>& conns=
buildConnections(det_cabling, *det_id);
575 vector<const FedChannelConnection *>::const_iterator ipair = conns.begin();
576 if(conns.size() ==0 )
continue;
583 vector< vector<const FedChannelConnection *>::const_iterator > listConns(nApvPairs,conns.end());
585 for ( ; ipair != conns.end(); ++ipair ){
590 listConns[ipair-conns.begin()]=ipair;
593 <<
"\n impossible to assign connection position in listConns " << std::endl;
601 for (uint16_t apvPair=0;apvPair<listConns.size();++apvPair){
602 ipair=listConns[apvPair];
603 if ( ipair == conns.end() ) {
607 <<
" Unable to find FED connection for detid : " <<
std::dec << *det_id <<
" APV pair number " << apvPair
608 <<
" Writing default values" << std::endl;
609 (*ipair)->print(ssMessage);
612 std::cout <<
" Put apvPair+100:" << apvPair <<
" into vector!" << std::endl;
613 p_apvpcon=std::make_pair(apvPair,**ipair);
618 p_apvpcon=std::make_pair(apvPair,**ipair);
631 std::cout <<
"Entering [SiStripCondObjBuilderFromDb::"<<__func__ <<
"]"<<std::endl;
638 <<
"[SiStripCondObjBuilderFromDb::" << __func__ <<
"]"
639 <<
" NULL pointer to AnalysisDescriptions returned by SiStripConfigDb!"
640 <<
" Cannot build Analysis object! QUIT";
650 for(
i_trackercon detids=tc.begin();detids!=detids_end;detids++){
651 uint32_t
detid = (*detids).first;
655 for(
i_apvpairconn connections=((*detids).second).begin();connections!=connections_end;connections++){
656 uint32_t apvPair =(*connections).first;
670 <<
" Unable to find Timing Analysis Description"
671 <<
" Writing default values for DetId: " << detid
685 std::cout <<
"Entering [SiStripCondObjBuilderFromDb::"<<__func__ <<
"]"<<std::endl;
696 for(
i_trackercon detids=tc.begin();detids!=detids_end;detids++){
697 uint32_t
detid = (*detids).first;
703 for(
i_apvpairconn connections=((*detids).second).begin();connections!=connections_end;connections++){
704 uint32_t apvPair =(*connections).first;
710 std::cout <<
"[SiStripCondObjBuilderFromDb::" << __func__ <<
"] No FEDConnection for DetId " << detid <<
" ApvPair " << apvPair-100 <<
" found, skipping Latency Insertion!" << std::endl;
718 <<
" Unable to find FEC Description"
719 <<
" Skipping Insertion for DetId: " << detid << std::endl;
728 std::stringstream
ss;
739 std::cout <<
"Entering [SiStripCondObjBuilderFromDb::"<<__func__ <<
"]"<<std::endl;
753 for(
i_trackercon detids=tc.begin();detids!=detids_end;detids++){
754 uint32_t
detid = (*detids).first;
758 for(
i_apvpairconn connections=((*detids).second).begin();connections!=connections_end;connections++){
759 uint32_t apvPair =(*connections).first;
765 <<
"[SiStripCondObjBuilderFromDb::" << __func__ <<
"]"
766 <<
" Unable to find FED description for FED id: " << ipair.
fedId()
767 <<
" detid : " << detid <<
" APV pair number " << apvPair
768 <<
" Writing default values"<< std::endl;
775 <<
"[SiStripCondObjBuilderFromDb::" << __func__ <<
"]"
776 <<
" Unable to find FED description for FED id: " << ipair.
fedId()
777 <<
" detid : " << detid <<
" APV pair number " << apvPair
778 <<
" Writing default values"<< std::endl;
const uint16_t & fecSlot() const
unsigned int sterStartBit_
bool put(const uint32_t &detID, const InputVector &vect)
vector< uint32_t > retrieveActiveDetIds(const SiStripDetCabling &det_cabling)
unsigned int ringStartBit_
SiStripPedestals::InputVector inputPedestals
unsigned int layerStartBit_
const uint16_t & fecCrate() 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_
void addActiveDetectorsRawIds(std::vector< uint32_t > &) const
SiStripLatency * latency_
SiStripFedCabling * fed_cabling_
unsigned int sterStartBit_
unsigned int layerStartBit_
SiStripCondObjBuilderFromDb()
Versions maskVersion() const
const uint16_t & fedCh() const
SiStripThreshold * threshold_
const std::pair< unsigned short, double > getNumberOfApvsAndStripLength(uint32_t detId) const
void buildAnalysisRelatedObjects(SiStripConfigDb *const db, const trackercon &tc)
DeviceFactory *const deviceFactory(std::string method_name="") const
static const uint32_t invalid32_
SiStripQuality::InputVector inputQuality
FedDescriptionsRange getFedDescriptions(std::string partition="")
pair_apvpairconn p_apvpcon
std::string partitionName() const
uint16_t apvPairNumber() const
FedDescriptions::range FedDescriptionsRange
unsigned int layerStartBit_
SiStripThreshold::InputVector inputThreshold
unsigned int rodStartBit_
float m_defaultthresholdhighvalue
unsigned int petal_fw_bwStartBit_
const uint16_t & fedId() const
unsigned int ladderStartBit_
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)
const std::vector< const FedChannelConnection * > & getConnections(uint32_t det_id) const
const_iterator_range partitions() const
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)
Versions apvTimingVersion() const
void buildStripRelatedObjects(SiStripConfigDb *const db, const SiStripDetCabling &det_cabling)
bool checkForCompatibility(std::stringstream &input, std::stringstream &output, std::string &label)
unsigned int strStartBit_
float m_defaulttickheightvalue
const uint16_t & fecRing() const
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
void compact(unsigned int &, std::vector< unsigned int > &)
unsigned int sterStartBit_
float m_gaincalibrationfactor
float m_defaultnoisevalue
An interface class to the DeviceFactory.
const uint16_t & ccuChan() const
void buildFEDRelatedObjects(SiStripConfigDb *const db, const trackercon &tc)
unsigned int rod_fw_bwStartBit_
unsigned int rod_fw_bwMask_
void setDefaultValuesApvTiming()
std::pair< ContainerIterator, ContainerIterator > Range
uint16_t retrieveNumberAPVPairs(uint32_t det_id)
std::vector< pair_detcon > trackercon
Container class for database partition parameters.
uint16_t m_defaultapvmodevalue
unsigned int str_fw_bwStartBit_
unsigned int moduleStartBit_
float m_defaultthresholdlowvalue
AnalysisDescriptionsRange getAnalysisDescriptions(AnalysisType, std::string partition="")
const uint16_t & ccuAddr() const
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_
void printSummary(std::stringstream &ss) const
Prints the number of ranges as well as the value of singleLatency and singleMode. ...
bool put(const uint32_t &detID, const InputVector &input)
DbClient *const databaseCache(std::string method_name="") const
unsigned int moduleStartBit_
const SiStripDbParams & dbParams() const
SiStripDbParams dbParams_
unsigned int sideStartBit_
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 put(const uint32_t &detID, InputVector &input)
TrackerTopology * buildTrackerTopology()
bool retrieveTimingAnalysisDescriptions(SiStripConfigDb *const db)
AnalysisDescriptions::range AnalysisDescriptionsRange
unsigned int bladeStartBit_
unsigned int module_fw_bwStartBit_
static const uint16_t invalid_
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)
Contains cabling info at the device level, including DetId, APV pair numbers, hardware addresses...
boost::iterator_range< SiStripPartitions::const_iterator > const_iterator_range
std::vector< std::vector< double > > tmp
SiStripApvGain::InputVector inputApvGain
void printDebug(std::stringstream &ss) const
Prints the full list of all ranges and corresponding values of latency and mode.
unsigned int sideStartBit_
void setData(float ped, InputVector &vped)
unsigned int module_fw_bwMask_
unsigned int diskStartBit_
unsigned int panelStartBit_
void storeTiming(uint32_t det_id)
void storePedestals(uint32_t det_id)
static uint16_t fedCh(const uint16_t &fe_unit, const uint16_t &fe_chan)
volatile std::atomic< bool > shutdown_flag false
DeviceDescriptionsRange getDeviceDescriptions(std::string partition="")
static const char mlESSources_[]
void storeNoise(uint32_t det_id)
unsigned int moduleStartBit_
const uint16_t & i2cAddr(const uint16_t &apv0_or_1) const
bool put(const uint32_t &detID, const InputVector &vect)
unsigned int sideStartBit_
std::vector< pair_detcon >::iterator i_trackercon
unsigned int sterStartBit_
Versions fecVersion() const
virtual ~SiStripCondObjBuilderFromDb()
SiStripQuality * quality_
Versions cabVersion() const
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)
Versions fedVersion() const
void setData(float noise_, InputVector &vped)
unsigned int str_fw_bwMask_
unsigned int ringStartBit_
bool setValuesApvTiming(SiStripConfigDb *const db, FedChannelConnection &ipair)
void storeQuality(uint32_t det_id)