本文整理汇总了C++中TObjArray::GetEntries方法的典型用法代码示例。如果您正苦于以下问题:C++ TObjArray::GetEntries方法的具体用法?C++ TObjArray::GetEntries怎么用?C++ TObjArray::GetEntries使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TObjArray
的用法示例。
在下文中一共展示了TObjArray::GetEntries方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: string
std::string Ntp1Analyzer_HWWlvjj::getHLTPathForRun(int runN, std::string fullname) {
TString fullName = TString(fullname.c_str());
TObjArray* selectionTokens = fullName.Tokenize(":");
if (selectionTokens->GetEntries()!=2) {
std::cout << "Wrong trigger strings " << selectionTokens->GetEntries() << std::endl;
return std::string("NOPATH");
}
TString RunRange =((TObjString*)(*selectionTokens)[0])->GetString();
TString HLTPathName =((TObjString*)(*selectionTokens)[1])->GetString();
TObjArray* runs = RunRange.Tokenize("-");
if (runs->GetEntries()!=2) {
std::cout << "Wrong trigger run range strings " << runs->GetEntries() << std::endl;
return std::string("NOPATH");
}
const char *minStr = (((TObjString*)(*runs)[0])->GetString()).Data();
const char *maxStr = (((TObjString*)(*runs)[1])->GetString()).Data();
int min = atoi(minStr);
int max = atoi(maxStr);
if(runN>=min && runN<=max) return std::string(HLTPathName.Data());
else return std::string("NOPATH");
}
示例2: main
int main() {
TGeoNode *node = NULL;
TGeoVolume *vol = NULL;
LMCgeomN *g = new LMCgeomN("Telescope");
TObjArray *oa = g->GetGeoManager()->GetListOfNodes();
for (int i=0; i<oa->GetEntries(); i++) {
node = (TGeoNode*)oa->At(i);
vol = node->GetVolume();
cout << "= " << node->GetName() << " " << vol->GetName() <<endl;
TObjArray *vnodes = vol->GetNodes();
cout << vnodes->GetEntries() << endl;
for (int j=0; j<vnodes->GetEntries(); j++) {
node = (TGeoNode*)vnodes->At(j);
cout << "== " << node->GetName() << endl;
vol = node->GetVolume();
TObjArray *vnodes1 = vol->GetNodes();
for (int k=0; k<vnodes1->GetEntries(); k++) {
node = (TGeoNode*)vnodes1->At(k);
cout << "=== " << node->GetName() << endl;
vol = node->GetVolume();
TObjArray *vnodes2 = vol->GetNodes();
if(!vnodes2) continue;
for (int q=0; q<vnodes2->GetEntries(); q++) {
node = (TGeoNode*)vnodes2->At(q);
cout << "==== " << node->GetName() << endl;
}
}
}
}
return 0;
}
示例3: getlist
void getlist(ostream& out, TBranch* branch, int depth=0)
{
TObjArray* array = branch->GetListOfBranches();
if ( ! array ) return;
if ( depth > 10 ) return;
string name;
int nitems = array->GetEntries();
for (int i = 0; i < nitems; i++)
{
TBranch* b = (TBranch*)((*array)[i]);
if ( ! b ) continue;
string branchname(b->GetName());
out << SPACE.substr(0,4*depth) << branchname << endl;
TObjArray* a = b->GetListOfLeaves();
if ( a )
{
int n = a->GetEntries();
{
for (int j = 0; j < n; j++)
{
TLeaf* leaf = (TLeaf*)((*a)[j]);
int count = 0;
int ndata = 0;
TLeaf* leafc = leaf->GetLeafCounter(count);
if ( ! leafc)
ndata = leaf->GetLen();
else
ndata = leafc->GetMaximum();
string leafname(leaf->GetName());
out << SPACE.substr(0,4*(depth+1))
<< ndata << " " << leafname << endl;
}
}
// else if ( n == 1 )
// {
// TBranch* bc = (TBranch*)((*a)[j]);
// string leafname(bc->GetName());
// if ( leafname != branchname )
// out << SPACE.substr(0,4*(depth+1)) << leafname << endl;
// }
}
getlist(out, b, depth+1);
}
}
示例4: IsGANACQFormat
Bool_t KVDatime::IsGANACQFormat(const Char_t* date)
{
// Static method, returns kTRUE if 'date' is in format of GANIL acquisition
// e.g. 29-SEP-2005 09:42:17.00
KVString tmp(date);
TObjArray *toks = tmp.Tokenize("-:. ");
if( toks->GetEntries() < 6 || toks->GetEntries() > 7 ) {
// if format is correct, there should be 6 or 7 elements in toks
delete toks;
return kFALSE;
}
delete toks;
return kTRUE;
}
示例5: GetTreeSize
void GetTreeSize(TString FileName, TString TreeName)
{
TFile *inf = TFile::Open(FileName);
TTree *tr = (TTree*)inf->Get(TreeName);
TObjArray *branches = (TObjArray*)tr->GetListOfBranches();
int size(0);
cout.setf(ios::right);
int N(branches->GetEntries());
TH1F *hSize = new TH1F("size","size",N,0,N);
for(int ib=0;ib<N;ib++) {
TString name(branches->At(ib)->GetName());
TBranch *br = (TBranch*)tr->GetBranch(name);
hSize->Fill(name,br->GetZipBytes()/1e+3);
size += br->GetZipBytes();
}
cout<<"Total size: "<<size<<endl;
for(int ib=0;ib<N;ib++) {
TString name(branches->At(ib)->GetName());
TBranch *br = (TBranch*)tr->GetBranch(name);
float percent = TMath::Ceil(1000*float(br->GetZipBytes())/float(size))/10;
cout<<ib<<setw(20)<<name<<setw(15)<<br->GetZipBytes()<<" "<<percent<<"%"<<endl;
}
TCanvas *can = new TCanvas("TreeSize","TreeSize",1000,400);
hSize->GetXaxis()->SetTitle("Branch Name");
hSize->GetXaxis()->SetLabelSize(0.04);
hSize->GetYaxis()->SetTitle("Size (KB)");
hSize->SetFillColor(kGray);
hSize->Draw();
}
示例6: formatForCmsPublic
void formatForCmsPublic(TPad * c, TLegend *leg, TString title, int nsamp, float legx, float legy, float legw, float legh, TString legopt)
{
if(title.Length()!=0)
{
TPaveText *pave = new TPaveText(0.5,0.96,0.94,0.99,"NDC");
pave->SetBorderSize(0);
pave->SetFillStyle(0);
pave->SetTextAlign(32);
pave->SetTextFont(42);
TObjArray * tokens = title.Tokenize("\\\\");
int nt = tokens->GetEntries();
for(int it=0; it<nt; ++it)
{
TObjString * t = (TObjString *)tokens->At(it);
pave->AddText(t->GetString());
}
pave->Draw("same");
}
float legx1=legx, legx2=legx+legw;
float legy1 = legy, legy2 = legy-legh*(float)(nsamp);
if(leg==0) leg = ((TPad *)c)->BuildLegend(legx1,legy1,legx2,legy2);
leg->SetBorderSize(0);
leg->SetFillColor(0);
leg->SetFillStyle(0);
leg->SetLineWidth(1);
leg->SetTextFont(42);
leg->SetEntryOption(legopt);
leg->SetX1NDC(legx1);
leg->SetY1NDC(legy1);//-nsamp*legh);
leg->SetX2NDC(legx2);
leg->SetY2NDC(legy2);
}
示例7: legend
TLegend* legend(THStack* stack, Option_t* option = "lp", Bool_t addColor = kFALSE, Int_t token = -1,
Float_t xmin = 0.50, Float_t ymin = 0.51, Float_t xmax = 0.85, Float_t ymax = 0.92) {
if(! stack) return 0;
TLegend* leg = new TLegend(xmin, ymin, xmax, ymax);
TList* list = stack->GetHists();
TIterator* iter = list->MakeIterator();
TObject* obj = 0;
//Hist color iterator
Int_t colorIt = 1;
while (obj = iter->Next()) {
if (! obj->InheritsFrom(TH1::Class())) continue;
if (addColor) {
hist::color(obj->GetName(), colorIt);
++colorIt;
}
if (token == -1)
leg->AddEntry(obj, obj->GetTitle(), option);
else {
TString name(obj->GetName());
TObjArray* a = name.Tokenize("_");
if (a->GetEntries() <= token)
leg->AddEntry(obj, obj->GetName(), option);
else
leg->AddEntry(obj, a->At(token)->GetName(), option);
}
}
return leg;
}
示例8: OnCharacters
void TBDataParser::OnCharacters(const char *characters)
{
if(_currentElement != NULL && !strcmp(_currentElement->Data(),"vector")) {
TString *string = new TString(characters);
TObjArray *values = string->Tokenize(", ");
for(Int_t i = 0; i < values->GetEntries(); i++) {
TObjString *object = (TObjString *) values->At(i);
TString value = object->GetString().ReplaceAll("\n", "").ReplaceAll("\t", "").ReplaceAll(" ", "").ReplaceAll("\0", "");
if(value.IsFloat()) {
_vector->Fill(value.Atof());
}
}
if(_vectorsStack->GetEntries() == 1) {
_motherVecEntries = _vector->GetEntries();
} else if(_currentMethod != NULL && !strcmp(_currentMethod->Data(),"all")) {
for(Int_t i = 1; i < _motherVecEntries; i++) {
TObjString *object = (TObjString *) values->First();
TString value = object->GetString().ReplaceAll("\n", "").ReplaceAll("\t", "").ReplaceAll(" ", "").ReplaceAll("\0", "");
if(value.IsFloat())
_vector->Fill(value.Atof());
}
}
values->Delete();
}
}
示例9: GetLogical
TString KVNumberList::GetLogical(const Char_t *observable)
{
// Get logical expression of 'this' list in the TTree:Draw condition format
// observable is one of the leaf of the TTree
// 12-15 20 --> ( 12<=observable&&observable<=15 || observable==20 )
// return "" if 'this' list is empty
if (IsEmpty()) return "";
GetList();
TString tmp = fString;
tmp.ReplaceAll(" ","||");
TObjArray *toks = tmp.Tokenize("||");
TString cond="( ";
Int_t nt = toks->GetEntries();
for (Int_t ii=0; ii<nt; ii+=1) {
TString line = ((TObjString*)(*toks)[ii])->GetString();
if ( line.Contains("-") ) {
line.ReplaceAll("-",Form("<=%s&&%s<=",observable,observable));
cond+=line;
}
else {
cond+=Form("%s==",observable)+line;
}
if (ii!=nt-1) cond+="||";
}
cond += " )";
delete toks;
return cond;
}
示例10: OCDBDefault
void OCDBDefault(Int_t mode)
{
Int_t run = atoi(gSystem->Getenv("CONFIG_RUN"));
AliCDBManager* man = AliCDBManager::Instance();
man->SetDefaultStorage("raw://");
if(gSystem->Getenv("CONFIG_OCDBTIMESTAMP"))
{
TString t = gSystem->Getenv("CONFIG_OCDBTIMESTAMP");
TObjArray* list =t.Tokenize("_");
UInt_t tU[6];
for(Int_t i=0; i<list->GetEntries(); i++)
{
TString st = ((TObjString*)list->At(i))->GetString();
tU[i] =(UInt_t)atoi(st.Data());
}
man->SetMaxDate(TTimeStamp(tU[0], tU[1], tU[2], tU[3], tU[4], tU[5]));
printf("*** Setting custom OCDB time stamp %s ***\n", t.Data());
}
man->SetRun(run);
// set detector specific paths
DefaultSpecificStorage(man, mode);
}
示例11: GetFullListing
KVUniqueNameList* KVDMS::GetFullListing(const Char_t* directory)
{
// Create and fill TList with info (name, size, modification date)
// on all files & containers in current directory
// (default) or in given directory.
// TList is filled with DMSFile_t objects which belong to the list, list must be deleted after use.
longlist(directory);
if (fout == "") {
Error("GetListing", "Unknown directory %s", directory);
return 0;
}
TObjArray* toks = fout.Tokenize("\n");
KVUniqueNameList* list = new KVUniqueNameList(kTRUE);
list->SetOwner(kTRUE);
list->SetName(((TObjString*)(*toks)[0])->String().Remove(TString::kBoth, ' ').Data());
for (int i = 1; i < toks->GetEntries(); i++) {
TString tmp = ((TObjString*)(*toks)[i])->String().Remove(TString::kBoth, ' ');
DMSFile_t* f = new DMSFile_t;
if (IsContainer(tmp)) { // container
f->SetName(gSystem->BaseName(tmp.Data()));
f->SetIsContainer();
} else {
ExtractFileInfos(tmp, f);
}
list->Add(f);
}
delete toks;
return list;
}
示例12: GetRunInfos
void KVAvailableRunsFile::GetRunInfos(Int_t run, KVList * dates,
KVList * files)
{
//Look for a given run number in the file, and read the file's modification date/time and filename
//These informations are stored in the two TList as TObjString objects (these objects belong to the
//lists and will be deleted by them).
//We do not stop at the first run found, but continue until the end of the file, adding
//informations for every occurence of the run in the file.
//If available runs file does not exist, Update() is called to create it.
//does runlist exist ?
if (!OpenAvailableRunsFile()) {
Error("GetRunInfos", "Error opening available runs file");
return;
}
//clear lists - delete objects
dates->Delete();
files->Delete();
//loop over lines in fRunlist file
//look for line beginning with 'run|'
TString line;
line.ReadLine(fRunlist);
while (fRunlist.good()) {
if (line.BeginsWith(Form("%d|", run))) {
//found it
TObjArray *toks = line.Tokenize('|'); // split into fields
// check date is not identical to a previous entry
// i.e. there are spurious duplicate entries
TObjString* rundate = (TObjString*)toks->At(1)->Clone();
if(dates->FindObject(rundate->GetName())){
delete toks;
delete rundate;
line.ReadLine(fRunlist);
continue;
}
//add date string
dates->Add(toks->At(1)->Clone());
//backwards compatibility
//an old available_runs file will not have the filename field
//in this case we assume that the name of the file is given by the
//dataset's base file name (i.e. with no date/time suffix)
if (toks->GetEntries() > 2) {
files->Add(toks->At(2)->Clone());
} else {
files->
Add(new
TObjString(fDataSet->
GetBaseFileName(GetDataType(), run)));
}
delete toks;
}
line.ReadLine(fRunlist);
}
CloseAvailableRunsFile();
}
示例13: transferxSecFromTextToROOT
void transferxSecFromTextToROOT(std::string inputStr="xSec_T3G.txt"){
ifstream fin(inputStr.c_str());
char line[200];
TFile *xSecProspinoFile =0;
TH1D *xSecProspino =0;
int minMom = 1000000, maxMom = 0;
int nBins = 0;
std::vector<int> momVec; std::vector<double> xSecVec, xSecErrVec;
while( fin.getline(line, 200) ){
TString lineT(line);
if( lineT.Contains("Interactions") ) continue;
TObjArray *vlist = lineT.Tokenize(" ");
int nEntries = vlist->GetEntries();
int mMom;
double xSec =0, xSecRelErr =0;
for(int ie=0; ie<nEntries; ie++){
TObjString* perObj = dynamic_cast<TObjString*>(vlist->At(ie));
TString perStr = perObj->GetString();
if( ie==0 ){
mMom = perStr.Atoi();
if( minMom > mMom ) minMom = mMom;
if( maxMom < mMom ) maxMom = mMom;
}
if( ie==1 ) xSec = perStr.Atof();
if( ie==2 ) xSecRelErr = perStr.Atof();
}
nBins ++;
momVec.push_back(mMom); xSecVec.push_back(xSec); xSecErrVec.push_back(xSec*xSecRelErr/100.);
// std::cout<<"mMom : "<<mMom<<" xSec : "<<xSec<<" xSecRelErr : "<<xSecRelErr<<std::endl;
}
double divBin = 1.0*(maxMom - minMom)/(nBins-1);
double lowMom = minMom-divBin/2.0, highMom = maxMom+divBin/2.0;
std::cout<<"nBins : "<<nBins<<" minMom : "<<minMom<<" maxMom : "<<maxMom<<" divBin : "<<divBin<<" lowMom : "<<lowMom<<" highMom : "<<highMom<<std::endl;
TString rootStrT(inputStr);
rootStrT.ReplaceAll("txt", "root");
std::cout<<"root file : "<<rootStrT<<std::endl;
xSecProspinoFile = new TFile(rootStrT, "RECREATE");
if( rootStrT.Contains("T1") ) xSecProspino = new TH1D("gluino_xsection", "gluino_xsection", nBins, lowMom, highMom);
if( rootStrT.Contains("T2") ) xSecProspino = new TH1D("squark_xsection", "squark_xsection", nBins, lowMom, highMom);
if( rootStrT.Contains("T3G") ) xSecProspino = new TH1D("stop_xsection", "stop_xsection", nBins, lowMom, highMom);
for(int iv=0; iv<(int)momVec.size(); iv++){
double mMom = (double)momVec[iv];
int ib = xSecProspino->FindFixBin(mMom);
xSecProspino->SetBinContent(ib, xSecVec[iv]);
xSecProspino->SetBinError(ib, xSecErrVec[iv]);
}
// xSecProspino->Write();
xSecProspinoFile->Write(); xSecProspinoFile->Close();
}
示例14: tokenize
vector<int> tokenize(TString s) {
TObjArray *t = s.Tokenize(",");
const int n = t->GetEntries();
vector<int> CATVETO;
CATVETO.clear();
for (int i=0; i<n; i++) {
CATVETO.push_back(((TObjString*)t->At(i))->String().Atoi());
}
return CATVETO;
}
示例15: tag
TString tag(TString s) {
TObjArray *t = s.Tokenize(",");
const int n = t->GetEntries();
TString tCATVETO = "";
for (int i=0; i<n; i++) {
tCATVETO += TString::Format("%d",((TObjString*)t->At(i))->String().Atoi());
}
if (n>0): tCATVETO = "_CATveto"+tCATVETO;
return tCATVETO;
}