CMS 3D CMS Logo

OptoScanHistosUsingDb.cc
Go to the documentation of this file.
1 
7 #include <iostream>
8 
9 using namespace sistrip;
10 
11 // -----------------------------------------------------------------------------
14  DQMStore* bei,
15  SiStripConfigDb* const db )
16  : CommissioningHistograms( pset.getParameter<edm::ParameterSet>("OptoScanParameters"),
17  bei,
18  sistrip::OPTO_SCAN ),
20  sistrip::OPTO_SCAN ),
21  OptoScanHistograms( pset.getParameter<edm::ParameterSet>("OptoScanParameters"),
22  bei )
23 {
25  << "[OptoScanHistosUsingDb::" << __func__ << "]"
26  << " Constructing object...";
27  skipGainUpdate_ = this->pset().getParameter<bool>("SkipGainUpdate");
28  if (skipGainUpdate_)
30  << "[OptoScanHistosUsingDb::" << __func__ << "]"
31  << " Skipping db update of gain parameters.";
32 
33  allowSelectiveUpload_ = this->pset().existsAs<bool>("doSelectiveUpload")?this->pset().getParameter<bool>("doSelectiveUpload"):false;
36  << "[OptoScanHistosUsingDb::" << __func__ << "]"
37  << " Enabling selective upload of gain parameters";
38 
39 }
40 
41 // -----------------------------------------------------------------------------
45  << "[OptoScanHistosUsingDb::" << __func__ << "]"
46  << " Destructing object...";
47 }
48 
49 // -----------------------------------------------------------------------------
53  << "[OptoScanHistosUsingDb::" << __func__ << "]";
54 
55  if ( !db() ) {
57  << "[OptoScanHistosUsingDb::" << __func__ << "]"
58  << " NULL pointer to SiStripConfigDb interface!"
59  << " Aborting upload...";
60  return;
61  }
62 
63  // Update LLD descriptions with new bias/gain settings
65  update( devices );
66  if ( doUploadConf() ) {
68  << "[OptoScanHistosUsingDb::" << __func__ << "]"
69  << " Uploading LLD settings to DB...";
72  << "[OptoScanHistosUsingDb::" << __func__ << "]"
73  << " Upload of LLD settings to DB finished!";
74  } else {
76  << "[OptoScanHistosUsingDb::" << __func__ << "]"
77  << " TEST only! No LLD settings will be uploaded to DB...";
78  }
79 
80 }
81 
82 // -----------------------------------------------------------------------------
85 
86  // Iterate through devices and update device descriptions
87  uint16_t updated = 0;
88  SiStripConfigDb::DeviceDescriptionsV::const_iterator idevice;
89  for ( idevice = devices.begin(); idevice != devices.end(); idevice++ ) {
90 
91  if ( (*idevice)->getDeviceType() != LASERDRIVER ) { continue; }
92 
93  // Cast to retrieve appropriate description object
94  laserdriverDescription* desc = dynamic_cast<laserdriverDescription*>( *idevice );
95  if ( !desc ) { continue; }
96 
97  // Retrieve device addresses from device description
98  const SiStripConfigDb::DeviceAddress& addr = db()->deviceAddress(*desc);
99 
100  // Iterate through LLD channels
101  for ( uint16_t ichan = 0; ichan < sistrip::CHANS_PER_LLD; ichan++ ) {
102 
103  // Construct key from device description
104  SiStripFecKey fec_key( addr.fecCrate_,
105  addr.fecSlot_,
106  addr.fecRing_,
107  addr.ccuAddr_,
108  addr.ccuChan_,
109  ichan+1 );
110 
111  // Iterate through all channels and extract LLD settings
112  Analyses::const_iterator iter = data(allowSelectiveUpload_).find( fec_key.key() );
113  if ( iter != data(allowSelectiveUpload_).end() ) {
114 
115  OptoScanAnalysis* anal = dynamic_cast<OptoScanAnalysis*>( iter->second );
116  if ( !anal ) {
118  << "[OptoScanHistosUsingDb::" << __func__ << "]"
119  << " NULL pointer to analysis object!";
120  continue;
121  }
122 
123  uint16_t gain = anal->gain();
124  std::stringstream ss;
125  ss << "[OptoScanHistosUsingDb::" << __func__ << "]"
126  << " Updating LLD gain/bias settings for crate/crate/FEC/ring/CCU/module/LLD "
127  << fec_key.fecCrate() << "/"
128  << fec_key.fecSlot() << "/"
129  << fec_key.fecRing() << "/"
130  << fec_key.ccuAddr() << "/"
131  << fec_key.ccuChan() << "/"
132  << fec_key.channel()
133  << " from "
134  << static_cast<uint16_t>( desc->getGain(ichan) ) << "/"
135  << static_cast<uint16_t>( desc->getBias(ichan) );
136  if (!skipGainUpdate_) desc->setGain( ichan, gain );
137  desc->setBias( ichan, anal->bias()[gain] );
138  updated++;
139  ss << " to "
140  << static_cast<uint16_t>(desc->getGain(ichan)) << "/"
141  << static_cast<uint16_t>(desc->getBias(ichan));
142  LogTrace(mlDqmClient_) << ss.str();
143 
144  } else {
145  if ( deviceIsPresent(fec_key) ) {
147  << "[OptoScanHistosUsingDb::" << __func__ << "]"
148  << " Unable to find FEC key with params crate/FEC/ring/CCU/module/LLD "
149  << fec_key.fecCrate() << "/"
150  << fec_key.fecSlot() << "/"
151  << fec_key.fecRing() << "/"
152  << fec_key.ccuAddr() << "/"
153  << fec_key.ccuChan() << "/"
154  << fec_key.channel();
155  }
156  }
157  }
158  }
159 
161  << "[OptoScanHistosUsingDb::" << __func__ << "]"
162  << " Updated LLD bias/gain settings for "
163  << updated << " modules";
164 
165 
166 }
167 
168 // -----------------------------------------------------------------------------
171  Analysis analysis ) {
172 
173  OptoScanAnalysis* anal = dynamic_cast<OptoScanAnalysis*>( analysis->second );
174  if ( !anal ) { return; }
175 
176  SiStripFecKey fec_key( anal->fecKey() );
177  SiStripFedKey fed_key( anal->fedKey() );
178 
179  for ( uint16_t iapv = 0; iapv < 2; ++iapv ) {
180 
181  // Create description
182  OptoScanAnalysisDescription* tmp;
183  tmp = new OptoScanAnalysisDescription( anal->baseSlope()[0],
184  anal->baseSlope()[1],
185  anal->baseSlope()[2],
186  anal->baseSlope()[3],
187  anal->gain(),
188  anal->bias()[0],
189  anal->bias()[1],
190  anal->bias()[2],
191  anal->bias()[3],
192  anal->measGain()[0],
193  anal->measGain()[1],
194  anal->measGain()[2],
195  anal->measGain()[3],
196  anal->zeroLight()[0],
197  anal->zeroLight()[1],
198  anal->zeroLight()[2],
199  anal->zeroLight()[3],
200  anal->linkNoise()[0],
201  anal->linkNoise()[1],
202  anal->linkNoise()[2],
203  anal->linkNoise()[3],
204  anal->liftOff()[0],
205  anal->liftOff()[1],
206  anal->liftOff()[2],
207  anal->liftOff()[3],
208  anal->threshold()[0],
209  anal->threshold()[1],
210  anal->threshold()[2],
211  anal->threshold()[3],
212  anal->tickHeight()[0],
213  anal->tickHeight()[1],
214  anal->tickHeight()[2],
215  anal->tickHeight()[3],
216  fec_key.fecCrate(),
217  fec_key.fecSlot(),
218  fec_key.fecRing(),
219  fec_key.ccuAddr(),
220  fec_key.ccuChan(),
221  SiStripFecKey::i2cAddr( fec_key.lldChan(), !iapv ),
222  db()->dbParams().partitions().begin()->second.partitionName(),
223  db()->dbParams().partitions().begin()->second.runNumber(),
224  anal->isValid(),
225  "",
226  fed_key.fedId(),
227  fed_key.feUnit(),
228  fed_key.feChan(),
229  fed_key.fedApv() );
230 
231  // Add comments
232  typedef std::vector<std::string> Strings;
233  Strings errors = anal->getErrorCodes();
234  Strings::const_iterator istr = errors.begin();
235  Strings::const_iterator jstr = errors.end();
236  for ( ; istr != jstr; ++istr ) { tmp->addComments( *istr ); }
237 
238  // Store description
239  desc.push_back( tmp );
240 
241  }
242 
243 }
244 
Histogram-based analysis for opto bias/gain scan.
const uint16_t & gain() const
T getParameter(std::string const &) const
void uploadConfigurations() override
bool existsAs(std::string const &parameterName, bool trackiness=true) const
checks if a parameter exists as a given type
Definition: ParameterSet.h:186
const uint32_t & fedKey() const
Analyses & data(bool getMaskedData=false)
const uint16_t & fecRing() const
const VFloat & baseSlope() const
A container class for generic run and event-related info, information required by the commissioning a...
Definition: SiStripFedKey.h:56
const edm::ParameterSet & pset() const
bool deviceIsPresent(const SiStripFecKey &)
const VFloat & liftOff() const
std::vector< std::string > Strings
Definition: MsgTools.h:18
void create(SiStripConfigDb::AnalysisDescriptionsV &, Analysis) override
static const char mlDqmClient_[]
const uint16_t & fecSlot() const
const VFloat & linkNoise() const
const uint16_t & i2cAddr() const
sistrip classes
const VFloat & measGain() const
const uint32_t & key() const
Definition: SiStripKey.h:125
const VFloat & tickHeight() const
Utility class that identifies a position within the strip tracker control structure, down to the level of an APV25.
Definition: SiStripFecKey.h:45
const_iterator_range partitions() const
const VFloat & zeroLight() const
void update(SiStripConfigDb::DeviceDescriptionsRange)
DeviceDescriptions::range DeviceDescriptionsRange
static const uint16_t CHANS_PER_LLD
An interface class to the DeviceFactory.
const uint32_t & fecKey() const
DeviceAddress deviceAddress(const deviceDescription &)
#define LogTrace(id)
const uint16_t & fecCrate() const
const VInt & bias() const
const SiStripDbParams & dbParams() const
OptoScanHistosUsingDb(const edm::ParameterSet &pset, DQMStore *, SiStripConfigDb *const )
const uint16_t & channel() const
Definition: SiStripKey.h:128
const VFloat & threshold() const
const uint16_t & ccuAddr() const
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100
HLT enums.
std::vector< AnalysisDescription * > AnalysisDescriptionsV
const uint16_t & ccuChan() const
Definition: errors.py:1
SiStripConfigDb *const db() const
DeviceDescriptionsRange getDeviceDescriptions(std::string partition="")
void uploadDeviceDescriptions(std::string partition="")
const VString & getErrorCodes() const
bool isValid() const override