CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
DaqScopeModeAlgorithm Class Reference

Algorithm for scope mode data. More...

#include <DaqScopeModeAlgorithm.h>

Inheritance diagram for DaqScopeModeAlgorithm:
CommissioningAlgorithm

Public Member Functions

 DaqScopeModeAlgorithm (const edm::ParameterSet &pset, DaqScopeModeAnalysis *const )
 
const Histohisto () const
 
const HistohNoise () const
 
const HistohPeds () const
 
 ~DaqScopeModeAlgorithm () override
 
- Public Member Functions inherited from CommissioningAlgorithm
void analysis (const std::vector< TH1 * > &)
 
 CommissioningAlgorithm (CommissioningAnalysis *const )
 
 CommissioningAlgorithm ()
 
virtual ~CommissioningAlgorithm ()
 

Private Member Functions

void analyse () override
 
 DaqScopeModeAlgorithm ()
 
void extract (const std::vector< TH1 * > &) override
 

Private Attributes

float deadStripMax_
 
Histo histo_
 
Histo hNoise_
 
Histo hPeds_
 
float noisyStripMin_
 

Additional Inherited Members

- Public Types inherited from CommissioningAlgorithm
typedef std::pair< TH1 *, std::string > Histo
 
- Protected Member Functions inherited from CommissioningAlgorithm
CommissioningAnalysis *const anal () const
 
uint32_t extractFedKey (const TH1 *const )
 

Detailed Description

Algorithm for scope mode data.

Author
R.Bainbridge

Definition at line 16 of file DaqScopeModeAlgorithm.h.

Constructor & Destructor Documentation

DaqScopeModeAlgorithm::DaqScopeModeAlgorithm ( const edm::ParameterSet pset,
DaqScopeModeAnalysis * const  anal 
)

Definition at line 16 of file DaqScopeModeAlgorithm.cc.

17  : CommissioningAlgorithm(anal),
18  histo_(nullptr,""),
19  hPeds_(nullptr,""),
20  hNoise_(nullptr,""),
21  deadStripMax_(pset.getParameter<double>("DeadStripMax")),
22  noisyStripMin_(pset.getParameter<double>("NoisyStripMin"))
23 {;}
T getParameter(std::string const &) const
DaqScopeModeAlgorithm::~DaqScopeModeAlgorithm ( )
inlineoverride

Definition at line 22 of file DaqScopeModeAlgorithm.h.

References histo(), hNoise(), and hPeds().

22 {;}
DaqScopeModeAlgorithm::DaqScopeModeAlgorithm ( )
inlineprivate

Definition at line 30 of file DaqScopeModeAlgorithm.h.

References analyse(), and extract().

30 {;}

Member Function Documentation

void DaqScopeModeAlgorithm::analyse ( )
overrideprivatevirtual

Performs histogram anaylsis.

pedestal

scope-mode profile

Implements CommissioningAlgorithm.

Definition at line 85 of file DaqScopeModeAlgorithm.cc.

References DaqScopeModeAnalysis::addErrorCode(), CommissioningAlgorithm::anal(), DaqScopeModeAnalysis::base_, DaqScopeModeAnalysis::dead_, deadStripMax_, DaqScopeModeAnalysis::height_, histo_, hNoise_, hPeds_, sistrip::invalid_, sistrip::maximum_, sistrip::mlCommissioning_, DaqScopeModeAnalysis::noise_, DaqScopeModeAnalysis::noiseMax_, DaqScopeModeAnalysis::noiseMean_, DaqScopeModeAnalysis::noiseMin_, DaqScopeModeAnalysis::noiseSpread_, DaqScopeModeAnalysis::noisy_, noisyStripMin_, sistrip::nullPtr_, sistrip::numberOfBins_, DaqScopeModeAnalysis::peak_, DaqScopeModeAnalysis::peds_, DaqScopeModeAnalysis::pedsMax_, DaqScopeModeAnalysis::pedsMean_, DaqScopeModeAnalysis::pedsMin_, DaqScopeModeAnalysis::pedsSpread_, DaqScopeModeAnalysis::raw_, DaqScopeModeAnalysis::rawMax_, DaqScopeModeAnalysis::rawMean_, DaqScopeModeAnalysis::rawMin_, DaqScopeModeAnalysis::rawSpread_, sistrip::smallTickMarkHeight_, mathSSE::sqrt(), digitizers_cfi::strip, DaqScopeModeAnalysis::tickMarkHeightThreshold_, and tmp.

Referenced by DaqScopeModeAlgorithm().

