00001 #include "SimMuon/Neutron/src/RootNeutronReader.h" 00002 #include <sstream> 00003 00004 RootNeutronReader::RootNeutronReader(const std::string & fileName) 00005 : theFile(new TFile(fileName.c_str())) 00006 { 00007 } 00008 00009 00010 RootChamberReader & RootNeutronReader::chamberReader(int chamberType) 00011 { 00012 std::map<int, RootChamberReader>::iterator mapItr 00013 = theChamberReaders.find(chamberType); 00014 00015 if(mapItr != theChamberReaders.end()) 00016 { 00017 return mapItr->second; 00018 } 00019 else 00020 { 00021 // make a new one 00022 std::ostringstream treeName; 00023 treeName << "ChamberType" << chamberType; 00024 theChamberReaders[chamberType] = RootChamberReader(theFile, treeName.str()); 00025 return theChamberReaders[chamberType]; 00026 } 00027 } 00028 00029 00030 void RootNeutronReader::readNextEvent(int chamberType, edm::PSimHitContainer & result) 00031 { 00032 chamberReader(chamberType).read(result); 00033 } 00034 00035