src/muongen.cc
// Writing the muon list to a ROOT file
Writing the muon list to a ROOT file
Writing the muon list to a ROOT file
void saveMuon() {
    Coords init_pos, final_pos;
    M_Identifiers identity;
    Int_t nPhotons;
    TString filename = "muonList_Run" + to_string(RUN_NO) + ".root";
    TFile f(ROOT_DIR + filename,"recreate");
    TTree *t = new TTree("t","MuonList");
    t->Branch("identity", &identity, "run/I:event/I");
    t->Branch("init_pos", &init_pos, "x/F:y/F:z/F:theta/F:phi/F");
    t->Branch("final_pos", &final_pos, "x/F:y/F:z/F:theta/F:phi/F");
    t->Branch("nPhotons", &nPhotons, "nPhotons/I");
    for (auto m = muonList.begin(); m != muonList.end(); ++m) {
        identity = m->identity;
        init_pos = m->init_coords;
        final_pos = m->final_coords;
        nPhotons = m->nphotons;
        t->Fill();
    }
    t->Write();
    delete t;
}
void saveMuon ( ) { Coords init_pos , final_pos ; M_Identifiers identity ; Int_t nPhotons ; TString filename = " " + to_string ( RUN_NO ) + " " ; TFile f ( ROOT_DIR + filename , " " ) ; TTree * t = new TTree ( " " , " " ) ; t -> Branch ( " " , & identity , " " ) ; t -> Branch ( " " , & init_pos , " " ) ; t -> Branch ( " " , & final_pos , " " ) ; t -> Branch ( " " , & nPhotons , " " ) ; for ( auto m = muonList . begin ( ) ; m != muonList . end ( ) ; ++ m ) { identity = m -> identity ; init_pos = m -> init_coords ; final_pos = m -> final_coords ; nPhotons = m -> nphotons ; t -> Fill ( ) ; } t -> Write ( ) ; delete t ; }
Writing the muon list to a ROOT file
Writing the muon list to a ROOT file
// Defining Branch Variables // Creating ROOT file // Setting Tree and Branches // Iterating over Muon List and Filling Tree // Write to ROOT file