85  {
86 
87  if ( !anal() ) {
89  << "[DaqScopeModeAlgorithm::" << __func__ << "]"
90  << " NULL pointer to base Analysis object!";
91  return;
92  }
93 
96  if ( !anal ) {
98  << "[DaqScopeModeAlgorithm::" << __func__ << "]"
99  << " NULL pointer to derived Analysis object!";
100  return;
101  }
102 
103  // Analysis level wants all the informations --> it will work only on Spy-events
104  if ( !hPeds_.first ) {
106  return;
107  }
108 
109  if ( !hNoise_.first ) {
111  return;
112  }
113 
114  if ( !histo_.first ) {
116  return;
117  }
118 
120  TProfile* peds_histo = dynamic_cast<TProfile*>(hPeds_.first);
121  TProfile* noise_histo = dynamic_cast<TProfile*>(hNoise_.first);
123  TProfile* scope_histo = dynamic_cast<TProfile*>(histo_.first);
124 
125  if ( !peds_histo ) {
127  return;
128  }
129 
130  if ( !noise_histo ) {
132  return;
133  }
134 
135  if ( !scope_histo ) {
137  return;
138  }
139 
140  if ( peds_histo->GetNbinsX() != 256 ) {
142  return;
143  }
144 
145  if ( noise_histo->GetNbinsX() != 256 ) {
147  return;
148  }
149 
150  if ( scope_histo->GetNbinsX() != 298 ) {
152  return;
153  }
154 
155  // Calculate pedestals and noise
156  // Iterate through APVs
157  for ( uint16_t iapv = 0; iapv < 2; iapv++ ) {
158 
159  // Used to calc mean and rms for peds and noise
160  float p_sum = 0., p_sum2 = 0., p_max = -1.*sistrip::invalid_, p_min = sistrip::invalid_;
161  float n_sum = 0., n_sum2 = 0., n_max = -1.*sistrip::invalid_, n_min = sistrip::invalid_;
162  float r_sum = 0., r_sum2 = 0., r_max = -1.*sistrip::invalid_, r_min = sistrip::invalid_;
163 
164  // Iterate through strips of APV
165  for ( uint16_t istr = 0; istr < 128; istr++ ) {
166  uint16_t strip = iapv*128 + istr;
167 
168  // Pedestals and raw noise
169  if ( peds_histo ) {
170  if ( peds_histo->GetBinEntries(strip+1) ) {
171  anal->peds_[iapv][istr] = peds_histo->GetBinContent(strip+1);
172  p_sum += anal->peds_[iapv][istr];
173  p_sum2 += (anal->peds_[iapv][istr] * anal->peds_[iapv][istr]);
174  if ( anal->peds_[iapv][istr] > p_max ) { p_max = anal->peds_[iapv][istr]; }
175  if ( anal->peds_[iapv][istr] < p_min ) { p_min = anal->peds_[iapv][istr]; }
176 
177  anal->raw_[iapv][istr] = peds_histo->GetBinError(strip+1);
178  r_sum += anal->raw_[iapv][istr];
179  r_sum2 += (anal->raw_[iapv][istr] * anal->raw_[iapv][istr]);
180  if ( anal->raw_[iapv][istr] > r_max ) { r_max = anal->raw_[iapv][istr]; }
181  if ( anal->raw_[iapv][istr] < r_min ) { r_min = anal->raw_[iapv][istr]; }
182  }
183  }
184 
185  // Noise
186  if ( noise_histo ) {
187  if ( noise_histo->GetBinEntries(strip+1) ) {
188  anal->noise_[iapv][istr] = noise_histo->GetBinContent(strip+1);
189  n_sum += anal->noise_[iapv][istr];
190  n_sum2 += (anal->noise_[iapv][istr] * anal->noise_[iapv][istr]);
191  if ( anal->noise_[iapv][istr] > n_max ) { n_max = anal->noise_[iapv][istr]; }
192  if ( anal->noise_[iapv][istr] < n_min ) { n_min = anal->noise_[iapv][istr]; }
193  }
194  }
195  } // strip loop
196 
197  // Calc mean and rms for peds
198  if (!anal->peds_[iapv].empty()) {
199  p_sum /= static_cast<float>( anal->peds_[iapv].size() );
200  p_sum2 /= static_cast<float>( anal->peds_[iapv].size() );
201  anal->pedsMean_[iapv] = p_sum;
202  anal->pedsSpread_[iapv] = sqrt( fabs(p_sum2 - p_sum*p_sum) );
203  }
204 
205  // Calc mean and rms for noise
206  if ( !anal->noise_[iapv].empty() ) {
207  n_sum /= static_cast<float>( anal->noise_[iapv].size() );
208  n_sum2 /= static_cast<float>( anal->noise_[iapv].size() );
209  anal->noiseMean_[iapv] = n_sum;
210  anal->noiseSpread_[iapv] = sqrt( fabs(n_sum2 - n_sum*n_sum) );
211  }
212 
213  // Calc mean and rms for raw noise
214  if ( !anal->raw_[iapv].empty() ) {
215  r_sum /= static_cast<float>( anal->raw_[iapv].size() );
216  r_sum2 /= static_cast<float>( anal->raw_[iapv].size() );
217  anal->rawMean_[iapv] = r_sum;
218  anal->rawSpread_[iapv] = sqrt( fabs(r_sum2 - r_sum*r_sum) );
219  }
220 
221  // Set max and min values for peds, noise and raw noise
222  if ( p_max > -1.*sistrip::maximum_ ) { anal->pedsMax_[iapv] = p_max; }
223  if ( p_min < 1.*sistrip::maximum_ ) { anal->pedsMin_[iapv] = p_min; }
224  if ( n_max > -1.*sistrip::maximum_ ) { anal->noiseMax_[iapv] = n_max; }
225  if ( n_min < 1.*sistrip::maximum_ ) { anal->noiseMin_[iapv] = n_min; }
226  if ( r_max > -1.*sistrip::maximum_ ) { anal->rawMax_[iapv] = r_max; }
227  if ( r_min < 1.*sistrip::maximum_ ) { anal->rawMin_[iapv] = r_min; }
228 
229  // Set dead and noisy strips
230  for ( uint16_t istr = 0; istr < 128; istr++ ) {
231  if ( anal->noiseMin_[iapv] > sistrip::maximum_ ||
232  anal->noiseMax_[iapv] > sistrip::maximum_ ) { continue; }
233  if ( anal->noise_[iapv][istr] < ( anal->noiseMean_[iapv] - deadStripMax_ * anal->noiseSpread_[iapv] ) ) {
234  anal->dead_[iapv].push_back(istr);
235  }
236  else if ( anal->noise_[iapv][istr] > ( anal->noiseMean_[iapv] + noisyStripMin_ * anal->noiseSpread_[iapv] ) ) {
237  anal->noisy_[iapv].push_back(istr);
238  }
239  }
240  } // apv loop
241 
243  anal->peak_ = (scope_histo->GetBinContent(287)+scope_histo->GetBinContent(288))/2.; // trailing tickmark for each APV
244  anal->base_ = (scope_histo->GetBinContent(1)+scope_histo->GetBinContent(2)+scope_histo->GetBinContent(3)+scope_histo->GetBinContent(4)+scope_histo->GetBinContent(5))/5.;
245  anal->height_ = anal->peak_-anal->base_;
248  return;
249  }
250 }
static const char numberOfBins_[]
static const float tickMarkHeightThreshold_
static const char mlCommissioning_[]
T sqrt(T t)
Definition: SSEVec.h:18
static const uint16_t maximum_
Definition: Constants.h:20
static const char smallTickMarkHeight_[]
static const uint16_t invalid_
Definition: Constants.h:16
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100
Abstract base for derived classes that provide analysis of commissioning histograms.
void addErrorCode(const std::string &error) override
CommissioningAnalysis *const anal() const
static const char nullPtr_[]
Analysis for scope mode data.
void DaqScopeModeAlgorithm::extract ( const std::vector< TH1 * > &  )
overrideprivatevirtual

