CMS 3D CMS Logo

PedsOnlyHistosUsingDb.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>("PedsOnlyParameters"),
18  bei,
19  sistrip::PEDS_ONLY ),
21  sistrip::PEDS_ONLY ),
22  PedsOnlyHistograms( pset.getParameter<edm::ParameterSet>("PedsOnlyParameters"),
23  bei )
24 {
26  << "[PedsOnlyHistosUsingDb::" << __func__ << "]"
27  << " Constructing object...";
28 }
29 
30 // -----------------------------------------------------------------------------
34  << "[PedsOnlyHistosUsingDb::" << __func__ << "]"
35  << " Destructing object...";
36 }
37 
38 // -----------------------------------------------------------------------------
42  << "[PedsOnlyHistosUsingDb::" << __func__ << "]";
43 
44  if ( !db() ) {
46  << "[PedsOnlyHistosUsingDb::" << __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  << "[PedsOnlyHistosUsingDb::" << __func__ << "]"
58  << " Uploading pedestals/noise to DB...";
61  << "[PedsOnlyHistosUsingDb::" << __func__ << "]"
62  << " Completed database upload of " << feds.size()
63  << " FED descriptions!";
64  } else {
66  << "[PedsOnlyHistosUsingDb::" << __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  PedsOnlyAnalysis* anal = dynamic_cast<PedsOnlyAnalysis*>( iter->second );
109  if ( !anal ) {
111  << "[PedsOnlyHistosUsingDb::" << __func__ << "]"
112  << " NULL pointer to analysis object!";
113  continue;
114  }
115 
116  // Determine the pedestal shift to apply
117  uint32_t pedshift = 127;
118  for ( uint16_t iapv = 0; iapv < sistrip::APVS_PER_FEDCH; iapv++ ) {
119  uint32_t pedmin = (uint32_t) anal->pedsMin()[iapv];
120  pedshift = pedmin < pedshift ? pedmin : pedshift;
121  }
122 
123  // Iterate through APVs and strips
124  for ( uint16_t iapv = 0; iapv < sistrip::APVS_PER_FEDCH; iapv++ ) {
125  for ( uint16_t istr = 0; istr < anal->peds()[iapv].size(); istr++ ) {
126 
127  constexpr float high_threshold = 5.;
128  constexpr float low_threshold = 2.;
129  constexpr bool disable_strip = false;
130  Fed9U::Fed9UStripDescription data( static_cast<uint32_t>( anal->peds()[iapv][istr]-pedshift ),
131  high_threshold,
132  low_threshold,
133  anal->raw()[iapv][istr], //@@ raw noise!
134  disable_strip );
135  Fed9U::Fed9UAddress addr( ichan, iapv, istr );
136  (*ifed)->getFedStrips().setStrip( addr, data );
137 
138  }
139  }
140  updated++;
141 
142  } else {
144  << "[PedsOnlyHistosUsingDb::" << __func__ << "]"
145  << " Unable to find pedestals/noise for FedKey/Id/Ch: "
146  << hex << setw(8) << setfill('0') << fed_key.key() << dec << "/"
147  << (*ifed)->getFedId() << "/"
148  << ichan
149  << " and device with FEC/slot/ring/CCU/LLD "
150  << fec_key.fecCrate() << "/"
151  << fec_key.fecSlot() << "/"
152  << fec_key.fecRing() << "/"
153  << fec_key.ccuAddr() << "/"
154  << fec_key.ccuChan() << "/"
155  << fec_key.channel();
156  }
157  }
158  }
159 
161  << "[PedsOnlyHistosUsingDb::" << __func__ << "]"
162  << " Updated FED pedestals/noise for "
163  << updated << " channels";
164 
165 }
166 
167 // -----------------------------------------------------------------------------
170  Analysis analysis ) {
171 
172  PedsOnlyAnalysis* anal = dynamic_cast<PedsOnlyAnalysis*>( analysis->second );
173  if ( !anal ) { return; }
174 
175  SiStripFecKey fec_key( anal->fecKey() );
176  SiStripFedKey fed_key( anal->fedKey() );
177 
178  for ( uint16_t iapv = 0; iapv < 2; ++iapv ) {
179 
180  // Create description
181  PedestalsAnalysisDescription* tmp;
182  tmp = new PedestalsAnalysisDescription( std::vector<uint16_t>(0,0), //@@
183  std::vector<uint16_t>(0,0), //@@
184  anal->pedsMean()[iapv],
185  anal->pedsSpread()[iapv],
186  1.*sistrip::invalid_, //@@
187  1.*sistrip::invalid_, //@@
188  anal->rawMean()[iapv],
189  anal->rawSpread()[iapv],
190  anal->pedsMax()[iapv],
191  anal->pedsMin()[iapv],
192  1.*sistrip::invalid_, //@@
193  1.*sistrip::invalid_, //@@
194  anal->rawMax()[iapv],
195  anal->rawMin()[iapv],
196  fec_key.fecCrate(),
197  fec_key.fecSlot(),
198  fec_key.fecRing(),
199  fec_key.ccuAddr(),
200  fec_key.ccuChan(),
201  SiStripFecKey::i2cAddr( fec_key.lldChan(), !iapv ),
202  db()->dbParams().partitions().begin()->second.partitionName(),
203  db()->dbParams().partitions().begin()->second.runNumber(),
204  anal->isValid(),
205  "",
206  fed_key.fedId(),
207  fed_key.feUnit(),
208  fed_key.feChan(),
209  fed_key.fedApv() );
210 
211  // Add comments
212  typedef std::vector<std::string> Strings;
213  Strings errors = anal->getErrorCodes();
214  Strings::const_iterator istr = errors.begin();
215  Strings::const_iterator jstr = errors.end();
216  for ( ; istr != jstr; ++istr ) { tmp->addComments( *istr ); }
217 
218  // Store description
219  desc.push_back( tmp );
220 
221  }
222 
223 }
224 
const uint16_t & fecSlot() const
const uint16_t & fecCrate() const
Histogram-based analysis for pedestal run.
const uint32_t & fedKey() 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
bool isValid() const
FedDescriptionsRange getFedDescriptions(std::string partition="")
std::vector< std::string > Strings
Definition: MsgTools.h:18
FedDescriptions::range FedDescriptionsRange
static const char mlDqmClient_[]
PedsOnlyHistosUsingDb(const edm::ParameterSet &pset, DQMStore *, SiStripConfigDb *const )
uint16_t lldChannel() const
const uint16_t & i2cAddr() const
const uint16_t & fedId() const
#define constexpr
sistrip classes
const uint32_t & key() const
Definition: SiStripKey.h:125
const VFloat & rawSpread() const
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 VVFloat & raw() const
const uint16_t & fecRing() const
void update(SiStripConfigDb::FedDescriptionsRange)
virtual void uploadConfigurations()
Class containning control, module, detector and connection information, at the level of a FED channel...
const VFloat & rawMin() const
const VFloat & pedsMin() const
An interface class to the DeviceFactory.
const uint16_t & ccuChan() const
const VFloat & pedsMax() const
const uint32_t & fecKey() const
const uint16_t & ccuAddr() const
#define LogTrace(id)
const VFloat & rawMax() 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
HLT enums.
static const uint16_t FEDCH_PER_FED
std::vector< AnalysisDescription * > AnalysisDescriptionsV
const uint16_t & feChan() const
const VFloat & pedsSpread() const
const VFloat & pedsMean() const
Definition: errors.py:1
SiStripConfigDb *const db() const
SiStripFedCabling *const cabling() const
const VString & getErrorCodes() const
static const uint16_t APVS_PER_FEDCH
void create(SiStripConfigDb::AnalysisDescriptionsV &, Analysis)
const VFloat & rawMean() const