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 HistoheaderHigh () const
 
const HistoheaderLow () 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 headerHigh_
 
Histo headerLow_
 
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  headerLow_(nullptr,""),
20  headerHigh_(nullptr,""),
21  hPeds_(nullptr,""),
22  hNoise_(nullptr,""),
23  deadStripMax_(pset.getParameter<double>("DeadStripMax")),
24  noisyStripMin_(pset.getParameter<double>("NoisyStripMin"))
25 {;}
T getParameter(std::string const &) const
DaqScopeModeAlgorithm::~DaqScopeModeAlgorithm ( )
inlineoverride

Definition at line 22 of file DaqScopeModeAlgorithm.h.

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

22 {;}
DaqScopeModeAlgorithm::DaqScopeModeAlgorithm ( )
inlineprivate

Definition at line 32 of file DaqScopeModeAlgorithm.h.

References analyse(), and extract().

32 {;}

Member Function Documentation

void DaqScopeModeAlgorithm::analyse ( )
overrideprivatevirtual

Performs histogram anaylsis.

pedestal

scope-mode profile

Implements CommissioningAlgorithm.

Definition at line 91 of file DaqScopeModeAlgorithm.cc.

References DaqScopeModeAnalysis::addErrorCode(), CommissioningAlgorithm::anal(), DaqScopeModeAnalysis::base_, DaqScopeModeAnalysis::dead_, deadStripMax_, headerHigh_, headerLow_, 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().

