CMS 3D CMS Logo

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

Algorithm for latency run. More...

#include <SamplingAlgorithm.h>

Inheritance diagram for SamplingAlgorithm:
CommissioningAlgorithm

Public Member Functions

const Histohisto () const
 
 SamplingAlgorithm (const edm::ParameterSet &pset, SamplingAnalysis *const, uint32_t latencyCode=0)
 
 ~SamplingAlgorithm () override
 
- Public Member Functions inherited from CommissioningAlgorithm
void analysis (const std::vector< TH1 * > &)
 
 CommissioningAlgorithm ()
 
 CommissioningAlgorithm (CommissioningAnalysis *const)
 
virtual ~CommissioningAlgorithm ()
 

Private Member Functions

void analyse () override
 
void correctBinning (TProfile *prof) const
 
void correctProfile (TProfile *profile, float SoNcut=3.) const
 
void extract (const std::vector< TH1 * > &) override
 
void pruneProfile (TProfile *profile) const
 
 SamplingAlgorithm ()
 

Private Attributes

TF1 * deconv_fitter_
 
Histo histo_
 
uint32_t latencyCode_
 
TF1 * peak_fitterA_
 
TF1 * peak_fitterB_
 
SamplingAnalysissamp_
 

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 latency run.

Author
C. Delaere

Definition at line 18 of file SamplingAlgorithm.h.

Constructor & Destructor Documentation

◆ SamplingAlgorithm() [1/2]

SamplingAlgorithm::SamplingAlgorithm ( const edm::ParameterSet pset,
SamplingAnalysis * const  anal,
uint32_t  latencyCode = 0 
)

Definition at line 18 of file SamplingAlgorithm.cc.

20  histo_(nullptr, ""),
21  deconv_fitter_(nullptr),
22  peak_fitterA_(nullptr),
23  peak_fitterB_(nullptr),
24  latencyCode_(latencyCode),
25  samp_(nullptr) {
26  peak_fitterA_ = new TF1("peak_fitterA", fpeak_convoluted, -4800, 0, 5);
27  peak_fitterA_->SetNpx(2000);
28  peak_fitterA_->FixParameter(0, 0);
29  peak_fitterA_->SetParLimits(1, 0, 4800);
30  peak_fitterA_->SetParLimits(2, 0, 20);
31  peak_fitterA_->FixParameter(3, 50);
32  peak_fitterA_->SetParLimits(4, 0, 75);
33  peak_fitterA_->SetParameters(0., 1250, 10, 50, 10);
34 
35  peak_fitterB_ = new TF1("peak_fitterB", fpeak_convoluted, -100, 100, 5);
36  peak_fitterB_->SetNpx(200);
37  peak_fitterB_->FixParameter(0, 0);
38  peak_fitterB_->SetParLimits(1, -100, 100);
39  peak_fitterB_->SetParLimits(2, 0, 20);
40  peak_fitterB_->FixParameter(3, 50);
41  peak_fitterB_->SetParLimits(4, 0, 75);
42  peak_fitterB_->SetParameters(0., -50, 10, 50, 10);
43 
44  deconv_fitter_ = new TF1("deconv_fitter", fdeconv_convoluted, -50, 50, 5);
45  deconv_fitter_->SetNpx(1000);
46  deconv_fitter_->FixParameter(0, 0);
47  deconv_fitter_->SetParLimits(1, -50, 50);
48  deconv_fitter_->SetParLimits(2, 0, 200);
49  deconv_fitter_->SetParLimits(3, 5, 100);
50  deconv_fitter_->FixParameter(3, 50);
51  deconv_fitter_->SetParLimits(4, 0, 75);
52  deconv_fitter_->SetParameters(0., -2.82, 0.96, 50, 20);
53 }

References deconv_fitter_, fdeconv_convoluted(), fpeak_convoluted(), peak_fitterA_, peak_fitterB_, and tools::TF1.

◆ ~SamplingAlgorithm()

SamplingAlgorithm::~SamplingAlgorithm ( )
inlineoverride

Definition at line 22 of file SamplingAlgorithm.h.

22 { ; }

◆ SamplingAlgorithm() [2/2]

SamplingAlgorithm::SamplingAlgorithm ( )
inlineprivate

Definition at line 27 of file SamplingAlgorithm.h.

27 { ; }

Member Function Documentation

◆ analyse()

void SamplingAlgorithm::analyse ( )
overrideprivatevirtual

Performs histogram anaylsis.

Implements CommissioningAlgorithm.

Definition at line 113 of file SamplingAlgorithm.cc.