Extracts and organises histograms.

Implements CommissioningAlgorithm.

Definition at line 27 of file DaqScopeModeAlgorithm.cc.

References CommissioningAnalysis::addErrorCode(), CommissioningAlgorithm::anal(), sistrip::extrainfo::commonMode_, sistrip::DAQ_SCOPE_MODE, CommissioningAlgorithm::extractFedKey(), CommissioningAnalysis::fedKey(), histo_, hNoise_, hPeds_, sistrip::mlCommissioning_, sistrip::extrainfo::noise_, sistrip::numberOfHistos_, sistrip::extrainfo::pedestals_, sistrip::extrainfo::pedsAndCmSubNoise_, sistrip::extrainfo::pedsAndRawNoise_, sistrip::extrainfo::scopeModeFrame_, fftjetcommon_cfi::title, and sistrip::unexpectedTask_.

Referenced by DaqScopeModeAlgorithm().

27  {
28 
29  if ( !anal() ) {
31  << "[DaqScopeModeAlgorithm::" << __func__ << "]"
32  << " NULL pointer to base Analysis object!";
33  return;
34  }
35 
36  // Check
37  if ( histos.size() != 3 ) {
39  }
40 
41  // Extract FED key from histo title
42  if ( !histos.empty() ) { anal()->fedKey( extractFedKey( histos.front() ) ); }
43 
44  // Extract histograms
45  std::vector<TH1*>::const_iterator ihis = histos.begin();
46  for ( ; ihis != histos.end(); ihis++ ) {
47 
48  // Check for NULL pointer
49  if ( !(*ihis) ) { continue; }
50 
51  // Check name
52  SiStripHistoTitle title( (*ihis)->GetName() );
53  if ( title.runType() != sistrip::DAQ_SCOPE_MODE ) {
55  continue;
56  }
57 
58  // Extract timing histo
59  // Extract peds and noise histos (check for legacy names first!)
60  if ( title.extraInfo().find(sistrip::extrainfo::pedsAndRawNoise_) != std::string::npos ) {
61  hPeds_.first = *ihis;
62  hPeds_.second = (*ihis)->GetName();
63  }
64  else if ( title.extraInfo().find(sistrip::extrainfo::pedsAndCmSubNoise_) != std::string::npos ) {
65  hNoise_.first = *ihis;
66  hNoise_.second = (*ihis)->GetName();
67  } else if ( title.extraInfo().find(sistrip::extrainfo::pedestals_) != std::string::npos ) {
68  hPeds_.first = *ihis;
69  hPeds_.second = (*ihis)->GetName();
70  } else if ( title.extraInfo().find(sistrip::extrainfo::noise_) != std::string::npos ) {
71  hNoise_.first = *ihis;
72  hNoise_.second = (*ihis)->GetName();
73  } else if ( title.extraInfo().find(sistrip::extrainfo::commonMode_) != std::string::npos ) {
74  //@@ something here for CM plots?
75  }
76  else if ( title.extraInfo().find(sistrip::extrainfo::scopeModeFrame_) != std::string::npos ) {
77  histo_.first = *ihis;
78  histo_.second = (*ihis)->GetName();
79  }
80  }
81 }
static const char noise_[]
static const char unexpectedTask_[]
const uint32_t & fedKey() const
static const char pedsAndRawNoise_[]
Utility class that holds histogram title.
static const char numberOfHistos_[]
static const char mlCommissioning_[]
uint32_t extractFedKey(const TH1 *const )
virtual void addErrorCode(const std::string &error)
static const char commonMode_[]
static const char pedestals_[]
static const char pedsAndCmSubNoise_[]
static const char scopeModeFrame_[]
CommissioningAnalysis *const anal() const
const DaqScopeModeAlgorithm::Histo & DaqScopeModeAlgorithm::histo ( ) const
inline

