本文整理汇总了C++中TH1I::GetMean方法的典型用法代码示例。如果您正苦于以下问题:C++ TH1I::GetMean方法的具体用法?C++ TH1I::GetMean怎么用?C++ TH1I::GetMean使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TH1I
的用法示例。
在下文中一共展示了TH1I::GetMean方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: runnestedind
int runnestedind() {
TTree *t = create();
t->SetScanField(0);
t->Scan("type[]:type[sonind[]]","type[]==3");
TH1I* hgood = new TH1I("hgood","works",10,0,10);
TH1I* hbad = new TH1I("hbad","used to fail",10,0,10);
TCanvas *c = new TCanvas("c1");
c->Divide(1,2);
c->cd(1);
t->Draw("type[sonind[]]>>hbad","type[]==3");
c->cd(2);
t->Draw("type[sonind[]]>>hgood","type[]==3 && sonind[]>=0");
if (hgood->GetMean()!=hbad->GetMean()) {
cout << "Drawing \"type[sonind[]]>>hbad\",\"type[]==3\" failed!\n";
return 1;
}
#ifdef ClingWorkAroundErracticValuePrinter
printf("(int)0\n");
#endif
return 0;
}
示例2: NewCosmicstest
//.........这里部分代码省略.........
}
nTry++;
weighttest += w;
MCTheta->Fill(theta,w); // kein Weight!
MCPhi->Fill(phi,w);
MCXZ->Fill(x,z,w);
nTest++;
}while(!hit);
nEvent++;
}
MCnTry->Fill(1.0*nTry/EVENTS);
}
clock0->Stop();
delete fRandomEngine;
cout<<nEvent<<" events have been generated."<<endl;
cout<<"There is a total of "<<nInside<<"/"<<nTest<<" muons that passed close enough to the detector."<<endl;
cout<<"Including the given weight this corresponds to ";
cout<<kmax*weighttest/xdist/zdist*10000/123.3044<<" spills (1 spill = "<<xdist*zdist*123.3044/10000;
cout<<" real cosmic muons = "<<EVENTS<<" simulated events)."<<endl;
cout<<weighttest<<endl;
clock0->Print();
Double_t meanflux = 0;
Int_t binsum = 0;
for (Int_t ix = 2; ix<29;ix++){
for (Int_t iz = 2; iz<89;iz++){
binsum++;
meanflux += MCXZ->GetBinContent(ix,iz);
}
}
cout<< "meanflux: "<<meanflux/binsum<<" "<< meanflux<<endl<<endl;
printf("MCnTry: %.9f +- %.9f",MCnTry->GetMean(),MCnTry->GetMeanError());
cout<<endl<<endl;
TCanvas *c1 = new TCanvas("c1","c1",400,400);
c1->Divide(1,1);
c1->cd(1);
MCnTry->DrawCopy();
TCanvas *c4 = new TCanvas("c4","c4",400,400);
c4->Divide(1,1);
c4->cd(1);
StartPTheta->DrawCopy("SURF2");
gPad->SetLogx();
//TCanvas *c2 = new TCanvas("c2","c2",400,400);
//c2->Divide(1,1);
//c2->cd(1);
//gPad->SetLogy();
//wei->DrawCopy();
TCanvas *c3 = new TCanvas("c3","c3",1600,800);
c3->Divide(4,2);
c3->cd(1);
StartXZ->DrawCopy("COLZ");
c3->cd(2);
//MCP->SetLineColor(kGreen);
// MCP->DrawCopy();
//StartP->DrawCopy();
//TF1 *fs = new TF1("fs",NEWs,1,100,2);
//fs->FixParameter(0, 0);
//fs->FixParameter(1, 500);
//StartP->Add(fs,-1);
StartP->DrawCopy();
示例3: ExtractTrackBasedTiming
//.........这里部分代码省略.........
// Scan over the histogram
//chose the correct number of bins based on the histogram
float nsPerBin = (projY->GetBinCenter(projY->GetNbinsX()) - projY->GetBinCenter(1)) / projY->GetNbinsX();
float timeWindow = 3; //ns (Full Width)
int binWindow = int(timeWindow / nsPerBin);
double maxEntries = 0;
double maxMean = 0;
for (int j = 1 ; j <= projY->GetNbinsX();j++){
int minBin = j;
int maxBin = (j + binWindow) <= projY->GetNbinsX() ? (j + binWindow) : projY->GetNbinsX();
double sum = 0, nEntries = 0;
for (int bin = minBin; bin <= maxBin; bin++){
sum += projY->GetBinContent(bin) * projY->GetBinCenter(bin);
nEntries += projY->GetBinContent(bin);
if (bin == maxBin){
if (nEntries > maxEntries) {
maxMean = sum / nEntries;
maxEntries = nEntries;
}
}
}
}
//In the case there is RF, our job is to pick just the number of the correct beam bunch, so that's really all we need.
if(useRF) {
int beamBucket = int((maxMean / RF_Period) + 0.5); // +0.5 to handle rounding correctly
selectedTAGMOffset->SetBinContent(i, beamBucket);
TAGMOffsetDistribution->Fill(beamBucket);
}
else{
selectedTAGMOffset->SetBinContent(i, maxMean);
TAGMOffsetDistribution->Fill(maxMean);
}
}
double meanOffset = TAGMOffsetDistribution->GetMean();
// This might be in units of beam bunches, so we need to convert
if (useRF) meanOffset *= RF_Period;
if (verbose) {
cout << "Dumping TAGM results...\n=======================================" << endl;
cout << "TAGM mean Offset = " << meanOffset << endl;
cout << "fADC Offsets" << endl;
}
outFile.open(prefix + "tagm_adc_timing_offsets.txt", ios::out);
//for (int i = 1 ; i <= nBinsX; i++){
// Loop over rows
if (verbose) cout << "Column\tRow\tvalueToUse\toldValue\tmeanOffset\tTotal" << endl;
for (unsigned int column = 1; column <= 102; column++){
int index = GetCCDBIndexTAGM(column, 0);
double valueToUse = selectedTAGMOffset->GetBinContent(index);
if (useRF) valueToUse *= RF_Period;
//if (valueToUse == 0) valueToUse = meanOffset;
outFile << "0 " << column << " " << valueToUse + tagm_fadc_time_offsets[index-1] - meanOffset<< endl;
if (verbose) printf("0\t%i\t%.3f\t\t%.3f\t\t%.3f\t\t%.3f\n", column, valueToUse, tagm_fadc_time_offsets[index-1], meanOffset,
valueToUse + tagm_fadc_time_offsets[index-1] - meanOffset);
if (column == 9 || column == 27 || column == 81 || column == 99){
for (unsigned int row = 1; row <= 5; row++){
index = GetCCDBIndexTAGM(column, row);
valueToUse = selectedTAGMOffset->GetBinContent(index);
if (useRF) valueToUse *= RF_Period;
//if (valueToUse == 0) valueToUse = meanOffset;
outFile << row << " " << column << " " << valueToUse + tagm_fadc_time_offsets[index-1] - meanOffset<< endl;
if (verbose) printf("%i\t%i\t%.3f\t\t%.3f\t\t%.3f\t\t%.3f\n", row, column, valueToUse, tagm_fadc_time_offsets[index-1], meanOffset,
valueToUse + tagm_fadc_time_offsets[index-1] - meanOffset);
}
}
示例4: ExtractTrackBasedTiming
//.........这里部分代码省略.........
if(useRF) {
int beamBucket = int((maxMean / RF_Period) + 0.5); // +0.5 to handle rounding correctly
selectedTAGMOffset->SetBinContent(i, beamBucket);
TAGMOffsetDistribution->Fill(beamBucket);
}
else{
selectedTAGMOffset->SetBinContent(i, maxMean);
TAGMOffsetDistribution->Fill(maxMean);
}
}
/*
if (!useRF){
//TFitResultPtr fr1 = selectedTAGMOffset->Fit("pol1", "SQ", "", 0.5, nBinsX + 0.5);
TFitResultPtr fr1 = selectedTAGMOffset->Fit("pol1", "SQ", "", 5, 50);
for (int i = 1 ; i <= nBinsX; i++){
double x0 = fr1->Parameter(0);
double x1 = fr1->Parameter(1);
//double x2 = fr1->Parameter(2);
//double fitResult = x0 + i*x1 + i*i*x2;
double fitResult = x0 + i*x1;
double outlierCut = 20;
double valueToUse = selectedTAGMOffset->GetBinContent(i);
if (fabs(selectedTAGMOffset->GetBinContent(i) - fitResult) > outlierCut && valueToUse != 0.0){
valueToUse = fitResult;
}
selectedTAGMOffset->SetBinContent(i, valueToUse);
if (valueToUse != 0 ) TAGMOffsetDistribution->Fill(valueToUse);
}
}
*/
double meanOffset = TAGMOffsetDistribution->GetMean();
// This might be in units of beam bunches, so we need to convert
if (useRF) meanOffset *= RF_Period;
/*
for (int i = 1 ; i <= nBinsX; i++){
double valueToUse = selectedTAGMOffset->GetBinContent(i);
if (useRF) valueToUse *= RF_Period;
if (valueToUse == 0) valueToUse = meanOffset;
outFile.open(prefix + "tagm_tdc_timing_offsets.txt", ios::out | ios::app);
outFile << "0 " << i << " " << valueToUse + tagm_tdc_time_offsets[i-1] - meanOffset<< endl;
if (i == 7 || i == 25 || i == 79 || i == 97){
for(int j = 1; j <= 5; j++){
outFile << j << " " << i << " " << valueToUse + tagm_tdc_time_offsets[i-1] - meanOffset<< endl;
}
}
outFile.close();
// Apply the same shift to the adc offsets
outFile.open(prefix + "tagm_adc_timing_offsets.txt", ios::out | ios::app);
outFile << "0 " << i << " " << valueToUse + tagm_fadc_time_offsets[i-1] - meanOffset<< endl;
if (i == 7 || i == 25 || i == 79 || i == 97){
for(int j = 1; j <= 5; j++){
outFile << j << " " << i << " " << valueToUse + tagm_fadc_time_offsets[i-1] - meanOffset<< endl;
}
}
outFile.close();
}
*/
outFile.open(prefix + "tagm_adc_timing_offsets.txt", ios::out);
//for (int i = 1 ; i <= nBinsX; i++){
// Loop over rows
for (unsigned int column = 1; column <= 102; column++){
int index = GetCCDBIndexTAGM(column, 0);