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 // Last commit: $Id: OptoScanHistosUsingDb.cc,v 1.21 2009/11/10 14:49:02 lowette Exp $
2 
8 #include <iostream>
9 
10 using namespace sistrip;
11 
12 // -----------------------------------------------------------------------------
15  DQMStore* bei,
16  SiStripConfigDb* const db )
17  : CommissioningHistograms( pset.getParameter<edm::ParameterSet>("OptoScanParameters"),
18  bei,
19  sistrip::OPTO_SCAN ),
21  sistrip::OPTO_SCAN ),
22  OptoScanHistograms( pset.getParameter<edm::ParameterSet>("OptoScanParameters"),
23  bei )
24 {
26  << "[OptoScanHistosUsingDb::" << __func__ << "]"
27  << " Constructing object...";
28  skipGainUpdate_ = this->pset().getParameter<bool>("SkipGainUpdate");
29  if (skipGainUpdate_)
31  << "[OptoScanHistosUsingDb::" << __func__ << "]"
32  << " Skipping db update of gain parameters.";
33 }
34 
35 // -----------------------------------------------------------------------------
39  << "[OptoScanHistosUsingDb::" << __func__ << "]"
40  << " Destructing object...";
41 }
42 
43 // -----------------------------------------------------------------------------
47  << "[OptoScanHistosUsingDb::" << __func__ << "]";
48 
49  if ( !db() ) {
51  << "[OptoScanHistosUsingDb::" << __func__ << "]"
52  << " NULL pointer to SiStripConfigDb interface!"
53  << " Aborting upload...";
54  return;
55  }
56 
57  // Update LLD descriptions with new bias/gain settings
59  update( devices );
60  if ( doUploadConf() ) {
62  << "[OptoScanHistosUsingDb::" << __func__ << "]"
63  << " Uploading LLD settings to DB...";
66  << "[OptoScanHistosUsingDb::" << __func__ << "]"
67  << " Upload of LLD settings to DB finished!";
68  } else {
70  << "[OptoScanHistosUsingDb::" << __func__ << "]"
71  << " TEST only! No LLD settings will be uploaded to DB...";
72  }
73 
74 }
75 
76 // -----------------------------------------------------------------------------
79 
80  // Iterate through devices and update device descriptions
81  uint16_t updated = 0;
82  SiStripConfigDb::DeviceDescriptionsV::const_iterator idevice;
83  for ( idevice = devices.begin(); idevice != devices.end(); idevice++ ) {
84 
85  if ( (*idevice)->getDeviceType() != LASERDRIVER ) { continue; }
86 
87  // Cast to retrieve appropriate description object
88  laserdriverDescription* desc = dynamic_cast<laserdriverDescription*>( *idevice );
89  if ( !desc ) { continue; }
90 
91  // Retrieve device addresses from device description
92  const SiStripConfigDb::DeviceAddress& addr = db()->deviceAddress(*desc);
93 
94  // Iterate through LLD channels
95  for ( uint16_t ichan = 0; ichan < sistrip::CHANS_PER_LLD; ichan++ ) {
96 
97  // Construct key from device description
98  SiStripFecKey fec_key( addr.fecCrate_,
99  addr.fecSlot_,
100  addr.fecRing_,
101  addr.ccuAddr_,
102  addr.ccuChan_,
103  ichan+1 );
104 
105  // Iterate through all channels and extract LLD settings
106  Analyses::const_iterator iter = data().find( fec_key.key() );
107  if ( iter != data().end() ) {
108 
109  OptoScanAnalysis* anal = dynamic_cast<OptoScanAnalysis*>( iter->second );
110  if ( !anal ) {
112  << "[OptoScanHistosUsingDb::" << __func__ << "]"
113  << " NULL pointer to analysis object!";
114  continue;
115  }
116 
117  uint16_t gain = anal->gain();
118  std::stringstream ss;
119  ss << "[OptoScanHistosUsingDb::" << __func__ << "]"
120  << " Updating LLD gain/bias settings for crate/crate/FEC/ring/CCU/module/LLD "
121  << fec_key.fecCrate() << "/"
122  << fec_key.fecSlot() << "/"
123  << fec_key.fecRing() << "/"
124  << fec_key.ccuAddr() << "/"
125  << fec_key.ccuChan() << "/"
126  << fec_key.channel()
127  << " from "
128  << static_cast<uint16_t>( desc->getGain(ichan) ) << "/"
129  << static_cast<uint16_t>( desc->getBias(ichan) );
130  if (!skipGainUpdate_) desc->setGain( ichan, gain );
131  desc->setBias( ichan, anal->bias()[gain] );
132  updated++;
133  ss << " to "
134  << static_cast<uint16_t>(desc->getGain(ichan)) << "/"
135  << static_cast<uint16_t>(desc->getBias(ichan));
136  LogTrace(mlDqmClient_) << ss.str();
137 
138  } else {
139  if ( deviceIsPresent(fec_key) ) {
141  << "[OptoScanHistosUsingDb::" << __func__ << "]"
142  << " Unable to find FEC key with params crate/FEC/ring/CCU/module/LLD "
143  << fec_key.fecCrate() << "/"
144  << fec_key.fecSlot() << "/"
145  << fec_key.fecRing() << "/"
146  << fec_key.ccuAddr() << "/"
147  << fec_key.ccuChan() << "/"
148  << fec_key.channel();
149  }
150  }
151  }
152  }
153 
155  << "[OptoScanHistosUsingDb::" << __func__ << "]"
156  << " Updated LLD bias/gain settings for "
157  << updated << " modules";
158 
159 
160 }
161 
162 // -----------------------------------------------------------------------------
165  Analysis analysis ) {
166 
167  OptoScanAnalysis* anal = dynamic_cast<OptoScanAnalysis*>( analysis->second );
168  if ( !anal ) { return; }
169 
170  SiStripFecKey fec_key( anal->fecKey() );
171  SiStripFedKey fed_key( anal->fedKey() );
172 
173  for ( uint16_t iapv = 0; iapv < 2; ++iapv ) {
174 
175  // Create description
176  OptoScanAnalysisDescription* tmp;
177  tmp = new OptoScanAnalysisDescription( anal->baseSlope()[0],
178  anal->baseSlope()[1],
179  anal->baseSlope()[2],
180  anal->baseSlope()[3],
181  anal->gain(),
182  anal->bias()[0],
183  anal->bias()[1],
184  anal->bias()[2],
185  anal->bias()[3],
186  anal->measGain()[0],
187  anal->measGain()[1],
188  anal->measGain()[2],
189  anal->measGain()[3],
190  anal->zeroLight()[0],
191  anal->zeroLight()[1],
192  anal->zeroLight()[2],
193  anal->zeroLight()[3],
194  anal->linkNoise()[0],
195  anal->linkNoise()[1],
196  anal->linkNoise()[2],
197  anal->linkNoise()[3],
198  anal->liftOff()[0],
199  anal->liftOff()[1],
200  anal->liftOff()[2],
201  anal->liftOff()[3],
202  anal->threshold()[0],
203  anal->threshold()[1],
204  anal->threshold()[2],
205  anal->threshold()[3],
206  anal->tickHeight()[0],
207  anal->tickHeight()[1],
208  anal->tickHeight()[2],
209  anal->tickHeight()[3],
210  fec_key.fecCrate(),
211  fec_key.fecSlot(),
212  fec_key.fecRing(),
213  fec_key.ccuAddr(),
214  fec_key.ccuChan(),
215  SiStripFecKey::i2cAddr( fec_key.lldChan(), !iapv ),
216  db()->dbParams().partitions().begin()->second.partitionName(),
217  db()->dbParams().partitions().begin()->second.runNumber(),
218  anal->isValid(),
219  "",
220  fed_key.fedId(),
221  fed_key.feUnit(),
222  fed_key.feChan(),
223  fed_key.fedApv() );
224 
225  // Add comments
226  typedef std::vector<std::string> Strings;
227  Strings errors = anal->getErrorCodes();
228  Strings::const_iterator istr = errors.begin();
229  Strings::const_iterator jstr = errors.end();
230  for ( ; istr != jstr; ++istr ) { tmp->addComments( *istr ); }
231 
232  // Store description
233  desc.push_back( tmp );
234 
235  }
236 
237 }
238 
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:57
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:126
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:46
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:129
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()