///////////////////////////////////////////////////////// // $Id: tutGenerateEvents.cxx,v 1.6 2010/09/07 22:26:56 lindner Exp $ #include #include #include #include #include #include #include "tutGenerateEvents.hxx" namespace SimG4 { EventVector Events; bool ReadEvents(const char* name) { std::cout << name << std::endl; // Read the same events from the file and save them in a local vector. COMET::ICOMETInput* input = new COMET::ICOMETInput(name,"OLD"); if (!input->IsOpen()) { delete input; return false; } // Make sure the geometry data base is read. COMET::IOADatabase::Get().GeomId().SetGeometryFileOverride(name); // Read the events and save them in a vector. COMET::ICOMETEvent* event = input->FirstEvent(); while (input->IsAttached()) { std::cout << "Event " << event->GetRunId() << "." << event->GetEventId() << std::endl; SimG4::Events.push_back(event); event = input->NextEvent(); if(!event) break; } input->Close(); delete input; COMET::IOADatabase::Get().GeomId().SetGeometryFileOverride(name); return true; } // Generate an SIMG4 output file to be available during the tut tests. // This must be called in the test constructor, and can be called multiple // times. void GenerateEvents(void) { if (SimG4::Events.size() > 0) return; if (TFile("SimG4-test-file.root").IsOpen()) if (ReadEvents("SimG4-test-file.root")) return; std::ostringstream cmd; cmd << "SimG4-test-file "; cmd << "'particle mu+' " << "'energy 100 GeV' " << "'position 30 30 -400 cm' " << "'direction 0 0 1' " << "'beamOn 1' "; cmd << "'particle mu+' " << "'energy 100 GeV' " << "'position 1000 75 170 cm' " << "'direction -1 0 0' " << "'beamOn 1' "; cmd << "'particle mu+' " << "'energy 100 GeV' " << "'position 75 1000 170 cm' " << "'direction 0 -1 0' " << "'beamOn 1' "; cmd << "'particle mu+' " << "'energy 100 GeV' " << "'position -75 1000 170 cm' " << "'direction 0 -1 0' " << "'beamOn 1' "; cmd << "'particle mu+' " << "'energy 100 GeV' " << "'position 1000 75.5 -210 cm' " // with y=75, muon doesn't make hits in pecal_RS << "'direction -1 0 0' " << "'beamOn 1' "; cmd << "'particle mu+' " << "'energy 100 GeV' " << "'position 75 1000 -210 cm' " << "'direction 0 -1 0' " << "'beamOn 1' "; cmd << "'particle mu+' " << "'energy 100 GeV' " << "'position -75 1000 -210 cm' " << "'direction 0 -1 0' " << "'beamOn 1' "; std::system(cmd.str().c_str()); ReadEvents("SimG4-test-file.root"); } }