113  {
114  if (!samp_) {
115  edm::LogWarning(mlCommissioning_) << "[SamplingAlgorithm::" << __func__ << "]"
116  << " NULL pointer to derived Analysis object!";
117  return;
118  }
119 
120  TProfile* prof = (TProfile*)(histo_.first);
121  if (!prof) {
122  edm::LogWarning(mlCommissioning_) << " NULL pointer to histogram!";
123  return;
124  }
125 
126  // set the right error mode: rms
127  prof->SetErrorOption(" ");
128 
129  //that should not be needed, but it seems histos are stored with error option " " and errors "s" in all cases.
130  //it MUST be removed if the DQM (?) bug is solved
131  for (int i = 0; i < prof->GetNbinsX(); ++i) {
132  if (prof->GetBinEntries(i) > 0)
133  prof->SetBinError(i, prof->GetBinError(i) / sqrt(prof->GetBinEntries(i)));
134  }
135 
136  // prune the profile
137  pruneProfile(prof);
138 
139  // correct for the binning
140  correctBinning(prof);
141 
142  // correct for clustering effects
143  correctProfile(prof, samp_->sOnCut_);
144 
145  // fit depending on the mode
147  // initialize the fit (overal latency)
148  float max = prof->GetBinCenter(prof->GetMaximumBin());
149  float ampl = prof->GetMaximum();
150  peak_fitterA_->SetParameters(0., 50 - max, ampl / 20., 50, 10);
151 
152  // fit
153  if (prof->Fit(peak_fitterA_, "Q") == 0)
154  prof->Fit(peak_fitterA_, "QEM");
155 
156  // Set monitorables
157  samp_->max_ = peak_fitterA_->GetMaximumX();
158  samp_->error_ = peak_fitterA_->GetParError(1);
159 
160  } else { // sistrip::FINE_DELAY
161 
162  // initialize the fit (overal latency)
163  float max = prof->GetBinCenter(prof->GetMaximumBin());
164  float ampl = prof->GetMaximum();
165  deconv_fitter_->SetParameters(0., -max, ampl / 10., 50, 20);
166  peak_fitterB_->SetParameters(0., 50 - max, ampl / 20., 50, 10);
167  if (latencyCode_ & 0x80) { // deconv mode
168  // fit
169  if (prof->Fit(deconv_fitter_, "Q") == 0)
170  prof->Fit(deconv_fitter_, "QEM");
171  // Set monitorables
172  samp_->max_ = deconv_fitter_->GetMaximumX();
173  samp_->error_ = deconv_fitter_->GetParError(1);
174  } else { // peak mode
175  // fit
176  if (prof->Fit(peak_fitterB_, "Q") == 0)
177  prof->Fit(peak_fitterB_, "QEM");
178  // Set monitorables
179  samp_->max_ = peak_fitterB_->GetMaximumX();
180  samp_->error_ = peak_fitterB_->GetParError(1);
181  }
182  }
183 }

References sistrip::APV_LATENCY, correctBinning(), correctProfile(), deconv_fitter_, SamplingAnalysis::error_, histo_, mps_fire::i, latencyCode_, SiStripPI::max, SamplingAnalysis::max_, sistrip::mlCommissioning_, peak_fitterA_, peak_fitterB_, pruneProfile(), SamplingAnalysis::runType_, samp_, SamplingAnalysis::sOnCut_, and mathSSE::sqrt().

◆ correctBinning()

void SamplingAlgorithm::correctBinning ( TProfile *  prof) const
private

Definition at line 204 of file SamplingAlgorithm.cc.

204  {
205  prof->GetXaxis()->SetLimits(prof->GetXaxis()->GetXmin() - prof->GetBinWidth(1) / 2.,
206  prof->GetXaxis()->GetXmax() - prof->GetBinWidth(1) / 2.);
207 }

Referenced by analyse().

◆ correctProfile()

void SamplingAlgorithm::correctProfile ( TProfile *  profile,
float  SoNcut = 3. 
) const
private

Definition at line 211 of file SamplingAlgorithm.cc.

211  {
212  if (!samp_) {
213  return;
214  }
215  uint32_t nbins = profile->GetNbinsX();
216  float min = samp_->limit(SoNcut);
217  for (uint32_t bin = 1; bin <= nbins; ++bin)
218  if (profile->GetBinContent(bin) < min) {
219  profile->SetBinContent(bin, 0.);
220  profile->SetBinError(bin, 0.);
221  profile->SetBinEntries(bin, 0);
222  } else {
223  profile->SetBinContent(
224  bin, profile->GetBinEntries(bin) * samp_->correctMeasurement(profile->GetBinContent(bin), SoNcut));
225  }
226 }

References newFWLiteAna::bin, SamplingAnalysis::correctMeasurement(), SamplingAnalysis::limit(), min(), LaserClient_cfi::nbins, PostProcessor_cff::profile, and samp_.

Referenced by analyse().

◆ extract()

void SamplingAlgorithm::extract ( const std::vector< TH1 * > &  )
overrideprivatevirtual

