本文整理汇总了C++中TList::First方法的典型用法代码示例。如果您正苦于以下问题:C++ TList::First方法的具体用法?C++ TList::First怎么用?C++ TList::First使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TList
的用法示例。
在下文中一共展示了TList::First方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main() {
TList *list = new TList();
printf_s("list.First() = %s\n", list->First());
printf_s("list.Pop() = %s\n", list->Pop());
list->Push("Hola");
printf_s("Pushed \"Hola\"!\n");
list->Push("Holita");
printf_s("Pushed \"Holita\"!\n");
list->Push("Que tal?");
printf_s("Pushed \"Que tal?\"!\n");
printf_s("list.Next() = %s\n", list->Next());
printf_s("list.Next() = %s\n", list->Next());
printf_s("list.Next() = %s\n", list->Next());
printf_s("list.Next() = %s\n", list->Next());
printf_s("list.First() = %s\n", list->First());
printf_s("list.Pop() = %s\n", list->Pop());
printf_s("list.First() = %s\n", list->First());
list->Push("Hola");
list->Reset();
printf_s("list reset!\n");
printf_s("list.First() = %s\n", list->First());
printf_s("list.Next() = %s\n", list->Next());
delete list;
getchar();
}
示例2: collectContours
void collectContours(map<string,TGraph2D *>& m_graphs,
const vector<string>& keys,
map<string,double>& m_contourlevels,
map<string,TList *>& m_contours)
{
cout << "CollectContours" << endl;
TCanvas *canv = new TCanvas("dummy","dummy",100,100);
//canv->Divide(3,2);
std::cout << "keys.size() = " << keys.size() << std::endl;
//process TGraph2Ds into contours at levels m_contourlevels
for (size_t i=0; i<keys.size(); i++) {
double clev = m_contourlevels[keys[i]];
TGraph2D *gr2d = m_graphs[keys[i]];
std::cout << "gr2d = " << gr2d << std::endl;
std::cout << "gr2d->GetN() = " << gr2d->GetN() << std::endl;
if (gr2d && (gr2d->GetN() > 0)) {
gr2d->GetHistogram()->SetContour(1, &clev);
//canv->cd(i+1);
cout << "drawing... " << endl;
gr2d->Draw("CONT LIST"); // it's stupid, but only "CONT" will generate the list
gPad->Update();
TObjArray *contours = (TObjArray *)gROOT->GetListOfSpecials()->FindObject("contours");
assert(contours);
TList *newlist = 0;
for (int ci=0; ci<contours->GetEntriesFast(); ci++) {
TList *contLevel = (TList*)contours->At(ci);
printf("%s: Contour %d has %d Graphs\n", keys[i].c_str(), ci, contLevel->GetSize());
if (contLevel->GetSize()) {
assert(contLevel->First());
if (!newlist) newlist = new TList();
TGraph *curv = (TGraph*)(contLevel->First());
for (int j=0; j<contLevel->GetSize(); j++) {
newlist->Add((TGraph *)(curv->Clone()));
curv=(TGraph *)(contLevel->After(curv));
}
}
} // contour loop
cout << "Inserting contour list for "<< keys[i] << " newlist="<<newlist<<endl;
m_contours[keys[i]] = newlist;
} // if (gr2d)
} // key loop
//delete canv;
} // collectContours
示例3: AddAllBaseConstructors
void KVClassFactory::AddAllBaseConstructors()
{
// Add constructors with the same signature as all base class constructors
// (apart from the default ctor or any copy constructors, which are a special case)
// By default, all constructors are 'public'.
if(!fBaseClass) return;
KVHashList clist;
clist.AddAll(fBaseClass->GetListOfMethods());
KVSeqCollection* constructors = clist.GetSubListWithName(fBaseClassName);
TIter next_ctor(constructors);
TMethod* method;
while( (method = (TMethod*)next_ctor()) )
{
if(!method->GetNargs()) continue; // ignore default ctor
TList* args = method->GetListOfMethodArgs();
TMethodArg* arg = (TMethodArg*)args->First();
TString typenam=arg->GetFullTypeName();
if(typenam.Contains(fBaseClassName)) continue; // ignore copy ctor
KVClassMethod* ctor;
if(arg->GetDefault()) ctor = AddConstructor( typenam, arg->GetName(), arg->GetDefault() );
else ctor = AddConstructor(typenam, arg->GetName());
for(int i=1; i<method->GetNargs(); i++){
arg = (TMethodArg*)args->At(i);
if(arg->GetDefault()) ctor->AddArgument( arg->GetFullTypeName(), arg->GetName(), arg->GetDefault() );
else ctor->AddArgument(arg->GetFullTypeName(), arg->GetName());
}
}
delete constructors;
}
示例4: iter
void TGo4LogInfo::linkedObjectUpdated(const char * linkname, TObject * obj)
{
TList* lst = dynamic_cast<TList*>(obj);
if (lst != 0) {
TListIter iter(lst, kFALSE);
TObject* obj = 0;
while ((obj = iter()) != 0) {
// first item is id of current status message, used to submit next request
if (obj==lst->First()) continue;
const char* msg = obj->GetName();
const char* separ = strchr(msg,':');
if ((separ==0) || (strlen(separ)<3)) continue;
Long64_t tm = TString(msg, separ-msg).Atoll();
QDateTime dt;
dt.setTime_t((time_t) tm);
separ++;
int level = 1;
if (*separ=='2') level=2; else
if (*separ=='3') level=3;
AddMessage(dt, level, separ+2);
}
} else
if (obj!=0) {
AddMessage(QDateTime::currentDateTime(), 0, obj->GetName());
}
}
示例5: compareHistos
void compareHistos( char *Current, char *Reference=0 ) {
TText* te = new TText();
te->SetTextSize(0.1);
TFile * curfile = new TFile( TString(Current)+".root" );
TFile * reffile = curfile;
if (Reference) reffile = new TFile(TString(Reference)+".root");
char * prefix="DQMData/MixingV/Mixing";
//1-Dimension Histogram
TDirectory * refDir=reffile->GetDirectory(prefix);
TDirectory * curDir=curfile->GetDirectory(prefix);
TList* list = refDir->GetListOfKeys();
TObject* object = list->First();
int iHisto = 0;
char title[50];
while (object) {
// find histo objects
std::cout << " object :" << object->GetName() << std::endl;
TProfile * h1 = dynamic_cast<TProfile*>( refDir->Get(object->GetName()));
TProfile * h2 = dynamic_cast<TProfile*>( curDir->Get(object->GetName()));
bool isHisto = (refDir->Get(object->GetName()))->InheritsFrom("TProfile");
std::cout << " isHisto = " << isHisto << std::endl;
if (isHisto && h1 && h2 && *h1->GetName()== *h2->GetName()) {
iHisto++;
char title[50];
// draw and compare
std::cout << " Start draw and compare" << std::endl;
TCanvas c1;
TProfile htemp2;
h2->Copy(htemp2);// to keep 2 distinct histos
h1->SetLineColor(2);
htemp2.SetLineColor(3);
h1->SetLineStyle(3);
h1->SetMarkerColor(3);
htemp2.SetLineStyle(5);
htemp2.SetMarkerColor(5);
TLegend leg(0.1, 0.15, 0.2, 0.25);
leg.AddEntry(h1, "Reference", "l");
leg.AddEntry(&htemp2, "New ", "l");
h1->Draw();
htemp2.Draw("Same");
leg.Draw();
sprintf(title,"%s%s", object->GetName(),".gif");
c1.Print(title);
}
// go to next object
object = list->After(object);
}
}
示例6: DoCompare
void DoCompare( char *Current, char *Reference=0 ){
TText* te = new TText();
te->SetTextSize(0.1);
gROOT->ProcessLine(".x HistoCompare.C");
HistoCompare * myPV = new HistoCompare();
TFile * curfile = new TFile( TString(Current)+".root" );
TFile * reffile = curfile;
if (Reference) reffile = new TFile(TString(Reference)+".root");
char * prefix="DQMData/MixingV/";
//1-Dimension Histogram
TDirectory * refDir=reffile->GetDirectory(prefix);
TDirectory * curDir=curfile->GetDirectory(prefix);
TList* list = refDir->GetListOfKeys();
TObject* object = list->First();
int iHisto = 0; char title[50];
while (object) {
// find histo objects
TH1F * h1 = dynamic_cast<TH1F*>( refDir->Get(object->GetName()));
TH1F * h2 = dynamic_cast<TH1F*>( curDir->Get(object->GetName()));
bool isHisto = (refDir->Get(object->GetName()))->InheritsFrom("TH1F");
if (isHisto && h1 && h2 && *h1->GetName()== *h2->GetName()) {
iHisto++;
char title[50];
// draw and compare
TCanvas c1;
TH1F htemp2;
h2->Copy(htemp2);// to keep 2 distinct histos
h1->SetLineColor(2);
htemp2.SetLineColor(3);
h1->SetLineStyle(3);
htemp2.SetLineStyle(5);
TLegend leg(0.1, 0.15, 0.2, 0.25);
leg.AddEntry(h1, "Reference", "l");
leg.AddEntry(&htemp2, "New ", "l");
h1->Draw();
htemp2.Draw("Same");
leg.Draw();
myPV->PVCompute(h1,&htemp2, te);
sprintf(title,"%s%s", object->GetName(),".eps");
c1.Print(title);
}
// go to next object
object = list->After(object);
}
}
示例7: ContourGraph
TGraph* ContourGraph( TH2F* hist,double xmin=16, double xmax=90) {
//temporary canvas
TCanvas* MOO = new TCanvas( TString::Format("dummy_canvas_%s", hist->GetName()), "A scan of m_{0} versus m_{12}", 0, 0, 650,640);
MOO->cd();
TGraph* gr0 = new TGraph();
TH2F* h = (TH2F*)hist->Clone();
TGraph* gr = (TGraph*)gr0->Clone(TString::Format("gr_%s", h->GetName()));
cout << "==> Will dumb histogram: " << h->GetName() << " into a graph" <<endl;
h->SetContour( 1 );
//h->GetXaxis()->SetRangeUser(250,1200);
h->GetXaxis()->SetRangeUser(xmin, xmax);
//h->GetYaxis()->SetRangeUser(2,50);
double pval = CombinationGlob::cl_percent[1];
std::cout << pval << std::endl;
double signif = TMath::NormQuantile(1-pval);
h->SetContourLevel( 0, signif );
h->Draw("CONT LIST");
h->SetDirectory(0);
gPad->Update();
TObjArray *contours = (TObjArray*) gROOT->GetListOfSpecials()->FindObject("contours");
Int_t ncontours = contours->GetSize();
cout << "Found " << ncontours << " contours " << endl;
TList *list = (TList*)contours->At(0);
contours->Print("v");
if(!list) return NULL;
gr = (TGraph*)list->First();
if(!gr) return NULL;
gr->SetName(TString::Format("gr_%s", hist->GetName()));
//gr->SetName(hist->GetName());
int N = gr->GetN();
double x0, y0;
for(int j=0; j<N; j++) {
gr->GetPoint(j,x0,y0);
cout << j << " : " << x0 << " : "<<y0 << endl;
}
// // gr->SetMarkerSize(2.0);
//gr->Draw("ALP");
delete MOO;
cout << "Generated graph " << gr << " with name " << gr->GetName() << endl;
return gr;
}
示例8: getTreeList
TList PlotAlignmentValidation::getTreeList()
{
TList treeList = new TList();
TFile *first_source = (TFile*)sourcelist->First();
std::cout<<first_source->GetName()<<std::endl;
TDirectoryFile *d=(TDirectoryFile*)first_source->Get( treeBaseDir.c_str() );
treeList.Add( (TTree*)(*d).Get("TkOffVal") );
if( moreThanOneSource ==true ){
TFile *nextsource = (TFile*)sourcelist->After( first_source );
while ( nextsource ) {
std::cout<<nextsource->GetName()<<std::endl;
d=(TDirectoryFile*)nextsource->Get("TrackerOfflineValidation");
treeList.Add((TTree*)(*d).Get("TkOffVal"));
nextsource = (TFile*)sourcelist->After( nextsource );
}
}return treeList;
}
示例9: StackLegend
/**
* Get or create a stack legend. This is done by adding a TLegend
* object to the list of functions for the first histogram in the
* stack.
*
* @param stack Stack to get the legend from/modify
*
* @return The legend object or null
*/
TLegend* StackLegend(THStack* stack)
{
TList* hists = stack->GetHists();
if (!hists) return 0;
TObject* first = hists->First();
if (!first) return 0;
TH1* hist = static_cast<TH1*>(first);
TList* list = hist->GetListOfFunctions();
TObject* o = list->FindObject("legend");
if (o) return static_cast<TLegend*>(o);
TLegend* l = new TLegend(0.65, 0.65, 0.9, 0.9, "", "NDC");
l->SetName("legend");
l->SetBorderSize(0);
l->SetFillColor(0);
l->SetFillStyle(0);
l->SetTextFont(42);
list->Add(l);
return l;
}
示例10: getContours
TList* getContours(const TH2* hist,double contourLevel,const TString filename)
{
TH2* h = (TH2*)hist->Clone("_clone");
double limitValue[1] = {contourLevel};
h->SetContour(1,limitValue);
TCanvas* c = new TCanvas("contour_canvas","Contour List",0,0,600,600);
h->Draw("CONT LIST");
c->Update();
TList* contours = (TList*)((TObjArray*)gROOT->GetListOfSpecials()->FindObject("contours"))->At(0);
TGraph* contour = (TGraph*)contours->First();
if(filename!="")
{
for(unsigned int j = 0; j < contours->GetSize(); j++)
{
TString newFilename = filename+"_";
newFilename+=j;
contour->SaveAs(newFilename+".C");
contour = (TGraph*)contours->After(contour); // Get Next graph
}
}
delete h;
delete c;
return contours;
}
示例11: merge
void merge(TString outfile, TString firstfile, TString pat=defaultPattern)
{
TList decayModes;
bool save=false;
TString dir=".";
TString first="";
long flags=0,id=0,size=0,modtime=0;
if(firstfile.Contains("~"))
{
cout<<"ERROR: input path cannot contain '~' character."<<endl;
return;
}
// Check pattern
TRegexp pattern(pat,true);
if(pattern.Status()!=0)
{
cout<<"ERROR: Wrong regular expression."<<endl;
return;
}
// Load libraries
loadLibs();
gSystem->GetPathInfo(firstfile, &id, &size, &flags, &modtime);
bool isDirectory = flags&2;
if(isDirectory)
{
dir=firstfile;
first="";
}
else
{
//Separate directory from filename
int separator=firstfile.Last('/');
if(separator!=-1) dir=firstfile(0,separator+1);
first=firstfile(separator+1,firstfile.Length());
}
cout<<"Output file: "<<outfile<<endl;
cout<<"Input dir: "<<dir<<endl;
if(!isDirectory) cout<<"First file: "<<first<<endl;
cout<<endl;
// Get file list and add first file if present
TList *files = getFileList(first,dir,pattern);
if(!isDirectory)
{
TFile *ff = new TFile(firstfile,"READ");
files->AddBefore(files->First(),ff);
}
// Merge files
TIter next(files);
TFile *file;
while(file = (TFile*)next())
{
if(!file->IsOpen()) continue;
ReadFile(file,decayModes);
cout<<"=============================="<<endl;
save=true;
}
// Save output
if(save)
{
cout<<"Saving..."<<endl;
SaveOutput(outfile,decayModes);
cout<<"Output saved to "<<outfile<<endl<<endl;
}
else cout<<"Nothing to save."<<endl<<endl;
// Closing files
cout<<"Closing files..."<<endl;
TIter cl(files);
while(file = (TFile*)cl()) { file->Close(); delete file; }
delete files;
gSystem->Exit(0);
}
示例12: ttreesToHistograms
//.........这里部分代码省略.........
}
cout << endl << endl;
// Open the files & set their scales
cout << endl << "Histograms will be scaled to " << invLuminosityToScaleTo << "pb-1 " << endl;
cout << "Looking for TTree named \"" << treeName << "\" in files..." << endl;
vector<float> fileScale;
TList *fileList = new TList();
for (int i=0; i < fileName.size(); i++) {
TFile* currentFile = TFile::Open(fileName[i]);
fileList->Add(currentFile);
float currentScale = crossSection[i]*invLuminosityToScaleTo*filterEffeciency[i]/eventsAnalyzied[i];
fileScale.push_back( currentScale );
// Display entries in that file's TTree
TTree* tree;
currentFile->GetObject(treeName, tree);
cout << "file" << i <<": " << fileName[i] << " contains " << tree->GetEntries(allCuts) << " entries, and will be scaled by " <<
currentScale << endl;
}
cout << endl << endl;
//Create output file
TFile *outputFile = TFile::Open( outputFileName, "RECREATE" );
//************************************************************
// Core of the Script //
// Loop over locations
for (int l=0; l<locationName.size(); l++) {
TString currentLocation = locationName[l];
TCut currentCuts = allCuts;
currentCuts += locationCut[l];
cout << "Creating plots for " << currentLocation << ", " << locationCut[l] << endl;
// Loop over variables to plot
for (int i=0; i<variableToPlot.size(); i++) {
// should we plot this variable for this location?
if (i<locationVariablesToPlot[l][0] || i>locationVariablesToPlot[l][1]) continue;
TString currentHistType = histogram[i]->IsA()->GetName();
TString currentHistName = TString(histogram[i]->GetName()) + "_" + currentLocation;
TString currentHistTitle = TString(histogram[i]->GetTitle()) + "(" + currentLocation + ")";
cout << " " << variableToPlot[i] << " >> " << currentHistName;
TString currentHistDrawOpt;
if (currentHistType=="TH2F") {
currentHistDrawOpt="goffbox";
} else {
currentHistDrawOpt="egoff";
}
TH1* currentHist = (TH1*)histogram[i]->Clone(currentHistName); // Creates clone with name currentHistName
currentHist->Sumw2(); // store errors
currentHist->SetTitle(currentHistTitle);
//cout << " from file";
// Plot from the first file
int f = 0;
//cout << f;
TTree *tree;
TFile *current_file = (TFile*)fileList->First();
current_file->cd();
current_file->GetObject(treeName, tree);
tree->Draw(variableToPlot[i]+">>"+currentHistName,currentCuts+TCut(fileCuts[f]),currentHistDrawOpt);
currentHist->Scale(fileScale[f]);
f++;
// Loop over files
current_file = (TFile*)fileList->After( current_file );
while ( current_file ) {
current_file->cd();
//cout << ", file" << f;
current_file->GetObject(treeName, tree);
TString tempHistName = currentHistName+"Temp";
TH1* tempHist = (TH1*)currentHist->Clone(tempHistName);
tree->Draw(variableToPlot[i]+">>"+tempHistName,currentCuts+TCut(fileCuts[f]),currentHistDrawOpt);
tempHist->Scale(fileScale[f]);
currentHist->Add(tempHist);
tempHist->Delete();
current_file = (TFile*)fileList->After( current_file );
f++;
} // End of loop over files
outputFile->cd();
currentHist->Write();
cout << endl;
} // End of loop over variabls to plot
} // End of loop over locations
// END of Core of Script //
//************************************************************
cout << endl;
cout << "Wrote file " << outputFileName << endl;
cout << endl;
outputFile->Close();
}
示例13: createMFOutfile
//.........这里部分代码省略.........
}
}
f->Close();
output->cd();
output->Close();
// if we want to interpolate, start making more histograms
if(interpolate) {
// Have to reopen the outfile because ROOT is odd
TFile *output2 = new TFile(outfileName, "UPDATE");
output2->cd();
std::pair<double,TString> maxPair = *moreFiles.begin();
double maxWidth = maxPair.first;
// check that it makes sense to interpolate with our settings
if(maxWidth <= nominalWidth) {
cout<<"\n\nERROR: Max width is less than or equal to the nominal width! Exiting."<<endl;
exit(EXIT_FAILURE);
}
// open the input file and loop through the relevant directories
TFile *maxFile = new TFile(maxPair.second);
for(int i=0; i<lepsSize; i++) {
// change directory and get the name of the folder we want to access
maxFile->cd();
char a[128];
sprintf(a, "mlbwa_%s_Mlb", leps[i]);
TDirectory *tDir = (TDirectory*) maxFile->Get(a);
TList *alok = tDir->GetListOfKeys();
// get the maxWidth histogram in this folder, clone and rename it
TString maxHName = alok->First()->GetName();
TString maxCloneName = formatName(maxHName, maxWidth);
TH1F *maxHisto = (TH1F*) tDir->Get(maxHName);
TH1F *maxClone = (TH1F*) maxHisto->Clone(maxCloneName);
// write this max histogram to the outfile
output2->cd();
maxClone->Write();
// get the corresponding nominal histogram from the outfile
TH1F *nomHisto = (TH1F*) output2->Get(formatName(maxHName,nominalWidth));
TCanvas *c = new TCanvas("");
nomHisto->Draw();
c->SaveAs(formatName(maxHName,nominalWidth)+TString(".pdf"));
// for each interpolation, create a morphed histogram and write to outfile
for(int i=interpolations; i>0; i--) {
double tWidth = nominalWidth + i*(maxWidth - nominalWidth)/(interpolations+1);
TString interpName = formatName(maxHName, tWidth);
TH1F *interpHisto = (TH1F*) th1fmorph(interpName, interpName,nomHisto,maxHisto,
nominalWidth,maxWidth,tWidth,nomHisto->Integral(),1);
interpHisto->Write();
}
}
maxFile->cd();
maxFile->Close();
output2->cd();
output2->Close();
// Otherwise, we want to collect signal histograms of different weights
示例14: TCanvas
void
draw2DLimitContours(map<string,TList *>& m_contours,
const TString& par1,
const TString& par2,
const TString& plotprefix,
TLegend *legend)
{
//from here we build the two-dimensional aTGC limit
TCanvas *finalPlot = new TCanvas("final","limits",500,500);
finalPlot->cd();
cout << "Drawing expected 68%" << endl;
TList *contLevel = m_contours["exp68"];
TGraph *curv;
std::cout << "m_contours.size() = " << m_contours.size() << std::endl;
for (map<string,TList *>::const_iterator iter = m_contours.begin(); iter != m_contours.end(); iter++ ){
std::cout << "iter->first = " << iter->first << std::endl;
std::cout << "iter->second = " << iter->second << std::endl;
}
std::cout << "contLevel = " << contLevel << std::endl;
assert(contLevel);
curv = (TGraph*)(contLevel->First());
curv->GetXaxis()->SetLimits(parmin(par1),parmax(par1));
curv->GetYaxis()->SetRangeUser(parmin(par2),parmax(par2));
curv->SetTitle();
curv->GetXaxis()->SetTitle(par2latex(par1));
curv->GetXaxis()->SetTitleFont(42);
curv->GetYaxis()->SetTitle(par2latex(par2));
curv->GetYaxis()->SetTitleFont(42);
curv->GetYaxis()->SetTitleOffset(1.20);
for (int i=0; i<contLevel->GetSize(); i++) {
assert(curv);
curv->SetLineColor(kBlue);
curv->SetLineWidth(2);
curv->SetLineStyle(9);
if (!i) {
curv->Draw("AC");
legend->AddEntry(curv,"Expected 68% C.L.","L");
} else
curv->Draw("SAME C");
curv=(TGraph *)(contLevel->After(curv));
}
cout << "Drawing expected 95%" << endl;
contLevel = m_contours["exp95"];
curv = (TGraph*)(contLevel->First());
for (int i=0; i<contLevel->GetSize(); i++) {
curv->SetLineColor(kGreen);
curv->SetLineWidth(2);
curv->SetLineStyle(9);
curv->Draw("SAME C");
if (!i) legend->AddEntry(curv,"Expected 95% C.L.","L");
curv=(TGraph *)(contLevel->After(curv));
}
cout << "Drawing expected 99%" << endl;
contLevel = m_contours["exp99"];
curv = (TGraph*)(contLevel->First());
for (int i=0; i<contLevel->GetSize(); i++) {
curv->SetLineColor(kRed);
curv->SetLineWidth(2);
curv->SetLineStyle(9);
curv->Draw("SAME C");
if (!i) legend->AddEntry(curv,"Expected 99% C.L.","L");
curv=(TGraph *)(contLevel->After(curv));
}
contLevel = m_contours["obs95"];
if (contLevel) {
cout << "Drawing obs95" << endl;
curv = (TGraph*)(contLevel->First());
for (int i=0; i<contLevel->GetSize(); i++) {
curv->Draw("SAME C");
curv->SetLineWidth(2);
if (!i) legend->AddEntry(curv,"Observed 95% C.L.","L");
curv=(TGraph *)(contLevel->After(curv));
}
}
TGraph *SMpoint = new TGraph(1);
//.........这里部分代码省略.........
示例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);
//.........这里部分代码省略.........