#include #include #include #include #include "TFile.h" #include "TTree.h" int hit_generator_forum ( int flux ) { std::string outputdir = "Output/Tree/"; system ( Form( "mkdir -p %s", outputdir.data( ) ) ); std::string outputpath = Form ( "%streehit_%04d.root", outputdir.data( ), flux ); TFile *file_output = new TFile ( outputpath.data( ), "recreate" ); TTree *tree_rechit = new TTree ( "tree_rechit", "tree with hit" ); int nrechit; std::vector hit_xcoor; std::vector hit_ycoor; std::vector hit_energy; tree_rechit -> Branch ( "nrechit", &nrechit ); tree_rechit -> Branch ( "hit_xcoor", &hit_xcoor ); tree_rechit -> Branch ( "hit_ycoor", &hit_ycoor ); tree_rechit -> Branch ( "hit_energy", &hit_energy ); TRandom3 *randgen = new TRandom3( 0 ); long nevent = 500000; for ( long ev=0; ev Integer( 5 ); ycoor = randgen -> Integer( 5 ); energy = 0; energy += randgen -> Landau( 20+0.22278298*3, 3 ); hit_xcoor . push_back ( xcoor ); hit_ycoor . push_back ( ycoor ); hit_energy . push_back ( energy ); ihit ++; } tree_rechit -> Fill( ); } file_output -> cd( ); tree_rechit -> Write ( "", TObject::kOverwrite ); file_output -> Close( ); return 0; }