#include "EGPTrack.hh" #include "CLHEP/Units/SystemOfUnits.h" void analyzeStage1() { std::string fileName = "CosmicsStage1_EGP_0.root"; TFile *file = new TFile(fileName.c_str(),"READ"); if(file==NULL) return; //File can't be opened TTree *tree = (TTree*)file->FindObjectAny("CosmicsStage1"); if(tree==NULL) return; //File doesn't contain the tree int nEntries = tree->GetEntries(); //number of events in the tree //all variable which we want to read //variables that are not needed can be removed EGPTrack *primaryMuon = new EGPTrack; std::map *containerTracks = new std::map; // int productionPlane; // bool muonPassedThroughPyramid; //set the branch to the address of the variables above //variables that are not needed can be removed tree->SetBranchAddress("primaryMuon",&primaryMuon); tree->SetBranchAddress("stage2Tracks",&containerTracks); // tree->SetBranchAddress("productionPlane",&productionPlane); // tree->SetBranchAddress("muonPassedThroughPyramid",&muonPassedThroughPyramid); //loop over all tree entries (=events) for(int i=0; iGetEntry(i); //read the i-th entry(=i-th event). the variables above are filled at this point const TString &endVolume = primaryMuon->_endVolume; if(!endVolume.EqualTo("Container")) continue; //skip all muons which don't hit the container //get some information about the position/direction of the primary muon when it hits the container const CLHEP::Hep3Vector &endPos = primaryMuon->_endPos; const CLHEP::Hep3Vector &endDir = primaryMuon->_endDir; float endEnergy = primaryMuon->_endEnergy; //print out some information for the first 10 events if(i<10) { //primary muon information std::cout<<"Event #"<begin(); track!=containerTracks->end(); ++track) { std::cout<<"TrackID "<second._trackID<<" PDG code "<second._particleID<<" E "<second._endEnergy/CLHEP::GeV<<" GeV"<