CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 
34 // -----------------------------------------------------------------------------
38  << "[OptoScanHistosUsingDb::" << __func__ << "]"
39  << " Destructing object...";
40 }
41 
42 // -----------------------------------------------------------------------------
46  << "[OptoScanHistosUsingDb::" << __func__ << "]";
47 
48  if ( !db() ) {
50  << "[OptoScanHistosUsingDb::" << __func__ << "]"
51  << " NULL pointer to SiStripConfigDb interface!"
52  << " Aborting upload...";
53  return;
54  }
55 
56  // Update LLD descriptions with new bias/gain settings
58  update( devices );
59  if ( doUploadConf() ) {
61  << "[OptoScanHistosUsingDb::" << __func__ << "]"
62  << " Uploading LLD settings to DB...";
65  << "[OptoScanHistosUsingDb::" << __func__ << "]"
66  << " Upload of LLD settings to DB finished!";
67  } else {
69  << "[OptoScanHistosUsingDb::" << __func__ << "]"
70  << " TEST only! No LLD settings will be uploaded to DB...";
71  }
72 
73 }
74 
75 // -----------------------------------------------------------------------------
78 
79  // Iterate through devices and update device descriptions
80  uint16_t updated = 0;
81  SiStripConfigDb::DeviceDescriptionsV::const_iterator idevice;
82  for ( idevice = devices.begin(); idevice != devices.end(); idevice++ ) {
83 
84  if ( (*idevice)->getDeviceType() != LASERDRIVER ) { continue; }
85 
86  // Cast to retrieve appropriate description object
87  laserdriverDescription* desc = dynamic_cast<laserdriverDescription*>( *idevice );
88  if ( !desc ) { continue; }
89 
90  // Retrieve device addresses from device description
91  const SiStripConfigDb::DeviceAddress& addr = db()->deviceAddress(*desc);
92 
93  // Iterate through LLD channels
94  for ( uint16_t ichan = 0; ichan < sistrip::CHANS_PER_LLD; ichan++ ) {
95 
96  // Construct key from device description
97  SiStripFecKey fec_key( addr.fecCrate_,
98  addr.fecSlot_,
99  addr.fecRing_,
100  addr.ccuAddr_,
101  addr.ccuChan_,
102  ichan+1 );
103 
104  // Iterate through all channels and extract LLD settings
105  Analyses::const_iterator iter = data().find( fec_key.key() );
106  if ( iter != data().end() ) {
107 
108  OptoScanAnalysis* anal = dynamic_cast<OptoScanAnalysis*>( iter->second );
109  if ( !anal ) {
111  << "[OptoScanHistosUsingDb::" << __func__ << "]"
112  << " NULL pointer to analysis object!";
113  continue;
114  }
115 
116  uint16_t gain = anal->gain();
117  std::stringstream ss;
118  ss << "[OptoScanHistosUsingDb::" << __func__ << "]"
119  << " Updating LLD gain/bias settings for crate/crate/FEC/ring/CCU/module/LLD "
120  << fec_key.fecCrate() << "/"
121  << fec_key.fecSlot() << "/"
122  << fec_key.fecRing() << "/"
123  << fec_key.ccuAddr() << "/"
124  << fec_key.ccuChan() << "/"
125  << fec_key.channel()
126  << " from "
127  << static_cast<uint16_t>( desc->getGain(ichan) ) << "/"
128  << static_cast<uint16_t>( desc->getBias(ichan) );
129  if (!skipGainUpdate_) desc->setGain( ichan, gain );
130  desc->setBias( ichan, anal->bias()[gain] );
131  updated++;
132  ss << " to "
133  << static_cast<uint16_t>(desc->getGain(ichan)) << "/"
134  << static_cast<uint16_t>(desc->getBias(ichan));
135  LogTrace(mlDqmClient_) << ss.str();
136 
137  } else {
138  if ( deviceIsPresent(fec_key) ) {
140  << "[OptoScanHistosUsingDb::" << __func__ << "]"
141  << " Unable to find FEC key with params crate/FEC/ring/CCU/module/LLD "
142  << fec_key.fecCrate() << "/"
143  << fec_key.fecSlot() << "/"
144  << fec_key.fecRing() << "/"
145  << fec_key.ccuAddr() << "/"
146  << fec_key.ccuChan() << "/"
147  << fec_key.channel();
148  }
149  }
150  }
151  }
152 
154  << "[OptoScanHistosUsingDb::" << __func__ << "]"
155  << " Updated LLD bias/gain settings for "
156  << updated << " modules";
157 
158 
159 }
160 
161 // -----------------------------------------------------------------------------
164  Analysis analysis ) {
165 
166  OptoScanAnalysis* anal = dynamic_cast<OptoScanAnalysis*>( analysis->second );
167  if ( !anal ) { return; }
168 
169  SiStripFecKey fec_key( anal->fecKey() );
170  SiStripFedKey fed_key( anal->fedKey() );
171 
172  for ( uint16_t iapv = 0; iapv < 2; ++iapv ) {
173 
174  // Create description
175  OptoScanAnalysisDescription* tmp;
176  tmp = new OptoScanAnalysisDescription( anal->baseSlope()[0],
177  anal->baseSlope()[1],
178  anal->baseSlope()[2],
179  anal->baseSlope()[3],
180  anal->gain(),
181  anal->bias()[0],
182  anal->bias()[1],
183  anal->bias()[2],
184  anal->bias()[3],
185  anal->measGain()[0],
186  anal->measGain()[1],
187  anal->measGain()[2],
188  anal->measGain()[3],
189  anal->zeroLight()[0],
190  anal->zeroLight()[1],
191  anal->zeroLight()[2],
192  anal->zeroLight()[3],
193  anal->linkNoise()[0],
194  anal->linkNoise()[1],
195  anal->linkNoise()[2],
196  anal->linkNoise()[3],
197  anal->liftOff()[0],
198  anal->liftOff()[1],
199  anal->liftOff()[2],
200  anal->liftOff()[3],
201  anal->threshold()[0],
202  anal->threshold()[1],
203  anal->threshold()[2],
204  anal->threshold()[3],
205  anal->tickHeight()[0],
206  anal->tickHeight()[1],
207  anal->tickHeight()[2],
208  anal->tickHeight()[3],
209  fec_key.fecCrate(),
210  fec_key.fecSlot(),
211  fec_key.fecRing(),
212  fec_key.ccuAddr(),
213  fec_key.ccuChan(),
214  SiStripFecKey::i2cAddr( fec_key.lldChan(), !iapv ),
215  db()->dbParams().partitions().begin()->second.partitionName(),
216  db()->dbParams().partitions().begin()->second.runNumber(),
217  anal->isValid(),
218  "",
219  fed_key.fedId(),
220  fed_key.feUnit(),
221  fed_key.feChan(),
222  fed_key.fedApv() );
223 
224  // Add comments
225  typedef std::vector<std::string> Strings;
226  Strings errors = anal->getErrorCodes();
227  Strings::const_iterator istr = errors.begin();
228  Strings::const_iterator jstr = errors.end();
229  for ( ; istr != jstr; ++istr ) { tmp->addComments( *istr ); }
230 
231  // Store description
232  desc.push_back( tmp );
233 
234  }
235 
236 }
237 
Histogram-based analysis for opto bias/gain scan.
const uint16_t & gain() const
T getParameter(std::string const &) const
const uint32_t & fedKey() const
const uint16_t & fecRing() const
const VFloat & baseSlope() const
bool isValid() 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
tuple db
Definition: EcalCondDB.py:151
static const char mlDqmClient_[]
const uint16_t & fecSlot() const
const VFloat & linkNoise() const
const uint16_t & i2cAddr() const
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
std::vector< AnalysisDescription * > AnalysisDescriptionsV
const uint16_t & ccuChan() const
SiStripConfigDb *const db() const
DeviceDescriptionsRange getDeviceDescriptions(std::string partition="")
void uploadDeviceDescriptions(std::string partition="")
const VString & getErrorCodes() const
void create(SiStripConfigDb::AnalysisDescriptionsV &, Analysis)
virtual void uploadConfigurations()