CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Functions
ecaldqm Namespace Reference

Functions

void calcBins (int binWidth, int divisor, long int start_time, long int last_time, long int current_time, long int &binDiff, long int &diff)
 
TObject * cloneIt (MonitorElement *me, std::string histo)
 
void getAverageFromTProfile (TProfile *p, double &mean, double &rms)
 
void getMeanRms (TObject *pre, TObject *cur, double &mean, double &rms)
 
void shift2Left (TProfile *p, int bins)
 
void shift2Right (TProfile *p, int bins)
 

Function Documentation

void ecaldqm::calcBins ( int  binWidth,
int  divisor,
long int  start_time,
long int  last_time,
long int  current_time,
long int &  binDiff,
long int &  diff 
)

Definition at line 28 of file UtilFunctions.h.

References evf::utils::start_time.

Referenced by EBTrendTask::analyze(), EETrendTask::analyze(), EETrendClient::analyze(), and EBTrendClient::analyze().

29  {
30 
31  // changing arguments : binDiff, diff
32 
33  // binWidth : time interval
34  // divisor : time unit - for minute case divisor is 60 and for hour case 3600
35  // start_time : initial time when the job started
36  // last_time : the last updated time before calling the current "analyze" function
37  // current_time : the current time inside "analyze" fucntion
38  // binDiff : the bin difference for the current time compared to the bin location of the last time
39  // diff : time difference between the current time and the last time
40 
41  long int diff_current_start = current_time - start_time;
42  long int diff_last_start = last_time - start_time;
43 
44  // --------------------------------------------------
45  // Calculate time interval and bin width
46  // --------------------------------------------------
47 
48  binDiff = diff_current_start/divisor/binWidth - diff_last_start/divisor/binWidth;
49  diff = (current_time - last_time)/divisor;
50 
51  if(diff >= binWidth) {
52  while(diff >= binWidth) diff -= binWidth;
53  }
54 
55  } // calcBins
unsigned long long start_time
Definition: procUtils.cc:98
TObject* ecaldqm::cloneIt ( MonitorElement me,
std::string  histo 
)

Definition at line 186 of file UtilFunctions.h.

References MonitorElement::getRootObject(), runTheMatrix::ret, and indexGen::title.

Referenced by EBTrendClient::analyze(), and EETrendClient::analyze().

186  {
187 
188  // The cloned object, ret should be deleted after using it.
189 
190  TObject* ret = 0;
191 
192  if(!me) return ret;
193 
194  std::string title = histo + " Clone";
195  ret = (TObject*) (me->getRootObject()->Clone(title.c_str()));
196 
197  return ret;
198  }
tuple histo
Definition: trackerHits.py:12
TObject * getRootObject(void) const
void ecaldqm::getAverageFromTProfile ( TProfile *  p,
double &  mean,
double &  rms 
)

Definition at line 123 of file UtilFunctions.h.

References i, ExpressReco_HICollisions_FallBack::nbins, mathSSE::sqrt(), and ExpressReco_HICollisions_FallBack::y.

Referenced by getMeanRms().

123  {
124 
125  // changing arguments : mean, rms
126  mean = rms = 0.0;
127 
128  if(!p) return;
129 
130  int nbins = p->GetXaxis()->GetNbins();
131  double y = 0.0;
132  double y2 = 0.0;
133  for(int i=1; i<=nbins; i++){
134  y += p->GetBinContent(i);
135  y2 += y*y;
136  }
137  mean = y/nbins;
138  rms = std::sqrt(y2/nbins - mean*mean);
139 
140  } // getAverageFromTProfile
int i
Definition: DBlmapReader.cc:9
T sqrt(T t)
Definition: SSEVec.h:28
void ecaldqm::getMeanRms ( TObject *  pre,
TObject *  cur,
double &  mean,
double &  rms 
)

Definition at line 145 of file UtilFunctions.h.

References getAverageFromTProfile(), AlCaRecoCosmics_cfg::name, and mathSSE::sqrt().

Referenced by EBTrendClient::analyze(), and EETrendClient::analyze().