91  {
92 
93  if ( !anal() ) {
95  << "[DaqScopeModeAlgorithm::" << __func__ << "]"
96  << " NULL pointer to base Analysis object!";
97  return;
98  }
99 
101  DaqScopeModeAnalysis* anal = dynamic_cast<DaqScopeModeAnalysis*>( tmp );
102  if ( !anal ) {
104  << "[DaqScopeModeAlgorithm::" << __func__ << "]"
105  << " NULL pointer to derived Analysis object!";
106  return;
107  }
108 
109  // Analysis level wants all the informations --> it will work only on Spy-events
110  if ( !hPeds_.first ) {
112  return;
113  }
114 
115  if ( !hNoise_.first ) {
117  return;
118  }
119 
120  if ( !histo_.first ) {
122  return;
123  }
124  if ( !headerLow_.first ) {
126  return;
127  }
128  if ( !headerHigh_.first ) {
130  return;
131  }
132 
134  TProfile* peds_histo = dynamic_cast<TProfile*>(hPeds_.first);
135  TProfile* noise_histo = dynamic_cast<TProfile*>(hNoise_.first);
137  TProfile* scope_histo = dynamic_cast<TProfile*>(histo_.first);
138  TH1F* headerLow_histo = dynamic_cast<TH1F*>(headerLow_.first);
139  TH1F* headerHigh_histo = dynamic_cast<TH1F*>(headerHigh_.first);
140 
141  if ( !peds_histo ) {
143  return;
144  }
145 
146  if ( !noise_histo ) {
148  return;
149  }
150 
151  if ( !scope_histo ) {
153  return;
154  }
155 
156  if ( !headerLow_histo ) {
158  return;
159  }
160 
161  if ( !headerHigh_histo ) {
163  return;
164  }
165 
166  if ( peds_histo->GetNbinsX() != 256 ) {
168  return;
169  }
170 
171  if ( noise_histo->GetNbinsX() != 256 ) {
173  return;
174  }
175 
176  if ( scope_histo->GetNbinsX() != 298 ) {
178  return;
179  }
180 
181  // Calculate pedestals and noise
182  // Iterate through APVs
183  for ( uint16_t iapv = 0; iapv < 2; iapv++ ) {
184 
185  // Used to calc mean and rms for peds and noise
186  float p_sum = 0., p_sum2 = 0., p_max = -1.*sistrip::invalid_, p_min = sistrip::invalid_;
187  float n_sum = 0., n_sum2 = 0., n_max = -1.*sistrip::invalid_, n_min = sistrip::invalid_;
188  float r_sum = 0., r_sum2 = 0., r_max = -1.*sistrip::invalid_, r_min = sistrip::invalid_;
189 
190  // Iterate through strips of APV
191  for ( uint16_t istr = 0; istr < 128; istr++ ) {
192  uint16_t strip = iapv*128 + istr;
193 
194  // Pedestals and raw noise
195  if ( peds_histo ) {
196  if ( peds_histo->GetBinEntries(strip+1) ) {
197  anal->peds_[iapv][istr] = peds_histo->GetBinContent(strip+1);
198  p_sum += anal->peds_[iapv][istr];
199  p_sum2 += (anal->peds_[iapv][istr] * anal->peds_[iapv][istr]);
200  if ( anal->peds_[iapv][istr] > p_max ) { p_max = anal->peds_[iapv][istr]; }
201  if ( anal->peds_[iapv][istr] < p_min ) { p_min = anal->peds_[iapv][istr]; }
202 
203  anal->raw_[iapv][istr] = peds_histo->GetBinError(strip+1);
204  r_sum += anal->raw_[iapv][istr];
205  r_sum2 += (anal->raw_[iapv][istr] * anal->raw_[iapv][istr]);
206  if ( anal->raw_[iapv][istr] > r_max ) { r_max = anal->raw_[iapv][istr]; }
207  if ( anal->raw_[iapv][istr] < r_min ) { r_min = anal->raw_[iapv][istr]; }
208  }
209  }
210 
211  // Noise
212  if ( noise_histo ) {
213  if ( noise_histo->GetBinEntries(strip+1) ) {
214  anal->noise_[iapv][istr] = noise_histo->GetBinContent(strip+1);
215  n_sum += anal->noise_[iapv][istr];
216  n_sum2 += (anal->noise_[iapv][istr] * anal->noise_[iapv][istr]);
217  if ( anal->noise_[iapv][istr] > n_max ) { n_max = anal->noise_[iapv][istr]; }
218  if ( anal->noise_[iapv][istr] < n_min ) { n_min = anal->noise_[iapv][istr]; }
219  }
220  }
221  } // strip loop
222 
223  // Calc mean and rms for peds
224  if (!anal->peds_[iapv].empty()) {
225  p_sum /= static_cast<float>( anal->peds_[iapv].size() );
226  p_sum2 /= static_cast<float>( anal->peds_[iapv].size() );
227  anal->pedsMean_[iapv] = p_sum;
228  anal->pedsSpread_[iapv] = sqrt( fabs(p_sum2 - p_sum*p_sum) );
229  }
230 
231  // Calc mean and rms for noise
232  if ( !anal->noise_[iapv].empty() ) {
233  n_sum /= static_cast<float>( anal->noise_[iapv].size() );
234  n_sum2 /= static_cast<float>( anal->noise_[iapv].size() );
235  anal->noiseMean_[iapv] = n_sum;
236  anal->noiseSpread_[iapv] = sqrt( fabs(n_sum2 - n_sum*n_sum) );
237  }
238 
239  // Calc mean and rms for raw noise
240  if ( !anal->raw_[iapv].empty() ) {
241  r_sum /= static_cast<float>( anal->raw_[iapv].size() );
242  r_sum2 /= static_cast<float>( anal->raw_[iapv].size() );
243  anal->rawMean_[iapv] = r_sum;
244  anal->rawSpread_[iapv] = sqrt( fabs(r_sum2 - r_sum*r_sum) );
245  }
246 
247  // Set max and min values for peds, noise and raw noise
248  if ( p_max > -1.*sistrip::maximum_ ) { anal->pedsMax_[iapv] = p_max; }
249  if ( p_min < 1.*sistrip::maximum_ ) { anal->pedsMin_[iapv] = p_min; }
250  if ( n_max > -1.*sistrip::maximum_ ) { anal->noiseMax_[iapv] = n_max; }
251  if ( n_min < 1.*sistrip::maximum_ ) { anal->noiseMin_[iapv] = n_min; }
252  if ( r_max > -1.*sistrip::maximum_ ) { anal->rawMax_[iapv] = r_max; }
253  if ( r_min < 1.*sistrip::maximum_ ) { anal->rawMin_[iapv] = r_min; }
254 
255  // Set dead and noisy strips
256  for ( uint16_t istr = 0; istr < 128; istr++ ) {
257  if ( anal->noiseMin_[iapv] > sistrip::maximum_ ||
258  anal->noiseMax_[iapv] > sistrip::maximum_ ) { continue; }
259  if ( anal->noise_[iapv][istr] < ( anal->noiseMean_[iapv] - deadStripMax_ * anal->noiseSpread_[iapv] ) ) {
260  anal->dead_[iapv].push_back(istr);
261  }
262  else if ( anal->noise_[iapv][istr] > ( anal->noiseMean_[iapv] + noisyStripMin_ * anal->noiseSpread_[iapv] ) ) {
263  anal->noisy_[iapv].push_back(istr);
264  }
265  }
266  } // apv loop
267 
269  //anal->peak_ = (scope_histo->GetBinContent(287)+scope_histo->GetBinContent(288))/2.;
270  //anal->base_ = (scope_histo->GetBinContent(1)+scope_histo->GetBinContent(2)+scope_histo->GetBinContent(3)+scope_histo->GetBinContent(4)+scope_histo->GetBinContent(5))/5.;
271  anal->peak_ = headerHigh_histo->GetMean();
272  anal->base_ = headerLow_histo->GetMean();
273  anal->height_ = anal->peak_-anal->base_;
276  return;
277  }
278 }
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 29 of file DaqScopeModeAlgorithm.cc.

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

Referenced by DaqScopeModeAlgorithm().