Extracts and organises histograms.

Implements CommissioningAlgorithm.

Definition at line 57 of file SamplingAlgorithm.cc.

57  {
58  if (!anal()) {
59  edm::LogWarning(mlCommissioning_) << "[SamplingAlgorithm::" << __func__ << "]"
60  << " NULL pointer to Analysis object!";
61  return;
62  }
63 
64  CommissioningAnalysis* tmp = const_cast<CommissioningAnalysis*>(anal());
65  samp_ = dynamic_cast<SamplingAnalysis*>(tmp);
66  if (!samp_) {
67  edm::LogWarning(mlCommissioning_) << "[SamplingAlgorithm::" << __func__ << "]"
68  << " NULL pointer to derived Analysis object!";
69  return;
70  }
71 
72  // Check
73  if (histos.size() != 1 && histos.size() != 2) {
75  }
76 
77  // Extract FED key from histo title
78  if (!histos.empty()) {
79  samp_->fedKey(extractFedKey(histos.front()));
80  }
81 
82  // Extract
83  std::vector<TH1*>::const_iterator ihis = histos.begin();
84  for (; ihis != histos.end(); ihis++) {
85  // Check pointer
86  if (!(*ihis)) {
87  edm::LogWarning(mlCommissioning_) << " NULL pointer to histogram!";
88  continue;
89  }
90 
91  // Check name
92  SiStripHistoTitle title((*ihis)->GetName());
93  if (title.runType() != sistrip::APV_LATENCY && title.runType() != sistrip::FINE_DELAY) {
95  continue;
96  }
97  // Set the mode for later fits
98  samp_->runType_ = title.runType();
99 
100  // Set the granularity
101  samp_->granularity_ = title.granularity();
102 
103  // Extract timing histo
104  if (title.extraInfo().find(sistrip::extrainfo::clusterCharge_) != std::string::npos) {
105  histo_.first = *ihis;
106  histo_.second = (*ihis)->GetName();
107  }
108  }
109 }

References CommissioningAnalysis::addErrorCode(), CommissioningAlgorithm::anal(), sistrip::APV_LATENCY, sistrip::extrainfo::clusterCharge_, CommissioningAlgorithm::extractFedKey(), CommissioningAnalysis::fedKey(), sistrip::FINE_DELAY, SamplingAnalysis::granularity_, histo_, combine::histos, sistrip::mlCommissioning_, sistrip::numberOfHistos_, SamplingAnalysis::runType_, samp_, runGCPTkAlMap::title, createJobs::tmp, and sistrip::unexpectedTask_.

◆ histo()

const Histo& SamplingAlgorithm::histo ( ) const
inline

◆ pruneProfile()

void SamplingAlgorithm::pruneProfile ( TProfile *  profile) const
private

Definition at line 187 of file SamplingAlgorithm.cc.

187  {
188  // loop over bins to find the max stat
189  uint32_t nbins = profile->GetNbinsX();
190  uint32_t max = 0;
191  for (uint32_t bin = 1; bin <= nbins; ++bin)
192  max = max < profile->GetBinEntries(bin) ? uint32_t(profile->GetBinEntries(bin)) : max;
193  // loop over bins to clean
194  uint32_t min = max / 10;
195  for (uint32_t bin = 1; bin <= nbins; ++bin)
196  if (profile->GetBinEntries(bin) < min) {
197  profile->SetBinContent(bin, 0.);
198  profile->SetBinError(bin, 0.);
199  }
200 }

References newFWLiteAna::bin, SiStripPI::max, min(), LaserClient_cfi::nbins, and PostProcessor_cff::profile.

Referenced by analyse().

Member Data Documentation

◆ deconv_fitter_

TF1* SamplingAlgorithm::deconv_fitter_
private

Fitter in peak and deconvolution mode

Definition at line 44 of file SamplingAlgorithm.h.

Referenced by analyse(), and SamplingAlgorithm().

◆ histo_

Histo SamplingAlgorithm::histo_
private

pulse shape

Definition at line 41 of file SamplingAlgorithm.h.

Referenced by analyse(), and extract().

◆ latencyCode_

uint32_t SamplingAlgorithm::latencyCode_
private

latency code for fine delay scans

Definition at line 49 of file SamplingAlgorithm.h.

Referenced by analyse().

◆ peak_fitterA_

TF1* SamplingAlgorithm::peak_fitterA_
private

Definition at line 45 of file SamplingAlgorithm.h.

Referenced by analyse(), and SamplingAlgorithm().

◆ peak_fitterB_

TF1* SamplingAlgorithm::peak_fitterB_
private

Definition at line 46 of file SamplingAlgorithm.h.

Referenced by analyse(), and SamplingAlgorithm().

◆ samp_

SamplingAnalysis* SamplingAlgorithm::samp_
private

