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  allowSelectiveUpload_ = this->pset().existsAs<bool>("doSelectiveUpload")?this->pset().getParameter<bool>("doSelectiveUpload"):false;
30  << "[PedestalsHistosUsingDb::" << __func__ << "]"
31  << " Selective upload of modules set to : " << allowSelectiveUpload_;
32 
33 }
34 
35 // -----------------------------------------------------------------------------
39  << "[VpspScanHistosUsingDb::" << __func__ << "]"
40  << " Destructing object...";
41 }
42 
43 // -----------------------------------------------------------------------------
47  << "[VpspScanHistosUsingDb::" << __func__ << "]";
48 
49  if ( !db() ) {
51  << "[VpspScanHistosUsingDb::" << __func__ << "]"
52  << " NULL pointer to SiStripConfigDb interface!"
53  << " Aborting upload...";
54  return;
55  }
56 
57  // Update all APV device descriptions with new VPSP settings
59  update( devices );
60  if ( doUploadConf() ) {
62  << "[VpspScanHistosUsingDb::" << __func__ << "]"
63  << " Uploading VPSP settings to DB...";
66  << "[VpspScanHistosUsingDb::" << __func__ << "]"
67  << " Uploaded VPSP settings to DB!";
68  } else {
70  << "[VpspScanHistosUsingDb::" << __func__ << "]"
71  << " TEST only! No VPSP settings will be uploaded to DB...";
72  }
74  << "[VpspScanHistosUsingDb::" << __func__ << "]"
75  << " Upload of VPSP settings to DB finished!";
76 
77 }
78 
79 // -----------------------------------------------------------------------------
82 
83  // Iterate through devices and update device descriptions
84  SiStripConfigDb::DeviceDescriptionsV::const_iterator idevice;
85  for ( idevice = devices.begin(); idevice != devices.end(); idevice++ ) {
86 
87  // Check device type
88  if ( (*idevice)->getDeviceType() != APV25 ) { continue; }
89 
90  // Cast to retrieve appropriate description object
91  apvDescription* desc = dynamic_cast<apvDescription*>( *idevice );
92  if ( !desc ) { continue; }
93 
94  // Retrieve device addresses from device description
95  const SiStripConfigDb::DeviceAddress& addr = db()->deviceAddress(*desc);
96 
97  // Retrieve LLD channel and APV numbers
98  uint16_t ichan = ( desc->getAddress() - 0x20 ) / 2;
99  uint16_t iapv = ( desc->getAddress() - 0x20 ) % 2;
100 
101  // Construct key from device description
102  SiStripFecKey fec_key( addr.fecCrate_,
103  addr.fecSlot_,
104  addr.fecRing_,
105  addr.ccuAddr_,
106  addr.ccuChan_,
107  ichan+1 );
108 
109  // Iterate through all channels and extract LLD settings
110  Analyses::const_iterator iter = data(allowSelectiveUpload_).find( fec_key.key() );
111  if ( iter != data(allowSelectiveUpload_).end() ) {
112 
113  VpspScanAnalysis* anal = dynamic_cast<VpspScanAnalysis*>( iter->second );
114  if ( !anal ) {
116  << "[VpspScanHistosUsingDb::" << __func__ << "]"
117  << " NULL pointer to analysis object!";
118  continue;
119  }
120 
121  std::stringstream ss;
122  ss << "[VpspScanHistosUsingDb::" << __func__ << "]"
123  << " Updating VPSP setting for crate/FEC/slot/ring/CCU/LLD/APV "
124  << fec_key.fecCrate() << "/"
125  << fec_key.fecSlot() << "/"
126  << fec_key.fecRing() << "/"
127  << fec_key.ccuAddr() << "/"
128  << fec_key.ccuChan() << "/"
129  << fec_key.channel()
130  << iapv
131  << " from "
132  << static_cast<uint16_t>(desc->getVpsp());
133  if ( iapv == 0 ) { desc->setVpsp( anal->vpsp()[0] ); }
134  if ( iapv == 1 ) { desc->setVpsp( anal->vpsp()[1] ); }
135  ss << " to " << static_cast<uint16_t>(desc->getVpsp());
136  LogTrace(mlDqmClient_) << ss.str();
137 
138  } else {
139  if ( deviceIsPresent(fec_key) ) {
141  << "[VpspScanHistosUsingDb::" << __func__ << "]"
142  << " Unable to find FEC key with params FEC/slot/ring/CCU/LLDchan/APV: "
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  << iapv+1;
150  }
151  }
152  }
153 
154 }
155 
156 // -----------------------------------------------------------------------------
159  Analysis analysis ) {
160 
161  VpspScanAnalysis* anal = dynamic_cast<VpspScanAnalysis*>( analysis->second );
162  if ( !anal ) { return; }
163 
164  SiStripFecKey fec_key( anal->fecKey() );
165  SiStripFedKey fed_key( anal->fedKey() );
166 
167  for ( uint16_t iapv = 0; iapv < 2; ++iapv ) {
168 
169  // Create description
170  VpspScanAnalysisDescription* tmp;
171  tmp = new VpspScanAnalysisDescription( anal->vpsp()[iapv],
172  anal->adcLevel()[iapv],
173  anal->fraction()[iapv],
174  anal->topEdge()[iapv],
175  anal->bottomEdge()[iapv],
176  anal->topLevel()[iapv],
177  anal->bottomLevel()[iapv],
178  fec_key.fecCrate(),
179  fec_key.fecSlot(),
180  fec_key.fecRing(),
181  fec_key.ccuAddr(),
182  fec_key.ccuChan(),
183  SiStripFecKey::i2cAddr( fec_key.lldChan(), !iapv ),
184  db()->dbParams().partitions().begin()->second.partitionName(),
185  db()->dbParams().partitions().begin()->second.runNumber(),
186  anal->isValid(),
187  "",
188  fed_key.fedId(),
189  fed_key.feUnit(),
190  fed_key.feChan(),
191  fed_key.fedApv() );
192 
193  // Add comments
194  typedef std::vector<std::string> Strings;
195  Strings errors = anal->getErrorCodes();
196  Strings::const_iterator istr = errors.begin();
197  Strings::const_iterator jstr = errors.end();
198  for ( ; istr != jstr; ++istr ) { tmp->addComments( *istr ); }
199 
200  // Store description
201  desc.push_back( tmp );
202 
203  }
204 
205 }
206 
T getParameter(std::string const &) const
bool isValid() const 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
const VInt & bottomEdge() const
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
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 &)
void uploadConfigurations() override
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="")
void uploadDeviceDescriptions(std::string partition="")
const VString & getErrorCodes() const
const VInt & topEdge() const
const VInt & bottomLevel() const
void create(SiStripConfigDb::AnalysisDescriptionsV &, Analysis) override