CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
VpspScanHistosUsingDb.cc
Go to the documentation of this file.
1 // Last commit: $Id: VpspScanHistosUsingDb.cc,v 1.21 2010/04/21 14:26:30 dstrom 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>("VpspScanParameters"),
18  bei,
19  sistrip::VPSP_SCAN ),
21  sistrip::VPSP_SCAN ),
22  VpspScanHistograms( pset.getParameter<edm::ParameterSet>("VpspScanParameters"),
23  bei )
24 {
26  << "[VpspScanHistosUsingDb::" << __func__ << "]"
27  << " Constructing object...";
28 }
29 
30 // -----------------------------------------------------------------------------
34  << "[VpspScanHistosUsingDb::" << __func__ << "]"
35  << " Destructing object...";
36 }
37 
38 // -----------------------------------------------------------------------------
42  << "[VpspScanHistosUsingDb::" << __func__ << "]";
43 
44  if ( !db() ) {
46  << "[VpspScanHistosUsingDb::" << __func__ << "]"
47  << " NULL pointer to SiStripConfigDb interface!"
48  << " Aborting upload...";
49  return;
50  }
51 
52  // Update all APV device descriptions with new VPSP settings
54  update( devices );
55  if ( doUploadConf() ) {
57  << "[VpspScanHistosUsingDb::" << __func__ << "]"
58  << " Uploading VPSP settings to DB...";
61  << "[VpspScanHistosUsingDb::" << __func__ << "]"
62  << " Uploaded VPSP settings to DB!";
63  } else {
65  << "[VpspScanHistosUsingDb::" << __func__ << "]"
66  << " TEST only! No VPSP settings will be uploaded to DB...";
67  }
69  << "[VpspScanHistosUsingDb::" << __func__ << "]"
70  << " Upload of VPSP settings to DB finished!";
71 
72 }
73 
74 // -----------------------------------------------------------------------------
77 
78  // Iterate through devices and update device descriptions
79  SiStripConfigDb::DeviceDescriptionsV::const_iterator idevice;
80  for ( idevice = devices.begin(); idevice != devices.end(); idevice++ ) {
81 
82  // Check device type
83  if ( (*idevice)->getDeviceType() != APV25 ) { continue; }
84 
85  // Cast to retrieve appropriate description object
86  apvDescription* desc = dynamic_cast<apvDescription*>( *idevice );
87  if ( !desc ) { continue; }
88 
89  // Retrieve device addresses from device description
90  const SiStripConfigDb::DeviceAddress& addr = db()->deviceAddress(*desc);
91 
92  // Retrieve LLD channel and APV numbers
93  uint16_t ichan = ( desc->getAddress() - 0x20 ) / 2;
94  uint16_t iapv = ( desc->getAddress() - 0x20 ) % 2;
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  VpspScanAnalysis* anal = dynamic_cast<VpspScanAnalysis*>( iter->second );
109  if ( !anal ) {
111  << "[VpspScanHistosUsingDb::" << __func__ << "]"
112  << " NULL pointer to analysis object!";
113  continue;
114  }
115 
116  std::stringstream ss;
117  ss << "[VpspScanHistosUsingDb::" << __func__ << "]"
118  << " Updating VPSP setting for crate/FEC/slot/ring/CCU/LLD/APV "
119  << fec_key.fecCrate() << "/"
120  << fec_key.fecSlot() << "/"
121  << fec_key.fecRing() << "/"
122  << fec_key.ccuAddr() << "/"
123  << fec_key.ccuChan() << "/"
124  << fec_key.channel()
125  << iapv
126  << " from "
127  << static_cast<uint16_t>(desc->getVpsp());
128  if ( iapv == 0 ) { desc->setVpsp( anal->vpsp()[0] ); }
129  if ( iapv == 1 ) { desc->setVpsp( anal->vpsp()[1] ); }
130  ss << " to " << static_cast<uint16_t>(desc->getVpsp());
131  LogTrace(mlDqmClient_) << ss.str();
132 
133  } else {
134  if ( deviceIsPresent(fec_key) ) {
136  << "[VpspScanHistosUsingDb::" << __func__ << "]"
137  << " Unable to find FEC key with params FEC/slot/ring/CCU/LLDchan/APV: "
138  << fec_key.fecCrate() << "/"
139  << fec_key.fecSlot() << "/"
140  << fec_key.fecRing() << "/"
141  << fec_key.ccuAddr() << "/"
142  << fec_key.ccuChan() << "/"
143  << fec_key.channel() << "/"
144  << iapv+1;
145  }
146  }
147  }
148 
149 }
150 
151 // -----------------------------------------------------------------------------
154  Analysis analysis ) {
155 
156  VpspScanAnalysis* anal = dynamic_cast<VpspScanAnalysis*>( analysis->second );
157  if ( !anal ) { return; }
158 
159  SiStripFecKey fec_key( anal->fecKey() );
160  SiStripFedKey fed_key( anal->fedKey() );
161 
162  for ( uint16_t iapv = 0; iapv < 2; ++iapv ) {
163 
164  // Create description
165  VpspScanAnalysisDescription* tmp;
166  tmp = new VpspScanAnalysisDescription( anal->vpsp()[iapv],
167  anal->adcLevel()[iapv],
168  anal->fraction()[iapv],
169  anal->topEdge()[iapv],
170  anal->bottomEdge()[iapv],
171  anal->topLevel()[iapv],
172  anal->bottomLevel()[iapv],
173  fec_key.fecCrate(),
174  fec_key.fecSlot(),
175  fec_key.fecRing(),
176  fec_key.ccuAddr(),
177  fec_key.ccuChan(),
178  SiStripFecKey::i2cAddr( fec_key.lldChan(), !iapv ),
179  db()->dbParams().partitions().begin()->second.partitionName(),
180  db()->dbParams().partitions().begin()->second.runNumber(),
181  anal->isValid(),
182  "",
183  fed_key.fedId(),
184  fed_key.feUnit(),
185  fed_key.feChan(),
186  fed_key.fedApv() );
187 
188  // Add comments
189  typedef std::vector<std::string> Strings;
190  Strings errors = anal->getErrorCodes();
191  Strings::const_iterator istr = errors.begin();
192  Strings::const_iterator jstr = errors.end();
193  for ( ; istr != jstr; ++istr ) { tmp->addComments( *istr ); }
194 
195  // Store description
196  desc.push_back( tmp );
197 
198  }
199 
200 }
201 
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:57
bool deviceIsPresent(const SiStripFecKey &)
std::vector< std::string > Strings
Definition: MsgTools.h:18
tuple db
Definition: EcalCondDB.py:151
static const char mlDqmClient_[]
void create(SiStripConfigDb::AnalysisDescriptionsV &, Analysis)
const uint16_t & fecSlot() const
void update(SiStripConfigDb::DeviceDescriptionsRange)
const uint16_t & i2cAddr() const
const uint32_t & key() const
Definition: SiStripKey.h:126
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 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:129
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="")
bool isValid() const
void uploadDeviceDescriptions(std::string partition="")
const VString & getErrorCodes() const
const VInt & topEdge() const
const VInt & bottomLevel() const