29  {
30 
31  if ( !anal() ) {
33  << "[DaqScopeModeAlgorithm::" << __func__ << "]"
34  << " NULL pointer to base Analysis object!";
35  return;
36  }
37 
38 
39  // Extract FED key from histo title
40  if ( !histos.empty() ) { anal()->fedKey( extractFedKey( histos.front() ) ); }
41 
42  // Extract histograms
43  std::vector<TH1*>::const_iterator ihis = histos.begin();
44  for ( ; ihis != histos.end(); ihis++ ) {
45 
46  // Check for NULL pointer
47  if ( !(*ihis) ) { continue; }
48 
49  // Check name
50  SiStripHistoTitle title( (*ihis)->GetName() );
51  if ( title.runType() != sistrip::DAQ_SCOPE_MODE ) {
53  continue;
54  }
55 
56  // Extract timing histo
57  // Extract peds and noise histos (check for legacy names first!)
58  if ( title.extraInfo().find(sistrip::extrainfo::pedsAndRawNoise_) != std::string::npos ) {
59  hPeds_.first = *ihis;
60  hPeds_.second = (*ihis)->GetName();
61  }
62  else if ( title.extraInfo().find(sistrip::extrainfo::pedsAndCmSubNoise_) != std::string::npos ) {
63  hNoise_.first = *ihis;
64  hNoise_.second = (*ihis)->GetName();
65  } else if ( title.extraInfo().find(sistrip::extrainfo::pedestals_) != std::string::npos ) {
66  hPeds_.first = *ihis;
67  hPeds_.second = (*ihis)->GetName();
68  } else if ( title.extraInfo().find(sistrip::extrainfo::noise_) != std::string::npos ) {
69  hNoise_.first = *ihis;
70  hNoise_.second = (*ihis)->GetName();
71  } else if ( title.extraInfo().find(sistrip::extrainfo::commonMode_) != std::string::npos ) {
72  //@@ something here for CM plots?
73  }
74  else if ( title.extraInfo().find(sistrip::extrainfo::scopeModeFrame_) != std::string::npos ) {
75  histo_.first = *ihis;
76  histo_.second = (*ihis)->GetName();
77  }
78  else if ( title.extraInfo().find(sistrip::extrainfo::scopeModeHeaderLow_) != std::string::npos ) {
79  headerLow_.first = *ihis;
80  headerLow_.second = (*ihis)->GetName();
81  }
82  else if ( title.extraInfo().find(sistrip::extrainfo::scopeModeHeaderHigh_) != std::string::npos ) {
83  headerHigh_.first = *ihis;
84  headerHigh_.second = (*ihis)->GetName();
85  }
86  }
87 }
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 mlCommissioning_[]
static const char scopeModeHeaderLow_[]
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 scopeModeHeaderHigh_[]
static const char scopeModeFrame_[]
CommissioningAnalysis *const anal() const
const DaqScopeModeAlgorithm::Histo & DaqScopeModeAlgorithm::headerHigh ( ) const
inline

Definition at line 59 of file DaqScopeModeAlgorithm.h.

References headerHigh_.

Referenced by ~DaqScopeModeAlgorithm().

const DaqScopeModeAlgorithm::Histo & DaqScopeModeAlgorithm::headerLow ( ) const
inline

Definition at line 58 of file DaqScopeModeAlgorithm.h.

References headerLow_.

Referenced by ~DaqScopeModeAlgorithm().

58 { return headerLow_; }
const DaqScopeModeAlgorithm::Histo & DaqScopeModeAlgorithm::histo ( ) const
inline

Definition at line 57 of file DaqScopeModeAlgorithm.h.

References histo_.

Referenced by ~DaqScopeModeAlgorithm().

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

Definition at line 61 of file DaqScopeModeAlgorithm.h.

References hNoise_.

Referenced by ~DaqScopeModeAlgorithm().

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

Definition at line 60 of file DaqScopeModeAlgorithm.h.

References hPeds_.

Referenced by ~DaqScopeModeAlgorithm().

60 { return hPeds_; }

Member Data Documentation

float DaqScopeModeAlgorithm::deadStripMax_
private

Analysis parameters

Definition at line 52 of file DaqScopeModeAlgorithm.h.

Referenced by analyse().

Histo DaqScopeModeAlgorithm::headerHigh_
private

Histogram of header high.

Definition at line 45 of file DaqScopeModeAlgorithm.h.

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

Histo DaqScopeModeAlgorithm::headerLow_
private

Histogram of header low.

Definition at line 43 of file DaqScopeModeAlgorithm.h.

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

Histo DaqScopeModeAlgorithm::histo_
private

Histogram of scope mode data.

Definition at line 41 of file DaqScopeModeAlgorithm.h.

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

Histo DaqScopeModeAlgorithm::hNoise_
private

Residuals and noise

Definition at line 49 of file DaqScopeModeAlgorithm.h.

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

Histo DaqScopeModeAlgorithm::hPeds_
private

Pedestals and raw noise

Definition at line 47 of file DaqScopeModeAlgorithm.h.

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

float DaqScopeModeAlgorithm::noisyStripMin_
private

Definition at line 53 of file DaqScopeModeAlgorithm.h.

Referenced by analyse().