145  {
146 
147  // changing arguments : mean, rms
148 
149  mean = rms = 0.0;
150 
151  if(!cur) return;
152 
153  TString name(cur->IsA()->GetName());
154 
155  if(name.Contains("TProfile")) {
156  getAverageFromTProfile((TProfile*)cur,mean,rms);
157  }
158  else if(name.Contains("TH2")) {
159  if(pre) {
160  mean = ((TH2F*)cur)->GetEntries() - ((TH2F*)pre)->GetEntries();
161  rms = std::sqrt(mean);
162  }
163  else {
164  mean = ((TH2F*)cur)->GetEntries();
165  rms = std::sqrt(mean);
166  }
167  float nxybins = ((TH2F*)cur)->GetNbinsX()*((TH2F*)cur)->GetNbinsY();
168  mean /= nxybins;
169  rms /= nxybins;
170  }
171  else if(name.Contains("TH1")) {
172  if(pre) {
173  ((TH1F*)pre)->Sumw2();
174  ((TH1F*)pre)->Add((TH1F*)pre,(TH1F*)cur,-1,1);
175  mean = ((TH1F*)pre)->GetMean();
176  rms = ((TH1F*)pre)->GetRMS();
177  }
178  else {
179  mean = ((TH1F*)cur)->GetMean();
180  rms = ((TH1F*)cur)->GetRMS();
181  }
182  }
183 
184  } // getMeanRms
void getAverageFromTProfile(TProfile *p, double &mean, double &rms)
T sqrt(T t)
Definition: SSEVec.h:28
void ecaldqm::shift2Left ( TProfile *  p,
int  bins 
)

Definition at line 93 of file UtilFunctions.h.

References i.

93  {
94 
95  if(bins <= 0) return;
96 
97  if(!p->GetSumw2()) p->Sumw2();
98  int nBins = p->GetXaxis()->GetNbins();
99 
100  // by shifting n bin to the left, the number of entries are
101  // reduced by the number in n bins including the underflow bin.
102  double nentries = p->GetEntries();
103  for(int i=0; i<bins; i++) nentries -= p->GetBinEntries(i);
104  p->SetEntries(nentries);
105 
106  // the first bin goes to underflow
107  // each bin moves to the right
108 
109  TArrayD* sumw2 = p->GetSumw2();
110 
111  for(int i=0; i<=nBins+1-bins; i++) {
112  // GetBinContent return binContent/binEntries
113  p->SetBinContent(i, p->GetBinContent(i+bins)*p->GetBinEntries(i+bins));
114  p->SetBinEntries(i,p->GetBinEntries(i+bins));
115  sumw2->SetAt(sumw2->GetAt(i+bins),i);
116  }
117 
118  }
int i
Definition: DBlmapReader.cc:9
void ecaldqm::shift2Right ( TProfile *  p,
int  bins 
)

Definition at line 61 of file UtilFunctions.h.

References i.

Referenced by ESTrendTask::analyze(), EETrendTask::analyze(), EBTrendTask::analyze(), EETrendClient::analyze(), and EBTrendClient::analyze().

61  {
62 
63  // bins : how many bins need to be shifted
64 
65  if(bins <= 0) return;
66 
67  if(!p->GetSumw2()) p->Sumw2();
68  int nBins = p->GetXaxis()->GetNbins();
69 
70  // by shifting n bin to the right, the number of entries are
71  // reduced by the number in n bins including the overflow bin.
72  double nentries = p->GetEntries();
73  for(int i=0; i<bins; i++) nentries -= p->GetBinEntries(i);
74  p->SetEntries(nentries);
75 
76  // the last bin goes to overflow
77  // each bin moves to the right
78 
79  TArrayD* sumw2 = p->GetSumw2();
80 
81  for(int i=nBins+1; i>bins; i--) {
82  // GetBinContent return binContent/binEntries
83  p->SetBinContent(i, p->GetBinContent(i-bins)*p->GetBinEntries(i-bins));
84  p->SetBinEntries(i,p->GetBinEntries(i-bins));
85  sumw2->SetAt(sumw2->GetAt(i-bins),i);
86  }
87 
88  }
int i
Definition: DBlmapReader.cc:9