本文整理汇总了C++中TObjArray::Add方法的典型用法代码示例。如果您正苦于以下问题:C++ TObjArray::Add方法的具体用法?C++ TObjArray::Add怎么用?C++ TObjArray::Add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TObjArray
的用法示例。
在下文中一共展示了TObjArray::Add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: makeCaloMEtTriggerEffPlots_Ztautau
void makeCaloMEtTriggerEffPlots_Ztautau()
{
//--- stop ROOT from keeping references to all histograms
TH1::AddDirectory(false);
//--- suppress the output canvas
gROOT->SetBatch(true);
TString inputFilePath = "/data1/veelken/tmp/muonPtGt17/V10_5tauEnRecovery_L1ETM20Eff_v3/2011RunB/tauIdEfficiency/";
TString inputFileName = "analyzeTauIdEffHistograms_all_2011Oct30V10_5tauEnRecovery.root";
TString dqmDirectory = "";
TString meName_numerator_data = "%s_%s_numCaloMEt_HLT_IsoMu15_L1ETM20_tauDiscrHPScombLooseDBcorr_%s";
TString meName_numerator_mc = "%s_%s_numCaloMEt_L1_ETM20_tauDiscrHPScombLooseDBcorr_%s";
TString meName_denominator = "%s_%s_denomCaloMEt_tauDiscrHPScombLooseDBcorr_%s";
TObjArray processes;
processes.Add(new TObjString("Ztautau"));
processes.Add(new TObjString("Zmumu"));
processes.Add(new TObjString("WplusJets"));
processes.Add(new TObjString("QCD"));
processes.Add(new TObjString("TTplusJets"));
TString region_passed = "C1p";
TString region_failed = "C1f";
TString inputFileName_full = inputFilePath;
if ( !inputFileName_full.EndsWith("/") ) inputFileName_full.Append("/");
inputFileName_full.Append(inputFileName);
std::cout << "opening inputFile = " << inputFileName_full.Data() << std::endl;
TFile* inputFile = new TFile(inputFileName_full.Data());
TH1* histogram_numerator_Data_passed = getHistogram(inputFile, meName_numerator_data, "Data", region_passed);
TH1* histogram_denominator_Data_passed = getHistogram(inputFile, meName_denominator, "Data", region_passed);
TH1* histogram_numerator_mcSum_passed = getHistogram(inputFile, meName_numerator_mc, processes, region_passed);
TH1* histogram_denominator_mcSum_passed = getHistogram(inputFile, meName_denominator, processes, region_passed);
TH1* histogram_numerator_Data_failed = getHistogram(inputFile, meName_numerator_data, "Data", region_failed);
TH1* histogram_denominator_Data_failed = getHistogram(inputFile, meName_denominator, "Data", region_failed);
TH1* histogram_numerator_mcSum_failed = getHistogram(inputFile, meName_numerator_mc, processes, region_failed);
TH1* histogram_denominator_mcSum_failed = getHistogram(inputFile, meName_denominator, processes, region_failed);
TString outputFileName = Form("makeCaloMEtTriggerEffPlots_Ztautau.png");
makePlot_wrapper("",
histogram_numerator_Data_passed, histogram_denominator_Data_passed,
histogram_numerator_mcSum_passed, histogram_denominator_mcSum_passed,
histogram_numerator_Data_failed, histogram_denominator_Data_failed,
histogram_numerator_mcSum_failed, histogram_denominator_mcSum_failed,
"Data", "Simulation", region_passed, region_failed,
outputFileName);
delete inputFile;
}
示例2: SecondaryElectronsNeutrons
void SecondaryElectronsNeutrons(const char* fileName,int numEvents){
double XMAX = 2.75;
char histKey_1[128] ="secElectronKinE_00_01PID";
char histKey_2[128] ="secElectronKinE_00_02PID";
char histKey_3[128] ="secElectronKinE_00_03PID";
char histKey_4[128] ="secElectronKinE_00_04PID";
// Getting the files and thickness
FILE* in = fopen(fileName,"r");
TObjArray *files = new TObjArray();
TObjArray *histPID1 = new TObjArray();
TObjArray *histPID2 = new TObjArray();
TObjArray *histPID3 = new TObjArray();
TObjArray *histPID4 = new TObjArray();
TObjArray *thickness = new TObjArray();
char* token;
TFile* f = NULL;
TH1F* h = NULL;
TH1F* hRef = NULL;
TObjString *s = NULL;
if (in != NULL){
char line[128];
while ( fscanf(in,"%s\n",line) == 1 ){
f = new TFile(line,"READ");
files->Add(f);
// Getting the histograms
h = (TH1F*) f->Get(histKey_1);
histPID1->Add(h);
h = (TH1F*) f->Get(histKey_2);
histPID2->Add(h);
h = (TH1F*) f->Get(histKey_3);
histPID3->Add(h);
h = (TH1F*) f->Get(histKey_4);
histPID4->Add(h);
token = strtok(line,"_");
s = new TObjString(token);
thickness->Add(s);
}
fclose(in);
}
else{
perror(fileName);
}
fprintf(stdout,"Files:\n");
files->Print();
fprintf(stdout,"\nThickness:\n");
thickness->Print();
plotHistograms("SecElec_Neutrons_PID3.eps",histPID3,thickness,XMAX,"PID = 3","Electron Kinetic Energy (MeV)");
plotHistograms("SecElec_Neutrons_PID4.eps",histPID4,thickness,XMAX,"PID = 4","Electron Kinetic Energy (MeV)");
// Saving the histograms
saveHistograms("Neutron_PID3_HistData.txt", histPID3, thickness);
saveHistograms("Neutron_PID4_HistData.txt", histPID4, thickness);
}
示例3: PublishCanvas
void PublishCanvas(TList *qaList, const char* det, const char* name, TString nadd)
{
//
// draw all nSigma + signal histo
//
TObjArray arrHistos;
TPaveText pt(.1,.1,.9,.9,"NDC");
pt.SetBorderSize(1);
pt.SetFillColor(0);
pt.SetTextSizePixels(16);
pt.AddText(Form("%s PID QA",det));
if (!nadd.IsNull()){
pt.AddText(nadd.Data());
nadd.Prepend("_");
}
arrHistos.Add(&pt);
TH2 *hSig=Get2DHistogramfromList(qaList,det,Form("hSigP_%s",det));
if (hSig){
hSig->SetOption("colz");
arrHistos.Add(hSig);
}
for (Int_t i=0;i<AliPID::kSPECIESC;++i){
// for (Int_t i=0;i<AliPID::kSPECIES;++i){
if (i==(Int_t)AliPID::kMuon) continue;
TH2 *h=Get2DHistogramfromList(qaList,det,Form(name,AliPID::ParticleName(i)));
if (!h) continue;
h->SetOption("colz");
AddFit(h);
arrHistos.Add(h);
}
Int_t nPads=arrHistos.GetEntriesFast();
Int_t nCols = (Int_t)TMath::Ceil( TMath::Sqrt(nPads) );
Int_t nRows = (Int_t)TMath::Ceil( (Double_t)nPads/(Double_t)nCols );
fCanvas->Divide(nCols,nRows);
for (Int_t i=0; i<nPads;++i) {
fCanvas->cd(i+1);
SetupPadStyle();
arrHistos.At(i)->Draw();
}
fCanvas->Update();
fCanvas->Clear();
}
示例4: CreateDCSAliasMap
TMap* CreateDCSAliasMap()
{
// Creates a DCS structure
// The structure is the following:
// TMap (key --> value)
// <DCSAlias> --> <valueList>
// <DCSAlias> is a string
// <valueList> is a TObjArray of AliDCSValue
// An AliDCSValue consists of timestamp and a value in form of a AliSimpleValue
// In this example 6 aliases exists: DCSAlias1 ... DCSAlias6
// Each contains 1000 values randomly generated by TRandom::Gaus + 5*nAlias
TMap* aliasMap = new TMap;
aliasMap->SetOwner(1);
TRandom random;
FILE *fp = fopen("./DCSValues.txt","r");
char name[50];
Float_t val;
while(!(EOF == fscanf(fp,"%s %f",name,&val))){
TObjArray* valueSet = new TObjArray;
valueSet->SetOwner(1);
TString aliasName=name;
//printf("alias: %s\t\t",aliasName.Data());
int timeStamp=10;
if(aliasName.Contains("HV")) {
for(int i=0;i<200;i++){
dcsVal = new AliDCSValue((Float_t) (val+random.Gaus(0,val*0.1)), timeStamp+10*i);
valueSet->Add(dcsVal);
}
} else {
for(int i=0;i<2;i++){
AliDCSValue* dcsVal = new AliDCSValue((UInt_t) (val), timeStamp+10*i);
valueSet->Add(dcsVal);
}
}
aliasMap->Add(new TObjString(aliasName), valueSet);
}
fclose(fp);
return aliasMap;
}
示例5: AddHist
//_____________________________________________________
TLegendEntry* GFHistManager::AddHist(TH1* hist, Int_t layer, const char* legendTitle,
const char* legOpt)
{
// add hist to 'layer'th list of histos (expands, if layer does not already exist!)
if(!hist){
this->Warning("AddHist", "adding NULL pointer will be ignored!");
return NULL;
}
if(!this->CheckDepth("AddHist", layer)) return NULL;
GFHistArray* newHist = new GFHistArray;
newHist->Add(hist);
TObjArray* layerHistArrays = static_cast<TObjArray*>(fHistArrays->At(layer));
layerHistArrays->Add(newHist);
if(legendTitle){
TObjArray* legends = this->MakeLegends(layer);
TLegend* legend = new TLegend(fLegendX1, fLegendY1, fLegendX2, fLegendY2);
#if ROOT_VERSION_CODE < ROOT_VERSION(5,6,0)
if (TString(gStyle->GetName()) == "Plain") legend->SetBorderSize(1);
#endif
legends->AddAtAndExpand(legend, layerHistArrays->IndexOf(newHist));
return legend->AddEntry(hist, legendTitle, legOpt ? legOpt : fgLegendEntryOption.Data());
}
return NULL;
}
示例6: Format
/* *************************************************************************** *
* *
* Format: *
* *
* Save into a format to be used in main code *
* *
* *************************************************************************** */
void GeomAcc::Format(TString saveName, TString pol){
TString plotName;
if(pol == "NoPol/") plotName = "GeoEff";
else if (pol == "Long/") plotName = "GeoLongEff";
else if (pol == "Trans/") plotName = "GeoTransEff";
TFile *f1 = TFile::Open("Output/" + saveName);
TH2D *GeoEff2 = (TH2D*) f1->Get(plotName);
GeoEff2->SetName("Geometric Acceptance");
//
//hack to use existing description plot
//
TFile *f2 = TFile::Open("Description/" + saveName);
TH1 * Descrip = (TH1*) f2->Get("Description");
TObjArray * histList = new TObjArray(0);
histList->Add(GeoEff2);
histList->Add(Descrip);
TFile* saveFile = new TFile("Efficiency/"+ pol+ saveName, "recreate");
histList->Write();
saveFile->Close();
return;
}
示例7: GetThreeSameHistos
//
// Sometimes we have h_jet_pt1_os, h_jet_pt2_os, h_jet_pt3_os but no h_jet_pt
// This function allows to add all three histos in one file, for all files
//
TObjArray GetThreeSameHistos(TString h1name, TString h2name, TString h3name, TEnv *params){
TObjArray histos; histos.Clear();
int num_files = params->GetValue ("Files.Number", 0);
for (int i = 1; i <= num_files; i++) {
ostringstream baseName;
baseName << "Files." << i << ".";
TString bName (baseName.str().c_str());
TString fname (params->GetValue(bName+"Name", "bogus_file"));
Double_t factor = params->GetValue(bName+"Factor", 1.0);
TFile *f = new TFile (fname, "READ");
TH1F * h1 = (TH1*) f->Get(h1name);
TH1F * h2 = (TH1*) f->Get(h2name);
TH1F * h3 = (TH1*) f->Get(h3name);
if (h1 && h2 && h3){
h1->Sumw2(); h2->Sumw2(); h3->Sumw2(); // you need this for the KS test
h1->Add (h1, factor-1.000);// Apply scaling factor (default=1.0)
h2->Add (h2, factor-1.000);
h3->Add (h3, factor-1.000);
h1->Add (h2);
h1->Add (h3);
histos.Add(h1);
//cout << "reading histo " << i << " factor=" << factor << " integral " << h->Integral() << endl;
} else {
printf(" Could not find histogram %s in file %s \n",h1name.Data(),fname.Data());
exit;
}
}
return histos;
}
示例8: GetITSsaSpectrum
CombinedSpectra(const Char_t *fileoutname, Int_t what = -1)
{
TFile *itssafile = TFile::Open(itssafilename);
// TFile *itstpcfile = TFile::Open(itstpcfilename);
TFile *tpctoffile = TFile::Open(tpctoffilename);
TFile *toffile = TFile::Open(toffilename);
TFile *fileout = TFile::Open(fileoutname, "RECREATE");
TH1D *hITSsa, *hITSTPC, *hTPCTOF, *hTOF;
TH1D *hCombined[10];
for (Int_t part = 2; part < AliPID::kSPECIES; part++) {
for (Int_t charge = 0; charge < 2; charge++) {
for (Int_t icent = 0; icent < 10; icent++) {
hCombined[icent] = new TH1D(Form("cent%d_%s_%s", icent, AliPID::ParticleName(part), chargeName[charge]), "", NptBins, ptBin);
TObjArray spectraArray;
hITSsa = GetITSsaSpectrum(itssafile, part, charge, icent);
//hITSTPC = GetITSTPCSpectrum(itstpcfile, part, charge, icent);
hTPCTOF = GetTPCTOFSpectrum(tpctoffile, part, charge, icent);
hTOF = GetTOFSpectrum(toffile, part, charge, icent);
if (hITSsa && (what == -1 || what == 0)) {
spectraArray.Add(hITSsa);
}
if (hITSTPC && (what == -1 || what == 1)) {
spectraArray.Add(hITSTPC);
}
if (hTPCTOF && (what == -1 || what == 2)) {
spectraArray.Add(hTPCTOF);
}
if (hTOF && (what == -1 || what == 3)) {
spectraArray.Add(hTOF);
}
CombineSpectra(hCombined[icent], &spectraArray);
fileout->cd();
hCombined[icent]->Write();
}
}
}
fileout->Close();
}
示例9: OccupancyAscii2OCDB
void OccupancyAscii2OCDB(Int_t runNumber,
const char* filename,
const char* ocdbpath,
const char* comment)
{
TObjArray a;
a.SetOwner(kTRUE);
a.Add(new TObjString(filename));
OccupancyAscii2OCDB(runNumber,a,ocdbpath,comment);
}
示例10: TObjString
TObjArray* Chain2List(TChain* chain)
{
// returns a TObjArray of TObjStrings of the file names in the chain
TObjArray* result = new TObjArray;
for (Int_t i=0; i<chain->GetListOfFiles()->GetEntries(); i++)
result->Add(new TObjString(chain->GetListOfFiles()->At(i)->GetTitle()));
return result;
}
示例11: PhiLab
float PhiLab( const PseudoJet& jet, Double_t PzInLepton, Double_t PzInHadron, TLorentzVector electron )
{
TLorentzVector p;
p . SetPxPyPzE( jet.px(), jet.py(), jet.pz(), jet.e() );
TObjArray InputCand;
InputCand.Add( &p );
TObjArray OutputCand;
Dijets::BreitBoost( InputCand, OutputCand, PzInLepton, PzInHadron, electron, 2 );
OutputCand.SetOwner();
float phi = (static_cast<TLorentzVector*>(OutputCand.At(0))) -> Phi();
OutputCand.Clear();
return phi;
}
示例12: OccupancyHLTtest
void OccupancyHLTtest()
{
// tail -c +205 EOR_mch-occupancy_0x02_HLT\:FXS_CAL | more > toto
// mv toto EOR_mch-occupancy_0x02_HLT\:FXS_CAL
TObjArray hlt;
hlt.SetOwner(kTRUE);
hlt.Add(new TObjString("EOR_mch-occupancy_0x02_HLT:FXS_CAL"));
hlt.Add(new TObjString("EOR_mch-occupancy_0x03_HLT:FXS_CAL"));
OccupancyAscii2OCDB(196474,hlt,"alien://folder=/alice/cern.ch/user/l/laphecet/HCDB","HLT");
OccupancyAscii2OCDB(196474,"occupancy.000196474082.15","alien://folder=/alice/cern.ch/user/l/laphecet/OCDB",
"occupancy.000196474082.15");
}
示例13: GetListOfMaterials
TObjArray* KVRangeYanez::GetListOfMaterials()
{
// Create and fill a list of all materials for which range tables exist.
// Each entry is a TNamed with the name and type (title) of the material.
// User's responsibility to delete list after use (it owns its objects).
TObjArray* list = new TObjArray(fMaterials->GetEntries());
list->SetOwner(kTRUE);
TIter next(fMaterials);
KVIonRangeTableMaterial* mat;
while ((mat = (KVIonRangeTableMaterial*)next())) {
list->Add(new TNamed(mat->GetName(), mat->GetType()));
}
return list;
}
示例14: tauIdEffValidation
void tauIdEffValidation()
{
//TFile* inputFile = TFile::Open("rfio:/castor/cern.ch/user/v/veelken/CMSSW_3_3_x/bgEstPlots/ZtoMuTau_frSimple/10TeVii/plotsZtoMuTau_bgEstFakeRate.root");
TFile* inputFile = TFile::Open("file:/afs/cern.ch/user/v/veelken/scratch0/CMSSW_3_3_6_patch5/src/TauAnalysis/BgEstimationTools/test/plotsZtoMuTau_bgEstFakeRate.root");
// define colors used to plot efficiencies/fake-rates of different tau id. criteria
// (definition of "rainbow" colors taken from TauAnalysis/DQMTools/python/plotterStyleDefinitions_cfi.py)
TArrayI colors(7);
colors[0] = 877; // violett
colors[1] = 596; // dark blue
//colors[2] = 856; // light blue
colors[2] = 817; // green
//colors[4] = 396; // yellow
//colors[3] = 797; // orange
colors[3] = 628; // red
TObjArray cutEffNames;
cutEffNames.Add(new TObjString("ByTrackIsolationSeq"));
cutEffNames.Add(new TObjString("ByEcalIsolationSeq"));
cutEffNames.Add(new TObjString("ByNTracksSeq"));
cutEffNames.Add(new TObjString("ByChargeSeq"));
//cutEffNames.Add(new TObjString("ByStandardChain"));
TObjArray meNames;
meNames.Add(new TObjString("TauPt"));
meNames.Add(new TObjString("TauEta"));
meNames.Add(new TObjString("TauPhi"));
meNames.Add(new TObjString("TauAssocJetPt"));
meNames.Add(new TObjString("TauLeadTrkPt"));
meNames.Add(new TObjString("TauJetRadius"));
//TString dqmDirectory = "zMuTauAnalyzer_frUnweighted/afterEvtSelTauLeadTrkPt_beforeEvtSelTauTrkIso/TauIdEffValidation";
TString dqmDirectory = "zMuTauAnalyzer_frUnweighted/afterEvtSelDiMuPairZmumuHypothesisVeto/TauIdEffValidation";
showTauIdEfficiency(inputFile, "Ztautau", dqmDirectory, meNames, cutEffNames, "effZTTsim", colors, false);
showTauIdEfficiency(inputFile, "qcdSum", dqmDirectory, meNames, cutEffNames, "frMuEnrichedQCDsim", colors, true);
//showTauIdEfficiency(inputFile, "PPmuXptGt20_factorized", dqmDirectory, meNames, cutEffNames, "frMuEnrichedQCDsim", colors, true);
delete inputFile;
}
示例15: SetupCanvas
// ______________________________________________________________________________________
TPad* SetupCanvas(const Char_t* canName, const Char_t *canTitle) {
// -- setup canvas and pad
canA.Add(new TCanvas(Form("can%s", canName), canTitle, 0, 0 , 420, 700));
can = static_cast<TCanvas*>(canA.Last());
can->SetFillColor(0);
can->SetBorderMode(0);
can->SetBorderSize(0.0);
can->SetFrameFillColor(0);
can->SetFrameBorderMode(0);
can->cd();
pad = new TPad("pad", "pad",0.05, 0.06, 0.99, 0.98);
pad->SetBorderMode(0);
pad->SetFillColor(0);
pad->Draw();
pad->cd();
pad->Divide(1, 3, 0., 0., 0);
can->cd();
TLatex *texb_5 = new TLatex(0.45, 0.03, "#sqrt{#it{s}_{NN}} (GeV)");
texb_5->SetTextSize(0.04);
texb_5->Draw("same");
TLatex *texb_6a = new TLatex(0.05,0.8, aMomentsTitle[4]);
texb_6a->SetTextSize(0.04);
texb_6a->SetTextAngle(90);
texb_6a->Draw("same");
TLatex *texb_6b = new TLatex(0.05,0.45, aMomentsTitle2[5]);
texb_6b->SetTextSize(0.04);
texb_6b->SetTextAngle(90);
texb_6b->Draw("same");
TLatex *texb_6c = new TLatex(0.05,0.2, aMomentsTitle[6]);
texb_6c->SetTextSize(0.04);
texb_6c->SetTextAngle(90);
texb_6c->Draw("same");
return pad;
}