#include <simhitshifter/SimHitShifter/src/SimHitShifter.cc>
Public Member Functions | |
virtual void | beginRun (const edm::Run &, const edm::EventSetup &) |
SimHitShifter (const edm::ParameterSet &) | |
~SimHitShifter () | |
Public Attributes | |
std::map< int, float > | shiftinfo |
Private Member Functions | |
virtual void | beginJob (const edm::Run &, const edm::EventSetup &) |
virtual void | endJob () |
virtual void | produce (edm::Event &, const edm::EventSetup &) |
Private Attributes | |
std::string | ShiftFileName |
Description: [one line class summary]
Implementation: [Notes on implementation]
Definition at line 110 of file SimHitShifter.cc.
SimHitShifter::SimHitShifter | ( | const edm::ParameterSet & | iConfig | ) | [explicit] |
Definition at line 127 of file SimHitShifter.cc.
References gather_cfg::cout, edm::ParameterSet::getUntrackedParameter(), evf::evtn::offset(), ShiftFileName, and shiftinfo.
{ std::cout<<"in the constructor"<<std::endl; ShiftFileName = iConfig.getUntrackedParameter<std::string>("ShiftFileName","/afs/cern.ch/user/c/carrillo/simhits/CMSSW_3_5_8_patch2/src/simhitshifter/SimHitShifter/Merged_Muon_RawId_Shift.txt"); //iSetup.get<MuonGeometryRecord>().get(rpcGeo); std::ifstream ifin(ShiftFileName.c_str()); int rawId; float offset; std::cout<<"In the constructor, The name of the file is "<<ShiftFileName.c_str()<<std::endl; if(!ifin) std::cout<<"Problem reading the map rawId shift "<<ShiftFileName.c_str()<<std::endl; assert(ifin); while (ifin.good()){ ifin >>rawId >>offset; shiftinfo[rawId]=offset; std::cout<<"rawId ="<<rawId<<" offset="<<offset<<std::endl; } produces<edm::PSimHitContainer>("MuonCSCHits"); produces<edm::PSimHitContainer>("MuonDTHits"); produces<edm::PSimHitContainer>("MuonRPCHits"); }
SimHitShifter::~SimHitShifter | ( | ) |
Definition at line 157 of file SimHitShifter.cc.
{ }
void SimHitShifter::beginJob | ( | const edm::Run & | run, |
const edm::EventSetup & | iSetup | ||
) | [private, virtual] |
Definition at line 282 of file SimHitShifter.cc.
{ }
void SimHitShifter::beginRun | ( | const edm::Run & | run, |
const edm::EventSetup & | iSetup | ||
) | [virtual] |
Definition at line 275 of file SimHitShifter.cc.
{ }
void SimHitShifter::endJob | ( | void | ) | [private, virtual] |
void SimHitShifter::produce | ( | edm::Event & | iEvent, |
const edm::EventSetup & | iSetup | ||
) | [private, virtual] |
Implements edm::EDProducer.
Definition at line 161 of file SimHitShifter.cc.
References CSCDetId::chamber(), CSCDetId::chamberId(), gather_cfg::cout, CSC(), CSCDetId, GeomDetEnumerators::DT, CSCDetId::endcap(), edm::Event::getManyByType(), i, CSCDetId::layer(), DetId::Muon, edm::Event::put(), DetId::rawId(), CSCDetId::ring(), dedefs::RPC, shiftinfo, and CSCDetId::station().
{ using namespace edm; //std::cout << " Getting the SimHits " <<std::endl; std::vector<edm::Handle<edm::PSimHitContainer> > theSimHitContainers; iEvent.getManyByType(theSimHitContainers); //std::cout << " The Number of sim Hits is " << theSimHitContainers.size() <<std::endl; std::auto_ptr<edm::PSimHitContainer> pcsc(new edm::PSimHitContainer); std::auto_ptr<edm::PSimHitContainer> pdt(new edm::PSimHitContainer); std::auto_ptr<edm::PSimHitContainer> prpc(new edm::PSimHitContainer); std::vector<PSimHit> theSimHits; using std::oct; using std::dec; for (int i = 0; i < int(theSimHitContainers.size()); i++){ theSimHits.insert(theSimHits.end(),theSimHitContainers.at(i)->begin(),theSimHitContainers.at(i)->end()); } for (std::vector<PSimHit>::const_iterator iHit = theSimHits.begin(); iHit != theSimHits.end(); iHit++){ DetId theDetUnitId((*iHit).detUnitId()); DetId simdetid= DetId((*iHit).detUnitId()); if(simdetid.det()!=DetId::Muon) continue; float newtof = 0; if(simdetid.det()==DetId::Muon && simdetid.subdetId()== MuonSubdetId::RPC){//Only RPCs //std::cout<<"\t\t We have an RPC Sim Hit! in t="<<(*iHit).timeOfFlight()<<" DetId="<<(*iHit).detUnitId()<<std::endl; if(shiftinfo.find(simdetid.rawId())==shiftinfo.end()){ std::cout<<"RPC Warning the RawId = "<<simdetid.det()<<" | "<<simdetid.rawId()<<"is not in the map"<<std::endl; newtof = (*iHit).timeOfFlight(); }else{ newtof = (*iHit).timeOfFlight()+shiftinfo[simdetid.rawId()]; } PSimHit hit((*iHit).entryPoint(),(*iHit).exitPoint(),(*iHit).pabs(), newtof, (*iHit).energyLoss(),(*iHit).particleType(),simdetid,(*iHit). trackId(),(*iHit).thetaAtEntry(),(*iHit).phiAtEntry(),(*iHit).processType()); prpc->push_back(hit); } else if(simdetid.det()==DetId::Muon && simdetid.subdetId()== MuonSubdetId::DT){//Only DTs int RawId = simdetid.rawId(); std::cout<<"We found a DT simhit the RawId in Dec is"; std::cout<<dec<<RawId<<std::endl; std::cout<<"and in oct"<<std::endl; std::cout<<oct<<RawId<< std::endl; std::cout<<"once masked in oct "<<std::endl; int compressedRawId = RawId/8/8/8/8/8; std::cout<<compressedRawId<<std::endl; std::cout<<"extendedRawId"<<std::endl; int extendedRawId = compressedRawId*8*8*8*8*8; std::cout<<extendedRawId<<std::endl; std::cout<<"converted again in decimal"<<std::endl; std::cout<<dec<<extendedRawId<<std::endl; if(shiftinfo.find(extendedRawId)==shiftinfo.end()){ //std::cout<<"DT Warning the RawId = "<<extendedRawId<<"is not in the map"<<std::endl; newtof = (*iHit).timeOfFlight(); }else{ newtof = (*iHit).timeOfFlight()+shiftinfo[extendedRawId]; std::cout<<"RawId = "<<extendedRawId<<"is in the map "<<(*iHit).timeOfFlight()<<" "<<newtof<<std::endl; } std::cout<<"\t\t We have an DT Sim Hit! in t="<<(*iHit).timeOfFlight()<<" DetId="<<(*iHit).detUnitId()<<std::endl; PSimHit hit((*iHit).entryPoint(),(*iHit).exitPoint(),(*iHit).pabs(), newtof, (*iHit).energyLoss(),(*iHit).particleType(),simdetid,(*iHit). trackId(),(*iHit).thetaAtEntry(),(*iHit).phiAtEntry(),(*iHit).processType()); pdt->push_back(hit); } else if(simdetid.det()==DetId::Muon && simdetid.subdetId()== MuonSubdetId::CSC){//Only CSCs //std::cout<<"\t\t We have an CSC Sim Hit! in t="<<(*iHit).timeOfFlight()<<" DetId="<<(*iHit).detUnitId()<<std::endl; CSCDetId TheCSCDetId = CSCDetId(simdetid); CSCDetId TheChamberDetId = TheCSCDetId.chamberId(); if(shiftinfo.find(TheChamberDetId.rawId())==shiftinfo.end()){ std::cout<<"The RawId is not in the map,perhaps it is on the CSCs station 1 ring 4"<<std::endl; if(TheChamberDetId.station()==1 && TheChamberDetId.ring()==4){ CSCDetId TheChamberDetIdNoring4= CSCDetId(TheChamberDetId.endcap(),TheChamberDetId.station(),1 //1 instead of 4 ,TheChamberDetId.chamber(),TheChamberDetId.layer()); if(shiftinfo.find(TheChamberDetIdNoring4.rawId())==shiftinfo.end()){ std::cout<<"CSC Warning the RawId = "<<TheChamberDetIdNoring4<<" "<<TheChamberDetIdNoring4.rawId()<<"is not in the map"<<std::endl; newtof = (*iHit).timeOfFlight(); }else{ newtof = (*iHit).timeOfFlight()+shiftinfo[TheChamberDetIdNoring4.rawId()]; } } }else{ newtof = (*iHit).timeOfFlight()+shiftinfo[TheChamberDetId.rawId()]; } PSimHit hit((*iHit).entryPoint(),(*iHit).exitPoint(),(*iHit).pabs(), newtof, (*iHit).energyLoss(),(*iHit).particleType(),simdetid,(*iHit). trackId(),(*iHit).thetaAtEntry(),(*iHit).phiAtEntry(),(*iHit).processType()); std::cout<<"CSC check newtof"<<newtof<<" "<<(*iHit).timeOfFlight()<<std::endl; if(newtof==(*iHit).timeOfFlight())std::cout<<"Warning!!!"<<std::endl; pcsc->push_back(hit); } } std::cout<<"Putting collections in the event"<<std::endl; iEvent.put(pcsc,"MuonCSCHits"); iEvent.put(pdt,"MuonDTHits"); iEvent.put(prpc,"MuonRPCHits"); }
std::string SimHitShifter::ShiftFileName [private] |
Definition at line 120 of file SimHitShifter.cc.
Referenced by SimHitShifter().
std::map<int,float> SimHitShifter::shiftinfo |
Definition at line 116 of file SimHitShifter.cc.
Referenced by produce(), and SimHitShifter().