CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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)
 
virtual ~SamplingAlgorithm ()
 
- Public Member Functions inherited from CommissioningAlgorithm
void analysis (const std::vector< TH1 * > &)
 
 CommissioningAlgorithm (CommissioningAnalysis *const )
 
 CommissioningAlgorithm ()
 
virtual ~CommissioningAlgorithm ()
 

Private Member Functions

void analyse ()
 
void correctBinning (TProfile *prof) const
 
void correctProfile (TProfile *profile, float SoNcut=3.) const
 
virtual void extract (const std::vector< TH1 * > &)
 
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::SamplingAlgorithm ( const edm::ParameterSet pset,
SamplingAnalysis * const  anal,
uint32_t  latencyCode = 0 
)

Definition at line 18 of file SamplingAlgorithm.cc.

References deconv_fitter_, fdeconv_convoluted(), fpeak_convoluted(), peak_fitterA_, and peak_fitterB_.

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

Definition at line 24 of file SamplingAlgorithm.h.

24 {;}
SamplingAlgorithm::SamplingAlgorithm ( )
inlineprivate

Definition at line 30 of file SamplingAlgorithm.h.

30 {;}

Member Function Documentation

void SamplingAlgorithm::analyse ( )
privatevirtual

Performs histogram anaylsis.

Implements CommissioningAlgorithm.

Definition at line 118 of file SamplingAlgorithm.cc.

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

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

Definition at line 215 of file SamplingAlgorithm.cc.

Referenced by analyse().

216 {
217  prof->GetXaxis()->SetLimits(prof->GetXaxis()->GetXmin()-prof->GetBinWidth(1)/2.,
218  prof->GetXaxis()->GetXmax()-prof->GetBinWidth(1)/2.);
219 }
void SamplingAlgorithm::correctProfile ( TProfile *  profile,
float  SoNcut = 3. 
) const
private

Definition at line 223 of file SamplingAlgorithm.cc.

References newFWLiteAna::bin, SamplingAnalysis::correctMeasurement(), SamplingAnalysis::limit(), min(), pileupCalc::nbins, and samp_.

Referenced by analyse().

224 {
225  if ( !samp_ ) { return; }
226  uint32_t nbins=profile->GetNbinsX();
227  float min = samp_->limit(SoNcut);
228  for(uint32_t bin=1;bin<=nbins;++bin)
229  if(profile->GetBinContent(bin)<min) {
230  profile->SetBinContent(bin,0.);
231  profile->SetBinError(bin,0.);
232  profile->SetBinEntries(bin,0);
233  }
234  else {
235  profile->SetBinContent(bin,
236  profile->GetBinEntries(bin)*
237  samp_->correctMeasurement(profile->GetBinContent(bin),SoNcut));
238  }
239 }
float limit(float SoNcut) const
SamplingAnalysis * samp_
T min(T a, T b)
Definition: MathUtil.h:58
float correctMeasurement(float mean, float SoNcut=3.) const
void SamplingAlgorithm::extract ( const std::vector< TH1 * > &  )
privatevirtual

Extracts and organises histograms.

Implements CommissioningAlgorithm.

Definition at line 58 of file SamplingAlgorithm.cc.

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

Referenced by BeautifulSoup.PageElement::_invert(), and BeautifulSoup.Tag::decompose().

58  {
59 
60  if ( !anal() ) {
62  << "[SamplingAlgorithm::" << __func__ << "]"
63  << " NULL pointer to Analysis object!";
64  return;
65  }
66 
68  samp_ = dynamic_cast<SamplingAnalysis*>( tmp );
69  if ( !samp_ ) {
71  << "[SamplingAlgorithm::" << __func__ << "]"
72  << " NULL pointer to derived Analysis object!";
73  return;
74  }
75 
76  // Check
77  if ( histos.size() != 1 && histos.size() != 2 ) {
79  }
80 
81  // Extract FED key from histo title
82  if ( !histos.empty() ) { samp_->fedKey( extractFedKey( histos.front() ) ); }
83 
84  // Extract
85  std::vector<TH1*>::const_iterator ihis = histos.begin();
86  for ( ; ihis != histos.end(); ihis++ ) {
87 
88  // Check pointer
89  if ( !(*ihis) ) {
90  edm::LogWarning(mlCommissioning_) << " NULL pointer to histogram!";
91  continue;
92  }
93 
94  // Check name
95  SiStripHistoTitle title( (*ihis)->GetName() );
96  if ( title.runType() != sistrip::APV_LATENCY && title.runType() != sistrip::FINE_DELAY) {
98  continue;
99  }
100  // Set the mode for later fits
101  samp_->runType_ = title.runType();
102 
103  // Set the granularity
104  samp_->granularity_ = title.granularity();
105 
106  // Extract timing histo
107  if ( title.extraInfo().find(sistrip::extrainfo::clusterCharge_) != std::string::npos ) {
108  histo_.first = *ihis;
109  histo_.second = (*ihis)->GetName();
110  }
111 
112  }
113 
114 }
static const char unexpectedTask_[]
Analysis for latency run.
const uint32_t & fedKey() const
Utility class that holds histogram title.
sistrip::RunType runType_
static const char numberOfHistos_[]
SamplingAnalysis * samp_
static const char mlCommissioning_[]
uint32_t extractFedKey(const TH1 *const )
virtual void addErrorCode(const std::string &error)
static const char clusterCharge_[]
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100
Abstract base for derived classes that provide analysis of commissioning histograms.
sistrip::Granularity granularity_
CommissioningAnalysis *const anal() const
const Histo& SamplingAlgorithm::histo ( ) const
inline
void SamplingAlgorithm::pruneProfile ( TProfile *  profile) const
private

Definition at line 198 of file SamplingAlgorithm.cc.

References newFWLiteAna::bin, bookConverter::max, min(), and pileupCalc::nbins.

Referenced by analyse().

199 {
200  // loop over bins to find the max stat
201  uint32_t nbins=profile->GetNbinsX();
202  uint32_t max = 0;
203  for(uint32_t bin=1;bin<=nbins;++bin) max = max < profile->GetBinEntries(bin) ? uint32_t(profile->GetBinEntries(bin)) : max;
204  // loop over bins to clean
205  uint32_t min = max/10;
206  for(uint32_t bin=1;bin<=nbins;++bin)
207  if(profile->GetBinEntries(bin)<min) {
208  profile->SetBinContent(bin,0.);
209  profile->SetBinError(bin,0.);
210  }
211 }
T min(T a, T b)
Definition: MathUtil.h:58

Member Data Documentation

TF1* SamplingAlgorithm::deconv_fitter_
private

Fitter in peak and deconvolution mode

Definition at line 48 of file SamplingAlgorithm.h.

Referenced by analyse(), and SamplingAlgorithm().

Histo SamplingAlgorithm::histo_
private

pulse shape

Definition at line 45 of file SamplingAlgorithm.h.

Referenced by analyse(), and extract().

uint32_t SamplingAlgorithm::latencyCode_
private

latency code for fine delay scans

Definition at line 53 of file SamplingAlgorithm.h.

Referenced by analyse().

TF1* SamplingAlgorithm::peak_fitterA_
private

Definition at line 49 of file SamplingAlgorithm.h.

Referenced by analyse(), and SamplingAlgorithm().

TF1* SamplingAlgorithm::peak_fitterB_
private

Definition at line 50 of file SamplingAlgorithm.h.

Referenced by analyse(), and SamplingAlgorithm().

SamplingAnalysis* SamplingAlgorithm::samp_
private

SamplingAnalysis object

Definition at line 56 of file SamplingAlgorithm.h.

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