本文整理汇总了C++中TGraphErrors::GetName方法的典型用法代码示例。如果您正苦于以下问题:C++ TGraphErrors::GetName方法的具体用法?C++ TGraphErrors::GetName怎么用?C++ TGraphErrors::GetName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TGraphErrors
的用法示例。
在下文中一共展示了TGraphErrors::GetName方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: spectra_mw
void spectra_mw(const char *prefix = "pt/PhiNsigma_KTPCnsig30_STD2010_00_DEFAULT_00")
{
TGraphErrors *g = ReadMWGraph(Form("%s/mass", prefix), 1);
g->Draw("ACP");
TLatex latex;
latex.SetTextFont(42);
latex.SetTextAlign(12);
latex.SetTextSize(0.03);
latex.SetTextColor(kBlue+1);
latex.DrawLatex(1.2, 1.01877, "MC generated");
latex.SetTextColor(kGreen+1);
latex.DrawLatex(1.2, 1.01877-0.00015, "MC reconstructed");
latex.SetTextColor(kRed+1);
latex.DrawLatex(1.2, 1.01877-2*0.000155, "Real data (uncorrected)");
latex.SetTextColor(kBlack);
latex.DrawLatex(1.2, 1.01877-3*0.00016, "Real data (corrected)");
gPad->Print(Form("%s.pdf", g->GetName()));
gPad->Clear();
gPad->SetLogy(0);
TGraphErrors *g = ReadMWGraph(Form("%s/mass", prefix), 3);
g->Draw("AP");
latex.SetTextAlign(22);
latex.SetTextSize(0.04);
latex.SetTextColor(kBlack);
latex.DrawLatex(2.0, 1.0207, "pp @ #sqrt{s} = 2.76 TeV");
latex.DrawLatex(2.0, 1.0205, "TPC 3.0 #sigma");
latex.DrawLatex(2.0, 1.0202, "#phi #rightarrow K^{ +} K^{ -}");
latex.SetTextSize(0.035);
latex.DrawLatex(1.7, 1.0182, "uncertainties: stat. (bars) & syst. (boxes)");
gPad->Print(Form("%s.pdf", g->GetName()));
gPad->Clear();
TGraphErrors *g = ReadMWGraph(Form("%s/width", prefix), 2);
g->Draw("AP");
TLatex latex;
latex.SetTextAlign(22);
latex.SetTextSize(0.04);
latex.SetTextColor(kBlack);
latex.DrawLatex(1.7, 0.0090, "pp @ #sqrt{s} = 2.76 TeV");
latex.DrawLatex(1.7, 0.0085, "TPC 3.0 #sigma");
latex.DrawLatex(1.7, 0.0077, "#phi #rightarrow K^{ +} K^{ -}");
latex.SetTextSize(0.035);
latex.DrawLatex(1.7, 0.0007, "uncertainties: stat. (bars) & syst. (boxes)");
gPad->Print(Form("%s.pdf", g->GetName()));
// gPad->Clear();
// gPad->SetLogy();
// TGraphErrors *g = ReadPtGraphSys("pt/out.txt");
// if (!g) return;
// g->Draw("AP");
// gPad->Print(Form("%s.pdf", g->GetName()));
}
示例2: if
//.........这里部分代码省略.........
nextReferencePartition = yCoordinate;
int firstRef = vectorOfReferenceChambers.at(0);
int lastRef = vectorOfReferenceChambers.at(vectorOfReferenceChambers.size() - 1);
int ccham = currentChNumber+1;
if(! (lastRef > ccham && firstRef < ccham) ){
// all partitions are possible, chambers are out of the reference scope
prevReferencePartition = this->getChamberNumber(1)->getClones();
nextReferencePartition = 1; // 3 in case of ecap chamber
}
}
if (positive){ startCounter = prevReferencePartition; endCounter = nextReferencePartition; }
else { startCounter = nextReferencePartition ; endCounter = prevReferencePartition ; }
for (int currentCounter = startCounter ; currentCounter <= endCounter; currentCounter ++ ){
assert(currentCounter > 0 && currentCounter < 4);
vectorOfpartitionsAndHit.push_back(currentCounter);
}
}
else{
vectorOfpartitionsAndHit.push_back(this->getChamberNumber(currentChNumber+1)->getXYCoordinatesOfCluster(clusterNum[referenceChambersIncrementor]).at(1));
referenceChambersIncrementor ++;
}
prevReference = 0 ; nextReference = 0 ; prevReferencePartition = 0 ; nextReferencePartition = 0; currentChamberIsReference = false;
//cout << "Chamber " << l+1 << " " << coordinates.at(1) << " " << fitfunc->Eval(l+1) << " " << endl;
int channelNumberToStore = channelNum;
if (channelNumberToStore < 96/this->getChamberNumber(1)->getClones()){
channelNumberToStore += 1;
} // add one to represent the fired channel, or none if the channel is on the right border
vectorOfpartitionsAndHit.push_back(channelNumberToStore); // the last element is the number of the channel
// Debug lines
/**
cout << "Chamber is " << currentChNumber+1 << " partitions " ;
for (int thesize = 0 ; thesize < vectorOfpartitionsAndHit.size() - 1; thesize++){
cout << vectorOfpartitionsAndHit.at(thesize) << " " ;
}
cout << "channel " << vectorOfpartitionsAndHit.at(vectorOfpartitionsAndHit.size()-1) << endl;
*/
mapOfHits[currentChNumber+1] = vectorOfpartitionsAndHit;
}
// ---------- scintilators coordinates estimate
for (int scintNum = 0 ; scintNum < 31 ; scintNum++){
if(this->getTriggerObjectNumber(1)->getChannel(scintNum+1)->hasHit() && vectorOfClusterNumberCombinations.size() == 1 ) {
if (scintNum < 10) { scintilatorsCoordinates[scintNum+1] = graphXZ->Eval(0); topScintToString = boost::lexical_cast<string>(scintNum+1); }
else { scintilatorsCoordinates[scintNum+1] = graphXZ->Eval(lastFitPoint+1); botScintToString = boost::lexical_cast<string>(scintNum+1); }
}
}
}
// get only vertical tracks from the A partition if there are only two scint hits
if (keepRecoTrack && isVerticalTrack && !mapOfHits.empty() && scintilatorsCoordinates.size() == 2){
graphXZ->SetName(boost::lexical_cast<string>(eventNum).c_str());
string partition;
if (mapOfHits.find(vectorOfReferenceChambers.at(0))->second.at(0) == 1) partition = "A";
else if (mapOfHits.find(vectorOfReferenceChambers.at(0))->second.at(0) == 2) partition = "B";
else partition = "C";
graphXZ->SetTitle(("Correlation factor is "+boost::lexical_cast<string>(graphXZ->GetCorrelationFactor()) + " trigger channels top: " + topScintToString + " bottom: " + botScintToString ).c_str());
if(abs(graphXZ->GetCorrelationFactor()) >= correlationFactor) {
string scintCombination="_"+topScintToString+"_"+botScintToString+"_"+partition;
TDirectory * dir = fileForRecoTracks->GetDirectory(scintCombination.c_str(),true);
if(!dir) {
//fileForRecoTracks->ls();
fileForRecoTracks->mkdir(scintCombination.c_str()) ;
fileForRecoTracks->cd("");
}
fileForRecoTracks->cd(scintCombination.c_str());
//cout << fileForRecoTracks->GetPath() << endl;
}
else{ fileForRecoTracks->cd("") ; fileForRecoTracks->cd("badTracks") ; }
graphXZ->Write(graphXZ->GetName(),TObject::kOverwrite);
fileForRecoTracks->cd("");
//fileForRecoTracks->Write(graphXZ->GetName(),TObject::kOverwrite);
}
fitfunc->Delete();
//histXZ->Delete();
graphXZ->Delete();
}
return mapOfHits;
}
示例3: joingraphsX
//========================================================================
void joingraphsX(const char* myname, const char* g1 , int autocolors=1 ){
TMultiGraph *mg;
TString myname2=myname;
myname2.ReplaceAll(".","_");
myname2.ReplaceAll(" ","_");
myname2.ReplaceAll("_mysql_dat","_mysql_MG");
if ( ( gROOT->GetListOfSpecials()->FindObject(myname2.Data()) ) ||
((gPad!=NULL)&&(gPad->FindObject(myname2.Data()) )) ){
mg=(TMultiGraph*)gROOT->GetListOfSpecials()->FindObject( myname2.Data() );
if (mg==NULL){mg=(TMultiGraph*)gPad->FindObject( myname2.Data() );}
printf("JG...TMultiGraph %s found...\n",myname2.Data() );
}else{
printf("JG...TMultiGraph %s created\n",myname2.Data() );
mg=new TMultiGraph();
mg->SetNameTitle(myname2.Data(),myname2.Data());
gROOT->GetListOfSpecials()->Add( mg );
}
TGraphErrors *o;
o=(TGraphErrors*)gROOT->GetListOfSpecials()->FindObject( g1 );
if (o==NULL){ o=(TGraphErrors*)gDirectory->FindObject( g1 ); }
if (o==NULL){
printf("JG...graph %ld NOT found...\n", (int64_t)g1 );
}else{
int ent=0;
if ( mg->GetListOfGraphs()!=NULL){
ent=mg->GetListOfGraphs()->GetEntries();
}
// ent=1;
printf("JG...multigraph entries =%d\n", ent);
// if (mg->GetListOfGraphs()->FindObject(o->GetTitle())==NULL){
TGraphErrors *grexi=NULL;
TList *glog= mg->GetListOfGraphs();
if (glog!=NULL){grexi=(TGraphErrors*)glog->FindObject(o->GetName()) ;}
printf("JG...TEST1 Graph name %s ---------------\n",
o->GetName() );
if (grexi!=NULL){
int col=grexi->GetLineColor();
printf("JG...Graph name %s exists, color=%d doing nothing\n", o->GetName() , col );
printf("%s\n","JG removing");
mg->RecursiveRemove(grexi);
printf("%s\n","JG adding");
mg->Add( (TGraphErrors*)o , "PL" ) ;
o->SetLineColor(col);
o->SetMarkerColor(col);
}else{
// printf("TEST2 Graph name %s not yet in MG\n",o->GetName() );
if (autocolors==1){ // for new
// printf("setting autocolor %d\n", ent);
o->SetLineColor(ent+1);
o->SetMarkerColor(ent+1);
}else{
// printf("NO autocolor (graphs=%d)\n", ent);
}
// char oname[100];
// sprintf(oname,"%s",o->GetName());
// printf("%s /%s/\n", "JG... looking for duplicity", oname );
// TObject *dupl=NULL;
// if ( (o!=NULL)&&(mg->GetListOfGraphs()!=NULL)){ dupl=(TObject*)mg->GetListOfGraphs()->FindObject( oname ); }
// printf("%s\n", "JG... looking for duplicity" );
// if (dupl!=NULL){
// printf("%s\n", "JG... duplicite found" );
// for (int i=0;i<mg->GetListOfGraphs()->GetEntries();i++){
// if (mg->GetListOfGraphs()->At(i)==dupl){
// mg->GetListOfGraphs()->RemoveAt(i);
// break;
// }
// }
// }
printf("%s\n", "JG... adding the object" );
mg->Add( (TGraphErrors*)o , "PL" ) ;
}//=========else NEW
double ttmax=0.,ttmin=0.;
for (int i=0;i<mg->GetListOfGraphs()->GetEntries();i++){
printf("JG... %d. %10s, total=%d\n", i,
mg->GetListOfGraphs()->At(i)->GetName(),mg->GetListOfGraphs()->GetEntries() );
TGraphErrors *ge=(TGraphErrors*)mg->GetListOfGraphs()->At(i);
int n = ge->GetN();
double* x = ge->GetX();
int locmin = TMath::LocMin(n,x);
double tmin = x[locmin];
int locmax = TMath::LocMax(n,x);
double tmax = x[locmax];
if (ttmin==ttmax){ttmax=tmax;ttmin=tmin;}
// printf("%f - %f\n", tmin, tmax);
if (ttmax<tmax){ttmax=tmax;}
if (ttmin>tmin){ttmin=tmin;}
// printf("%d. %s\n", i, mg->GetListOfGraphs()->At(i)->GetTitle() );
}// for all graphs
if (mg->GetXaxis()!=NULL){ // if not drawn, no possibility to change-refresh!
mg->GetXaxis()->SetLimits( ttmin,ttmax );
mg->GetXaxis()->SetTimeDisplay(1);
mg->GetXaxis()->SetTimeFormat("#splitline{%d.%m}{%H:%M}");
//.........这里部分代码省略.........
示例4: 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);
//.........这里部分代码省略.........