SamplingAnalysis object

Definition at line 52 of file SamplingAlgorithm.h.

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

runGCPTkAlMap.title
string title
Definition: runGCPTkAlMap.py:94
SamplingAlgorithm::latencyCode_
uint32_t latencyCode_
Definition: SamplingAlgorithm.h:49
mps_fire.i
i
Definition: mps_fire.py:428
CommissioningAlgorithm::extractFedKey
uint32_t extractFedKey(const TH1 *const)
Definition: CommissioningAlgorithm.cc:29
sistrip::unexpectedTask_
static const char unexpectedTask_[]
Definition: ConstantsForCommissioningAnalysis.h:21
SamplingAnalysis::correctMeasurement
float correctMeasurement(float mean, float SoNcut=3.) const
Definition: SamplingAnalysis.cc:50
min
T min(T a, T b)
Definition: MathUtil.h:58
SamplingAlgorithm::pruneProfile
void pruneProfile(TProfile *profile) const
Definition: SamplingAlgorithm.cc:187
SamplingAlgorithm::histo_
Histo histo_
Definition: SamplingAlgorithm.h:41
CommissioningAnalysis::fedKey
const uint32_t & fedKey() const
Definition: CommissioningAnalysis.h:134
SamplingAnalysis::limit
float limit(float SoNcut) const
Definition: SamplingAnalysis.cc:44
SamplingAnalysis::max_
float max_
Definition: SamplingAnalysis.h:50
CommissioningAnalysis::addErrorCode
virtual void addErrorCode(const std::string &error)
Definition: CommissioningAnalysis.h:148
sistrip::numberOfHistos_
static const char numberOfHistos_[]
Definition: ConstantsForCommissioningAnalysis.h:16
createJobs.tmp
tmp
align.sh
Definition: createJobs.py:716
tools.TF1
TF1
Definition: tools.py:23
edm::LogWarning
Log< level::Warning, false > LogWarning
Definition: MessageLogger.h:122
sistrip::FINE_DELAY
Definition: ConstantsForRunType.h:85
SamplingAnalysis::error_
float error_
Definition: SamplingAnalysis.h:53
sistrip::mlCommissioning_
static const char mlCommissioning_[]
Definition: ConstantsForLogger.h:15
SamplingAlgorithm::deconv_fitter_
TF1 * deconv_fitter_
Definition: SamplingAlgorithm.h:44
CommissioningAlgorithm::anal
CommissioningAnalysis *const anal() const
Definition: CommissioningAlgorithm.h:50
fdeconv_convoluted
double fdeconv_convoluted(double *x, double *par)
Definition: SiStripPulseShape.cc:113
sistrip::extrainfo::clusterCharge_
static const char clusterCharge_[]
Definition: ConstantsForDqm.h:59
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
fpeak_convoluted
double fpeak_convoluted(double *x, double *par)
Definition: SiStripPulseShape.cc:108
LaserClient_cfi.nbins
nbins
Definition: LaserClient_cfi.py:51
SamplingAlgorithm::correctBinning
void correctBinning(TProfile *prof) const
Definition: SamplingAlgorithm.cc:204
PostProcessor_cff.profile
profile
Definition: PostProcessor_cff.py:38
CommissioningAlgorithm::CommissioningAlgorithm
CommissioningAlgorithm()
Definition: CommissioningAlgorithm.cc:15
SiStripPI::max
Definition: SiStripPayloadInspectorHelper.h:169
SamplingAnalysis::granularity_
sistrip::Granularity granularity_
Definition: SamplingAnalysis.h:59
SamplingAlgorithm::samp_
SamplingAnalysis * samp_
Definition: SamplingAlgorithm.h:52
newFWLiteAna.bin
bin
Definition: newFWLiteAna.py:161
combine.histos
histos
Definition: combine.py:4
CommissioningAnalysis
Abstract base for derived classes that provide analysis of commissioning histograms.
Definition: CommissioningAnalysis.h:18
SamplingAlgorithm::peak_fitterB_
TF1 * peak_fitterB_
Definition: SamplingAlgorithm.h:46
SamplingAnalysis::runType_
sistrip::RunType runType_
Definition: SamplingAnalysis.h:56
sistrip::APV_LATENCY
Definition: ConstantsForRunType.h:76
SamplingAnalysis::sOnCut_
float sOnCut_
Definition: SamplingAnalysis.h:47
SiStripHistoTitle
Utility class that holds histogram title.
Definition: SiStripHistoTitle.h:20
SamplingAlgorithm::correctProfile
void correctProfile(TProfile *profile, float SoNcut=3.) const
Definition: SamplingAlgorithm.cc:211
SamplingAlgorithm::peak_fitterA_
TF1 * peak_fitterA_
Definition: SamplingAlgorithm.h:45