25 #include "Fed9UUtils.hh"
28 using namespace sistrip;
35 m_gaincalibrationfactor(static_cast<float>(pset.getUntrackedParameter<double>(
"GainNormalizationFactor",690.))),
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))),
44 m_usefed(static_cast<bool>(pset.getUntrackedParameter<bool>(
"UseFED",
false))),
45 m_usefec(static_cast<bool>(pset.getUntrackedParameter<bool>(
"UseFEC",
false))),
46 m_debug(static_cast<bool>(pset.getUntrackedParameter<bool>(
"DebugMode",
false)))
49 <<
"[SiStripCondObjBuilderFromDb::" << __func__ <<
"]"
50 <<
" Constructing object...";
58 <<
"[SiStripCondObjBuilderFromDb::" << __func__ <<
"]"
59 <<
" Constructing object...";
66 <<
"[SiStripCondObjBuilderFromDb::" << __func__ <<
"]"
67 <<
" Destructing object...";
90 SiStripDbParams::SiStripPartitions::const_iterator ipart = partitionsRange.begin();
91 SiStripDbParams::SiStripPartitions::const_iterator ipartEnd = partitionsRange.end();
92 for ( ; ipart != ipartEnd; ++ipart ) {
96 if (label!=
"Cabling" && label !=
"ApvLatency")
101 if(label==
"ApvTiming")
103 if(label==
"ApvLatency")
104 output<<
" FecVersion " << partition.
fecVersion().first <<
"." << partition.
fecVersion().second;
107 if (!strcmp(output.str().c_str(),input.str().c_str()))
117 <<
"[SiStripCondObjBuilderFromDb::" << __func__ <<
"]";
147 <<
"[SiStripCondObjBuilderFromDb::" << __func__ <<
"]"
148 <<
" NULL pointer to DeviceFactory returned by SiStripConfigDb!"
149 <<
" Cannot build Pedestals object!";
153 <<
"[SiStripCondObjBuilderFromDb::" << __func__ <<
"]"
154 <<
" NULL pointer to SiStripConfigDb returned by DB \"service\"!"
155 <<
" Cannot build Pedestals object!";
164 if ( descriptions.empty() ) {
166 <<
"SiStripCondObjBuilderFromDb::" << __func__ <<
"]"
167 <<
" No FED descriptions found!";
180 if ( anal_descriptions.empty() ) {
182 <<
"SiStripCondObjBuilderFromDb::" << __func__ <<
"]"
183 <<
" Unable to build SiStripApvGain object!"
184 <<
" No timing-scan analysis descriptions found!";
194 vector<uint32_t> det_ids;
196 if ( det_ids.empty() ) {
198 <<
"SiStripCondObjBuilderFromDb::" << __func__ <<
"]"
199 <<
" Unable to build Pedestals object!"
200 <<
" No DetIds found!";
204 <<
"\n\nSiStripCondObjBuilderFromDb::" << __func__ <<
"]"
205 <<
" Found " << det_ids.size() <<
" active DetIds";
213 vector<const FedChannelConnection *> conns = det_cabling.
getConnections(det_id);
214 if (conns.size()==0){
216 <<
"SiStripCondObjBuilderFromDb::" << __func__ <<
"]"
217 <<
" Unable to build condition object!"
218 <<
" No FED channel connections found for detid "<< det_id;
238 std::cout <<
"Found disabled FedConnection! APVPair: " << apvPair <<
" Strips: " << sistrip::STRIPS_PER_FEDCH << std::endl;
240 for ( ;istrip < (apvPair+1)*sistrip::STRIPS_PER_FEDCH; ++istrip ){
257 std::cout <<
"[SiStripCondObjBuilderFromDb::"<<__func__<<
"]: Set Default Latency for Detid: " << detid <<
" ApvNr: " << apvnr << std::endl;
260 std::cout <<
"[SiStripCondObjBuilderFromDb::"<<__func__<<
"]: Unable to fill Latency for Detid: " << detid <<
" ApvNr: " << apvnr << std::endl;
264 std::cout <<
"[SiStripCondObjBuilderFromDb::"<<__func__<<
"]: Unable to fill Latency for Detid: " << detid <<
" ApvNr: " << apvnr << std::endl;
275 SiStripConfigDb::AnalysisDescriptionsV::const_iterator iii = anal_descriptions.begin();
276 SiStripConfigDb::AnalysisDescriptionsV::const_iterator jjj = anal_descriptions.end();
278 while ( iii != jjj ) {
279 CommissioningAnalysisDescription*
tmp = *iii;
280 uint16_t fed_id = tmp->getFedId();
282 if ( fed_id == ipair.
fedId() && fed_ch == ipair.
fedCh() ) {
break; }
286 TimingAnalysisDescription *anal=0;
287 if ( iii != jjj ) { anal =
dynamic_cast<TimingAnalysisDescription*
>(*iii); }
307 SiStripConfigDb::DeviceDescriptionsV::const_iterator iapv = apvs.begin();
308 SiStripConfigDb::DeviceDescriptionsV::const_iterator japv = apvs.end();
309 if(iapv==japv)
return false;
310 for ( ; iapv != japv; ++iapv ) {
311 apvDescription* apv =
dynamic_cast<apvDescription*
>( *iapv );
312 if ( !apv ) {
continue; }
313 if((apv->getCrateId()) != (ipair.
fecCrate()))
continue;
314 if((apv->getFecSlot()) != (ipair.
fecSlot()))
continue;
315 if((apv->getRingSlot()) != (ipair.
fecRing()))
continue;
316 if((apv->getCcuAddress()) != (ipair.
ccuAddr()))
continue;
317 if((apv->getChannel()) != (ipair.
ccuChan()))
continue;
319 if((apv->getAddress()) == (ipair.
i2cAddr(0))) {
320 if(!latency_.
put( detid, apvnr, static_cast<uint16_t>(apv->getLatency()), static_cast<uint16_t>(apv->getApvMode()))){
321 std::cout <<
"UNABLE APVLatency Put: Detid "<< dec<<detid
322 <<
" APVNr.: " << apvnr
323 <<
" Latency Value: " << dec <<static_cast<uint16_t>(apv->getLatency())
324 <<
" APV Mode: " << dec<< static_cast<uint16_t>(apv->getApvMode())
329 if((apv->getAddress()) == (ipair.
i2cAddr(1))) {
330 if(!latency_.
put( detid, apvnr, static_cast<uint16_t>(apv->getLatency()), static_cast<uint16_t>(apv->getApvMode()))){
331 std::cout <<
"UNABLE APVLatency Put: Detid "<<dec<< detid
332 <<
" APVNr.: " << apvnr
333 <<
" Latency Value: " << dec <<static_cast<uint16_t>(apv->getLatency())
334 <<
" APV Mode: " << dec <<static_cast<uint16_t>(apv->getApvMode())
349 SiStripConfigDb::FedDescriptionsV::const_iterator
description = descriptions.begin();
350 while ( description != descriptions.end() ) {
351 if ( (*description)->getFedId() ==ipair.
fedId() ) {
break; }
354 if ( description == descriptions.end() ) {
return false;}
356 const Fed9U::Fed9UStrips&
strips = (*description)->getFedStrips();
361 for ( uint16_t iapv = 2*ipair.
fedCh(); iapv < 2*ipair.
fedCh()+2; iapv++ ) {
364 Fed9U::Fed9UAddress addr;
365 addr.setFedApv(iapv);
366 vector<Fed9U::Fed9UStripDescription> strip = strips.getApvStrips(addr);
368 vector<Fed9U::Fed9UStripDescription>::const_iterator istrip = strip.begin();
370 for ( ; istrip != strip.end(); istrip++ ) {
375 if(istrip->getDisable()){
376 std::cout <<
"Found disabled strip! Detid: " << detid <<
" APVNr: " << iapv <<
" Strips: " << jstrip << std::endl;
393 <<
"[SiStripCondObjBuilderFromDb::" << __func__ <<
"]"
394 <<
" Unable to insert values into SiStripPedestals object!"
395 <<
" DetId already exists!" << std::endl;
410 <<
"[SiStripCondObjBuilderFromDb::" << __func__ <<
"]"
411 <<
" Unable to insert values into SiStripNoises object!"
412 <<
" DetId already exists!" << std::endl;
424 <<
"[SiStripCondObjBuilderFromDb::" << __func__ <<
"]"
425 <<
" Unable to insert values into SiStripThreshold object!"
426 <<
" DetId already exists!" << std::endl;
439 <<
"[SiStripCondObjBuilderFromDb::" << __func__ <<
"]"
440 <<
" Unable to insert values into SiStripQuality object!"
441 <<
" DetId already exists!" << std::endl;
452 if ( !
gain_->
put( det_id, range ) ) {
454 <<
"[SiStripCondObjBuilderFromDb::" << __func__ <<
"]"
455 <<
" Unable to insert values into SiStripApvGain object!"
456 <<
" DetId already exists!";
467 vector<uint32_t>::const_iterator det_id;
468 vector<uint32_t> det_ids;
471 <<
"\n[SiStripCondObjBuilderFromDb::" << __func__ <<
"] first call to this method";
477 if ( det_ids.empty() ) {
479 <<
"SiStripCondObjBuilderFromDb::" << __func__ <<
"]"
480 <<
" Unable to build Pedestals object!"
481 <<
" No DetIds found!" << std::endl;
484 std::cout <<
"\n\nSiStripCondObjBuilderFromDb::" << __func__ <<
"]"
485 <<
" Found " << det_ids.size() <<
" active DetIds";
488 det_id = det_ids.begin();
489 for ( ; det_id != det_ids.end(); det_id++ ) {
490 std::stringstream ssMessage;
493 if ( !(*det_id) ) {
continue; }
498 const vector<const FedChannelConnection *>& conns=
buildConnections(det_cabling, *det_id);
500 vector<const FedChannelConnection *>::const_iterator ipair = conns.begin();
501 if(conns.size() ==0 )
continue;
508 vector< vector<const FedChannelConnection *>::const_iterator > listConns(nApvPairs,conns.end());
510 for ( ; ipair != conns.end(); ++ipair ){
515 listConns[ipair-conns.begin()]=ipair;
518 <<
"\n impossible to assign connection position in listConns " << std::endl;
526 for (uint16_t apvPair=0;apvPair<listConns.size();++apvPair){
527 ipair=listConns[apvPair];
528 if ( ipair == conns.end() ) {
532 <<
" Unable to find FED connection for detid : " << std::dec << *det_id <<
" APV pair number " << apvPair
533 <<
" Writing default values" << std::endl;
534 (*ipair)->print(ssMessage);
537 std::cout <<
" Put apvPair+100:" << apvPair <<
" into vector!" << std::endl;
538 p_apvpcon=std::make_pair(apvPair,**ipair);
543 p_apvpcon=std::make_pair(apvPair,**ipair);
556 std::cout <<
"Entering [SiStripCondObjBuilderFromDb::"<<__func__ <<
"]"<<std::endl;
563 <<
"[SiStripCondObjBuilderFromDb::" << __func__ <<
"]"
564 <<
" NULL pointer to AnalysisDescriptions returned by SiStripConfigDb!"
565 <<
" Cannot build Analysis object! QUIT";
575 for(
i_trackercon detids=tc.begin();detids!=detids_end;detids++){
576 uint32_t
detid = (*detids).first;
580 for(
i_apvpairconn connections=((*detids).second).begin();connections!=connections_end;connections++){
581 uint32_t apvPair =(*connections).first;
595 <<
" Unable to find Timing Analysis Description"
596 <<
" Writing default values for DetId: " << detid
610 std::cout <<
"Entering [SiStripCondObjBuilderFromDb::"<<__func__ <<
"]"<<std::endl;
621 for(
i_trackercon detids=tc.begin();detids!=detids_end;detids++){
622 uint32_t
detid = (*detids).first;
628 for(
i_apvpairconn connections=((*detids).second).begin();connections!=connections_end;connections++){
629 uint32_t apvPair =(*connections).first;
635 std::cout <<
"[SiStripCondObjBuilderFromDb::" << __func__ <<
"] No FEDConnection for DetId " << detid <<
" ApvPair " << apvPair-100 <<
" found, skipping Latency Insertion!" << std::endl;
643 <<
" Unable to find FEC Description"
644 <<
" Skipping Insertion for DetId: " << detid << std::endl;
653 std::stringstream ss;
664 std::cout <<
"Entering [SiStripCondObjBuilderFromDb::"<<__func__ <<
"]"<<std::endl;
678 for(
i_trackercon detids=tc.begin();detids!=detids_end;detids++){
679 uint32_t
detid = (*detids).first;
683 for(
i_apvpairconn connections=((*detids).second).begin();connections!=connections_end;connections++){
684 uint32_t apvPair =(*connections).first;
690 <<
"[SiStripCondObjBuilderFromDb::" << __func__ <<
"]"
691 <<
" Unable to find FED description for FED id: " << ipair.
fedId()
692 <<
" detid : " << detid <<
" APV pair number " << apvPair
693 <<
" Writing default values"<< std::endl;
700 <<
"[SiStripCondObjBuilderFromDb::" << __func__ <<
"]"
701 <<
" Unable to find FED description for FED id: " << ipair.
fedId()
702 <<
" detid : " << detid <<
" APV pair number " << apvPair
703 <<
" Writing default values"<< std::endl;
const uint16_t & fecSlot() const
bool put(const uint32_t &detID, const InputVector &vect)
vector< uint32_t > retrieveActiveDetIds(const SiStripDetCabling &det_cabling)
SiStripPedestals::InputVector inputPedestals
const uint16_t & fecCrate() const
bool put(const uint32_t detId, const uint16_t apv, const uint16_t latency, const uint16_t mode)
void addActiveDetectorsRawIds(std::vector< uint32_t > &) const
SiStripLatency * latency_
SiStripFedCabling * fed_cabling_
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
SiStripThreshold::InputVector inputThreshold
float m_defaultthresholdhighvalue
const uint16_t & fedId() const
void setDefaultValuesCabling(uint16_t apvPair)
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
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)
float m_defaulttickheightvalue
const uint16_t & fecRing() const
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 > &)
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)
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
float m_defaultthresholdlowvalue
AnalysisDescriptionsRange getAnalysisDescriptions(AnalysisType, std::string partition="")
const uint16_t & ccuAddr() const
void storeThreshold(uint32_t det_id)
uint16_t m_defaultapvlatencyvalue
vector< const FedChannelConnection * > buildConnections(const SiStripDetCabling &det_cabling, uint32_t det_id)
SiStripNoises::InputVector inputNoises
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
const SiStripDbParams & dbParams() const
SiStripDbParams dbParams_
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)
bool retrieveTimingAnalysisDescriptions(SiStripConfigDb *const db)
AnalysisDescriptions::range AnalysisDescriptionsRange
static const uint16_t invalid_
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.
void setData(float ped, InputVector &vped)
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)
DeviceDescriptionsRange getDeviceDescriptions(std::string partition="")
static const char mlESSources_[]
void storeNoise(uint32_t det_id)
const uint16_t & i2cAddr(const uint16_t &apv0_or_1) const
bool put(const uint32_t &detID, const InputVector &vect)
std::vector< pair_detcon >::iterator i_trackercon
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)
bool setValuesApvTiming(SiStripConfigDb *const db, FedChannelConnection &ipair)
void storeQuality(uint32_t det_id)