本文整理汇总了C++中TList::Add方法的典型用法代码示例。如果您正苦于以下问题:C++ TList::Add方法的具体用法?C++ TList::Add怎么用?C++ TList::Add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TList
的用法示例。
在下文中一共展示了TList::Add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetListOfTitles
UInt_t GetListOfTitles( TDirectory *rfdir, TList & titles )
{
// get a list of titles (i.e TDirectory) given a method dir
UInt_t ni=0;
if (rfdir==0) return 0;
TList *keys = rfdir->GetListOfKeys();
if (keys==0) {
cout << "+++ Directory '" << rfdir->GetName() << "' contains no keys" << endl;
return 0;
}
//
TIter rfnext(rfdir->GetListOfKeys());
TKey *rfkey;
titles.Clear();
titles.SetOwner(kFALSE);
while ((rfkey = (TKey*)rfnext())) {
// make sure, that we only look at histograms
TClass *cl = gROOT->GetClass(rfkey->GetClassName());
if (cl->InheritsFrom("TDirectory")) {
titles.Add(rfkey);
ni++;
}
}
cout << "--- Found " << ni << " instance(s) of the method " << rfdir->GetName() << endl;
return ni;
}
示例2: fullCombination
void fullCombination(const bool electrons = false)
{
TString type("_muons");
if( electrons ) type = "_electrons";
std::map<TString, TList*> cathegories;
// Loop over all files
std::map<TString, double> fw(filesAndWeightsMap( electrons ));
std::map<TString, double>::const_iterator it = fw.begin();
for( ; it != fw.end(); ++it ) {
TString cathegory(getCategory(it->first));
if( cathegories[cathegory] == 0 ) cathegories[cathegory] = new TList();
std::cout << "fileName = " << std::string(it->first).substr(std::string(it->first).find_last_of("/")+1)+"weighted"+type+".root" << std::endl;
cathegories[cathegory]->Add( TFile::Open(std::string(it->first).substr(std::string(it->first).find_last_of("/")+1)+"weighted"+type+".root") );
}
TList * combinationsList = new TList();
std::map<TString, TList*>::const_iterator it2 = cathegories.begin();
for( ; it2 != cathegories.end(); ++it2 ) {
TFile *Target = TFile::Open( it2->first+"_combined"+type+".root", "RECREATE" );
std::cout << "fileName = " << it2->first << std::endl;
combinationsList->Add( Target );
mergeFiles( Target, it2->second );
}
}
示例3: GetListOfJobs
UInt_t GetListOfJobs( TFile* file, TList& jobdirs)
{
// get a list of all jobs in all method directories
// based on ideas by Peter and Joerg found in macro deviations.C
TIter next(file->GetListOfKeys());
TKey *key(0);
while ((key = (TKey*)next())) {
if (TString(key->GetName()).BeginsWith("Method_")) {
if (gROOT->GetClass(key->GetClassName())->InheritsFrom("TDirectory")) {
TDirectory* mDir = (TDirectory*)key->ReadObj();
TIter keyIt(mDir->GetListOfKeys());
TKey *jobkey;
while ((jobkey = (TKey*)keyIt())) {
if (!gROOT->GetClass(jobkey->GetClassName())->InheritsFrom("TDirectory")) continue;
TDirectory *jobDir = (TDirectory *)jobkey->ReadObj();
cout << "jobdir name " << jobDir->GetName() << endl;
jobdirs.Add(jobDir);
}
}
}
}
return jobdirs.GetSize();
}
示例4: main
int main(int argc, char *argv[])
try
{
// Test if sufficient number of arguments is specified.
if (5 > argc)
throw std::invalid_argument("usage: merge luminosity out.root in.root [more_in.root]");
std::auto_ptr<TRint> application(new TRint("histInMemory", 0, 0));
TFile *output = 0;
TList *inputs = 0;
try
{
::luminosity = lexical_cast<double>(argv[1]);
if (0 >= ::luminosity)
throw std::runtime_error("Non-positive luminosity is specified");
// Create output file
output = new TFile(argv[2], "RECREATE");
if (!output->IsOpen())
throw std::runtime_error("Failed to open output file");
// open specified input files to the List
//
inputs = new TList();
cout << "Inputs" << endl;
for( int i = 3; argc > i; ++i)
{
cout << " [+] " << argv[i] << endl;
inputs->Add(TFile::Open(argv[i]));
}
// Call merge
MergeRootfile(output, inputs);
// memory cleanup
delete inputs;
delete output;
}
catch(const std::exception &error)
{
// memory cleanup in case of error
if (inputs)
delete inputs;
if (output)
delete output;
throw;
}
return 0;
}
catch(const std::exception &error)
{
cerr << error.what() << endl;
return 1;
}
示例5: MakeFourView
//_______________________________________________________________________________________
void MakeFourView(TVirtualPad *pad=0)
{
// Creates 4 pads view of the pad (or qPad)
// ------------------------------
// | | |
// | | |
// | | |
// | Front | Top |
// | view | view |
// | | |
// | | |
// | | |
// ---------------+-------------
// | | |
// | | |
// | | |
// | Side | Spacial |
// | view | view |
// | | |
// | | |
// | | |
// ------------------------------
// begin_html <P ALIGN=CENTER> <IMG SRC="gif/FourStarView.gif" ></P> end_html
//
TVirtualPad *thisPad = pad;
if (!thisPad) thisPad = qPad();
TView *view = 0;
TList *thisPrimitives = 0;
if (thisPad && (thisPrimitives = thisPad->GetListOfPrimitives()) && (view = thisPad->GetView()) )
{
Double_t min[3],max[3];
view->GetRange(min,max);
Int_t system = view->GetSystem();
TCanvas *c = new TCanvas(" 4 views", thisPad->GetTitle(),600,600);
c->Divide(2,2);
TIter *next= new TIter(thisPrimitives);
for (int i =1; i <= 4; i++) {
c->cd(i);
TList *newPrimitives = qPad()->GetListOfPrimitives();
TObject *obj = 0;
while (obj = next->Next()) newPrimitives->Add(obj);
TView *newView = new TView(system);
newView->SetRange(min,max);
next->Reset();
}
delete next;
// set separate view;
// Fron view
Int_t j = 1;
c->cd(j++); FrontView();
c->cd(j++); TopView();
c->cd(j++); SideView();
c->cd(j++); RotateView(-30.0,60.0,0);
c->Modified();
c->Update();
}
}
示例6: 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
示例7: GetMonitorObjects
/**
* Get the list of monitored objects
*
* @return The list of monitored objects
*/
virtual TList* GetMonitorObjects()
{
TObject* m1 = new TNamed("dNdy", "");
m1->SetUniqueID(0x8); // Scale
TList* ret = new TList;
ret->Add(m1);
return ret;
}
示例8: compareDYTemplates
void compareDYTemplates(TString baseURL="~/scratch0/top-newjec/syst_plotter.root")
{
TString ch[]={"ee","mumu"};
TString categs[]={"eq1jets",""};
for(size_t ich=0; ich<2; ich++)
{
for(size_t icat=0; icat<2; icat++)
{
TObjArray lowMet = getDistributionFromPlotter(ch[ich]+"_"+categs[icat]+"lowmetdilarccosine",baseURL);
TH1 *lowMetH = (TH1 *) ((TList *)lowMet.At(3))->At(3);
formatPlot(lowMetH,1,1,1,24,0,false,false,1,1,1);
lowMetH->SetTitle("E_{T}^{miss}<30 GeV/c^{2}");
lowMetH->Scale(1./lowMetH->Integral());
TObjArray highMet = getDistributionFromPlotter(ch[ich]+"_"+categs[icat]+"dilarccosine",baseURL);
TH1 *highMetH = (TH1 *) ((TList *)highMet.At(3))->At(3);
formatPlot(highMetH,1,1,1,20,0,false,false,1,1,1);
highMetH->SetTitle("E_{T}^{miss}>30 GeV/c^{2}");
highMetH->Scale(1./highMetH->Integral());
TString channelTitle(ich==0 ? "ee" : "#mu#mu");
if(categs[icat]=="eq1jets") channelTitle += "+ 1 jet";
else channelTitle += "+ #geq 2 jets";
//draw
TString plot(ch[ich]+categs[icat]+"_anglecomparison");
TCanvas *cnv = getNewCanvas(plot+"c",plot+"c",false);
cnv->Clear();
cnv->SetWindowSize(600,600);
cnv->cd();
TList *mc = new TList; mc->Add(lowMetH);
TList *data = new TList; data->Add(highMetH);
TList *spimpose = new TList;
TLegend *leg=showPlotsAndMCtoDataComparison(cnv,*mc,*spimpose,*data,false);
TPad *p=(TPad *)cnv->cd(1);
formatForCmsPublic(p,leg,"CMS simulation, " + channelTitle, 4);
cnv->SaveAs(plot+".C");
cnv->SaveAs(plot+".pdf");
cnv->SaveAs(plot+".png");
}
}
}
示例9: CreateAnalysisTrain
//______________________________________________________________________________
void CreateAnalysisTrain()
{
/// create the analysis train and configure it
// analysis manager
AliAnalysisManager *mgr = new AliAnalysisManager("MuonPhysicsAnalysis");
// Debug mode
//mgr->SetDebugLevel(3);
// AOD handler
AliInputEventHandler* aodH = new AliAODInputHandler;
mgr->SetInputEventHandler(aodH);
// Fill the trigger list with desired trigger combinations (See on ALICE log book for denomination)
//==============================================================================
TList* triggers = new TList; // Create pointer for trigger list
triggers->SetOwner(kTRUE); // Give rights to trigger liser
if (!isMC)
{
// PbPb trigger
triggers->Add(new TObjString("CINT7-B-NOPF-MUFAST"));//MB &0MUL
triggers->Add(new TObjString("CINT7-B-NOPF-MUFAST&0MSL"));//MB &0MUL
triggers->Add(new TObjString("CINT7-B-NOPF-MUFAST&0MUL"));//MB &0MUL
triggers->Add(new TObjString("CMUL7-B-NOPF-MUFAST"));// MUL
triggers->Add(new TObjString("CMSL7-B-NOPF-MUFAST"));// MSL
triggers->Add(new TObjString("CMSL7-B-NOPF-MUFAST&0MUL"));// MSL &0MUL
}
// Load centrality task
//==============================================================================
gROOT->LoadMacro("$ALICE_PHYSICS/OADB/COMMON/MULTIPLICITY/macros/AddTaskMultSelection.C");
AddTaskMultSelection(kFALSE); // user
// Load task
//==============================================================================
TString outputname = AliAnalysisManager::GetAnalysisManager()->GetCommonFileName(); // Create output name in case of no dataset selected
gROOT->LoadMacro("AddTaskMuMu.C");
AddTaskMuMu(outputname.Data(),triggers,"PbPb2015",isMC);
cout <<"add task mumu done"<< endl;
}
示例10: 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;
}
示例11: TxtToBmp
void TxtToBmp (TStrings *List, Graphics::TBitmap *Bitmap, TFont *Font, int left, int top)
{
TList *newlist = new TList;
for(int i=0; i<List->Count; ++i)
{
char str[10000];
strcpy(str, List->Strings[i].c_str());
newlist->Add(strdup(str));
}
TxtToBmp(newlist, Bitmap, Font, left, top);
}
示例12: GetKeyList
TList* GetKeyList( const TString& pattern )
{
TList* list = new TList();
TIter next( TMVAGui_keyContent );
TKey* key(0);
while ((key = (TKey*)next())) {
if (TString(key->GetName()).Contains( pattern )) { list->Add( new TObjString( key->GetName() ) ); }
}
return list;
}
示例13: GetDetectorsInLayer
TList* KVASGroup::GetDetectorsInLayer(UInt_t lay)
{
//Creates and fills a list with all the detectors in the "detector layer"
//lay. Detector layers are always numbered from 1 (nearest target) to
//GetNumberOfDetectorLayers().
//Delete list after use.
if (lay < 1)
return 0;
UInt_t ndl = 0;
UInt_t imin = GetLayerNearestTarget();
UInt_t imax = GetLayerFurthestTarget();
for (UInt_t i = imin; i <= imax; i++) {
TList* tlist = GetTelescopesInLayer(i);
if (tlist) {
//note we take the max number of detectors in telescopes of layer i
Int_t max = 0;
TIter it(tlist);
KVTelescope* tel = 0;
while ((tel = (KVTelescope*)it.Next()))
if (max < tel->GetDetectors()->GetSize())
max = tel->GetDetectors()->GetSize();
ndl += max;
//
//before it was assume that all telescopes in same layer are identically constructed
//ndl += ((KVTelescope *) tlist->At(0))->GetDetectors()->GetSize();
//
if (ndl >= lay) {
//the required detector layer is in the telescopes in the list
//calculate rank of detectors in telescopes
UInt_t rank = max - ndl + lay;
TIter next(tlist);
KVTelescope* tel;
TList* list = new TList;
while ((tel = (KVTelescope*) next())) {
if (rank <= (UInt_t)tel->GetSize()) {
KVDetector* ddd = tel->GetDetector(rank);
if (ddd)
list->Add(ddd);
else
Warning("GetDetectorsInLayer", "pb d index pour GetDetector");
}
}
delete tlist;
return list;
}
delete tlist;
}
}
return 0;
}
示例14: AddObject
//_____________________________________________________
void GFHistManager::AddObject(TObject* obj, Int_t layer, Int_t histoNum, Option_t* opt)
{
// hist and layer must already exist
if(!this->CheckHistNum("AddObject", layer, histoNum)) return;
TList* objList = this->MakeObjList(layer, histoNum);
objList->Add(obj, opt);
if(layer < fCanArrays->GetEntriesFast()) {
this->Update(layer); // if canvas already drawn
}
}
示例15: FindMainRoads
//---------------------------------------------------------------------------
// Description: Highlights the routes with the heigher pheromone intesity
// starting from the Nest. If the Food source is not reached
// after a given number of tries, stop the search and draw the
// result.
bool __fastcall Civilization::FindMainRoads(int Ntries, TImage *ImageBox, const int RWidth, const float Scale)
{
// Start from the Anthill...
City *CurrentCity = Nest;
TList *MainRoads = new TList();
while(CurrentCity!=FoodSourceCity && Ntries>0)
{
int PheroLevel = -MAXINT;
Route *CurrentRoad = NULL;
City* NextCity;
Route* thisRoad;
// the following loop select the best road acording to the pheromone level
for(int j=0; j<Roads->Count; j++)
{
thisRoad = (Route*)Roads->Items[j];
// if the road has a conection with the current city...
NextCity = thisRoad->GetConection(CurrentCity);
// Test the highest Pheromone level among the possible roads...
// if 'thisRoad' was not used before...
if(NextCity!=NULL && MainRoads->IndexOf(thisRoad)==-1)
{
if(thisRoad->GetPheromone() > PheroLevel)
{
CurrentRoad = thisRoad;
PheroLevel = thisRoad->GetPheromone();
}
}
}
// Go to next city using the selected road...
if(CurrentCity!=NULL && CurrentRoad!=NULL)
{
CurrentCity = CurrentRoad->GetConection(CurrentCity);
MainRoads->Add(CurrentRoad);
}
Ntries--;
}
// Draw the MainRoad
Rebuild(ImageBox,Scale);
// Draw all the roads
for(int i=0; i<MainRoads->Count; i++)
{
ImageBox->Canvas->Pen->Width = RWidth;
((Route*)MainRoads->Items[i])->DrawRoad(ImageBox,clRed,Scale);
ImageBox->Canvas->Pen->Width = 1;
}
return (Ntries>0)?true:false;
}