本文整理汇总了C++中TObjArray::AddAt方法的典型用法代码示例。如果您正苦于以下问题:C++ TObjArray::AddAt方法的具体用法?C++ TObjArray::AddAt怎么用?C++ TObjArray::AddAt使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TObjArray
的用法示例。
在下文中一共展示了TObjArray::AddAt方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: AddSample
void AddSample(TMap &lookup,
const char *key, const char* datadir, const char * pattern, const char *sampletype, const char *dataformat){
//
// Add sample entry to the lookup table
//
TObjArray *infos = new TObjArray();
infos->AddAt(new TObjString(datadir), 0);
infos->AddAt(new TObjString(pattern), 1);
infos->AddAt(new TObjString(sampletype), 2);
infos->AddAt(new TObjString(dataformat), 3);
lookup.Add(new TObjString(key), infos);
}
示例2: GetTerminateOptions
//_______________________________________
TObjArray* GetTerminateOptions ( TString taskOpt, Bool_t isMC )
{
TObjArray* terminateList = 0x0;
if ( ! taskOpt.IsNull() ) {
TObjArray* optList = taskOpt.Tokenize(";");
for ( Int_t iopt=0; iopt<optList->GetEntries(); iopt++ ) {
TString currOpt = (static_cast<TObjString*>(optList->At(iopt)))->GetString();
if ( ! currOpt.Contains("@") ) continue;
TObjArray* tmpList = currOpt.Tokenize("@");
if ( tmpList->GetEntries() == 4 ) {
terminateList = tmpList;
break;
}
delete tmpList;
}
delete optList;
}
else {
terminateList = new TObjArray(4);
terminateList->SetOwner();
TString physSel = "", trigClasses = "", centr = "", furtherOpt = "";
if ( isMC ) {
physSel = "PhysSelPass,PhysSelReject";
trigClasses = "ANY";
centr = "-5_105";
furtherOpt = "MC verbose";
}
//TString GetPeriod(opt);
terminateList->AddAt(new TObjString(physSel),0);
terminateList->AddAt(new TObjString(trigClasses),1);
terminateList->AddAt(new TObjString(centr),2);
terminateList->AddAt(new TObjString(furtherOpt),3);
}
// if ( terminateList ) {
// printf("Printing terminate list\n"); // REMEMBER TO CUT
// PrintNames("Terminate options", terminateList);
// printf(" ***************:\n");
// }
return terminateList;
}
示例3: AddFit
void AddFit(TH2* h2d)
{
//
// Fit in slices and draw mean and sigma
//
TF1 *f1 = new TF1("f1", "gaus");
f1->SetRange(-1.5,1.5);
TObjArray aSlices;
h2d->FitSlicesY(f1, 0,-1, 0, "QNR",&aSlices);
aSlices.SetOwner(1);
TH1* hMean=(TH1*)aSlices.At(1);
TH1* hSigma=(TH1*)aSlices.At(2);
TH1* hChi2=(TH1*)aSlices.At(3);
hChi2->Scale(1./10.);
aSlices.AddAt(0x0,1);
aSlices.AddAt(0x0,2);
aSlices.AddAt(0x0,3);
hMean->SetMarkerStyle(20);
hMean->SetMarkerSize(0.3);
hMean->SetOption("same");
h2d->GetListOfFunctions()->Add(hMean);
hSigma->SetMarkerStyle(20);
hSigma->SetMarkerSize(0.3);
hSigma->SetOption("same");
hSigma->SetMarkerColor(kMagenta);
h2d->GetListOfFunctions()->Add(hSigma);
hChi2->SetOption("same");
hChi2->SetMarkerColor(kMagenta + 2);
hChi2->SetLineColor(kMagenta + 2);
h2d->GetListOfFunctions()->Add(hChi2);
TLine *l=0x0;
l=new TLine(h2d->GetXaxis()->GetXmin(),0,h2d->GetXaxis()->GetXmax(),0);
l->SetLineStyle(2);
h2d->GetListOfFunctions()->Add(l);
l=new TLine(h2d->GetXaxis()->GetXmin(),1,h2d->GetXaxis()->GetXmax(),1);
l->SetLineStyle(2);
h2d->GetListOfFunctions()->Add(l);
}
示例4: FindDataSample
bool FindDataSample(const TMap &lookup, TObjArray &sampleinfis){
//
// Find Data sample in the list of samples
//
TObjArray *entry = dynamic_cast<TObjArray *>(lookup.GetValue(g_sample.Data()));
if(!entry){
printf("Sample %s not found in the list of samples", g_sample.Data());
return false;
}
// Copy to output container
sampleinfis.SetOwner(kFALSE);
for(int ival = 0; ival < 4; ival++) sampleinfis.AddAt(entry->At(ival), ival);
return true;
}
示例5: CacheTestMCProductions
/// \brief Cache MC production trees, store summary information in formated text files -> root trees
/// \param dataType -
/// \param fileList
void CacheTestMCProductions(TString dataType, const char *fileList=NULL){
AliExternalInfo info;
info.fLoadMetadata=kFALSE;
TObjArray* periodList = NULL;
TArrayI nRuns;
if (fileList!=NULL) {
periodList=(gSystem->GetFromPipe(TString::Format("cat %s", fileList).Data())).Tokenize("\n");
nRuns.Set(periodList->GetEntries());
}else{
TTree * tree = info.GetTree("MonALISA.ProductionMC","","");
Int_t nProd=tree->GetEntries();
periodList = new TObjArray(nProd);
nRuns.Set(nProd);
TLeaf *leaf = tree->GetLeaf("Tag");
TLeaf *leafRuns = tree->GetLeaf("Number_of_runs");
for (Int_t iProd=0; iProd<nProd; iProd++){
tree->GetEntry(iProd);
TString prodName=((char*)leaf->GetValuePointer());
if (prodName.Contains("LHC")==0) continue;
periodList->AddAt(new TObjString(((char*)leaf->GetValuePointer())),iProd);
nRuns[iProd]=leafRuns->GetValue();
}
delete tree;
}
for (Int_t iPeriod=0; iPeriod<periodList->GetEntriesFast(); iPeriod++){
TObjString * pName= (TObjString*)periodList->At(iPeriod);
if (pName==NULL) continue;
TTree* tree = info.GetTree(dataType.Data(),periodList->At(iPeriod)->GetName(),"passMC");
if (tree){
Int_t entries=tree->Draw("run","1","goff");
TString sInfo=periodList->At(iPeriod)->GetName();
sInfo+="\t";
sInfo+=dataType;
sInfo+="\t";
sInfo+=TString::Format("%d\t",entries);
sInfo+=TString::Format("%d\t",nRuns[iPeriod]);
for (Int_t j=0; j<entries; j++) {
sInfo+=TString::Format("%2.0f,",tree->GetV1()[j]);
::Info("CacheTestMCProductionsRun:","%s\t%s\t%d\t%d\t%d\t%2.0f",periodList->At(iPeriod)->GetName(),dataType.Data(),entries,nRuns[iPeriod],j, tree->GetV1()[j]);
}
sInfo+="0";
::Info("CacheTestMCProductionsPeriod:","%s\n",sInfo.Data());
delete tree;
}else{
::Error("CacheTestMCProductionsPeriod:","%s\t%s\t-1\t%d\t0",periodList->At(iPeriod)->GetName(), dataType.Data(),nRuns[iPeriod]);
}
}
}
示例6: SetUserTree
//.........这里部分代码省略.........
// root[0] T->Draw("PARNAME", "PARNAME_M")
// will histogram the value of PARNAME for each event in which it is present.
// (if the selection condition "PARNAME_M" is not used, the histogram will also be filled with a 0
// for each event in which PARNAME does not appear).
// N.B. the PARNAME alias is in fact the sum of the values of PARNAME in each event.
// If PARNAME_M>1 in some events, it is not the individual values but their sum which will
// be histogrammed in this case.
//
// Thus, if the data file has parameters called "PAR_1" and "PAR_2",
// the following command will work
//
// root[0] T->Draw("PAR_1:PAR_2", "PAR_1_M&&PAR_2_M", "col")
//
// even though no branches "PAR_1" or "PAR_2" exist.
//
//
//
// opt = "leaves":
//
// The TTree will have a branch/leaf for each parameter. This option is slower and produces
// larger files.
//
// If the option string contains both "arrays" and "leaves", then both structures will be used
// (in this case there is a high redundancy, as each parameter is stored twice).
//
// The full list of parameters is stored in a TObjArray in the list returned by TTree::GetUserInfo().
// Each parameter is represented by a TNamed object.
// In order to retrieve the name of the parameter with index 674 (e.g. taken from branch ParNum),
// do:
// TObjArray* parlist = (TObjArray*) T->GetUserInfo()->FindObject("ParameterList");
// cout << "Par 674 name = " << (*parlist)[674]->GetName() << endl;
//
//
// Automatic creation & filling of Scalers TTree
//
// give an option string containing "scalers", i.e. "leaves,scalers", or "ARRAYS+SCALERS", etc.
// a TTree with name 'Scalers' will be created, all scaler buffers will be written in it.
TString option = opt;
option.ToUpper();
make_arrays = option.Contains("ARRAYS");
make_leaves = option.Contains("LEAVES");
Bool_t make_scalers = option.Contains("SCALERS");
if(make_scalers){
fGanilData->SetScalerBuffersManagement(GTGanilData::kAutoWriteScaler);
}
fUserTree = T;
if( make_arrays ){
Int_t maxParFired = GetRawDataParameters()->GetEntries();
ParVal = new UShort_t[maxParFired];
ParNum = new UInt_t[maxParFired];
fUserTree->Branch("NbParFired", &NbParFired, "NbParFired/I");
fUserTree->Branch("ParNum", ParNum, "ParNum[NbParFired]/i");
fUserTree->Branch("ParVal", ParVal, "ParVal[NbParFired]/s");
}
if( make_leaves ){
TIter next_rawpar( GetRawDataParameters() );
KVACQParam* acqpar;
while( (acqpar = (KVACQParam*)next_rawpar()) ){
TString leaf;
leaf.Form("%s/S", acqpar->GetName());
// for parameters with <=8 bits only use 1 byte for storage
if(acqpar->GetNbBits()<=8) leaf += "1";
fUserTree->Branch( acqpar->GetName(), *(acqpar->ConnectData()), leaf.Data() );
}
}
#if ROOT_VERSION_CODE > ROOT_VERSION(5,25,4)
#if ROOT_VERSION_CODE < ROOT_VERSION(5,26,1)
// The TTree::OptimizeBaskets mechanism is disabled, as for ROOT versions < 5.26/00b
// this lead to a memory leak
fUserTree->SetAutoFlush(0);
#endif
#endif
// add list of parameter names in fUserTree->GetUserInfos()
// and if option="arrays" add aliases for each parameter & its multiplicity
// TObjArray has to be as big as the largest parameter number in the list
// of raw data parameters. So first loop over parameters to find max param number.
UInt_t maxpar = 0;
TIter next(GetRawDataParameters());
KVACQParam* par;
while( (par=(KVACQParam*)next()) ) if (par->GetNumber()>maxpar) maxpar=par->GetNumber();
TObjArray *parlist = new TObjArray(maxpar,1);
parlist->SetName("ParameterList");
next.Reset();
while( (par = (KVACQParam*)next()) ){
parlist->AddAt( new TNamed( par->GetName(), Form("index=%d",par->GetNumber()) ), par->GetNumber() );
if( make_arrays ){
fUserTree->SetAlias( par->GetName(), Form("Sum$((ParNum==%d)*ParVal)", par->GetNumber() ) );
fUserTree->SetAlias( Form("%s_M", par->GetName()), Form("Sum$(ParNum==%d)", par->GetNumber() ) );
}
}
fUserTree->GetUserInfo()->Add(parlist);
}
示例7: PlotPubHisto
void PlotPubHisto(TObjArray histograms,TEnv *params){
// This is a modification of the AddHistos macro
// Number of histos to plot:
Int_t ntot = histograms.GetEntries();
// Check we have what we expect (the order should be: data, qcd, wjets, etc...)
for(Int_t i = 0; i<ntot; i++){
if(histograms[i]==0) {
cout<<"Error in AddHistos: histogram "<<i<<" is a NULL pointer!"<<endl;
return;
}
TH1F * hthis = (TH1F*) histograms[i];
// include the overflow/underflow bins:
int numbins = hthis->GetNbinsX(); //this is the last bin plotted
double hicontent = hthis->GetBinContent(numbins);
double overflow = hthis->GetBinContent(numbins+1);// this bin contains the overflow
double locontent = hthis->GetBinContent(1);// this is the first bin plotted
double underflow = hthis->GetBinContent(0);// this bin contains the underflow
if (underflow>0 || overflow>0){
//printf("%-20s numbins=%4i hicontent=%4.2f over=%4.2f locontent=%4.2f underflow=%4.2f \n",
// title.Data(),numbins,hicontent,overflow,locontent,underflow);
}
hthis->SetBinContent(numbins,hicontent+overflow);
hthis->SetBinContent(1,locontent+underflow);
}
// define a few additional line styles:
gStyle->SetLineStyleString(5,"20 12 4 12");
gStyle->SetLineStyleString(6,"20 12 4 12 4 12 4 12");
gStyle->SetLineStyleString(7,"20 20");
gStyle->SetLineStyleString(8,"20 12 4 12 4 12");
gStyle->SetLineStyleString(9,"80 25");
gStyle->SetLineStyleString(10,"50 10 10 10");
gStyle->SetLineStyleString(17,"30 25");
gStyle->SetLineStyleString(20,"60 20");
gStyle->SetLineStyleString(21,"60 20 20 20");
int lineStyle[20];
for(int i=0;i<20;i++) {
lineStyle[i]=i;
}
// the first histogram in the list:
TH1F *h0=((TH1F*) histograms[0])->Clone();
// histogram output filename
TString oFileName=params->GetValue("Histo.Output.Filename","bogus.eps");
// figure out the number of signals
Int_t nsig=1;
if(params->Defined("Histo.Signal.Title.1")) nsig=1;
if(params->Defined("Histo.Signal.Title.2")) nsig=2;
if(params->Defined("Histo.Signal.Title.3")) nsig=3;
cout << " I will use nsig = " << nsig << " signal sources" << endl;
// Do the cumulative summing, except for the data
TObjArray addedhistos; addedhistos.Clear();
TObjArray signalhistos; signalhistos.Clear();
TString sampletitles[20];
Int_t nbkg=0;
for(Int_t i = 1; i<ntot; i++){// i runs over histograms[i], so data is for i=0
ostringstream baseSrcName;
baseSrcName << "Files." << i+1 << ".";// Counting starts at 1: Files.1.Name: Data
TString bSrcName(baseSrcName.str().c_str());
// skip some if we want to show them as lines
TString htitle=params->GetValue(bSrcName+"Title","");
sampletitles[i-1]=htitle;
if(params->GetValue("Histo.ShowSignalSeparately",0)==1 &&
// skip the last two if the signal title is not defined:
( ( !(params->Defined("Histo.Signal.Title")||params->Defined("Histo.Signal.Title.1")) && i>=ntot-nsig)
// skip the signal if the signal title is defined
|| params->GetValue("Histo.Signal.Title",".")==htitle
|| params->GetValue("Histo.Signal.Title.1",".")==htitle
|| params->GetValue("Histo.Signal.Title.2",".")==htitle
|| params->GetValue("Histo.Signal.Title.3",".")==htitle
) ) {
TH1F * hthis = (TH1F*) histograms[i]->Clone();
cout<<" Found signal in location "<<i+1<<" with name "<<htitle.Data()<<endl;
signalhistos.Add(hthis);
} else {
TH1F * hthis = (TH1F*) histograms[i]->Clone();
addedhistos.Add(hthis); // Fill in the new TObjArray with a copy
//cout << " Adding bkg " << i << " " << htitle.Data() << " " << hthis->Integral() << endl;
// add all of the backgrounds
if (i>1) {// i=0 is the data, and we must start with the second
// background to add the previous
TH1F * hprevious = (TH1F*) addedhistos[i-2];
if ( hthis->GetXaxis()->GetNbins() != hprevious->GetXaxis()->GetNbins() ) {
// Protection against _whoran histogram.
// We cannot add two histograms with different numbers of bins!
cout<<"Error in AddHistos: incompatible number of bins!"<<endl;
return;
}
hthis->Add(hprevious); // Do the addition
addedhistos.RemoveAt(i-1); // And substitute whatever we had
addedhistos.AddAt(hthis,i-1);
nbkg++;
//cout << "Substituing bkg " << i << " + " << i-1 << " in addedhistos["<< i-1 <<"]" << endl;
}
//.........这里部分代码省略.........
示例8: AliITSDigitPlot
//----------------------------------------------------------------------
void AliITSDigitPlot(Int_t istart=0,Int_t iend=-1,
const char *filename="galice.root"){
// Macro to plot digits from many events
// Inputs:
// Int_t istart Starting event number
// Int_t iend Last event number, =-1 all
// Outputs:
// none.
// Return:
// none.
if (gClassTable->GetID("AliRun") < 0) {
gROOT->ProcessLine(".x $(ALICE_ROOT)/macros/loadlibs.C");
}
if(gAlice){
delete AliRunLoader::Instance();
delete gAlice;
gAlice=0;
} // end if gAlice
Int_t nevents=0,nmodules=0,retval=0;
Int_t i,j,module,dig,ndig,row,column,signal,det;
AliITS *its = 0;
AliITSgeom *gm = 0;
AliRunLoader *rl = 0;
AliITSLoader *ld = 0;
TTree *treeD = 0;
TBranch *br = 0;
TClonesArray *digits = 0;
AliITSdigit *d = 0;
TObjArray *digDet = 0;
Char_t *branchname[3] = {"ITSDigitsSPD","ITSDigitsSDD","ITSDigitsSSD"};
//
rl = AliRunLoader::Open(filename);
if(!rl){
cerr<<"Error, can not open file "<<filename<<endl;
return;
} // end if !rl
retval = rl->LoadgAlice();
if (retval){
cerr<<"Error, LoadgAlice returned error"<<endl;
return;
}
gAlice = rl->GetAliRun();
retval = rl->LoadHeader();
if (retval){
cerr<<"Error, LoadHeader returned error"<<endl;
return;
} // end if
ld = (AliITSLoader*) rl->GetLoader("ITSLoader");
if(!ld){
cerr<<"Error, ITS loader not found"<<endl;
return;
} // end if
its = (AliITS*) gAlice->GetModule("ITS");
if(!its){
cerr <<"Error, No AliDetector ITS found on file"<<endl;
return;
} // end if
gm = its->GetITSgeom();
if(!gm){
cerr <<"Error, AliITSgeom not initilized in module ITS"<<endl;
return;
} // end if
nevents = rl->GetNumberOfEvents();
if(iend>nevents) iend = nevents;
if(iend<0) iend = nevents;
if(iend<=istart){delete rl; return;}
nmodules = gm->GetIndexMax();
ld->GetDigitsDataLoader()->Load("read");
treeD = ld->TreeD();
if(!treeD){
cerr <<"Error, could not get TreeD="<<treeD << endl;
return;
} // end if !treeD
digDet = new TObjArray(3);
its->SetDefaults();
for(det=0;det<3;det++){
digDet->AddAt(new TClonesArray(its->GetDetTypeSim()->
GetDigitClassName(det),1000),det);
br = treeD->GetBranch(branchname[det]);
br->SetAddress(&((*digDet)[det]));
} // end for det
//
SetUPHistograms();
//
for(i=istart;i<iend;i++){
rl->GetEvent(i);
treeD = ld->TreeD();
for(det=0;det<3;det++){
((TClonesArray*)(digDet->At(det)))->Clear();
br = treeD->GetBranch(branchname[det]);
br->SetAddress(&((*digDet)[det]));
} // end for det
for(module=0;module<nmodules;module++){
for(j=0;j<3;j++) ((TClonesArray*)(digDet->At(j)))->Clear();
treeD->GetEvent(module);
digits = (TClonesArray*) (digDet->At(0)); // SPD only.
ndig = digits->GetEntriesFast();
//.........这里部分代码省略.........
示例9: CacheTrendingProductions
/// Cache MC production information
void CacheTrendingProductions(TString dataType){
AliExternalInfo info;
info.fLoadMetadata=kFALSE;
TObjArray* periodList = NULL, *idList=NULL;
//
TTree * tree = info.GetTree("MonALISA.ProductionCycle","","");
Int_t nProd=tree->GetEntries();
periodList = new TObjArray(nProd);
idList= new TObjArray(nProd);
TLeaf *leafTag = tree->GetLeaf("Tag");
TLeaf *leafID = tree->GetLeaf("ID");
for (Int_t iProd=0; iProd<nProd; iProd++){
tree->GetEntry(iProd);
TString prodName=((char*)leafTag->GetValuePointer());
TString idName =TString::Format("%d",TMath::Nint(leafID->GetValue()));
if (prodName.Contains("LHC")==0) continue;
periodList->AddAt(new TObjString(prodName),iProd);
idList->AddAt(new TObjString(idName),iProd);
}
delete tree;
//
for (Int_t iPeriod=0; iPeriod<periodList->GetEntriesFast(); iPeriod++) {
TObjString * pName= (TObjString*)idList->At(iPeriod);
if (pName==NULL) continue;
TTree* treeP = info.GetTreeProdCycleByID(idList->At(iPeriod)->GetName());
if (treeP==NULL) continue;
TLeaf *leafOutput = treeP->GetLeaf("outputdir");
Int_t nRuns= treeP->GetEntries();
treeP->GetEntry(0);
TString path=((char*)leafOutput->GetValuePointer());
TObjArray *pArray = path.Tokenize("/");
if (pArray==NULL) continue;
Int_t nElems=pArray->GetEntries();
if (nElems<4) continue;
TString aperiod=pArray->At(3)->GetName();
TString apass =pArray->At(nElems-1)->GetName();
delete pArray;
::Info("CacheTrendingProductions","%s\t%s\t%s\t%s\t%d",idList->At(iPeriod)->GetName(),path.Data(), aperiod.Data(),apass.Data(),nRuns);
delete treeP;
TTree* treeQA = info.GetTree(dataType.Data(),aperiod.Data(),apass.Data());
if (treeQA){
Int_t entries=treeQA->Draw("run","1","goff");
TString sInfo=aperiod;
sInfo+="\t";
sInfo+=apass;
sInfo+="\t";
sInfo+=dataType;
sInfo+="\t";
sInfo+=TString::Format("%d\t",entries);
sInfo+=TString::Format("%d\t",nRuns);
for (Int_t j=0; j<entries; j++) {
sInfo+=TString::Format("%2.0f,",treeQA->GetV1()[j]);
::Info("CacheTrendingProductionsRun:","%s\t%s\t%s\t%d\t%d\t%2.0f",aperiod.Data(),apass.Data(),dataType.Data(),entries,nRuns,treeQA->GetV1()[j]);
}
sInfo+="0";
::Info("CacheTrendingProductionsPeriod:","%s\n",sInfo.Data());
delete treeQA;
}else{
::Error("CacheTrendingProductionsPeriod:","%s\t%s\t%s\t-1\t%d\t0",aperiod.Data(),apass.Data(), dataType.Data(),nRuns);
}
}
}