CMS 3D CMS Logo

VpspScanHistosUsingDb.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>("VpspScanParameters"),
17  bei,
18  sistrip::VPSP_SCAN ),
20  sistrip::VPSP_SCAN ),
21  VpspScanHistograms( pset.getParameter<edm::ParameterSet>("VpspScanParameters"),
22  bei )
23 {
25  << "[VpspScanHistosUsingDb::" << __func__ << "]"
26  << " Constructing object...";
27 }
28 
29 // -----------------------------------------------------------------------------
33  << "[VpspScanHistosUsingDb::" << __func__ << "]"
34  << " Destructing object...";
35 }
36 
37 // -----------------------------------------------------------------------------
41  << "[VpspScanHistosUsingDb::" << __func__ << "]";
42 
43  if ( !db() ) {
45  << "[VpspScanHistosUsingDb::" << __func__ << "]"
46  << " NULL pointer to SiStripConfigDb interface!"
47  << " Aborting upload...";
48  return;
49  }
50 
51  // Update all APV device descriptions with new VPSP settings
53  update( devices );
54  if ( doUploadConf() ) {
56  << "[VpspScanHistosUsingDb::" << __func__ << "]"
57  << " Uploading VPSP settings to DB...";
60  << "[VpspScanHistosUsingDb::" << __func__ << "]"
61  << " Uploaded VPSP settings to DB!";
62  } else {
64  << "[VpspScanHistosUsingDb::" << __func__ << "]"
65  << " TEST only! No VPSP settings will be uploaded to DB...";
66  }
68  << "[VpspScanHistosUsingDb::" << __func__ << "]"
69  << " Upload of VPSP settings to DB finished!";
70 
71 }
72 
73 // -----------------------------------------------------------------------------
76 
77  // Iterate through devices and update device descriptions
78  SiStripConfigDb::DeviceDescriptionsV::const_iterator idevice;
79  for ( idevice = devices.begin(); idevice != devices.end(); idevice++ ) {
80 
81  // Check device type
82  if ( (*idevice)->getDeviceType() != APV25 ) { continue; }
83 
84  // Cast to retrieve appropriate description object
85  apvDescription* desc = dynamic_cast<apvDescription*>( *idevice );
86  if ( !desc ) { continue; }
87 
88  // Retrieve device addresses from device description
89  const SiStripConfigDb::DeviceAddress& addr = db()->deviceAddress(*desc);
90 
91  // Retrieve LLD channel and APV numbers
92  uint16_t ichan = ( desc->getAddress() - 0x20 ) / 2;
93  uint16_t iapv = ( desc->getAddress() - 0x20 ) % 2;
94 
95  // Construct key from device description
96  SiStripFecKey fec_key( addr.fecCrate_,
97  addr.fecSlot_,
98  addr.fecRing_,
99  addr.ccuAddr_,
100  addr.ccuChan_,
101  ichan+1 );
102 
103  // Iterate through all channels and extract LLD settings
104  Analyses::const_iterator iter = data().find( fec_key.key() );
105  if ( iter != data().end() ) {
106 
107  VpspScanAnalysis* anal = dynamic_cast<VpspScanAnalysis*>( iter->second );
108  if ( !anal ) {
110  << "[VpspScanHistosUsingDb::" << __func__ << "]"
111  << " NULL pointer to analysis object!";
112  continue;
113  }
114 
115  std::stringstream ss;
116  ss << "[VpspScanHistosUsingDb::" << __func__ << "]"
117  << " Updating VPSP setting for crate/FEC/slot/ring/CCU/LLD/APV "
118  << fec_key.fecCrate() << "/"
119  << fec_key.fecSlot() << "/"
120  << fec_key.fecRing() << "/"
121  << fec_key.ccuAddr() << "/"
122  << fec_key.ccuChan() << "/"
123  << fec_key.channel()
124  << iapv
125  << " from "
126  << static_cast<uint16_t>(desc->getVpsp());
127  if ( iapv == 0 ) { desc->setVpsp( anal->vpsp()[0] ); }
128  if ( iapv == 1 ) { desc->setVpsp( anal->vpsp()[1] ); }
129  ss << " to " << static_cast<uint16_t>(desc->getVpsp());
130  LogTrace(mlDqmClient_) << ss.str();
131 
132  } else {
133  if ( deviceIsPresent(fec_key) ) {
135  << "[VpspScanHistosUsingDb::" << __func__ << "]"
136  << " Unable to find FEC key with params FEC/slot/ring/CCU/LLDchan/APV: "
137  << fec_key.fecCrate() << "/"
138  << fec_key.fecSlot() << "/"
139  << fec_key.fecRing() << "/"
140  << fec_key.ccuAddr() << "/"
141  << fec_key.ccuChan() << "/"
142  << fec_key.channel() << "/"
143  << iapv+1;
144  }
145  }
146  }
147 
148 }
149 
150 // -----------------------------------------------------------------------------
153  Analysis analysis ) {
154 
155  VpspScanAnalysis* anal = dynamic_cast<VpspScanAnalysis*>( analysis->second );
156  if ( !anal ) { return; }
157 
158  SiStripFecKey fec_key( anal->fecKey() );
159  SiStripFedKey fed_key( anal->fedKey() );
160 
161  for ( uint16_t iapv = 0; iapv < 2; ++iapv ) {
162 
163  // Create description
164  VpspScanAnalysisDescription* tmp;
165  tmp = new VpspScanAnalysisDescription( anal->vpsp()[iapv],
166  anal->adcLevel()[iapv],
167  anal->fraction()[iapv],
168  anal->topEdge()[iapv],
169  anal->bottomEdge()[iapv],
170  anal->topLevel()[iapv],
171  anal->bottomLevel()[iapv],
172  fec_key.fecCrate(),
173  fec_key.fecSlot(),
174  fec_key.fecRing(),
175  fec_key.ccuAddr(),
176  fec_key.ccuChan(),
177  SiStripFecKey::i2cAddr( fec_key.lldChan(), !iapv ),
178  db()->dbParams().partitions().begin()->second.partitionName(),
179  db()->dbParams().partitions().begin()->second.runNumber(),
180  anal->isValid(),
181  "",
182  fed_key.fedId(),
183  fed_key.feUnit(),
184  fed_key.feChan(),
185  fed_key.fedApv() );
186 
187  // Add comments
188  typedef std::vector<std::string> Strings;
189  Strings errors = anal->getErrorCodes();
190  Strings::const_iterator istr = errors.begin();
191  Strings::const_iterator jstr = errors.end();
192  for ( ; istr != jstr; ++istr ) { tmp->addComments( *istr ); }
193 
194  // Store description
195  desc.push_back( tmp );
196 
197  }
198 
199 }
200 
virtual void uploadConfigurations()
const uint32_t & fedKey() const
const VInt & bottomEdge() const
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
bool deviceIsPresent(const SiStripFecKey &)
std::vector< std::string > Strings
Definition: MsgTools.h:18
static const char mlDqmClient_[]
void create(SiStripConfigDb::AnalysisDescriptionsV &, Analysis)
const uint16_t & fecSlot() const
void update(SiStripConfigDb::DeviceDescriptionsRange)
const uint16_t & i2cAddr() const
sistrip classes
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 VInt & topLevel() const
const VInt & fraction() const
DeviceDescriptions::range DeviceDescriptionsRange
An interface class to the DeviceFactory.
const uint32_t & fecKey() const
DeviceAddress deviceAddress(const deviceDescription &)
const VInt & vpsp() const
#define LogTrace(id)
const uint16_t & fecCrate() const
Histogram-based analysis for VPSP scan.
VpspScanHistosUsingDb(const edm::ParameterSet &pset, DQMStore *, SiStripConfigDb *const )
const VInt & adcLevel() const
const SiStripDbParams & dbParams() const
const uint16_t & channel() const
Definition: SiStripKey.h:128
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="")
bool isValid() const
void uploadDeviceDescriptions(std::string partition="")
const VString & getErrorCodes() const
const VInt & topEdge() const
const VInt & bottomLevel() const