Definition at line 51 of file DaqScopeModeAlgorithm.h.

References histo_.

Referenced by ~DaqScopeModeAlgorithm().

51 { return histo_; }
const DaqScopeModeAlgorithm::Histo & DaqScopeModeAlgorithm::hNoise ( ) const
inline

Definition at line 53 of file DaqScopeModeAlgorithm.h.

References hNoise_.

Referenced by ~DaqScopeModeAlgorithm().

53 { return hNoise_; }
const DaqScopeModeAlgorithm::Histo & DaqScopeModeAlgorithm::hPeds ( ) const
inline

Definition at line 52 of file DaqScopeModeAlgorithm.h.

References hPeds_.

Referenced by ~DaqScopeModeAlgorithm().

52 { return hPeds_; }

Member Data Documentation

float DaqScopeModeAlgorithm::deadStripMax_
private

Analysis parameters

Definition at line 46 of file DaqScopeModeAlgorithm.h.

Referenced by analyse().

Histo DaqScopeModeAlgorithm::histo_
private

Histogram of scope mode data.

Definition at line 39 of file DaqScopeModeAlgorithm.h.

Referenced by analyse(), extract(), and histo().

Histo DaqScopeModeAlgorithm::hNoise_
private

Residuals and noise

Definition at line 43 of file DaqScopeModeAlgorithm.h.

Referenced by analyse(), extract(), and hNoise().

Histo DaqScopeModeAlgorithm::hPeds_
private

Pedestals and raw noise

Definition at line 41 of file DaqScopeModeAlgorithm.h.

Referenced by analyse(), extract(), and hPeds().

float DaqScopeModeAlgorithm::noisyStripMin_
private

Definition at line 47 of file DaqScopeModeAlgorithm.h.

Referenced by analyse().