CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
NoiseHistosUsingDb.cc
Go to the documentation of this file.
1 // Last commit: $Id: NoiseHistosUsingDb.cc,v 1.5 2009/11/10 14:49:02 lowette Exp $
2 
9 #include <iostream>
10 
11 using namespace sistrip;
12 
13 // -----------------------------------------------------------------------------
16  DQMStore* bei,
17  SiStripConfigDb* const db )
18  : CommissioningHistograms( pset.getParameter<edm::ParameterSet>("NoiseParameters"),
19  bei,
20  sistrip::NOISE ),
22  sistrip::NOISE ),
23  NoiseHistograms( pset.getParameter<edm::ParameterSet>("NoiseParameters"),
24  bei )
25 {
27  << "[NoiseHistosUsingDb::" << __func__ << "]"
28  << " Constructing object...";
29 }
30 
31 // -----------------------------------------------------------------------------
35  << "[NoiseHistosUsingDb::" << __func__ << "]"
36  << " Destructing object...";
37 }
38 
39 // -----------------------------------------------------------------------------
43  << "[NoiseHistosUsingDb::" << __func__ << "]";
44 
45  if ( !db() ) {
47  << "[NoiseHistosUsingDb::" << __func__ << "]"
48  << " NULL pointer to SiStripConfigDb interface!"
49  << " Aborting upload...";
50  return;
51  }
52 
53  // Update FED descriptions with new peds/noise values
55  update( feds );
56  if ( doUploadConf() ) {
58  << "[NoiseHistosUsingDb::" << __func__ << "]"
59  << " Uploading pedestals/noise to DB...";
62  << "[NoiseHistosUsingDb::" << __func__ << "]"
63  << " Completed database upload of " << feds.size()
64  << " FED descriptions!";
65  } else {
67  << "[NoiseHistosUsingDb::" << __func__ << "]"
68  << " TEST only! No pedestals/noise values will be uploaded to DB...";
69  }
70 
71 }
72 
73 // -----------------------------------------------------------------------------
76 
77  // Iterate through feds and update fed descriptions
78  uint16_t updated = 0;
79  SiStripConfigDb::FedDescriptionsV::const_iterator ifed;
80  for ( ifed = feds.begin(); ifed != feds.end(); ifed++ ) {
81 
82  for ( uint16_t ichan = 0; ichan < sistrip::FEDCH_PER_FED; ichan++ ) {
83 
84  // Build FED and FEC keys
85  const FedChannelConnection& conn = cabling()->connection( (*ifed)->getFedId(), ichan );
86  if ( conn.fecCrate() == sistrip::invalid_ ||
87  conn.fecSlot() == sistrip::invalid_ ||
88  conn.fecRing() == sistrip::invalid_ ||
89  conn.ccuAddr() == sistrip::invalid_ ||
90  conn.ccuChan() == sistrip::invalid_ ||
91  conn.lldChannel() == sistrip::invalid_ ) { continue; }
92  SiStripFedKey fed_key( conn.fedId(),
93  SiStripFedKey::feUnit( conn.fedCh() ),
94  SiStripFedKey::feChan( conn.fedCh() ) );
95  SiStripFecKey fec_key( conn.fecCrate(),
96  conn.fecSlot(),
97  conn.fecRing(),
98  conn.ccuAddr(),
99  conn.ccuChan(),
100  conn.lldChannel() );
101 
102  // Locate appropriate analysis object
103  Analyses::const_iterator iter = data().find( fec_key.key() );
104  if ( iter != data().end() ) {
105 
106  // Check if analysis is valid
107  if ( !iter->second->isValid() ) { continue; }
108 
109  NoiseAnalysis* anal = dynamic_cast<NoiseAnalysis*>( iter->second );
110  if ( !anal ) {
112  << "[NoiseHistosUsingDb::" << __func__ << "]"
113  << " NULL pointer to analysis object!";
114  continue;
115  }
116 
117  // Iterate through APVs and strips
118  for ( uint16_t iapv = 0; iapv < sistrip::APVS_PER_FEDCH; iapv++ ) {
119  for ( uint16_t istr = 0; istr < anal->peds()[iapv].size(); istr++ ) {
120 
121  static float high_threshold = 5.;
122  static float low_threshold = 2.;
123  static bool disable_strip = false;
124  Fed9U::Fed9UStripDescription data( static_cast<uint32_t>( anal->peds()[iapv][istr] ),
125  high_threshold,
126  low_threshold,
127  anal->noise()[iapv][istr],
128  disable_strip );
129  Fed9U::Fed9UAddress addr( ichan, iapv, istr );
130  (*ifed)->getFedStrips().setStrip( addr, data );
131 
132  }
133  }
134  updated++;
135 
136  } else {
138  << "[NoiseHistosUsingDb::" << __func__ << "]"
139  << " Unable to find pedestals/noise for FedKey/Id/Ch: "
140  << hex << setw(8) << setfill('0') << fed_key.key() << dec << "/"
141  << (*ifed)->getFedId() << "/"
142  << ichan
143  << " and device with FEC/slot/ring/CCU/LLD "
144  << fec_key.fecCrate() << "/"
145  << fec_key.fecSlot() << "/"
146  << fec_key.fecRing() << "/"
147  << fec_key.ccuAddr() << "/"
148  << fec_key.ccuChan() << "/"
149  << fec_key.channel();
150  }
151  }
152  }
153 
155  << "[NoiseHistosUsingDb::" << __func__ << "]"
156  << " Updated FED pedestals/noise for "
157  << updated << " channels";
158 
159 }
160 
161 // -----------------------------------------------------------------------------
164  Analysis analysis ) {
165 
166  NoiseAnalysis* anal = dynamic_cast<NoiseAnalysis*>( analysis->second );
167  if ( !anal ) { return; }
168 
169  SiStripFecKey fec_key( anal->fecKey() );
170  SiStripFedKey fed_key( anal->fedKey() );
171 
172  for ( uint16_t iapv = 0; iapv < 2; ++iapv ) {
173 
174  // Create description
175  PedestalsAnalysisDescription* tmp;
176  tmp = new PedestalsAnalysisDescription( anal->dead()[iapv],
177  anal->noisy()[iapv],
178  anal->pedsMean()[iapv],
179  anal->pedsSpread()[iapv],
180  anal->noiseMean()[iapv],
181  anal->noiseSpread()[iapv],
182  anal->rawMean()[iapv],
183  anal->rawSpread()[iapv],
184  anal->pedsMax()[iapv],
185  anal->pedsMin()[iapv],
186  anal->noiseMax()[iapv],
187  anal->noiseMin()[iapv],
188  anal->rawMax()[iapv],
189  anal->rawMin()[iapv],
190  fec_key.fecCrate(),
191  fec_key.fecSlot(),
192  fec_key.fecRing(),
193  fec_key.ccuAddr(),
194  fec_key.ccuChan(),
195  SiStripFecKey::i2cAddr( fec_key.lldChan(), !iapv ),
196  db()->dbParams().partitions().begin()->second.partitionName(),
197  db()->dbParams().partitions().begin()->second.runNumber(),
198  anal->isValid(),
199  "",
200  fed_key.fedId(),
201  fed_key.feUnit(),
202  fed_key.feChan(),
203  fed_key.fedApv() );
204 
205  // Add comments
206  typedef std::vector<std::string> Strings;
207  Strings errors = anal->getErrorCodes();
208  Strings::const_iterator istr = errors.begin();
209  Strings::const_iterator jstr = errors.end();
210  for ( ; istr != jstr; ++istr ) { tmp->addComments( *istr ); }
211 
212  // Store description
213  desc.push_back( tmp );
214 
215  }
216 
217 }
218 
const uint16_t & fecSlot() const
const uint16_t & fecCrate() const
const VVInt & dead() const
const VFloat & noiseMean() const
const uint32_t & fedKey() const
const VFloat & noiseSpread() const
A container class for generic run and event-related info, information required by the commissioning a...
Definition: SiStripFedKey.h:57
const uint16_t & fedCh() const
void create(SiStripConfigDb::AnalysisDescriptionsV &, Analysis)
const VFloat & pedsMax() const
FedDescriptionsRange getFedDescriptions(std::string partition="")
std::vector< std::string > Strings
Definition: MsgTools.h:18
tuple db
Definition: EcalCondDB.py:151
FedDescriptions::range FedDescriptionsRange
static const char mlDqmClient_[]
const FedChannelConnection & connection(uint16_t fed_id, uint16_t fed_ch) const
const VFloat & rawMin() const
uint16_t lldChannel() const
const VFloat & rawMax() const
const VFloat & pedsMean() const
const uint16_t & i2cAddr() const
const uint16_t & fedId() 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 uint16_t & fecRing() const
virtual void uploadConfigurations()
Class containning control, module, detector and connection information, at the level of a FED channel...
const VVFloat & noise() const
An interface class to the DeviceFactory.
const uint16_t & ccuChan() const
const VVInt & noisy() const
const uint32_t & fecKey() const
const uint16_t & ccuAddr() const
#define LogTrace(id)
const VFloat & pedsSpread() const
const VFloat & noiseMin() const
const VFloat & noiseMax() const
const VFloat & rawSpread() const
const VFloat & rawMean() const
const uint16_t & feUnit() const
const SiStripDbParams & dbParams() const
void uploadFedDescriptions(std::string partition="")
static const uint16_t invalid_
Definition: Constants.h:17
const VVFloat & peds() const
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100
void update(SiStripConfigDb::FedDescriptionsRange)
static const uint16_t FEDCH_PER_FED
std::vector< AnalysisDescription * > AnalysisDescriptionsV
const uint16_t & feChan() const
Histogram-based analysis for pedestal run.
Definition: NoiseAnalysis.h:15
SiStripConfigDb *const db() const
SiStripFedCabling *const cabling() const
const VString & getErrorCodes() const
static const uint16_t APVS_PER_FEDCH
tuple conn
Definition: results_mgr.py:53
bool isValid() const
NoiseHistosUsingDb(const edm::ParameterSet &pset, DQMStore *, SiStripConfigDb *const )
const VFloat & pedsMin() const