CMS 3D CMS Logo

CalibrationHistosUsingDb.cc
Go to the documentation of this file.
8 #include <iostream>
9 
10 using namespace sistrip;
11 
12 // -----------------------------------------------------------------------------
15  return path.substr(0,path.find(std::string(sistrip::root_) + "/")+sizeof(sistrip::root_) );
16 }
17 
18 // -----------------------------------------------------------------------------
21  DQMStore* bei,
22  SiStripConfigDb* const db,
23  const sistrip::RunType& task )
24  : CommissioningHistograms( pset.getParameter<edm::ParameterSet>("CalibrationParameters"),
25  bei,
26  task ),
28  task ),
29  CalibrationHistograms( pset.getParameter<edm::ParameterSet>("CalibrationParameters"),
30  bei,
31  task )
32 {
34  << "[CalibrationHistosUsingDb::" << __func__ << "]"
35  << " Constructing object...";
36 
37  // Load and dump the current ISHA/VFS values. This is used by the standalone analysis script
38  const SiStripConfigDb::DeviceDescriptionsRange & apvDescriptions = db->getDeviceDescriptions(APV25);
39  for(SiStripConfigDb::DeviceDescriptionsV::const_iterator apv = apvDescriptions.begin();apv!=apvDescriptions.end();++apv) {
40  apvDescription* desc = dynamic_cast<apvDescription*>( *apv );
41  if ( !desc ) { continue; }
42  // Retrieve device addresses from device description
43  const SiStripConfigDb::DeviceAddress& addr = db->deviceAddress(*desc);
44  std::stringstream bin;
45  bin << std::setw(1) << std::setfill('0') << addr.fecCrate_;
46  bin << "." << std::setw(2) << std::setfill('0') << addr.fecSlot_;
47  bin << "." << std::setw(1) << std::setfill('0') << addr.fecRing_;
48  bin << "." << std::setw(3) << std::setfill('0') << addr.ccuAddr_;
49  bin << "." << std::setw(2) << std::setfill('0') << addr.ccuChan_;
50  bin << "." << desc->getAddress();
51  LogTrace(mlDqmClient_) << "Present values for ISHA/VFS of APV "
52  << bin.str() << " : "
53  << static_cast<uint16_t>(desc->getIsha()) << " " << static_cast<uint16_t>(desc->getVfs());
54  }
55 
56  allowSelectiveUpload_ = this->pset().existsAs<bool>("doSelectiveUpload")?this->pset().getParameter<bool>("doSelectiveUpload"):false;
59  << "[CalibrationHistosUsingDb::" << __func__ << "]"
60  << " Enabling selective update of FED parameters.";
61 
62 }
63 
64 // -----------------------------------------------------------------------------
68  << "[CalibrationHistosUsingDb::" << __func__ << "]"
69  << " Destructing object...";
70 }
71 
72 // -----------------------------------------------------------------------------
75 
76  if ( !db() ) {
78  << "[CalibrationHistosUsingDb::" << __func__ << "]"
79  << " NULL pointer to SiStripConfigDb interface!"
80  << " Aborting upload...";
81  return;
82  }
83 
86  << "[CalibrationHistosUsingDb::" << __func__ << "]"
87  << " Nothing has to be uploaded to the SiStripConfigDb for CALIBRATION_SCAN or CALIBRATION_SCAN_DECO run-types"
88  << " Aborting upload...";
89  return;
90  }
92 
93  // Update all APV device descriptions with new ISHA and VFS settings
95  update( devices );
96  if ( doUploadConf() ) {
98  << "[CalibrationHistosUsingDb::" << __func__ << "]"
99  << " Uploading ISHA/VFS settings to DB...";
102  << "[CalibrationHistosUsingDb::" << __func__ << "]"
103  << " Uploaded ISHA/VFS settings to DB!";
104  } else {
106  << "[CalibrationHistosUsingDb::" << __func__ << "]"
107  << " TEST only! No ISHA/VFS settings will be uploaded to DB...";
108  }
109 
111  << "[CalibrationHistosUsingDb::" << __func__ << "]"
112  << " Upload of ISHA/VFS settings to DB finished!";
113 
114  }
115 }
116 
117 // -----------------------------------------------------------------------------
119 
122  << "[CalibrationHistosUsingDb::" << __func__ << "]"
123  << " Nothing has to be uploaded to the SiStripConfigDb for CALIBRATION_SCAN or CALIBRATION_SCAN_DECO run-type"
124  << " Aborting upload...";
125  return;
126  }
128 
129  // Iterate through devices and update device descriptions
130  SiStripConfigDb::DeviceDescriptionsV::const_iterator idevice;
131  for ( idevice = devices.begin(); idevice != devices.end(); idevice++ ) {
132 
133  // Check device type
134  if ( (*idevice)->getDeviceType() != APV25 ) { continue; }
135  // Cast to retrieve appropriate description object
136  apvDescription* desc = dynamic_cast<apvDescription*>( *idevice );
137  if ( !desc ) { continue; }
138  // Retrieve the device address from device description
139  const SiStripConfigDb::DeviceAddress& addr = db()->deviceAddress(*desc);
140 
141  // Retrieve LLD channel and APV numbers
142  uint16_t ichan = ( desc->getAddress() - 0x20 ) / 2;
143  uint16_t iapv = ( desc->getAddress() - 0x20 ) % 2;
144 
145  // Construct key from device description
146  SiStripFecKey fec_key( addr.fecCrate_,
147  addr.fecSlot_,
148  addr.fecRing_,
149  addr.ccuAddr_,
150  addr.ccuChan_,
151  ichan+1 );
152 
153  // Iterate through all channels and extract LLD settings
154  Analyses::const_iterator iter = data(allowSelectiveUpload_).find( fec_key.key() );
155  if ( iter != data(allowSelectiveUpload_).end() ) {
156  CalibrationScanAnalysis* anal = dynamic_cast<CalibrationScanAnalysis*>( iter->second );
157 
158  if ( !anal ) {
160  << "[CalibrationHistosUsingDb::" << __func__ << "]"
161  << " NULL pointer to analysis object!";
162  continue;
163  }
164 
165  std::stringstream ss;
166  ss << "[CalibrationHistosUsingDb::" << __func__ << "]"
167  << " Updating ISHA and VFS setting for FECCrate/FECSlot/FECRing/CCUAddr/LLD/APV "
168  << fec_key.fecCrate() << "/"
169  << fec_key.fecSlot() << "/"
170  << fec_key.fecRing() << "/"
171  << fec_key.ccuAddr() << "/"
172  << fec_key.ccuChan() << "/"
173  << fec_key.channel()
174  << iapv
175  << " from ISHA "<< static_cast<uint16_t>(desc->getIsha())
176  << " and VFS "<< static_cast<uint16_t>(desc->getVfs());
177  if ( iapv == 0 ) { desc->setIsha( anal->bestISHA()[0] ); }
178  if ( iapv == 1 ) { desc->setIsha( anal->bestISHA()[1] ); }
179  if ( iapv == 0 ) { desc->setVfs( anal->bestVFS()[0] ); }
180  if ( iapv == 1 ) { desc->setVfs( anal->bestVFS()[1] ); }
181  ss << " to ISHA " << static_cast<uint16_t>(desc->getIsha())
182  << " and VFS " << static_cast<uint16_t>(desc->getVfs());
183  edm::LogWarning(mlDqmClient_) << ss.str();
184  }
185  else{
186  if ( deviceIsPresent(fec_key) ) {
188  << "[CalibrationHistosUsingDb::" << __func__ << "]"
189  << " Unable to find FEC key with params FEC/slot/ring/CCU/LLDchan/APV: "
190  << fec_key.fecCrate() << "/"
191  << fec_key.fecSlot() << "/"
192  << fec_key.fecRing() << "/"
193  << fec_key.ccuAddr() << "/"
194  << fec_key.ccuChan() << "/"
195  << fec_key.channel() << "/"
196  << iapv+1;
197  }
198  }
199  }
200  }
201 }
202 
203 // -----------------------------------------------------------------------------
205  Analysis analysis) {
206 
207 
208  if(task() == sistrip::CALIBRATION or task() == sistrip::CALIBRATION_DECO){ // calibration run --> pulse shape measurement
209 
210  CalibrationAnalysis* anal = dynamic_cast<CalibrationAnalysis*>( analysis->second );
211  if ( !anal ) { return; }
212 
213  SiStripFecKey fec_key( anal->fecKey() );
214  SiStripFedKey fed_key( anal->fedKey() );
215 
216  for ( uint16_t iapv = 0; iapv < 2; ++iapv ) {
217 
218  // Create description table with placeholder values for isha and vfs
219  CalibrationAnalysisDescription *tmp;
220  tmp = new CalibrationAnalysisDescription(anal->amplitudeMean()[iapv],
221  anal->tailMean()[iapv],
222  anal->riseTimeMean()[iapv],
223  anal->decayTimeMean()[iapv],
224  anal->smearingMean()[iapv],
225  anal->chi2Mean()[iapv],
226  anal->deconvMode(),
227  fec_key.fecCrate(),
228  fec_key.fecSlot(),
229  fec_key.fecRing(),
230  fec_key.ccuAddr(),
231  fec_key.ccuChan(),
232  SiStripFecKey::i2cAddr( fec_key.lldChan(), !iapv ),
233  db()->dbParams().partitions().begin()->second.partitionName(),
234  db()->dbParams().partitions().begin()->second.runNumber(),
235  anal->isValid(),
236  "",
237  fed_key.fedId(),
238  fed_key.feUnit(),
239  fed_key.feChan(),
240  fed_key.fedApv(),
241  anal->calChan(),
242  -1,
243  -1);
244 
245  // Add comments
246  typedef std::vector<std::string> Strings;
247  Strings errors = anal->getErrorCodes();
248  Strings::const_iterator istr = errors.begin();
249  Strings::const_iterator jstr = errors.end();
250  for ( ; istr != jstr; ++istr ) { tmp->addComments( *istr ); }
251  // Store description
252  desc.push_back( tmp );
253  }
254  }
256 
257  CalibrationScanAnalysis* anal = dynamic_cast<CalibrationScanAnalysis*>( analysis->second );
258  if ( !anal ) { return; }
259 
260  SiStripFecKey fec_key( anal->fecKey() );
261  SiStripFedKey fed_key( anal->fedKey() );
262 
263  for ( uint16_t iapv = 0; iapv < 2; ++iapv ) {
264 
265  // Create description table with placeholder values for isha and vfs
266  CalibrationAnalysisDescription *tmp;
267  tmp = new CalibrationAnalysisDescription(anal->tunedAmplitude()[iapv],
268  anal->tunedTail()[iapv],
269  anal->tunedRiseTime()[iapv],
270  anal->tunedDecayTime()[iapv],
271  anal->tunedSmearing()[iapv],
272  anal->tunedChi2()[iapv],
273  anal->deconvMode(),
274  fec_key.fecCrate(),
275  fec_key.fecSlot(),
276  fec_key.fecRing(),
277  fec_key.ccuAddr(),
278  fec_key.ccuChan(),
279  SiStripFecKey::i2cAddr( fec_key.lldChan(), !iapv ),
280  db()->dbParams().partitions().begin()->second.partitionName(),
281  db()->dbParams().partitions().begin()->second.runNumber(),
282  anal->isValid(),
283  "",
284  fed_key.fedId(),
285  fed_key.feUnit(),
286  fed_key.feChan(),
287  fed_key.fedApv(),
288  -1,
289  anal->tunedISHA()[iapv],
290  anal->tunedVFS()[iapv]);
291 
292 
293  // Add comments
294  typedef std::vector<std::string> Strings;
295  Strings errors = anal->getErrorCodes();
296  Strings::const_iterator istr = errors.begin();
297  Strings::const_iterator jstr = errors.end();
298  for ( ; istr != jstr; ++istr ) { tmp->addComments( *istr ); }
299  // Store description
300  desc.push_back( tmp );
301  }
302  }
303 }
304 
T getParameter(std::string const &) const
const sistrip::RunType & task() const
bool existsAs(std::string const &parameterName, bool trackiness=true) const
checks if a parameter exists as a given type
Definition: ParameterSet.h:161
const uint32_t & fedKey() const
const VFloat & smearingMean()
Analyses & data(bool getMaskedData=false)
const uint16_t & fecRing() 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 &)
std::vector< std::string > Strings
Definition: MsgTools.h:18
static const char mlDqmClient_[]
const uint16_t & fecSlot() const
const uint16_t & i2cAddr() const
sistrip classes
const VFloat & chi2Mean()
const uint32_t & key() const
Definition: SiStripKey.h:125
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 VBool isValid(const std::string &key)
const VFloat & tailMean()
Analysis for calibration runs.
Analysis for calibration scans.
const VFloat & amplitudeMean()
DeviceDescriptions::range DeviceDescriptionsRange
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e< void, edm::EventID const &, edm::Timestamp const & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
Definition: Activities.doc:12
An interface class to the DeviceFactory.
const uint32_t & fecKey() const
const VFloat & riseTimeMean()
DeviceAddress deviceAddress(const deviceDescription &)
#define LogTrace(id)
const uint16_t & fecCrate() const
bin
set the eta bin as selection string.
const VFloat & decayTimeMean()
const SiStripDbParams & dbParams() const
const uint16_t & channel() const
Definition: SiStripKey.h:128
bool isValid() const override
const uint16_t & ccuAddr() const
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100
HLT enums.
void create(SiStripConfigDb::AnalysisDescriptionsV &, Analysis) override
CalibrationHistosUsingDb(const edm::ParameterSet &pset, DQMStore *, SiStripConfigDb *const, const sistrip::RunType &task=sistrip::CALIBRATION)
std::vector< AnalysisDescription * > AnalysisDescriptionsV
static const char root_[]
void update(SiStripConfigDb::DeviceDescriptionsRange &)
const uint16_t & ccuChan() const
Definition: errors.py:1
SiStripConfigDb *const db() const
DeviceDescriptionsRange getDeviceDescriptions(std::string partition="")
void uploadDeviceDescriptions(std::string partition="")
std::string getBasePath(const std::string &path)
const VString & getErrorCodes() const