本文整理汇总了C++中TNamed类的典型用法代码示例。如果您正苦于以下问题:C++ TNamed类的具体用法?C++ TNamed怎么用?C++ TNamed使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TNamed类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetOption
//_____________________________________________________________________________
void ProofSimple::Begin(TTree * /*tree*/)
{
// The Begin() function is called at the start of the query.
// When running with PROOF Begin() is only called on the client.
// The tree argument is deprecated (on PROOF 0 is passed).
TString option = GetOption();
Ssiz_t iopt = kNPOS;
// Histos array
if (fInput->FindObject("ProofSimple_NHist")) {
TParameter<Long_t> *p =
dynamic_cast<TParameter<Long_t>*>(fInput->FindObject("ProofSimple_NHist"));
fNhist = (p) ? (Int_t) p->GetVal() : fNhist;
} else if ((iopt = option.Index("nhist=")) != kNPOS) {
TString s;
Ssiz_t from = iopt + strlen("nhist=");
if (option.Tokenize(s, from, ";") && s.IsDigit()) fNhist = s.Atoi();
}
if (fNhist < 1) {
Abort("fNhist must be > 0! Hint: proof->SetParameter(\"ProofSimple_NHist\","
" (Long_t) <nhist>)", kAbortProcess);
return;
}
if (fInput->FindObject("ProofSimple_NHist3")) {
TParameter<Long_t> *p =
dynamic_cast<TParameter<Long_t>*>(fInput->FindObject("ProofSimple_NHist3"));
fNhist3 = (p) ? (Int_t) p->GetVal() : fNhist3;
} else if ((iopt = option.Index("nhist3=")) != kNPOS) {
TString s;
Ssiz_t from = iopt + strlen("nhist3=");
if (option.Tokenize(s, from, ";") && s.IsDigit()) fNhist3 = s.Atoi();
}
// Ntuple
TNamed *nm = dynamic_cast<TNamed *>(fInput->FindObject("ProofSimple_Ntuple"));
if (nm) {
// Title is in the form
// merge merge via file
// |<fout> location of the output file if merge
// |retrieve retrieve to client machine
// dataset create a dataset
// |<dsname> dataset name (default: dataset_ntuple)
// |plot for a final plot
// <empty> or other keep in memory
fHasNtuple = 1;
TString ontp(nm->GetTitle());
if (ontp.Contains("|plot") || ontp == "plot") {
fPlotNtuple = kTRUE;
ontp.ReplaceAll("|plot", "");
if (ontp == "plot") ontp = "";
}
if (ontp.BeginsWith("dataset")) fHasNtuple = 2;
}
}
示例2: GetOption
//_____________________________________________________________________________
void ProofEventProc::SlaveBegin(TTree * /*tree*/)
{
// The SlaveBegin() function is called after the Begin() function.
// When running with PROOF SlaveBegin() is called on each slave server.
// The tree argument is deprecated (on PROOF 0 is passed).
TString option = GetOption();
// How much to read
fFullRead = kFALSE;
TNamed *nm = 0;
if (fInput) {
if ((nm = dynamic_cast<TNamed *>(fInput->FindObject("ProofEventProc_Read")))) {
if (!strcmp(nm->GetTitle(), "readall")) fFullRead = kTRUE;
}
}
if (!nm) {
// Check option
if (option == "readall") fFullRead = kTRUE;
}
Info("SlaveBegin", "'%s' reading", (fFullRead ? "full" : "optimized"));
fPtHist = new TH1F("pt_dist","p_{T} Distribution",100,0,5);
fPtHist->SetDirectory(0);
fPtHist->GetXaxis()->SetTitle("p_{T}");
fPtHist->GetYaxis()->SetTitle("dN/p_{T}dp_{T}");
fOutput->Add(fPtHist);
fPzHist = new TH1F("pz_dist","p_{Z} Distribution",100,0,5.);
fPzHist->SetDirectory(0);
fPzHist->GetXaxis()->SetTitle("p_{Z}");
fPzHist->GetYaxis()->SetTitle("dN/dp_{Z}");
fOutput->Add(fPzHist);
fPxPyHist = new TH2F("px_py","p_{X} vs p_{Y} Distribution",100,-5.,5.,100,-5.,5.);
fPxPyHist->SetDirectory(0);
fPxPyHist->GetXaxis()->SetTitle("p_{X}");
fPxPyHist->GetYaxis()->SetTitle("p_{Y}");
fOutput->Add(fPxPyHist);
// Abort test, if any
TParameter<Int_t> *pi = 0;
if (fInput)
pi = dynamic_cast<TParameter<Int_t> *>(fInput->FindObject("ProofEventProc_TestAbort"));
if (pi) fTestAbort = pi->GetVal();
if (fTestAbort < -1 || fTestAbort > 1) {
Info("SlaveBegin", "unsupported value for the abort test: %d not in [-1,1] - ignore", fTestAbort);
fTestAbort = -1;
} else if (fTestAbort > -1) {
Info("SlaveBegin", "running abort test: %d", fTestAbort);
}
if (fTestAbort == 0)
Abort("Test abortion during init", kAbortProcess);
}
示例3: it
void KVCanvas::ShowShortcutsInfos()
{
std::cout << std::endl << std::endl;
TNamed* info = 0;
TIter it(&fShortCuts);
while ((info = (TNamed*)it())) {
std::cout << Form("%20s", info->GetName()) << " " << info->GetTitle() << std::endl;
}
std::cout << std::endl;
}
示例4: execCreateAndMerge
void execCreateAndMerge() {
//--------------------------------------------------------------------------
for ( Int_t ifile = 0 ; ifile < 4 ; ifile++ ) {
TFile* outputFile = TFile::Open(Form("a_file_%d.root",ifile),"RECREATE");
TNamed* namedObj = new TNamed(Form("namedObj%d",ifile),Form("namedObj%d",ifile));
namedObj->Write();
outputFile->Close();
}
cout << "4 a files created" << endl;
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
for ( Int_t ifile = 0 ; ifile < 4 ; ifile++ ) {
TFile* outputFile = TFile::Open(Form("b_file_%d.root",ifile),"RECREATE");
TNamed* namedObj = new TNamed("namedObj","namedObj");
namedObj->Write();
outputFile->Close();
}
cout << "4 b files created" << endl;
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
TFileMerger* aMerger = new TFileMerger(kFALSE);
for ( Int_t ifile = 0 ; ifile < 4 ; ifile++ ) {
TFile* inFile = TFile::Open(Form("a_file_%d.root",ifile));
aMerger->AddFile(inFile);
}
aMerger->OutputFile("a_file.root");
aMerger->Merge();
cout << "4 a files merged" << endl;
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
TFileMerger* bMerger = new TFileMerger(kFALSE);
for ( Int_t ifile = 0 ; ifile < 4 ; ifile++ ) {
TFile* inFile = TFile::Open(Form("b_file_%d.root",ifile));
bMerger->AddFile(inFile);
}
bMerger->OutputFile("b_file.root");
bMerger->Merge();
cout << "4 b files merged" << endl;
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
TFile* inAFile = TFile::Open("a_file.root");
cout << "******* MERGED A FILE ******** 4 objects with different names" << endl;
inAFile->ls();
cout << "******************************" << endl;
//--------------------------------------------------------------------------
//--------------------------------------------------------------------------
TFile* inBFile = TFile::Open("b_file.root");
cout << "******* MERGED B FILE ******** 4 objects with the same names" << endl;
inBFile->ls();
cout << "******************************" << endl;
//--------------------------------------------------------------------------
}
示例5: AddAllManagers
Bool_t AddAllManagers(TList *listManagers,TString anSrc, TString anMode,TString input,TString inputMC) {
TIter next(listManagers);
Int_t counter=0;
TNamed *name;
while ((name = (TNamed *)next.Next())) {
if (!AddAnalysisManager(name->GetName(), anSrc, anMode,input,inputMC,name->GetTitle(),Form("%d",counter++))) {
Printf("Error: Problem adding %s",name->GetName());
return kFALSE;
}
}
return kTRUE;
}
示例6: saveSummaryLoop
void RootWImage::saveSummaryLoop(TPad* basePad, std::string baseName, TFile* myTargetFile) {
TList* aList;
TObject* anObject;
TPad* myPad;
std::string myClass;
std::string myName;
TNamed* aNamed;
// TSystemFile* aFile;
// string aFileName;
// string aFileNameTail;
// TFile* myRootFile;
aList = basePad->GetListOfPrimitives();
for (int i=0; i<aList->GetEntries(); ++i) {
anObject = aList->At(i);
myClass = anObject->ClassName();
if (myClass=="TPad") { // Go one step inside
myPad = (TPad*) anObject;
saveSummaryLoop(myPad, baseName, myTargetFile);
} else if (
(myClass=="TProfile") ||
(myClass=="TGraph") ||
(myClass=="TH1D") ||
(myClass=="TH2C") ||
(myClass=="TH2D") ||
(myClass=="THStack")
) {
aNamed = (TNamed*) anObject;
myTargetFile->cd();
myName = Form("%s.%s", baseName.c_str(), aNamed->GetName());
myName = RootWeb::cleanUpObjectName(myName);
aNamed->SetName(myName.c_str());
aNamed->Write();
} else if (
(myClass=="TEllipse") ||
(myClass=="TFrame") ||
(myClass=="TLatex") ||
(myClass=="TLegend") ||
(myClass=="TLine") ||
(myClass=="TPaveText") ||
(myClass=="TPolyLine") ||
(myClass=="TText")
) {
} else {
std::cerr << Form("Unhandled class %s", myClass.c_str()) << std::endl;
}
}
}
示例7: while
const char *Next(int &kind,int &idx,double &exe,double &heap,double &free,double &inc) {
if(!inp) return 0;
kind=0;idx=0;exe=0;heap=0;free=0,inc=0;
TString ts;
char *endMaker,*clear,*ctr,*doPs,*fr,*to,*and;
while(fgets(line,500,inp)) {
doPs = strstr(line,"doPs for");
if (!doPs) continue;
endMaker = strstr(line,"EndMaker");
clear = strstr(line,"Clear");
ctr = strstr(line,"constructor");
kind = 0;
if (ctr ) kind = 1;
if (clear ) kind = 2;
if (endMaker) kind = 3;
if (!kind) continue;
fr = doPs+8 +strspn(doPs+8," \t");
to = strstr(fr,":");
ts = ""; ts.Append(fr,to-fr);
if (!ts.Length()) continue;
fr = strstr(fr,"total"); if (!fr) continue;
fr = strstr(fr,"=" ); if (!fr) continue;
exe = atof(fr+1);
fr = strstr(fr,"heap" ); if (!fr) continue;
fr = strstr(fr,"=" ); if (!fr) continue;
heap = atof(fr+1);
and = strstr(fr,"and");
if (and) free = atof(and+3);
fr = strstr(fr,"(" ); if (!fr) continue;
inc = atof(fr+1);
if (kind==1) continue;
TNamed *tn = (TNamed*)hash.FindObject(ts.Data());
if (!tn) {
tn = new TNamed(ts.Data(),"");
hash.Add(tn);
fNMakers++;
tn->SetUniqueID((UInt_t)fNMakers);
mArray.AddAtAndExpand(tn,fNMakers);
}
idx = tn->GetUniqueID();
return tn->GetName();
}
fclose(inp); inp = 0;
return 0;
}};
示例8: EventInfo
//______________________________________________________________________
void EventInfo(Int_t event, Int_t px, Int_t , TObject *selected)
{
//draw the tooltip showing the backtrace for the bin at px
if (!gTip) return;
gTip->Hide();
if (event == kMouseLeave)
return;
Double_t xpx = gPad->AbsPixeltoX(px);
Int_t bin = hleaks->GetXaxis()->FindBin(xpx);
if (bin <=0 || bin > hleaks->GetXaxis()->GetNbins()) return;
Int_t nbytes = (Int_t)hleaks->GetBinContent(bin);
Int_t entry = (Int_t)hentry->GetBinContent(bin);
Int_t btid = (Int_t)V4[entry];
Double_t time = 0.0001*V3[entry];
TH1I *hbtids = (TH1I*)T->GetUserInfo()->FindObject("btids");
if (!hbtids) return;
if (!btidlist) btidlist = (TObjArray*)T->GetUserInfo()->FindObject("FAddrsList");
if (!btidlist) btidlist = (TObjArray*)f->Get("FAddrsList"); //old memstat files
if (!btidlist) return;
Int_t nbt = (Int_t)hbtids->GetBinContent(btid-1);
TString ttip;
for (Int_t i=0;i<nbt;i++) {
Int_t j = (Int_t)hbtids->GetBinContent(btid+i);
TNamed *nm = (TNamed*)btidlist->At(j);
if (nm==0) break;
char *title = (char*)nm->GetTitle();
Int_t nch = strlen(title);
if (nch < 20) continue;
if (nch > 100) title[100] =0;
const char *bar = strstr(title,"| ");
if (!bar) continue;
if (strstr(bar,"operator new")) continue;
if (strstr(bar,"libMemStat")) continue;
if (strstr(bar,"G__Exception")) continue;
ttip += TString::Format("%2d %s\n",i,bar+1);
}
if (selected) {
TString form1 = TString::Format(" Leak number=%d, leaking %d bytes at entry=%d time=%gseconds\n\n",bin,nbytes,entry,time);
gTip->SetText(TString::Format("%s%s",form1.Data(),ttip.Data() ));
gTip->SetPosition(px+15, 100);
gTip->Reset();
}
}
示例9: Book
/// Store an object to send back. We encase it in a FlowObject because the list
/// of objects that goes back is "flat" and FlowObject holds onto
/// a tag that tells us where this should be stored later. Helps!
void Book(TObject *o)
{
string objName("");
if (o->InheritsFrom("TNamed")) {
TNamed *n = static_cast<TNamed*>(o);
objName = n->GetName();
}
else {
objName = o->ClassName();
}
///
/// If this is a replacement, then boom!
///
if (dynamic_cast<TObject*> (GetOutputList()->FindObject(objName.c_str())) == 0) {
GetOutputList()->Add(o->Clone());
}
}
示例10: GetNpar
void KVNameValueList::ClearSelection(TRegexp& sel)
{
// Remove from list all parameters whose name matches the regular expression
// Examples:
// remove all parameters starting with "toto": TRegexp sel("^toto")
// remove all parameters with "toto" in name: TRegexp sel("toto")
TList toBeRemoved;
Int_t np1 = GetNpar();
for (Int_t ii = 0; ii < np1; ii += 1) {
TString name = GetParameter(ii)->GetName();
if (name.Contains(sel)) toBeRemoved.Add(new TNamed(name.Data(), ""));
}
if (toBeRemoved.GetEntries()) {
TIter next(&toBeRemoved);
TNamed* tbr;
while ((tbr = (TNamed*)next())) RemoveParameter(tbr->GetName());
toBeRemoved.Delete();
}
}
示例11: GetAction
//_____________________________________________________________________________
Int_t ProofAux::GetAction(TList *input)
{
// Get the required action.
// Returns -1 if unknown.
Int_t action = -1;
// Determine the test type
TNamed *ntype = dynamic_cast<TNamed*>(input->FindObject("ProofAux_Action"));
if (ntype) {
if (!strcmp(ntype->GetTitle(), "GenerateTrees")) {
action = 0;
} else if (!strcmp(ntype->GetTitle(), "GenerateTreesSameFile")) {
action = 1;
} else {
Warning("GetAction", "unknown action: '%s'", ntype->GetTitle());
}
}
// Done
return action;
}
示例12: sprintf
void KVTrieur::Copy(TObject & a) const
{
#else
void KVTrieur::Copy(TObject & a)
{
#endif
//
// Methode de Copy
//
Char_t nom[80];
#ifdef DEBUG_KVTrieur
cout << "Copy de " << a.GetName() << "..." << endl;
#endif
#ifdef DEBUG_KVTrieur
sprintf(nom, "Copy de %s", a.GetName());
#else
sprintf(nom, "Copy_%s", a.GetName());
#endif
((KVTrieur &) a).SetName(nom);
((KVTrieur &) a).SetTitle(nom);
((KVTrieur &) a).nb_cases = this->nb_cases;
if (this->noms_cases) {
((KVTrieur &) a).noms_cases =
new TClonesArray("TNamed", this->nb_cases);
TClonesArray *tca = ((KVTrieur &) a).noms_cases;
Char_t nomc[80];
for (Int_t i = 0; i < this->nb_cases; i++) {
TNamed *c = (TNamed *) this->noms_cases->At(i);
sprintf(nomc, "%s_C%d", this->GetName(), i + 1);
new((*tca)[i]) TNamed(nomc, c->GetTitle());
}
} else {
((KVTrieur &) a).noms_cases = 0;
}
#ifdef DEBUG_KVTrieur
cout << "Nom de la Copy (arguement): " << nom << endl;
cout << "Nom de la Copy (resultat) : " << GetName() << endl;
#endif
}
示例13: sprintf
//_____________________________________________________
void KVTrieurLin::SetNomsCases(void)
{
//
// On affecte les noms aux cases
//
Char_t nomt[80];
if (noms_cases) {
Double_t xpas = (xmax - xmin) / nb_cases;
for (Int_t i = 0; i < nb_cases; i++) {
if (i == 0) {
sprintf(nomt, "%s < %f", nom_var, xmin + (i + 1) * xpas);
} else if (i == nb_cases - 1) {
sprintf(nomt, "%f #leq %s", xmin + i * xpas, nom_var);
} else {
sprintf(nomt, "%f #leq %s < %f", xmin + i * xpas, nom_var,
xmin + (i + 1) * xpas);
}
TNamed* nom = (TNamed*) noms_cases->At(i);
nom->SetTitle(nomt);
}
}
}
示例14: pwd
bool PlotManager::dumpObject(const string& objName,
const string& objTitle,
const string& srcObjName)
{
if ( ! isSetup_ ) return false;
// Push to base directory
string pwd(gDirectory->GetPath());
string newObjPath = dirname(objName);
string newObjName = basename(objName);
if ( newObjPath.empty() ) {
theOutFile_->cd();
}
else if ( theOutFile_->cd(newObjPath.c_str()) == kFALSE ) {
cout << "Cannot find dir, do mkdirs : " << newObjPath << endl;
mkdirs(theOutFile_, newObjPath)->cd();
}
TNamed* srcObj = dynamic_cast<TNamed*>(theSrcFile_->Get(srcObjName.c_str()));
if ( srcObj == NULL ) {
cerr << "Cannot get object : " << srcObjName << endl;
return false;
}
TNamed* saveObj = dynamic_cast<TNamed*>(srcObj->Clone(newObjName.c_str()));
saveObj->SetTitle(objTitle.c_str());
// Save histogram
saveObj->Write();
// Pop directory
gDirectory->cd(pwd.c_str());
return true;
}
示例15: GetOption
void ProofNtuple::SlaveBegin(TTree * /*tree*/)
{
// The SlaveBegin() function is called after the Begin() function.
// When running with PROOF SlaveBegin() is called on each slave server.
// The tree argument is deprecated (on PROOF 0 is passed).
TString option = GetOption();
// We may be creating a dataset or a merge file: check it
TNamed *nm = dynamic_cast<TNamed *>(fInput->FindObject("SimpleNtuple.root"));
if (nm) {
// Just create the object
UInt_t opt = TProofOutputFile::kRegister | TProofOutputFile::kOverwrite | TProofOutputFile::kVerify;
fProofFile = new TProofOutputFile("SimpleNtuple.root",
TProofOutputFile::kDataset, opt, nm->GetTitle());
} else {
// For the ntuple, we use the automatic file merging facility
// Check if an output URL has been given
TNamed *out = (TNamed *) fInput->FindObject("PROOF_OUTPUTFILE_LOCATION");
Info("SlaveBegin", "PROOF_OUTPUTFILE_LOCATION: %s", (out ? out->GetTitle() : "undef"));
fProofFile = new TProofOutputFile("SimpleNtuple.root", (out ? out->GetTitle() : "M"));
out = (TNamed *) fInput->FindObject("PROOF_OUTPUTFILE");
if (out) fProofFile->SetOutputFileName(out->GetTitle());
}
// Open the file
fFile = fProofFile->OpenFile("RECREATE");
if (fFile && fFile->IsZombie()) SafeDelete(fFile);
// Cannot continue
if (!fFile) {
Info("SlaveBegin", "could not create '%s': instance is invalid!", fProofFile->GetName());
return;
}
// Now we create the ntuple
fNtp = new TNtuple("ntuple","Demo ntuple","px:py:pz:random:i");
// File resident
fNtp->SetDirectory(fFile);
fNtp->AutoSave();
// Should we generate the random numbers or take them from the ntuple ?
TNamed *unr = (TNamed *) fInput->FindObject("PROOF_USE_NTP_RNDM");
if (unr) {
// Get the ntuple from the input list
if (!(fNtpRndm = dynamic_cast<TNtuple *>(fInput->FindObject("NtpRndm")))) {
Warning("SlaveBegin",
"asked to use rndm ntuple but 'NtpRndm' not found in the"
" input list! Using the random generator");
fInput->Print();
} else {
Info("SlaveBegin", "taking randoms from input ntuple 'NtpRndm'");
}
}
// Init the random generator, if required
if (!fNtpRndm) fRandom = new TRandom3(0);
}