Ejemplo n.º 1
0
def write_plots( filepath, classname, filename ):

    write_tool.write_top_file( filepath, filename+"Plots", "cc" )
    filehistos = open( filepath+filename+"Plots.cc", "a" )
    filehistos.write("#include \"%s.hh\"\n\n" % classname )
    write_tool.write_mainfunction_comment( filehistos, "%sPlots" % filename )
    filehistos.write( "int %sPlots( TString dirin, TString dirout )\n{\n" % filename )
    filehistos.write( "\t// Create file to store histograms\n" )
    filehistos.write( "\tTFile *rootfile = new TFile( dirin+\"rootfiles/out_name.root\");\n" )
    filehistos.write( "\tTH1F *htest = Utils1::getTH1F( rootfile, \"htest\");\n\n" )
    filehistos.write( "\tTCanvas *c1 = NULL;\n" );
    filehistos.write( "\tc1 = Plot1::getCanvas(\"c1\",\"c1\");\n" )
    filehistos.write( "\thtest->Draw();\n" );
    filehistos.write( "\tUtils1::MyPrint(c1, dirout, \"Basic\", \"example\");\n" )
    filehistos.write( "\treturn 0;\n\n}\n\n" )
    filehistos.close()
    write_tool.write_help( filepath, filename+"Plots" )
    write_tool.write_main( filepath, filename+"Plots" )
Ejemplo n.º 2
0
def write_histos( filepath, classname, filename ):

    write_tool.write_top_file( filepath, filename+"Histos", "cc" )
    filehistos = open( filepath+filename+"Histos.cc", "a" )
    filehistos.write("#include \"%s.hh\"\n\n" % classname )
    write_tool.write_mainfunction_comment( filehistos, "%sHistos" % filename )
    filehistos.write( "int %sHistos( TString dirin, TString dirout )\n{\n" % filename )
    filehistos.write( "\t// Create file to store histograms\n" )
    filehistos.write( "\tTFile *rootfile = new TFile( dirout+\"rootfiles/out_name.root\",\"RECREATE\");\n" )
    filehistos.write( "\tTH1F *htest = Utils1::bookTH1F( \"htest\", \"title;xtitle;ytitle;units\", nbins, xmin, xmax, true);\n\n" )
    filehistos.write( "\t// TChain to retrieve data\n" )
    filehistos.write( "\tTChain *c%s = new TChain(\"tree_name\");\n" % classname.lower() )
    filehistos.write( "\tc%s->Add(dirin+\"/file_name\");\n" % classname.lower() )
    filehistos.write( "\t%s *%s = new %s( c%s );\n" % (classname, classname.lower(), classname, classname.lower()) )
    filehistos.write( "\tLong64_t nevents = %s->GetEntries();\n\n" % classname.lower() )
    filehistos.write( "\t// Loop\n" )
    filehistos.write( "\tfor ( Int_t index = 0; index < nevents; index++)\n\t{\n" )
    filehistos.write( "\t\t%s->GetEntry(index);\n\n\t}\n\n" % classname.lower() )
    filehistos.write( "\trootfile->Write();\n")
    filehistos.write( "\trootfile->Close();\n\n")
    filehistos.write( "\treturn 0;\n\n}\n\n")
    filehistos.close()
    write_tool.write_help( filepath, filename+"Histos" )
    write_tool.write_main( filepath, filename+"Histos" )