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 
8 #include <iostream>
9 
10 using namespace sistrip;
11 
12 // -----------------------------------------------------------------------------
15  DQMStore* bei,
16  SiStripConfigDb* const db )
17  : CommissioningHistograms( pset.getParameter<edm::ParameterSet>("NoiseParameters"),
18  bei,
19  sistrip::NOISE ),
21  sistrip::NOISE ),
22  NoiseHistograms( pset.getParameter<edm::ParameterSet>("NoiseParameters"),
23  bei )
24 {
26  << "[NoiseHistosUsingDb::" << __func__ << "]"
27  << " Constructing object...";
28 }
29 
30 // -----------------------------------------------------------------------------
34  << "[NoiseHistosUsingDb::" << __func__ << "]"
35  << " Destructing object...";
36 }
37 
38 // -----------------------------------------------------------------------------
42  << "[NoiseHistosUsingDb::" << __func__ << "]";
43 
44  if ( !db() ) {
46  << "[NoiseHistosUsingDb::" << __func__ << "]"
47  << " NULL pointer to SiStripConfigDb interface!"
48  << " Aborting upload...";
49  return;
50  }
51 
52  // Update FED descriptions with new peds/noise values
54  update( feds );
55  if ( doUploadConf() ) {
57  << "[NoiseHistosUsingDb::" << __func__ << "]"
58  << " Uploading pedestals/noise to DB...";
61  << "[NoiseHistosUsingDb::" << __func__ << "]"
62  << " Completed database upload of " << feds.size()
63  << " FED descriptions!";
64  } else {
66  << "[NoiseHistosUsingDb::" << __func__ << "]"
67  << " TEST only! No pedestals/noise values will be uploaded to DB...";
68  }
69 
70 }
71 
72 // -----------------------------------------------------------------------------
75 
76  // Iterate through feds and update fed descriptions
77  uint16_t updated = 0;
78  SiStripConfigDb::FedDescriptionsV::const_iterator ifed;
79  for ( ifed = feds.begin(); ifed != feds.end(); ifed++ ) {
80 
81  for ( uint16_t ichan = 0; ichan < sistrip::FEDCH_PER_FED; ichan++ ) {
82 
83  // Build FED and FEC keys
84  const FedChannelConnection& conn = cabling()->fedConnection( (*ifed)->getFedId(), ichan );
85  if ( conn.fecCrate() == sistrip::invalid_ ||
86  conn.fecSlot() == sistrip::invalid_ ||
87  conn.fecRing() == sistrip::invalid_ ||
88  conn.ccuAddr() == sistrip::invalid_ ||
89  conn.ccuChan() == sistrip::invalid_ ||
90  conn.lldChannel() == sistrip::invalid_ ) { continue; }
91  SiStripFedKey fed_key( conn.fedId(),
92  SiStripFedKey::feUnit( conn.fedCh() ),
93  SiStripFedKey::feChan( conn.fedCh() ) );
94  SiStripFecKey fec_key( conn.fecCrate(),
95  conn.fecSlot(),
96  conn.fecRing(),
97  conn.ccuAddr(),
98  conn.ccuChan(),
99  conn.lldChannel() );
100 
101  // Locate appropriate analysis object
102  Analyses::const_iterator iter = data().find( fec_key.key() );
103  if ( iter != data().end() ) {
104 
105  // Check if analysis is valid
106  if ( !iter->second->isValid() ) { continue; }
107 
108  NoiseAnalysis* anal = dynamic_cast<NoiseAnalysis*>( iter->second );
109  if ( !anal ) {
111  << "[NoiseHistosUsingDb::" << __func__ << "]"
112  << " NULL pointer to analysis object!";
113  continue;
114  }
115 
116  // Iterate through APVs and strips
117  for ( uint16_t iapv = 0; iapv < sistrip::APVS_PER_FEDCH; iapv++ ) {
118  for ( uint16_t istr = 0; istr < anal->peds()[iapv].size(); istr++ ) {
119 
120  constexpr float high_threshold = 5.;
121  constexpr float low_threshold = 2.;
122  constexpr bool disable_strip = false;
123  Fed9U::Fed9UStripDescription data( static_cast<uint32_t>( anal->peds()[iapv][istr] ),
124  high_threshold,
125  low_threshold,
126  anal->noise()[iapv][istr],
127  disable_strip );
128  Fed9U::Fed9UAddress addr( ichan, iapv, istr );
129  (*ifed)->getFedStrips().setStrip( addr, data );
130 
131  }
132  }
133  updated++;
134 
135  } else {
137  << "[NoiseHistosUsingDb::" << __func__ << "]"
138  << " Unable to find pedestals/noise for FedKey/Id/Ch: "
139  << hex << setw(8) << setfill('0') << fed_key.key() << dec << "/"
140  << (*ifed)->getFedId() << "/"
141  << ichan
142  << " and device with FEC/slot/ring/CCU/LLD "
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  }
150  }
151  }
152 
154  << "[NoiseHistosUsingDb::" << __func__ << "]"
155  << " Updated FED pedestals/noise for "
156  << updated << " channels";
157 
158 }
159 
160 // -----------------------------------------------------------------------------
163  Analysis analysis ) {
164 
165  NoiseAnalysis* anal = dynamic_cast<NoiseAnalysis*>( analysis->second );
166  if ( !anal ) { return; }
167 
168  SiStripFecKey fec_key( anal->fecKey() );
169  SiStripFedKey fed_key( anal->fedKey() );
170 
171  for ( uint16_t iapv = 0; iapv < 2; ++iapv ) {
172 
173  // Create description
174  PedestalsAnalysisDescription* tmp;
175  tmp = new PedestalsAnalysisDescription( anal->dead()[iapv],
176  anal->noisy()[iapv],
177  anal->pedsMean()[iapv],
178  anal->pedsSpread()[iapv],
179  anal->noiseMean()[iapv],
180  anal->noiseSpread()[iapv],
181  anal->rawMean()[iapv],
182  anal->rawSpread()[iapv],
183  anal->pedsMax()[iapv],
184  anal->pedsMin()[iapv],
185  anal->noiseMax()[iapv],
186  anal->noiseMin()[iapv],
187  anal->rawMax()[iapv],
188  anal->rawMin()[iapv],
189  fec_key.fecCrate(),
190  fec_key.fecSlot(),
191  fec_key.fecRing(),
192  fec_key.ccuAddr(),
193  fec_key.ccuChan(),
194  SiStripFecKey::i2cAddr( fec_key.lldChan(), !iapv ),
195  db()->dbParams().partitions().begin()->second.partitionName(),
196  db()->dbParams().partitions().begin()->second.runNumber(),
197  anal->isValid(),
198  "",
199  fed_key.fedId(),
200  fed_key.feUnit(),
201  fed_key.feChan(),
202  fed_key.fedApv() );
203 
204  // Add comments
205  typedef std::vector<std::string> Strings;
206  Strings errors = anal->getErrorCodes();
207  Strings::const_iterator istr = errors.begin();
208  Strings::const_iterator jstr = errors.end();
209  for ( ; istr != jstr; ++istr ) { tmp->addComments( *istr ); }
210 
211  // Store description
212  desc.push_back( tmp );
213 
214  }
215 
216 }
217 
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
FedChannelConnection fedConnection(uint16_t fed_id, uint16_t fed_ch) const
A container class for generic run and event-related info, information required by the commissioning a...
Definition: SiStripFedKey.h:56
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 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: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 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:16
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
#define constexpr
NoiseHistosUsingDb(const edm::ParameterSet &pset, DQMStore *, SiStripConfigDb *const )
const VFloat & pedsMin() const