29 void calcBins(
int binWidth,
int divisor,
long int start_time,
long int last_time,
long int current_time,
30 long int & binDiff,
long int &
diff) {
42 long int diff_current_start = current_time -
start_time;
43 long int diff_last_start = last_time -
start_time;
49 binDiff = diff_current_start/divisor/binWidth - diff_last_start/divisor/binWidth;
50 diff = (current_time - last_time)/divisor;
52 if(diff >= binWidth) {
53 while(diff >= binWidth) diff -= binWidth;
60 if(!bins || !h)
return;
61 if(h->GetXaxis()->IsVariableBinSize())
return;
68 if(!h->GetSumw2()) h->Sumw2();
69 int nBins = h->GetXaxis()->GetNbins();
78 int firstBin, lastBin, bound, increment;
89 bound = nBins - bins + 1;
96 int shift = increment * bins;
98 if( h->IsA() == TClass::GetClass(
"TProfile") ){
100 TProfile *
p =
static_cast<TProfile *
>(
h);
104 double nentries = p->GetEntries();
105 for(
int i = firstBin;
i != firstBin +
shift;
i += increment) nentries -= p->GetBinEntries(
i);
106 p->SetEntries(nentries);
108 TArrayD* sumw2 = p->GetSumw2();
110 for(
int i = firstBin;
i != bound;
i += increment){
112 p->SetBinContent(
i, p->GetBinContent(
i+shift ) * p->GetBinEntries(
i+shift ) );
113 p->SetBinEntries(
i, p->GetBinEntries(
i+shift ) );
114 sumw2->SetAt( sumw2->GetAt(
i+shift ),
i );
117 for(
int i = bound;
i != lastBin + increment;
i += increment){
118 p->SetBinContent(
i, 0 );
119 p->SetBinEntries(
i, 0 );
120 sumw2->SetAt( 0.,
i );
123 }
else if( h->InheritsFrom(
"TH2") ){
125 TH2 *h2 =
static_cast<TH2 *
>(
h);
126 int nBinsY = h2->GetYaxis()->GetNbins();
129 double nentries = h2->GetEntries();
130 for(
int i = firstBin;
i != firstBin +
shift;
i += increment)
131 for(
int j=0 ;
j<=nBinsY+1 ;
j++) nentries -= h2->GetBinContent(
i,
j);
133 h2->SetEntries(nentries);
135 for(
int i = firstBin;
i != bound;
i += increment)
136 for(
int j = 0;
j <= nBinsY + 1;
j++)
137 h2->SetBinContent(
i,
j, h2->GetBinContent(
i+shift,
j) );
139 for(
int i = bound;
i != lastBin + increment;
i += increment)
140 for(
int j = 0;
j <= nBinsY + 1;
j++)
141 h2->SetBinContent(
i,
j, 0 );
143 }
else if( h->InheritsFrom(
"TH1") ){
146 double nentries = h->GetEntries();
147 for(
int i = firstBin;
i != firstBin +
shift;
i += increment) nentries -= h->GetBinContent(
i);
149 h->SetEntries(nentries);
151 for(
int i = firstBin;
i != bound;
i += increment)
152 h->SetBinContent(
i, h->GetBinContent(
i+shift) );
154 for(
int i = bound;
i != lastBin + increment;
i += increment)
155 h->SetBinContent(
i, 0 );
176 TAxis *xax = h->GetXaxis();
177 if( h->GetXaxis()->IsVariableBinSize() )
return;
179 double xmax = xax->GetXmax();
180 double xmin = xax->GetXmin();
181 int nbins = xax->GetNbins();
184 xax->Set(nbins, xmin - shift, xmax - shift);
186 xax->Set(nbins, xmin + shift, xmax + shift);
198 int nbins = p->GetXaxis()->GetNbins();
202 y += p->GetBinContent(
i);
221 TString
name(cur->IsA()->GetName());
223 if(
name.Contains(
"TProfile")) {
226 else if(
name.Contains(
"TH2")) {
228 mean = ((TH2F*)cur)->GetEntries() - ((TH2F*)pre)->GetEntries();
233 mean = ((TH2F*)cur)->GetEntries();
237 float nxybins = ((TH2F*)cur)->GetNbinsX()*((TH2F*)cur)->GetNbinsY();
238 if(nxybins < 1.) nxybins = 1.;
242 else if(
name.Contains(
"TH1")) {
244 ((TH1F*)pre)->Sumw2();
245 ((TH1F*)pre)->Add((TH1F*)pre,(TH1F*)cur,-1,1);
246 mean = ((TH1F*)pre)->GetMean();
247 rms = ((TH1F*)pre)->GetRMS();
250 mean = ((TH1F*)cur)->GetMean();
251 rms = ((TH1F*)cur)->GetRMS();
266 ret = (TObject*) (me->
getRootObject()->Clone(title.c_str()));
void getAverageFromTProfile(TProfile *p, double &mean, double &rms)
unsigned long long start_time
void shiftAxis(TH1 *h, Directions d, double shift)
void shift2Left(TH1 *h, int bins)
void shift(TH1 *h, Directions d, int bins)
Ecal Monitor Utility functions.
TObject * getRootObject(void) const
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
TObject * cloneIt(MonitorElement *me, std::string histo)
void calcBins(int binWidth, int divisor, long int start_time, long int last_time, long int current_time, long int &binDiff, long int &diff)
void shift2Right(TH1 *h, int bins)
void getMeanRms(TObject *pre, TObject *cur, double &mean, double &rms)