本文整理汇总了C++中TGraphErrors::GetN方法的典型用法代码示例。如果您正苦于以下问题:C++ TGraphErrors::GetN方法的具体用法?C++ TGraphErrors::GetN怎么用?C++ TGraphErrors::GetN使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TGraphErrors
的用法示例。
在下文中一共展示了TGraphErrors::GetN方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: covertQuan
void covertQuan(){
TFile *fin = TFile::Open("pPb.root");
// TFile *fout = new TFile("pPb_xq.root","Recreate");
int mult[4] = {120,150,185,220};
int n[4] = {2,4,6,8};
for(int i=0;i<4;i++){
for(int j=0;j<4;j++){
TGraphErrors *g = (TGraphErrors*)fin->Get(Form("v2Pt_%d_%d",n[j],mult[i]));
if(n[j]==4){
cout<<mult[i]<<endl;
for(int ibin=0;ibin<g->GetN();ibin++){
cout<<g->GetX()[ibin]<<",";
}
cout<<endl;
for(int ibin=0;ibin<g->GetN();ibin++){
cout<<g->GetY()[ibin]<<",";
}
cout<<endl;
for(int ibin=0;ibin<g->GetN();ibin++){
cout<<g->GetEY()[ibin]<<",";
}
cout<<endl;
}
// fout->cd();
// g->Write("AP");
// g1->Write();
}
}
}
示例2: add_point
void add_point( double coefover, double sigma, double dsigma ){//============================================================
TGraphErrors *fisig;
if ( gROOT->GetListOfSpecials()->FindObject("fisig")!=NULL ){
fisig=(TGraphErrors*) gROOT->GetListOfSpecials()->FindObject("fisig");
printf("fisig exists\n%s","");
}else{
printf("\n\n NO fisig exists NONONO \n\n\n%s","");
fisig=new TGraphErrors();
fisig->SetTitle("fisig");
fisig->SetName("fisig");
gROOT->GetListOfSpecials()->Add( fisig );// TRICK TO KEEP IT
gDirectory->Add( fisig );
fisig->SetMarkerStyle(7);
}
int n=fisig->GetN();
fisig->SetPoint(n,coefover,sigma);
fisig->SetPointError(n,0.0,dsigma);
// fisig->Print(); // too many data
char text[100];
sprintf(text,"%.3f ... %d",coefover, fisig->GetN() );
// TText *t=new TText(from,0,text );
// t->SetTextSize(0.08);t->Draw();
}//============================================================
示例3: JEC_fit_Uncertainty
void JEC_fit_Uncertainty(int N)
{
TF1 *func[1000];
TFile *inf = new TFile("L3Graphs_test_Icone5.root");
TGraphErrors *g = (TGraphErrors*)inf->Get("Correction_vs_CaloPt");
TGraphErrors *vg[1000];
int i,k;
double x[20],y[20],ex[20],ey[20];
double vx[20],vy[20],vex[20],vey[20];
for(i=0;i<g->GetN();i++)
{
g->GetPoint(i,x[i],y[i]);
ex[i]=g->GetErrorX(i);
ey[i]=g->GetErrorY(i);
}
TRandom *rnd = new TRandom();
rnd->SetSeed(0);
for(k=0;k<N;k++)
{
for(i=0;i<g->GetN();i++)
{
vx[i] = rnd->Gaus(x[i],ex[i]);
//vx[i] = x[i];
vy[i] = rnd->Gaus(y[i],ey[i]);
vex[i] = ex[i];
vey[i] = ey[i];
}
vg[k] = new TGraphErrors(g->GetN(),vx,vy,vex,vey);
func[k] = new TF1("func","[0]+[1]/(pow(log10(x),[2])+[3])",1,2000);
func[k]->SetParameters(1,3,6,5);
vg[k]->Fit(func[k],"RQ");
}
TCanvas *c = new TCanvas("c","c");
gPad->SetLogx();
g->SetMarkerStyle(20);
g->SetMaximum(3.5);
g->Draw("AP");
for(k=0;k<N;k++)
{
func[k]->SetLineColor(5);
func[k]->SetLineWidth(1);
cout<<func[k]->GetChisquare()<<endl;
vg[k]->SetMarkerColor(2);
vg[k]->SetLineColor(2);
vg[k]->SetMarkerStyle(21);
//if (func[k]->GetChisquare()<0.1)
//vg[k]->Draw("sameP");
func[k]->Draw("same");
}
}
示例4: RampCorrellation_single
int RampCorrellation_single(std::string file_name, TGraphErrors &graph, TGraphErrors &graph2, vector<double> &vec_errors)
{
TTree *t = new TTree();
const std::string file_path = "/home/jlab/github/MagCloak_Analysis/calibration/data-calib/DATA_MegaVIEW/";
// std::string file_name = "DataFile_2016-12-08_06-59-11.csv";
std::string file = file_path+file_name;
t->ReadFile(file.c_str());
// t->Print();
TCanvas *c = new TCanvas();
t->Draw("TMath::Abs(B1/B2):time");
TGraph *gh = (TGraph*)c->GetListOfPrimitives()->FindObject("Graph");
double ratio_mean = gh->GetMean(2);
double ratio_std = gh->GetRMS(2);
t->Draw("Bnom:time");
TGraph *gh1 = (TGraph*)c->GetListOfPrimitives()->FindObject("Graph");
double nom_mean = gh1->GetMean(2);
double nom_std = 0;
// cout << "At " << nom_mean << " mT, B1/B2 is: " << ratio_mean << " +/- " << ratio_std << endl;
c->Close();
int n = graph.GetN();
graph.SetPoint(n,nom_mean,ratio_mean);
graph.SetPointError(n,nom_std,ratio_std);
//-------------------------------------------------------------------------------
TCanvas *c2 = new TCanvas();
t->Draw("B3:time");
TGraph *gh2 = (TGraph*)c2->GetListOfPrimitives()->FindObject("Graph");
double B3_mean = -1*(gh2->GetMean(2));
double B3_std = gh2->GetRMS(2);
int n2 = graph2.GetN();
graph2.SetPoint(n2, nom_mean, B3_mean);
graph2.SetPointError(n2, nom_std, B3_std);
c2->Close();
if(nom_mean < 500) vec_errors.push_back(B3_std);
return 0;
}
示例5: draw
void draw() {
gStyle->SetOptStat(0000);
TGraphErrors* gr = new TGraphErrors("papel_um.txt", "%lg %lg %lg %lg");
gr->Draw("A");
gr->GetXaxis()->SetTitle("Diametro (mm)");
gr->GetYaxis()->SetTitle("Massa (u.m.)");
gr->SetTitle("Dimensao Fractal - Papel");
gr->SetMarkerStyle(20);
gr->SetMarkerSize(gr->GetMarkerSize()/2.);
TCanvas* c1 = new TCanvas();
gr->Draw("AP");
c1->Print("gr1.png");
TGraphErrors* grlog = new TGraphErrors();
for (int i=0; i<gr->GetN(); i++) {
grlog->SetPoint(i, TMath::Log(gr->GetX()[i]), TMath::Log(gr->GetY()[i]));
grlog->SetPointError(i, gr->GetEX()[i]/gr->GetX()[i], 0.0);
}
grlog->Draw("A");
grlog->GetXaxis()->SetTitle("Logaritmo do diametro (diametro em mm)");
grlog->GetYaxis()->SetTitle("Logaritmo da massa (massa em unidade arbitraria)");
grlog->SetTitle("Dimensao Fractal - Papel");
grlog->SetMarkerStyle(20);
// grlog->SetMarkerSize(gr->GetMarkerSize()/2.);
grlog->Fit("pol1");
TCanvas* c2 = new TCanvas();
grlog->Draw("AP");
c2->Print("gr2.png");
}
示例6: InitSummaryTrending
void InitSummaryTrending(TTree * tree){
//
// Init drawing for the <detector> QA
// Detector specific qaConfig() has to be called before invoking this function
// 0.) Make descriptor
// 1.) Make default canvas - addopt canvas width to the number of entries to draw
// 3.) compute detector status graphs
//
// 0.) Make descriptor
//
TLatex *latex= new TLatex;
latex->SetX(0.11);
latex->SetY(0.8);
latex->SetTextSize(0.03);
descriptionQA = GetTexDescription(latex);
//
// 1.) Make default canvas - addopt canvas width to the number of entries to draw
//
TGraphErrors *gr = (TGraphErrors*) TStatToolkit::MakeGraphSparse(tree,"resolution:tagID","");
Int_t numberOfTags = gr->GetN();
cout<<"number of graph entries: "<<numberOfTags<<endl;
double SpaceForLegend = 0.;
Int_t canvas_width = SpaceForLegend + (numberOfTags+5)*30;
Int_t canvas_height = 600;
if ( canvas_width>kMaxCanvasWidth) canvas_width=kMaxCanvasWidth;
canvasQA = new TCanvas("canvasQA","canvasQA",canvas_width,canvas_height);
canvasQA->SetGrid(3);
canvasQA->cd();
gPad->SetTicks(1,2);
// canvasQA->SetRightMargin(SpaceForLegend/canvas_width);
double leftlegend = 1 - 180./canvasQA->GetWw();
double rightlegend = 1 - 10./canvasQA->GetWw();
//
// 2.) process config file qaConfig.C to initialize status aliases (outliers etc.), status bar criteria, status lines, ...
//
TString sStatusbarVars = statusDescription[0];
TString sStatusbarNames = statusDescription[1];
TString sCriteria = statusDescription[2];
cout << "sStatusbarVars = " << sStatusbarVars.Data() << endl;
cout << "sCriteria = " << sCriteria.Data() << endl;
//
// 3.) compute detector status graphs
//
TObjArray* oaStatusbarVars = sStatusbarVars.Tokenize(";");
TObjArray* oaStatusbarNames = sStatusbarNames.Tokenize(";");
oaMultGr = new TObjArray();
int igr=0;
for (Int_t vari=oaStatusbarVars->GetEntriesFast()-1; vari>=0; vari--){ // invert the order of the status graphs
TString sVar = Form("%s:tagID", oaStatusbarVars->At(vari)->GetName()); //e.g. -> dcar:run
oaMultGr->Add( TStatToolkit::MakeStatusMultGr(tree, sVar.Data(), "", sCriteria.Data(), igr) );
TString sYtitle = oaStatusbarNames->At(vari)->GetName(); // set better name for y axis of statuspad
((TMultiGraph*) oaMultGr->At(igr))->SetTitle(sYtitle.Data());
igr++;
}
}
示例7: points
void points(TString filename) {
TString cmssw;
// 167
cmssw = "$1.6.7$";
TFile *f = TFile::Open(filename);
std::vector< TString > taggers;
taggers.push_back( "gTC2_udsg" );
taggers.push_back( "gTC3_udsg" );
taggers.push_back( "gTP_udsg" );
taggers.push_back( "gJBP_udsg" );
taggers.push_back( "gSSV_udsg" );
taggers.push_back( "gCSV_udsg" );
std::vector< TString > discriminators;
discriminators.push_back( "discTC2_udsg" );
discriminators.push_back( "discTC3_udsg" );
discriminators.push_back( "discTP_udsg" );
discriminators.push_back( "discJBP_udsg" );
discriminators.push_back( "discSSV_udsg" );
discriminators.push_back( "discCSV_udsg" );
//TCanvas *cv_TC = new TCanvas("cv_TC","cv_TC",700,700);
//TCanvas *cv_TP = new TCanvas("cv_TP","cv_TP",700,700);
std::cout << "Tagger & Point & Discriminator & light mistag & b-efficiency \\\\ \\hline" << std::endl;
for ( size_t itagger = 0; itagger < taggers.size(); ++itagger ) {
TString tag = taggers[itagger];
TGraphErrors *agraph = (TGraphErrors*) gDirectory->Get("Histograms/MCtruth/"+tag);
//if (taggers == "gTC2_udsg" || taggers =
TGraph *dgraph = (TGraph*) gDirectory->Get("Histograms/MCtruth/"+discriminators[itagger]);
dgraph->Sort();
TGraphErrors *g = new TGraphErrors(agraph->GetN(),agraph->GetY(),agraph->GetX(),agraph->GetEY(),agraph->GetEX());
g->Sort();
//cv[itagger] = new TCanvas("cv","cv",600,600);
//g->Draw("ACP");
TString se = " & ";
std::cout << tag << se << "Loose" << se << std::setprecision(3) << dgraph->Eval(0.1) << se << "0.1" << se << std::setprecision(2) << g->Eval(0.1) << "\\\\" << std::endl;
std::cout << tag << se << "Medium" << se << std::setprecision(3) << dgraph->Eval(0.01) << se << "0.01" << se << std::setprecision(2) << g->Eval(0.01) << "\\\\" << std::endl;
std::cout << tag << se << "Tight" << se << std::setprecision(3) << dgraph->Eval(0.001) << se << "0.001" << se << std::setprecision(2) << g->Eval(0.001) << "\\\\ \\hline" << std::endl;
}
}
示例8: assert
TGraphErrors *tools::makeGraph(TH1 *hx, TH1 *hy, double scale ) {
assert(hx->GetNbinsX()==hy->GetNbinsX());
TGraphErrors *g = new TGraphErrors(0);
for (int i = 1; i != hx->GetNbinsX()+1; ++i) {
assert(hx->GetBinLowEdge(i)==hy->GetBinLowEdge(i));
int n = g->GetN();
SetPoint(g, n, hx->GetBinContent(i), scale*hy->GetBinContent(i),
hx->GetBinError(i), scale*hy->GetBinError(i));
}
return g;
}
示例9:
double ll_matrix::matrix_calibration::get_min_mass( TGraphErrors & graph )
{
double m_min_x = graph.GetX()[0] , m_min_y = graph.GetY()[0];
for( int i = 0 ; i < graph.GetN() ; i++ )
{
if( graph.GetY()[i] < m_min_y )
{
if( graph.GetX()[i] < LOWEST_MASS || graph.GetX()[i] > HIGHEST_MASS )
continue;
m_min_x = graph.GetX()[i];
m_min_y = graph.GetY()[i];
}
}
return m_min_x;
}
示例10: TFile
printgraph(const char* file, const char* graphname, const char* graphname_syst, bool reverseta=false, double scale=1./34.62)
{
TFile * f = new TFile(file);
TGraphErrors *gr = (TGraphErrors*) f->Get(graphname);
TGraphErrors *grsyst = (TGraphErrors*) f->Get(graphname_syst);
int nbins = gr->GetN();
double *x = new double[nbins];
if (reverseta)
for (int i=0; i<nbins; i++)
x[i] = gr->GetX()[nbins-i-1];
else
x = gr->GetX();
double *y = gr->GetY();
double *ey = gr->GetEY();
double *ey_syst = grsyst->GetEY();
for (int i=0; i<nbins; i++)
cout << x[i] << ": " << y[i]*scale << "+-" << ey[i]*scale << "(stat.) +-" << ey_syst[i]*scale << "(syst.)" << endl;
}
示例11: VisualizeSurface
Int_t VisualizeSurface()
{
std::string gfname;
std::cout << "\nFor the graph ";
ListAllFilesInDirOfType (".",".root");
std::cout << "\nEnter filename : ";
std::getline(std::cin, gfname);
TGraphErrors* mygr = GetGraph(gfname);
mygr->SetMarkerColor(kRed);
mygr->SetLineColor(kRed);
mygr->SetMarkerStyle(20);
std::string parfname = GetParamFile();
std::ifstream pfile(parfname.data());
Parameters params(pfile);
if (! params.KeysAreSensible()) return -1;
AngDistC W(params, 1, ELECTRIC);
std::cout << params << std::endl;
TGraph* gr = new TGraph(mygr->GetN());
gr->SetMarkerColor(kBlue);
gr->SetLineColor(kBlue);
gr->SetMarkerStyle(20);
Double_t num, denom;
Double_t ratio;
Double_t x[2];
for (UInt_t i=0; i<mygr->GetN(); i++)
{
x[0] = mygr->GetX()[i];
x[1] = 0;
num = W(x);
x[1] = TMath::Pi()/2.;
denom = W(x);
ratio = num/denom;
gr->SetPoint(i, mygr->GetX()[i], TMath::Abs(ratio));
}
std::cout << "\n Phase2ChiSqC setup completed " << std::endl;
TPaveText* pt = new TPaveText(0.5, 0.75, 0.8, 0.95);
std::ostringstream os("", std::ios::out|std::ios::app);
os << "a = " << params[0]->GetValue();
pt->AddText(os.str().data());
os.str("b = ");
os << params[1]->GetValue();
pt->AddText(os.str().data());
os.str("c = ");
os << params[2]->GetValue();
pt->AddText(os.str().data());
os.str("d = ");
os << params[3]->GetValue();
pt->AddText(os.str().data());
TH1* h = new TH2D("Ratio Comparison", "", 10, -1,1, 500, 0,100);
h->SetStats(0);
TCanvas* c = new TCanvas("c");
h->Draw();
gr->Draw("LP");
mygr->Draw("LP");
gPad->Modified();
c->Update();
TLegend *leg = new TLegend(0.5, 0.75, 0.8, 0.95);
leg->AddEntry(gr, "Fit", "PL");
leg->AddEntry(mygr, "Data", "PL");
leg->Draw();
return 0;
}
示例12: AnalyzeClipping
void AnalyzeClipping(TString inputWaveName = "sum trigger input ch5 960mV",
TString outputWaveName = "sum trigger output ch5 - 2V clip - 960mV input",
Double_t inputDelay = 1.1E-8, Double_t lowerCut = 16E-9, Double_t upperCut = 23E-9,
const char *inFile = "Data.root",const char *WaveformsFile = "Waveforms.root") {
//try to access data file and in case of failure return
if(gSystem->AccessPathName(inFile,kFileExists)) {
cout << "Error: file " << inFile << " does not exsist. Run .x DataParse.C to create it" << endl;
return;
}
TFile *f = TFile::Open(inFile);
TFolder *dataSet;
TString dataFolderS = "SumTriggerBoardData";
dataFolderS.Append(";1");
dataSet = (TFolder*)f->Get(dataFolderS);
cout << dataSet << endl;
cout << dataSet->GetName() << endl;
Int_t nScope = 150; // number of measurements done by the scope evey time
//try to access waveforms file and in case of failure return
if(gSystem->AccessPathName(WaveformsFile,kFileExists)) {
cout << "Error: file " << WaveformsFile << " does not exsist. Run .x WaveformsFileMaker.C to create it" << endl;
return;
}
TFile *f = TFile::Open(WaveformsFile);
TList *listOfKeys = f->GetListOfKeys();
Int_t numberOfKeys = listOfKeys->GetEntries();
TList *listOfGraphs = new TList();
// if the waveform file name begins with the string "comparator" it goes in this list
TList *listOfCompWaves = new TList();
// if the waveform file name begins with the string "sum output" it goes in this list
TList *listOfAdderWaves = new TList();
for(Int_t i = 0; i < numberOfKeys; i++) {
TString *keyName = new TString(listOfKeys->At(i)->GetName());
TTree *tree = (TTree*)f->Get(keyName->Data());
Float_t x = 0;
Float_t y = 0;
tree->SetBranchAddress("x",&x);
tree->SetBranchAddress("y",&y);
Int_t nentries = tree->GetEntries();
TString *gName = new TString(keyName->Data());
gName->Append(" graph");
TGraphErrors *gWave = new TGraphErrors(nentries);
gWave->SetName(gName->Data());
gWave->SetTitle(gName->Data());
gWave->GetXaxis()->SetTitle("Time");
gWave->GetYaxis()->SetTitle("Voltage");
for (Int_t j = 0; j < nentries; j++) {
tree->GetEntry(j);
gWave->SetPoint(j,x,y);
}
listOfGraphs->Add(gWave);
}
// Global variables
Double_t *xInput, *xOutput, *yInput, *yOutput;
// V input 960 mV
TString path = "Clipping/Output width analysis/Channel 5/V input 960mV/";
TGraphErrors *gClip960mV = TBGraphErrors(dataSet,path,"V clip","Output FWHM",1,nScope);
gClip960mV->SetMarkerStyle(20);
gClip960mV->SetMarkerSize(0.8);
gClip960mV->GetXaxis()->SetTitle("V clipping (mV)");
gClip960mV->GetYaxis()->SetTitle("Output FWHM (ns)");
TCanvas *cClip960mV = new TCanvas("cClip960mV","Output FWHM in function of V clipping",800,600);
gClip960mV->Draw("APEL");
// Expected output FWHM
TGraphErrors *gInput960mV = listOfGraphs->FindObject("sum trigger input ch5 960mV graph");
Double_t *xClip = gClip960mV->GetX();
Int_t nClip = gClip960mV->GetN();
cout << "nClip = " << nClip << endl;
Long64_t graphPoints = gInput960mV->GetN();
yInput = gInput960mV->GetY();
xInput = gInput960mV->GetX();
vector<double> xFirst(nClip);
vector<double> xLast(nClip);
Double_t half;
Int_t flag = 0;
//.........这里部分代码省略.........
示例13: softrad
//.........这里部分代码省略.........
c3->Divide(ntypes,nmethods);
TH1D *h3 = new TH1D("h3",";p_{T,ref} (GeV);FSR sensitivity: -dR/d#alpha [%]",
1270,30,1300);
cout << "Reading in data" << endl << flush;
// Read in plots vs pT (and alpha)
map<string, map<string, map<string, map<int, TGraphErrors*> > > > gemap;
map<string, map<string, map<string, map<int, TGraphErrors*> > > > gamap;
for (int itype = 0; itype != ntypes; ++itype) {
for (int imethod = 0; imethod != nmethods; ++imethod) {
for (int isample = 0; isample != nsamples; ++isample) {
for (int ialpha = 0; ialpha != nalphas; ++ialpha) {
fin->cd();
assert(gDirectory->cd(types[itype]));
assert(gDirectory->cd(bin));
TDirectory *d = gDirectory;
const char *ct = types[itype];
const char *cm = methods[imethod];
const char *cs = samples[isample];
const int a = alphas[ialpha];
// Get graph made vs pT
string s = Form("%s/%s/%s_%s_a%d",types[itype],bin,cm,cs,a);
TGraphErrors *g = (TGraphErrors*)fin->Get(s.c_str());
if (!g) cout << "Missing " << s << endl << flush;
assert(g);
// Clean out empty points
// as well as trigger-biased ones for dijets
// as well as weird gamma+jet high pT point
for (int i = g->GetN()-1; i != -1; --i) {
if (g->GetY()[i]==0 || g->GetEY()[i]==0 ||
(string(cs)=="dijet" && g->GetX()[i]<70.) ||
(string(cs)=="gamjet" && g->GetX()[i]>600. && etamin!=0))
g->RemovePoint(i);
}
gemap[ct][cm][cs][a] = g;
// Sort points into new graphs vs alpha
TH1D *hpt = (isample==0 ? hpt2 : hpt1);
TProfile *ppt = (isample==0 ? ppt2 : ppt1);
if (isample==3) { hpt = hpt4; ppt = ppt4; } // pas-v6
for (int i = 0; i != g->GetN(); ++i) {
double pt = g->GetX()[i];
ppt->Fill(pt, pt);
int ipt = int(hpt->GetBinLowEdge(hpt->FindBin(pt))+0.5);
//int ipt = int(pt+0.5);
TGraphErrors *ga = gamap[ct][cm][cs][ipt];
if (!ga) {
ga = new TGraphErrors(0);
ga->SetMarkerStyle(g->GetMarkerStyle());
ga->SetMarkerColor(g->GetMarkerColor());
ga->SetLineColor(g->GetLineColor());
gamap[ct][cm][cs][ipt] = ga;
}
int n = ga->GetN();
ga->SetPoint(n, 0.01*a, g->GetY()[i]);
ga->SetPointError(n, 0, g->GetEY()[i]);
} // for i
} // for ialpha
示例14: DrawKinvarPlot
void DrawKinvarPlot(TString filename="kinvarset/FMSOR_Pt_vs_run.root",
TString classname="pi0") {
TFile * infile = new TFile(filename.Data(),"READ");
char trig[32];
char typ[32];
char tmp[128];
TString tmpstr = filename;
tmpstr.ReplaceAll("_"," ");
TRegexp re("^.*\/");
tmpstr(re) = "";
cout << tmpstr << endl;
sscanf(tmpstr.Data(),"%s %s",trig,typ);
printf("%s %s\n",trig,typ);
TString hname = "h2_"+classname;
TH2D * h = (TH2D*)infile->Get(hname.Data());
TString gname = "g_"+classname;
TGraphErrors * g = (TGraphErrors*)infile->Get(gname.Data());
TString gtname = "gt_"+classname;
TGraphErrors * gt;
if(!strcmp(typ,"Pt")) gt = (TGraphErrors*)infile->Get(gtname.Data());
char htitle[256];
char hnewtitle[512];
strcpy(htitle,h->GetTitle());
sprintf(hnewtitle,"%s -- %s triggers",htitle,trig);
h->SetTitle(hnewtitle);
h->SetMinimum(0.001);
if(!strcmp(typ,"Pt")) {
gt->SetLineWidth(2);
gt->SetLineColor(kBlack);
};
// temporary hack to cut out fluctuations of pt_thresh vs. run to 0
Double_t xx,yy;
Int_t gtn = gt->GetN();
for(int ii=0; ii<gtn; ii++) {
gt->GetPoint(ii,xx,yy);
printf("xx=%f yy=%f\n",xx,yy);
if(yy<0.001) gt->RemovePoint(ii);
};
// drawing range
Float_t xmin = h->GetXaxis()->GetXmin();
Float_t xmax = h->GetXaxis()->GetXmax();
xmax = 515;
if(xmax<gtn) {
fprintf(stderr,"\nWARNING: xmax < gt->GetN(); graphs will be cut off!\n\n");
};
TCanvas * c = new TCanvas("c","c",1500,700);
c->Divide(1,2);
gStyle->SetOptStat(0);
for(int x=1; x<=2; x++) c->GetPad(x)->SetGrid(1,1);
c->cd(1);
c->GetPad(1)->SetLogz();
h->GetXaxis()->SetRangeUser(xmin,xmax);
h->Draw("colz");
if(!strcmp(typ,"Pt")) gt->Draw("LX");
c->cd(2);
g->SetFillColor(kGray);
printf("%f %f\n",xmin,xmax);
g->GetXaxis()->SetLimits(xmin,xmax);
g->GetXaxis()->SetRangeUser(xmin,xmax);
/*
g->Draw("A3");
g->Draw("PLX");
*/
g->Draw("APLX");
TString outname = filename.ReplaceAll(".root"," "+classname);
outname = outname+".png";
c->Print(outname.Data(),"png");
};
示例15: AnalyzeWaveforms
void AnalyzeWaveforms(char *WaveformsFile = "Waveforms.root", const int nAddedChannels = 5) {
//try to access waveforms file and in case of failure return
if(gSystem->AccessPathName(WaveformsFile,kFileExists)) {
cout << "Error: file " << WaveformsFile << " does not exsist. Run .x WaveformsFileMaker.C to create it" << endl;
return;
}
// gStyle->SetOptFit(111);
// gStyle->SetStatFormat("1.3E");
// gStyle->SetFitFormat("1.3E");
// fetch the list of trees contained in the waveforms file
// for every tree generate a waveform graph
TFile *f = TFile::Open(WaveformsFile);
TList *listOfKeys = f->GetListOfKeys();
Int_t numberOfKeys = listOfKeys->GetEntries();
TList *listOfGraphs = new TList();
// if the waveform file name begins with the string "comparator" it goes in this list
TList *listOfCompWaves = new TList();
// if the waveform file name begins with the string "sum output" it goes in this list
TList *listOfAdderWaves = new TList();
for(Int_t i = 0; i < numberOfKeys; i++) {
TString *keyName = new TString(listOfKeys->At(i)->GetName());
TTree *tree = (TTree*)f->Get(keyName->Data());
Float_t x = 0;
Float_t y = 0;
tree->SetBranchAddress("x",&x);
tree->SetBranchAddress("y",&y);
Int_t nentries = tree->GetEntries();
TString *gName = new TString(keyName->Data());
gName->Append(" graph");
TGraphErrors *gWave = new TGraphErrors(nentries);
gWave->SetName(gName->Data());
gWave->SetTitle(gName->Data());
gWave->GetXaxis()->SetTitle("Time");
gWave->GetYaxis()->SetTitle("Voltage");
// gWave->SetBit(TH1::kCanRebin);
for (Int_t j = 0; j < nentries; j++) {
tree->GetEntry(j);
gWave->SetPoint(j,x,y);
}
listOfGraphs->Add(gWave);
if(keyName->BeginsWith("comparator"))
listOfCompWaves->Add(gWave);
if(keyName->BeginsWith("sum output"))
listOfAdderWaves->Add(gWave);
/* TString *cName = new TString(keyName->Data());
cName->Append(" canvas");
TCanvas *cy = new TCanvas(cName->Data(),cName->Data(),800,600);
gWave->Draw("AL"); */
}
cout << listOfAdderWaves->GetEntries() << endl;
// analysis for waves with no delay
// global variables
Double_t xMin,xMax,yStart,yEnd;
Int_t graphPoints;
Double_t step;
// comparator outputs waves sum
TGraphErrors *gFirstCompWave = (TGraphErrors *)listOfCompWaves->First();
graphPoints = gFirstCompWave->GetN();
gFirstCompWave->GetPoint(0,xMin,yStart);
gFirstCompWave->GetPoint(graphPoints - 1,xMax,yEnd);
step = (xMax - xMin)/graphPoints;
cout << gFirstCompWave->GetName() << endl;
cout << "xMin = " << xMin << " xMax = " << xMax << " graphPoints = " << graphPoints << endl;
TGraphErrors *gCompSum = new TGraphErrors(graphPoints);
gCompSum->SetLineColor(kBlue);
gCompSum->SetLineWidth(2);
gCompSum->SetName("Comparator Outputs Sum");
gCompSum->SetTitle("Comparator Outputs Sum");
Int_t nCompWaves = listOfCompWaves->GetEntries();
Float_t gx,gy = 0;
// Alpha coefficiens are now written "hard coded" here
Float_t alphaArray[3] = {0.199,0.201,0.197};
// Deleays coming from the multiplexer are written "hard coded" here
Float_t muxDelayArray[3] = {0,77.14E-12,192.01E-12};
for(Int_t i = 0; i < graphPoints; i++) {
for(Int_t j = 0; j < nCompWaves; j++) {
TGraphErrors *gCompWave = (TGraphErrors *)listOfCompWaves->At(j);
//.........这里部分代码省略.........