本文整理汇总了C++中TObjArray::GetEntriesFast方法的典型用法代码示例。如果您正苦于以下问题:C++ TObjArray::GetEntriesFast方法的具体用法?C++ TObjArray::GetEntriesFast怎么用?C++ TObjArray::GetEntriesFast使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TObjArray
的用法示例。
在下文中一共展示了TObjArray::GetEntriesFast方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: OpenFilesLegends
//________________________________________________________
bool GFOverlay::OpenFilesLegends(const char *fileLegendList)
{
bool allOk = true;
TObjArray *fileLegPairs = TString(fileLegendList).Tokenize(",");
for (Int_t iF = 0; iF < fileLegPairs->GetEntriesFast(); ++iF) {
TObjArray *aFileLegPair = TString(fileLegPairs->At(iF)->GetName()).Tokenize("=");
const char *legend = "";
if (aFileLegPair->GetEntriesFast() >= 2) {
if (aFileLegPair->GetEntriesFast() > 2) {
::Error("GFOverlay::OpenFilesLegends", "File-legend pair %s: %d (>2) '=' separated parts!",
fileLegPairs->At(iF)->GetName(), aFileLegPair->GetEntriesFast());
}
legend = aFileLegPair->At(1)->GetName();
} else if (aFileLegPair->GetEntriesFast() < 1) {
continue; // empty: should report error?
} // else if (aFileLegPair->GetEntriesFast() == 1): That's OK, use empty legend.
TFile *file = TFile::Open(aFileLegPair->At(0)->GetName());
if (!file) {
::Error("GFOverlay::OpenFilesLegends", "Skip file-legend pair %s due to opening problems!",
fileLegPairs->At(iF)->GetName());
allOk = false;
} else {
fFiles.Add(file);
fLegends.Add(new TObjString(legend));
}
delete aFileLegPair;
}
delete fileLegPairs;
return allOk;
}
示例2: DrawHighlightFragments
//______________________________________________________________________________
void DrawHighlightFragments(const TRsnGroup *rsng, const char *whichtag = "")
{
if (!rsng || !rsng->GetListOfFragments()) return;
tagname = whichtag;
group = rsng;
TObjArray *fragments = group->GetListOfFragments();
gr = new TGraph(fragments->GetEntriesFast());
for (Int_t i = 0; i < fragments->GetEntriesFast(); i++) {
TRsnFragment *frag = group->FragmentAt(i);
if (frag) gr->SetPoint(i, frag->GetMean(), 0.91);
}
// TString cmd = TString::Format("(TGraph *)0x%lx", (ULong_t)g);
// Printf("cmd = %s", cmd.Data());
// cmd = TString::Format("((TRsnGroup *)0x%lx)->HighlightFragment(%s)",
// (ULong_t)this, cmd.Data());
// Printf("cmd = %s", cmd.Data());
// TExec *ex = new TExec("ex", cmd.Data());
TExec *ex = new TExec("ex", "HighlightFragment()");
gr->GetListOfFunctions()->Add(ex);
gr->SetHighlight(kTRUE);
gr->SetTitle();
gr->SetMarkerStyle(20);
gr->GetYaxis()->SetTickLength(0.0);
gr->SetBit(kCanDelete);
gr->Draw("AP");
gr->GetXaxis()->SetTitle("bla_bla");
}
示例3: CreateFillMeanRms
//________________________________________________________
void GFOverlay::CreateFillMeanRms(const TObjArray &hists, Int_t layer, const char *dirName,
std::vector<TH1*> &meanHists, std::vector<TH1*> &rmsHists) const
{
// fill mean/rms from hists into the corresponding meanHists/rmsHists
// if these are empty, create one hist for each slot of hists (even for empty ones!)
if (hists.IsEmpty()) return;
TH1 *h1 = 0;
for (Int_t iH = 0; !h1 && iH < hists.GetEntriesFast(); ++iH) {
h1 = static_cast<TH1*>(hists[iH]);
}
if (!h1 || h1->GetDimension() > 1) return; // only for 1D hists
if (meanHists.empty()) { // create mean/RMS hists if not yet done
const Float_t min = h1->GetXaxis()->GetXmin()/3.;
const Float_t max = h1->GetXaxis()->GetXmax()/3.;
const Int_t nBins = h1->GetNbinsX()/2;
for (Int_t iHist = 0; iHist < hists.GetEntriesFast(); ++iHist) {
TH1 *hMean = new TH1F(Form("mean%d_%d", layer, iHist), Form("%s: mean", dirName),
nBins, min, max);
meanHists.push_back(hMean);
TH1 *hRms = new TH1F(Form("rms%d_%d", layer, iHist), Form("%s: RMS", dirName),
nBins, 0., max);
rmsHists.push_back(hRms);
}
}
// now fill mean and rms hists
for (Int_t iHist = 0; iHist < hists.GetEntriesFast(); ++iHist) {
TH1 *h = static_cast<TH1*>(hists[iHist]);
if (!h) continue;
meanHists[iHist]->Fill(h->GetMean());
rmsHists[iHist]->Fill(h->GetRMS());
}
}
示例4: fixLeafOffsets
void Output::fixLeafOffsets( TBranch * b)
{
// recalculates the addresses for all the leaves.
//
// when constructing a branch with containing a variable length array with the index
// variable in the same branch it is not possible to specify the span of the index variable
// This span defaults to zero. When the addresses are asigned to the various leaves in the branch
// it calculates the size of the particular leaf (variable length array) in the buffer by looking
// at the span of the index variable - 0 in this case! using the method TLeaf::GetLen().
// The following code shoudl be applied to the branch after the spans of the index variables have been
// specified manually using the TLeaf::SetMaximum method. This time the GetLen method calculates the correct offset.
TObjArray * leaves = b->GetListOfLeaves();
char * addr = b->GetAddress();
int offset = 0;
int nleaves = leaves->GetEntriesFast();
// loop over the leaves:
for( int i =0; i < nleaves; ++i) {
TLeaf * leaf = (TLeaf *)leaves->UncheckedAt(i);
leaf->SetAddress( addr + offset );
int oldOffset = leaf->GetOffset();
leaf->SetOffset( offset );
//std::cout << " offset changed from : " << oldOffset << " to " << offset << std::endl;
TLeaf * index = leaf->GetLeafCount();
int nelements = 1;
if( index ) {
nelements = index->GetMaximum(); // deal with variable length arrays
} else {
nelements = leaf->GetLenStatic(); // deal with single variables and fixed length arrays
}
offset += leaf->GetLenType() * nelements;
}
}
示例5:
Bool_t
RecoParamWithTPCDistortions(AliCDBManager *man) {
// check methods exist
if (!AliRecoParam::Class()->GetMethodAny("SuggestRunEventSpecie"))
return kFALSE;
if (!AliTPCRecoParam::Class()->GetMethodAny("GetUseCorrectionMap"))
return kFALSE;
// get event specie from GRP
AliCDBEntry *grpe = man->Get("GRP/GRP/Data");
if (!grpe) return kFALSE;
AliGRPObject *grp = (AliGRPObject *)grpe->GetObject();
AliRecoParam::EventSpecie_t evs = AliRecoParam::SuggestRunEventSpecie(grp->GetRunType(),
grp->GetBeamType(),
grp->GetLHCState());
// get TPC RecoParam for event specie
AliCDBEntry *pare = man->Get("TPC/Calib/RecoParam");
if (!pare) return kFALSE;
TObjArray *parl = (TObjArray *)pare->GetObject();
AliTPCRecoParam *par = NULL;
for (Int_t i = parl->GetEntriesFast(); i--;) {
AliTPCRecoParam *p = (AliTPCRecoParam *)parl->UncheckedAt(i);
if (!p || !(p->GetEventSpecie() & evs)) continue;
par = p;
break;
}
// check if use correction map
if (!par->GetUseCorrectionMap())
return kFALSE;
return kTRUE;
}
示例6: SaveCanvas
// ______________________________________________________________________________________
void SaveCanvas(const Char_t* name, Bool_t isNice = kTRUE) {
// -- Write out canvas
gSystem->Exec(Form("mkdir -p results/nice/%s/png", name));
gSystem->Exec(Form("mkdir -p results/nice/%s/pdf", name));
gSystem->Exec(Form("mkdir -p results/nice/%s/eps", name));
gSystem->Exec(Form("mkdir -p results/nice/%s/gif", name));
gSystem->Exec(Form("mkdir -p results/nice/%s/root", name));
if (isNice) {
gSystem->Exec(Form("mkdir -p results/nice/pdf"));
gSystem->Exec(Form("mkdir -p results/nice/png"));
}
// -----------------------------------------------------
for (Int_t idx = 0; idx < canA.GetEntriesFast() ; ++idx) {
TCanvas* c = static_cast<TCanvas*>(canA.At(idx));
if (!c)
continue;
c->SaveAs(Form("results/nice/%s/png/%s.png", name, c->GetName()));
c->SaveAs(Form("results/nice/%s/eps/%s.eps", name, c->GetName()));
c->SaveAs(Form("results/nice/%s/gif/%s.gif", name, c->GetName()));
c->SaveAs(Form("results/nice/%s/pdf/%s.pdf", name, c->GetName()));
c->SaveAs(Form("results/nice/%s/root/%s.C", name, c->GetName()));
c->SaveAs(Form("results/nice/%s/root/%s.root", name, c->GetName()));
if (isNice) {
c->SaveAs(Form("results/nice/pdf/%s.pdf", c->GetName()));
c->SaveAs(Form("results/nice/png/%s.png", c->GetName()));
}
}
}
示例7: CountChargedinScint
Int_t CountChargedinScint()
{
Int_t ncharged = 0;
TObjArray* tracks = gGeoManager->GetListOfTracks();
for(Int_t i=0,l=tracks->GetEntriesFast();i<l;++i) {
TVirtualGeoTrack* track = (TVirtualGeoTrack*)tracks->At(i);
//track->Print();
Int_t pdg = track->GetPDG();
Double_t charge = TDatabasePDG::Instance()->GetParticle(pdg)->Charge();
if( charge == 0 ) continue;
Double_t x,y,z,t;
TGeoNode* lastnode = NULL;
for(Int_t j=0,lp=track->GetNpoints();j<lp;++j) {
track->GetPoint(j,x,y,z,t);
TGeoNode* node = gGeoManager->FindNode(x,y,z);
if(! node ) continue;
//node->Print();
if( lastnode == node ) continue;
lastnode = node;
//is scintillator ?
//std::cout << node->GetMedium()->GetMaterial()->GetZ() << std::endl;
if(node->GetMedium()->GetMaterial()->GetZ() == 1)
++ncharged;
}
//std::cout << "charge:" << ncharged << std::endl;
}
//std::cout << ncharged << std::endl;
return ncharged;
}
示例8: GetNumHistsOf
//________________________________________________________
Int_t GFHistManager::GetNumHistsOf(Int_t layer)
{
if(!this->CheckDepth("GetNumHistsOf", layer, kFALSE)) return 0;
TObjArray* layerHists = static_cast<TObjArray*>(fHistArrays->At(layer));
if(layerHists) return layerHists->GetEntriesFast();
return 0;
}
示例9: PublicationHisto
void PublicationHisto(TString config=""){
//gROOT->SetStyle("Plain"); gROOT->ForceStyle();
gROOT->ProcessLine(".x /home/aran/.rootlogon.C");
gStyle->SetPadBottomMargin(.160); // Need this for subscripts
gStyle->SetPadTopMargin(.08);
TEnv *params = new TEnv("PubHisto");
params->ReadFile (config, kEnvChange);
TString type=params->GetValue("Histo.Type", "PublicationHisto");
if (type != "PublicationHisto"){
printf(" Must have Histo.Type: PublicationHisto in config file");
return;
}
// Fetch the histos from the different files:
TString hname=params->GetValue("Histo.Name", "BOGUSNAME");
TObjArray sameHistos;
if (hname == "3"){// ok this means we want to add 3 histos
TString h1=params->GetValue("Histo.1.Name", "BOGUS_H1");
TString h2=params->GetValue("Histo.2.Name", "BOGUS_H2");
TString h3=params->GetValue("Histo.3.Name", "BOGUS_H3");
printf("Adding histos: %s, %s, %s \n",h1.Data(),h2.Data(), h3.Data());
TObjArray sameHistos = GetThreeSameHistos(h1,h2,h3,params);
} else {// normal case
TObjArray sameHistos = GetSameHistos(hname,params);
}
// Plot them:
printf (" Found %3i histos \n",sameHistos.GetEntriesFast());
TCanvas *c1 = new TCanvas("c1","PubHist");
PlotPubHisto(sameHistos,params);
TString outfile=params->GetValue("Output.File", "dummy.eps");
c1->SaveAs(outfile.Data());
}
示例10: compareFileAges
int compareFileAges(const char* newestCandidate, const char* filesToCompare) {
Long_t dummy = 0;
Long_t candidateTime = 0;
Long_t comparisonTime = 0;
int found = !gSystem->GetPathInfo(newestCandidate, &dummy, &dummy, &dummy,
&candidateTime);
//cout << newestCandidate << ": " << candidateTime << endl;
// If the first file is not found, return 1
if(!found)
return 1;
// Separate files in the list into an array
TObjArray* compareList = TString(filesToCompare).Tokenize(" ");
// Go through the array
for (Int_t iFile = 0; iFile < compareList->GetEntriesFast(); ++iFile) {
found = !gSystem->GetPathInfo(compareList->At(iFile)->GetName(), &dummy,
&dummy, &dummy, &comparisonTime);
//cout << compareList->At(iFile)->GetName() << ": " << comparisonTime << endl;
// If the first file doesn't have the biggest modification time, return 1
if(found && candidateTime <= comparisonTime)
return 1;
}
// The first file had the biggest modification time: return 0
return 0;
}
示例11:
// This piece of code is borrowed from Argo written by Nathaniel Tagg
std::vector<std::string> DataFetcher::FindLeavesOfType(std::string pattern) {
/// Look in the tree and try to find a leaf element that matches 'pattern'.
/// Return the full name of that leaf.
std::vector<std::string> leaf_names;
// Strip whitespace from pattern.
pattern.erase(std::remove_if(pattern.begin(), pattern.end(), ::isspace),
pattern.end());
TObjArray * list = tree_->GetListOfLeaves();
for (int i = 0; i < list->GetEntriesFast(); ++i) {
TObject * o = list->At(i);
TLeaf * leaf = (TLeaf *) o;
std::string name = leaf->GetTypeName();
// Strip whitespace from pattern.
name.erase(std::remove_if(name.begin(), name.end(), ::isspace),
name.end());
size_t found = name.find(pattern);
if (found != std::string::npos) {
// Return this match.
leaf_names.push_back(leaf->GetName());
}
}
return leaf_names;
}
示例12: vol
GeoHandler& GeoHandler::i_collect(const TGeoNode* current, int level, Region rg, LimitSet ls) {
TGeoVolume* volume = current->GetVolume();
TObjArray* nodes = volume->GetNodes();
int num_children = nodes ? nodes->GetEntriesFast() : 0;
Volume vol(volume);
Region region = vol.region();
LimitSet limits = vol.limitSet();
if ( m_propagateRegions ) {
if ( !region.isValid() && rg.isValid() ) {
region = rg;
vol.setRegion(region);
}
if ( !limits.isValid() && ls.isValid() ) {
limits = ls;
vol.setLimitSet(limits);
}
}
(*m_data)[level].insert(current);
//printf("GeoHandler: collect level:%d %s\n",level,current->GetName());
if (num_children > 0) {
for (int i = 0; i < num_children; ++i) {
TGeoNode* node = (TGeoNode*) nodes->At(i);
i_collect(node, level + 1, region, limits);
}
}
return *this;
}
示例13: infile
vector<int> inputEMAP(vector<int> compVar, vector<int> compIdx){
vector<string> lines;
std::string line;
lines.clear();
std::ifstream infile(gl_emap, std::ios_base::in);
if (!infile) {
cout<<"Cannot open file "<<gl_emap<<endl;
return false;
}
while(getline(infile, line, '\n')) {
/*
string dummy; //0
string crate; //1
string slot; //2
string tb; //3
string dcc; //4
string spigot; //5
string fiber; //6
string fiberchan; //7
string subdet; //8
string ieta; //9
string iphi; //10
string depth; //11
*/
TString conv = TString(line.c_str());
TObjArray* aline = conv.Tokenize(" ");
bool foundIt = true;
for(int idx=0; idx<compVar.size() && foundIt; idx++){
TString s = ((TObjString*)(aline->At(compIdx[idx])))->GetString();
if( compVar[idx] != atoi(s.Data())) foundIt = false;
}
if(foundIt){
vector<int> found;
for(int l=0; l<aline->GetEntriesFast(); l++){
TString s = ((TObjString*)(aline->At(l)))->GetString();
if(l!=3 && l!=8) found.push_back(atoi(s.Data()));
else{
if(l==3){
if(s==TString("t")) found.push_back(0);
else if(s==TString("b")) found.push_back(1);
}
if(l==8){
if(s==TString("HB")) found.push_back(0);
else if(s==TString("HE")) found.push_back(1);
else if(s==TString("HF")) found.push_back(2);
else if(s==TString("HO")) found.push_back(3);
}
}
}
return found;
}
}
vector<int> notFound;
return notFound;
}
示例14: KeyContainsListMember
//________________________________________________________
bool GFOverlay::KeyContainsListMember(const TString &key, const TObjArray &list) const
{
for (Int_t i = 0; i < list.GetEntriesFast(); ++i) {
if (key.Contains(list[i]->GetName())) return true;
}
return false;
}
示例15: Print
//________________________________________________________
void GFHistManager::Print(const char* filename, Bool_t add)
{
// print all layers of histograms to ps-file 'filename'
// if 'add == true' puts '(' or ')' only if 'filename' ends with it,
// e.g. if i is loop variable
// GFHistManager *man = ...;
// TString name("XXX.ps");
// if(i == 0) man->Print(name + '(');
// else if(i == last) man->Print(name + ')');
// else man->Print(name, kTRUE);
const Bool_t rootIsBatch = gROOT->IsBatch();
if(fBatch){
gROOT->SetBatch();
for(Int_t i = 0; i < fDepth; ++i){
this->DrawReally(i);
}
}
gROOT->SetBatch(rootIsBatch);
TObjArray cans;
TIter canArrayIter(fCanArrays);
while(TObjArray* canArray = static_cast<TObjArray*>(canArrayIter.Next())){
cans.AddAll(canArray);
}
const Int_t nCans = cans.GetEntriesFast();
if(nCans == 1) {
cans.At(0)->Print(filename);
return;
}
TString plainName(filename);
const Bool_t starting = plainName.EndsWith("(");
if(starting) {
const Ssiz_t ind = plainName.Last('(');
plainName.Remove(ind);
// plainName.ReplaceAll("(", "");
}
const Bool_t ending = plainName.EndsWith(")");
if(ending) {
const Ssiz_t ind = plainName.Last(')');
plainName.Remove(ind);
// plainName.ReplaceAll(")", "");
}
for(Int_t i = 0; i < nCans; ++i){
if(i == 0 && !ending && (!add || starting)) {
cans.At(i)->Print(plainName + "(");
} else if(i == nCans - 1 && !starting && (!add || ending)) {
cans.At(i)->Print(plainName + ")");
} else {
cans.At(i)->Print(plainName);
}
}
}