当前位置: 首页>>代码示例>>C++>>正文


C++ TDirectory::GetObjectUnchecked方法代码示例

本文整理汇总了C++中TDirectory::GetObjectUnchecked方法的典型用法代码示例。如果您正苦于以下问题:C++ TDirectory::GetObjectUnchecked方法的具体用法?C++ TDirectory::GetObjectUnchecked怎么用?C++ TDirectory::GetObjectUnchecked使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TDirectory的用法示例。


在下文中一共展示了TDirectory::GetObjectUnchecked方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: analysis

int analysis(char* filename)
{
    // char* filename = "combined.root";
    // Read in the file
    TFile* f = new TFile(filename);
    TDirectory* hists  = f->GetDirectory("hists;1");
    TDirectory* tuples = f->GetDirectory("tuples;1");

    TTree* accum = tuples->GetObjectUnchecked("AccumulatedEnergy;1");
    TLeaf* einit = accum->GetLeaf("Einit");
    TLeaf* edepo = accum->GetLeaf("Edep");

    TTree* edeps = tuples->GetObjectUnchecked("EnergyDepositions;1");

    TTree* secs  = tuples->GetObjectUnchecked("SecondarySpectrum;1");
    TLeaf* secsenergy = secs->GetLeaf("KineticEnergy");

    double ein = 0;
    double eout = 0;



    int nevents = accum->GetEntries();
    cout << "Making Summary\n";
    FILE* summary = fopen("summ.txt", "a+");

    for (int ii = 0; ii<nevents; ii++)
    {
        accum->GetEntry(ii);
        ein+=einit->GetValue();
        eout+=edepo->GetValue();
    }

    FILE* summary = fopen("summ.txt", "a+");

    time_t t = time(NULL);
    char* c_time_string = ctime(&t);
    char* mytime[20];
    strncpy(mytime, c_time_string, 19);
    mytime[ strlen(mytime) - 1 ] = '\0';

    fprintf(summary, "%s,%s,%e,%e\n", mytime, filename, ein, eout);//*c_time_string, *filename, ein, eout);
    //cout << *c_time_string << "," << *filename << "," << ein << "," << eout << "\n";
    fclose(summary);

    // Print out or save these values
    cout << "Making Histogram\n";

    nevents = secs->GetEntries();
    TH1F* secondaries = new TH1F("secondaries", "Secondary Electrons <100 keV", 92, 0.010, 0.102);

    for (int ii = 0; ii<nevents; ii++)
    {
        secs->GetEntry(ii);
        secondaries->Fill(secsenergy->GetValue());
    }

    char* suffix = ".secondaryhisto";

    cout << "Making Filenames\n";


    char* outfilename = malloc(strlen(filename) + strlen(suffix) + 1);
    strcpy(outfilename, filename);
    strcat(outfilename, suffix);

    printf("Saving Histogram: %s \n", outfilename);
    h12ascii(secondaries, outfilename);

    return 0;

}
开发者ID:natl,项目名称:multiscale,代码行数:72,代码来源:analysis.C


注:本文中的TDirectory::GetObjectUnchecked方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。