本文整理汇总了C++中TObject::FindObject方法的典型用法代码示例。如果您正苦于以下问题:C++ TObject::FindObject方法的具体用法?C++ TObject::FindObject怎么用?C++ TObject::FindObject使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TObject
的用法示例。
在下文中一共展示了TObject::FindObject方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: merge_histos
TH1* merge_histos(TList *sourcelist){
TH1 *htot;
TFile *first_source = (TFile*)sourcelist->First();
TDirectory *current_sourcedir = gDirectory;
//gain time, do not add the objects in the list in memory
Bool_t status = TH1::AddDirectoryStatus();
TH1::AddDirectory(kFALSE);
// loop over all keys in this directory
TChain *globChain = 0;
TIter nextkey( current_sourcedir->GetListOfKeys() );
TKey *key, *oldkey=0;
while ( (key = (TKey*)nextkey())) {
//keep only the highest cycle number for each key
if (oldkey && !strcmp(oldkey->GetName(),key->GetName())) continue;
// read object from first source file
TObject *obj = key->ReadObj();
// if the object is named "tot_edp_hbcoil" merge it
if ( obj->FindObject("Tot_Edep_HBCoil")) {
// cout << "Merging histogram " << obj->GetName() << endl;
htot = (TH1*)obj;
// loop over all source files and add the content of the
// correspondant histogram to the one pointed to by "h1"
TFile *nextsource = (TFile*)sourcelist->After( first_source );
while ( nextsource ) {
// make sure we are at the correct directory level by cd'ing to path
TKey *key2 = (TKey*)gDirectory->GetListOfKeys()->FindObject(htot->GetName());
if (key2) {
TH1 *htemp = (TH1*)key2->ReadObj();
htot->Add(htemp);
delete htemp;
}
nextsource = (TFile*)sourcelist->After( nextsource );
}
}
}
return htot;
}
示例2: energyHistoCompare
void energyHistoCompare(string dataset){
/*setting up some global style variables */
gStyle->SetLabelSize(0.05, "xyz");
gStyle->SetLabelOffset(0.015, "xyz");
gStyle->SetTitleSize(0.05, "xyz");
gStyle->SetTitleSize(0.055, "h");
gStyle->SetTitleOffset(1.1, "x");
gStyle->SetTitleOffset(1.2, "y");
gStyle->SetPadTopMargin(0.08);
gStyle->SetPadBottomMargin(0.12);
gStyle->SetPadLeftMargin(0.14);
gStyle->SetPadRightMargin(0.1);
gStyle->SetOptStat(0);
gROOT->ForceStyle();
//Initialize OADB container
AliOADBContainer *container = new AliOADBContainer("");
container->InitFromFile("$ALICE_PHYSICS/OADB/EMCAL/EMCALTimeCalib.root", "AliEMCALTimeCalib");
if(!container){
fprintf(stderr, "No OADB container!");
return;
}
//Find container in OADB
TObject *calibration = (TObject*) container->GetObject(0, "TimeCalib13");
if(!calibration){
fprintf(stderr, "No calibration container found in OADB!");
return;
}
//Get Array for pass1 (13g) and pass4 (13b and 13c) and set up histograms
TObject *calibPass1 = (TObject*) calibration->FindObject("pass1");
if(!calibPass1){
fprintf(stderr, "No pass1!");
return;
}
TH1F *pass1[4];
TObject* calibPass4 = (TObject*) calibration->FindObject("pass4");
if(!calibPass4){
fprintf(stderr, "No pass4!");
return;
}
TH1F *pass4[4];
//Set up the file to check against OADB
TFile *checkFile[6];
checkFile[0] = new TFile(Form("Calibration_%s_1000_400.root", dataset.c_str()));
checkFile[1] = new TFile(Form("Calibration_%s_1000_200.root", dataset.c_str()));
checkFile[2] = new TFile(Form("Calibration_%s_800_400.root", dataset.c_str()));
checkFile[3] = new TFile(Form("Calibration_%s_800_200.root", dataset.c_str()));
checkFile[4] = new TFile(Form("Calibration_%s_400_400.root", dataset.c_str()));
checkFile[5] = new TFile(Form("Calibration_%s_400_200.root", dataset.c_str()));
for(int i=0; i<6; i++){
if(!checkFile[i]){
fprintf(stderr, "Check file %i wasn't loaded!", i);
return;
}
}
// printf("dataset: %s, strcomp(\"13g\", %s) = %i\n", dataset.c_str(), dataset.c_str(), strcmp("13g", dataset.c_str()));
TH1F **check[6];
TH1F **errors[6];
TH1F **errorsRebin[6];
TH1F **compare[6];
TH1F **compareRebin[6];
TH1F **compare1000[6];
TH1F **compare1000Rebin[6];
for(int nfile = 0; nfile<6; nfile++){
check[nfile] = new TH1F*[4];
compare[nfile] = new TH1F*[4];
compareRebin[nfile] = new TH1F*[4];
errors[nfile] = new TH1F*[4];
errorsRebin[nfile] = new TH1F*[4];
compare1000[nfile] = new TH1F*[4];
compare1000Rebin[nfile] = new TH1F*[4];
}
TH1F *compareSingle[4];
TH1F *errors1000400upper[4];
TH1F *errors1000400lower[4];
//Get histograms from files (not LG for dataset 13g)
for(int ibc =0; ibc<4; ibc++){
for(int nfile = 0; nfile<6; nfile++){
if(strcmp("13g", dataset.c_str())==0){
check[nfile][ibc] = (TH1F*)checkFile[nfile]->Get(Form("hAllTimeAvBC%d", ibc));
errors[nfile][ibc] = (TH1F*)checkFile[nfile]->Get(Form("hAllTimeRMSBC%d", ibc));
}else{
check[nfile][ibc] = (TH1F*)checkFile[nfile]->Get(Form("hAllTimeAvLGBC%d", ibc));
errors[nfile][ibc] = (TH1F*)checkFile[nfile]->Get(Form("hAllTimeRMSLGBC%d", ibc));
}
switch(nfile){
case 0 : check[nfile][ibc]->SetName(Form("1000mev400mevBC%d", ibc));
break;
case 1 : check[nfile][ibc]->SetName(Form("1000mev200mevBC%d", ibc));
break;
case 2 : check[nfile][ibc]->SetName(Form("800mev400mevBC%d", ibc));
//.........这里部分代码省略.........