diff --git a/FastSimulation/CTPPSFastTrackingProducer/interface/CTPPSFastTrackingProducer.h b/FastSimulation/CTPPSFastTrackingProducer/interface/CTPPSFastTrackingProducer.h index 38381987a0e15..2b319ee00ba30 100644 --- a/FastSimulation/CTPPSFastTrackingProducer/interface/CTPPSFastTrackingProducer.h +++ b/FastSimulation/CTPPSFastTrackingProducer/interface/CTPPSFastTrackingProducer.h @@ -43,8 +43,6 @@ #include "DataFormats/Math/interface/Vector3D.h" #include "DataFormats/Math/interface/Point3D.h" - - // // class declaration // @@ -53,80 +51,93 @@ class H_RecRPObject; class H_BeamLine; class CTPPSFastTrackingProducer : public edm::stream::EDProducer<> { - public: - explicit CTPPSFastTrackingProducer(const edm::ParameterSet&); - ~CTPPSFastTrackingProducer() override; - - private: - void beginStream(edm::StreamID) override; - void produce(edm::Event&, const edm::EventSetup&) override; - void endStream() override; - //this function will only be called once per event - virtual void beginEvent(edm::Event& event, const edm::EventSetup& eventSetup); - virtual void endEvent(edm::Event& event, const edm::EventSetup& eventSetup); - - // ----------member data --------------------------- - - typedef std::vector CTPPSFastRecHitContainer; - edm::EDGetTokenT< CTPPSFastRecHitContainer > _recHitToken; - void ReadRecHits(edm::Handle &); - void FastReco(int Direction,H_RecRPObject* station); - void Reconstruction(); - void ReconstructArm(H_RecRPObject* pps_station, double x1,double y1,double x2,double y2, double& tx, double& ty,double& eloss); - void MatchCellId(int cellId, std::vector vrecCellId, std::vector vrecTof, bool& match, double& recTof); - bool SearchTrack(int ,int ,int Direction,double& xi,double& t,double& partP,double& pt,double& thx,double& thy, - double& x0,double& y0, double& xt, double& yt, double& X1d, double& Y1d, double& X2d, double& Y2d); - void TrackerStationClear(); - void TrackerStationStarting(); - void ProjectToToF(const double x1, const double y1, const double x2, const double y2, double& xt, double& yt) { - xt = ((fz_timing-fz_tracker2)*(x2-x1)/(fz_tracker2-fz_tracker1)) + x2; - yt = ((fz_timing-fz_tracker2)*(y2-y1)/(fz_tracker2-fz_tracker1)) + y2; - }; - // Hector objects - bool SetBeamLine(); - - std::map m_beamPart; - std::unique_ptr m_beamlineCTPPS1; - std::unique_ptr m_beamlineCTPPS2; - std::unique_ptr pps_stationF; - std::unique_ptr pps_stationB; - - std::string beam1filename; - std::string beam2filename; - - // Defaults - double lengthctpps ; - bool m_verbosity; - double fBeamEnergy; - double fBeamMomentum; - bool fCrossAngleCorr; - double fCrossingAngleBeam1; - double fCrossingAngleBeam2; - //////////////////////////////////////////////// - std::unique_ptr TrkStation_F; // auxiliary object with the tracker geometry - std::unique_ptr TrkStation_B; - std::unique_ptr det1F; - std::unique_ptr det1B; - std::unique_ptr det2F; - std::unique_ptr det2B; - std::unique_ptr detToF_F; - std::unique_ptr detToF_B; - - std::vector theCTPPSFastTrack; - - CTPPSFastTrack track; - - std::vector recCellId_F, recCellId_B ; - std::vector recTof_F, recTof_B ; - - double fz_tracker1, fz_tracker2, fz_timing; - double fTrackerWidth,fTrackerHeight,fTrackerInsertion,fBeamXRMS_Trk1,fBeamXRMS_Trk2,fTrk1XOffset,fTrk2XOffset; - std::vector fToFCellWidth; - double fToFCellHeight,fToFPitchX,fToFPitchY; - int fToFNCellX,fToFNCellY; - double fToFInsertion,fBeamXRMS_ToF,fToFXOffset,fTimeSigma,fImpParcut; - - +public: + explicit CTPPSFastTrackingProducer(const edm::ParameterSet&); + ~CTPPSFastTrackingProducer() override; + +private: + void beginStream(edm::StreamID) override; + void produce(edm::Event&, const edm::EventSetup&) override; + void endStream() override; + //this function will only be called once per event + virtual void beginEvent(edm::Event& event, const edm::EventSetup& eventSetup); + virtual void endEvent(edm::Event& event, const edm::EventSetup& eventSetup); + + // ----------member data --------------------------- + + typedef std::vector CTPPSFastRecHitContainer; + edm::EDGetTokenT _recHitToken; + void ReadRecHits(edm::Handle&); + void FastReco(int Direction, H_RecRPObject* station); + void Reconstruction(); + void ReconstructArm( + H_RecRPObject* pps_station, double x1, double y1, double x2, double y2, double& tx, double& ty, double& eloss); + void MatchCellId(int cellId, std::vector vrecCellId, std::vector vrecTof, bool& match, double& recTof); + bool SearchTrack(int, + int, + int Direction, + double& xi, + double& t, + double& partP, + double& pt, + double& thx, + double& thy, + double& x0, + double& y0, + double& xt, + double& yt, + double& X1d, + double& Y1d, + double& X2d, + double& Y2d); + void TrackerStationClear(); + void TrackerStationStarting(); + void ProjectToToF(const double x1, const double y1, const double x2, const double y2, double& xt, double& yt) { + xt = ((fz_timing - fz_tracker2) * (x2 - x1) / (fz_tracker2 - fz_tracker1)) + x2; + yt = ((fz_timing - fz_tracker2) * (y2 - y1) / (fz_tracker2 - fz_tracker1)) + y2; + }; + // Hector objects + bool SetBeamLine(); + + std::map m_beamPart; + std::unique_ptr m_beamlineCTPPS1; + std::unique_ptr m_beamlineCTPPS2; + std::unique_ptr pps_stationF; + std::unique_ptr pps_stationB; + + std::string beam1filename; + std::string beam2filename; + + // Defaults + double lengthctpps; + bool m_verbosity; + double fBeamEnergy; + double fBeamMomentum; + bool fCrossAngleCorr; + double fCrossingAngleBeam1; + double fCrossingAngleBeam2; + //////////////////////////////////////////////// + std::unique_ptr TrkStation_F; // auxiliary object with the tracker geometry + std::unique_ptr TrkStation_B; + std::unique_ptr det1F; + std::unique_ptr det1B; + std::unique_ptr det2F; + std::unique_ptr det2B; + std::unique_ptr detToF_F; + std::unique_ptr detToF_B; + + std::vector theCTPPSFastTrack; + + CTPPSFastTrack track; + + std::vector recCellId_F, recCellId_B; + std::vector recTof_F, recTof_B; + + double fz_tracker1, fz_tracker2, fz_timing; + double fTrackerWidth, fTrackerHeight, fTrackerInsertion, fBeamXRMS_Trk1, fBeamXRMS_Trk2, fTrk1XOffset, fTrk2XOffset; + std::vector fToFCellWidth; + double fToFCellHeight, fToFPitchX, fToFPitchY; + int fToFNCellX, fToFNCellY; + double fToFInsertion, fBeamXRMS_ToF, fToFXOffset, fTimeSigma, fImpParcut; }; #endif - diff --git a/FastSimulation/CTPPSFastTrackingProducer/plugins/CTPPSFastTrackingProducer.cc b/FastSimulation/CTPPSFastTrackingProducer/plugins/CTPPSFastTrackingProducer.cc index c3cba0f6cb32e..c7db749ad318e 100644 --- a/FastSimulation/CTPPSFastTrackingProducer/plugins/CTPPSFastTrackingProducer.cc +++ b/FastSimulation/CTPPSFastTrackingProducer/plugins/CTPPSFastTrackingProducer.cc @@ -2,7 +2,7 @@ // // Package: FastSimulation/CTPPSFastTrackingProducer // Class: CTPPSFastTrackingProducer -// +// /**\class CTPPSFastTrackingProducer CTPPSFastTrackingProducer.cc FastSimulation/CTPPSFastTrackingProducer/plugins/CTPPSFastTrackingProducer.cc Description: [one line class summary] @@ -16,7 +16,6 @@ Description: [one line class summary] // // - // system include files #include @@ -32,367 +31,415 @@ Description: [one line class summary] ////////////////////// // constructors and destructor // -CTPPSFastTrackingProducer::CTPPSFastTrackingProducer(const edm::ParameterSet& iConfig): - m_verbosity(false), fBeamMomentum(0.), fCrossAngleCorr(false), fCrossingAngleBeam1(0.),fCrossingAngleBeam2(0.) -{ - //register your products - produces("CTPPSFastTrack"); - using namespace edm; - _recHitToken = consumes(iConfig.getParameter("recHitTag")); - m_verbosity = iConfig.getParameter("Verbosity"); - // User definitons - - // Read beam parameters needed for Hector reconstruction - lengthctpps = iConfig.getParameter("BeamLineLengthCTPPS" ); - beam1filename = iConfig.getParameter("Beam1"); - beam2filename = iConfig.getParameter("Beam2"); - fBeamEnergy = iConfig.getParameter("BeamEnergy"); // beam energy in GeV - fBeamMomentum = sqrt(fBeamEnergy*fBeamEnergy - PPSTools::ProtonMassSQ); - fCrossingAngleBeam1 = iConfig.getParameter("CrossingAngleBeam1"); - fCrossingAngleBeam2 = iConfig.getParameter("CrossingAngleBeam2"); - - if (fCrossingAngleBeam1!=0||fCrossingAngleBeam2!=0) fCrossAngleCorr = true; - //Read detectors positions and parameters - - fz_tracker1 = iConfig.getParameter("Z_Tracker1"); - fz_tracker2 = iConfig.getParameter("Z_Tracker2"); - fz_timing = iConfig.getParameter("Z_Timing"); +CTPPSFastTrackingProducer::CTPPSFastTrackingProducer(const edm::ParameterSet& iConfig) + : m_verbosity(false), fBeamMomentum(0.), fCrossAngleCorr(false), fCrossingAngleBeam1(0.), fCrossingAngleBeam2(0.) { + //register your products + produces("CTPPSFastTrack"); + using namespace edm; + _recHitToken = consumes(iConfig.getParameter("recHitTag")); + m_verbosity = iConfig.getParameter("Verbosity"); + // User definitons + + // Read beam parameters needed for Hector reconstruction + lengthctpps = iConfig.getParameter("BeamLineLengthCTPPS"); + beam1filename = iConfig.getParameter("Beam1"); + beam2filename = iConfig.getParameter("Beam2"); + fBeamEnergy = iConfig.getParameter("BeamEnergy"); // beam energy in GeV + fBeamMomentum = sqrt(fBeamEnergy * fBeamEnergy - PPSTools::ProtonMassSQ); + fCrossingAngleBeam1 = iConfig.getParameter("CrossingAngleBeam1"); + fCrossingAngleBeam2 = iConfig.getParameter("CrossingAngleBeam2"); + + if (fCrossingAngleBeam1 != 0 || fCrossingAngleBeam2 != 0) + fCrossAngleCorr = true; + //Read detectors positions and parameters + + fz_tracker1 = iConfig.getParameter("Z_Tracker1"); + fz_tracker2 = iConfig.getParameter("Z_Tracker2"); + fz_timing = iConfig.getParameter("Z_Timing"); + // + fTrackerWidth = iConfig.getParameter("TrackerWidth"); + fTrackerHeight = iConfig.getParameter("TrackerHeight"); + fTrackerInsertion = iConfig.getParameter("TrackerInsertion"); + fBeamXRMS_Trk1 = iConfig.getParameter("BeamXRMS_Trk1"); + fBeamXRMS_Trk2 = iConfig.getParameter("BeamXRMS_Trk2"); + fTrk1XOffset = iConfig.getParameter("Trk1XOffset"); + fTrk2XOffset = iConfig.getParameter("Trk2XOffset"); + fToFCellWidth = iConfig.getUntrackedParameter >("ToFCellWidth"); + fToFCellHeight = iConfig.getParameter("ToFCellHeight"); + fToFPitchX = iConfig.getParameter("ToFPitchX"); + fToFPitchY = iConfig.getParameter("ToFPitchY"); + fToFNCellX = iConfig.getParameter("ToFNCellX"); + fToFNCellY = iConfig.getParameter("ToFNCellY"); + fToFInsertion = iConfig.getParameter("ToFInsertion"); + fBeamXRMS_ToF = iConfig.getParameter("BeamXRMS_ToF"); + fToFXOffset = iConfig.getParameter("ToFXOffset"); + fTimeSigma = iConfig.getParameter("TimeSigma"); + fImpParcut = iConfig.getParameter("ImpParcut"); + + if (!SetBeamLine()) { + if (m_verbosity) + LogDebug("CTPPSFastTrackingProducer") << "CTPPSFastTrackingProducer: WARNING: lengthctpps= " << lengthctpps; + return; + } + + // Create a particle to get the beam energy from the beam file + // Take care: the z inside the station is in meters + // + //Tracker Detector Description + det1F = std::unique_ptr( + new CTPPSTrkDetector(fTrackerWidth, fTrackerHeight, fTrackerInsertion * fBeamXRMS_Trk1 + fTrk1XOffset)); + det2F = std::unique_ptr( + new CTPPSTrkDetector(fTrackerWidth, fTrackerHeight, fTrackerInsertion * fBeamXRMS_Trk2 + fTrk2XOffset)); + det1B = std::unique_ptr( + new CTPPSTrkDetector(fTrackerWidth, fTrackerHeight, fTrackerInsertion * fBeamXRMS_Trk1 + fTrk1XOffset)); + det2B = std::unique_ptr( + new CTPPSTrkDetector(fTrackerWidth, fTrackerHeight, fTrackerInsertion * fBeamXRMS_Trk2 + fTrk2XOffset)); + + //Timing Detector Description + std::vector vToFCellWidth; + for (int i = 0; i < 8; i++) { + vToFCellWidth.push_back(fToFCellWidth[i]); + } + double pos_tof = fToFInsertion * fBeamXRMS_ToF + fToFXOffset; + detToF_F = std::unique_ptr(new CTPPSToFDetector( + fToFNCellX, fToFNCellY, vToFCellWidth, fToFCellHeight, fToFPitchX, fToFPitchY, pos_tof, fTimeSigma)); + detToF_B = std::unique_ptr(new CTPPSToFDetector( + fToFNCellX, fToFNCellY, vToFCellWidth, fToFCellHeight, fToFPitchX, fToFPitchY, pos_tof, fTimeSigma)); // - fTrackerWidth = iConfig.getParameter("TrackerWidth"); - fTrackerHeight = iConfig.getParameter("TrackerHeight"); - fTrackerInsertion = iConfig.getParameter("TrackerInsertion"); - fBeamXRMS_Trk1 = iConfig.getParameter("BeamXRMS_Trk1"); - fBeamXRMS_Trk2 = iConfig.getParameter("BeamXRMS_Trk2"); - fTrk1XOffset = iConfig.getParameter("Trk1XOffset"); - fTrk2XOffset = iConfig.getParameter("Trk2XOffset"); - fToFCellWidth = iConfig.getUntrackedParameter >("ToFCellWidth"); - fToFCellHeight = iConfig.getParameter("ToFCellHeight"); - fToFPitchX = iConfig.getParameter("ToFPitchX"); - fToFPitchY = iConfig.getParameter("ToFPitchY"); - fToFNCellX = iConfig.getParameter("ToFNCellX"); - fToFNCellY = iConfig.getParameter("ToFNCellY"); - fToFInsertion = iConfig.getParameter("ToFInsertion"); - fBeamXRMS_ToF = iConfig.getParameter("BeamXRMS_ToF"); - fToFXOffset = iConfig.getParameter("ToFXOffset"); - fTimeSigma = iConfig.getParameter("TimeSigma"); - fImpParcut = iConfig.getParameter("ImpParcut"); - - - if(!SetBeamLine() ) { - if ( m_verbosity ) LogDebug("CTPPSFastTrackingProducer") << "CTPPSFastTrackingProducer: WARNING: lengthctpps= " << lengthctpps; - return; - } - - // Create a particle to get the beam energy from the beam file - // Take care: the z inside the station is in meters - // - //Tracker Detector Description - det1F =std::unique_ptr(new CTPPSTrkDetector(fTrackerWidth,fTrackerHeight,fTrackerInsertion*fBeamXRMS_Trk1+fTrk1XOffset)); - det2F =std::unique_ptr(new CTPPSTrkDetector(fTrackerWidth,fTrackerHeight,fTrackerInsertion*fBeamXRMS_Trk2+fTrk2XOffset)); - det1B =std::unique_ptr(new CTPPSTrkDetector(fTrackerWidth,fTrackerHeight,fTrackerInsertion*fBeamXRMS_Trk1+fTrk1XOffset)); - det2B =std::unique_ptr(new CTPPSTrkDetector(fTrackerWidth,fTrackerHeight,fTrackerInsertion*fBeamXRMS_Trk2+fTrk2XOffset)); - - //Timing Detector Description - std::vector vToFCellWidth; - for (int i = 0 ; i < 8 ; i++){ - vToFCellWidth.push_back(fToFCellWidth[i]); - } - double pos_tof = fToFInsertion*fBeamXRMS_ToF+fToFXOffset; - detToF_F =std::unique_ptr(new CTPPSToFDetector(fToFNCellX,fToFNCellY,vToFCellWidth,fToFCellHeight,fToFPitchX,fToFPitchY,pos_tof,fTimeSigma)); - detToF_B =std::unique_ptr(new CTPPSToFDetector(fToFNCellX,fToFNCellY,vToFCellWidth,fToFCellHeight,fToFPitchX,fToFPitchY,pos_tof,fTimeSigma)); -// } -CTPPSFastTrackingProducer::~CTPPSFastTrackingProducer() -{ - for (std::map::iterator it = m_beamPart.begin(); it != m_beamPart.end(); ++it ) { - delete (*it).second; - } +CTPPSFastTrackingProducer::~CTPPSFastTrackingProducer() { + for (std::map::iterator it = m_beamPart.begin(); it != m_beamPart.end(); ++it) { + delete (*it).second; + } } // ------------ method called to produce the data ------------ - void -CTPPSFastTrackingProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) -{ - using namespace edm; - TrackerStationStarting(); - Handle recHits; - iEvent.getByToken( _recHitToken,recHits); - recCellId_F.clear(); recCellId_B.clear(); - recTof_F.clear(); recTof_B.clear(); - ReadRecHits(recHits); - Reconstruction(); - TrackerStationClear(); - - std::unique_ptr output_tracks(new CTPPSFastTrackContainer); - int n = 0; - for ( std::vector::const_iterator i = theCTPPSFastTrack.begin(); - i != theCTPPSFastTrack.end(); i++ ) { - output_tracks->push_back(*i); - n += 1; - } - - iEvent.put(std::move(output_tracks),"CTPPSFastTrack"); -}//end -void CTPPSFastTrackingProducer::beginEvent(edm::Event& event, const edm::EventSetup& eventSetup) -{ - TrackerStationStarting(); - +void CTPPSFastTrackingProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup) { + using namespace edm; + TrackerStationStarting(); + Handle recHits; + iEvent.getByToken(_recHitToken, recHits); + recCellId_F.clear(); + recCellId_B.clear(); + recTof_F.clear(); + recTof_B.clear(); + ReadRecHits(recHits); + Reconstruction(); + TrackerStationClear(); + + std::unique_ptr output_tracks(new CTPPSFastTrackContainer); + int n = 0; + for (std::vector::const_iterator i = theCTPPSFastTrack.begin(); i != theCTPPSFastTrack.end(); i++) { + output_tracks->push_back(*i); + n += 1; + } + + iEvent.put(std::move(output_tracks), "CTPPSFastTrack"); +} //end +void CTPPSFastTrackingProducer::beginEvent(edm::Event& event, const edm::EventSetup& eventSetup) { + TrackerStationStarting(); } //////////////////// -void CTPPSFastTrackingProducer::endEvent(edm::Event& event, const edm::EventSetup& eventSetup) -{ - TrackerStationClear(); +void CTPPSFastTrackingProducer::endEvent(edm::Event& event, const edm::EventSetup& eventSetup) { + TrackerStationClear(); } -///////////////////////// -void CTPPSFastTrackingProducer::TrackerStationClear(){ - - TrkStation_F->first.clear(); TrkStation_F->second.clear(); - TrkStation_B->first.clear(); TrkStation_B->second.clear(); +///////////////////////// +void CTPPSFastTrackingProducer::TrackerStationClear() { + TrkStation_F->first.clear(); + TrkStation_F->second.clear(); + TrkStation_B->first.clear(); + TrkStation_B->second.clear(); } ///////////////////////// -void CTPPSFastTrackingProducer::TrackerStationStarting(){ - det1F->clear(); - det1B->clear(); - det2F->clear(); - det2B->clear(); - detToF_F->clear(); - detToF_B->clear(); - +void CTPPSFastTrackingProducer::TrackerStationStarting() { + det1F->clear(); + det1B->clear(); + det2F->clear(); + det2B->clear(); + detToF_F->clear(); + detToF_B->clear(); } - //////////////////////////// - void -CTPPSFastTrackingProducer::ReadRecHits(edm::Handle &recHits) -{ - // DetId codification for PSimHit taken from CTPPSPixel- It will be replaced by CTPPSDetId - // 2014314496 -> Tracker1 zPositive - // 2014838784 -> Tracker2 zPositive - // 2046820352 -> Timing zPositive - // 2031091712 -> Tracker1 zNegative - // 2031616000 -> Tracker2 zNegative - // 2063597568 -> Timing zNegative - - for (unsigned int irecHits = 0; irecHits < recHits->size(); ++irecHits) - { - const CTPPSFastRecHit* recHitDet = &(*recHits)[irecHits]; - unsigned int detlayerId = recHitDet->detUnitId(); - double x = recHitDet->entryPoint().x(); - double y = recHitDet->entryPoint().y(); - double z = recHitDet->entryPoint().z(); - float tof = recHitDet->tof(); - if(detlayerId == 2014314496) det1F->AddHit(detlayerId,x,y,z); - else if(detlayerId == 2014838784) det2F->AddHit(detlayerId,x,y,z); - else if(detlayerId == 2031091712) det1B->AddHit(detlayerId,x,y,z); - else if(detlayerId == 2031616000) det2B->AddHit(detlayerId,x,y,z); - else if(detlayerId == 2046820352) { detToF_F->AddHit(x,y,tof); recCellId_F.push_back(detToF_F->findCellId(x,y)); recTof_F.push_back(tof); } - else if(detlayerId == 2063597568) { detToF_B->AddHit(x,y,tof); recCellId_B.push_back(detToF_B->findCellId(x,y)); recTof_B.push_back(tof); } - - }//LOOP TRK - //creating Stations - TrkStation_F = std::unique_ptr(new std::pair(*det1F,*det2F)); - TrkStation_B = std::unique_ptr(new std::pair(*det1B,*det2B)); -} // end function - -void CTPPSFastTrackingProducer::Reconstruction() -{ - theCTPPSFastTrack.clear(); - int Direction; - Direction=1; //cms positive Z / forward - FastReco(Direction,&*pps_stationF); - Direction=-1; //cms negative Z / backward - FastReco(Direction,&*pps_stationB); -}//end Reconstruction - -bool CTPPSFastTrackingProducer::SearchTrack(int i,int j,int Direction,double& xi,double& t,double& partP,double& pt,double& thx,double& thy,double& x0, double& y0, double& xt, double& yt, double& X1d, double& Y1d, double& X2d, double& Y2d) -{ - // Given 1 hit in Tracker1 and 1 hit in Tracker2 try to make a track with Hector - double theta=0.; - xi = 0; t=0; partP=0; pt=0; x0=0.;y0=0.;xt =0.;yt =0.;X1d=0.;Y1d=0.;X2d=0.;Y2d=0.; - CTPPSTrkDetector* det1 = nullptr; - CTPPSTrkDetector* det2 = nullptr; - H_RecRPObject* station = nullptr; - // Separate in forward and backward stations according to direction - if (Direction>0) { - det1=&(TrkStation_F->first);det2=&(TrkStation_F->second); - station = &*pps_stationF; - } else { - det1=&(TrkStation_B->first);det2=&(TrkStation_B->second); - station = &*pps_stationB; - } - if (det1->ppsNHits_<=i||det2->ppsNHits_<=j) return false; -// - double x1 = det1->ppsX_.at(i); double y1 = det1->ppsY_.at(i); - double x2 = det2->ppsX_.at(j); double y2 = det2->ppsY_.at(j); - double eloss; - - //thx and thy are returned in microrad - ReconstructArm(station,Direction*x1,y1,Direction*x2,y2,thx,thy,eloss); // Pass the hits in the LHC ref. frame - thx*=-Direction;// invert to the CMS ref frame - - // Protect for unphysical results - if (std::isnan(eloss)||std::isinf(eloss)|| - std::isnan(thx) || std::isinf(thx) || - std::isnan(thy) || std::isinf(thy)) return false; - // - - if ( m_verbosity ) LogDebug("CTPPSFastTrackingProducer::SearchTrack:") << "thx " << thx << " thy " << thy << " eloss " << eloss; - - // Get the start point of the reconstructed track near the origin made by Hector in the CMS ref. frame - x0 = -Direction*station->getX0()*um_to_cm; - y0 = station->getY0()*um_to_cm; - double ImpPar=sqrt(x0*x0+y0*y0); - if (ImpPar>fImpParcut) return false; - if (eloss<0.||eloss>fBeamEnergy) return false; -// - // Calculate the reconstructed track parameters - theta = sqrt(thx*thx+thy*thy)*urad; - xi = eloss/fBeamEnergy; - double energy= fBeamEnergy*(1.-xi); - partP = sqrt(energy*energy-PPSTools::ProtonMassSQ); - t = -2.*(PPSTools::ProtonMassSQ- fBeamEnergy*energy + fBeamMomentum*partP*cos(theta)); - pt = sqrt(pow(partP*thx*urad,2)+pow(partP*thy*urad,2)); - if (xi<0.||xi>1.||t<0.||t>10.||pt<=0.) { - xi = 0.; t=0.; partP=0.; pt=0.; theta=0.; x0=0.;y0=0.; - return false; // unphysical values +void CTPPSFastTrackingProducer::ReadRecHits(edm::Handle& recHits) { + // DetId codification for PSimHit taken from CTPPSPixel- It will be replaced by CTPPSDetId + // 2014314496 -> Tracker1 zPositive + // 2014838784 -> Tracker2 zPositive + // 2046820352 -> Timing zPositive + // 2031091712 -> Tracker1 zNegative + // 2031616000 -> Tracker2 zNegative + // 2063597568 -> Timing zNegative + + for (unsigned int irecHits = 0; irecHits < recHits->size(); ++irecHits) { + const CTPPSFastRecHit* recHitDet = &(*recHits)[irecHits]; + unsigned int detlayerId = recHitDet->detUnitId(); + double x = recHitDet->entryPoint().x(); + double y = recHitDet->entryPoint().y(); + double z = recHitDet->entryPoint().z(); + float tof = recHitDet->tof(); + if (detlayerId == 2014314496) + det1F->AddHit(detlayerId, x, y, z); + else if (detlayerId == 2014838784) + det2F->AddHit(detlayerId, x, y, z); + else if (detlayerId == 2031091712) + det1B->AddHit(detlayerId, x, y, z); + else if (detlayerId == 2031616000) + det2B->AddHit(detlayerId, x, y, z); + else if (detlayerId == 2046820352) { + detToF_F->AddHit(x, y, tof); + recCellId_F.push_back(detToF_F->findCellId(x, y)); + recTof_F.push_back(tof); + } else if (detlayerId == 2063597568) { + detToF_B->AddHit(x, y, tof); + recCellId_B.push_back(detToF_B->findCellId(x, y)); + recTof_B.push_back(tof); } - //Try to include the timing detector in the track - ProjectToToF(x1, y1, x2, y2, xt, yt); // the projections is done in the CMS ref frame - X1d = x1; - Y1d = y1; - X2d = x2; - Y2d = y2; - return true; -}//end SearchTrack -void CTPPSFastTrackingProducer::ReconstructArm(H_RecRPObject* pps_station, double x1, double y1, double x2, double y2, double& tx, double& ty, double& eloss) -{ - tx=0.; - ty=0.; - eloss=0.; - if (!pps_station) return; - x1*=mm_to_um; - x2*=mm_to_um; - y1*=mm_to_um; - y2*=mm_to_um; - pps_station->setPositions(x1,y1,x2,y2); - double energy = pps_station->getE(AM); // dummy call needed to calculate some Hector internal parameter - if (std::isnan(energy)||std::isinf(energy)) return; - tx = pps_station->getTXIP(); // change orientation to CMS - ty = pps_station->getTYIP(); - eloss = pps_station->getE(); -} + } //LOOP TRK + //creating Stations + TrkStation_F = std::unique_ptr(new std::pair(*det1F, *det2F)); + TrkStation_B = std::unique_ptr(new std::pair(*det1B, *det2B)); +} // end function + +void CTPPSFastTrackingProducer::Reconstruction() { + theCTPPSFastTrack.clear(); + int Direction; + Direction = 1; //cms positive Z / forward + FastReco(Direction, &*pps_stationF); + Direction = -1; //cms negative Z / backward + FastReco(Direction, &*pps_stationB); +} //end Reconstruction + +bool CTPPSFastTrackingProducer::SearchTrack(int i, + int j, + int Direction, + double& xi, + double& t, + double& partP, + double& pt, + double& thx, + double& thy, + double& x0, + double& y0, + double& xt, + double& yt, + double& X1d, + double& Y1d, + double& X2d, + double& Y2d) { + // Given 1 hit in Tracker1 and 1 hit in Tracker2 try to make a track with Hector + double theta = 0.; + xi = 0; + t = 0; + partP = 0; + pt = 0; + x0 = 0.; + y0 = 0.; + xt = 0.; + yt = 0.; + X1d = 0.; + Y1d = 0.; + X2d = 0.; + Y2d = 0.; + CTPPSTrkDetector* det1 = nullptr; + CTPPSTrkDetector* det2 = nullptr; + H_RecRPObject* station = nullptr; + // Separate in forward and backward stations according to direction + if (Direction > 0) { + det1 = &(TrkStation_F->first); + det2 = &(TrkStation_F->second); + station = &*pps_stationF; + } else { + det1 = &(TrkStation_B->first); + det2 = &(TrkStation_B->second); + station = &*pps_stationB; + } + if (det1->ppsNHits_ <= i || det2->ppsNHits_ <= j) + return false; + // + double x1 = det1->ppsX_.at(i); + double y1 = det1->ppsY_.at(i); + double x2 = det2->ppsX_.at(j); + double y2 = det2->ppsY_.at(j); + double eloss; + + //thx and thy are returned in microrad + ReconstructArm( + station, Direction * x1, y1, Direction * x2, y2, thx, thy, eloss); // Pass the hits in the LHC ref. frame + thx *= -Direction; // invert to the CMS ref frame + + // Protect for unphysical results + if (std::isnan(eloss) || std::isinf(eloss) || std::isnan(thx) || std::isinf(thx) || std::isnan(thy) || + std::isinf(thy)) + return false; + // -void CTPPSFastTrackingProducer::MatchCellId(int cellId, std::vector vrecCellId, std::vector vrecTof, bool& match, double& recTof){ - for (unsigned int i = 0 ; i < vrecCellId.size(); i++){ - if(cellId == vrecCellId.at(i)) { - match = true; - recTof = vrecTof.at(i); - continue; - } - } + if (m_verbosity) + LogDebug("CTPPSFastTrackingProducer::SearchTrack:") << "thx " << thx << " thy " << thy << " eloss " << eloss; + + // Get the start point of the reconstructed track near the origin made by Hector in the CMS ref. frame + x0 = -Direction * station->getX0() * um_to_cm; + y0 = station->getY0() * um_to_cm; + double ImpPar = sqrt(x0 * x0 + y0 * y0); + if (ImpPar > fImpParcut) + return false; + if (eloss < 0. || eloss > fBeamEnergy) + return false; + // + // Calculate the reconstructed track parameters + theta = sqrt(thx * thx + thy * thy) * urad; + xi = eloss / fBeamEnergy; + double energy = fBeamEnergy * (1. - xi); + partP = sqrt(energy * energy - PPSTools::ProtonMassSQ); + t = -2. * (PPSTools::ProtonMassSQ - fBeamEnergy * energy + fBeamMomentum * partP * cos(theta)); + pt = sqrt(pow(partP * thx * urad, 2) + pow(partP * thy * urad, 2)); + if (xi < 0. || xi > 1. || t < 0. || t > 10. || pt <= 0.) { + xi = 0.; + t = 0.; + partP = 0.; + pt = 0.; + theta = 0.; + x0 = 0.; + y0 = 0.; + return false; // unphysical values + } + //Try to include the timing detector in the track + ProjectToToF(x1, y1, x2, y2, xt, yt); // the projections is done in the CMS ref frame + X1d = x1; + Y1d = y1; + X2d = x2; + Y2d = y2; + return true; +} //end SearchTrack + +void CTPPSFastTrackingProducer::ReconstructArm( + H_RecRPObject* pps_station, double x1, double y1, double x2, double y2, double& tx, double& ty, double& eloss) { + tx = 0.; + ty = 0.; + eloss = 0.; + if (!pps_station) + return; + x1 *= mm_to_um; + x2 *= mm_to_um; + y1 *= mm_to_um; + y2 *= mm_to_um; + pps_station->setPositions(x1, y1, x2, y2); + double energy = pps_station->getE(AM); // dummy call needed to calculate some Hector internal parameter + if (std::isnan(energy) || std::isinf(energy)) + return; + tx = pps_station->getTXIP(); // change orientation to CMS + ty = pps_station->getTYIP(); + eloss = pps_station->getE(); } -void CTPPSFastTrackingProducer::FastReco(int Direction,H_RecRPObject* station) -{ - double theta = 0.; - double xi,t,partP,pt,phi,x0,y0,thx,thy,xt,yt,X1d,Y1d,X2d,Y2d; - CTPPSTrkDetector* Trk1 = nullptr; - CTPPSTrkDetector* Trk2 = nullptr; - double pos_tof = fToFInsertion*fBeamXRMS_ToF+fToFXOffset; - int cellId = 0; - std::vector vToFCellWidth; - for (int i = 0 ; i < 8 ; i++){ - vToFCellWidth.push_back(fToFCellWidth[i]); +void CTPPSFastTrackingProducer::MatchCellId( + int cellId, std::vector vrecCellId, std::vector vrecTof, bool& match, double& recTof) { + for (unsigned int i = 0; i < vrecCellId.size(); i++) { + if (cellId == vrecCellId.at(i)) { + match = true; + recTof = vrecTof.at(i); + continue; } - CTPPSToFDetector* ToF = new CTPPSToFDetector(fToFNCellX,fToFNCellY,vToFCellWidth,fToFCellHeight,fToFPitchX,fToFPitchY,pos_tof,fTimeSigma); - if (Direction>0) { - Trk1=&(TrkStation_F->first);Trk2=&(TrkStation_F->second); - } else { - Trk1=&(TrkStation_B->first);Trk2=&(TrkStation_B->second); - } - // Make a track from EVERY pair of hits combining Tracker1 and Tracker2. - // The tracks may not be independent as 1 hit may belong to more than 1 track. - for(int i=0;i<(int)Trk1->ppsNHits_;i++) { - for(int j=0;j<(int)Trk2->ppsNHits_;j++){ - if (SearchTrack(i,j,Direction,xi,t,partP,pt,thx,thy,x0,y0,xt,yt,X1d,Y1d,X2d,Y2d)) { - // Check if the hitted timing cell matches the reconstructed track - cellId = ToF->findCellId(xt,yt); - double recTof = 0.; - bool matchCellId = false; - if (Direction > 0 ) { - theta = sqrt(thx*thx+thy*thy)*urad; - MatchCellId(cellId, recCellId_F, recTof_F, matchCellId, recTof); - } - else if (Direction<0) { - theta = TMath::Pi() - sqrt(thx*thx+thy*thy)*urad; - MatchCellId(cellId, recCellId_B, recTof_B, matchCellId, recTof); - } - phi = atan2(thy,thx); // at this point, thx is already in the cms ref. frame - - double px = partP*sin(theta)*cos(phi); - double py = partP*sin(theta)*sin(phi); - double pz = partP*cos(theta); - double e = sqrt(partP*partP+PPSTools::ProtonMassSQ); - TLorentzVector p(px,py,pz,e); - // Invert the Lorentz boost made to take into account the crossing angle during simulation - if (fCrossAngleCorr) { - PPSTools::LorentzBoost(p,"MC", {fCrossingAngleBeam1, - fCrossingAngleBeam2,fBeamMomentum,fBeamEnergy}); - } - //Getting the Xi and t (squared four momentum transferred) of the reconstructed track - PPSTools::Get_t_and_xi(const_cast(&p),t,xi, {fBeamMomentum,fBeamEnergy}); - double pxx = p.Px(); double pyy = p.Py(); double pzz = p.Pz(); - math::XYZVector momentum (pxx,pyy,pzz); - math::XYZPoint vertex (x0,y0,0); + } +} - track.setp(momentum); - track.setvertex(vertex); - track.sett(t); - track.setxi(xi); - track.setx1(X1d); - track.sety1(Y1d); - track.setx2(X2d); - track.sety2(Y2d); - if (matchCellId) { - track.setcellid(cellId); - track.settof(recTof); - } - else { - track.setcellid(0); - track.settof(0.); - } - theCTPPSFastTrack.push_back(track); - } - } +void CTPPSFastTrackingProducer::FastReco(int Direction, H_RecRPObject* station) { + double theta = 0.; + double xi, t, partP, pt, phi, x0, y0, thx, thy, xt, yt, X1d, Y1d, X2d, Y2d; + CTPPSTrkDetector* Trk1 = nullptr; + CTPPSTrkDetector* Trk2 = nullptr; + double pos_tof = fToFInsertion * fBeamXRMS_ToF + fToFXOffset; + int cellId = 0; + std::vector vToFCellWidth; + for (int i = 0; i < 8; i++) { + vToFCellWidth.push_back(fToFCellWidth[i]); + } + CTPPSToFDetector* ToF = new CTPPSToFDetector( + fToFNCellX, fToFNCellY, vToFCellWidth, fToFCellHeight, fToFPitchX, fToFPitchY, pos_tof, fTimeSigma); + if (Direction > 0) { + Trk1 = &(TrkStation_F->first); + Trk2 = &(TrkStation_F->second); + } else { + Trk1 = &(TrkStation_B->first); + Trk2 = &(TrkStation_B->second); + } + // Make a track from EVERY pair of hits combining Tracker1 and Tracker2. + // The tracks may not be independent as 1 hit may belong to more than 1 track. + for (int i = 0; i < (int)Trk1->ppsNHits_; i++) { + for (int j = 0; j < (int)Trk2->ppsNHits_; j++) { + if (SearchTrack(i, j, Direction, xi, t, partP, pt, thx, thy, x0, y0, xt, yt, X1d, Y1d, X2d, Y2d)) { + // Check if the hitted timing cell matches the reconstructed track + cellId = ToF->findCellId(xt, yt); + double recTof = 0.; + bool matchCellId = false; + if (Direction > 0) { + theta = sqrt(thx * thx + thy * thy) * urad; + MatchCellId(cellId, recCellId_F, recTof_F, matchCellId, recTof); + } else if (Direction < 0) { + theta = TMath::Pi() - sqrt(thx * thx + thy * thy) * urad; + MatchCellId(cellId, recCellId_B, recTof_B, matchCellId, recTof); + } + phi = atan2(thy, thx); // at this point, thx is already in the cms ref. frame + + double px = partP * sin(theta) * cos(phi); + double py = partP * sin(theta) * sin(phi); + double pz = partP * cos(theta); + double e = sqrt(partP * partP + PPSTools::ProtonMassSQ); + TLorentzVector p(px, py, pz, e); + // Invert the Lorentz boost made to take into account the crossing angle during simulation + if (fCrossAngleCorr) { + PPSTools::LorentzBoost(p, "MC", {fCrossingAngleBeam1, fCrossingAngleBeam2, fBeamMomentum, fBeamEnergy}); + } + //Getting the Xi and t (squared four momentum transferred) of the reconstructed track + PPSTools::Get_t_and_xi(const_cast(&p), t, xi, {fBeamMomentum, fBeamEnergy}); + double pxx = p.Px(); + double pyy = p.Py(); + double pzz = p.Pz(); + math::XYZVector momentum(pxx, pyy, pzz); + math::XYZPoint vertex(x0, y0, 0); + + track.setp(momentum); + track.setvertex(vertex); + track.sett(t); + track.setxi(xi); + track.setx1(X1d); + track.sety1(Y1d); + track.setx2(X2d); + track.sety2(Y2d); + if (matchCellId) { + track.setcellid(cellId); + track.settof(recTof); + } else { + track.setcellid(0); + track.settof(0.); + } + theCTPPSFastTrack.push_back(track); + } } -}//end FastReco + } +} //end FastReco // ------------ method called once each stream before processing any runs, lumis or events ------------ -void CTPPSFastTrackingProducer::beginStream(edm::StreamID) -{ -} +void CTPPSFastTrackingProducer::beginStream(edm::StreamID) {} // ------------ method called once each stream after processing all runs, lumis and events ------------ -void CTPPSFastTrackingProducer::endStream() -{ -} -bool CTPPSFastTrackingProducer::SetBeamLine() -{ - edm::FileInPath b1(beam1filename.c_str()); - edm::FileInPath b2(beam2filename.c_str()); - if (lengthctpps<=0) return false; - m_beamlineCTPPS1 = std::unique_ptr(new H_BeamLine( -1, lengthctpps + 0.1)); // (direction, length) - m_beamlineCTPPS1->fill( b2.fullPath(), 1, "IP5"); - m_beamlineCTPPS2 = std::unique_ptr(new H_BeamLine( 1, lengthctpps + 0.1 )); // - m_beamlineCTPPS2->fill( b1.fullPath(), 1, "IP5"); - m_beamlineCTPPS1->offsetElements( 120, 0.097 ); - m_beamlineCTPPS2->offsetElements( 120,-0.097 ); - pps_stationF = std::unique_ptr(new H_RecRPObject(fz_tracker1,fz_tracker2,*m_beamlineCTPPS1)); - pps_stationB = std::unique_ptr(new H_RecRPObject(fz_tracker1,fz_tracker2,*m_beamlineCTPPS2)); - return true; +void CTPPSFastTrackingProducer::endStream() {} +bool CTPPSFastTrackingProducer::SetBeamLine() { + edm::FileInPath b1(beam1filename.c_str()); + edm::FileInPath b2(beam2filename.c_str()); + if (lengthctpps <= 0) + return false; + m_beamlineCTPPS1 = std::unique_ptr(new H_BeamLine(-1, lengthctpps + 0.1)); // (direction, length) + m_beamlineCTPPS1->fill(b2.fullPath(), 1, "IP5"); + m_beamlineCTPPS2 = std::unique_ptr(new H_BeamLine(1, lengthctpps + 0.1)); // + m_beamlineCTPPS2->fill(b1.fullPath(), 1, "IP5"); + m_beamlineCTPPS1->offsetElements(120, 0.097); + m_beamlineCTPPS2->offsetElements(120, -0.097); + pps_stationF = std::unique_ptr(new H_RecRPObject(fz_tracker1, fz_tracker2, *m_beamlineCTPPS1)); + pps_stationB = std::unique_ptr(new H_RecRPObject(fz_tracker1, fz_tracker2, *m_beamlineCTPPS2)); + return true; } //define this as a plug-in DEFINE_FWK_MODULE(CTPPSFastTrackingProducer); diff --git a/FastSimulation/Event/interface/FBaseSimEvent.h b/FastSimulation/Event/interface/FBaseSimEvent.h index 9cb7a068352e6..dd1f727541d6b 100644 --- a/FastSimulation/Event/interface/FBaseSimEvent.h +++ b/FastSimulation/Event/interface/FBaseSimEvent.h @@ -37,13 +37,10 @@ namespace HepMC { class GenEvent; class GenParticle; class GenVertex; -} - -class FBaseSimEvent -{ +} // namespace HepMC +class FBaseSimEvent { public: - /// Default constructor FBaseSimEvent(const edm::ParameterSet& kine); @@ -54,9 +51,7 @@ class FBaseSimEvent void initializePdt(const HepPDT::ParticleDataTable* aPdt); /// Get the pointer to the particle data table - inline const HepPDT::ParticleDataTable* theTable() const { - return pdt; - } + inline const HepPDT::ParticleDataTable* theTable() const { return pdt; } /// fill the FBaseSimEvent from the current HepMC::GenEvent void fill(const HepMC::GenEvent& hev); @@ -76,83 +71,66 @@ class FBaseSimEvent /// clear the FBaseSimEvent content before the next event void clear(); - /// Add an id in the vector of charged tracks id's void addChargedTrack(int id); /// Number of tracks - inline unsigned int nTracks() const { - return nSimTracks; - } + inline unsigned int nTracks() const { return nSimTracks; } /// Number of vertices - inline unsigned int nVertices() const { - return nSimVertices; - } + inline unsigned int nVertices() const { return nSimVertices; } /// Number of generator particles - inline unsigned int nGenParts() const { - return nGenParticles; - } + inline unsigned int nGenParts() const { return nGenParticles; } /// Number of "reconstructed" charged tracks - inline unsigned int nChargedTracks() const { - return nChargedParticleTracks; - } + inline unsigned int nChargedTracks() const { return nChargedParticleTracks; } - /// Return track with given Id + /// Return track with given Id inline FSimTrack& track(int id) const; - /// Return vertex with given Id + /// Return vertex with given Id inline FSimVertex& vertex(int id) const; - /// Return vertex with given Id + /// Return vertex with given Id inline FSimVertexType& vertexType(int id) const; /// return "reconstructed" charged tracks index. int chargedTrack(int id) const; /// return embedded track with given id - inline const SimTrack & embdTrack(int i) const; + inline const SimTrack& embdTrack(int i) const; /// return embedded vertex with given id - inline const SimVertex & embdVertex(int i) const; + inline const SimVertex& embdVertex(int i) const; /// return embedded vertex type with given id - inline const FSimVertexType & embdVertexType(int i) const; + inline const FSimVertexType& embdVertexType(int i) const; /// return MC track with a given id const HepMC::GenParticle* embdGenpart(int i) const; /// Add a new track to the Event and to the various lists - int addSimTrack(const RawParticle* p, int iv, int ig=-1, - const HepMC::GenVertex* ev=nullptr); + int addSimTrack(const RawParticle* p, int iv, int ig = -1, const HepMC::GenVertex* ev = nullptr); /// Add a new vertex to the Event and to the various lists - int addSimVertex(const XYZTLorentzVector& decayVertex, int im=-1, - FSimVertexType::VertexType type = FSimVertexType::ANY); + int addSimVertex(const XYZTLorentzVector& decayVertex, + int im = -1, + FSimVertexType::VertexType type = FSimVertexType::ANY); - const KineParticleFilter& filter() const { return *myFilter; } + const KineParticleFilter& filter() const { return *myFilter; } - protected: +protected: + /// The pointer to the vector of FSimTrack's + inline std::vector* tracks() const { return theSimTracks; } - /// The pointer to the vector of FSimTrack's - inline std::vector* tracks() const { - return theSimTracks; - } + /// The pointer to the vector of FSimVertex's + inline std::vector* vertices() const { return theSimVertices; } - /// The pointer to the vector of FSimVertex's - inline std::vector* vertices() const { - return theSimVertices; - } - - /// The pointer to the vector of GenParticle's - inline std::vector* genparts() const { - return theGenParticles; - } - - private: + /// The pointer to the vector of GenParticle's + inline std::vector* genparts() const { return theGenParticles; } +private: std::vector* theSimTracks; std::vector* theSimVertices; FSimVertexTypeCollection* theFSimVerticesType; @@ -178,14 +156,13 @@ class FBaseSimEvent double sigmaVerteY; double sigmaVerteZ; - const ParticleDataTable * pdt; + const ParticleDataTable* pdt; double lateVertexPosition; // Histos* myHistos; - }; #include "FastSimulation/Event/interface/FBaseSimEvent.icc" -#endif // FBaseSimEvent_H +#endif // FBaseSimEvent_H diff --git a/FastSimulation/Event/interface/FBaseSimEvent.icc b/FastSimulation/Event/interface/FBaseSimEvent.icc index 8a1993752040c..30f1106af929e 100644 --- a/FastSimulation/Event/interface/FBaseSimEvent.icc +++ b/FastSimulation/Event/interface/FBaseSimEvent.icc @@ -2,32 +2,32 @@ #include "FastSimulation/Event/interface/FSimVertex.h" #include "FastSimDataFormats/NuclearInteractions/interface/FSimVertexType.h" -inline FSimTrack& FBaseSimEvent::track(int i) const { - if (i < 0 || i>=(int)nTracks()){ - throw cms::Exception("FastSim") << "Index for FSimTracks out of range, please contact FastSim developers"<< std::endl; +inline FSimTrack& FBaseSimEvent::track(int i) const { + if (i < 0 || i >= (int)nTracks()) { + throw cms::Exception("FastSim") << "Index for FSimTracks out of range, please contact FastSim developers" + << std::endl; } return (*theSimTracks)[i]; } -inline FSimVertex& FBaseSimEvent::vertex(int i) const { - if (i < 0 || i>=(int)nVertices()){ - throw cms::Exception("FastSim") << "Index for FSimVertex out of range, please contact FastSim developers"<< std::endl; +inline FSimVertex& FBaseSimEvent::vertex(int i) const { + if (i < 0 || i >= (int)nVertices()) { + throw cms::Exception("FastSim") << "Index for FSimVertex out of range, please contact FastSim developers" + << std::endl; } return (*theSimVertices)[i]; } inline FSimVertexType& FBaseSimEvent::vertexType(int i) const { - if (i < 0 || i >=(int)nVertices()){ - throw cms::Exception("FastSim") << "Index for FSimVertexType out of range, please contact FastSim developers"<< std::endl; + if (i < 0 || i >= (int)nVertices()) { + throw cms::Exception("FastSim") << "Index for FSimVertexType out of range, please contact FastSim developers" + << std::endl; } - return (*theFSimVerticesType)[i]; + return (*theFSimVerticesType)[i]; } -inline const SimTrack& FBaseSimEvent::embdTrack(int i) const { - return (*theSimTracks)[i].simTrack(); } +inline const SimTrack& FBaseSimEvent::embdTrack(int i) const { return (*theSimTracks)[i].simTrack(); } -inline const SimVertex& FBaseSimEvent::embdVertex(int i) const { - return (*theSimVertices)[i].simVertex(); } +inline const SimVertex& FBaseSimEvent::embdVertex(int i) const { return (*theSimVertices)[i].simVertex(); } -inline const FSimVertexType& FBaseSimEvent::embdVertexType(int i) const { - return (*theFSimVerticesType)[i]; } +inline const FSimVertexType& FBaseSimEvent::embdVertexType(int i) const { return (*theFSimVerticesType)[i]; } diff --git a/FastSimulation/Event/interface/FSimEvent.h b/FastSimulation/Event/interface/FSimEvent.h index 260b49f11e61f..7ca56d2f45c91 100644 --- a/FastSimulation/Event/interface/FSimEvent.h +++ b/FastSimulation/Event/interface/FSimEvent.h @@ -9,7 +9,7 @@ // FAMOS Headers #include "FastSimulation/Event/interface/FBaseSimEvent.h" - + /** The FAMOS SimEvent: inherits from FBaseSimEvent, * where the latter provides FAMOS-specific event features (splitting * proposed by Maya STAVRIANAKOU) @@ -27,9 +27,7 @@ */ class FSimEvent : public FBaseSimEvent { - public: - /// Default constructor FSimEvent(const edm::ParameterSet& kine); @@ -37,18 +35,17 @@ class FSimEvent : public FBaseSimEvent { virtual ~FSimEvent(); /// fill the FBaseSimEvent from the current HepMC::GenEvent - void fill(const HepMC::GenEvent & hev, edm::EventID & Id); + void fill(const HepMC::GenEvent& hev, edm::EventID& Id); /// fill the FBaseSimEvent from the SimTrack's and SimVert'ices - void fill(const std::vector& simTracks, - const std::vector& simVertices); + void fill(const std::vector& simTracks, const std::vector& simVertices); ///Method to return the EventId edm::EventID id() const; ///Method to return the event weight float weight() const; - + /// Number of tracks unsigned int nTracks() const; /// Number of vertices @@ -57,15 +54,13 @@ class FSimEvent : public FBaseSimEvent { unsigned int nGenParts() const; /// Load containers of tracks (and muons) and vertices for the edm::Event - void load(edm::SimTrackContainer & c, edm::SimTrackContainer & m) const; - void load(edm::SimVertexContainer & c) const; - void load(FSimVertexTypeCollection & c) const; + void load(edm::SimTrackContainer& c, edm::SimTrackContainer& m) const; + void load(edm::SimVertexContainer& c) const; + void load(FSimVertexTypeCollection& c) const; private: - edm::EventID id_; double weight_; - }; -#endif // FSIMEVENT_H +#endif // FSIMEVENT_H diff --git a/FastSimulation/Event/interface/FSimTrack.h b/FastSimulation/Event/interface/FSimTrack.h index 67bc348fd091b..7b2af48d7b259 100644 --- a/FastSimulation/Event/interface/FSimTrack.h +++ b/FastSimulation/Event/interface/FSimTrack.h @@ -19,7 +19,7 @@ class FBaseSimEvent; namespace HepMC { class GenParticle; class GenVertex; -} +} // namespace HepMC /** A class that mimics SimTrack, with enhanced features. * Essentially an interface to SimTrack. @@ -28,31 +28,36 @@ namespace HepMC { */ class FSimTrack : public SimTrack { - - public: +public: /// Default constructor FSimTrack(); - + /// Constructor from the EmmbSimTrack index in the FBaseSimEvent - FSimTrack(const RawParticle* p, int iv, int ig, int id, FBaseSimEvent* mom, double dt=-1.); + FSimTrack(const RawParticle* p, int iv, int ig, int id, FBaseSimEvent* mom, double dt = -1.); //! Hack to interface "old" calorimetry with "new" propagation in tracker (need to construct FSimTracks) - FSimTrack(int ipart, const math::XYZTLorentzVector& p, int iv, int ig, int id, double charge, const math::XYZTLorentzVector& tkp, const math::XYZTLorentzVector& tkm, const SimVertex& tkv); - + FSimTrack(int ipart, + const math::XYZTLorentzVector& p, + int iv, + int ig, + int id, + double charge, + const math::XYZTLorentzVector& tkp, + const math::XYZTLorentzVector& tkm, + const SimVertex& tkv); + /// Destructor virtual ~FSimTrack(); /// particle info... - inline const HepPDT::ParticleData* particleInfo() const { - return info_; - } - + inline const HepPDT::ParticleData* particleInfo() const { return info_; } + /// charge - inline float charge() const { - if(particleInfo() == nullptr) return charge_; + inline float charge() const { + if (particleInfo() == nullptr) + return charge_; return particleInfo()->charge(); } - /// Origin vertex inline const FSimVertex vertex() const; @@ -73,20 +78,20 @@ class FSimTrack : public SimTrack { inline const std::vector& daughters() const; /// no end vertex - inline bool noEndVertex() const; + inline bool noEndVertex() const; /// Compare the end vertex position with another position. bool notYetToEndVertex(const XYZTLorentzVector& pos) const; /// no mother particle - inline bool noMother() const; + inline bool noMother() const; /// no daughters - inline bool noDaughter() const; + inline bool noDaughter() const; /// The original GenParticle inline const HepMC::GenParticle* genParticle() const; - + /// the index in FBaseSimEvent and other vectors inline int id() const { return id_; } @@ -95,7 +100,7 @@ class FSimTrack : public SimTrack { /// 0 : not yet propagated or no pe inline int onLayer1() const { return layer1; } - /// The particle was propagated to the Preshower Layer2 + /// The particle was propagated to the Preshower Layer2 /// 2 : on the EndCaps; (no Barrel Preshower); 3 : No propagation possible /// 0 : not yet propagated inline int onLayer2() const { return layer2; } @@ -114,7 +119,7 @@ class FSimTrack : public SimTrack { /// 2 : on the EndCaps (No VFCAL Barrel); 3 : no propagation possible /// 0 : not yet propagated inline int onVFcal() const { return vfcal; } - + /// The particle was propagated to the HCAL back face /// 1 : on the barrel; 2 : on the EndCaps; 3 : no propagation possible /// 0 : not yet propagated @@ -156,10 +161,10 @@ class FSimTrack : public SimTrack { inline void setGlobal() { isGlobal_ = true; } /// Set origin vertex - inline void setOriginVertex(const SimVertex& v) { vertex_ = v; } + inline void setOriginVertex(const SimVertex& v) { vertex_ = v; } /// Set the end vertex - inline void setEndVertex(int endv) { endv_ = endv; } + inline void setEndVertex(int endv) { endv_ = endv; } /// The particle has been propgated through the tracker void setPropagate(); @@ -171,7 +176,7 @@ class FSimTrack : public SimTrack { void setLayer2(const RawParticle& pp, int success); /// Set the ecal variables - void setEcal(const RawParticle& pp,int success); + void setEcal(const RawParticle& pp, int success); /// Set the hcal variables void setHcal(const RawParticle& pp, int success); @@ -204,7 +209,7 @@ class FSimTrack : public SimTrack { const XYZTLorentzVector& momentum() const { return momentum_; } /// Reset the momentum (to be used with care) - inline void setMomentum(const math::XYZTLorentzVector& newMomentum) {momentum_ = newMomentum; } + inline void setMomentum(const math::XYZTLorentzVector& newMomentum) { momentum_ = newMomentum; } /// Simply returns the SimTrack inline const SimTrack& simTrack() const { return *this; } @@ -212,61 +217,50 @@ class FSimTrack : public SimTrack { /// Return the pre-defined decay time inline double decayTime() const { return properDecayTime; } - private: - +private: // HepMC::GenParticle* me_; SimVertex vertex_; FBaseSimEvent* mom_; // int embd_; // The index in the SimTrack vector - int id_; // The index in the FSimTrackVector - double charge_; // Charge of the particle - - int endv_; // The index of the end vertex in FSimVertex - - int layer1;// 1 if the particle was propagated to preshower layer1 - int layer2;// 1 if the particle was propagated to preshower layer2 - int ecal; // 1 if the particle was propagated to ECAL/HCAL barrel - int hcal; // 2 if the particle was propagated to ECAL/HCAL endcap - int vfcal; // 1 if the particle was propagated to VFCAL - int hcalexit; // 2 if the particle was propagated to HCAL Exit point - int hoentr; // 1 if the particle was propagated to HO + int id_; // The index in the FSimTrackVector + double charge_; // Charge of the particle + int endv_; // The index of the end vertex in FSimVertex - bool prop; // true if the propagation to the calorimeters was done + int layer1; // 1 if the particle was propagated to preshower layer1 + int layer2; // 1 if the particle was propagated to preshower layer2 + int ecal; // 1 if the particle was propagated to ECAL/HCAL barrel + int hcal; // 2 if the particle was propagated to ECAL/HCAL endcap + int vfcal; // 1 if the particle was propagated to VFCAL + int hcalexit; // 2 if the particle was propagated to HCAL Exit point + int hoentr; // 1 if the particle was propagated to HO - RawParticle Layer1_Entrance; // the particle at preshower Layer1 - RawParticle Layer2_Entrance; // the particle at preshower Layer2 - RawParticle ECAL_Entrance; // the particle at ECAL entrance - RawParticle HCAL_Entrance; // the particle at HCAL entrance - RawParticle VFCAL_Entrance; // the particle at VFCAL entrance - RawParticle HCAL_Exit; // the particle at HCAL ezit point - RawParticle HO_Entrance; // the particle at HO entrance + bool prop; // true if the propagation to the calorimeters was done + RawParticle Layer1_Entrance; // the particle at preshower Layer1 + RawParticle Layer2_Entrance; // the particle at preshower Layer2 + RawParticle ECAL_Entrance; // the particle at ECAL entrance + RawParticle HCAL_Entrance; // the particle at HCAL entrance + RawParticle VFCAL_Entrance; // the particle at VFCAL entrance + RawParticle HCAL_Exit; // the particle at HCAL ezit point + RawParticle HO_Entrance; // the particle at HO entrance - std::vector daugh_; // The indices of the daughters in FSimTrack - int closestDaughterId_; // The index of the closest daughter id + std::vector daugh_; // The indices of the daughters in FSimTrack + int closestDaughterId_; // The index of the closest daughter id - const HepPDT::ParticleData* info_; // The PDG info + const HepPDT::ParticleData* info_; // The PDG info XYZTLorentzVector momentum_; - double properDecayTime; // The proper decay time (default is -1) - - bool isGlobal_; // needed for interfacing the new particle propagator with the old muon sim hit code + double properDecayTime; // The proper decay time (default is -1) + bool isGlobal_; // needed for interfacing the new particle propagator with the old muon sim hit code }; -#include -std::ostream& operator <<(std::ostream& o , const FSimTrack& t); +#include +std::ostream& operator<<(std::ostream& o, const FSimTrack& t); #include "FastSimulation/Event/interface/FSimTrack.icc" - - -#endif // FSimTrack_H - - - - - +#endif // FSimTrack_H diff --git a/FastSimulation/Event/interface/FSimTrack.icc b/FastSimulation/Event/interface/FSimTrack.icc index 651ea9f0f3835..001bb63fe58ab 100644 --- a/FastSimulation/Event/interface/FSimTrack.icc +++ b/FastSimulation/Event/interface/FSimTrack.icc @@ -1,73 +1,74 @@ #include "FastSimulation/Event/interface/FBaseSimEvent.h" #include "FastSimulation/Event/interface/FSimVertex.h" -inline const FSimVertex FSimTrack::vertex() const { return (!mom_ ? FSimVertex(vertex_.position(), vertex_.parentIndex(), vertex_.vertexId(), nullptr) : mom_->vertex(vertIndex())); } +inline const FSimVertex FSimTrack::vertex() const { + return (!mom_ ? FSimVertex(vertex_.position(), vertex_.parentIndex(), vertex_.vertexId(), nullptr) + : mom_->vertex(vertIndex())); +} inline const FSimVertex& FSimTrack::endVertex() const { - if(endv_ < 0) - throw cms::Exception("FastSim") << "FSimTrack::endVertex() called for FSimTrack w/o end vertex, please contact FastSim developers" << std::endl; - return mom_->vertex(endv_); + if (endv_ < 0) + throw cms::Exception("FastSim") + << "FSimTrack::endVertex() called for FSimTrack w/o end vertex, please contact FastSim developers" << std::endl; + return mom_->vertex(endv_); } -inline const FSimTrack& FSimTrack::mother() const{ - if(noMother()){ - throw cms::Exception("FastSim") << "FSimTrack::mother() called for FSimTrack w/o mother, please contact FastSim developers" << std::endl; +inline const FSimTrack& FSimTrack::mother() const { + if (noMother()) { + throw cms::Exception("FastSim") + << "FSimTrack::mother() called for FSimTrack w/o mother, please contact FastSim developers" << std::endl; } - return vertex().parent(); + return vertex().parent(); } inline const FSimTrack& FSimTrack::daughter(int i) const { - if(i < 0 || i >= nDaughters()) - throw cms::Exception("FastSim") << "FSimTrack::daughter(int index) index out of range, please contact FastSim developers" << std::endl; - if(abs(type()) == 11 || abs(type()) == 13) + if (i < 0 || i >= nDaughters()) + throw cms::Exception("FastSim") + << "FSimTrack::daughter(int index) index out of range, please contact FastSim developers" << std::endl; + if (abs(type()) == 11 || abs(type()) == 13) return mom_->track(daugh_[i]); else return endVertex().daughter(i); } inline int FSimTrack::nDaughters() const { - if(abs(type()) == 11 || abs(type()) == 13) + if (abs(type()) == 11 || abs(type()) == 13) return daugh_.size(); - else{ - if(noEndVertex()) + else { + if (noEndVertex()) return 0; - else - return endVertex().nDaughters(); + else + return endVertex().nDaughters(); } } inline const std::vector& FSimTrack::daughters() const { - if(abs(type()) == 11 || noEndVertex() ) + if (abs(type()) == 11 || noEndVertex()) return daugh_; - else{ + else { //if(noEndVertex()){ - //throw cms::Exception("FastSim") << "FSimTrack::daughters() called for FSimTrack w/o end vertex, please contact FastSim developers" << std::endl; + //throw cms::Exception("FastSim") << "FSimTrack::daughters() called for FSimTrack w/o end vertex, please contact FastSim developers" << std::endl; //} return endVertex().daughters(); } } -inline bool FSimTrack::noEndVertex() const { - +inline bool FSimTrack::noEndVertex() const { // The particle either has no end vertex index - if(endv_ < 0) - return true; + if (endv_ < 0) + return true; // or it's an electron/muon that has just Brem'ed, but continues its way // ... but not those intermediate e/mu PYTHIA entries with prompt Brem bool bremOutOfPipe = true; - if( (mom_->vertex(endv_)).position().Perp2() < 1.0 ) bremOutOfPipe = false; - return - ( (abs(type())==11 || abs(type())==13) && - bremOutOfPipe && - endVertex().nDaughters()>0 && - endVertex().daughter(endVertex().nDaughters()-1).type()==22); -} + if ((mom_->vertex(endv_)).position().Perp2() < 1.0) + bremOutOfPipe = false; + return ((abs(type()) == 11 || abs(type()) == 13) && bremOutOfPipe && endVertex().nDaughters() > 0 && + endVertex().daughter(endVertex().nDaughters() - 1).type() == 22); +} inline bool FSimTrack::noMother() const { return noVertex() || vertex().noParent(); } inline bool FSimTrack::noDaughter() const { return noEndVertex() || !nDaughters(); } -inline const HepMC::GenParticle* FSimTrack::genParticle() const { - return mom_->embdGenpart(genpartIndex()); -} +inline const HepMC::GenParticle* FSimTrack::genParticle() const { return mom_->embdGenpart(genpartIndex()); } diff --git a/FastSimulation/Event/interface/FSimTrackEqual.h b/FastSimulation/Event/interface/FSimTrackEqual.h index 2684c65773d36..4666d8d5f1e41 100644 --- a/FastSimulation/Event/interface/FSimTrackEqual.h +++ b/FastSimulation/Event/interface/FSimTrackEqual.h @@ -3,21 +3,16 @@ #include "FastSimulation/Event/interface/FSimTrack.h" -class FSimTrackEqual -{ - public: - FSimTrackEqual(int index):trackIndex_(index){}; - FSimTrackEqual(const FSimTrack & myTrack):trackIndex_(myTrack.trackId()){}; - ~FSimTrackEqual(){;}; +class FSimTrackEqual { +public: + FSimTrackEqual(int index) : trackIndex_(index){}; + FSimTrackEqual(const FSimTrack& myTrack) : trackIndex_(myTrack.trackId()){}; + ~FSimTrackEqual() { ; }; - inline bool operator()(const FSimTrack& track) const - { - return(track.id()==trackIndex_); - } - private: - int trackIndex_; + inline bool operator()(const FSimTrack& track) const { return (track.id() == trackIndex_); } +private: + int trackIndex_; }; - #endif diff --git a/FastSimulation/Event/interface/FSimVertex.h b/FastSimulation/Event/interface/FSimVertex.h index 4bfcab7f066c5..7fa9a9e33f4e4 100644 --- a/FastSimulation/Event/interface/FSimVertex.h +++ b/FastSimulation/Event/interface/FSimVertex.h @@ -17,11 +17,10 @@ class FSimTrack; */ class FSimVertex : public SimVertex { - public: /// Default constructor FSimVertex(); - + /// constructor from the embedded vertex index in the FBaseSimEvent FSimVertex(const math::XYZTLorentzVector& v, int im, int id, FBaseSimEvent* mom); @@ -38,7 +37,7 @@ class FSimVertex : public SimVertex { inline const FSimTrack& daughter(int i) const; /// no Daughters - inline bool noDaughter() const { return !nDaughters(); } + inline bool noDaughter() const { return !nDaughters(); } /// the index in FBaseSimEvent inline int id() const { return id_; } @@ -49,24 +48,22 @@ class FSimVertex : public SimVertex { inline const math::XYZTLorentzVector& position() const { return position_; } /// Reset the position (to be used with care) - inline void setPosition(const math::XYZTLorentzVector& newPosition) {position_ = newPosition; } + inline void setPosition(const math::XYZTLorentzVector& newPosition) { position_ = newPosition; } /// Simply returns the SimVertex inline const SimVertex& simVertex() const { return *this; } - private: - +private: const FBaseSimEvent* mom_; - int id_; // The index in the FSimVertex vector - std::vector daugh_; // The indices of the daughters in FSimTrack + int id_; // The index in the FSimVertex vector + std::vector daugh_; // The indices of the daughters in FSimTrack math::XYZTLorentzVector position_; - }; -#include -std::ostream& operator <<(std::ostream& o , const FSimVertex& t); +#include +std::ostream& operator<<(std::ostream& o, const FSimVertex& t); #include "FastSimulation/Event/interface/FSimVertex.icc" -#endif // FSimVertex_H +#endif // FSimVertex_H diff --git a/FastSimulation/Event/interface/FSimVertex.icc b/FastSimulation/Event/interface/FSimVertex.icc index 6f76947b9dcba..8ac4b13d7c16b 100644 --- a/FastSimulation/Event/interface/FSimVertex.icc +++ b/FastSimulation/Event/interface/FSimVertex.icc @@ -1,6 +1,6 @@ #include "FastSimulation/Event/interface/FSimTrack.h" #include "FastSimulation/Event/interface/FBaseSimEvent.h" -inline const FSimTrack& FSimVertex::parent() const{ return mom_->track(parentIndex()); } +inline const FSimTrack& FSimVertex::parent() const { return mom_->track(parentIndex()); } inline const FSimTrack& FSimVertex::daughter(int i) const { return mom_->track(daugh_[i]); } diff --git a/FastSimulation/Event/interface/KineParticleFilter.h b/FastSimulation/Event/interface/KineParticleFilter.h index 0e1ee0171a9d1..40261a0ea7722 100644 --- a/FastSimulation/Event/interface/KineParticleFilter.h +++ b/FastSimulation/Event/interface/KineParticleFilter.h @@ -4,26 +4,25 @@ #include "DataFormats/Math/interface/LorentzVector.h" class RawParticle; -namespace edm { - class ParameterSet; +namespace edm { + class ParameterSet; } -class KineParticleFilter -{ +class KineParticleFilter { public: - KineParticleFilter(const edm::ParameterSet& kine); - - ~KineParticleFilter(){;} - - bool acceptParticle(const RawParticle & p) const; - - bool acceptVertex(const math::XYZTLorentzVector & p) const; + KineParticleFilter(const edm::ParameterSet& kine); + + ~KineParticleFilter() { ; } + + bool acceptParticle(const RawParticle& p) const; + + bool acceptVertex(const math::XYZTLorentzVector& p) const; private: - // see constructor for comments - double chargedPtMin2, EMin, protonEMin; - double cos2ThetaMax; - double vertexRMax2,vertexZMax; + // see constructor for comments + double chargedPtMin2, EMin, protonEMin; + double cos2ThetaMax; + double vertexRMax2, vertexZMax; }; #endif diff --git a/FastSimulation/Event/src/FBaseSimEvent.cc b/FastSimulation/Event/src/FBaseSimEvent.cc index a1937b148abdc..6497e8f882189 100644 --- a/FastSimulation/Event/src/FBaseSimEvent.cc +++ b/FastSimulation/Event/src/FBaseSimEvent.cc @@ -29,17 +29,10 @@ using namespace HepPDT; #include #include -FBaseSimEvent::FBaseSimEvent(const edm::ParameterSet& kine) - : - nSimTracks(0), - nSimVertices(0), - nGenParticles(0), - nChargedParticleTracks(0), - initialSize(5000) -{ - +FBaseSimEvent::FBaseSimEvent(const edm::ParameterSet& kine) + : nSimTracks(0), nSimVertices(0), nGenParticles(0), nChargedParticleTracks(0), initialSize(5000) { // Initialize the vectors of particles and vertices - theGenParticles = new std::vector(); + theGenParticles = new std::vector(); theSimTracks = new std::vector; theSimVertices = new std::vector; theChargedTracks = new std::vector(); @@ -61,14 +54,13 @@ FBaseSimEvent::FBaseSimEvent(const edm::ParameterSet& kine) // Initialize the Particle filter myFilter = new KineParticleFilter(kine); - // Initialize the distance from (0,0,0) after which *generated* particles are + // Initialize the distance from (0,0,0) after which *generated* particles are // no longer considered - because the mother could have interacted before. // unit : cm x cm - lateVertexPosition = 2.5*2.5; + lateVertexPosition = 2.5 * 2.5; } - -FBaseSimEvent::~FBaseSimEvent(){ +FBaseSimEvent::~FBaseSimEvent() { // Clear the vectors theGenParticles->clear(); theSimTracks->clear(); @@ -76,60 +68,49 @@ FBaseSimEvent::~FBaseSimEvent(){ theChargedTracks->clear(); theFSimVerticesType->clear(); - // Delete + // Delete delete theGenParticles; delete theSimTracks; delete theSimVertices; delete theChargedTracks; delete theFSimVerticesType; delete myFilter; - } -void -FBaseSimEvent::initializePdt(const HepPDT::ParticleDataTable* aPdt) { +void FBaseSimEvent::initializePdt(const HepPDT::ParticleDataTable* aPdt) { pdt = aPdt; } - pdt = aPdt; - -} - -void -FBaseSimEvent::fill(const HepMC::GenEvent& myGenEvent) { - +void FBaseSimEvent::fill(const HepMC::GenEvent& myGenEvent) { // Clear old vectors clear(); // Add the particles in the FSimEvent addParticles(myGenEvent); - } -void -FBaseSimEvent::fill(const std::vector& simTracks, - const std::vector& simVertices) { - - // Watch out there ! A SimVertex is in mm (stupid), +void FBaseSimEvent::fill(const std::vector& simTracks, const std::vector& simVertices) { + // Watch out there ! A SimVertex is in mm (stupid), // while a FSimVertex is in cm (clever). - + clear(); unsigned nVtx = simVertices.size(); unsigned nTks = simTracks.size(); // Empty event, do nothin' - if ( nVtx == 0 ) return; + if (nVtx == 0) + return; // Two arrays for internal use. - std::vector myVertices(nVtx,-1); - std::vector myTracks(nTks,-1); + std::vector myVertices(nVtx, -1); + std::vector myTracks(nTks, -1); - // create a map associating geant particle id and position in the + // create a map associating geant particle id and position in the // event SimTrack vector - + std::map geantToIndex; - for( unsigned it=0; it& simTracks, // XYZTLorentzVector primaryVertex = simVertices[0].position(); // The next 5 lines to be then replaced by the previous line XYZTLorentzVector primaryVertex(simVertices[0].position().x(), - simVertices[0].position().y(), - simVertices[0].position().z(), - simVertices[0].position().t()); + simVertices[0].position().y(), + simVertices[0].position().z(), + simVertices[0].position().t()); // //myFilter->setMainVertex(primaryVertex); // Add the main vertex to the list. - addSimVertex(/*myFilter->vertex()*/primaryVertex, -1, FSimVertexType::PRIMARY_VERTEX); + addSimVertex(/*myFilter->vertex()*/ primaryVertex, -1, FSimVertexType::PRIMARY_VERTEX); myVertices[0] = 0; - for( unsigned trackId=0; trackId& simTracks, const SimVertex& vertex = simVertices[vertexId]; //std::cout << "Origin vertex " << vertexId << " " << vertex << std::endl; - // The mother track + // The mother track int motherId = -1; - if( !vertex.noParent() ) { // there is a parent to this vertex + if (!vertex.noParent()) { // there is a parent to this vertex // geant id of the mother - unsigned motherGeantId = vertex.parentIndex(); - std::map::iterator association - = geantToIndex.find( motherGeantId ); - if(association != geantToIndex.end() ) - motherId = association->second; + unsigned motherGeantId = vertex.parentIndex(); + std::map::iterator association = geantToIndex.find(motherGeantId); + if (association != geantToIndex.end()) + motherId = association->second; } - int originId = motherId == - 1 ? -1 : myTracks[motherId]; + int originId = motherId == -1 ? -1 : myTracks[motherId]; //std::cout << "Origin id " << originId << std::endl; /* @@ -189,82 +168,77 @@ FBaseSimEvent::fill(const std::vector& simTracks, */ // Add the vertex (if it does not already exist!) - XYZTLorentzVector position(vertex.position().px(),vertex.position().py(), - vertex.position().pz(),vertex.position().e()); - if ( myVertices[vertexId] == -1 ) + XYZTLorentzVector position( + vertex.position().px(), vertex.position().py(), vertex.position().pz(), vertex.position().e()); + if (myVertices[vertexId] == -1) // Momentum and position are copied until SimTrack and SimVertex // switch to Mathcore. - // myVertices[vertexId] = addSimVertex(vertex.position(),originId); + // myVertices[vertexId] = addSimVertex(vertex.position(),originId); // The next line to be then replaced by the previous line - myVertices[vertexId] = addSimVertex(position,originId); + myVertices[vertexId] = addSimVertex(position, originId); // Add the track (with protection for brem'ing electrons and muons) int motherType = motherId == -1 ? 0 : simTracks[motherId].type(); - bool notBremInDetector = - (abs(motherType) != 11 && std::abs(motherType) != 13) || - motherType != track.type() || - position.Perp2() < lateVertexPosition ; + bool notBremInDetector = (abs(motherType) != 11 && std::abs(motherType) != 13) || motherType != track.type() || + position.Perp2() < lateVertexPosition; - if ( notBremInDetector ) { + if (notBremInDetector) { // Momentum and position are copied until SimTrack and SimVertex // switch to Mathcore. // RawParticle part(track.momentum(), vertex.position()); // The next 3 lines to be then replaced by the previous line - XYZTLorentzVector momentum(track.momentum().px(),track.momentum().py(), - track.momentum().pz(),track.momentum().e()); - RawParticle part = makeParticle(theTable(),track.type(),momentum,position); + XYZTLorentzVector momentum( + track.momentum().px(), track.momentum().py(), track.momentum().pz(), track.momentum().e()); + RawParticle part = makeParticle(theTable(), track.type(), momentum, position); // //std::cout << "Ctau = " << part.PDGcTau() << std::endl; // Don't save tracks that have decayed immediately but for which no daughters // were saved (probably due to cuts on E, pT and eta) - // if ( part.PDGcTau() > 0.1 || endVertex.find(trackId) != endVertex.end() ) - myTracks[trackId] = addSimTrack(&part,myVertices[vertexId],track.genpartIndex()); - if ( myTracks[trackId] >= 0 ) { - (*theSimTracks)[ myTracks[trackId] ].setTkPosition(track.trackerSurfacePosition()); - (*theSimTracks)[ myTracks[trackId] ].setTkMomentum(track.trackerSurfaceMomentum()); + // if ( part.PDGcTau() > 0.1 || endVertex.find(trackId) != endVertex.end() ) + myTracks[trackId] = addSimTrack(&part, myVertices[vertexId], track.genpartIndex()); + if (myTracks[trackId] >= 0) { + (*theSimTracks)[myTracks[trackId]].setTkPosition(track.trackerSurfacePosition()); + (*theSimTracks)[myTracks[trackId]].setTkMomentum(track.trackerSurfaceMomentum()); } } else { - myTracks[trackId] = myTracks[motherId]; - if ( myTracks[trackId] >= 0 ) { - (*theSimTracks)[ myTracks[trackId] ].setTkPosition(track.trackerSurfacePosition()); - (*theSimTracks)[ myTracks[trackId] ].setTkMomentum(track.trackerSurfaceMomentum()); + if (myTracks[trackId] >= 0) { + (*theSimTracks)[myTracks[trackId]].setTkPosition(track.trackerSurfacePosition()); + (*theSimTracks)[myTracks[trackId]].setTkMomentum(track.trackerSurfaceMomentum()); } } - } // Now loop over the remaining end vertices ! - for( unsigned vertexId=0; vertexId::iterator association - = geantToIndex.find( motherGeantId ); - if(association != geantToIndex.end() ) - motherId = association->second; + unsigned motherGeantId = vertex.parentIndex(); + std::map::iterator association = geantToIndex.find(motherGeantId); + if (association != geantToIndex.end()) + motherId = association->second; } - int originId = motherId == - 1 ? -1 : myTracks[motherId]; + int originId = motherId == -1 ? -1 : myTracks[motherId]; // Add the vertex // Momentum and position are copied until SimTrack and SimVertex // switch to Mathcore. // myVertices[vertexId] = addSimVertex(vertex.position(),originId); // The next 3 lines to be then replaced by the previous line - XYZTLorentzVector position(vertex.position().px(),vertex.position().py(), - vertex.position().pz(),vertex.position().e()); - myVertices[vertexId] = addSimVertex(position,originId); + XYZTLorentzVector position( + vertex.position().px(), vertex.position().py(), vertex.position().pz(), vertex.position().e()); + myVertices[vertexId] = addSimVertex(position, originId); } // Finally, propagate all particles to the calorimeters @@ -272,467 +246,421 @@ FBaseSimEvent::fill(const std::vector& simTracks, XYZTLorentzVector mom; XYZTLorentzVector pos; - // Loop over the tracks - for( int fsimi=0; fsimi < (int)nTracks() ; ++fsimi) { - - + for (int fsimi = 0; fsimi < (int)nTracks(); ++fsimi) { FSimTrack& myTrack = track(fsimi); - double trackerSurfaceTime = myTrack.vertex().position().t() - + myTrack.momentum().e()/myTrack.momentum().pz() - * ( myTrack.trackerSurfacePosition().z() - - myTrack.vertex().position().z() ); + double trackerSurfaceTime = + myTrack.vertex().position().t() + myTrack.momentum().e() / myTrack.momentum().pz() * + (myTrack.trackerSurfacePosition().z() - myTrack.vertex().position().z()); pos = XYZTLorentzVector(myTrack.trackerSurfacePosition().x(), - myTrack.trackerSurfacePosition().y(), - myTrack.trackerSurfacePosition().z(), - trackerSurfaceTime); + myTrack.trackerSurfacePosition().y(), + myTrack.trackerSurfacePosition().z(), + trackerSurfaceTime); mom = XYZTLorentzVector(myTrack.trackerSurfaceMomentum().x(), - myTrack.trackerSurfaceMomentum().y(), - myTrack.trackerSurfaceMomentum().z(), - myTrack.trackerSurfaceMomentum().t()); + myTrack.trackerSurfaceMomentum().y(), + myTrack.trackerSurfaceMomentum().z(), + myTrack.trackerSurfaceMomentum().t()); - if ( mom.T() > 0. ) { + if (mom.T() > 0.) { // The particle to be propagated - myPart = BaseParticlePropagator(RawParticle(mom,pos,myTrack.charge()),0.,0.,4.); - + myPart = BaseParticlePropagator(RawParticle(mom, pos, myTrack.charge()), 0., 0., 4.); + // Propagate to Preshower layer 1 myPart.propagateToPreshowerLayer1(false); - if ( myTrack.notYetToEndVertex(myPart.particle().vertex()) && myPart.getSuccess()>0 ) - myTrack.setLayer1(myPart.particle(),myPart.getSuccess()); - - // Propagate to Preshower Layer 2 + if (myTrack.notYetToEndVertex(myPart.particle().vertex()) && myPart.getSuccess() > 0) + myTrack.setLayer1(myPart.particle(), myPart.getSuccess()); + + // Propagate to Preshower Layer 2 myPart.propagateToPreshowerLayer2(false); - if ( myTrack.notYetToEndVertex(myPart.particle().vertex()) && myPart.getSuccess()>0 ) - myTrack.setLayer2(myPart.particle(),myPart.getSuccess()); - + if (myTrack.notYetToEndVertex(myPart.particle().vertex()) && myPart.getSuccess() > 0) + myTrack.setLayer2(myPart.particle(), myPart.getSuccess()); + // Propagate to Ecal Endcap myPart.propagateToEcalEntrance(false); - if ( myTrack.notYetToEndVertex(myPart.particle().vertex()) ) - myTrack.setEcal(myPart.particle(),myPart.getSuccess()); - + if (myTrack.notYetToEndVertex(myPart.particle().vertex())) + myTrack.setEcal(myPart.particle(), myPart.getSuccess()); + // Propagate to HCAL entrance myPart.propagateToHcalEntrance(false); - if ( myTrack.notYetToEndVertex(myPart.particle().vertex()) ) - myTrack.setHcal(myPart.particle(),myPart.getSuccess()); - - // Attempt propagation to HF for low pt and high eta - if ( myPart.particle().cos2ThetaV()>0.8 || mom.T() < 3. ) { - // Propagate to VFCAL entrance - myPart.propagateToVFcalEntrance(false); - if ( myTrack.notYetToEndVertex(myPart.particle().vertex()) ) - myTrack.setVFcal(myPart.particle(),myPart.getSuccess()); - - // Otherwise propagate to the HCAL exit and HO. - } else { - // Propagate to HCAL exit - myPart.propagateToHcalExit(false); - if ( myTrack.notYetToEndVertex(myPart.particle().vertex()) ) - myTrack.setHcalExit(myPart.particle(),myPart.getSuccess()); - // Propagate to HOLayer entrance - myPart.setMagneticField(0); - myPart.propagateToHOLayer(false); - if ( myTrack.notYetToEndVertex(myPart.particle().vertex()) ) - myTrack.setHO(myPart.particle(),myPart.getSuccess()); - } + if (myTrack.notYetToEndVertex(myPart.particle().vertex())) + myTrack.setHcal(myPart.particle(), myPart.getSuccess()); + + // Attempt propagation to HF for low pt and high eta + if (myPart.particle().cos2ThetaV() > 0.8 || mom.T() < 3.) { + // Propagate to VFCAL entrance + myPart.propagateToVFcalEntrance(false); + if (myTrack.notYetToEndVertex(myPart.particle().vertex())) + myTrack.setVFcal(myPart.particle(), myPart.getSuccess()); + + // Otherwise propagate to the HCAL exit and HO. + } else { + // Propagate to HCAL exit + myPart.propagateToHcalExit(false); + if (myTrack.notYetToEndVertex(myPart.particle().vertex())) + myTrack.setHcalExit(myPart.particle(), myPart.getSuccess()); + // Propagate to HOLayer entrance + myPart.setMagneticField(0); + myPart.propagateToHOLayer(false); + if (myTrack.notYetToEndVertex(myPart.particle().vertex())) + myTrack.setHO(myPart.particle(), myPart.getSuccess()); + } } } } -void -FBaseSimEvent::addParticles(const HepMC::GenEvent& myGenEvent) { - +void FBaseSimEvent::addParticles(const HepMC::GenEvent& myGenEvent) { /// Some internal array to work with. int genEventSize = myGenEvent.particles_size(); std::vector myGenVertices(genEventSize, static_cast(0)); // If no particles, no work to be done ! - if ( myGenEvent.particles_empty() ) return; + if (myGenEvent.particles_empty()) + return; - // Are there particles in the FSimEvent already ? + // Are there particles in the FSimEvent already ? int offset = nGenParts(); // Primary vertex HepMC::GenVertex* primaryVertex = *(myGenEvent.vertices_begin()); // unit transformation (needs review) - XYZTLorentzVector primaryVertexPosition(primaryVertex->position().x()/10., - primaryVertex->position().y()/10., - primaryVertex->position().z()/10., - primaryVertex->position().t()/10.); + XYZTLorentzVector primaryVertexPosition(primaryVertex->position().x() / 10., + primaryVertex->position().y() / 10., + primaryVertex->position().z() / 10., + primaryVertex->position().t() / 10.); // This is the main vertex index int mainVertex = addSimVertex(primaryVertexPosition, -1, FSimVertexType::PRIMARY_VERTEX); - int initialBarcode = 0; - if ( myGenEvent.particles_begin() != myGenEvent.particles_end() ) - { - initialBarcode = (*myGenEvent.particles_begin())->barcode(); + int initialBarcode = 0; + if (myGenEvent.particles_begin() != myGenEvent.particles_end()) { + initialBarcode = (*myGenEvent.particles_begin())->barcode(); } // Loop on the particles of the generated event - for ( auto piter = myGenEvent.particles_begin(); piter != myGenEvent.particles_end(); ++piter ) - { - + for (auto piter = myGenEvent.particles_begin(); piter != myGenEvent.particles_end(); ++piter) { // This is the generated particle pointer - for the signal event only HepMC::GenParticle* p = *piter; - if ( !offset ) { + if (!offset) { (*theGenParticles)[nGenParticles++] = p; - if ( nGenParticles/theGenSize*theGenSize == nGenParticles ) { - theGenSize *= 2; - theGenParticles->resize(theGenSize); + if (nGenParticles / theGenSize * theGenSize == nGenParticles) { + theGenSize *= 2; + theGenParticles->resize(theGenSize); } - } // Reject particles with late origin vertex (i.e., coming from late decays) // This should not happen, but one never knows what users may be up to! // For example exotic particles might decay late - keep the decay products in the case. - XYZTLorentzVector productionVertexPosition(0.,0.,0.,0.); + XYZTLorentzVector productionVertexPosition(0., 0., 0., 0.); HepMC::GenVertex* productionVertex = p->production_vertex(); - if ( productionVertex ) { + if (productionVertex) { unsigned productionMother = productionVertex->particles_in_size(); - if ( productionMother ) { - unsigned motherId = (*(productionVertex->particles_in_const_begin()))->pdg_id(); - if ( motherId < 1000000 ) - productionVertexPosition = - XYZTLorentzVector(productionVertex->position().x()/10., - productionVertex->position().y()/10., - productionVertex->position().z()/10., - productionVertex->position().t()/10.); + if (productionMother) { + unsigned motherId = (*(productionVertex->particles_in_const_begin()))->pdg_id(); + if (motherId < 1000000) + productionVertexPosition = XYZTLorentzVector(productionVertex->position().x() / 10., + productionVertex->position().y() / 10., + productionVertex->position().z() / 10., + productionVertex->position().t() / 10.); } } - if ( !myFilter->acceptVertex(productionVertexPosition) ) continue; + if (!myFilter->acceptVertex(productionVertexPosition)) + continue; int abspdgId = std::abs(p->pdg_id()); HepMC::GenVertex* endVertex = p->end_vertex(); - // Keep only: + // Keep only: // 1) Stable particles (watch out! New status code = 1001!) - bool testStable = p->status()%1000==1; + bool testStable = p->status() % 1000 == 1; // Declare stable standard particles that decay after a macroscopic path length // (except if exotic) - if ( p->status() == 2 && abspdgId < 1000000) { - if ( endVertex ) { - XYZTLorentzVector decayPosition = - XYZTLorentzVector(endVertex->position().x()/10., - endVertex->position().y()/10., - endVertex->position().z()/10., - endVertex->position().t()/10.); - // If the particle flew enough to be beyond the beam pipe enveloppe, just declare it stable - if ( decayPosition.Perp2() > lateVertexPosition ) testStable = true; + if (p->status() == 2 && abspdgId < 1000000) { + if (endVertex) { + XYZTLorentzVector decayPosition = XYZTLorentzVector(endVertex->position().x() / 10., + endVertex->position().y() / 10., + endVertex->position().z() / 10., + endVertex->position().t() / 10.); + // If the particle flew enough to be beyond the beam pipe enveloppe, just declare it stable + if (decayPosition.Perp2() > lateVertexPosition) + testStable = true; } - } + } // 2) or particles with stable daughters (watch out! New status code = 1001!) bool testDaugh = false; - if ( !testStable && - p->status() == 2 && - endVertex && - endVertex->particles_out_size() ) { - HepMC::GenVertex::particles_out_const_iterator firstDaughterIt = - endVertex->particles_out_const_begin(); - HepMC::GenVertex::particles_out_const_iterator lastDaughterIt = - endVertex->particles_out_const_end(); - for ( ; firstDaughterIt != lastDaughterIt ; ++firstDaughterIt ) { - HepMC::GenParticle* daugh = *firstDaughterIt; - if ( daugh->status()%1000==1 ) { - // Check that it is not a "prompt electron or muon brem": - if (abspdgId == 11 || abspdgId == 13) { - if ( endVertex ) { - XYZTLorentzVector endVertexPosition = XYZTLorentzVector(endVertex->position().x()/10., - endVertex->position().y()/10., - endVertex->position().z()/10., - endVertex->position().t()/10.); - // If the particle flew enough to be beyond the beam pipe enveloppe, just declare it stable - if ( endVertexPosition.Perp2() < lateVertexPosition ) { - break; - } - } - } - testDaugh=true; - break; - } + if (!testStable && p->status() == 2 && endVertex && endVertex->particles_out_size()) { + HepMC::GenVertex::particles_out_const_iterator firstDaughterIt = endVertex->particles_out_const_begin(); + HepMC::GenVertex::particles_out_const_iterator lastDaughterIt = endVertex->particles_out_const_end(); + for (; firstDaughterIt != lastDaughterIt; ++firstDaughterIt) { + HepMC::GenParticle* daugh = *firstDaughterIt; + if (daugh->status() % 1000 == 1) { + // Check that it is not a "prompt electron or muon brem": + if (abspdgId == 11 || abspdgId == 13) { + if (endVertex) { + XYZTLorentzVector endVertexPosition = XYZTLorentzVector(endVertex->position().x() / 10., + endVertex->position().y() / 10., + endVertex->position().z() / 10., + endVertex->position().t() / 10.); + // If the particle flew enough to be beyond the beam pipe enveloppe, just declare it stable + if (endVertexPosition.Perp2() < lateVertexPosition) { + break; + } + } + } + testDaugh = true; + break; + } } } // 3) or particles that fly more than one micron. double dist = 0.; - if ( !testStable && !testDaugh && p->production_vertex() ) { - XYZTLorentzVector - productionVertexPosition(p->production_vertex()->position().x()/10., - p->production_vertex()->position().y()/10., - p->production_vertex()->position().z()/10., - p->production_vertex()->position().t()/10.); - dist = (primaryVertexPosition-productionVertexPosition).Vect().Mag2(); + if (!testStable && !testDaugh && p->production_vertex()) { + XYZTLorentzVector productionVertexPosition(p->production_vertex()->position().x() / 10., + p->production_vertex()->position().y() / 10., + p->production_vertex()->position().z() / 10., + p->production_vertex()->position().t() / 10.); + dist = (primaryVertexPosition - productionVertexPosition).Vect().Mag2(); } - bool testDecay = ( dist > 1e-8 ) ? true : false; + bool testDecay = (dist > 1e-8) ? true : false; // Save the corresponding particle and vertices - if ( testStable || testDaugh || testDecay ) { - + if (testStable || testDaugh || testDecay) { /* const HepMC::GenParticle* mother = p->production_vertex() ? *(p->production_vertex()->particles_in_const_begin()) : 0; */ - int motherBarcode = p->production_vertex() && - p->production_vertex()->particles_in_const_begin() != - p->production_vertex()->particles_in_const_end() ? - (*(p->production_vertex()->particles_in_const_begin()))->barcode() : 0; + int motherBarcode = p->production_vertex() && p->production_vertex()->particles_in_const_begin() != + p->production_vertex()->particles_in_const_end() + ? (*(p->production_vertex()->particles_in_const_begin()))->barcode() + : 0; - int originVertex = - motherBarcode && myGenVertices[motherBarcode-initialBarcode] ? - myGenVertices[motherBarcode-initialBarcode] : mainVertex; + int originVertex = motherBarcode && myGenVertices[motherBarcode - initialBarcode] + ? myGenVertices[motherBarcode - initialBarcode] + : mainVertex; - XYZTLorentzVector momentum(p->momentum().px(), - p->momentum().py(), - p->momentum().pz(), - p->momentum().e()); - RawParticle part= makeParticle(theTable(),p->pdg_id(),momentum, vertex(originVertex).position()); + XYZTLorentzVector momentum(p->momentum().px(), p->momentum().py(), p->momentum().pz(), p->momentum().e()); + RawParticle part = makeParticle(theTable(), p->pdg_id(), momentum, vertex(originVertex).position()); // Add the particle to the event and to the various lists - - int theTrack = testStable && p->end_vertex() ? - // The particle is scheduled to decay - addSimTrack(&part,originVertex, nGenParts()-offset,p->end_vertex()) : - // The particle is not scheduled to decay - addSimTrack(&part,originVertex, nGenParts()-offset); - - if ( - // This one deals with particles with no end vertex - !p->end_vertex() || - // This one deals with particles that have a pre-defined - // decay proper time, but have not decayed yet - ( testStable && p->end_vertex() && !p->end_vertex()->particles_out_size() ) - // In both case, just don't add a end vertex in the FSimEvent - ) continue; - + + int theTrack = testStable && p->end_vertex() ? + // The particle is scheduled to decay + addSimTrack(&part, originVertex, nGenParts() - offset, p->end_vertex()) + : + // The particle is not scheduled to decay + addSimTrack(&part, originVertex, nGenParts() - offset); + + if ( + // This one deals with particles with no end vertex + !p->end_vertex() || + // This one deals with particles that have a pre-defined + // decay proper time, but have not decayed yet + (testStable && p->end_vertex() && !p->end_vertex()->particles_out_size()) + // In both case, just don't add a end vertex in the FSimEvent + ) + continue; + // Add the vertex to the event and to the various lists - XYZTLorentzVector decayVertex = - XYZTLorentzVector(p->end_vertex()->position().x()/10., - p->end_vertex()->position().y()/10., - p->end_vertex()->position().z()/10., - p->end_vertex()->position().t()/10.); + XYZTLorentzVector decayVertex = XYZTLorentzVector(p->end_vertex()->position().x() / 10., + p->end_vertex()->position().y() / 10., + p->end_vertex()->position().z() / 10., + p->end_vertex()->position().t() / 10.); // vertex(mainVertex).position(); - int theVertex = addSimVertex(decayVertex,theTrack, FSimVertexType::DECAY_VERTEX); + int theVertex = addSimVertex(decayVertex, theTrack, FSimVertexType::DECAY_VERTEX); - if ( theVertex != -1 ) myGenVertices[p->barcode()-initialBarcode] = theVertex; + if (theVertex != -1) + myGenVertices[p->barcode() - initialBarcode] = theVertex; // There we are ! } } - } -int -FBaseSimEvent::addSimTrack(const RawParticle* p, int iv, int ig, - const HepMC::GenVertex* ev) { - +int FBaseSimEvent::addSimTrack(const RawParticle* p, int iv, int ig, const HepMC::GenVertex* ev) { // Check that the particle is in the Famos "acceptance" // Keep all primaries of pile-up events, though - if ( !myFilter->acceptParticle(*p) && ig >= -1 ) return -1; + if (!myFilter->acceptParticle(*p) && ig >= -1) + return -1; // The new track index int trackId = nSimTracks++; - if ( nSimTracks/theTrackSize*theTrackSize == nSimTracks ) { + if (nSimTracks / theTrackSize * theTrackSize == nSimTracks) { theTrackSize *= 2; theSimTracks->resize(theTrackSize); } // Attach the particle to the origin vertex, and to the mother vertex(iv).addDaughter(trackId); - if ( !vertex(iv).noParent() ) { + if (!vertex(iv).noParent()) { track(vertex(iv).parent().id()).addDaughter(trackId); - if ( ig == -1 ) { + if (ig == -1) { int motherId = track(vertex(iv).parent().id()).genpartIndex(); - if ( motherId < -1 ) ig = motherId; + if (motherId < -1) + ig = motherId; } } - + // Some transient information for FAMOS internal use - (*theSimTracks)[trackId] = ev ? - // A proper decay time is scheduled - FSimTrack(p,iv,ig,trackId,this, - ev->position().t()/10. - * pdg::mass(p->pid(), theTable()) - / std::sqrt(p->momentum().Vect().Mag2())) : - // No proper decay time is scheduled - FSimTrack(p,iv,ig,trackId,this); + (*theSimTracks)[trackId] = + ev ? + // A proper decay time is scheduled + FSimTrack(p, + iv, + ig, + trackId, + this, + ev->position().t() / 10. * pdg::mass(p->pid(), theTable()) / std::sqrt(p->momentum().Vect().Mag2())) + : + // No proper decay time is scheduled + FSimTrack(p, iv, ig, trackId, this); return trackId; - } -int -FBaseSimEvent::addSimVertex(const XYZTLorentzVector& v, int im, FSimVertexType::VertexType type) { - +int FBaseSimEvent::addSimVertex(const XYZTLorentzVector& v, int im, FSimVertexType::VertexType type) { // Check that the vertex is in the Famos "acceptance" - if ( !myFilter->acceptVertex(v) ) return -1; + if (!myFilter->acceptVertex(v)) + return -1; // The number of vertices int vertexId = nSimVertices++; - if ( nSimVertices/theVertexSize*theVertexSize == nSimVertices ) { + if (nSimVertices / theVertexSize * theVertexSize == nSimVertices) { theVertexSize *= 2; theSimVertices->resize(theVertexSize); theFSimVerticesType->resize(theVertexSize); } // Attach the end vertex to the particle (if accepted) - if ( im !=-1 ) track(im).setEndVertex(vertexId); + if (im != -1) + track(im).setEndVertex(vertexId); // Some transient information for FAMOS internal use - (*theSimVertices)[vertexId] = FSimVertex(v,im,vertexId,this); + (*theSimVertices)[vertexId] = FSimVertex(v, im, vertexId, this); (*theFSimVerticesType)[vertexId] = FSimVertexType(type); return vertexId; - } -void -FBaseSimEvent::printMCTruth(const HepMC::GenEvent& myGenEvent) { - - std::cout << "Id Gen Name eta phi pT E Vtx1 " - << " x y z " - << "Moth Vtx2 eta phi R Z Da1 Da2 Ecal?" << std::endl; - - for ( HepMC::GenEvent::particle_const_iterator - piter = myGenEvent.particles_begin(); - piter != myGenEvent.particles_end(); - ++piter ) { - +void FBaseSimEvent::printMCTruth(const HepMC::GenEvent& myGenEvent) { + std::cout << "Id Gen Name eta phi pT E Vtx1 " + << " x y z " + << "Moth Vtx2 eta phi R Z Da1 Da2 Ecal?" << std::endl; + + for (HepMC::GenEvent::particle_const_iterator piter = myGenEvent.particles_begin(); + piter != myGenEvent.particles_end(); + ++piter) { HepMC::GenParticle* p = *piter; - /* */ + /* */ int partId = p->pdg_id(); std::string name; - if ( pdt->particle(ParticleID(partId)) !=nullptr ) { + if (pdt->particle(ParticleID(partId)) != nullptr) { name = (pdt->particle(ParticleID(partId)))->name(); } else { name = "none"; } - - XYZTLorentzVector momentum1(p->momentum().px(), - p->momentum().py(), - p->momentum().pz(), - p->momentum().e()); + + XYZTLorentzVector momentum1(p->momentum().px(), p->momentum().py(), p->momentum().pz(), p->momentum().e()); int vertexId1 = 0; - if ( !p->production_vertex() ) continue; + if (!p->production_vertex()) + continue; - XYZVector vertex1 (p->production_vertex()->position().x()/10., - p->production_vertex()->position().y()/10., - p->production_vertex()->position().z()/10.); + XYZVector vertex1(p->production_vertex()->position().x() / 10., + p->production_vertex()->position().y() / 10., + p->production_vertex()->position().z() / 10.); vertexId1 = p->production_vertex()->barcode(); - + std::cout.setf(std::ios::fixed, std::ios::floatfield); std::cout.setf(std::ios::right, std::ios::adjustfield); - - std::cout << std::setw(4) << p->barcode() << " " - << name; - - for(unsigned int k=0;k<11-name.length() && k<12; k++) std::cout << " "; - + + std::cout << std::setw(4) << p->barcode() << " " << name; + + for (unsigned int k = 0; k < 11 - name.length() && k < 12; k++) + std::cout << " "; + double eta = momentum1.eta(); - if ( eta > +10. ) eta = +10.; - if ( eta < -10. ) eta = -10.; - std::cout << std::setw(6) << std::setprecision(2) << eta << " " - << std::setw(6) << std::setprecision(2) << momentum1.phi() << " " - << std::setw(7) << std::setprecision(2) << momentum1.pt() << " " - << std::setw(7) << std::setprecision(2) << momentum1.e() << " " - << std::setw(4) << vertexId1 << " " - << std::setw(6) << std::setprecision(1) << vertex1.x() << " " - << std::setw(6) << std::setprecision(1) << vertex1.y() << " " - << std::setw(6) << std::setprecision(1) << vertex1.z() << " "; - - const HepMC::GenParticle* mother = - *(p->production_vertex()->particles_in_const_begin()); - - if ( mother ) + if (eta > +10.) + eta = +10.; + if (eta < -10.) + eta = -10.; + std::cout << std::setw(6) << std::setprecision(2) << eta << " " << std::setw(6) << std::setprecision(2) + << momentum1.phi() << " " << std::setw(7) << std::setprecision(2) << momentum1.pt() << " " << std::setw(7) + << std::setprecision(2) << momentum1.e() << " " << std::setw(4) << vertexId1 << " " << std::setw(6) + << std::setprecision(1) << vertex1.x() << " " << std::setw(6) << std::setprecision(1) << vertex1.y() + << " " << std::setw(6) << std::setprecision(1) << vertex1.z() << " "; + + const HepMC::GenParticle* mother = *(p->production_vertex()->particles_in_const_begin()); + + if (mother) std::cout << std::setw(4) << mother->barcode() << " "; - else - std::cout << " " ; - - if ( p->end_vertex() ) { - XYZTLorentzVector vertex2(p->end_vertex()->position().x()/10., - p->end_vertex()->position().y()/10., - p->end_vertex()->position().z()/10., - p->end_vertex()->position().t()/10.); + else + std::cout << " "; + + if (p->end_vertex()) { + XYZTLorentzVector vertex2(p->end_vertex()->position().x() / 10., + p->end_vertex()->position().y() / 10., + p->end_vertex()->position().z() / 10., + p->end_vertex()->position().t() / 10.); int vertexId2 = p->end_vertex()->barcode(); std::vector children; - HepMC::GenVertex::particles_out_const_iterator firstDaughterIt = - p->end_vertex()->particles_out_const_begin(); - HepMC::GenVertex::particles_out_const_iterator lastDaughterIt = - p->end_vertex()->particles_out_const_end(); - for ( ; firstDaughterIt != lastDaughterIt ; ++firstDaughterIt ) { - children.push_back(*firstDaughterIt); - } - - std::cout << std::setw(4) << vertexId2 << " " - << std::setw(6) << std::setprecision(2) << vertex2.eta() << " " - << std::setw(6) << std::setprecision(2) << vertex2.phi() << " " - << std::setw(5) << std::setprecision(1) << vertex2.pt() << " " - << std::setw(6) << std::setprecision(1) << vertex2.z() << " "; - for ( unsigned id=0; idbarcode() << " "; + HepMC::GenVertex::particles_out_const_iterator firstDaughterIt = p->end_vertex()->particles_out_const_begin(); + HepMC::GenVertex::particles_out_const_iterator lastDaughterIt = p->end_vertex()->particles_out_const_end(); + for (; firstDaughterIt != lastDaughterIt; ++firstDaughterIt) { + children.push_back(*firstDaughterIt); + } + + std::cout << std::setw(4) << vertexId2 << " " << std::setw(6) << std::setprecision(2) << vertex2.eta() << " " + << std::setw(6) << std::setprecision(2) << vertex2.phi() << " " << std::setw(5) << std::setprecision(1) + << vertex2.pt() << " " << std::setw(6) << std::setprecision(1) << vertex2.z() << " "; + for (unsigned id = 0; id < children.size(); ++id) + std::cout << std::setw(4) << children[id]->barcode() << " "; } std::cout << std::endl; - } - } -void -FBaseSimEvent::print() const { - - std::cout << " Id Gen Name eta phi pT E Vtx1 " - << " x y z " - << "Moth Vtx2 eta phi R Z Daughters Ecal?" << std::endl; +void FBaseSimEvent::print() const { + std::cout << " Id Gen Name eta phi pT E Vtx1 " + << " x y z " + << "Moth Vtx2 eta phi R Z Daughters Ecal?" << std::endl; - for( int i=0; i<(int)nTracks(); i++ ) + for (int i = 0; i < (int)nTracks(); i++) std::cout << track(i) << std::endl; - for( int i=0; i<(int)nVertices(); i++ ) + for (int i = 0; i < (int)nVertices(); i++) std::cout << "i = " << i << " " << vertexType(i) << std::endl; - - - } -void -FBaseSimEvent::clear() { - +void FBaseSimEvent::clear() { nSimTracks = 0; nSimVertices = 0; nGenParticles = 0; nChargedParticleTracks = 0; - } -void -FBaseSimEvent::addChargedTrack(int id) { +void FBaseSimEvent::addChargedTrack(int id) { (*theChargedTracks)[nChargedParticleTracks++] = id; - if ( nChargedParticleTracks/theChargedSize*theChargedSize - == nChargedParticleTracks ) { + if (nChargedParticleTracks / theChargedSize * theChargedSize == nChargedParticleTracks) { theChargedSize *= 2; theChargedTracks->resize(theChargedSize); } } -int -FBaseSimEvent::chargedTrack(int id) const { - if (id>=0 && id<(int)nChargedParticleTracks) - return (*theChargedTracks)[id]; - else +int FBaseSimEvent::chargedTrack(int id) const { + if (id >= 0 && id < (int)nChargedParticleTracks) + return (*theChargedTracks)[id]; + else return -1; } -const HepMC::GenParticle* -FBaseSimEvent::embdGenpart(int i) const { - return (*theGenParticles)[i]; -} - +const HepMC::GenParticle* FBaseSimEvent::embdGenpart(int i) const { return (*theGenParticles)[i]; } diff --git a/FastSimulation/Event/src/FSimEvent.cc b/FastSimulation/Event/src/FSimEvent.cc index ab980f202d573..832f8c0cc4165 100644 --- a/FastSimulation/Event/src/FSimEvent.cc +++ b/FastSimulation/Event/src/FSimEvent.cc @@ -3,95 +3,57 @@ //C++ Headers -FSimEvent::FSimEvent(const edm::ParameterSet& kine) - : FBaseSimEvent(kine), id_(edm::EventID(0,0,0)), weight_(0) -{} - -FSimEvent::~FSimEvent() -{} +FSimEvent::FSimEvent(const edm::ParameterSet& kine) : FBaseSimEvent(kine), id_(edm::EventID(0, 0, 0)), weight_(0) {} -void -FSimEvent::fill(const HepMC::GenEvent& hev, edm::EventID& Id) { +FSimEvent::~FSimEvent() {} + +void FSimEvent::fill(const HepMC::GenEvent& hev, edm::EventID& Id) { FBaseSimEvent::fill(hev); id_ = Id; } -void -FSimEvent::fill(const std::vector& simTracks, - const std::vector& simVertices) { - FBaseSimEvent::fill(simTracks,simVertices); +void FSimEvent::fill(const std::vector& simTracks, const std::vector& simVertices) { + FBaseSimEvent::fill(simTracks, simVertices); id_ = edm::EventID(); -} - -edm::EventID -FSimEvent::id() const { - return id_; -} - -float FSimEvent::weight() const { - return weight_; } -unsigned int -FSimEvent::nTracks() const { - return FBaseSimEvent::nTracks(); -} +edm::EventID FSimEvent::id() const { return id_; } -unsigned int -FSimEvent::nVertices() const { - return FBaseSimEvent::nVertices(); -} +float FSimEvent::weight() const { return weight_; } -unsigned int -FSimEvent::nGenParts() const { - return FBaseSimEvent::nGenParts(); -} +unsigned int FSimEvent::nTracks() const { return FBaseSimEvent::nTracks(); } + +unsigned int FSimEvent::nVertices() const { return FBaseSimEvent::nVertices(); } -void -FSimEvent::load(edm::SimTrackContainer & c, edm::SimTrackContainer & m) const -{ - for (unsigned int i=0; i 1.0 && - fabs(t.momentum().eta()) < 3.0 && - track(i).noEndVertex() ) { + if (abs(t.type()) == 13 && t.momentum().perp2() > 1.0 && fabs(t.momentum().eta()) < 3.0 && track(i).noEndVertex()) { // Actually save the muon mother (and the attached muon) in case - if ( !track(i).noMother() && track(i).mother().closestDaughterId() == (int)i ) { - const SimTrack& T = embdTrack(track(i).mother().id()); - m.push_back(T); - } + if (!track(i).noMother() && track(i).mother().closestDaughterId() == (int)i) { + const SimTrack& T = embdTrack(track(i).mother().id()); + m.push_back(T); + } m.push_back(t); } } } -void -FSimEvent::load(edm::SimVertexContainer & c) const -{ - for (unsigned int i=0; ipid(),*p,iv,ig), // to uncomment once Mathcore is installed - SimTrack(p->pid(),p->momentum(),iv,ig), - mom_(mom), id_(id), charge_(-999), endv_(-1), - layer1(0), layer2(0), ecal(0), hcal(0), vfcal(0), hcalexit(0), hoentr(0), prop(false), - closestDaughterId_(-1), momentum_(p->momentum()), - properDecayTime(dt) -{ +FSimTrack::FSimTrack() + : SimTrack(), + mom_(nullptr), + id_(-1), + charge_(-999), + endv_(-1), + layer1(0), + layer2(0), + ecal(0), + hcal(0), + vfcal(0), + hcalexit(0), + hoentr(0), + prop(false), + closestDaughterId_(-1), + info_(nullptr), + properDecayTime(1E99) { + ; +} + +FSimTrack::FSimTrack(const RawParticle* p, int iv, int ig, int id, FBaseSimEvent* mom, double dt) + : // SimTrack(p->pid(),*p,iv,ig), // to uncomment once Mathcore is installed + SimTrack(p->pid(), p->momentum(), iv, ig), + mom_(mom), + id_(id), + charge_(-999), + endv_(-1), + layer1(0), + layer2(0), + ecal(0), + hcal(0), + vfcal(0), + hcalexit(0), + hoentr(0), + prop(false), + closestDaughterId_(-1), + momentum_(p->momentum()), + properDecayTime(dt) { setTrackId(id); info_ = mom_->theTable()->particle(HepPDT::ParticleID(type())); } - //! Hack to interface "old" calorimetry with "new" propagation in tracker (need to construct FSimTracks) -FSimTrack::FSimTrack(int ipart, const math::XYZTLorentzVector& p, int iv, int ig, int id, double charge, const math::XYZTLorentzVector& tkp, const math::XYZTLorentzVector& tkm, const SimVertex& tkv) : - SimTrack(ipart, p, iv, ig, math::XYZVectorD(tkp.X(), tkp.Y(), tkp.Z()), tkm), vertex_(tkv), - mom_(nullptr), id_(id), charge_(charge), endv_(-1), - layer1(0), layer2(0), ecal(0), hcal(0), vfcal(0), hcalexit(0), hoentr(0), prop(false), - closestDaughterId_(-1), info_(nullptr), momentum_(p), - properDecayTime(-1), isGlobal_(false) - { - setTrackId(id); - } +FSimTrack::FSimTrack(int ipart, + const math::XYZTLorentzVector& p, + int iv, + int ig, + int id, + double charge, + const math::XYZTLorentzVector& tkp, + const math::XYZTLorentzVector& tkm, + const SimVertex& tkv) + : SimTrack(ipart, p, iv, ig, math::XYZVectorD(tkp.X(), tkp.Y(), tkp.Z()), tkm), + vertex_(tkv), + mom_(nullptr), + id_(id), + charge_(charge), + endv_(-1), + layer1(0), + layer2(0), + ecal(0), + hcal(0), + vfcal(0), + hcalexit(0), + hoentr(0), + prop(false), + closestDaughterId_(-1), + info_(nullptr), + momentum_(p), + properDecayTime(-1), + isGlobal_(false) { + setTrackId(id); +} -FSimTrack::~FSimTrack() {;} +FSimTrack::~FSimTrack() { ; } -bool -FSimTrack::notYetToEndVertex(const XYZTLorentzVector& pos) const { +bool FSimTrack::notYetToEndVertex(const XYZTLorentzVector& pos) const { // If there is no end vertex, nothing to compare to - if ( noEndVertex() ) return true; + if (noEndVertex()) + return true; // If the particle immediately decays, no need to propagate - if ( (endVertex().position()-vertex().position()).Vect().Mag2() < 1e-4 ) + if ((endVertex().position() - vertex().position()).Vect().Mag2() < 1e-4) return false; // If the end vertex has a larger radius, not yet there - if ( endVertex().position().Perp2() > pos.Perp2()+1e-10 ) return true; + if (endVertex().position().Perp2() > pos.Perp2() + 1e-10) + return true; // If the end vertex has a larger z, not yet there - if ( fabs(endVertex().position().Z()) > fabs(pos.Z())+1e-5 ) return true; + if (fabs(endVertex().position().Z()) > fabs(pos.Z()) + 1e-5) + return true; // Otherwise, the end vertex is overtaken already return false; } /// Set the variable at the beginning of the propagation -void -FSimTrack::setPropagate() { - prop=true; -} +void FSimTrack::setPropagate() { prop = true; } /// Set the preshower layer1 variables -void -FSimTrack::setLayer1(const RawParticle& pp, int success) { - Layer1_Entrance=pp; - layer1=success; +void FSimTrack::setLayer1(const RawParticle& pp, int success) { + Layer1_Entrance = pp; + layer1 = success; } /// Set the preshower layer2 variables -void -FSimTrack::setLayer2(const RawParticle& pp, int success) { - Layer2_Entrance=pp; - layer2=success; +void FSimTrack::setLayer2(const RawParticle& pp, int success) { + Layer2_Entrance = pp; + layer2 = success; } /// Set the ecal variables -void -FSimTrack::setEcal(const RawParticle& pp, int success) { - ECAL_Entrance=pp; - ecal=success; +void FSimTrack::setEcal(const RawParticle& pp, int success) { + ECAL_Entrance = pp; + ecal = success; } /// Set the hcal variables -void -FSimTrack::setHcal(const RawParticle& pp, int success) { - HCAL_Entrance=pp; - hcal=success; +void FSimTrack::setHcal(const RawParticle& pp, int success) { + HCAL_Entrance = pp; + hcal = success; } /// Set the vcal variables -void -FSimTrack::setVFcal(const RawParticle& pp, int success) { - VFCAL_Entrance=pp; - vfcal=success; +void FSimTrack::setVFcal(const RawParticle& pp, int success) { + VFCAL_Entrance = pp; + vfcal = success; } /// Set the hcal variables -void -FSimTrack::setHcalExit(const RawParticle& pp, int success) { - HCAL_Exit=pp; - hcalexit=success; +void FSimTrack::setHcalExit(const RawParticle& pp, int success) { + HCAL_Exit = pp; + hcalexit = success; } -void -FSimTrack::setHO(const RawParticle& pp, int success) { - HO_Entrance=pp; - hoentr=success; +void FSimTrack::setHO(const RawParticle& pp, int success) { + HO_Entrance = pp; + hoentr = success; } - - - - - -std::ostream& operator <<(std::ostream& o , const FSimTrack& t) { +std::ostream& operator<<(std::ostream& o, const FSimTrack& t) { std::string name = t.particleInfo() ? t.particleInfo()->name() : "Unknown"; const XYZTLorentzVector& momentum1 = t.momentum(); XYZVector vertex1 = t.vertex().position().Vect(); @@ -124,103 +152,82 @@ std::ostream& operator <<(std::ostream& o , const FSimTrack& t) { o.setf(std::ios::fixed, std::ios::floatfield); o.setf(std::ios::right, std::ios::adjustfield); - o << std::setw(4) << t.id() << "; " - << std::setw(4) << t.genpartIndex() << "; " - << name << "\n\t\t"; - - //for(unsigned int k=0;k<11-name.length() && k<12; k++) o << "; "; - - o << "Position: " - << std::setw(6) << std::setprecision(2) << momentum1.eta() << "; " - << std::setw(6) << std::setprecision(2) << momentum1.phi() << "; " - << std::setw(6) << std::setprecision(2) << momentum1.pt() << "; " - << std::setw(6) << std::setprecision(2) << momentum1.e() << "; " - << std::setw(4) << vertexId1 << "; " - << std::setw(6) << std::setprecision(1) << vertex1.x() << "; " - << std::setw(6) << std::setprecision(1) << vertex1.y() << "; " - << std::setw(6) << std::setprecision(1) << vertex1.z() << "; " - << std::setw(4) << (t.particleInfo() ? (t.noMother() ? -1 :t.mother().id()) :-1) << "; " << "\n\t\t"; - - if ( !t.noEndVertex() ) { + o << std::setw(4) << t.id() << "; " << std::setw(4) << t.genpartIndex() << "; " << name << "\n\t\t"; + + //for(unsigned int k=0;k<11-name.length() && k<12; k++) o << "; "; + + o << "Position: " << std::setw(6) << std::setprecision(2) << momentum1.eta() << "; " << std::setw(6) + << std::setprecision(2) << momentum1.phi() << "; " << std::setw(6) << std::setprecision(2) << momentum1.pt() << "; " + << std::setw(6) << std::setprecision(2) << momentum1.e() << "; " << std::setw(4) << vertexId1 << "; " + << std::setw(6) << std::setprecision(1) << vertex1.x() << "; " << std::setw(6) << std::setprecision(1) + << vertex1.y() << "; " << std::setw(6) << std::setprecision(1) << vertex1.z() << "; " << std::setw(4) + << (t.particleInfo() ? (t.noMother() ? -1 : t.mother().id()) : -1) << "; " + << "\n\t\t"; + + if (!t.noEndVertex()) { XYZTLorentzVector vertex2 = t.endVertex().position(); int vertexId2 = t.endVertex().id(); - - o << "Decayed particle: " - << std::setw(4) << vertexId2 << "; " - << std::setw(6) << std::setprecision(2) << vertex2.eta() << "; " - << std::setw(6) << std::setprecision(2) << vertex2.phi() << "; " - << std::setw(5) << std::setprecision(1) << vertex2.pt() << "; " - << std::setw(6) << std::setprecision(1) << vertex2.z() << "; "; - for (int i=0; i(t); +/// constructor from the embedded vertex index in the FBaseSimEvent +FSimVertex::FSimVertex(const XYZTLorentzVector& v, int im, int id, FBaseSimEvent* mom) + : // SimVertex(Hep3Vector(v.vect(),v.e(),im), mom_(mom), id_(id) + SimVertex(v.Vect(), v.T(), im, id), + mom_(mom), + id_(id), + position_(v) { + ; } + +std::ostream& operator<<(std::ostream& o, const FSimVertex& t) { return o << static_cast(t); } diff --git a/FastSimulation/Event/src/KineParticleFilter.cc b/FastSimulation/Event/src/KineParticleFilter.cc index e8a1efe80fb80..69c60d1c0b6c0 100644 --- a/FastSimulation/Event/src/KineParticleFilter.cc +++ b/FastSimulation/Event/src/KineParticleFilter.cc @@ -2,73 +2,60 @@ #include "CommonTools/BaseParticlePropagator/interface/RawParticle.h" #include "FWCore/ParameterSet/interface/ParameterSet.h" -KineParticleFilter::KineParticleFilter(const edm::ParameterSet & cfg) -{ - // Charged particles must have pt greater than chargedPtMin [GeV] - double chargedPtMin = cfg.getParameter("chargedPtMin"); - chargedPtMin2 = chargedPtMin*chargedPtMin; - - // Particles must have energy greater than EMin [GeV] - EMin = cfg.getParameter("EMin"); - - // Allow *ALL* protons with energy > protonEMin - protonEMin = cfg.getParameter("protonEMin"); - - // Particles must have abs(eta) < etaMax (if close enough to 0,0,0) - double etaMax = cfg.getParameter("etaMax"); - cos2ThetaMax = (std::exp(2.*etaMax)-1.) / (std::exp(2.*etaMax)+1.); - cos2ThetaMax *= cos2ThetaMax; - - // Particles must have vertex inside the volume enclosed by ECAL - double vertexRMax = cfg.getParameter("rMax"); - vertexRMax2 = vertexRMax*vertexRMax; - vertexZMax = cfg.getParameter("zMax"); - +KineParticleFilter::KineParticleFilter(const edm::ParameterSet& cfg) { + // Charged particles must have pt greater than chargedPtMin [GeV] + double chargedPtMin = cfg.getParameter("chargedPtMin"); + chargedPtMin2 = chargedPtMin * chargedPtMin; + + // Particles must have energy greater than EMin [GeV] + EMin = cfg.getParameter("EMin"); + + // Allow *ALL* protons with energy > protonEMin + protonEMin = cfg.getParameter("protonEMin"); + + // Particles must have abs(eta) < etaMax (if close enough to 0,0,0) + double etaMax = cfg.getParameter("etaMax"); + cos2ThetaMax = (std::exp(2. * etaMax) - 1.) / (std::exp(2. * etaMax) + 1.); + cos2ThetaMax *= cos2ThetaMax; + + // Particles must have vertex inside the volume enclosed by ECAL + double vertexRMax = cfg.getParameter("rMax"); + vertexRMax2 = vertexRMax * vertexRMax; + vertexZMax = cfg.getParameter("zMax"); } -bool KineParticleFilter::acceptParticle(const RawParticle & particle) const -{ +bool KineParticleFilter::acceptParticle(const RawParticle& particle) const { + int pId = abs(particle.pid()); - int pId = abs(particle.pid()); + // skipp invisible particles + if (pId == 12 || pId == 14 || pId == 16 || pId == 1000022) { + return false; + } - // skipp invisible particles - if(pId == 12 || pId == 14 || pId == 16 || pId == 1000022) - { - return false; - } + // keep all high-energy protons + else if (pId == 2212 && particle.E() >= protonEMin) { + return true; + } - // keep all high-energy protons - else if(pId == 2212 && particle.E() >= protonEMin) - { - return true; - } + // cut on the energy + else if (particle.E() < EMin) { + return false; + } - // cut on the energy - else if( particle.E() < EMin) - { - return false; - } + // cut on pt of charged particles + else if (particle.charge() != 0 && particle.Perp2() < chargedPtMin2) { + return false; + } - // cut on pt of charged particles - else if( particle.charge()!=0 && particle.Perp2() cos2ThetaMax) { + return false; + } - // cut on eta if the origin vertex is close to the beam - else if( particle.vertex().Perp2() < 25. && particle.cos2Theta() > cos2ThetaMax) - { - return false; - } - - - - // particles must have vertex in volume enclosed by ECAL - return acceptVertex(particle.vertex()); + // particles must have vertex in volume enclosed by ECAL + return acceptVertex(particle.vertex()); } - -bool KineParticleFilter::acceptVertex(const XYZTLorentzVector & vertex) const -{ - return vertex.Perp2() < vertexRMax2 && fabs(vertex.Z()) < vertexZMax; +bool KineParticleFilter::acceptVertex(const XYZTLorentzVector& vertex) const { + return vertex.Perp2() < vertexRMax2 && fabs(vertex.Z()) < vertexZMax; } diff --git a/FastSimulation/MaterialEffects/interface/BremsstrahlungSimulator.h b/FastSimulation/MaterialEffects/interface/BremsstrahlungSimulator.h index 8475b3b162bb0..ee7ede2c2d590 100644 --- a/FastSimulation/MaterialEffects/interface/BremsstrahlungSimulator.h +++ b/FastSimulation/MaterialEffects/interface/BremsstrahlungSimulator.h @@ -17,25 +17,20 @@ * * \author Patrick Janot * $Date: 25-Dec-2003 - */ - + */ class ParticlePropagator; class RandomEngineAndDistribution; -class BremsstrahlungSimulator : public MaterialEffectsSimulator -{ - public: - +class BremsstrahlungSimulator : public MaterialEffectsSimulator { +public: /// Constructor - BremsstrahlungSimulator(double photonEnergyCut, - double photonFractECut); + BremsstrahlungSimulator(double photonEnergyCut, double photonFractECut); /// Default destructor ~BremsstrahlungSimulator() override {} - private: - +private: /// The minimum photon energy to be radiated, in GeV double photonEnergy; @@ -49,16 +44,12 @@ class BremsstrahlungSimulator : public MaterialEffectsSimulator unsigned int poisson(double ymu, RandomEngineAndDistribution const*); /// Generate Bremsstrahlung photons - void compute(ParticlePropagator &Particle, RandomEngineAndDistribution const*) override; + void compute(ParticlePropagator& Particle, RandomEngineAndDistribution const*) override; /// Compute Brem photon energy and angles, if any. XYZTLorentzVector brem(ParticlePropagator& p, RandomEngineAndDistribution const*) const; /// A universal angular distribution - still from GEANT. - double gbteth(const double ener, - const double partm, - const double efrac, - RandomEngineAndDistribution const*) const; - + double gbteth(const double ener, const double partm, const double efrac, RandomEngineAndDistribution const*) const; }; #endif diff --git a/FastSimulation/MaterialEffects/interface/CMSDummyDeexcitation.h b/FastSimulation/MaterialEffects/interface/CMSDummyDeexcitation.h index 7347958d6b8c7..b8adcf4122cf7 100644 --- a/FastSimulation/MaterialEffects/interface/CMSDummyDeexcitation.h +++ b/FastSimulation/MaterialEffects/interface/CMSDummyDeexcitation.h @@ -7,7 +7,7 @@ * * \author Vladimir Ivanchenko * $Date: 20-Jan-2015 - */ + */ #include "G4VPreCompoundModel.hh" #include "G4ReactionProductVector.hh" @@ -17,19 +17,16 @@ class G4HadFinalState; class G4HadProjectile; class G4Nucleus; -class CMSDummyDeexcitation : public G4VPreCompoundModel -{ +class CMSDummyDeexcitation : public G4VPreCompoundModel { public: + CMSDummyDeexcitation() : G4VPreCompoundModel(nullptr, "PRECO"){}; - CMSDummyDeexcitation():G4VPreCompoundModel(nullptr, "PRECO") {}; + ~CMSDummyDeexcitation() override{}; - ~CMSDummyDeexcitation() override {}; - - G4HadFinalState* ApplyYourself(const G4HadProjectile&, G4Nucleus&) override { return nullptr; } + G4HadFinalState* ApplyYourself(const G4HadProjectile&, G4Nucleus&) override { return nullptr; } G4ReactionProductVector* DeExcite(G4Fragment&) override { return new G4ReactionProductVector(); }; void DeExciteModelDescription(std::ostream&) const override {} - }; #endif diff --git a/FastSimulation/MaterialEffects/interface/EnergyLossSimulator.h b/FastSimulation/MaterialEffects/interface/EnergyLossSimulator.h old mode 100755 new mode 100644 index 65bba74a86d2c..3b2eda18689cd --- a/FastSimulation/MaterialEffects/interface/EnergyLossSimulator.h +++ b/FastSimulation/MaterialEffects/interface/EnergyLossSimulator.h @@ -17,16 +17,13 @@ * * \author Patrick Janot * $Date: 8-Jan-2004 - */ - + */ class RandomEngineAndDistribution; class LandauFluctuationGenerator; -class EnergyLossSimulator : public MaterialEffectsSimulator -{ - public: - +class EnergyLossSimulator : public MaterialEffectsSimulator { +public: /// Constructor EnergyLossSimulator(double A, double Z, double density, double radLen); @@ -39,19 +36,18 @@ class EnergyLossSimulator : public MaterialEffectsSimulator /// Returns the actual energy lost inline const XYZTLorentzVector& deltaMom() const { return deltaP; } - private: +private: /// The Landau Fluctuation generator LandauFluctuationGenerator* theGenerator; /// The real dE/dx generation and particle update - void compute(ParticlePropagator &Particle, RandomEngineAndDistribution const*) override; + void compute(ParticlePropagator& Particle, RandomEngineAndDistribution const*) override; /// The most probable enery loss double mostProbableLoss; /// The actual energy loss XYZTLorentzVector deltaP; - }; #endif diff --git a/FastSimulation/MaterialEffects/interface/MaterialEffects.h b/FastSimulation/MaterialEffects/interface/MaterialEffects.h old mode 100755 new mode 100644 index 4ce15d0b9f843..7a8734c6a0500 --- a/FastSimulation/MaterialEffects/interface/MaterialEffects.h +++ b/FastSimulation/MaterialEffects/interface/MaterialEffects.h @@ -48,11 +48,8 @@ namespace edm { class ParameterSet; } -class MaterialEffects -{ - - public: - +class MaterialEffects { +public: /// Constructor MaterialEffects(const edm::ParameterSet& matEff); @@ -62,9 +59,9 @@ class MaterialEffects /// Steer the various interaction processes in the Tracker Material /// and update the FSimEvent void interact(FSimEvent& simEvent, - const TrackerLayer& layer, - ParticlePropagator& PP, - unsigned i, + const TrackerLayer& layer, + ParticlePropagator& PP, + unsigned i, RandomEngineAndDistribution const*); /// Save nuclear interaction information @@ -77,32 +74,22 @@ class MaterialEffects inline double energyLoss() const { return theEnergyLoss; } /// Return the Multiple Scattering engine - inline MultipleScatteringSimulator* multipleScatteringSimulator() const { - return MultipleScattering; - } + inline MultipleScatteringSimulator* multipleScatteringSimulator() const { return MultipleScattering; } /// Return the Energy Loss engine - inline EnergyLossSimulator* energyLossSimulator() const { - return EnergyLoss; - } + inline EnergyLossSimulator* energyLossSimulator() const { return EnergyLoss; } /// Return the Muon Bremsstrahlung engine - inline MuonBremsstrahlungSimulator* muonBremsstrahlungSimulator() const { - return MuonBremsstrahlung; - } - - private: + inline MuonBremsstrahlungSimulator* muonBremsstrahlungSimulator() const { return MuonBremsstrahlung; } +private: /// The number of radiation lengths traversed - double radLengths(const TrackerLayer& layer, - ParticlePropagator& myTrack); + double radLengths(const TrackerLayer& layer, ParticlePropagator& myTrack); /// The vector normal to the surface traversed - GlobalVector normalVector(const TrackerLayer& layer, - ParticlePropagator& myTrack ) const; - - private: + GlobalVector normalVector(const TrackerLayer& layer, ParticlePropagator& myTrack) const; +private: PairProductionSimulator* PairProduction; BremsstrahlungSimulator* Bremsstrahlung; ////// Muon Brem @@ -122,7 +109,6 @@ class MaterialEffects // double myEta; bool use_hardcoded; - }; #endif diff --git a/FastSimulation/MaterialEffects/interface/MaterialEffectsSimulator.h b/FastSimulation/MaterialEffects/interface/MaterialEffectsSimulator.h index 205060d211899..c05a928f033e4 100644 --- a/FastSimulation/MaterialEffects/interface/MaterialEffectsSimulator.h +++ b/FastSimulation/MaterialEffects/interface/MaterialEffectsSimulator.h @@ -20,19 +20,14 @@ class RandomEngineAndDistribution; * * \author Stephan Wynhoff, Florian Beaudette, Patrick Janot * $Date: Last update 8-Jan-2004 - */ - -class MaterialEffectsSimulator -{ - public: + */ +class MaterialEffectsSimulator { +public: typedef std::vector::const_iterator RHEP_const_iter; // Constructor : default values are for Silicon - MaterialEffectsSimulator(double A = 28.0855, - double Z = 14.0000, - double density = 2.329, - double radLen = 9.360); + MaterialEffectsSimulator(double A = 28.0855, double Z = 14.0000, double density = 2.329, double radLen = 9.360); virtual ~MaterialEffectsSimulator(); @@ -48,44 +43,42 @@ class MaterialEffectsSimulator ///One radiation length in cm inline double radLenIncm() const { return radLen; } ///Mean excitation energy (in GeV) - inline double excitE() const { return 12.5E-9*theZ(); } + inline double excitE() const { return 12.5E-9 * theZ(); } ///Electron mass in GeV/c2 inline double eMass() const { return 0.000510998902; } /// Compute the material effect (calls the sub class) void updateState(ParticlePropagator& myTrack, double radlen, RandomEngineAndDistribution const*); - + /// Returns const iterator to the beginning of the daughters list - inline RHEP_const_iter beginDaughters() const {return _theUpdatedState.begin();} + inline RHEP_const_iter beginDaughters() const { return _theUpdatedState.begin(); } /// Returns const iterator to the end of the daughters list - inline RHEP_const_iter endDaughters() const {return _theUpdatedState.end();} + inline RHEP_const_iter endDaughters() const { return _theUpdatedState.end(); } - /// Returns the number of daughters - inline unsigned nDaughters() const {return _theUpdatedState.size();} + /// Returns the number of daughters + inline unsigned nDaughters() const { return _theUpdatedState.size(); } - /// Sets the vector normal to the surface traversed + /// Sets the vector normal to the surface traversed inline void setNormalVector(const GlobalVector& normal) { theNormalVector = normal; } - + /// A vector orthogonal to another one (because it's not in XYZTLorentzVector) - XYZVector orthogonal(const XYZVector&) const; + XYZVector orthogonal(const XYZVector&) const; /// The id of the closest charged daughter (filled for nuclear interactions only) - inline int closestDaughterId() { return theClosestChargedDaughterId; } + inline int closestDaughterId() { return theClosestChargedDaughterId; } /// Used by NuclearInteractionSimulator to save last sampled event - virtual void save() {}; - - private: + virtual void save(){}; +private: /// Overloaded in all material effects updtators virtual void compute(ParticlePropagator& Particle, RandomEngineAndDistribution const*) = 0; /// Returns the fraction of radiation lengths traversed - inline double radiationLength() const {return radLengths;} - - protected: + inline double radiationLength() const { return radLengths; } +protected: std::vector _theUpdatedState; double radLengths; @@ -99,7 +92,6 @@ class MaterialEffectsSimulator GlobalVector theNormalVector; int theClosestChargedDaughterId; - }; #endif diff --git a/FastSimulation/MaterialEffects/interface/MultipleScatteringSimulator.h b/FastSimulation/MaterialEffects/interface/MultipleScatteringSimulator.h index 2c8971968dc38..4ec48fc6d1aac 100644 --- a/FastSimulation/MaterialEffects/interface/MultipleScatteringSimulator.h +++ b/FastSimulation/MaterialEffects/interface/MultipleScatteringSimulator.h @@ -18,31 +18,26 @@ * * \author Patrick Janot * $Date: 8-Jan-2004 - */ + */ class ParticlePropagator; class RandomEngineAndDistribution; -class MultipleScatteringSimulator : public MaterialEffectsSimulator -{ - public: - +class MultipleScatteringSimulator : public MaterialEffectsSimulator { +public: /// Default Constructor MultipleScatteringSimulator(double A, double Z, double density, double radLen); /// Default Destructor - ~MultipleScatteringSimulator() override {} ; - - private: + ~MultipleScatteringSimulator() override{}; +private: /// The real dE/dx generation and particle update - void compute(ParticlePropagator &Particle, RandomEngineAndDistribution const*) override; + void compute(ParticlePropagator &Particle, RandomEngineAndDistribution const *) override; - private: - +private: /// Save (a tiny bit of) time double sqr12; - }; #endif diff --git a/FastSimulation/MaterialEffects/interface/MuonBremsstrahlungSimulator.h b/FastSimulation/MaterialEffects/interface/MuonBremsstrahlungSimulator.h index 04047e76d5b8a..cfe395608dd4d 100644 --- a/FastSimulation/MaterialEffects/interface/MuonBremsstrahlungSimulator.h +++ b/FastSimulation/MaterialEffects/interface/MuonBremsstrahlungSimulator.h @@ -17,41 +17,34 @@ * * \author Patrick Janot * $Date: 25-Dec-2003 - */ - + */ #include - -class TF1; +class TF1; class ParticlePropagator; class RandomEngineAndDistribution; -class MuonBremsstrahlungSimulator : public MaterialEffectsSimulator -{ - public: - +class MuonBremsstrahlungSimulator : public MaterialEffectsSimulator { +public: /// Constructor - MuonBremsstrahlungSimulator(double A, double Z, double density, - double radLen,double photonEnergyCut,double photonFractECut); + MuonBremsstrahlungSimulator( + double A, double Z, double density, double radLen, double photonEnergyCut, double photonFractECut); /// Default destructor ~MuonBremsstrahlungSimulator() override {} + // Returns the actual Muon brem Energy + inline const XYZTLorentzVector& deltaP_BremMuon() const { return deltaPMuon; } -// Returns the actual Muon brem Energy - inline const XYZTLorentzVector& deltaP_BremMuon() const { return deltaPMuon ; } - -// Returns the actual photon brem Energy - inline const XYZTLorentzVector& deltaP_BremPhoton() const { return brem_photon ; } + // Returns the actual photon brem Energy + inline const XYZTLorentzVector& deltaP_BremPhoton() const { return brem_photon; } +private: + TF1* f1; - private: - - TF1* f1 ; - - int npar ; + int npar; /// The minimum photon energy to be radiated, in GeV double photonEnergy; @@ -60,27 +53,24 @@ class MuonBremsstrahlungSimulator : public MaterialEffectsSimulator double photonFractE; /// The fractional photon energy cut (determined from the above two) - double xmin,xmax,rand; - double d; //distance - + double xmin, xmax, rand; + double d; //distance + /// Generate numbers according to a Poisson distribution of mean ymu. unsigned int poisson(double ymu); /// Generate Bremsstrahlung photons - void compute(ParticlePropagator &Particle, RandomEngineAndDistribution const*) override; + void compute(ParticlePropagator& Particle, RandomEngineAndDistribution const*) override; /// Compute Brem photon energy and angles, if any. - XYZTLorentzVector brem(ParticlePropagator& p, RandomEngineAndDistribution const*)const; + XYZTLorentzVector brem(ParticlePropagator& p, RandomEngineAndDistribution const*) const; /// A universal angular distribution - still from GEANT. - double gbteth(const double ener, - const double partm, - const double efrac, - RandomEngineAndDistribution const*) const; + double gbteth(const double ener, const double partm, const double efrac, RandomEngineAndDistribution const*) const; // The actual Muon Brem - XYZTLorentzVector deltaPMuon; - //The photon brem - XYZTLorentzVector brem_photon; + XYZTLorentzVector deltaPMuon; + //The photon brem + XYZTLorentzVector brem_photon; }; #endif diff --git a/FastSimulation/MaterialEffects/interface/NuclearInteractionFTFSimulator.h b/FastSimulation/MaterialEffects/interface/NuclearInteractionFTFSimulator.h index 9eb88dbbb27ef..f6c137789e6c0 100644 --- a/FastSimulation/MaterialEffects/interface/NuclearInteractionFTFSimulator.h +++ b/FastSimulation/MaterialEffects/interface/NuclearInteractionFTFSimulator.h @@ -11,7 +11,7 @@ * * \author Vladimir Ivanchenko * $Date: 20-Jan-2015 - */ + */ #include "FastSimulation/MaterialEffects/interface/MaterialEffectsSimulator.h" @@ -37,26 +37,21 @@ class G4PhysicsLogVector; static const int numHadrons = 30; static const int npoints = 21; -class NuclearInteractionFTFSimulator : public MaterialEffectsSimulator -{ +class NuclearInteractionFTFSimulator : public MaterialEffectsSimulator { public: - /// Constructor - NuclearInteractionFTFSimulator(unsigned int distAlgo, double distCut, - double elimit, double eth); + NuclearInteractionFTFSimulator(unsigned int distAlgo, double distCut, double elimit, double eth); /// Default Destructor ~NuclearInteractionFTFSimulator() override; private: - /// Generate a nuclear interaction according to the probability that it happens void compute(ParticlePropagator& Particle, RandomEngineAndDistribution const*) override; void saveDaughter(ParticlePropagator& Particle, const G4LorentzVector& lv, int pdgid); - double distanceToPrimary(const RawParticle& Particle, - const RawParticle& aDaughter) const; + double distanceToPrimary(const RawParticle& Particle, const RawParticle& aDaughter) const; static const G4ParticleDefinition* theG4Hadron[numHadrons]; static int theId[numHadrons]; @@ -64,9 +59,9 @@ class NuclearInteractionFTFSimulator : public MaterialEffectsSimulator G4TheoFSGenerator* theHadronicModel; G4FTFModel* theStringModel; - G4ExcitedStringDecay* theStringDecay; + G4ExcitedStringDecay* theStringDecay; G4LundStringFragmentation* theLund; - G4GeneratorPrecompoundInterface* theCascade; + G4GeneratorPrecompoundInterface* theCascade; G4CascadeInterface* theBertiniCascade; G4DiffuseElastic* theDiffuseElastic; diff --git a/FastSimulation/MaterialEffects/interface/NuclearInteractionSimulator.h b/FastSimulation/MaterialEffects/interface/NuclearInteractionSimulator.h index 5d64ebfb7b003..816829baa88e7 100644 --- a/FastSimulation/MaterialEffects/interface/NuclearInteractionSimulator.h +++ b/FastSimulation/MaterialEffects/interface/NuclearInteractionSimulator.h @@ -11,7 +11,7 @@ * * \author Patrick Janot * $Date: 25-Jan-2007 - */ + */ #include "FastSimulation/MaterialEffects/interface/MaterialEffectsSimulator.h" @@ -30,23 +30,21 @@ class RandomEngineAndDistribution; //class DaqMonitorBEInterface; //class MonitorElement; -class NuclearInteractionSimulator : public MaterialEffectsSimulator -{ - public: - +class NuclearInteractionSimulator : public MaterialEffectsSimulator { +public: /// Constructor NuclearInteractionSimulator(std::vector& hadronEnergies, - std::vector& hadronTypes, - std::vector& hadronNames, - std::vector& hadronMasses, - std::vector& hadronPMin, - double pionEnergy, - std::vector& lengthRatio, - std::vector< std::vector >& ratios, - std::map& idMap, - std::string inputFile, - unsigned int distAlgo, - double distCut); + std::vector& hadronTypes, + std::vector& hadronNames, + std::vector& hadronMasses, + std::vector& hadronPMin, + double pionEnergy, + std::vector& lengthRatio, + std::vector >& ratios, + std::map& idMap, + std::string inputFile, + unsigned int distAlgo, + double distCut); /// Default Destructor ~NuclearInteractionSimulator() override; @@ -57,14 +55,12 @@ class NuclearInteractionSimulator : public MaterialEffectsSimulator /// Read former nuclear interaction (from previous run) bool read(std::string inputFile); - private: - +private: /// Generate a nuclear interaction according to the probability that it happens void compute(ParticlePropagator& Particle, RandomEngineAndDistribution const*) override; /// Compute distance between secondary and primary - double distanceToPrimary(const RawParticle& Particle, - const RawParticle& aDaughter) const; + double distanceToPrimary(const RawParticle& Particle, const RawParticle& aDaughter) const; /// Return a hashed index for a given pid unsigned index(int thePid); @@ -76,20 +72,20 @@ class NuclearInteractionSimulator : public MaterialEffectsSimulator std::vector thePionPMin; double thePionEnergy; std::vector theLengthRatio; - std::vector< std::vector > theRatios; + std::vector > theRatios; TFile* theFile; - std::vector< std::vector > theTrees; - std::vector< std::vector > theBranches; - std::vector< std::vector > theNUEvents; - std::vector< std::vector > theCurrentEntry; - std::vector< std::vector > theCurrentInteraction; - std::vector< std::vector > theNumberOfEntries; - std::vector< std::vector > theNumberOfInteractions; - std::vector< std::vector > theFileNames; - std::vector< std::vector > thePionCM; - - std::map< int, int > theIDMap; + std::vector > theTrees; + std::vector > theBranches; + std::vector > theNUEvents; + std::vector > theCurrentEntry; + std::vector > theCurrentInteraction; + std::vector > theNumberOfEntries; + std::vector > theNumberOfInteractions; + std::vector > theFileNames; + std::vector > thePionCM; + + std::map theIDMap; unsigned ien4; unsigned theDistAlgo; double theDistCut; @@ -108,6 +104,5 @@ class NuclearInteractionSimulator : public MaterialEffectsSimulator // MonitorElement* hinel; // MonitorElement* hscatter; // MonitorElement* hscatter2; - }; #endif diff --git a/FastSimulation/MaterialEffects/interface/PairProductionSimulator.h b/FastSimulation/MaterialEffects/interface/PairProductionSimulator.h index 407f49cf9e0c4..c6c0a75d77726 100644 --- a/FastSimulation/MaterialEffects/interface/PairProductionSimulator.h +++ b/FastSimulation/MaterialEffects/interface/PairProductionSimulator.h @@ -16,23 +16,20 @@ * * \author Patrick Janot * $Date: 24-Dec-2003 - */ + */ class ParticlePropagator; class RandomEngineAndDistribution; -class PairProductionSimulator : public MaterialEffectsSimulator -{ - public: - +class PairProductionSimulator : public MaterialEffectsSimulator { +public: /// Constructor PairProductionSimulator(double photonEnergyCut); /// Default Destructor ~PairProductionSimulator() override {} - private: - +private: /// The minimal photon energy for possible conversion double photonEnergy; @@ -40,6 +37,6 @@ class PairProductionSimulator : public MaterialEffectsSimulator void compute(ParticlePropagator& Particle, RandomEngineAndDistribution const*) override; /// A universal angular distribution - still from GEANT. - double gbteth(double ener,double partm,double efrac, RandomEngineAndDistribution const*); + double gbteth(double ener, double partm, double efrac, RandomEngineAndDistribution const*); }; -#endif // PAIRPRODUCTIONSIMULATOR +#endif // PAIRPRODUCTIONSIMULATOR diff --git a/FastSimulation/MaterialEffects/interface/PetrukhinModel.h b/FastSimulation/MaterialEffects/interface/PetrukhinModel.h index 8a0a93b8e5251..7980db7e7bd48 100644 --- a/FastSimulation/MaterialEffects/interface/PetrukhinModel.h +++ b/FastSimulation/MaterialEffects/interface/PetrukhinModel.h @@ -1,5 +1,5 @@ ////////////////////////////////////////////////////////// -// PETRUKHINMODEL_h +// PETRUKHINMODEL_h // // Improvements: Function of Muom Brem using nuclear screening correction // Description: Muon bremsstrahlung using the Petrukhin's model in FASTSIM @@ -13,8 +13,6 @@ #include "TMath.h" #include "TF1.h" - -double PetrukhinFunc (double *x, double *p ); - +double PetrukhinFunc(double *x, double *p); #endif diff --git a/FastSimulation/MaterialEffects/src/BremsstrahlungSimulator.cc b/FastSimulation/MaterialEffects/src/BremsstrahlungSimulator.cc old mode 100755 new mode 100644 index 81e4b87d2b5d9..6a6e584b147c0 --- a/FastSimulation/MaterialEffects/src/BremsstrahlungSimulator.cc +++ b/FastSimulation/MaterialEffects/src/BremsstrahlungSimulator.cc @@ -5,135 +5,121 @@ #include -BremsstrahlungSimulator::BremsstrahlungSimulator(double photonEnergyCut, - double photonFractECut) -{ +BremsstrahlungSimulator::BremsstrahlungSimulator(double photonEnergyCut, double photonFractECut) { // Set the minimal photon energy for a Brem from e+/- photonEnergy = photonEnergyCut; photonFractE = photonFractECut; } - -void -BremsstrahlungSimulator::compute(ParticlePropagator &Particle, RandomEngineAndDistribution const* random) -{ - +void BremsstrahlungSimulator::compute(ParticlePropagator& Particle, RandomEngineAndDistribution const* random) { // Protection : Just stop the electron if more than 1 radiation lengths. - // This case corresponds to an electron entering the layer parallel to + // This case corresponds to an electron entering the layer parallel to // the layer axis - no reliable simulation can be done in that case... // 08/02/06 - pv: increase protection from 1 to 4 X0 for eta>4.8 region // if ( radLengths > 1. ) Particle.particle().setMomentum(0.,0.,0.,0.); - if ( radLengths > 4. ) Particle.particle().setMomentum(0.,0.,0.,0.); + if (radLengths > 4.) + Particle.particle().setMomentum(0., 0., 0., 0.); // Hard brem probability with a photon Energy above photonEnergy. - if (Particle.particle().e()=1. || xmin <=0. ) return; + if (Particle.particle().e() < photonEnergy) + return; + xmin = std::max(photonEnergy / Particle.particle().e(), photonFractE); + if (xmin >= 1. || xmin <= 0.) + return; - double bremProba = radLengths * ( 4./3. * std::log(1./xmin) - - 4./3. * (1.-xmin) - + 1./2. * (1.-xmin*xmin) ); + double bremProba = + radLengths * (4. / 3. * std::log(1. / xmin) - 4. / 3. * (1. - xmin) + 1. / 2. * (1. - xmin * xmin)); - // Number of photons to be radiated. unsigned int nPhotons = poisson(bremProba, random); _theUpdatedState.reserve(nPhotons); - if ( !nPhotons ) return; + if (!nPhotons) + return; //Rotate to the lab frame double chi = Particle.particle().theta(); double psi = Particle.particle().phi(); RawParticle::RotationZ rotZ(psi); RawParticle::RotationY rotY(chi); - - // Energy of these photons - for ( unsigned int i=0; i C++ former version. // Author : Patrick Janot - 25-Dec-2003 double emass = 0.0005109990615; - double xp=0; + double xp = 0; double weight = 0.; - + do { - xp = xmin * std::exp ( -std::log(xmin) * random->flatShoot() ); - weight = 1. - xp + 3./4.*xp*xp; - } while ( weight < random->flatShoot() ); - - - // Have photon energy. Now generate angles with respect to the z axis + xp = xmin * std::exp(-std::log(xmin) * random->flatShoot()); + weight = 1. - xp + 3. / 4. * xp * xp; + } while (weight < random->flatShoot()); + + // Have photon energy. Now generate angles with respect to the z axis // defined by the incoming particle's momentum. // Isotropic in phi - const double phi = random->flatShoot()*2*M_PI; + const double phi = random->flatShoot() * 2 * M_PI; // theta from universal distribution - const double theta = gbteth(pp.particle().e(),emass,xp,random)*emass/pp.particle().e(); - + const double theta = gbteth(pp.particle().e(), emass, xp, random) * emass / pp.particle().e(); + // Make momentum components double stheta = std::sin(theta); double ctheta = std::cos(theta); - double sphi = std::sin(phi); - double cphi = std::cos(phi); - - return xp * pp.particle().e() * XYZTLorentzVector(stheta*cphi,stheta*sphi,ctheta,1.); - + double sphi = std::sin(phi); + double cphi = std::cos(phi); + + return xp * pp.particle().e() * XYZTLorentzVector(stheta * cphi, stheta * sphi, ctheta, 1.); } -double -BremsstrahlungSimulator::gbteth(const double ener, - const double partm, - const double efrac, - RandomEngineAndDistribution const* random) const { +double BremsstrahlungSimulator::gbteth(const double ener, + const double partm, + const double efrac, + RandomEngineAndDistribution const* random) const { const double alfa = 0.625; - const double d = 0.13*(0.8+1.3/theZ())*(100.0+(1.0/ener))*(1.0+efrac); - const double w1 = 9.0/(9.0+d); - const double umax = ener*M_PI/partm; + const double d = 0.13 * (0.8 + 1.3 / theZ()) * (100.0 + (1.0 / ener)) * (1.0 + efrac); + const double w1 = 9.0 / (9.0 + d); + const double umax = ener * M_PI / partm; double u; - + do { - double beta = (random->flatShoot()<=w1) ? alfa : 3.0*alfa; - u = -std::log(random->flatShoot()*random->flatShoot())/beta; - } while (u>=umax); + double beta = (random->flatShoot() <= w1) ? alfa : 3.0 * alfa; + u = -std::log(random->flatShoot() * random->flatShoot()) / beta; + } while (u >= umax); return u; } - -unsigned int -BremsstrahlungSimulator::poisson(double ymu, RandomEngineAndDistribution const* random) { - +unsigned int BremsstrahlungSimulator::poisson(double ymu, RandomEngineAndDistribution const* random) { unsigned int n = 0; double prob = std::exp(-ymu); double proba = prob; double x = random->flatShoot(); - - while ( proba <= x ) { + + while (proba <= x) { prob *= ymu / double(++n); proba += prob; } - - return n; - -} + return n; +} diff --git a/FastSimulation/MaterialEffects/src/EnergyLossSimulator.cc b/FastSimulation/MaterialEffects/src/EnergyLossSimulator.cc old mode 100755 new mode 100644 index 21e196d5e4949..448455e9517fe --- a/FastSimulation/MaterialEffects/src/EnergyLossSimulator.cc +++ b/FastSimulation/MaterialEffects/src/EnergyLossSimulator.cc @@ -4,54 +4,44 @@ #include -EnergyLossSimulator::EnergyLossSimulator(double A, double Z, double density, double radLen) : - MaterialEffectsSimulator(A,Z,density,radLen) -{ +EnergyLossSimulator::EnergyLossSimulator(double A, double Z, double density, double radLen) + : MaterialEffectsSimulator(A, Z, density, radLen) { theGenerator = new LandauFluctuationGenerator(); } -EnergyLossSimulator::~EnergyLossSimulator() { - - delete theGenerator; - -} - -void -EnergyLossSimulator::compute(ParticlePropagator &Particle, RandomEngineAndDistribution const* random) -{ +EnergyLossSimulator::~EnergyLossSimulator() { delete theGenerator; } +void EnergyLossSimulator::compute(ParticlePropagator& Particle, RandomEngineAndDistribution const* random) { // FamosHistos* myHistos = FamosHistos::instance(); // double gamma_e = 0.577215664901532861; // Euler constant - + // The thickness in cm double thick = radLengths * radLenIncm(); - + // This is a simple version (a la PDG) of a dE/dx generator. // It replaces the buggy GEANT3 -> C++ former version. // Author : Patrick Janot - 8-Jan-2004 - double p2 = Particle.particle().Vect().Mag2(); + double p2 = Particle.particle().Vect().Mag2(); double verySmallP2 = 0.0001; - if (p2<=verySmallP2) { - deltaP.SetXYZT(0.,0.,0.,0.); + if (p2 <= verySmallP2) { + deltaP.SetXYZT(0., 0., 0., 0.); return; } - double m2 = Particle.particle().mass() * Particle.particle().mass(); - double e2 = p2+m2; + double m2 = Particle.particle().mass() * Particle.particle().mass(); + double e2 = p2 + m2; + + double beta2 = p2 / e2; + double gama2 = e2 / m2; - double beta2 = p2/e2; - double gama2 = e2/m2; - double charge2 = Particle.particle().charge() * Particle.particle().charge(); - + // Energy loss spread in GeV - double eSpread = 0.1536E-3*charge2*(theZ()/theA())*rho()*thick/beta2; - + double eSpread = 0.1536E-3 * charge2 * (theZ() / theA()) * rho() * thick / beta2; + // Most probable energy loss (from the integrated Bethe-Bloch equation) - mostProbableLoss = eSpread * ( log ( 2.*eMass()*beta2*gama2*eSpread - / (excitE()*excitE()) ) - - beta2 + 0.200 ); + mostProbableLoss = eSpread * (log(2. * eMass() * beta2 * gama2 * eSpread / (excitE() * excitE())) - beta2 + 0.200); // This one can be needed on output (but is not used internally) // meanEnergyLoss = 2.*eSpread * ( log ( 2.*eMass()*beta2*gama2 /excitE() ) - beta2 ); @@ -60,17 +50,16 @@ EnergyLossSimulator::compute(ParticlePropagator &Particle, RandomEngineAndDistri double dedx = mostProbableLoss + eSpread * theGenerator->landau(random); // Compute the new energy and momentum - double aBitAboveMass = Particle.particle().mass()*1.0001; - double newE = std::max(aBitAboveMass,Particle.particle().e()-dedx); + double aBitAboveMass = Particle.particle().mass() * 1.0001; + double newE = std::max(aBitAboveMass, Particle.particle().e() - dedx); // double newE = std::max(Particle.particle().mass(),Particle.particle().e()-dedx); - double fac = std::sqrt((newE*newE-m2)/p2); + double fac = std::sqrt((newE * newE - m2) / p2); - // Update the momentum - deltaP.SetXYZT(Particle.particle().Px()*(1.-fac),Particle.particle().Py()*(1.-fac), - Particle.particle().Pz()*(1.-fac),Particle.particle().E()-newE); - Particle.particle().setMomentum(Particle.particle().Px()*fac,Particle.particle().Py()*fac, - Particle.particle().Pz()*fac,newE); - + deltaP.SetXYZT(Particle.particle().Px() * (1. - fac), + Particle.particle().Py() * (1. - fac), + Particle.particle().Pz() * (1. - fac), + Particle.particle().E() - newE); + Particle.particle().setMomentum( + Particle.particle().Px() * fac, Particle.particle().Py() * fac, Particle.particle().Pz() * fac, newE); } - diff --git a/FastSimulation/MaterialEffects/src/MaterialEffects.cc b/FastSimulation/MaterialEffects/src/MaterialEffects.cc old mode 100755 new mode 100644 index a338499eea0b2..c3866c5a39c94 --- a/FastSimulation/MaterialEffects/src/MaterialEffects.cc +++ b/FastSimulation/MaterialEffects/src/MaterialEffects.cc @@ -24,420 +24,371 @@ #include MaterialEffects::MaterialEffects(const edm::ParameterSet& matEff) - : PairProduction(nullptr), Bremsstrahlung(nullptr),MuonBremsstrahlung(nullptr), - MultipleScattering(nullptr), EnergyLoss(nullptr), - NuclearInteraction(nullptr), - pTmin(999.), use_hardcoded(true) -{ + : PairProduction(nullptr), + Bremsstrahlung(nullptr), + MuonBremsstrahlung(nullptr), + MultipleScattering(nullptr), + EnergyLoss(nullptr), + NuclearInteraction(nullptr), + pTmin(999.), + use_hardcoded(true) { // Set the minimal photon energy for a Brem from e+/- - use_hardcoded = matEff.getParameter("use_hardcoded_geometry"); + use_hardcoded = matEff.getParameter("use_hardcoded_geometry"); - bool doPairProduction = matEff.getParameter("PairProduction"); - bool doBremsstrahlung = matEff.getParameter("Bremsstrahlung"); - bool doEnergyLoss = matEff.getParameter("EnergyLoss"); + bool doPairProduction = matEff.getParameter("PairProduction"); + bool doBremsstrahlung = matEff.getParameter("Bremsstrahlung"); + bool doEnergyLoss = matEff.getParameter("EnergyLoss"); bool doMultipleScattering = matEff.getParameter("MultipleScattering"); bool doNuclearInteraction = matEff.getParameter("NuclearInteraction"); - bool doG4NuclInteraction = matEff.getParameter("G4NuclearInteraction"); + bool doG4NuclInteraction = matEff.getParameter("G4NuclearInteraction"); bool doMuonBremsstrahlung = matEff.getParameter("MuonBremsstrahlung"); double A = matEff.getParameter("A"); double Z = matEff.getParameter("Z"); double density = matEff.getParameter("Density"); double radLen = matEff.getParameter("RadiationLength"); - - // Set the minimal pT before giving up the dE/dx treatment - if ( doPairProduction ) { + // Set the minimal pT before giving up the dE/dx treatment + if (doPairProduction) { double photonEnergy = matEff.getParameter("photonEnergy"); PairProduction = new PairProductionSimulator(photonEnergy); } - if ( doBremsstrahlung ) { - + if (doBremsstrahlung) { double bremEnergy = matEff.getParameter("bremEnergy"); double bremEnergyFraction = matEff.getParameter("bremEnergyFraction"); - Bremsstrahlung = new BremsstrahlungSimulator(bremEnergy, - bremEnergyFraction); + Bremsstrahlung = new BremsstrahlungSimulator(bremEnergy, bremEnergyFraction); } //muon Brem+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - if ( doMuonBremsstrahlung ) { - + if (doMuonBremsstrahlung) { double bremEnergy = matEff.getParameter("bremEnergy"); double bremEnergyFraction = matEff.getParameter("bremEnergyFraction"); - MuonBremsstrahlung = new MuonBremsstrahlungSimulator(A,Z,density,radLen,bremEnergy, - bremEnergyFraction); - + MuonBremsstrahlung = new MuonBremsstrahlungSimulator(A, Z, density, radLen, bremEnergy, bremEnergyFraction); } //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - if ( doEnergyLoss ) { - + if (doEnergyLoss) { pTmin = matEff.getParameter("pTmin"); - EnergyLoss = new EnergyLossSimulator(A,Z,density,radLen); - + EnergyLoss = new EnergyLossSimulator(A, Z, density, radLen); } - if ( doMultipleScattering ) { - - MultipleScattering = new MultipleScatteringSimulator(A,Z,density,radLen); - + if (doMultipleScattering) { + MultipleScattering = new MultipleScatteringSimulator(A, Z, density, radLen); } - - if ( doNuclearInteraction ) { - + if (doNuclearInteraction) { // The energies simulated - std::vector hadronEnergies - = matEff.getUntrackedParameter >("hadronEnergies"); + std::vector hadronEnergies = matEff.getUntrackedParameter >("hadronEnergies"); // The particle types simulated - std::vector hadronTypes - = matEff.getUntrackedParameter >("hadronTypes"); + std::vector hadronTypes = matEff.getUntrackedParameter >("hadronTypes"); // The corresponding particle names - std::vector hadronNames - = matEff.getUntrackedParameter >("hadronNames"); + std::vector hadronNames = matEff.getUntrackedParameter >("hadronNames"); // The corresponding particle masses - std::vector hadronMasses - = matEff.getUntrackedParameter >("hadronMasses"); + std::vector hadronMasses = matEff.getUntrackedParameter >("hadronMasses"); // The smallest momentum for inelastic interactions - std::vector hadronPMin - = matEff.getUntrackedParameter >("hadronMinP"); + std::vector hadronPMin = matEff.getUntrackedParameter >("hadronMinP"); // The interaction length / radiation length ratio for each particle type - std::vector lengthRatio - = matEff.getParameter >("lengthRatio"); + std::vector lengthRatio = matEff.getParameter >("lengthRatio"); // std::map lengthRatio; // for ( unsigned i=0; i("fudgeFactor"); // The evolution of the interaction lengths with energy - std::vector theRatios - = matEff.getUntrackedParameter >("ratios"); + std::vector theRatios = matEff.getUntrackedParameter >("ratios"); //std::map > ratios; - //for ( unsigned i=0; i > ratios; + std::vector > ratios; ratios.resize(hadronTypes.size()); - for ( unsigned i=0; i("pionEnergy"); + double pionEnergy = matEff.getParameter("pionEnergy"); // The algorithm to compute the distance between primary and secondaries // when a nuclear interaction occurs - unsigned distAlgo - = matEff.getParameter("distAlgo"); - double distCut - = matEff.getParameter("distCut"); + unsigned distAlgo = matEff.getParameter("distAlgo"); + double distCut = matEff.getParameter("distCut"); // The file to read the starting interaction in each files // (random reproducibility in case of a crash) - std::string inputFile - = matEff.getUntrackedParameter("inputFile"); + std::string inputFile = matEff.getUntrackedParameter("inputFile"); // Build the ID map (i.e., what is to be considered as a proton, etc...) - std::map idMap; + std::map idMap; // Protons - std::vector idProtons - = matEff.getUntrackedParameter >("protons"); - for ( unsigned i=0; i idProtons = matEff.getUntrackedParameter >("protons"); + for (unsigned i = 0; i < idProtons.size(); ++i) idMap[idProtons[i]] = 2212; // Anti-Protons - std::vector idAntiProtons - = matEff.getUntrackedParameter >("antiprotons"); - for ( unsigned i=0; i idAntiProtons = matEff.getUntrackedParameter >("antiprotons"); + for (unsigned i = 0; i < idAntiProtons.size(); ++i) idMap[idAntiProtons[i]] = -2212; // Neutrons - std::vector idNeutrons - = matEff.getUntrackedParameter >("neutrons"); - for ( unsigned i=0; i idNeutrons = matEff.getUntrackedParameter >("neutrons"); + for (unsigned i = 0; i < idNeutrons.size(); ++i) idMap[idNeutrons[i]] = 2112; // Anti-Neutrons - std::vector idAntiNeutrons - = matEff.getUntrackedParameter >("antineutrons"); - for ( unsigned i=0; i idAntiNeutrons = matEff.getUntrackedParameter >("antineutrons"); + for (unsigned i = 0; i < idAntiNeutrons.size(); ++i) idMap[idAntiNeutrons[i]] = -2112; // K0L's - std::vector idK0Ls - = matEff.getUntrackedParameter >("K0Ls"); - for ( unsigned i=0; i idK0Ls = matEff.getUntrackedParameter >("K0Ls"); + for (unsigned i = 0; i < idK0Ls.size(); ++i) idMap[idK0Ls[i]] = 130; // K+'s - std::vector idKplusses - = matEff.getUntrackedParameter >("Kplusses"); - for ( unsigned i=0; i idKplusses = matEff.getUntrackedParameter >("Kplusses"); + for (unsigned i = 0; i < idKplusses.size(); ++i) idMap[idKplusses[i]] = 321; // K-'s - std::vector idKminusses - = matEff.getUntrackedParameter >("Kminusses"); - for ( unsigned i=0; i idKminusses = matEff.getUntrackedParameter >("Kminusses"); + for (unsigned i = 0; i < idKminusses.size(); ++i) idMap[idKminusses[i]] = -321; // pi+'s - std::vector idPiplusses - = matEff.getUntrackedParameter >("Piplusses"); - for ( unsigned i=0; i idPiplusses = matEff.getUntrackedParameter >("Piplusses"); + for (unsigned i = 0; i < idPiplusses.size(); ++i) idMap[idPiplusses[i]] = 211; // pi-'s - std::vector idPiminusses - = matEff.getUntrackedParameter >("Piminusses"); - for ( unsigned i=0; i idPiminusses = matEff.getUntrackedParameter >("Piminusses"); + for (unsigned i = 0; i < idPiminusses.size(); ++i) idMap[idPiminusses[i]] = -211; // Construction - if ( doG4NuclInteraction ) { - double elimit = matEff.getParameter("EkinBertiniGeV")*CLHEP::GeV; - double eth = matEff.getParameter("EkinLimitGeV")*CLHEP::GeV; - NuclearInteraction = - new NuclearInteractionFTFSimulator(distAlgo, distCut, elimit, eth); + if (doG4NuclInteraction) { + double elimit = matEff.getParameter("EkinBertiniGeV") * CLHEP::GeV; + double eth = matEff.getParameter("EkinLimitGeV") * CLHEP::GeV; + NuclearInteraction = new NuclearInteractionFTFSimulator(distAlgo, distCut, elimit, eth); } else { - NuclearInteraction = - new NuclearInteractionSimulator(hadronEnergies, hadronTypes, hadronNames, - hadronMasses, hadronPMin, pionEnergy, - lengthRatio, ratios, idMap, - inputFile, distAlgo, distCut); + NuclearInteraction = new NuclearInteractionSimulator(hadronEnergies, + hadronTypes, + hadronNames, + hadronMasses, + hadronPMin, + pionEnergy, + lengthRatio, + ratios, + idMap, + inputFile, + distAlgo, + distCut); } } } MaterialEffects::~MaterialEffects() { - - if ( PairProduction ) delete PairProduction; - if ( Bremsstrahlung ) delete Bremsstrahlung; - if ( EnergyLoss ) delete EnergyLoss; - if ( MultipleScattering ) delete MultipleScattering; - if ( NuclearInteraction ) delete NuclearInteraction; + if (PairProduction) + delete PairProduction; + if (Bremsstrahlung) + delete Bremsstrahlung; + if (EnergyLoss) + delete EnergyLoss; + if (MultipleScattering) + delete MultipleScattering; + if (NuclearInteraction) + delete NuclearInteraction; //Muon Brem - if ( MuonBremsstrahlung ) delete MuonBremsstrahlung; + if (MuonBremsstrahlung) + delete MuonBremsstrahlung; } -void MaterialEffects::interact(FSimEvent& mySimEvent, - const TrackerLayer& layer, - ParticlePropagator& myTrack, - unsigned itrack, +void MaterialEffects::interact(FSimEvent& mySimEvent, + const TrackerLayer& layer, + ParticlePropagator& myTrack, + unsigned itrack, RandomEngineAndDistribution const* random) { - MaterialEffectsSimulator::RHEP_const_iter DaughterIter; double radlen; theEnergyLoss = 0; - theNormalVector = normalVector(layer,myTrack); - radlen = radLengths(layer,myTrack); + theNormalVector = normalVector(layer, myTrack); + radlen = radLengths(layer, myTrack); //std::cout << "### MaterialEffects: for Track= " << itrack << " in layer #" // << layer.layerNumber() << std::endl; //std::cout << myTrack << std::endl; -//------------------- -// Photon Conversion -//------------------- + //------------------- + // Photon Conversion + //------------------- - if ( PairProduction && myTrack.particle().pid()==22 ) { - + if (PairProduction && myTrack.particle().pid() == 22) { // PairProduction->updateState(myTrack, radlen, random); - if ( PairProduction->nDaughters() ) { + if (PairProduction->nDaughters()) { //add a vertex to the mother particle - int ivertex = mySimEvent.addSimVertex(myTrack.particle().vertex(),itrack, - FSimVertexType::PAIR_VERTEX); - + int ivertex = mySimEvent.addSimVertex(myTrack.particle().vertex(), itrack, FSimVertexType::PAIR_VERTEX); + // Check if it is a valid vertex first: - if (ivertex>=0) { - // This was a photon that converted - for ( DaughterIter = PairProduction->beginDaughters(); - DaughterIter != PairProduction->endDaughters(); - ++DaughterIter) { - - mySimEvent.addSimTrack(&(*DaughterIter), ivertex); - - } - // The photon converted. Return. - return; - } - else { - edm::LogWarning("MaterialEffects") << " WARNING: A non valid vertex was found in photon conv. -> " << ivertex << std::endl; + if (ivertex >= 0) { + // This was a photon that converted + for (DaughterIter = PairProduction->beginDaughters(); DaughterIter != PairProduction->endDaughters(); + ++DaughterIter) { + mySimEvent.addSimTrack(&(*DaughterIter), ivertex); + } + // The photon converted. Return. + return; + } else { + edm::LogWarning("MaterialEffects") + << " WARNING: A non valid vertex was found in photon conv. -> " << ivertex << std::endl; } - } - } - if ( myTrack.particle().pid() == 22 ) return; + if (myTrack.particle().pid() == 22) + return; -//------------------------ -// Nuclear interactions -//------------------------ - - if ( NuclearInteraction && abs(myTrack.particle().pid()) > 100 - && abs(myTrack.particle().pid()) < 1000000) { + //------------------------ + // Nuclear interactions + //------------------------ + if (NuclearInteraction && abs(myTrack.particle().pid()) > 100 && abs(myTrack.particle().pid()) < 1000000) { // Simulate a nuclear interaction double factor = 1.0; - if(use_hardcoded){ - if (layer.layerNumber() >= 19 && layer.layerNumber() <= 27 ) - factor = theTECFudgeFactor; + if (use_hardcoded) { + if (layer.layerNumber() >= 19 && layer.layerNumber() <= 27) + factor = theTECFudgeFactor; } - NuclearInteraction->updateState(myTrack, radlen*factor, random); + NuclearInteraction->updateState(myTrack, radlen * factor, random); - //std::cout << "MaterialEffects: nDaughters= " + //std::cout << "MaterialEffects: nDaughters= " // << NuclearInteraction->nDaughters() << std::endl; - if ( NuclearInteraction->nDaughters() ) { - + if (NuclearInteraction->nDaughters()) { //add a end vertex to the mother particle - int ivertex = mySimEvent.addSimVertex(myTrack.particle().vertex(),itrack, - FSimVertexType::NUCL_VERTEX); - //std::cout << "ivertex= " << ivertex << " nDaughters= " + int ivertex = mySimEvent.addSimVertex(myTrack.particle().vertex(), itrack, FSimVertexType::NUCL_VERTEX); + //std::cout << "ivertex= " << ivertex << " nDaughters= " // << NuclearInteraction->nDaughters() << std::endl; // Check if it is a valid vertex first: - if (ivertex>=0) { - // This was a hadron that interacted inelastically - int idaugh = 0; - for ( DaughterIter = NuclearInteraction->beginDaughters(); - DaughterIter != NuclearInteraction->endDaughters(); - ++DaughterIter) { - - // The daughter in the event - int daughId = mySimEvent.addSimTrack(&(*DaughterIter), ivertex); - - // Store the closest daughter in the mother info (for later tracking purposes) - if ( NuclearInteraction->closestDaughterId() == idaugh ) { - if ( mySimEvent.track(itrack).vertex().position().Pt() < 4.0 ) - mySimEvent.track(itrack).setClosestDaughterId(daughId); - } - ++idaugh; - } - // The hadron is destroyed. Return. - return; + if (ivertex >= 0) { + // This was a hadron that interacted inelastically + int idaugh = 0; + for (DaughterIter = NuclearInteraction->beginDaughters(); DaughterIter != NuclearInteraction->endDaughters(); + ++DaughterIter) { + // The daughter in the event + int daughId = mySimEvent.addSimTrack(&(*DaughterIter), ivertex); + + // Store the closest daughter in the mother info (for later tracking purposes) + if (NuclearInteraction->closestDaughterId() == idaugh) { + if (mySimEvent.track(itrack).vertex().position().Pt() < 4.0) + mySimEvent.track(itrack).setClosestDaughterId(daughId); + } + ++idaugh; + } + // The hadron is destroyed. Return. + return; + } else { + edm::LogWarning("MaterialEffects") + << " WARNING: A non valid vertex was found in nucl. int. -> " << ivertex << std::endl; } - else { - edm::LogWarning("MaterialEffects") << " WARNING: A non valid vertex was found in nucl. int. -> " << ivertex << std::endl; - } - } - } - if ( myTrack.particle().charge() == 0 ) return; + if (myTrack.particle().charge() == 0) + return; - if ( !MuonBremsstrahlung && !Bremsstrahlung && !EnergyLoss && !MultipleScattering ) return; + if (!MuonBremsstrahlung && !Bremsstrahlung && !EnergyLoss && !MultipleScattering) + return; -//---------------- -// Bremsstrahlung -//---------------- + //---------------- + // Bremsstrahlung + //---------------- - if ( Bremsstrahlung && abs(myTrack.particle().pid())==11 ) { - - Bremsstrahlung->updateState(myTrack,radlen, random); + if (Bremsstrahlung && abs(myTrack.particle().pid()) == 11) { + Bremsstrahlung->updateState(myTrack, radlen, random); - if ( Bremsstrahlung->nDaughters() ) { - - // Add a vertex, but do not attach it to the electron, because it + if (Bremsstrahlung->nDaughters()) { + // Add a vertex, but do not attach it to the electron, because it // continues its way... - int ivertex = mySimEvent.addSimVertex(myTrack.particle().vertex(),itrack, - FSimVertexType::BREM_VERTEX); + int ivertex = mySimEvent.addSimVertex(myTrack.particle().vertex(), itrack, FSimVertexType::BREM_VERTEX); // Check if it is a valid vertex first: - if (ivertex>=0) { - for ( DaughterIter = Bremsstrahlung->beginDaughters(); - DaughterIter != Bremsstrahlung->endDaughters(); - ++DaughterIter) { - mySimEvent.addSimTrack(&(*DaughterIter), ivertex); - } - } - else { - edm::LogWarning("MaterialEffects") << " WARNING: A non valid vertex was found in brem -> " << ivertex << std::endl; + if (ivertex >= 0) { + for (DaughterIter = Bremsstrahlung->beginDaughters(); DaughterIter != Bremsstrahlung->endDaughters(); + ++DaughterIter) { + mySimEvent.addSimTrack(&(*DaughterIter), ivertex); + } + } else { + edm::LogWarning("MaterialEffects") + << " WARNING: A non valid vertex was found in brem -> " << ivertex << std::endl; } - } - - } + } -//--------------------------- -// Muon_Bremsstrahlung -//-------------------------- + //--------------------------- + // Muon_Bremsstrahlung + //-------------------------- - if ( MuonBremsstrahlung && abs(myTrack.particle().pid())==13 ) { - + if (MuonBremsstrahlung && abs(myTrack.particle().pid()) == 13) { MuonBremsstrahlung->updateState(myTrack, radlen, random); - if ( MuonBremsstrahlung->nDaughters() ) { - - // Add a vertex, but do not attach it to the muon, because it + if (MuonBremsstrahlung->nDaughters()) { + // Add a vertex, but do not attach it to the muon, because it // continues its way... - int ivertex = mySimEvent.addSimVertex(myTrack.particle().vertex(),itrack, - FSimVertexType::BREM_VERTEX); - - // Check if it is a valid vertex first: - if (ivertex>=0) { - for ( DaughterIter = MuonBremsstrahlung->beginDaughters(); - DaughterIter != MuonBremsstrahlung->endDaughters(); - ++DaughterIter) { - mySimEvent.addSimTrack(&(*DaughterIter), ivertex); - } - } - else { - edm::LogWarning("MaterialEffects") << " WARNING: A non valid vertex was found in muon brem -> " << ivertex << std::endl; - } + int ivertex = mySimEvent.addSimVertex(myTrack.particle().vertex(), itrack, FSimVertexType::BREM_VERTEX); + // Check if it is a valid vertex first: + if (ivertex >= 0) { + for (DaughterIter = MuonBremsstrahlung->beginDaughters(); DaughterIter != MuonBremsstrahlung->endDaughters(); + ++DaughterIter) { + mySimEvent.addSimTrack(&(*DaughterIter), ivertex); + } + } else { + edm::LogWarning("MaterialEffects") + << " WARNING: A non valid vertex was found in muon brem -> " << ivertex << std::endl; + } } - } -////-------------- -//// Energy loss -///--------------- + ////-------------- + //// Energy loss + ///--------------- - if ( EnergyLoss ) - { + if (EnergyLoss) { theEnergyLoss = myTrack.particle().E(); EnergyLoss->updateState(myTrack, radlen, random); theEnergyLoss -= myTrack.particle().E(); } - -////---------------------- -//// Multiple scattering -///----------------------- + ////---------------------- + //// Multiple scattering + ///----------------------- - if ( MultipleScattering && myTrack.particle().Pt() > pTmin ) { + if (MultipleScattering && myTrack.particle().Pt() > pTmin) { // MultipleScattering->setNormalVector(normalVector(layer,myTrack)); MultipleScattering->setNormalVector(theNormalVector); - MultipleScattering->updateState(myTrack,radlen, random); + MultipleScattering->updateState(myTrack, radlen, random); } - } -double -MaterialEffects::radLengths(const TrackerLayer& layer, - ParticlePropagator& myTrack) { - +double MaterialEffects::radLengths(const TrackerLayer& layer, ParticlePropagator& myTrack) { // Thickness of layer theThickness = layer.surface().mediumProperties().radLen(); - GlobalVector P(myTrack.particle().Px(),myTrack.particle().Py(),myTrack.particle().Pz()); - + GlobalVector P(myTrack.particle().Px(), myTrack.particle().Py(), myTrack.particle().Pz()); + // Effective length of track inside layer (considering crossing angle) // double radlen = theThickness / fabs(P.dot(theNormalVector)/(P.mag()*theNormalVector.mag())); double radlen = theThickness / fabs(P.dot(theNormalVector)) * P.mag(); - // This is a series of fudge factors (from the geometry description), + // This is a series of fudge factors (from the geometry description), // to describe the layer inhomogeneities (services, cables, supports...) double rad = myTrack.particle().R(); double zed = fabs(myTrack.particle().Z()); @@ -445,38 +396,30 @@ MaterialEffects::radLengths(const TrackerLayer& layer, double factor = 1; // Are there fudge factors for this layer - if ( layer.fudgeNumber() ) + if (layer.fudgeNumber()) // If yes, loop on them - for ( unsigned int iLayer=0; iLayer < layer.fudgeNumber(); ++iLayer ) { - + for (unsigned int iLayer = 0; iLayer < layer.fudgeNumber(); ++iLayer) { // Apply to R if forward layer, to Z if barrel layer - if ( ( layer.forward() && layer.fudgeMin(iLayer) < rad && rad < layer.fudgeMax(iLayer) ) || - ( !layer.forward() && layer.fudgeMin(iLayer) < zed && zed < layer.fudgeMax(iLayer) ) ) { - factor = layer.fudgeFactor(iLayer); - break; + if ((layer.forward() && layer.fudgeMin(iLayer) < rad && rad < layer.fudgeMax(iLayer)) || + (!layer.forward() && layer.fudgeMin(iLayer) < zed && zed < layer.fudgeMax(iLayer))) { + factor = layer.fudgeFactor(iLayer); + break; } - - } + } theThickness *= factor; return radlen * factor; - } -GlobalVector -MaterialEffects::normalVector(const TrackerLayer& layer, - ParticlePropagator& myTrack ) const { - return layer.forward() ? - layer.disk()->normalVector() : - GlobalVector(myTrack.particle().X(),myTrack.particle().Y(),0.)/myTrack.particle().R(); +GlobalVector MaterialEffects::normalVector(const TrackerLayer& layer, ParticlePropagator& myTrack) const { + return layer.forward() ? layer.disk()->normalVector() + : GlobalVector(myTrack.particle().X(), myTrack.particle().Y(), 0.) / myTrack.particle().R(); } -void -MaterialEffects::save() { - +void MaterialEffects::save() { // Save current nuclear interactions in the event libraries. - if ( NuclearInteraction ) NuclearInteraction->save(); - + if (NuclearInteraction) + NuclearInteraction->save(); } diff --git a/FastSimulation/MaterialEffects/src/MaterialEffectsSimulator.cc b/FastSimulation/MaterialEffects/src/MaterialEffectsSimulator.cc index f5f6b09e956b4..ccbc5315cb27d 100644 --- a/FastSimulation/MaterialEffects/src/MaterialEffectsSimulator.cc +++ b/FastSimulation/MaterialEffects/src/MaterialEffectsSimulator.cc @@ -6,11 +6,9 @@ using std::list; using std::pair; -MaterialEffectsSimulator:: MaterialEffectsSimulator(double A, double Z, - double density, double radLen) : - A(A), Z(Z), density(density), radLen(radLen) -{ - _theUpdatedState.clear(); +MaterialEffectsSimulator::MaterialEffectsSimulator(double A, double Z, double density, double radLen) + : A(A), Z(Z), density(density), radLen(radLen) { + _theUpdatedState.clear(); } MaterialEffectsSimulator::~MaterialEffectsSimulator() { @@ -18,34 +16,24 @@ MaterialEffectsSimulator::~MaterialEffectsSimulator() { _theUpdatedState.clear(); } -void MaterialEffectsSimulator::updateState(ParticlePropagator & Particle, - double radlen, - RandomEngineAndDistribution const* random) -{ - +void MaterialEffectsSimulator::updateState(ParticlePropagator& Particle, + double radlen, + RandomEngineAndDistribution const* random) { _theUpdatedState.clear(); theClosestChargedDaughterId = -1; radLengths = radlen; - if ( radLengths > 0. ) compute(Particle, random); - + if (radLengths > 0.) + compute(Particle, random); } -XYZVector -MaterialEffectsSimulator::orthogonal(const XYZVector& aVector) const { - +XYZVector MaterialEffectsSimulator::orthogonal(const XYZVector& aVector) const { double x = fabs(aVector.X()); double y = fabs(aVector.Y()); double z = fabs(aVector.Z()); - if ( x < y ) - return x < z ? - XYZVector(0.,aVector.Z(),-aVector.Y()) : - XYZVector(aVector.Y(),-aVector.X(),0.); + if (x < y) + return x < z ? XYZVector(0., aVector.Z(), -aVector.Y()) : XYZVector(aVector.Y(), -aVector.X(), 0.); else - return y < z ? - XYZVector(-aVector.Z(),0.,aVector.X()) : - XYZVector(aVector.Y(),-aVector.X(),0.); - + return y < z ? XYZVector(-aVector.Z(), 0., aVector.X()) : XYZVector(aVector.Y(), -aVector.X(), 0.); } - diff --git a/FastSimulation/MaterialEffects/src/MultipleScatteringSimulator.cc b/FastSimulation/MaterialEffects/src/MultipleScatteringSimulator.cc old mode 100755 new mode 100644 index 09c8332909777..15d7d6c1ce0ae --- a/FastSimulation/MaterialEffects/src/MultipleScatteringSimulator.cc +++ b/FastSimulation/MaterialEffects/src/MultipleScatteringSimulator.cc @@ -3,56 +3,47 @@ #include -MultipleScatteringSimulator::MultipleScatteringSimulator( - double A, double Z, double density, double radLen) : - MaterialEffectsSimulator(A,Z,density,radLen) -{ +MultipleScatteringSimulator::MultipleScatteringSimulator(double A, double Z, double density, double radLen) + : MaterialEffectsSimulator(A, Z, density, radLen) { sqr12 = std::sqrt(12.); } -void MultipleScatteringSimulator::compute(ParticlePropagator &Particle, RandomEngineAndDistribution const* random) -{ - +void MultipleScatteringSimulator::compute(ParticlePropagator& Particle, RandomEngineAndDistribution const* random) { double p2 = Particle.particle().Vect().Mag2(); - double m2 = Particle.particle().mass()*Particle.particle().mass(); - double e = std::sqrt(p2+m2); + double m2 = Particle.particle().mass() * Particle.particle().mass(); + double e = std::sqrt(p2 + m2); - double pbeta = p2/e; // This is p*beta + double pbeta = p2 / e; // This is p*beta // Average multiple scattering angle from Moliere radius // The sqrt(2) factor is because of the *space* angle - double theta0 = 0.0136 / pbeta * Particle.particle().charge() - * std::sqrt(2.*radLengths) - * (1. + 0.038*std::log(radLengths)); + double theta0 = + 0.0136 / pbeta * Particle.particle().charge() * std::sqrt(2. * radLengths) * (1. + 0.038 * std::log(radLengths)); // Generate multiple scattering space angle perpendicular to the particle motion - double theta = random->gaussShoot(0.,theta0); + double theta = random->gaussShoot(0., theta0); // Plus a random rotation angle around the particle motion double phi = 2. * 3.14159265358979323 * random->flatShoot(); // The two rotations - RawParticle::Rotation rotation1(orthogonal(Particle.particle().Vect()),theta); - RawParticle::Rotation rotation2(Particle.particle().Vect(),phi); + RawParticle::Rotation rotation1(orthogonal(Particle.particle().Vect()), theta); + RawParticle::Rotation rotation2(Particle.particle().Vect(), phi); // Rotate! - Particle.particle().rotate(rotation1); + Particle.particle().rotate(rotation1); Particle.particle().rotate(rotation2); // Generate mutiple scattering displacements in cm (assuming the detectors // are silicon only to determine the thickness) in the directions orthogonal // to the vector normal to the surface - double xp = (cos(phi)*theta/2. + random->gaussShoot(0.,theta0)/sqr12) - * radLengths * radLenIncm(); - double yp = (sin(phi)*theta/2. + random->gaussShoot(0.,theta0)/sqr12) - * radLengths * radLenIncm(); + double xp = (cos(phi) * theta / 2. + random->gaussShoot(0., theta0) / sqr12) * radLengths * radLenIncm(); + double yp = (sin(phi) * theta / 2. + random->gaussShoot(0., theta0) / sqr12) * radLengths * radLenIncm(); // Determine a unitary vector tangent to the surface // This tangent vector is unitary because "normal" is // either (0,0,1) in the Endcap or (x,y,0) in the Barrel ! - XYZVector normal(theNormalVector.x(),theNormalVector.y(),theNormalVector.z()); - XYZVector tangent = orthogonal(normal); - // The total displacement - XYZVector delta = xp*tangent + yp*normal.Cross(tangent); + XYZVector normal(theNormalVector.x(), theNormalVector.y(), theNormalVector.z()); + XYZVector tangent = orthogonal(normal); + // The total displacement + XYZVector delta = xp * tangent + yp * normal.Cross(tangent); // Translate! Particle.particle().translate(delta); - } - diff --git a/FastSimulation/MaterialEffects/src/MuonBremsstrahlungSimulator.cc b/FastSimulation/MaterialEffects/src/MuonBremsstrahlungSimulator.cc index d267bd855f07c..1c0ceaab2651d 100644 --- a/FastSimulation/MaterialEffects/src/MuonBremsstrahlungSimulator.cc +++ b/FastSimulation/MaterialEffects/src/MuonBremsstrahlungSimulator.cc @@ -16,123 +16,108 @@ #include "TF1.h" - - - ////////////////////////////////////////////////////////////////////////////////////// -MuonBremsstrahlungSimulator::MuonBremsstrahlungSimulator(double A,double Z, double density,double radLen, - double photonEnergyCut,double photonFractECut) : - MaterialEffectsSimulator(A,Z,density,radLen) -{ +MuonBremsstrahlungSimulator::MuonBremsstrahlungSimulator( + double A, double Z, double density, double radLen, double photonEnergyCut, double photonFractECut) + : MaterialEffectsSimulator(A, Z, density, radLen) { // Set the minimal photon energy for a Brem from mu+/- photonEnergy = photonEnergyCut; photonFractE = photonFractECut; - d = 0.; //distance - LogDebug("MuonBremsstrahlungSimulator")<< "Starting the MuonBremsstrahlungSimulator"<< std::endl; + d = 0.; //distance + LogDebug("MuonBremsstrahlungSimulator") << "Starting the MuonBremsstrahlungSimulator" << std::endl; } - - /////////////////////////////////////////////////////////////////// -void -MuonBremsstrahlungSimulator::compute(ParticlePropagator &Particle, RandomEngineAndDistribution const* random) -{ - +void MuonBremsstrahlungSimulator::compute(ParticlePropagator& Particle, RandomEngineAndDistribution const* random) { double NA = 6.022e+23; //Avogadro's number - if ( radLengths > 4. ) { - Particle.particle().setMomentum(0.,0.,0.,0.); - deltaPMuon.SetXYZT(0.,0.,0.,0.); - brem_photon.SetXYZT(0.,0.,0.,0.); + if (radLengths > 4.) { + Particle.particle().setMomentum(0., 0., 0., 0.); + deltaPMuon.SetXYZT(0., 0., 0., 0.); + brem_photon.SetXYZT(0., 0., 0., 0.); } -// Hard brem probability with a photon Energy above photonEnergy. - - double EMuon = Particle.particle().e();//Muon Energy - if (EMuon= 1. || xmin <= 0.) + return; - // xmax = photonEnergy/Particle.particle().e(); - if ( xmin >=1. || xmin <=0. ) return; - xmax = 1.; - npar = 3 ;//Number of parameters + npar = 3; //Number of parameters - // create TF1 using a free C function - f1 = new TF1("f1",PetrukhinFunc,xmin,xmax,npar); + // create TF1 using a free C function + f1 = new TF1("f1", PetrukhinFunc, xmin, xmax, npar); //Setting parameters - f1->SetParameters(EMuon,A,Z); - ///////////////////////////////////////////////////////////////////////// + f1->SetParameters(EMuon, A, Z); + ///////////////////////////////////////////////////////////////////////// //d = distance for several materials //X0 = radLen //d = radLengths * X0(for tracker,yoke,ECAL and HCAL) - d = radLengths * radLen ; + d = radLengths * radLen; //Integration - bremProba = density * d *(NA/A)* (f1->Integral(0.,1.)); - - + bremProba = density * d * (NA / A) * (f1->Integral(0., 1.)); + // Number of photons to be radiated. unsigned int nPhotons = random->poissonShoot(bremProba); _theUpdatedState.reserve(nPhotons); - - - if ( !nPhotons ) return; - + + if (!nPhotons) + return; + //Rotate to the lab frame double chi = Particle.particle().theta(); double psi = Particle.particle().phi(); RawParticle::RotationZ rotZ(psi); RawParticle::RotationY rotY(chi); - - // Energy of these photons - for ( unsigned int i=0; i " << xmin << std::endl; - LogDebug("MuonBremsstrahlungSimulator")<< "Atomic Weight-> " << A << std::endl; - LogDebug("MuonBremsstrahlungSimulator")<< "Density-> " << density << std::endl; - LogDebug("MuonBremsstrahlungSimulator")<< "Distance-> " << d << std::endl; - LogDebug("MuonBremsstrahlungSimulator")<< "bremProba->" << bremProba << std::endl; - LogDebug("MuonBremsstrahlungSimulator")<< "nPhotons->" << nPhotons << std::endl; - LogDebug("MuonBremsstrahlungSimulator")<< " Muon_Energy-> " << EMuon << std::endl; - LogDebug("MuonBremsstrahlungSimulator")<< "X0-> "<< radLen << std::endl; - LogDebug("MuonBremsstrahlungSimulator")<< " radLengths-> " << radLengths << std::endl; + for (unsigned int i = 0; i < nPhotons; ++i) { + // Check that there is enough energy left. + if (Particle.particle().e() < photonEnergy) + break; + LogDebug("MuonBremsstrahlungSimulator") << "MuonBremsstrahlungSimulator parameters:" << std::endl; + LogDebug("MuonBremsstrahlungSimulator") << "xmin-> " << xmin << std::endl; + LogDebug("MuonBremsstrahlungSimulator") << "Atomic Weight-> " << A << std::endl; + LogDebug("MuonBremsstrahlungSimulator") << "Density-> " << density << std::endl; + LogDebug("MuonBremsstrahlungSimulator") << "Distance-> " << d << std::endl; + LogDebug("MuonBremsstrahlungSimulator") << "bremProba->" << bremProba << std::endl; + LogDebug("MuonBremsstrahlungSimulator") << "nPhotons->" << nPhotons << std::endl; + LogDebug("MuonBremsstrahlungSimulator") << " Muon_Energy-> " << EMuon << std::endl; + LogDebug("MuonBremsstrahlungSimulator") << "X0-> " << radLen << std::endl; + LogDebug("MuonBremsstrahlungSimulator") << " radLengths-> " << radLengths << std::endl; // Add a photon - RawParticle thePhoton=makeParticle(Particle.particleDataTable(),22,brem(Particle, random)); - if (thePhoton.E()>0.){ - - thePhoton.rotate(rotY); - thePhoton.rotate(rotZ); - - _theUpdatedState.push_back(thePhoton); - - // Update the original mu +/- - deltaPMuon = Particle.particle().momentum() -= thePhoton.momentum(); - // Information of brem photon - brem_photon.SetXYZT(thePhoton.Px(),thePhoton.Py(),thePhoton.Pz(),thePhoton.E()); - - LogDebug("MuonBremsstrahlungSimulator")<< " Muon Bremsstrahlung: photon_energy-> " << thePhoton.E() << std::endl; - LogDebug("MuonBremsstrahlungSimulator")<< "photon_px->" << thePhoton.Px() << std::endl; - LogDebug("MuonBremsstrahlungSimulator")<< "photon_py->" << thePhoton.Py() << std::endl; - LogDebug("MuonBremsstrahlungSimulator")<< "photon_pz->" << thePhoton.Pz() << std::endl; - - } - + RawParticle thePhoton = makeParticle(Particle.particleDataTable(), 22, brem(Particle, random)); + if (thePhoton.E() > 0.) { + thePhoton.rotate(rotY); + thePhoton.rotate(rotZ); + + _theUpdatedState.push_back(thePhoton); + + // Update the original mu +/- + deltaPMuon = Particle.particle().momentum() -= thePhoton.momentum(); + // Information of brem photon + brem_photon.SetXYZT(thePhoton.Px(), thePhoton.Py(), thePhoton.Pz(), thePhoton.E()); + + LogDebug("MuonBremsstrahlungSimulator") << " Muon Bremsstrahlung: photon_energy-> " << thePhoton.E() << std::endl; + LogDebug("MuonBremsstrahlungSimulator") << "photon_px->" << thePhoton.Px() << std::endl; + LogDebug("MuonBremsstrahlungSimulator") << "photon_py->" << thePhoton.Py() << std::endl; + LogDebug("MuonBremsstrahlungSimulator") << "photon_pz->" << thePhoton.Pz() << std::endl; + } } - } /////////////////////////////////////////////////////////////////////////////////////////// -XYZTLorentzVector -MuonBremsstrahlungSimulator::brem(ParticlePropagator& pp, RandomEngineAndDistribution const* random) const { - +XYZTLorentzVector MuonBremsstrahlungSimulator::brem(ParticlePropagator& pp, + RandomEngineAndDistribution const* random) const { // This is a simple version of a Muon Brem using Petrukhin model . - //Ref: http://pdg.lbl.gov/2008/AtomicNuclearProperties/adndt.pdf - double mumass = 0.105658367;//mu mass (GeV/c^2) + //Ref: http://pdg.lbl.gov/2008/AtomicNuclearProperties/adndt.pdf + double mumass = 0.105658367; //mu mass (GeV/c^2) // RANDOM_NUMBER_ERROR // Random number should be generated by the engines from the @@ -144,46 +129,42 @@ MuonBremsstrahlungSimulator::brem(ParticlePropagator& pp, RandomEngineAndDistrib // It might be that this is never used because of the std::cout // statement 2 lines below. I've never seen or heard complaints // about that vebosity .... - double xp = f1->GetRandom(); - LogDebug("MuonBremsstrahlungSimulator")<< "MuonBremsstrahlungSimulator: xp->" << xp << std::endl; + double xp = f1->GetRandom(); + LogDebug("MuonBremsstrahlungSimulator") << "MuonBremsstrahlungSimulator: xp->" << xp << std::endl; std::cout << "MuonBremsstrahlungSimulator: xp->" << xp << std::endl; - // Have photon energy. Now generate angles with respect to the z axis + // Have photon energy. Now generate angles with respect to the z axis // defined by the incoming particle's momentum. // Isotropic in phi - const double phi = random->flatShoot()*2*M_PI; + const double phi = random->flatShoot() * 2 * M_PI; // theta from universal distribution - const double theta = gbteth(pp.particle().e(),mumass,xp,random)*mumass/pp.particle().e(); + const double theta = gbteth(pp.particle().e(), mumass, xp, random) * mumass / pp.particle().e(); // Make momentum components double stheta = std::sin(theta); double ctheta = std::cos(theta); - double sphi = std::sin(phi); - double cphi = std::cos(phi); + double sphi = std::sin(phi); + double cphi = std::cos(phi); - return xp * pp.particle().e() * XYZTLorentzVector(stheta*cphi,stheta*sphi,ctheta,1.); - + return xp * pp.particle().e() * XYZTLorentzVector(stheta * cphi, stheta * sphi, ctheta, 1.); } ////////////////////////////////////////////////////////////////////////////////////////////// -double -MuonBremsstrahlungSimulator::gbteth(const double ener, - const double partm, - const double efrac, - RandomEngineAndDistribution const* random) const { +double MuonBremsstrahlungSimulator::gbteth(const double ener, + const double partm, + const double efrac, + RandomEngineAndDistribution const* random) const { const double alfa = 0.625; - const double d = 0.13*(0.8+1.3/theZ())*(100.0+(1.0/ener))*(1.0+efrac); - const double w1 = 9.0/(9.0+d); - const double umax = ener*M_PI/partm; + const double d = 0.13 * (0.8 + 1.3 / theZ()) * (100.0 + (1.0 / ener)) * (1.0 + efrac); + const double w1 = 9.0 / (9.0 + d); + const double umax = ener * M_PI / partm; double u; - + do { - double beta = (random->flatShoot()<=w1) ? alfa : 3.0*alfa; - u = -std::log(random->flatShoot()*random->flatShoot())/beta; - } while (u>=umax); + double beta = (random->flatShoot() <= w1) ? alfa : 3.0 * alfa; + u = -std::log(random->flatShoot() * random->flatShoot()) / beta; + } while (u >= umax); return u; } - - diff --git a/FastSimulation/MaterialEffects/src/NuclearInteractionFTFSimulator.cc b/FastSimulation/MaterialEffects/src/NuclearInteractionFTFSimulator.cc index ed577c26bac14..57daf712fa254 100644 --- a/FastSimulation/MaterialEffects/src/NuclearInteractionFTFSimulator.cc +++ b/FastSimulation/MaterialEffects/src/NuclearInteractionFTFSimulator.cc @@ -71,103 +71,153 @@ static std::once_flag initializeOnce; CMS_THREAD_GUARD(initializeOnce) const G4ParticleDefinition* NuclearInteractionFTFSimulator::theG4Hadron[] = {nullptr}; CMS_THREAD_GUARD(initializeOnce) int NuclearInteractionFTFSimulator::theId[] = {0}; -const double fact = 1.0/CLHEP::GeV; +const double fact = 1.0 / CLHEP::GeV; -// inelastic interaction length corrections per particle and energy +// inelastic interaction length corrections per particle and energy const double corrfactors_inel[numHadrons][npoints] = { - {1.0872, 1.1026, 1.111, 1.111, 1.0105, 0.97622, 0.9511, 0.9526, 0.97591, 0.99277, 1.0099, 1.015, 1.0217, 1.0305, 1.0391, 1.0438, 1.0397, 1.0328, 1.0232, 1.0123, 1.0}, - {1.0416, 1.1044, 1.1467, 1.1273, 1.026, 0.99085, 0.96572, 0.96724, 0.99091, 1.008, 1.0247, 1.0306, 1.0378, 1.0427, 1.0448, 1.0438, 1.0397, 1.0328, 1.0232, 1.0123, 1.0}, - {0.5308, 0.53589, 0.67059, 0.80253, 0.82341, 0.79083, 0.85967, 0.90248, 0.93792, 0.9673, 1.0034, 1.022, 1.0418, 1.0596, 1.0749, 1.079, 1.0704, 1.0576, 1.0408, 1.0214, 1.0}, - {0.49107, 0.50571, 0.64149, 0.77209, 0.80472, 0.78166, 0.83509, 0.8971, 0.93234, 0.96154, 0.99744, 1.0159, 1.0355, 1.0533, 1.0685, 1.0732, 1.0675, 1.0485, 1.0355, 1.0191, 1.0}, - {1.9746, 1.7887, 1.5645, 1.2817, 1.0187, 0.95216, 0.9998, 1.035, 1.0498, 1.0535, 1.0524, 1.0495, 1.0461, 1.0424, 1.0383, 1.0338, 1.0287, 1.0228, 1.0161, 1.0085, 1.0}, - {0.46028, 0.59514, 0.70355, 0.70698, 0.62461, 0.65103, 0.71945, 0.77753, 0.83582, 0.88422, 0.92117, 0.94889, 0.96963, 0.98497, 0.99596, 1.0033, 1.0075, 1.0091, 1.0081, 1.005, 1.0}, - {0.75016, 0.89607, 0.97185, 0.91083, 0.77425, 0.77412, 0.8374, 0.88848, 0.93104, 0.96174, 0.98262, 0.99684, 1.0065, 1.0129, 1.0168, 1.0184, 1.018, 1.0159, 1.0121, 1.0068, 1.0}, - {0.75016, 0.89607, 0.97185, 0.91083, 0.77425, 0.77412, 0.8374, 0.88848, 0.93104, 0.96174, 0.98262, 0.99684, 1.0065, 1.0129, 1.0168, 1.0184, 1.018, 1.0159, 1.0121, 1.0068, 1.0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1.0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1.0}, - {1.1006, 1.1332, 1.121, 1.1008, 1.086, 1.077, 1.0717, 1.0679, 1.0643, 1.0608, 1.057, 1.053, 1.0487, 1.0441, 1.0392, 1.0338, 1.028, 1.0218, 1.015, 1.0078, 1.0}, - {1.1318, 1.1255, 1.1062, 1.0904, 1.0802, 1.0742, 1.0701, 1.0668, 1.0636, 1.0602, 1.0566, 1.0527, 1.0485, 1.044, 1.0391, 1.0337, 1.028, 1.0217, 1.015, 1.0078, 1.0}, - {1.1094, 1.1332, 1.1184, 1.0988, 1.0848, 1.0765, 1.0714, 1.0677, 1.0642, 1.0607, 1.0569, 1.053, 1.0487, 1.0441, 1.0391, 1.0338, 1.028, 1.0218, 1.015, 1.0078, 1.0}, - {1.1087, 1.1332, 1.1187, 1.099, 1.0849, 1.0765, 1.0715, 1.0677, 1.0642, 1.0607, 1.057, 1.053, 1.0487, 1.0441, 1.0391, 1.0338, 1.028, 1.0218, 1.015, 1.0078, 1.0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1.0}, - {1.1192, 1.132, 1.1147, 1.0961, 1.0834, 1.0758, 1.0711, 1.0674, 1.064, 1.0606, 1.0569, 1.0529, 1.0486, 1.0441, 1.0391, 1.0338, 1.028, 1.0218, 1.015, 1.0078, 1.0}, - {1.1188, 1.1321, 1.1149, 1.0963, 1.0834, 1.0758, 1.0711, 1.0675, 1.0641, 1.0606, 1.0569, 1.0529, 1.0486, 1.0441, 1.0391, 1.0338, 1.028, 1.0218, 1.015, 1.0078, 1.0}, - {0.50776, 0.5463, 0.5833, 0.61873, 0.65355, 0.68954, 0.72837, 0.7701, 0.81267, 0.85332, 0.89037, 0.92329, 0.95177, 0.97539, 0.99373, 1.0066, 1.014, 1.0164, 1.0144, 1.0087, 1.0}, - {0.50787, 0.5464, 0.58338, 0.6188, 0.65361, 0.6896, 0.72841, 0.77013, 0.8127, 0.85333, 0.89038, 0.92329, 0.95178, 0.9754, 0.99373, 1.0066, 1.014, 1.0164, 1.0144, 1.0087, 1.0}, - {1.1006, 1.1332, 1.121, 1.1008, 1.086, 1.077, 1.0717, 1.0679, 1.0643, 1.0608, 1.057, 1.053, 1.0487, 1.0441, 1.0392, 1.0338, 1.028, 1.0218, 1.015, 1.0078, 1.0}, - {1.1318, 1.1255, 1.1062, 1.0904, 1.0802, 1.0742, 1.0701, 1.0668, 1.0636, 1.0602, 1.0566, 1.0527, 1.0485, 1.044, 1.0391, 1.0337, 1.028, 1.0217, 1.015, 1.0078, 1.0}, - {1.1094, 1.1332, 1.1184, 1.0988, 1.0848, 1.0765, 1.0714, 1.0677, 1.0642, 1.0607, 1.0569, 1.053, 1.0487, 1.0441, 1.0391, 1.0338, 1.028, 1.0218, 1.015, 1.0078, 1.0}, - {1.1087, 1.1332, 1.1187, 1.099, 1.0849, 1.0765, 1.0715, 1.0677, 1.0642, 1.0607, 1.057, 1.053, 1.0487, 1.0441, 1.0391, 1.0338, 1.028, 1.0218, 1.015, 1.0078, 1.0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1.0}, - {1.1192, 1.132, 1.1147, 1.0961, 1.0834, 1.0758, 1.0711, 1.0674, 1.064, 1.0606, 1.0569, 1.0529, 1.0486, 1.0441, 1.0391, 1.0338, 1.028, 1.0218, 1.015, 1.0078, 1.0}, - {1.1188, 1.1321, 1.1149, 1.0963, 1.0834, 1.0758, 1.0711, 1.0675, 1.0641, 1.0606, 1.0569, 1.0529, 1.0486, 1.0441, 1.0391, 1.0338, 1.028, 1.0218, 1.015, 1.0078, 1.0}, - {0.47677, 0.51941, 0.56129, 0.60176, 0.64014, 0.67589, 0.70891, 0.73991, 0.77025, 0.80104, 0.83222, 0.86236, 0.8901, 0.91518, 0.9377, 0.95733, 0.97351, 0.98584, 0.9942, 0.99879, 1.0}, - {0.49361, 0.53221, 0.56976, 0.60563, 0.63954, 0.67193, 0.70411, 0.73777, 0.77378, 0.81114, 0.84754, 0.88109, 0.91113, 0.93745, 0.95974, 0.97762, 0.99081, 0.99929, 1.0033, 1.0034, 1.0}, - {0.4873, 0.52744, 0.56669, 0.60443, 0.64007, 0.67337, 0.70482, 0.73572, 0.76755, 0.80086, 0.83456, 0.86665, 0.8959, 0.92208, 0.94503, 0.96437, 0.97967, 0.99072, 0.99756, 1.0005, 1.0}, - {0.48729, 0.52742, 0.56668, 0.60442, 0.64006, 0.67336, 0.70482, 0.73571, 0.76754, 0.80086, 0.83455, 0.86665, 0.8959, 0.92208, 0.94503, 0.96437, 0.97967, 0.99072, 0.99756, 1.0005, 1.0}, + {1.0872, 1.1026, 1.111, 1.111, 1.0105, 0.97622, 0.9511, 0.9526, 0.97591, 0.99277, 1.0099, + 1.015, 1.0217, 1.0305, 1.0391, 1.0438, 1.0397, 1.0328, 1.0232, 1.0123, 1.0}, + {1.0416, 1.1044, 1.1467, 1.1273, 1.026, 0.99085, 0.96572, 0.96724, 0.99091, 1.008, 1.0247, + 1.0306, 1.0378, 1.0427, 1.0448, 1.0438, 1.0397, 1.0328, 1.0232, 1.0123, 1.0}, + {0.5308, 0.53589, 0.67059, 0.80253, 0.82341, 0.79083, 0.85967, 0.90248, 0.93792, 0.9673, 1.0034, + 1.022, 1.0418, 1.0596, 1.0749, 1.079, 1.0704, 1.0576, 1.0408, 1.0214, 1.0}, + {0.49107, 0.50571, 0.64149, 0.77209, 0.80472, 0.78166, 0.83509, 0.8971, 0.93234, 0.96154, 0.99744, + 1.0159, 1.0355, 1.0533, 1.0685, 1.0732, 1.0675, 1.0485, 1.0355, 1.0191, 1.0}, + {1.9746, 1.7887, 1.5645, 1.2817, 1.0187, 0.95216, 0.9998, 1.035, 1.0498, 1.0535, 1.0524, + 1.0495, 1.0461, 1.0424, 1.0383, 1.0338, 1.0287, 1.0228, 1.0161, 1.0085, 1.0}, + {0.46028, 0.59514, 0.70355, 0.70698, 0.62461, 0.65103, 0.71945, 0.77753, 0.83582, 0.88422, 0.92117, + 0.94889, 0.96963, 0.98497, 0.99596, 1.0033, 1.0075, 1.0091, 1.0081, 1.005, 1.0}, + {0.75016, 0.89607, 0.97185, 0.91083, 0.77425, 0.77412, 0.8374, 0.88848, 0.93104, 0.96174, 0.98262, + 0.99684, 1.0065, 1.0129, 1.0168, 1.0184, 1.018, 1.0159, 1.0121, 1.0068, 1.0}, + {0.75016, 0.89607, 0.97185, 0.91083, 0.77425, 0.77412, 0.8374, 0.88848, 0.93104, 0.96174, 0.98262, + 0.99684, 1.0065, 1.0129, 1.0168, 1.0184, 1.018, 1.0159, 1.0121, 1.0068, 1.0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1.0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1.0}, + {1.1006, 1.1332, 1.121, 1.1008, 1.086, 1.077, 1.0717, 1.0679, 1.0643, 1.0608, 1.057, + 1.053, 1.0487, 1.0441, 1.0392, 1.0338, 1.028, 1.0218, 1.015, 1.0078, 1.0}, + {1.1318, 1.1255, 1.1062, 1.0904, 1.0802, 1.0742, 1.0701, 1.0668, 1.0636, 1.0602, 1.0566, + 1.0527, 1.0485, 1.044, 1.0391, 1.0337, 1.028, 1.0217, 1.015, 1.0078, 1.0}, + {1.1094, 1.1332, 1.1184, 1.0988, 1.0848, 1.0765, 1.0714, 1.0677, 1.0642, 1.0607, 1.0569, + 1.053, 1.0487, 1.0441, 1.0391, 1.0338, 1.028, 1.0218, 1.015, 1.0078, 1.0}, + {1.1087, 1.1332, 1.1187, 1.099, 1.0849, 1.0765, 1.0715, 1.0677, 1.0642, 1.0607, 1.057, + 1.053, 1.0487, 1.0441, 1.0391, 1.0338, 1.028, 1.0218, 1.015, 1.0078, 1.0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1.0}, + {1.1192, 1.132, 1.1147, 1.0961, 1.0834, 1.0758, 1.0711, 1.0674, 1.064, 1.0606, 1.0569, + 1.0529, 1.0486, 1.0441, 1.0391, 1.0338, 1.028, 1.0218, 1.015, 1.0078, 1.0}, + {1.1188, 1.1321, 1.1149, 1.0963, 1.0834, 1.0758, 1.0711, 1.0675, 1.0641, 1.0606, 1.0569, + 1.0529, 1.0486, 1.0441, 1.0391, 1.0338, 1.028, 1.0218, 1.015, 1.0078, 1.0}, + {0.50776, 0.5463, 0.5833, 0.61873, 0.65355, 0.68954, 0.72837, 0.7701, 0.81267, 0.85332, 0.89037, + 0.92329, 0.95177, 0.97539, 0.99373, 1.0066, 1.014, 1.0164, 1.0144, 1.0087, 1.0}, + {0.50787, 0.5464, 0.58338, 0.6188, 0.65361, 0.6896, 0.72841, 0.77013, 0.8127, 0.85333, 0.89038, + 0.92329, 0.95178, 0.9754, 0.99373, 1.0066, 1.014, 1.0164, 1.0144, 1.0087, 1.0}, + {1.1006, 1.1332, 1.121, 1.1008, 1.086, 1.077, 1.0717, 1.0679, 1.0643, 1.0608, 1.057, + 1.053, 1.0487, 1.0441, 1.0392, 1.0338, 1.028, 1.0218, 1.015, 1.0078, 1.0}, + {1.1318, 1.1255, 1.1062, 1.0904, 1.0802, 1.0742, 1.0701, 1.0668, 1.0636, 1.0602, 1.0566, + 1.0527, 1.0485, 1.044, 1.0391, 1.0337, 1.028, 1.0217, 1.015, 1.0078, 1.0}, + {1.1094, 1.1332, 1.1184, 1.0988, 1.0848, 1.0765, 1.0714, 1.0677, 1.0642, 1.0607, 1.0569, + 1.053, 1.0487, 1.0441, 1.0391, 1.0338, 1.028, 1.0218, 1.015, 1.0078, 1.0}, + {1.1087, 1.1332, 1.1187, 1.099, 1.0849, 1.0765, 1.0715, 1.0677, 1.0642, 1.0607, 1.057, + 1.053, 1.0487, 1.0441, 1.0391, 1.0338, 1.028, 1.0218, 1.015, 1.0078, 1.0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1.0}, + {1.1192, 1.132, 1.1147, 1.0961, 1.0834, 1.0758, 1.0711, 1.0674, 1.064, 1.0606, 1.0569, + 1.0529, 1.0486, 1.0441, 1.0391, 1.0338, 1.028, 1.0218, 1.015, 1.0078, 1.0}, + {1.1188, 1.1321, 1.1149, 1.0963, 1.0834, 1.0758, 1.0711, 1.0675, 1.0641, 1.0606, 1.0569, + 1.0529, 1.0486, 1.0441, 1.0391, 1.0338, 1.028, 1.0218, 1.015, 1.0078, 1.0}, + {0.47677, 0.51941, 0.56129, 0.60176, 0.64014, 0.67589, 0.70891, 0.73991, 0.77025, 0.80104, 0.83222, + 0.86236, 0.8901, 0.91518, 0.9377, 0.95733, 0.97351, 0.98584, 0.9942, 0.99879, 1.0}, + {0.49361, 0.53221, 0.56976, 0.60563, 0.63954, 0.67193, 0.70411, 0.73777, 0.77378, 0.81114, 0.84754, + 0.88109, 0.91113, 0.93745, 0.95974, 0.97762, 0.99081, 0.99929, 1.0033, 1.0034, 1.0}, + {0.4873, 0.52744, 0.56669, 0.60443, 0.64007, 0.67337, 0.70482, 0.73572, 0.76755, 0.80086, 0.83456, + 0.86665, 0.8959, 0.92208, 0.94503, 0.96437, 0.97967, 0.99072, 0.99756, 1.0005, 1.0}, + {0.48729, 0.52742, 0.56668, 0.60442, 0.64006, 0.67336, 0.70482, 0.73571, 0.76754, 0.80086, 0.83455, + 0.86665, 0.8959, 0.92208, 0.94503, 0.96437, 0.97967, 0.99072, 0.99756, 1.0005, 1.0}, }; -// elastic interaction length corrections per particle and energy +// elastic interaction length corrections per particle and energy const double corrfactors_el[numHadrons][npoints] = { - {0.58834, 1.1238, 1.7896, 1.4409, 0.93175, 0.80587, 0.80937, 0.83954, 0.87453, 0.91082, 0.94713, 0.98195, 1.0134, 1.0397, 1.0593, 1.071, 1.0739, 1.0678, 1.053, 1.03, 1.0}, - {0.40938, 0.92337, 1.3365, 1.1607, 1.008, 0.82206, 0.81163, 0.79489, 0.82919, 0.91812, 0.96688, 1.0225, 1.0734, 1.0833, 1.0874, 1.0854, 1.0773, 1.0637, 1.0448, 1.0235, 1.0}, - {0.43699, 0.42165, 0.46594, 0.64917, 0.85314, 0.80782, 0.83204, 0.91162, 1.0155, 1.0665, 1.0967, 1.1125, 1.1275, 1.1376, 1.1464, 1.1477, 1.1312, 1.1067, 1.0751, 1.039, 1.0}, - {0.3888, 0.39527, 0.43921, 0.62834, 0.8164, 0.79866, 0.82272, 0.90163, 1.0045, 1.055, 1.0849, 1.1005, 1.1153, 1.1253, 1.134, 1.1365, 1.1255, 1.0895, 1.0652, 1.0348, 1.0}, - {0.32004, 0.31119, 0.30453, 0.30004, 0.31954, 0.40148, 0.5481, 0.74485, 0.99317, 1.1642, 1.2117, 1.2351, 1.2649, 1.3054, 1.375, 1.4992, 1.4098, 1.3191, 1.2232, 1.118, 1.0}, - {0.10553, 0.14623, 0.20655, 0.26279, 0.19996, 0.40125, 0.5139, 0.71271, 0.89269, 1.0108, 1.1673, 1.3052, 1.4149, 1.429, 1.4521, 1.4886, 1.4006, 1.3116, 1.2177, 1.1151, 1.0}, - {0.106, 0.14692, 0.20755, 0.26257, 0.20089, 0.40236, 0.51452, 0.71316, 0.89295, 1.0109, 1.1673, 1.3053, 1.4149, 1.429, 1.4521, 1.4886, 1.4006, 1.3116, 1.2177, 1.1151, 1.0}, - {0.31991, 0.31111, 0.30445, 0.30004, 0.31995, 0.40221, 0.54884, 0.74534, 0.99364, 1.1644, 1.2117, 1.2351, 1.265, 1.3054, 1.375, 1.4992, 1.4098, 1.3191, 1.2232, 1.118, 1.0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1.0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1.0}, - {0.37579, 0.39922, 0.37445, 0.32631, 0.39002, 0.42161, 0.54251, 0.69127, 0.90332, 1.0664, 1.1346, 1.1481, 1.1692, 1.2036, 1.2625, 1.3633, 1.2913, 1.2215, 1.1516, 1.0788, 1.0}, - {0.31756, 0.33409, 0.25339, 0.35525, 0.52989, 0.63382, 0.7453, 0.93505, 1.1464, 1.2942, 1.3161, 1.328, 1.3393, 1.3525, 1.374, 1.4051, 1.3282, 1.2523, 1.1745, 1.0916, 1.0}, - {0.38204, 0.39694, 0.36502, 0.33367, 0.39229, 0.43119, 0.54898, 0.70169, 0.91004, 1.0696, 1.1348, 1.1483, 1.1694, 1.2038, 1.2627, 1.3632, 1.2913, 1.2215, 1.1516, 1.0788, 1.0}, - {0.38143, 0.39716, 0.36609, 0.33294, 0.39207, 0.43021, 0.54834, 0.70066, 0.90945, 1.0693, 1.1348, 1.1482, 1.1694, 1.2038, 1.2627, 1.3632, 1.2913, 1.2215, 1.1516, 1.0788, 1.0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1.0}, - {0.29564, 0.32645, 0.29986, 0.30611, 0.48808, 0.59902, 0.71207, 0.8832, 1.1164, 1.2817, 1.3154, 1.3273, 1.3389, 1.3521, 1.3736, 1.4056, 1.3285, 1.2524, 1.1746, 1.0916, 1.0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1.0}, - {0.3265, 0.3591, 0.39232, 0.42635, 0.46259, 0.50365, 0.55244, 0.61014, 0.67446, 0.74026, 0.80252, 0.85858, 0.90765, 0.94928, 0.9827, 1.0071, 1.0221, 1.0279, 1.0253, 1.0155, 1.0}, - {0.13808, 0.15585, 0.17798, 0.2045, 0.22596, 0.25427, 0.33214, 0.44821, 0.5856, 0.74959, 0.89334, 1.0081, 1.0964, 1.1248, 1.173, 1.2548, 1.1952, 1.1406, 1.0903, 1.0437, 1.0}, - {0.20585, 0.23253, 0.26371, 0.28117, 0.30433, 0.35417, 0.44902, 0.58211, 0.73486, 0.90579, 1.0395, 1.1488, 1.2211, 1.2341, 1.2553, 1.2877, 1.2245, 1.1654, 1.1093, 1.0547, 1.0}, - {0.2852, 0.32363, 0.31419, 0.35164, 0.45463, 0.54331, 0.66908, 0.81735, 0.98253, 1.1557, 1.2557, 1.3702, 1.4186, 1.401, 1.374, 1.3325, 1.2644, 1.1991, 1.1348, 1.0694, 1.0}, - {0.20928, 0.23671, 0.2664, 0.28392, 0.30584, 0.35929, 0.45725, 0.5893, 0.74047, 0.9101, 1.0407, 1.1503, 1.2212, 1.2342, 1.2554, 1.2876, 1.2245, 1.1654, 1.1093, 1.0547, 1.0}, - {0.11897, 0.13611, 0.15796, 0.1797, 0.21335, 0.26367, 0.34705, 0.46115, 0.6016, 0.7759, 0.91619, 1.0523, 1.1484, 1.1714, 1.2098, 1.2721, 1.2106, 1.1537, 1.1004, 1.0496, 1.0}, - {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1.0}, - {0.26663, 0.30469, 0.32886, 0.33487, 0.41692, 0.51616, 0.63323, 0.78162, 0.95551, 1.1372, 1.2502, 1.3634, 1.4189, 1.4013, 1.3743, 1.3329, 1.2646, 1.1992, 1.1349, 1.0694, 1.0}, - {0.16553, 0.19066, 0.21468, 0.23609, 0.30416, 0.38821, 0.49644, 0.63386, 0.80299, 0.99907, 1.1304, 1.2724, 1.3535, 1.3475, 1.3381, 1.3219, 1.2549, 1.191, 1.1287, 1.0659, 1.0}, - {0.37736, 0.41414, 0.45135, 0.48843, 0.52473, 0.55973, 0.59348, 0.62696, 0.66202, 0.70042, 0.74241, 0.786, 0.82819, 0.86688, 0.90128, 0.93107, 0.95589, 0.97532, 0.98908, 0.99719, 1.0}, - {0.34354, 0.37692, 0.4109, 0.44492, 0.47873, 0.51296, 0.54937, 0.59047, 0.63799, 0.69117, 0.74652, 0.7998, 0.84832, 0.89111, 0.92783, 0.95798, 0.98095, 0.99635, 1.0043, 1.0052, 1.0}, - {0.36364, 0.39792, 0.43277, 0.4676, 0.50186, 0.53538, 0.56884, 0.604, 0.64308, 0.68729, 0.73544, 0.7842, 0.83019, 0.87156, 0.90777, 0.93854, 0.96346, 0.98209, 0.99421, 1, 1.0}, - {0.36362, 0.39791, 0.43276, 0.46759, 0.50185, 0.53537, 0.56883, 0.604, 0.64307, 0.68728, 0.73544, 0.7842, 0.83019, 0.87156, 0.90777, 0.93854, 0.96346, 0.98209, 0.99421, 1, 1.0}, + {0.58834, 1.1238, 1.7896, 1.4409, 0.93175, 0.80587, 0.80937, 0.83954, 0.87453, 0.91082, 0.94713, + 0.98195, 1.0134, 1.0397, 1.0593, 1.071, 1.0739, 1.0678, 1.053, 1.03, 1.0}, + {0.40938, 0.92337, 1.3365, 1.1607, 1.008, 0.82206, 0.81163, 0.79489, 0.82919, 0.91812, 0.96688, + 1.0225, 1.0734, 1.0833, 1.0874, 1.0854, 1.0773, 1.0637, 1.0448, 1.0235, 1.0}, + {0.43699, 0.42165, 0.46594, 0.64917, 0.85314, 0.80782, 0.83204, 0.91162, 1.0155, 1.0665, 1.0967, + 1.1125, 1.1275, 1.1376, 1.1464, 1.1477, 1.1312, 1.1067, 1.0751, 1.039, 1.0}, + {0.3888, 0.39527, 0.43921, 0.62834, 0.8164, 0.79866, 0.82272, 0.90163, 1.0045, 1.055, 1.0849, + 1.1005, 1.1153, 1.1253, 1.134, 1.1365, 1.1255, 1.0895, 1.0652, 1.0348, 1.0}, + {0.32004, 0.31119, 0.30453, 0.30004, 0.31954, 0.40148, 0.5481, 0.74485, 0.99317, 1.1642, 1.2117, + 1.2351, 1.2649, 1.3054, 1.375, 1.4992, 1.4098, 1.3191, 1.2232, 1.118, 1.0}, + {0.10553, 0.14623, 0.20655, 0.26279, 0.19996, 0.40125, 0.5139, 0.71271, 0.89269, 1.0108, 1.1673, + 1.3052, 1.4149, 1.429, 1.4521, 1.4886, 1.4006, 1.3116, 1.2177, 1.1151, 1.0}, + {0.106, 0.14692, 0.20755, 0.26257, 0.20089, 0.40236, 0.51452, 0.71316, 0.89295, 1.0109, 1.1673, + 1.3053, 1.4149, 1.429, 1.4521, 1.4886, 1.4006, 1.3116, 1.2177, 1.1151, 1.0}, + {0.31991, 0.31111, 0.30445, 0.30004, 0.31995, 0.40221, 0.54884, 0.74534, 0.99364, 1.1644, 1.2117, + 1.2351, 1.265, 1.3054, 1.375, 1.4992, 1.4098, 1.3191, 1.2232, 1.118, 1.0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1.0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1.0}, + {0.37579, 0.39922, 0.37445, 0.32631, 0.39002, 0.42161, 0.54251, 0.69127, 0.90332, 1.0664, 1.1346, + 1.1481, 1.1692, 1.2036, 1.2625, 1.3633, 1.2913, 1.2215, 1.1516, 1.0788, 1.0}, + {0.31756, 0.33409, 0.25339, 0.35525, 0.52989, 0.63382, 0.7453, 0.93505, 1.1464, 1.2942, 1.3161, + 1.328, 1.3393, 1.3525, 1.374, 1.4051, 1.3282, 1.2523, 1.1745, 1.0916, 1.0}, + {0.38204, 0.39694, 0.36502, 0.33367, 0.39229, 0.43119, 0.54898, 0.70169, 0.91004, 1.0696, 1.1348, + 1.1483, 1.1694, 1.2038, 1.2627, 1.3632, 1.2913, 1.2215, 1.1516, 1.0788, 1.0}, + {0.38143, 0.39716, 0.36609, 0.33294, 0.39207, 0.43021, 0.54834, 0.70066, 0.90945, 1.0693, 1.1348, + 1.1482, 1.1694, 1.2038, 1.2627, 1.3632, 1.2913, 1.2215, 1.1516, 1.0788, 1.0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1.0}, + {0.29564, 0.32645, 0.29986, 0.30611, 0.48808, 0.59902, 0.71207, 0.8832, 1.1164, 1.2817, 1.3154, + 1.3273, 1.3389, 1.3521, 1.3736, 1.4056, 1.3285, 1.2524, 1.1746, 1.0916, 1.0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1.0}, + {0.3265, 0.3591, 0.39232, 0.42635, 0.46259, 0.50365, 0.55244, 0.61014, 0.67446, 0.74026, 0.80252, + 0.85858, 0.90765, 0.94928, 0.9827, 1.0071, 1.0221, 1.0279, 1.0253, 1.0155, 1.0}, + {0.13808, 0.15585, 0.17798, 0.2045, 0.22596, 0.25427, 0.33214, 0.44821, 0.5856, 0.74959, 0.89334, + 1.0081, 1.0964, 1.1248, 1.173, 1.2548, 1.1952, 1.1406, 1.0903, 1.0437, 1.0}, + {0.20585, 0.23253, 0.26371, 0.28117, 0.30433, 0.35417, 0.44902, 0.58211, 0.73486, 0.90579, 1.0395, + 1.1488, 1.2211, 1.2341, 1.2553, 1.2877, 1.2245, 1.1654, 1.1093, 1.0547, 1.0}, + {0.2852, 0.32363, 0.31419, 0.35164, 0.45463, 0.54331, 0.66908, 0.81735, 0.98253, 1.1557, 1.2557, + 1.3702, 1.4186, 1.401, 1.374, 1.3325, 1.2644, 1.1991, 1.1348, 1.0694, 1.0}, + {0.20928, 0.23671, 0.2664, 0.28392, 0.30584, 0.35929, 0.45725, 0.5893, 0.74047, 0.9101, 1.0407, + 1.1503, 1.2212, 1.2342, 1.2554, 1.2876, 1.2245, 1.1654, 1.1093, 1.0547, 1.0}, + {0.11897, 0.13611, 0.15796, 0.1797, 0.21335, 0.26367, 0.34705, 0.46115, 0.6016, 0.7759, 0.91619, + 1.0523, 1.1484, 1.1714, 1.2098, 1.2721, 1.2106, 1.1537, 1.1004, 1.0496, 1.0}, + {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1.0}, + {0.26663, 0.30469, 0.32886, 0.33487, 0.41692, 0.51616, 0.63323, 0.78162, 0.95551, 1.1372, 1.2502, + 1.3634, 1.4189, 1.4013, 1.3743, 1.3329, 1.2646, 1.1992, 1.1349, 1.0694, 1.0}, + {0.16553, 0.19066, 0.21468, 0.23609, 0.30416, 0.38821, 0.49644, 0.63386, 0.80299, 0.99907, 1.1304, + 1.2724, 1.3535, 1.3475, 1.3381, 1.3219, 1.2549, 1.191, 1.1287, 1.0659, 1.0}, + {0.37736, 0.41414, 0.45135, 0.48843, 0.52473, 0.55973, 0.59348, 0.62696, 0.66202, 0.70042, 0.74241, + 0.786, 0.82819, 0.86688, 0.90128, 0.93107, 0.95589, 0.97532, 0.98908, 0.99719, 1.0}, + {0.34354, 0.37692, 0.4109, 0.44492, 0.47873, 0.51296, 0.54937, 0.59047, 0.63799, 0.69117, 0.74652, + 0.7998, 0.84832, 0.89111, 0.92783, 0.95798, 0.98095, 0.99635, 1.0043, 1.0052, 1.0}, + {0.36364, 0.39792, 0.43277, 0.4676, 0.50186, 0.53538, 0.56884, 0.604, 0.64308, 0.68729, 0.73544, + 0.7842, 0.83019, 0.87156, 0.90777, 0.93854, 0.96346, 0.98209, 0.99421, 1, 1.0}, + {0.36362, 0.39791, 0.43276, 0.46759, 0.50185, 0.53537, 0.56883, 0.604, 0.64307, 0.68728, 0.73544, + 0.7842, 0.83019, 0.87156, 0.90777, 0.93854, 0.96346, 0.98209, 0.99421, 1, 1.0}, }; // inelastic interaction length in Silicon at 1 TeV per particle const double nuclInelLength[numHadrons] = { -4.5606, 4.4916, 5.7511, 5.7856, 6.797, 6.8373, 6.8171, 6.8171, 0, 0, 4.6926, 4.6926, 4.6926, 4.6926, 0, 4.6926, 4.6926, 4.3171, 4.3171, 4.6926, 4.6926, 4.6926, 4.6926, 0, 4.6926, 4.6926, 2.509, 2.9048, 2.5479, 2.5479 -}; + 4.5606, 4.4916, 5.7511, 5.7856, 6.797, 6.8373, 6.8171, 6.8171, 0, 0, 4.6926, 4.6926, 4.6926, 4.6926, 0, + 4.6926, 4.6926, 4.3171, 4.3171, 4.6926, 4.6926, 4.6926, 4.6926, 0, 4.6926, 4.6926, 2.509, 2.9048, 2.5479, 2.5479}; // elastic interaction length in Silicon at 1 TeV per particle const double nuclElLength[numHadrons] = { -9.248, 9.451, 11.545, 11.671, 32.081, 34.373, 34.373, 32.081, 0, 0, 15.739, 20.348, 15.739, 15.739, 0, 20.349, 0, 9.7514, 12.864, 15.836, 20.516, 15.836, 15.744, 0, 20.517, 20.44, 4.129, 6.0904, 4.5204, 4.5204 -}; - - -NuclearInteractionFTFSimulator::NuclearInteractionFTFSimulator( - unsigned int distAlgo, double distCut, double elimit, double eth) : - curr4Mom(0.,0.,0.,0.), - vectProj(0.,0.,1.), - theBoost(0.,0.,0.), - theBertiniLimit(elimit), - theEnergyLimit(eth), - theDistCut(distCut), - distMin(1E99), - theDistAlgo(distAlgo) -{ + 9.248, 9.451, 11.545, 11.671, 32.081, 34.373, 34.373, 32.081, 0, 0, 15.739, 20.348, 15.739, 15.739, 0, + 20.349, 0, 9.7514, 12.864, 15.836, 20.516, 15.836, 15.744, 0, 20.517, 20.44, 4.129, 6.0904, 4.5204, 4.5204}; + +NuclearInteractionFTFSimulator::NuclearInteractionFTFSimulator(unsigned int distAlgo, + double distCut, + double elimit, + double eth) + : curr4Mom(0., 0., 0., 0.), + vectProj(0., 0., 1.), + theBoost(0., 0., 0.), + theBertiniLimit(elimit), + theEnergyLimit(eth), + theDistCut(distCut), + distMin(1E99), + theDistAlgo(distAlgo) { // FTF model theHadronicModel = new G4TheoFSGenerator("FTF"); theStringModel = new G4FTFModel(); - G4GeneratorPrecompoundInterface* cascade - = new G4GeneratorPrecompoundInterface(new CMSDummyDeexcitation()); + G4GeneratorPrecompoundInterface* cascade = new G4GeneratorPrecompoundInterface(new CMSDummyDeexcitation()); theLund = new G4LundStringFragmentation(); theStringDecay = new G4ExcitedStringDecay(theLund); theStringModel->SetFragmentationModel(theStringDecay); @@ -176,13 +226,13 @@ NuclearInteractionFTFSimulator::NuclearInteractionFTFSimulator( theHadronicModel->SetHighEnergyGenerator(theStringModel); theHadronicModel->SetMinEnergy(theEnergyLimit); - // Bertini Cascade + // Bertini Cascade theBertiniCascade = new G4CascadeInterface(); theDiffuseElastic = new G4DiffuseElastic(); // Geant4 particles and cross sections - std::call_once(initializeOnce, [] () { + std::call_once(initializeOnce, []() { theG4Hadron[0] = G4Proton::Proton(); theG4Hadron[1] = G4Neutron::Neutron(); theG4Hadron[2] = G4PionPlus::PionPlus(); @@ -193,43 +243,43 @@ NuclearInteractionFTFSimulator::NuclearInteractionFTFSimulator( theG4Hadron[7] = G4KaonZeroShort::KaonZeroShort(); theG4Hadron[8] = G4KaonZero::KaonZero(); theG4Hadron[9] = G4AntiKaonZero::AntiKaonZero(); - theG4Hadron[10]= G4Lambda::Lambda(); - theG4Hadron[11]= G4OmegaMinus::OmegaMinus(); - theG4Hadron[12]= G4SigmaMinus::SigmaMinus(); - theG4Hadron[13]= G4SigmaPlus::SigmaPlus(); - theG4Hadron[14]= G4SigmaZero::SigmaZero(); - theG4Hadron[15]= G4XiMinus::XiMinus(); - theG4Hadron[16]= G4XiZero::XiZero(); - theG4Hadron[17]= G4AntiProton::AntiProton(); - theG4Hadron[18]= G4AntiNeutron::AntiNeutron(); - theG4Hadron[19]= G4AntiLambda::AntiLambda(); - theG4Hadron[20]= G4AntiOmegaMinus::AntiOmegaMinus(); - theG4Hadron[21]= G4AntiSigmaMinus::AntiSigmaMinus(); - theG4Hadron[22]= G4AntiSigmaPlus::AntiSigmaPlus(); - theG4Hadron[23]= G4AntiSigmaZero::AntiSigmaZero(); - theG4Hadron[24]= G4AntiXiMinus::AntiXiMinus(); - theG4Hadron[25]= G4AntiXiZero::AntiXiZero(); - theG4Hadron[26]= G4AntiAlpha::AntiAlpha(); - theG4Hadron[27]= G4AntiDeuteron::AntiDeuteron(); - theG4Hadron[28]= G4AntiTriton::AntiTriton(); - theG4Hadron[29]= G4AntiHe3::AntiHe3(); + theG4Hadron[10] = G4Lambda::Lambda(); + theG4Hadron[11] = G4OmegaMinus::OmegaMinus(); + theG4Hadron[12] = G4SigmaMinus::SigmaMinus(); + theG4Hadron[13] = G4SigmaPlus::SigmaPlus(); + theG4Hadron[14] = G4SigmaZero::SigmaZero(); + theG4Hadron[15] = G4XiMinus::XiMinus(); + theG4Hadron[16] = G4XiZero::XiZero(); + theG4Hadron[17] = G4AntiProton::AntiProton(); + theG4Hadron[18] = G4AntiNeutron::AntiNeutron(); + theG4Hadron[19] = G4AntiLambda::AntiLambda(); + theG4Hadron[20] = G4AntiOmegaMinus::AntiOmegaMinus(); + theG4Hadron[21] = G4AntiSigmaMinus::AntiSigmaMinus(); + theG4Hadron[22] = G4AntiSigmaPlus::AntiSigmaPlus(); + theG4Hadron[23] = G4AntiSigmaZero::AntiSigmaZero(); + theG4Hadron[24] = G4AntiXiMinus::AntiXiMinus(); + theG4Hadron[25] = G4AntiXiZero::AntiXiZero(); + theG4Hadron[26] = G4AntiAlpha::AntiAlpha(); + theG4Hadron[27] = G4AntiDeuteron::AntiDeuteron(); + theG4Hadron[28] = G4AntiTriton::AntiTriton(); + theG4Hadron[29] = G4AntiHe3::AntiHe3(); // other Geant4 particles G4ParticleDefinition* ion = G4GenericIon::GenericIon(); ion->SetProcessManager(new G4ProcessManager(ion)); G4DecayPhysics decays; - decays.ConstructParticle(); + decays.ConstructParticle(); G4ParticleTable* partTable = G4ParticleTable::GetParticleTable(); partTable->SetVerboseLevel(0); partTable->SetReadiness(); - for(int i=0; iGetPDGEncoding(); } - }); + }); // local objects - vect = new G4PhysicsLogVector(npoints-1,100*MeV,TeV); + vect = new G4PhysicsLogVector(npoints - 1, 100 * MeV, TeV); intLengthElastic = intLengthInelastic = 0.0; currIdx = 0; index = 0; @@ -245,228 +295,222 @@ NuclearInteractionFTFSimulator::NuclearInteractionFTFSimulator( } NuclearInteractionFTFSimulator::~NuclearInteractionFTFSimulator() { - delete theStringDecay; delete theStringModel; delete theLund; delete vect; } -void NuclearInteractionFTFSimulator::compute(ParticlePropagator& Particle, - RandomEngineAndDistribution const* random) -{ - //std::cout << "#### Primary " << Particle.particle().pid() << " E(GeV)= " +void NuclearInteractionFTFSimulator::compute(ParticlePropagator& Particle, RandomEngineAndDistribution const* random) { + //std::cout << "#### Primary " << Particle.particle().pid() << " E(GeV)= " // << Particle.particle().momentum().e() << std::endl; - int thePid = Particle.particle().pid(); - if(thePid != theId[currIdx]) { + int thePid = Particle.particle().pid(); + if (thePid != theId[currIdx]) { currParticle = nullptr; currIdx = 0; - for(; currIdxflatShoot() > 0.5) { currParticle = theG4Hadron[10]; } - } - break; + for (; currIdx < numHadrons; ++currIdx) { + if (theId[currIdx] == thePid) { + currParticle = theG4Hadron[currIdx]; + // neutral kaons + if (7 == currIdx || 8 == currIdx) { + currParticle = theG4Hadron[9]; + if (random->flatShoot() > 0.5) { + currParticle = theG4Hadron[10]; + } + } + break; } } } - if(!currParticle) { return; } + if (!currParticle) { + return; + } // fill projectile for Geant4 double mass = currParticle->GetPDGMass(); - double ekin = CLHEP::GeV*Particle.particle().momentum().e() - mass; + double ekin = CLHEP::GeV * Particle.particle().momentum().e() - mass; // check interaction length - intLengthElastic = nuclElLength[currIdx]; + intLengthElastic = nuclElLength[currIdx]; intLengthInelastic = nuclInelLength[currIdx]; - if(0.0 == intLengthInelastic) { return; } + if (0.0 == intLengthInelastic) { + return; + } // apply corrections - if(ekin <= vect->Energy(0)) { - intLengthElastic *= corrfactors_el[currIdx][0]; + if (ekin <= vect->Energy(0)) { + intLengthElastic *= corrfactors_el[currIdx][0]; intLengthInelastic *= corrfactors_inel[currIdx][0]; - } else if(ekin < vect->Energy(npoints-1)) { + } else if (ekin < vect->Energy(npoints - 1)) { index = vect->FindBin(ekin, index); double e1 = vect->Energy(index); - double e2 = vect->Energy(index+1); - intLengthElastic *= ((corrfactors_el[currIdx][index]*(e2 - ekin) + - corrfactors_el[currIdx][index+1]*(ekin - e1))/(e2 - e1)); - intLengthInelastic *= ((corrfactors_inel[currIdx][index]*(e2 - ekin) + - corrfactors_inel[currIdx][index+1]*(ekin - e1))/(e2 - e1)); + double e2 = vect->Energy(index + 1); + intLengthElastic *= + ((corrfactors_el[currIdx][index] * (e2 - ekin) + corrfactors_el[currIdx][index + 1] * (ekin - e1)) / (e2 - e1)); + intLengthInelastic *= + ((corrfactors_inel[currIdx][index] * (e2 - ekin) + corrfactors_inel[currIdx][index + 1] * (ekin - e1)) / + (e2 - e1)); } /* std::cout << " Primary " << currParticle->GetParticleName() << " E(GeV)= " << e*fact << std::endl; */ - double currInteractionLength = -G4Log(random->flatShoot())*intLengthElastic*intLengthInelastic - /(intLengthElastic + intLengthInelastic); + double currInteractionLength = + -G4Log(random->flatShoot()) * intLengthElastic * intLengthInelastic / (intLengthElastic + intLengthInelastic); /* std::cout << "*NuclearInteractionFTFSimulator::compute: R(X0)= " << radLengths << " Rnuc(X0)= " << theNuclIntLength[currIdx] << " IntLength(X0)= " << currInteractionLength << std::endl; */ // Check position of nuclear interaction - if (currInteractionLength > radLengths) { return; } + if (currInteractionLength > radLengths) { + return; + } // fill projectile for Geant4 double px = Particle.particle().momentum().px(); double py = Particle.particle().momentum().py(); double pz = Particle.particle().momentum().pz(); - double ptot = sqrt(px*px + py*py + pz*pz); - double norm = 1./ptot; - G4ThreeVector dir(px*norm, py*norm, pz*norm); + double ptot = sqrt(px * px + py * py + pz * pz); + double norm = 1. / ptot; + G4ThreeVector dir(px * norm, py * norm, pz * norm); /* std::cout << " Primary " << currParticle->GetParticleName() << " E(GeV)= " << e*fact << " P(GeV/c)= (" << px << " " << py << " " << pz << ")" << std::endl; */ - G4DynamicParticle* dynParticle = new G4DynamicParticle(theG4Hadron[currIdx],dir,ekin); + G4DynamicParticle* dynParticle = new G4DynamicParticle(theG4Hadron[currIdx], dir, ekin); currTrack = new G4Track(dynParticle, 0.0, vectProj); currTrack->SetStep(dummyStep); - theProjectile.Initialise(*currTrack); + theProjectile.Initialise(*currTrack); delete currTrack; G4HadFinalState* result; // elastic interaction - if(random->flatShoot()*(intLengthElastic + intLengthInelastic) > intLengthElastic) { - + if (random->flatShoot() * (intLengthElastic + intLengthInelastic) > intLengthElastic) { result = theDiffuseElastic->ApplyYourself(theProjectile, targetNucleus); G4ThreeVector dirnew = result->GetMomentumChange().unit(); - double cost = (dir*dirnew); - double sint = std::sqrt((1. - cost)*(1. + cost)); + double cost = (dir * dirnew); + double sint = std::sqrt((1. - cost) * (1. + cost)); - curr4Mom.set(ptot*dirnew.x(),ptot*dirnew.y(),ptot*dirnew.z(),Particle.particle().momentum().e()); + curr4Mom.set(ptot * dirnew.x(), ptot * dirnew.y(), ptot * dirnew.z(), Particle.particle().momentum().e()); - // Always create a daughter if the kink is large engough - if (sint > theDistCut) { - saveDaughter(Particle, curr4Mom, thePid); + // Always create a daughter if the kink is large engough + if (sint > theDistCut) { + saveDaughter(Particle, curr4Mom, thePid); } else { Particle.particle().setMomentum(curr4Mom.px(), curr4Mom.py(), curr4Mom.pz(), curr4Mom.e()); } // inelastic interaction } else { - // Bertini cascade for low-energy hadrons (except light anti-nuclei) - // FTFP is applied above energy limit and for all anti-hyperons and anti-ions - if(ekin <= theBertiniLimit && currIdx < 17) { + // FTFP is applied above energy limit and for all anti-hyperons and anti-ions + if (ekin <= theBertiniLimit && currIdx < 17) { result = theBertiniCascade->ApplyYourself(theProjectile, targetNucleus); } else { result = theHadronicModel->ApplyYourself(theProjectile, targetNucleus); } - if(result) { - + if (result) { int nsec = result->GetNumberOfSecondaries(); - if(0 < nsec) { - - result->SetTrafoToLab(theProjectile.GetTrafoToLab()); - _theUpdatedState.clear(); - - //std::cout << " " << nsec << " secondaries" << std::endl; - // Generate angle - double phi = random->flatShoot()*CLHEP::twopi; - theClosestChargedDaughterId = -1; - distMin = 1e99; - - // rotate and store secondaries - for (int j=0; jGetSecondary(j)->GetParticle(); - int thePid = dp->GetParticleDefinition()->GetPDGEncoding(); - - // rotate around primary direction - curr4Mom = dp->Get4Momentum(); - curr4Mom.rotate(phi, vectProj); - curr4Mom *= result->GetTrafoToLab(); - /* + if (0 < nsec) { + result->SetTrafoToLab(theProjectile.GetTrafoToLab()); + _theUpdatedState.clear(); + + //std::cout << " " << nsec << " secondaries" << std::endl; + // Generate angle + double phi = random->flatShoot() * CLHEP::twopi; + theClosestChargedDaughterId = -1; + distMin = 1e99; + + // rotate and store secondaries + for (int j = 0; j < nsec; ++j) { + const G4DynamicParticle* dp = result->GetSecondary(j)->GetParticle(); + int thePid = dp->GetParticleDefinition()->GetPDGEncoding(); + + // rotate around primary direction + curr4Mom = dp->Get4Momentum(); + curr4Mom.rotate(phi, vectProj); + curr4Mom *= result->GetTrafoToLab(); + /* std::cout << j << ". " << dp->GetParticleDefinition()->GetParticleName() << " " << thePid << " " << curr4Mom*fact << std::endl; */ - // prompt 2-gamma decay for pi0, eta, eta'p - if(111 == thePid || 221 == thePid || 331 == thePid) { - theBoost = curr4Mom.boostVector(); - double e = 0.5*dp->GetParticleDefinition()->GetPDGMass(); - double fi = random->flatShoot()*CLHEP::twopi; - double cth = 2*random->flatShoot() - 1.0; - double sth = sqrt((1.0 - cth)*(1.0 + cth)); - G4LorentzVector lv(e*sth*cos(fi),e*sth*sin(fi),e*cth,e); - lv.boost(theBoost); - saveDaughter(Particle, lv, 22); - curr4Mom -= lv; - if(curr4Mom.e() > theEnergyLimit) { - saveDaughter(Particle, curr4Mom, 22); - } - } else { - if(curr4Mom.e() > theEnergyLimit + dp->GetParticleDefinition()->GetPDGMass()) { - saveDaughter(Particle, curr4Mom, thePid); - } - } - } - result->Clear(); + // prompt 2-gamma decay for pi0, eta, eta'p + if (111 == thePid || 221 == thePid || 331 == thePid) { + theBoost = curr4Mom.boostVector(); + double e = 0.5 * dp->GetParticleDefinition()->GetPDGMass(); + double fi = random->flatShoot() * CLHEP::twopi; + double cth = 2 * random->flatShoot() - 1.0; + double sth = sqrt((1.0 - cth) * (1.0 + cth)); + G4LorentzVector lv(e * sth * cos(fi), e * sth * sin(fi), e * cth, e); + lv.boost(theBoost); + saveDaughter(Particle, lv, 22); + curr4Mom -= lv; + if (curr4Mom.e() > theEnergyLimit) { + saveDaughter(Particle, curr4Mom, 22); + } + } else { + if (curr4Mom.e() > theEnergyLimit + dp->GetParticleDefinition()->GetPDGMass()) { + saveDaughter(Particle, curr4Mom, thePid); + } + } + } + result->Clear(); } } } } -void NuclearInteractionFTFSimulator::saveDaughter(ParticlePropagator& Particle, - const G4LorentzVector& lv, int pdgid) -{ - unsigned int idx = _theUpdatedState.size(); - _theUpdatedState.emplace_back(makeParticle(Particle.particleDataTable(), - pdgid, - XYZTLorentzVector{lv.px()*fact,lv.py()*fact,lv.pz()*fact,lv.e()*fact}, - Particle.particle().vertex())); - - // Store the closest daughter index (for later tracking purposes, so charged particles only) - double distance = distanceToPrimary(Particle.particle(),_theUpdatedState[idx]); +void NuclearInteractionFTFSimulator::saveDaughter(ParticlePropagator& Particle, const G4LorentzVector& lv, int pdgid) { + unsigned int idx = _theUpdatedState.size(); + _theUpdatedState.emplace_back( + makeParticle(Particle.particleDataTable(), + pdgid, + XYZTLorentzVector{lv.px() * fact, lv.py() * fact, lv.pz() * fact, lv.e() * fact}, + Particle.particle().vertex())); + + // Store the closest daughter index (for later tracking purposes, so charged particles only) + double distance = distanceToPrimary(Particle.particle(), _theUpdatedState[idx]); // Find the closest daughter, if closer than a given upper limit. - if ( distance < distMin && distance < theDistCut ) { + if (distance < distMin && distance < theDistCut) { distMin = distance; theClosestChargedDaughterId = idx; } // std::cout << _theUpdatedState[idx] << std::endl; } -double -NuclearInteractionFTFSimulator::distanceToPrimary(const RawParticle& Particle, - const RawParticle& aDaughter) const -{ +double NuclearInteractionFTFSimulator::distanceToPrimary(const RawParticle& Particle, + const RawParticle& aDaughter) const { double distance = 2E99; // Compute the distance only for charged primaries - if ( fabs(Particle.charge()) > 1E-6 ) { - + if (fabs(Particle.charge()) > 1E-6) { // The secondary must have the same charge - double chargeDiff = fabs(aDaughter.charge()-Particle.charge()); - if ( fabs(chargeDiff) < 1E-6 ) { - + double chargeDiff = fabs(aDaughter.charge() - Particle.charge()); + if (fabs(chargeDiff) < 1E-6) { // Here are two distance definitions * to be tuned * - switch ( theDistAlgo ) { - - case 1: - // sin(theta12) - distance = (aDaughter.Vect().Unit().Cross(Particle.Vect().Unit())).R(); - break; - - case 2: - // sin(theta12) * p1/p2 - distance = (aDaughter.Vect().Cross(Particle.Vect())).R() - /aDaughter.Vect().Mag2(); - break; - - default: - // Should not happen - break; + switch (theDistAlgo) { + case 1: + // sin(theta12) + distance = (aDaughter.Vect().Unit().Cross(Particle.Vect().Unit())).R(); + break; + + case 2: + // sin(theta12) * p1/p2 + distance = (aDaughter.Vect().Cross(Particle.Vect())).R() / aDaughter.Vect().Mag2(); + break; + + default: + // Should not happen + break; } } - } + } return distance; } diff --git a/FastSimulation/MaterialEffects/src/NuclearInteractionSimulator.cc b/FastSimulation/MaterialEffects/src/NuclearInteractionSimulator.cc index c437d2a2f39e2..79ae3f1f412b2 100644 --- a/FastSimulation/MaterialEffects/src/NuclearInteractionSimulator.cc +++ b/FastSimulation/MaterialEffects/src/NuclearInteractionSimulator.cc @@ -22,48 +22,45 @@ // vectors/variable not only for pions but for all type of hadrons // treated inside this code -NuclearInteractionSimulator::NuclearInteractionSimulator( - std::vector& hadronEnergies, - std::vector& hadronTypes, - std::vector& hadronNames, - std::vector& hadronMasses, - std::vector& hadronPMin, - double pionEnergy, - std::vector& lengthRatio, - std::vector< std::vector >& ratios, - std::map& idMap, - std::string inputFile, - unsigned int distAlgo, - double distCut) - : - MaterialEffectsSimulator(), - thePionEN(hadronEnergies), - thePionID(hadronTypes), - thePionNA(hadronNames), - thePionMA(hadronMasses), - thePionPMin(hadronPMin), - thePionEnergy(pionEnergy), - theLengthRatio(lengthRatio), - theRatios(ratios), - theIDMap(idMap), - theDistAlgo(distAlgo), - theDistCut(distCut), - currentValuesWereSet(false) -{ +NuclearInteractionSimulator::NuclearInteractionSimulator(std::vector& hadronEnergies, + std::vector& hadronTypes, + std::vector& hadronNames, + std::vector& hadronMasses, + std::vector& hadronPMin, + double pionEnergy, + std::vector& lengthRatio, + std::vector >& ratios, + std::map& idMap, + std::string inputFile, + unsigned int distAlgo, + double distCut) + : MaterialEffectsSimulator(), + thePionEN(hadronEnergies), + thePionID(hadronTypes), + thePionNA(hadronNames), + thePionMA(hadronMasses), + thePionPMin(hadronPMin), + thePionEnergy(pionEnergy), + theLengthRatio(lengthRatio), + theRatios(ratios), + theIDMap(idMap), + theDistAlgo(distAlgo), + theDistCut(distCut), + currentValuesWereSet(false) { std::string fullPath; // Prepare the map of files // Loop over the particle names - TFile* aVFile=nullptr; - std::vector aVTree(thePionEN.size(),static_cast(nullptr)); - std::vector aVBranch(thePionEN.size(),static_cast(nullptr)); - std::vector aVNUEvents(thePionEN.size(),static_cast(nullptr)); - std::vector aVCurrentEntry(thePionEN.size(),static_cast(0)); - std::vector aVCurrentInteraction(thePionEN.size(),static_cast(0)); - std::vector aVNumberOfEntries(thePionEN.size(),static_cast(0)); - std::vector aVNumberOfInteractions(thePionEN.size(),static_cast(0)); - std::vector aVFileName(thePionEN.size(),static_cast("")); - std::vector aVPionCM(thePionEN.size(),static_cast(0)); + TFile* aVFile = nullptr; + std::vector aVTree(thePionEN.size(), static_cast(nullptr)); + std::vector aVBranch(thePionEN.size(), static_cast(nullptr)); + std::vector aVNUEvents(thePionEN.size(), static_cast(nullptr)); + std::vector aVCurrentEntry(thePionEN.size(), static_cast(0)); + std::vector aVCurrentInteraction(thePionEN.size(), static_cast(0)); + std::vector aVNumberOfEntries(thePionEN.size(), static_cast(0)); + std::vector aVNumberOfInteractions(thePionEN.size(), static_cast(0)); + std::vector aVFileName(thePionEN.size(), static_cast("")); + std::vector aVPionCM(thePionEN.size(), static_cast(0)); theTrees.resize(thePionNA.size()); theBranches.resize(thePionNA.size()); @@ -75,7 +72,7 @@ NuclearInteractionSimulator::NuclearInteractionSimulator( theFileNames.resize(thePionNA.size()); thePionCM.resize(thePionNA.size()); theFile = aVFile; - for ( unsigned iname=0; inameread(inputFile); - if ( currentValuesWereSet ) - std::cout << "***WARNING*** You are reading nuclear-interaction information from the file " - << inputFile << " created in an earlier run." - << std::endl; + if (currentValuesWereSet) + std::cout << "***WARNING*** You are reading nuclear-interaction information from the file " << inputFile + << " created in an earlier run." << std::endl; // Open the file for saving the information of the current run - myOutputFile.open ("NuclearInteractionOutputFile.txt"); + myOutputFile.open("NuclearInteractionOutputFile.txt"); myOutputBuffer = 0; - // Open the root files // for ( unsigned file=0; fileGet(treeName.c_str()); - if ( !theTrees[iname][iene] ) throw cms::Exception("FastSimulation/MaterialEffects") - << "Tree with name " << treeName << " not found "; + theTrees[iname][iene] = (TTree*)theFile->Get(treeName.c_str()); + if (!theTrees[iname][iene]) + throw cms::Exception("FastSimulation/MaterialEffects") << "Tree with name " << treeName << " not found "; // theBranches[iname][iene] = theTrees[iname][iene]->GetBranch("nuEvent"); //std::cout << "The branch = " << theBranches[iname][iene] << std::endl; - if ( !theBranches[iname][iene] ) throw cms::Exception("FastSimulation/MaterialEffects") - << "Branch with name nuEvent not found in " << theFileNames[iname][iene]; + if (!theBranches[iname][iene]) + throw cms::Exception("FastSimulation/MaterialEffects") + << "Branch with name nuEvent not found in " << theFileNames[iname][iene]; // theNUEvents[iname][iene] = new NUEvent(); //std::cout << "The branch = " << theBranches[iname][iene] << std::endl; @@ -134,7 +130,7 @@ NuclearInteractionSimulator::NuclearInteractionSimulator( // theNumberOfEntries[iname][iene] = theTrees[iname][iene]->GetEntries(); - if(currentValuesWereSet) { + if (currentValuesWereSet) { theTrees[iname][iene]->GetEntry(theCurrentEntry[iname][iene]); unsigned NInteractions = theNUEvents[iname][iene]->nInteractions(); theNumberOfInteractions[iname][iene] = NInteractions; @@ -142,51 +138,44 @@ NuclearInteractionSimulator::NuclearInteractionSimulator( // // Compute the corresponding cm energies of the nuclear interactions - XYZTLorentzVector Proton(0.,0.,0.,0.986); - XYZTLorentzVector - Reference(0., - 0., - std::sqrt(thePionEN[iene]*thePionEN[iene] - -thePionMA[iname]*thePionMA[iname]), - thePionEN[iene]); - thePionCM[iname][iene] = (Reference+Proton).M(); - + XYZTLorentzVector Proton(0., 0., 0., 0.986); + XYZTLorentzVector Reference( + 0., 0., std::sqrt(thePionEN[iene] * thePionEN[iene] - thePionMA[iname] * thePionMA[iname]), thePionEN[iene]); + thePionCM[iname][iene] = (Reference + Proton).M(); } - } // Find the index for which EN = 4. (or thereabout) ien4 = 0; - while ( thePionEN[ien4] < 4.0 ) ++ien4; + while (thePionEN[ien4] < 4.0) + ++ien4; gROOT->cd(); // Information (Should be on LogInfo) -// std::cout << " ---> A total of " << fileNb -// << " nuclear-interaction files was sucessfully open" << std::endl; + // std::cout << " ---> A total of " << fileNb + // << " nuclear-interaction files was sucessfully open" << std::endl; // dbe = edm::Service().operator->(); // htot = dbe->book1D("Total", "All particles",150,0.,150.); // helas = dbe->book1D("Elastic", "Elastic interactions",150,0.,150.); // hinel = dbe->book1D("Inelastic", "Inelastic interactions",150,0.,150.); - // hscatter = dbe->book1D("Scattering","Elastic Scattering angle",200,0.,2.); - // hscatter2 = dbe->book2D("Scattering2","Elastic Scattering angle vs p",100,0.,10.,200,0.,2.); - // hAfter = dbe->book1D("eAfter","Energy after collision",200,0.,4.); - // hAfter2 = dbe->book2D("eAfter2","Energy after collision",100,-2.5,2.5,100,0.,4); - // hAfter3 = dbe->book2D("eAfter3","Energy after collision",100,0.,1000.,100,0.,4); - + // hscatter = dbe->book1D("Scattering","Elastic Scattering angle",200,0.,2.); + // hscatter2 = dbe->book2D("Scattering2","Elastic Scattering angle vs p",100,0.,10.,200,0.,2.); + // hAfter = dbe->book1D("eAfter","Energy after collision",200,0.,4.); + // hAfter2 = dbe->book2D("eAfter2","Energy after collision",100,-2.5,2.5,100,0.,4); + // hAfter3 = dbe->book2D("eAfter3","Energy after collision",100,0.,1000.,100,0.,4); } NuclearInteractionSimulator::~NuclearInteractionSimulator() { - // Close all local files - // Among other things, this allows the TROOT destructor to end up + // Among other things, this allows the TROOT destructor to end up // without crashing, while trying to close these files from outside theFile->Close(); delete theFile; - for(auto& vEvents: theNUEvents) { - for(auto evtPtr: vEvents) { + for (auto& vEvents : theNUEvents) { + for (auto evtPtr : vEvents) { delete evtPtr; } } @@ -195,42 +184,39 @@ NuclearInteractionSimulator::~NuclearInteractionSimulator() { myOutputFile.close(); // dbe->save("test.root"); - } -void NuclearInteractionSimulator::compute(ParticlePropagator& Particle, RandomEngineAndDistribution const* random) -{ - if(!currentValuesWereSet) { +void NuclearInteractionSimulator::compute(ParticlePropagator& Particle, RandomEngineAndDistribution const* random) { + if (!currentValuesWereSet) { currentValuesWereSet = true; - for ( unsigned iname=0; inameflatShoot()); + for (unsigned iname = 0; iname < thePionNA.size(); ++iname) { + for (unsigned iene = 0; iene < thePionEN.size(); ++iene) { + theCurrentEntry[iname][iene] = (unsigned)(theNumberOfEntries[iname][iene] * random->flatShoot()); theTrees[iname][iene]->GetEntry(theCurrentEntry[iname][iene]); unsigned NInteractions = theNUEvents[iname][iene]->nInteractions(); theNumberOfInteractions[iname][iene] = NInteractions; - theCurrentInteraction[iname][iene] = (unsigned) (theNumberOfInteractions[iname][iene] * random->flatShoot()); + theCurrentInteraction[iname][iene] = (unsigned)(theNumberOfInteractions[iname][iene] * random->flatShoot()); } } } // Read a Nuclear Interaction in a random manner - double pHadron = std::sqrt(Particle.particle().Vect().Mag2()); + double pHadron = std::sqrt(Particle.particle().Vect().Mag2()); // htot->Fill(pHadron); // The hadron has enough momentum to create some relevant final state - if ( pHadron > thePionEnergy ) { - + if (pHadron > thePionEnergy) { // The particle type - std::map::const_iterator thePit = theIDMap.find(Particle.particle().pid()); - - int thePid = thePit != theIDMap.end() ? thePit->second : Particle.particle().pid(); + std::map::const_iterator thePit = theIDMap.find(Particle.particle().pid()); + + int thePid = thePit != theIDMap.end() ? thePit->second : Particle.particle().pid(); // Is this particle type foreseen? unsigned fPid = abs(thePid); - if ( fPid != 211 && fPid != 130 && fPid != 321 && fPid != 2112 && fPid != 2212 ) { + if (fPid != 211 && fPid != 130 && fPid != 321 && fPid != 2112 && fPid != 2212) { return; //std::cout << "Unknown particle type = " << thePid << std::endl; //thePid = 211; @@ -242,259 +228,243 @@ void NuclearInteractionSimulator::compute(ParticlePropagator& Particle, RandomEn // The elastic interaction length // The baroque parameterization is a fit to Fig. 40.13 of the PDG - double ee = pHadron > 0.6 ? - exp(-std::sqrt((pHadron-0.6)/1.122)) : exp(std::sqrt((0.6-pHadron)/1.122)); - double theElasticLength = ( 0.8753 * ee + 0.15 ) - // double theElasticLength = ( 0.15 + 0.195 / log(pHadron/0.4) ) - // double theElasticLength = ( 0.15 + 0.305 / log(pHadron/0.35) ) - * theInelasticLength; + double ee = pHadron > 0.6 ? exp(-std::sqrt((pHadron - 0.6) / 1.122)) : exp(std::sqrt((0.6 - pHadron) / 1.122)); + double theElasticLength = (0.8753 * ee + 0.15) + // double theElasticLength = ( 0.15 + 0.195 / log(pHadron/0.4) ) + // double theElasticLength = ( 0.15 + 0.305 / log(pHadron/0.35) ) + * theInelasticLength; // The total interaction length double theTotalInteractionLength = theInelasticLength + theElasticLength; // Probability to interact is dl/L0 (maximum for 4 GeV pion) double aNuclInteraction = -std::log(random->flatShoot()); - if ( aNuclInteraction < theTotalInteractionLength ) { - + if (aNuclInteraction < theTotalInteractionLength) { // The elastic part double elastic = random->flatShoot(); - if ( elastic < theElasticLength/theTotalInteractionLength ) { - - // helas->Fill(pHadron); - - // Characteristic scattering angle for the elastic part - double theta0 = std::sqrt(3.)/ std::pow(theA(),1./3.) * Particle.particle().mass()/pHadron; - - // Draw an angle with theta/theta0*exp[(-theta/2theta0)**2] shape - double theta = theta0 * std::sqrt(-2.*std::log(random->flatShoot())); - double phi = 2. * 3.14159265358979323 * random->flatShoot(); - - // Rotate the particle accordingly - RawParticle::Rotation rotation1(orthogonal(Particle.particle().Vect()),theta); - RawParticle::Rotation rotation2(Particle.particle().Vect(),phi); - Particle.particle().rotate(rotation1); - Particle.particle().rotate(rotation2); - - // Distance - double distance = std::sin(theta); - - // Create a daughter if the kink is large engough - if ( distance > theDistCut ) { - _theUpdatedState.reserve(1); + if (elastic < theElasticLength / theTotalInteractionLength) { + // helas->Fill(pHadron); + + // Characteristic scattering angle for the elastic part + double theta0 = std::sqrt(3.) / std::pow(theA(), 1. / 3.) * Particle.particle().mass() / pHadron; + + // Draw an angle with theta/theta0*exp[(-theta/2theta0)**2] shape + double theta = theta0 * std::sqrt(-2. * std::log(random->flatShoot())); + double phi = 2. * 3.14159265358979323 * random->flatShoot(); + + // Rotate the particle accordingly + RawParticle::Rotation rotation1(orthogonal(Particle.particle().Vect()), theta); + RawParticle::Rotation rotation2(Particle.particle().Vect(), phi); + Particle.particle().rotate(rotation1); + Particle.particle().rotate(rotation2); + + // Distance + double distance = std::sin(theta); + + // Create a daughter if the kink is large engough + if (distance > theDistCut) { + _theUpdatedState.reserve(1); _theUpdatedState.clear(); - _theUpdatedState.emplace_back(Particle.particle()); - } + _theUpdatedState.emplace_back(Particle.particle()); + } - // hscatter->Fill(myTheta); - // hscatter2->Fill(pHadron,myTheta); - - } + // hscatter->Fill(myTheta); + // hscatter2->Fill(pHadron,myTheta); + + } // The inelastic part else { - - // Avoid multiple map access - const std::vector& aPionCM = thePionCM[thePidIndex]; - const std::vector& aRatios = theRatios[thePidIndex]; - // Find the file with the closest c.m energy - // The target nucleon - XYZTLorentzVector Proton(0.,0.,0.,0.939); - // The current particle - const XYZTLorentzVector& Hadron = (const XYZTLorentzVector&)Particle; - // The smallest momentum for inelastic interactions - double pMin = thePionPMin[thePidIndex]; - // The correspong smallest four vector - XYZTLorentzVector Hadron0(0.,0.,pMin,std::sqrt(pMin*pMin+Particle.particle().M2())); - - // The current centre-of-mass energy - double ecm = (Proton+Hadron).M(); - //std::cout << "Proton = " << Proton << std::endl; - //std::cout << "Hadron = " << Hadron << std::endl; - //std::cout << "ecm = " << ecm << std::endl; - // Get the files of interest (closest c.m. energies) - unsigned ene1=0; - unsigned ene2=0; - // The smallest centre-of-mass energy - // double ecm1=1.63; - double ecm1= (Proton+Hadron0).M(); - //std::cout << "ecm1 = " << ecm1 << std::endl; - //std::cout << "ecm[0] = " << aPionCM[0] << std::endl; - //std::cout << "ecm[11] = " << aPionCM [ aPionCM.size()-1 ] << std::endl; - double ecm2=aPionCM[0]; - double ratio1=0.; - double ratio2=aRatios[0]; - if ( ecm > aPionCM[0] && ecm < aPionCM [ aPionCM.size()-1 ] ) { - for ( unsigned ene=1; - ene < aPionCM.size() && ecm > aPionCM[ene-1]; - ++ene ) { - if ( ecm aPionCM[ aPionCM.size()-1 ] ) { - ene1 = aPionCM.size()-1; - ene2 = aPionCM.size()-2; - ecm1 = aPionCM[ene1]; - ecm2 = aPionCM[ene2]; - ratio1 = aRatios[ene2]; - ratio2 = aRatios[ene2]; - } - - - // The inelastic part of the cross section depends cm energy - double slope = (std::log10(ecm )-std::log10(ecm1)) - / (std::log10(ecm2)-std::log10(ecm1)); - double inelastic = ratio1 + (ratio2-ratio1) * slope; - double inelastic4 = pHadron < 4. ? aRatios[ien4] : 1.; - - //std::cout << "Inelastic = " << ratio1 << " " << ratio2 << " " << inelastic << std::endl; - // std::cout << "Energy/Inelastic : " - // << Hadron.e() << " " << inelastic << std::endl; - - // Simulate an inelastic interaction - if ( elastic > 1.- (inelastic*theInelasticLength) - /theTotalInteractionLength ) { - - // Avoid mutliple map access - std::vector& aCurrentInteraction = theCurrentInteraction[thePidIndex]; - std::vector& aNumberOfInteractions = theNumberOfInteractions[thePidIndex]; - std::vector& aNUEvents = theNUEvents[thePidIndex]; - // hinel->Fill(pHadron); - // std::cout << "INELASTIC INTERACTION ! " - // << pHadron << " " << theInelasticLength << " " - // << inelastic * theInelasticLength << std::endl; - // Choice of the file to read according the the log10(ecm) distance - // and protection against low momentum proton and neutron that never interacts - // (i.e., empty files) - unsigned ene; - if ( random->flatShoot() < slope || aNumberOfInteractions[ene1] == 0 ) - ene = ene2; - else - ene = ene1; - - //std::cout << "Ecm1/2 = " << ecm1 << " " << ecm2 << std::endl; - //std::cout << "Ratio1/2 = " << ratio1 << " " << ratio2 << std::endl; - //std::cout << "Ene = " << ene << " slope = " << slope << std::endl; - - //std::cout << "Pion energy = " << Hadron.E() - // << "File chosen " << theFileNames[thePidIndex][ene] - // << std::endl; - - // The boost characteristics - XYZTLorentzVector theBoost = Proton + Hadron; - theBoost /= theBoost.e(); - - // std::cout << "File chosen : " << thePid << "/" << ene - // << " Current interaction = " << aCurrentInteraction[ene] - // << " Total interactions = " << aNumberOfInteractions[ene] - // << std::endl; - // theFiles[thePidIndex][ene]->cd(); - // gDirectory->ls(); - - // Check we are not either at the end of an interaction bunch - // or at the end of a file - if ( aCurrentInteraction[ene] == aNumberOfInteractions[ene] ) { - // std::cout << "End of interaction bunch ! "; - std::vector& aCurrentEntry = theCurrentEntry[thePidIndex]; - std::vector& aNumberOfEntries = theNumberOfEntries[thePidIndex]; - std::vector& aTrees = theTrees[thePidIndex]; - ++aCurrentEntry[ene]; - // std::cerr << "Read the next entry " - // << aCurrentEntry[ene] << std::endl; - aCurrentInteraction[ene] = 0; - if ( aCurrentEntry[ene] == aNumberOfEntries[ene] ) { - aCurrentEntry[ene] = 0; - // std::cout << "End of file - Rewind! " << std::endl; - } - unsigned myEntry = aCurrentEntry[ene]; - // std::cout << "The new entry " << myEntry - // << " is read ... in TTree " << aTrees[ene] << " "; - aTrees[ene]->GetEntry(myEntry); - // std::cout << "The number of interactions in the new entry is ... "; - aNumberOfInteractions[ene] = aNUEvents[ene]->nInteractions(); - // std::cout << aNumberOfInteractions[ene] << std::endl; - } - - // Read the interaction - NUEvent::NUInteraction anInteraction - = aNUEvents[ene]->theNUInteractions()[aCurrentInteraction[ene]]; - - unsigned firstTrack = anInteraction.first; - unsigned lastTrack = anInteraction.last; - // std::cout << "First and last tracks are " << firstTrack << " " << lastTrack << std::endl; - - _theUpdatedState.reserve(lastTrack-firstTrack+1); + // Avoid multiple map access + const std::vector& aPionCM = thePionCM[thePidIndex]; + const std::vector& aRatios = theRatios[thePidIndex]; + // Find the file with the closest c.m energy + // The target nucleon + XYZTLorentzVector Proton(0., 0., 0., 0.939); + // The current particle + const XYZTLorentzVector& Hadron = (const XYZTLorentzVector&)Particle; + // The smallest momentum for inelastic interactions + double pMin = thePionPMin[thePidIndex]; + // The correspong smallest four vector + XYZTLorentzVector Hadron0(0., 0., pMin, std::sqrt(pMin * pMin + Particle.particle().M2())); + + // The current centre-of-mass energy + double ecm = (Proton + Hadron).M(); + //std::cout << "Proton = " << Proton << std::endl; + //std::cout << "Hadron = " << Hadron << std::endl; + //std::cout << "ecm = " << ecm << std::endl; + // Get the files of interest (closest c.m. energies) + unsigned ene1 = 0; + unsigned ene2 = 0; + // The smallest centre-of-mass energy + // double ecm1=1.63; + double ecm1 = (Proton + Hadron0).M(); + //std::cout << "ecm1 = " << ecm1 << std::endl; + //std::cout << "ecm[0] = " << aPionCM[0] << std::endl; + //std::cout << "ecm[11] = " << aPionCM [ aPionCM.size()-1 ] << std::endl; + double ecm2 = aPionCM[0]; + double ratio1 = 0.; + double ratio2 = aRatios[0]; + if (ecm > aPionCM[0] && ecm < aPionCM[aPionCM.size() - 1]) { + for (unsigned ene = 1; ene < aPionCM.size() && ecm > aPionCM[ene - 1]; ++ene) { + if (ecm < aPionCM[ene]) { + ene2 = ene; + ene1 = ene2 - 1; + ecm1 = aPionCM[ene1]; + ecm2 = aPionCM[ene2]; + ratio1 = aRatios[ene1]; + ratio2 = aRatios[ene2]; + } + } + } else if (ecm > aPionCM[aPionCM.size() - 1]) { + ene1 = aPionCM.size() - 1; + ene2 = aPionCM.size() - 2; + ecm1 = aPionCM[ene1]; + ecm2 = aPionCM[ene2]; + ratio1 = aRatios[ene2]; + ratio2 = aRatios[ene2]; + } + + // The inelastic part of the cross section depends cm energy + double slope = (std::log10(ecm) - std::log10(ecm1)) / (std::log10(ecm2) - std::log10(ecm1)); + double inelastic = ratio1 + (ratio2 - ratio1) * slope; + double inelastic4 = pHadron < 4. ? aRatios[ien4] : 1.; + + //std::cout << "Inelastic = " << ratio1 << " " << ratio2 << " " << inelastic << std::endl; + // std::cout << "Energy/Inelastic : " + // << Hadron.e() << " " << inelastic << std::endl; + + // Simulate an inelastic interaction + if (elastic > 1. - (inelastic * theInelasticLength) / theTotalInteractionLength) { + // Avoid mutliple map access + std::vector& aCurrentInteraction = theCurrentInteraction[thePidIndex]; + std::vector& aNumberOfInteractions = theNumberOfInteractions[thePidIndex]; + std::vector& aNUEvents = theNUEvents[thePidIndex]; + // hinel->Fill(pHadron); + // std::cout << "INELASTIC INTERACTION ! " + // << pHadron << " " << theInelasticLength << " " + // << inelastic * theInelasticLength << std::endl; + // Choice of the file to read according the the log10(ecm) distance + // and protection against low momentum proton and neutron that never interacts + // (i.e., empty files) + unsigned ene; + if (random->flatShoot() < slope || aNumberOfInteractions[ene1] == 0) + ene = ene2; + else + ene = ene1; + + //std::cout << "Ecm1/2 = " << ecm1 << " " << ecm2 << std::endl; + //std::cout << "Ratio1/2 = " << ratio1 << " " << ratio2 << std::endl; + //std::cout << "Ene = " << ene << " slope = " << slope << std::endl; + + //std::cout << "Pion energy = " << Hadron.E() + // << "File chosen " << theFileNames[thePidIndex][ene] + // << std::endl; + + // The boost characteristics + XYZTLorentzVector theBoost = Proton + Hadron; + theBoost /= theBoost.e(); + + // std::cout << "File chosen : " << thePid << "/" << ene + // << " Current interaction = " << aCurrentInteraction[ene] + // << " Total interactions = " << aNumberOfInteractions[ene] + // << std::endl; + // theFiles[thePidIndex][ene]->cd(); + // gDirectory->ls(); + + // Check we are not either at the end of an interaction bunch + // or at the end of a file + if (aCurrentInteraction[ene] == aNumberOfInteractions[ene]) { + // std::cout << "End of interaction bunch ! "; + std::vector& aCurrentEntry = theCurrentEntry[thePidIndex]; + std::vector& aNumberOfEntries = theNumberOfEntries[thePidIndex]; + std::vector& aTrees = theTrees[thePidIndex]; + ++aCurrentEntry[ene]; + // std::cerr << "Read the next entry " + // << aCurrentEntry[ene] << std::endl; + aCurrentInteraction[ene] = 0; + if (aCurrentEntry[ene] == aNumberOfEntries[ene]) { + aCurrentEntry[ene] = 0; + // std::cout << "End of file - Rewind! " << std::endl; + } + unsigned myEntry = aCurrentEntry[ene]; + // std::cout << "The new entry " << myEntry + // << " is read ... in TTree " << aTrees[ene] << " "; + aTrees[ene]->GetEntry(myEntry); + // std::cout << "The number of interactions in the new entry is ... "; + aNumberOfInteractions[ene] = aNUEvents[ene]->nInteractions(); + // std::cout << aNumberOfInteractions[ene] << std::endl; + } + + // Read the interaction + NUEvent::NUInteraction anInteraction = aNUEvents[ene]->theNUInteractions()[aCurrentInteraction[ene]]; + + unsigned firstTrack = anInteraction.first; + unsigned lastTrack = anInteraction.last; + // std::cout << "First and last tracks are " << firstTrack << " " << lastTrack << std::endl; + + _theUpdatedState.reserve(lastTrack - firstTrack + 1); _theUpdatedState.clear(); - - double distMin = 1E99; - - // Some rotation around the boost axis, for more randomness - XYZVector theAxis = theBoost.Vect().Unit(); - double theAngle = random->flatShoot() * 2. * 3.14159265358979323; - RawParticle::Rotation axisRotation(theAxis,theAngle); - RawParticle::Boost axisBoost(theBoost.x(),theBoost.y(),theBoost.z()); - - // A rotation to bring the particles back to the pion direction - XYZVector zAxis(0.,0.,1.); - XYZVector orthAxis = (zAxis.Cross(theBoost.Vect())).Unit(); - double orthAngle = acos(theBoost.Vect().Unit().Z()); - RawParticle::Rotation orthRotation(orthAxis,orthAngle); - - // A few checks - // double eAfter = 0.; - - // Loop on the nuclear interaction products - for ( unsigned iTrack=firstTrack; iTrack<=lastTrack; ++iTrack ) { - - unsigned idaugh = iTrack - firstTrack; - NUEvent::NUParticle aParticle = aNUEvents[ene]->theNUParticles()[iTrack]; - // std::cout << "Track " << iTrack - // << " id/px/py/pz/mass " - // << aParticle.id << " " - // << aParticle.px << " " - // << aParticle.py << " " - // << aParticle.pz << " " - // << aParticle.mass << " " << endl; - - // Add a RawParticle with the proper energy in the c.m frame of - // the nuclear interaction - double energy = std::sqrt( aParticle.px*aParticle.px - + aParticle.py*aParticle.py - + aParticle.pz*aParticle.pz - + aParticle.mass*aParticle.mass/(ecm*ecm) ); - - RawParticle& aDaughter = _theUpdatedState.emplace_back(makeParticle(Particle.particleDataTable(), - aParticle.id, - XYZTLorentzVector( - aParticle.px*ecm,aParticle.py*ecm, - aParticle.pz*ecm,energy*ecm))); - // Rotate to the collision axis - aDaughter.rotate(orthRotation); - - // Rotate around the boost axis for more randomness - aDaughter.rotate(axisRotation); - - // Boost it in the lab frame - aDaughter.boost(axisBoost); - - // Store the closest daughter index (for later tracking purposes, so charged particles only) - double distance = distanceToPrimary(Particle.particle(),aDaughter); - // Find the closest daughter, if closer than a given upper limit. - if ( distance < distMin && distance < theDistCut ) { - distMin = distance; - theClosestChargedDaughterId = idaugh; - } - - // eAfter += aDaughter.E(); - - } - /* + double distMin = 1E99; + + // Some rotation around the boost axis, for more randomness + XYZVector theAxis = theBoost.Vect().Unit(); + double theAngle = random->flatShoot() * 2. * 3.14159265358979323; + RawParticle::Rotation axisRotation(theAxis, theAngle); + RawParticle::Boost axisBoost(theBoost.x(), theBoost.y(), theBoost.z()); + + // A rotation to bring the particles back to the pion direction + XYZVector zAxis(0., 0., 1.); + XYZVector orthAxis = (zAxis.Cross(theBoost.Vect())).Unit(); + double orthAngle = acos(theBoost.Vect().Unit().Z()); + RawParticle::Rotation orthRotation(orthAxis, orthAngle); + + // A few checks + // double eAfter = 0.; + + // Loop on the nuclear interaction products + for (unsigned iTrack = firstTrack; iTrack <= lastTrack; ++iTrack) { + unsigned idaugh = iTrack - firstTrack; + NUEvent::NUParticle aParticle = aNUEvents[ene]->theNUParticles()[iTrack]; + // std::cout << "Track " << iTrack + // << " id/px/py/pz/mass " + // << aParticle.id << " " + // << aParticle.px << " " + // << aParticle.py << " " + // << aParticle.pz << " " + // << aParticle.mass << " " << endl; + + // Add a RawParticle with the proper energy in the c.m frame of + // the nuclear interaction + double energy = std::sqrt(aParticle.px * aParticle.px + aParticle.py * aParticle.py + + aParticle.pz * aParticle.pz + aParticle.mass * aParticle.mass / (ecm * ecm)); + + RawParticle& aDaughter = _theUpdatedState.emplace_back(makeParticle( + Particle.particleDataTable(), + aParticle.id, + XYZTLorentzVector(aParticle.px * ecm, aParticle.py * ecm, aParticle.pz * ecm, energy * ecm))); + // Rotate to the collision axis + aDaughter.rotate(orthRotation); + + // Rotate around the boost axis for more randomness + aDaughter.rotate(axisRotation); + + // Boost it in the lab frame + aDaughter.boost(axisBoost); + + // Store the closest daughter index (for later tracking purposes, so charged particles only) + double distance = distanceToPrimary(Particle.particle(), aDaughter); + // Find the closest daughter, if closer than a given upper limit. + if (distance < distMin && distance < theDistCut) { + distMin = distance; + theClosestChargedDaughterId = idaugh; + } + + // eAfter += aDaughter.E(); + } + + /* double eBefore = Particle.E(); double rapid = Particle.momentum().Eta(); if ( eBefore > 0. ) { @@ -504,197 +474,164 @@ void NuclearInteractionSimulator::compute(ParticlePropagator& Particle, RandomEn } */ - // ERROR The way this loops through the events breaks - // replay. Which events are retrieved depends on - // which previous events were processed. - - // Increment for next time - ++aCurrentInteraction[ene]; - - // Simulate a stopping hadron (low momentum) - } else if ( pHadron < 4. && - elastic > 1.- (inelastic4*theInelasticLength) - /theTotalInteractionLength ) { - // A fake particle with 0 momentum as a daughter! - _theUpdatedState.reserve(1); - _theUpdatedState.clear(); - _theUpdatedState.emplace_back(makeParticle(Particle.particleDataTable(), - 22, XYZTLorentzVector(0.,0.,0.,0.))); - } + // ERROR The way this loops through the events breaks + // replay. Which events are retrieved depends on + // which previous events were processed. - } + // Increment for next time + ++aCurrentInteraction[ene]; + // Simulate a stopping hadron (low momentum) + } else if (pHadron < 4. && elastic > 1. - (inelastic4 * theInelasticLength) / theTotalInteractionLength) { + // A fake particle with 0 momentum as a daughter! + _theUpdatedState.reserve(1); + _theUpdatedState.clear(); + _theUpdatedState.emplace_back( + makeParticle(Particle.particleDataTable(), 22, XYZTLorentzVector(0., 0., 0., 0.))); + } + } } - } - } -double -NuclearInteractionSimulator::distanceToPrimary(const RawParticle& Particle, - const RawParticle& aDaughter) const { - +double NuclearInteractionSimulator::distanceToPrimary(const RawParticle& Particle, const RawParticle& aDaughter) const { double distance = 2E99; // Compute the distance only for charged primaries - if ( fabs(Particle.charge()) > 1E-12 ) { - + if (fabs(Particle.charge()) > 1E-12) { // The secondary must have the same charge - double chargeDiff = fabs(aDaughter.charge()-Particle.charge()); - if ( fabs(chargeDiff) < 1E-12 ) { - + double chargeDiff = fabs(aDaughter.charge() - Particle.charge()); + if (fabs(chargeDiff) < 1E-12) { // Here are two distance definitions * to be tuned * - switch ( theDistAlgo ) { - - case 1: - // sin(theta12) - distance = (aDaughter.Vect().Unit().Cross(Particle.Vect().Unit())).R(); - break; - - case 2: - // sin(theta12) * p1/p2 - distance = (aDaughter.Vect().Cross(Particle.Vect())).R() - /aDaughter.Vect().Mag2(); - break; - - default: - // Should not happen - distance = 2E99; - break; - + switch (theDistAlgo) { + case 1: + // sin(theta12) + distance = (aDaughter.Vect().Unit().Cross(Particle.Vect().Unit())).R(); + break; + + case 2: + // sin(theta12) * p1/p2 + distance = (aDaughter.Vect().Cross(Particle.Vect())).R() / aDaughter.Vect().Mag2(); + break; + + default: + // Should not happen + distance = 2E99; + break; } - } - } - - return distance; + return distance; } -void -NuclearInteractionSimulator::save() { - +void NuclearInteractionSimulator::save() { // Size of buffer ++myOutputBuffer; // Periodically close the current file and open a new one - if ( myOutputBuffer/1000*1000 == myOutputBuffer ) { + if (myOutputBuffer / 1000 * 1000 == myOutputBuffer) { myOutputFile.close(); - myOutputFile.open ("NuclearInteractionOutputFile.txt"); + myOutputFile.open("NuclearInteractionOutputFile.txt"); // myOutputFile.seekp(0); // No need to rewind in that case } // - unsigned size1 = - theCurrentEntry.size()* - theCurrentEntry.begin()->size(); + unsigned size1 = theCurrentEntry.size() * theCurrentEntry.begin()->size(); std::vector theCurrentEntries; theCurrentEntries.resize(size1); - size1*=sizeof(unsigned); + size1 *= sizeof(unsigned); // - unsigned size2 = - theCurrentInteraction.size()* - theCurrentInteraction.begin()->size(); + unsigned size2 = theCurrentInteraction.size() * theCurrentInteraction.begin()->size(); std::vector theCurrentInteractions; theCurrentInteractions.resize(size2); size2 *= sizeof(unsigned); - // Save the current entries - std::vector< std::vector >::const_iterator aCurrentEntry = theCurrentEntry.begin(); - std::vector< std::vector >::const_iterator lastCurrentEntry = theCurrentEntry.end(); - unsigned allEntries=0; - for ( ; aCurrentEntry!=lastCurrentEntry; ++aCurrentEntry ) { + // Save the current entries + std::vector >::const_iterator aCurrentEntry = theCurrentEntry.begin(); + std::vector >::const_iterator lastCurrentEntry = theCurrentEntry.end(); + unsigned allEntries = 0; + for (; aCurrentEntry != lastCurrentEntry; ++aCurrentEntry) { unsigned size = aCurrentEntry->size(); - for ( unsigned iene=0; iene >::const_iterator aCurrentInteraction = theCurrentInteraction.begin(); - std::vector< std::vector >::const_iterator lastCurrentInteraction = theCurrentInteraction.end(); - unsigned allInteractions=0; - for ( ; aCurrentInteraction!=lastCurrentInteraction; ++aCurrentInteraction ) { + std::vector >::const_iterator aCurrentInteraction = theCurrentInteraction.begin(); + std::vector >::const_iterator lastCurrentInteraction = theCurrentInteraction.end(); + unsigned allInteractions = 0; + for (; aCurrentInteraction != lastCurrentInteraction; ++aCurrentInteraction) { unsigned size = aCurrentInteraction->size(); - for ( unsigned iene=0; ienesize(); + unsigned size1 = theCurrentEntry.size() * theCurrentEntry.begin()->size(); std::vector theCurrentEntries; theCurrentEntries.resize(size1); - size1*=sizeof(unsigned); + size1 *= sizeof(unsigned); // - unsigned size2 = - theCurrentInteraction.size()* - theCurrentInteraction.begin()->size(); + unsigned size2 = theCurrentInteraction.size() * theCurrentInteraction.begin()->size(); std::vector theCurrentInteractions; theCurrentInteractions.resize(size2); size2 *= sizeof(unsigned); // unsigned size = 0; - // Open the file (if any) - myInputFile.open (inputFile.c_str()); - if ( myInputFile.is_open() ) { - + myInputFile.open(inputFile.c_str()); + if (myInputFile.is_open()) { // Get the size of the file - if ( stat(inputFile.c_str(), &results) == 0 ) size = results.st_size; - else return false; // Something is wrong with that file ! + if (stat(inputFile.c_str(), &results) == 0) + size = results.st_size; + else + return false; // Something is wrong with that file ! // Position the pointer just before the last record - myInputFile.seekg(size-size1-size2); - myInputFile.read((char*)(&theCurrentEntries.front()),size1); - myInputFile.read((char*)(&theCurrentInteractions.front()),size2); + myInputFile.seekg(size - size1 - size2); + myInputFile.read((char*)(&theCurrentEntries.front()), size1); + myInputFile.read((char*)(&theCurrentInteractions.front()), size2); myInputFile.close(); // Read the current entries - std::vector< std::vector >::iterator aCurrentEntry = theCurrentEntry.begin(); - std::vector< std::vector >::iterator lastCurrentEntry = theCurrentEntry.end(); - unsigned allEntries=0; - for ( ; aCurrentEntry!=lastCurrentEntry; ++aCurrentEntry ) { + std::vector >::iterator aCurrentEntry = theCurrentEntry.begin(); + std::vector >::iterator lastCurrentEntry = theCurrentEntry.end(); + unsigned allEntries = 0; + for (; aCurrentEntry != lastCurrentEntry; ++aCurrentEntry) { unsigned size = aCurrentEntry->size(); - for ( unsigned iene=0; iene >::iterator aCurrentInteraction = theCurrentInteraction.begin(); - std::vector< std::vector >::iterator lastCurrentInteraction = theCurrentInteraction.end(); - unsigned allInteractions=0; - for ( ; aCurrentInteraction!=lastCurrentInteraction; ++aCurrentInteraction ) { + std::vector >::iterator aCurrentInteraction = theCurrentInteraction.begin(); + std::vector >::iterator lastCurrentInteraction = theCurrentInteraction.end(); + unsigned allInteractions = 0; + for (; aCurrentInteraction != lastCurrentInteraction; ++aCurrentInteraction) { unsigned size = aCurrentInteraction->size(); - for ( unsigned iene=0; iene -PairProductionSimulator::PairProductionSimulator(double photonEnergyCut) -{ - // Set the minimal photon energy for possible conversion - photonEnergy = std::max(0.100,photonEnergyCut); +PairProductionSimulator::PairProductionSimulator(double photonEnergyCut) { + // Set the minimal photon energy for possible conversion + photonEnergy = std::max(0.100, photonEnergyCut); } -void -PairProductionSimulator::compute(ParticlePropagator& Particle, RandomEngineAndDistribution const* random) -{ - - double eGamma = Particle.particle().e(); +void PairProductionSimulator::compute(ParticlePropagator& Particle, RandomEngineAndDistribution const* random) { + double eGamma = Particle.particle().e(); // The photon has enough energy to create a pair - if ( eGamma>=photonEnergy ) { - + if (eGamma >= photonEnergy) { // This is a simple version (a la PDG) of a photon conversion generator. // It replaces the buggy GEANT3 -> C++ former version. // Author : Patrick Janot - 7-Jan-2004 // Probability to convert is 7/9*(dx/X0) - if ( -std::log(random->flatShoot()) <= (7./9.)*radLengths ) { - - double xe=0; - double xm=eMass()/eGamma; + if (-std::log(random->flatShoot()) <= (7. / 9.) * radLengths) { + double xe = 0; + double xm = eMass() / eGamma; double weight = 0.; - + // Generate electron energy between emass and eGamma-emass do { - xe = random->flatShoot()*(1.-2.*xm) + xm; - weight = 1. - 4./3.*xe*(1.-xe); - } while ( weight < random->flatShoot() ); - + xe = random->flatShoot() * (1. - 2. * xm) + xm; + weight = 1. - 4. / 3. * xe * (1. - xe); + } while (weight < random->flatShoot()); + double eElectron = xe * eGamma; - double tElectron = eElectron-eMass(); - double pElectron = std::sqrt(std::max((eElectron+eMass())*tElectron,0.)); + double tElectron = eElectron - eMass(); + double pElectron = std::sqrt(std::max((eElectron + eMass()) * tElectron, 0.)); + + double ePositron = eGamma - eElectron; + double tPositron = ePositron - eMass(); + double pPositron = std::sqrt((ePositron + eMass()) * tPositron); - double ePositron = eGamma-eElectron; - double tPositron = ePositron-eMass(); - double pPositron = std::sqrt((ePositron+eMass())*tPositron); - // Generate angles - double phi = random->flatShoot()*2.*M_PI; - double sphi = std::sin(phi); - double cphi = std::cos(phi); + double phi = random->flatShoot() * 2. * M_PI; + double sphi = std::sin(phi); + double cphi = std::cos(phi); double stheta1, stheta2, ctheta1, ctheta2; - if ( eElectron > ePositron ) { - double theta1 = gbteth(eElectron,eMass(),xe,random)*eMass()/eElectron; - stheta1 = std::sin(theta1); - ctheta1 = std::cos(theta1); - stheta2 = stheta1*pElectron/pPositron; - ctheta2 = std::sqrt(std::max(0.,1.0-(stheta2*stheta2))); + if (eElectron > ePositron) { + double theta1 = gbteth(eElectron, eMass(), xe, random) * eMass() / eElectron; + stheta1 = std::sin(theta1); + ctheta1 = std::cos(theta1); + stheta2 = stheta1 * pElectron / pPositron; + ctheta2 = std::sqrt(std::max(0., 1.0 - (stheta2 * stheta2))); } else { - double theta2 = gbteth(ePositron,eMass(),xe,random)*eMass()/ePositron; - stheta2 = std::sin(theta2); - ctheta2 = std::cos(theta2); - stheta1 = stheta2*pPositron/pElectron; - ctheta1 = std::sqrt(std::max(0.,1.0-(stheta1*stheta1))); + double theta2 = gbteth(ePositron, eMass(), xe, random) * eMass() / ePositron; + stheta2 = std::sin(theta2); + ctheta2 = std::cos(theta2); + stheta1 = stheta2 * pPositron / pElectron; + ctheta1 = std::sqrt(std::max(0., 1.0 - (stheta1 * stheta1))); } - - + double chi = Particle.particle().theta(); double psi = Particle.particle().phi(); RawParticle::RotationZ rotZ(psi); RawParticle::RotationY rotY(chi); - + _theUpdatedState.reserve(2); _theUpdatedState.clear(); // The electron - _theUpdatedState.emplace_back( - makeParticle(Particle.particleDataTable(), - +11,XYZTLorentzVector(pElectron*stheta1*cphi, - pElectron*stheta1*sphi, - pElectron*ctheta1, - eElectron) )); + _theUpdatedState.emplace_back(makeParticle( + Particle.particleDataTable(), + +11, + XYZTLorentzVector(pElectron * stheta1 * cphi, pElectron * stheta1 * sphi, pElectron * ctheta1, eElectron))); _theUpdatedState[0].rotate(rotY); _theUpdatedState[0].rotate(rotZ); - + // The positron - _theUpdatedState.emplace_back( - makeParticle(Particle.particleDataTable(), - -11,XYZTLorentzVector(-pPositron*stheta2*cphi, - -pPositron*stheta2*sphi, - pPositron*ctheta2, - ePositron))); + _theUpdatedState.emplace_back(makeParticle( + Particle.particleDataTable(), + -11, + XYZTLorentzVector(-pPositron * stheta2 * cphi, -pPositron * stheta2 * sphi, pPositron * ctheta2, ePositron))); _theUpdatedState[1].rotate(rotY); _theUpdatedState[1].rotate(rotZ); - } - } + } } -double -PairProductionSimulator::gbteth(double ener,double partm,double efrac, RandomEngineAndDistribution const* random) -{ +double PairProductionSimulator::gbteth(double ener, + double partm, + double efrac, + RandomEngineAndDistribution const* random) { const double alfa = 0.625; - double d = 0.13*(0.8+1.3/theZ())*(100.0+(1.0/ener))*(1.0+efrac); - double w1 = 9.0/(9.0+d); - double umax = ener*M_PI/partm; + double d = 0.13 * (0.8 + 1.3 / theZ()) * (100.0 + (1.0 / ener)) * (1.0 + efrac); + double w1 = 9.0 / (9.0 + d); + double umax = ener * M_PI / partm; double u; do { - double beta; - if (random->flatShoot()<=w1) beta = alfa; - else beta = 3.0*alfa; - u = -(std::log(random->flatShoot()*random->flatShoot()))/beta; - } while (u>=umax); + double beta; + if (random->flatShoot() <= w1) + beta = alfa; + else + beta = 3.0 * alfa; + u = -(std::log(random->flatShoot() * random->flatShoot())) / beta; + } while (u >= umax); return u; } diff --git a/FastSimulation/MaterialEffects/src/PetrukhinModel.cc b/FastSimulation/MaterialEffects/src/PetrukhinModel.cc index af39753600906..67ca3d3ecb1a3 100644 --- a/FastSimulation/MaterialEffects/src/PetrukhinModel.cc +++ b/FastSimulation/MaterialEffects/src/PetrukhinModel.cc @@ -19,17 +19,16 @@ using namespace std; //Function of Muom Brem using nuclear-electron screening correction from G4 style // - double PetrukhinFunc (double *x, double *p ){ - - //Function independent variable - double nu = x[0]; //fraction of muon's energy transferred to the photon - +double PetrukhinFunc(double *x, double *p) { + //Function independent variable + double nu = x[0]; //fraction of muon's energy transferred to the photon + // Parameters - double E=p[0]; //Muon Energy (in GeV) - double A=p[1];// Atomic weight - double Z=p[2];// Atomic number + double E = p[0]; //Muon Energy (in GeV) + double A = p[1]; // Atomic weight + double Z = p[2]; // Atomic number - /* + /* ////////////////////////////////////////////////// //Function of Muom Brem using nuclear screening correction @@ -59,47 +58,35 @@ using namespace std; double f = alpha * constant *(4./3.-4./3.*nu + nu*nu)*Phi/nu; */ -////////////////////////////////////////////////// -// Function for Muon Brem Xsec from G4 -////////////////////////////////////////////////// -//Physical constants - double B = 183.; - double Bl= 1429.; - double ee = 1.64872 ; // sqrt(e) - double Z13= pow( Z,-1./3.); // Z^-1/3 - double Z23= pow( Z,-2./3.); // Z^-2/3 - - //Original values of paper - double emass = 0.0005109990615; // electron mass (GeV/c^2) - double mumass = 0.105658367; // muon mass (GeV/c^2) - // double re = 2.817940285e-13; // Classical electron radius (Units: cm) - double alpha = 0.00729735; // 1./137.03599976; // fine structure constant - double constant = 1.85736e-30; // pow( ( emass / mumass * re ) , 2.0); - - double Dn = 1.54*(pow(A,0.27)); - double Dnl= pow(Dn,(1.-1./Z)); - - double delta = (mumass * mumass * nu)/(2.* E * (1.- nu)); - - - double Phi_n = TMath::Log( B * Z13 *( mumass + delta * ( Dnl * ee -2 )) - / ( Dnl * ( emass + delta * ee * B * Z13 ) ) ); - - - double Phi_e = TMath::Log( ( Bl * Z23 * mumass ) - / ( 1.+ delta * mumass / ( emass*emass * ee ) ) - / ( emass + delta *ee * Bl * Z23 ) ); - - - -//Diff. Cross Section for Muon Brem from G4 ( without NA/A factor ) - double f = 16./3. * alpha * constant* Z * ( Z * Phi_n + Phi_e ) * (1./nu) * (1. - nu + 0.75*nu*nu) ; + ////////////////////////////////////////////////// + // Function for Muon Brem Xsec from G4 + ////////////////////////////////////////////////// + //Physical constants + double B = 183.; + double Bl = 1429.; + double ee = 1.64872; // sqrt(e) + double Z13 = pow(Z, -1. / 3.); // Z^-1/3 + double Z23 = pow(Z, -2. / 3.); // Z^-2/3 + + //Original values of paper + double emass = 0.0005109990615; // electron mass (GeV/c^2) + double mumass = 0.105658367; // muon mass (GeV/c^2) + // double re = 2.817940285e-13; // Classical electron radius (Units: cm) + double alpha = 0.00729735; // 1./137.03599976; // fine structure constant + double constant = 1.85736e-30; // pow( ( emass / mumass * re ) , 2.0); - return f; - + double Dn = 1.54 * (pow(A, 0.27)); + double Dnl = pow(Dn, (1. - 1. / Z)); + double delta = (mumass * mumass * nu) / (2. * E * (1. - nu)); - } + double Phi_n = TMath::Log(B * Z13 * (mumass + delta * (Dnl * ee - 2)) / (Dnl * (emass + delta * ee * B * Z13))); + double Phi_e = + TMath::Log((Bl * Z23 * mumass) / (1. + delta * mumass / (emass * emass * ee)) / (emass + delta * ee * Bl * Z23)); + //Diff. Cross Section for Muon Brem from G4 ( without NA/A factor ) + double f = 16. / 3. * alpha * constant * Z * (Z * Phi_n + Phi_e) * (1. / nu) * (1. - nu + 0.75 * nu * nu); + return f; +} diff --git a/FastSimulation/MaterialEffects/test/testMaterialEffects.cc b/FastSimulation/MaterialEffects/test/testMaterialEffects.cc index e96c9858de3de..24139da8d39f4 100644 --- a/FastSimulation/MaterialEffects/test/testMaterialEffects.cc +++ b/FastSimulation/MaterialEffects/test/testMaterialEffects.cc @@ -20,20 +20,19 @@ #include class testMaterialEffects : public DQMEDAnalyzer { -public : +public: explicit testMaterialEffects(const edm::ParameterSet&); ~testMaterialEffects(){}; - virtual void analyze(const edm::Event&, const edm::EventSetup& ) override; - virtual void dqmBeginRun(edm::Run const& ,edm::EventSetup const& ) override; - void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override; - + virtual void analyze(const edm::Event&, const edm::EventSetup&) override; + virtual void dqmBeginRun(edm::Run const&, edm::EventSetup const&) override; + void bookHistograms(DQMStore::IBooker&, edm::Run const&, edm::EventSetup const&) override; + private: - // See RecoParticleFlow/PFProducer/interface/PFProducer.h edm::ParameterSet particleFilter_; std::vector mySimEvent; - std::string simModuleLabel_; + std::string simModuleLabel_; // TH2F * h100; std::vector h0; std::vector h1; @@ -55,49 +54,45 @@ public : std::vector h17; std::vector htmp; - std::vector< std::vector > h100; - std::vector< std::vector > h200; - std::vector< std::vector > h300; - std::vector< std::vector > trackerRadius; - std::vector< std::vector > trackerLength; - std::vector< std::vector > blockTrackerRadius; - std::vector< std::vector > blockTrackerLength; - std::vector< std::vector > subTrackerRadius; - std::vector< std::vector > subTrackerLength; + std::vector > h100; + std::vector > h200; + std::vector > h300; + std::vector > trackerRadius; + std::vector > trackerLength; + std::vector > blockTrackerRadius; + std::vector > blockTrackerLength; + std::vector > subTrackerRadius; + std::vector > subTrackerLength; std::vector tmpRadius; std::vector tmpLength; unsigned int nevt; - }; -testMaterialEffects::testMaterialEffects(const edm::ParameterSet& p) : - mySimEvent(2, static_cast(0)), - h0(2,static_cast(0)), - h1(2,static_cast(0)), - h2(2,static_cast(0)), - h3(2,static_cast(0)), - h4(2,static_cast(0)), - h5(2,static_cast(0)), - h6(2,static_cast(0)), - h7(2,static_cast(0)), - h8(2,static_cast(0)), - h9(2,static_cast(0)), - h10(2,static_cast(0)), - h11(2,static_cast(0)), - h12(2,static_cast(0)), - h13(2,static_cast(0)), - h14(2,static_cast(0)), - h15(2,static_cast(0)), - h16(2,static_cast(0)), - h17(2,static_cast(0)), - htmp(2,static_cast(0)), - tmpRadius(2,static_cast(0.)), - tmpLength(2,static_cast(0.)) -{ - - particleFilter_ = p.getParameter - ( "TestParticleFilter" ); +testMaterialEffects::testMaterialEffects(const edm::ParameterSet& p) + : mySimEvent(2, static_cast(0)), + h0(2, static_cast(0)), + h1(2, static_cast(0)), + h2(2, static_cast(0)), + h3(2, static_cast(0)), + h4(2, static_cast(0)), + h5(2, static_cast(0)), + h6(2, static_cast(0)), + h7(2, static_cast(0)), + h8(2, static_cast(0)), + h9(2, static_cast(0)), + h10(2, static_cast(0)), + h11(2, static_cast(0)), + h12(2, static_cast(0)), + h13(2, static_cast(0)), + h14(2, static_cast(0)), + h15(2, static_cast(0)), + h16(2, static_cast(0)), + h17(2, static_cast(0)), + htmp(2, static_cast(0)), + tmpRadius(2, static_cast(0.)), + tmpLength(2, static_cast(0.)) { + particleFilter_ = p.getParameter("TestParticleFilter"); // For the full sim mySimEvent[0] = new FSimEvent(particleFilter_); // For the fast sim @@ -341,7 +336,7 @@ testMaterialEffects::testMaterialEffects(const edm::ParameterSet& p) : blockTrackerRadius.push_back(tmpRadius); blockTrackerLength.push_back(tmpLength); - // All Outer + // All Outer subTrackerRadius.push_back(tmpRadius); subTrackerLength.push_back(tmpLength); @@ -355,7 +350,7 @@ testMaterialEffects::testMaterialEffects(const edm::ParameterSet& p) : blockTrackerRadius.push_back(tmpRadius); blockTrackerLength.push_back(tmpLength); - // All + // All subTrackerRadius.push_back(tmpRadius); subTrackerLength.push_back(tmpLength); @@ -363,450 +358,445 @@ testMaterialEffects::testMaterialEffects(const edm::ParameterSet& p) : subTrackerRadius.push_back(tmpRadius); subTrackerLength.push_back(tmpLength); - nevt=0; + nevt = 0; } -void testMaterialEffects::bookHistograms(DQMStore::IBooker & ibooker, - edm::Run const & iRun, - edm::EventSetup const & iSetup) -{ +void testMaterialEffects::bookHistograms(DQMStore::IBooker& ibooker, + edm::Run const& iRun, + edm::EventSetup const& iSetup) { ibooker.setCurrentFolder("testMaterialEffects"); - h0[0] = ibooker.book2D("radioFull", "Full Tracker radiography", 1000, 0.,320.,1000,0., 150. ); - h0[1] = ibooker.book2D("radioFast", "Fast Tracker radiography", 1000, 0.,320.,1000,0., 150. ); - h1[0] = ibooker.book1D("etaEFull", "Full Electron eta distribution",54,0.,2.7); - h1[1] = ibooker.book1D("etaEFast", "Fast Electron eta distribution",54,0.,2.7); - h2[0] = ibooker.book1D("EgammaFull", "Full Brem energy distribution",600,0.,300.); - h2[1] = ibooker.book1D("EgammaFast", "Fast Brem energy distribution",600,0.,300.); - h3[0] = ibooker.book1D("FEgammaFull", "Full Brem energy fraction distribution",1000,0.,1.); - h3[1] = ibooker.book1D("FEgammaFast", "Fast Brem energy fraction distribution",1000,0.,1.); - h4[0] = ibooker.book1D("NgammaFull", "Full Brem number",25,-0.5,24.5); - h4[1] = ibooker.book1D("NgammaFast", "Fast Brem number",25,-0.5,24.5); - h5[0] = ibooker.book1D("NgammaMinFull", "Full Brem number > Emin",25,-0.5,24.5); - h5[1] = ibooker.book1D("NgammaMinFast", "Fast Brem number > Emin",25,-0.5,24.5); - h6[0] = ibooker.book2D("radioFullRem1", "Full Tracker radiography", 1000, 0.,320.,1000,0., 150. ); - h6[1] = ibooker.book2D("radioFastRem1", "Fast Tracker radiography", 1000, 0.,320.,1000,0., 150. ); - h7[0] = ibooker.book2D("radioFullRem2", "Full Tracker radiography", 1000, 0.,320.,1000,0., 150. ); - h7[1] = ibooker.book2D("radioFastRem2", "Fast Tracker radiography", 1000, 0.,320.,1000,0., 150. ); - h8[0] = ibooker.book2D("radioFullBP", "Full BP radiography", 1000, 0.,320.,1000,0., 150. ); - h8[1] = ibooker.book2D("radioFastBP", "Fast BP radiography", 1000, 0.,320.,1000,0., 150. ); - h9[0] = ibooker.book2D("radioFullPX", "Full PX radiography", 1000, 0.,320.,1000,0., 150. ); - h9[1] = ibooker.book2D("radioFastPX", "Fast PX radiography", 1000, 0.,320.,1000,0., 150. ); - h10[0] = ibooker.book2D("radioFullTI", "Full TI radiography", 1000, 0.,320.,1000,0., 150. ); - h10[1] = ibooker.book2D("radioFastTI", "Fast TI radiography", 1000, 0.,320.,1000,0., 150. ); - h11[0] = ibooker.book2D("radioFullTO", "Full TO radiography", 1000, 0.,320.,1000,0., 150. ); - h11[1] = ibooker.book2D("radioFastTO", "Fast TO radiography", 1000, 0.,320.,1000,0., 150. ); - h12[0] = ibooker.book2D("radioFullCA", "Full CA radiography", 1000, 0.,320.,1000,0., 150. ); - h12[1] = ibooker.book2D("radioFastCA", "Fast CA radiography", 1000, 0.,320.,1000,0., 150. ); - h13[0] = ibooker.book1D("TrackerFullR","Full Tracker Radius",300,0.,150.); - h13[1] = ibooker.book1D("TrackerFastR","Fast Tracker Radius",300,0.,150.); - h14[0] = ibooker.book1D("TrackerFullR2","Full Tracker Radius 2",800,0.,40.); - h14[1] = ibooker.book1D("TrackerFastR2","Fast Tracker Radius 2",800,0.,40.); - h15[0] = ibooker.book1D("HF1Full","Full HF1 region",550,0.,5.5); - h15[1] = ibooker.book1D("HF1Fast","Fast HF1 region",550,0.,5.5); - h16[0] = ibooker.book1D("HF2Full","Full HF2 region",550,0.,5.5); - h16[1] = ibooker.book1D("HF2Fast","Fast HF2 region",550,0.,5.5); - h17[0] = ibooker.book1D("HF3Full","Full HF3 region",550,0.,5.5); - h17[1] = ibooker.book1D("HF3Fast","Fast HF3 region",550,0.,5.5); - - + h0[0] = ibooker.book2D("radioFull", "Full Tracker radiography", 1000, 0., 320., 1000, 0., 150.); + h0[1] = ibooker.book2D("radioFast", "Fast Tracker radiography", 1000, 0., 320., 1000, 0., 150.); + h1[0] = ibooker.book1D("etaEFull", "Full Electron eta distribution", 54, 0., 2.7); + h1[1] = ibooker.book1D("etaEFast", "Fast Electron eta distribution", 54, 0., 2.7); + h2[0] = ibooker.book1D("EgammaFull", "Full Brem energy distribution", 600, 0., 300.); + h2[1] = ibooker.book1D("EgammaFast", "Fast Brem energy distribution", 600, 0., 300.); + h3[0] = ibooker.book1D("FEgammaFull", "Full Brem energy fraction distribution", 1000, 0., 1.); + h3[1] = ibooker.book1D("FEgammaFast", "Fast Brem energy fraction distribution", 1000, 0., 1.); + h4[0] = ibooker.book1D("NgammaFull", "Full Brem number", 25, -0.5, 24.5); + h4[1] = ibooker.book1D("NgammaFast", "Fast Brem number", 25, -0.5, 24.5); + h5[0] = ibooker.book1D("NgammaMinFull", "Full Brem number > Emin", 25, -0.5, 24.5); + h5[1] = ibooker.book1D("NgammaMinFast", "Fast Brem number > Emin", 25, -0.5, 24.5); + h6[0] = ibooker.book2D("radioFullRem1", "Full Tracker radiography", 1000, 0., 320., 1000, 0., 150.); + h6[1] = ibooker.book2D("radioFastRem1", "Fast Tracker radiography", 1000, 0., 320., 1000, 0., 150.); + h7[0] = ibooker.book2D("radioFullRem2", "Full Tracker radiography", 1000, 0., 320., 1000, 0., 150.); + h7[1] = ibooker.book2D("radioFastRem2", "Fast Tracker radiography", 1000, 0., 320., 1000, 0., 150.); + h8[0] = ibooker.book2D("radioFullBP", "Full BP radiography", 1000, 0., 320., 1000, 0., 150.); + h8[1] = ibooker.book2D("radioFastBP", "Fast BP radiography", 1000, 0., 320., 1000, 0., 150.); + h9[0] = ibooker.book2D("radioFullPX", "Full PX radiography", 1000, 0., 320., 1000, 0., 150.); + h9[1] = ibooker.book2D("radioFastPX", "Fast PX radiography", 1000, 0., 320., 1000, 0., 150.); + h10[0] = ibooker.book2D("radioFullTI", "Full TI radiography", 1000, 0., 320., 1000, 0., 150.); + h10[1] = ibooker.book2D("radioFastTI", "Fast TI radiography", 1000, 0., 320., 1000, 0., 150.); + h11[0] = ibooker.book2D("radioFullTO", "Full TO radiography", 1000, 0., 320., 1000, 0., 150.); + h11[1] = ibooker.book2D("radioFastTO", "Fast TO radiography", 1000, 0., 320., 1000, 0., 150.); + h12[0] = ibooker.book2D("radioFullCA", "Full CA radiography", 1000, 0., 320., 1000, 0., 150.); + h12[1] = ibooker.book2D("radioFastCA", "Fast CA radiography", 1000, 0., 320., 1000, 0., 150.); + h13[0] = ibooker.book1D("TrackerFullR", "Full Tracker Radius", 300, 0., 150.); + h13[1] = ibooker.book1D("TrackerFastR", "Fast Tracker Radius", 300, 0., 150.); + h14[0] = ibooker.book1D("TrackerFullR2", "Full Tracker Radius 2", 800, 0., 40.); + h14[1] = ibooker.book1D("TrackerFastR2", "Fast Tracker Radius 2", 800, 0., 40.); + h15[0] = ibooker.book1D("HF1Full", "Full HF1 region", 550, 0., 5.5); + h15[1] = ibooker.book1D("HF1Fast", "Fast HF1 region", 550, 0., 5.5); + h16[0] = ibooker.book1D("HF2Full", "Full HF2 region", 550, 0., 5.5); + h16[1] = ibooker.book1D("HF2Fast", "Fast HF2 region", 550, 0., 5.5); + h17[0] = ibooker.book1D("HF3Full", "Full HF3 region", 550, 0., 5.5); + h17[1] = ibooker.book1D("HF3Fast", "Fast HF3 region", 550, 0., 5.5); + // Beam Pipe - htmp[0] = ibooker.book1D("BeamPipeFull", "Full Beam Pipe",220,0.,5.5); - htmp[1] = ibooker.book1D("BeamPipeFast", "Fast Beam Pipe",220,0.,5.5); + htmp[0] = ibooker.book1D("BeamPipeFull", "Full Beam Pipe", 220, 0., 5.5); + htmp[1] = ibooker.book1D("BeamPipeFast", "Fast Beam Pipe", 220, 0., 5.5); h100.push_back(htmp); // Beam Pipe (cont'd) - htmp[0] = ibooker.book1D("BPFullDummy", "Full Beam Pipe",220,0.,5.5); - htmp[1] = ibooker.book1D("BPFastDummy", "Fast Beam Pipe",220,0.,5.5); + htmp[0] = ibooker.book1D("BPFullDummy", "Full Beam Pipe", 220, 0., 5.5); + htmp[1] = ibooker.book1D("BPFastDummy", "Fast Beam Pipe", 220, 0., 5.5); h200.push_back(htmp); // Beam Pipe (cont'd) - htmp[0] = ibooker.book1D("BPFull", "Full Beam Pipe",220,0.,5.5); - htmp[1] = ibooker.book1D("BPFast", "Fast Beam Pipe",220,0.,5.5); + htmp[0] = ibooker.book1D("BPFull", "Full Beam Pipe", 220, 0., 5.5); + htmp[1] = ibooker.book1D("BPFast", "Fast Beam Pipe", 220, 0., 5.5); h300.push_back(htmp); // PIXB1 - htmp[0] = ibooker.book1D("PXB1Full", "Full Pixel Barrel 1",220,0.,5.5); - htmp[1] = ibooker.book1D("PXB1Fast", "Fast Pixel Barrel 1",220,0.,5.5); + htmp[0] = ibooker.book1D("PXB1Full", "Full Pixel Barrel 1", 220, 0., 5.5); + htmp[1] = ibooker.book1D("PXB1Fast", "Fast Pixel Barrel 1", 220, 0., 5.5); h100.push_back(htmp); // PIXB2 - htmp[0] = ibooker.book1D("PXB2Full", "Full Pixel Barrel 2",220,0.,5.5); - htmp[1] = ibooker.book1D("PXB2Fast", "Fast Pixel Barrel 2",220,0.,5.5); + htmp[0] = ibooker.book1D("PXB2Full", "Full Pixel Barrel 2", 220, 0., 5.5); + htmp[1] = ibooker.book1D("PXB2Fast", "Fast Pixel Barrel 2", 220, 0., 5.5); h100.push_back(htmp); // PIXB3 - htmp[0] = ibooker.book1D("PXB3Full", "Full Pixel Barrel 3",220,0.,5.5); - htmp[1] = ibooker.book1D("PXB3Fast", "Fast Pixel Barrel 3",220,0.,5.5); + htmp[0] = ibooker.book1D("PXB3Full", "Full Pixel Barrel 3", 220, 0., 5.5); + htmp[1] = ibooker.book1D("PXB3Fast", "Fast Pixel Barrel 3", 220, 0., 5.5); h100.push_back(htmp); // PIXB Cables - htmp[0] = ibooker.book1D("PXBCFull", "Full Pixel Barrel Cables",220,0.,5.5); - htmp[1] = ibooker.book1D("PXBCFast", "Fast Pixel Barrel Cables",220,0.,5.5); + htmp[0] = ibooker.book1D("PXBCFull", "Full Pixel Barrel Cables", 220, 0., 5.5); + htmp[1] = ibooker.book1D("PXBCFast", "Fast Pixel Barrel Cables", 220, 0., 5.5); h100.push_back(htmp); // All Pixel Barrel - htmp[0] = ibooker.book1D("PXBFull", "Full Pixel Barrel",220,0.,5.5); - htmp[1] = ibooker.book1D("PXBFast", "Fast Pixel Barrel",220,0.,5.5); + htmp[0] = ibooker.book1D("PXBFull", "Full Pixel Barrel", 220, 0., 5.5); + htmp[1] = ibooker.book1D("PXBFast", "Fast Pixel Barrel", 220, 0., 5.5); h200.push_back(htmp); // PIXD1 - htmp[0] = ibooker.book1D("PXD1Full", "Full Pixel Disk 1",220,0.,5.5); - htmp[1] = ibooker.book1D("PXD1Fast", "Fast Pixel Disk 1",220,0.,5.5); + htmp[0] = ibooker.book1D("PXD1Full", "Full Pixel Disk 1", 220, 0., 5.5); + htmp[1] = ibooker.book1D("PXD1Fast", "Fast Pixel Disk 1", 220, 0., 5.5); h100.push_back(htmp); // PIXD2 - htmp[0] = ibooker.book1D("PXD2Full", "Full Pixel Disk 2",220,0.,5.5); - htmp[1] = ibooker.book1D("PXD2Fast", "Fast Pixel Disk 2",220,0.,5.5); + htmp[0] = ibooker.book1D("PXD2Full", "Full Pixel Disk 2", 220, 0., 5.5); + htmp[1] = ibooker.book1D("PXD2Fast", "Fast Pixel Disk 2", 220, 0., 5.5); h100.push_back(htmp); // PIXD Cables - htmp[0] = ibooker.book1D("PXDCFull", "Full Pixel Disk Cables",220,0.,5.5); - htmp[1] = ibooker.book1D("PXDCFast", "Fast Pixel Disk Cables",220,0.,5.5); + htmp[0] = ibooker.book1D("PXDCFull", "Full Pixel Disk Cables", 220, 0., 5.5); + htmp[1] = ibooker.book1D("PXDCFast", "Fast Pixel Disk Cables", 220, 0., 5.5); h100.push_back(htmp); // All Pixel Disks - htmp[0] = ibooker.book1D("PXDFull", "Full Pixel Disk",220,0.,5.5); - htmp[1] = ibooker.book1D("PXDFast", "Fast Pixel Disk",220,0.,5.5); + htmp[0] = ibooker.book1D("PXDFull", "Full Pixel Disk", 220, 0., 5.5); + htmp[1] = ibooker.book1D("PXDFast", "Fast Pixel Disk", 220, 0., 5.5); h200.push_back(htmp); // All Pixel - htmp[0] = ibooker.book1D("PixelFull", "Full Pixel",220,0.,5.5); - htmp[1] = ibooker.book1D("PixelFast", "Fast Pixel",220,0.,5.5); + htmp[0] = ibooker.book1D("PixelFull", "Full Pixel", 220, 0., 5.5); + htmp[1] = ibooker.book1D("PixelFast", "Fast Pixel", 220, 0., 5.5); h300.push_back(htmp); // TIB1 - htmp[0] = ibooker.book1D("TIB1Full", "Full Tracker Inner Barrel 1",220,0.,5.5); - htmp[1] = ibooker.book1D("TIB1Fast", "Fast Tracker Inner Barrel 1",220,0.,5.5); + htmp[0] = ibooker.book1D("TIB1Full", "Full Tracker Inner Barrel 1", 220, 0., 5.5); + htmp[1] = ibooker.book1D("TIB1Fast", "Fast Tracker Inner Barrel 1", 220, 0., 5.5); h100.push_back(htmp); // TIB2 - htmp[0] = ibooker.book1D("TIB2Full", "Full Tracker Inner Barrel 2",220,0.,5.5); - htmp[1] = ibooker.book1D("TIB2Fast", "Fast Tracker Inner Barrel 2",220,0.,5.5); + htmp[0] = ibooker.book1D("TIB2Full", "Full Tracker Inner Barrel 2", 220, 0., 5.5); + htmp[1] = ibooker.book1D("TIB2Fast", "Fast Tracker Inner Barrel 2", 220, 0., 5.5); h100.push_back(htmp); // TIB3 - htmp[0] = ibooker.book1D("TIB3Full", "Full Tracker Inner Barrel 3",220,0.,5.5); - htmp[1] = ibooker.book1D("TIB3Fast", "Fast Tracker Inner Barrel 3",220,0.,5.5); + htmp[0] = ibooker.book1D("TIB3Full", "Full Tracker Inner Barrel 3", 220, 0., 5.5); + htmp[1] = ibooker.book1D("TIB3Fast", "Fast Tracker Inner Barrel 3", 220, 0., 5.5); h100.push_back(htmp); // TIB4 - htmp[0] = ibooker.book1D("TIB4Full", "Full Tracker Inner Barrel 4",220,0.,5.5); - htmp[1] = ibooker.book1D("TIB4Fast", "Fast Tracker Inner Barrel 4",220,0.,5.5); + htmp[0] = ibooker.book1D("TIB4Full", "Full Tracker Inner Barrel 4", 220, 0., 5.5); + htmp[1] = ibooker.book1D("TIB4Fast", "Fast Tracker Inner Barrel 4", 220, 0., 5.5); h100.push_back(htmp); // TIB Cables - htmp[0] = ibooker.book1D("TIBCFull", "Full Tracker Inner Barrel Cables",220,0.,5.5); - htmp[1] = ibooker.book1D("TIBCFast", "Fast Tracker Inner Barrel Cables",220,0.,5.5); + htmp[0] = ibooker.book1D("TIBCFull", "Full Tracker Inner Barrel Cables", 220, 0., 5.5); + htmp[1] = ibooker.book1D("TIBCFast", "Fast Tracker Inner Barrel Cables", 220, 0., 5.5); h100.push_back(htmp); // All TIB - htmp[0] = ibooker.book1D("TIBFull", "Full Tracker Inner Barrel",220,0.,5.5); - htmp[1] = ibooker.book1D("TIBFast", "Fast Tracker Inner Barrel",220,0.,5.5); + htmp[0] = ibooker.book1D("TIBFull", "Full Tracker Inner Barrel", 220, 0., 5.5); + htmp[1] = ibooker.book1D("TIBFast", "Fast Tracker Inner Barrel", 220, 0., 5.5); h200.push_back(htmp); // TID1 - htmp[0] = ibooker.book1D("TID1Full", "Full Tracker Inner Disk 1",220,0.,5.5); - htmp[1] = ibooker.book1D("TID1Fast", "Fast Tracker Inner Disk 1",220,0.,5.5); + htmp[0] = ibooker.book1D("TID1Full", "Full Tracker Inner Disk 1", 220, 0., 5.5); + htmp[1] = ibooker.book1D("TID1Fast", "Fast Tracker Inner Disk 1", 220, 0., 5.5); h100.push_back(htmp); // TID2 - htmp[0] = ibooker.book1D("TID2Full", "Full Tracker Inner Disk 2",220,0.,5.5); - htmp[1] = ibooker.book1D("TID2Fast", "Fast Tracker Inner Disk 2",220,0.,5.5); + htmp[0] = ibooker.book1D("TID2Full", "Full Tracker Inner Disk 2", 220, 0., 5.5); + htmp[1] = ibooker.book1D("TID2Fast", "Fast Tracker Inner Disk 2", 220, 0., 5.5); h100.push_back(htmp); // TID3 - htmp[0] = ibooker.book1D("TID3Full", "Full Tracker Inner Disk 3",220,0.,5.5); - htmp[1] = ibooker.book1D("TID3Fast", "Fast Tracker Inner Disk 3",220,0.,5.5); + htmp[0] = ibooker.book1D("TID3Full", "Full Tracker Inner Disk 3", 220, 0., 5.5); + htmp[1] = ibooker.book1D("TID3Fast", "Fast Tracker Inner Disk 3", 220, 0., 5.5); h100.push_back(htmp); // TID Cables - htmp[0] = ibooker.book1D("TIDCFull", "Full Tracker Inner Disk Cables",220,0.,5.5); - htmp[1] = ibooker.book1D("TIDCFast", "Fast Tracker Inner Disk Cables",220,0.,5.5); + htmp[0] = ibooker.book1D("TIDCFull", "Full Tracker Inner Disk Cables", 220, 0., 5.5); + htmp[1] = ibooker.book1D("TIDCFast", "Fast Tracker Inner Disk Cables", 220, 0., 5.5); h100.push_back(htmp); // All TID - htmp[0] = ibooker.book1D("TIDFull", "Full Tracker Inner Disk",220,0.,5.5); - htmp[1] = ibooker.book1D("TIDFast", "Fast Tracker Inner Disk",220,0.,5.5); + htmp[0] = ibooker.book1D("TIDFull", "Full Tracker Inner Disk", 220, 0., 5.5); + htmp[1] = ibooker.book1D("TIDFast", "Fast Tracker Inner Disk", 220, 0., 5.5); h200.push_back(htmp); // All Inner Tracker - htmp[0] = ibooker.book1D("InnerFull", "Full Inner Tracker",220,0.,5.5); - htmp[1] = ibooker.book1D("InnerFast", "Fast Inner Tracker",220,0.,5.5); + htmp[0] = ibooker.book1D("InnerFull", "Full Inner Tracker", 220, 0., 5.5); + htmp[1] = ibooker.book1D("InnerFast", "Fast Inner Tracker", 220, 0., 5.5); h300.push_back(htmp); // TOB1 - htmp[0] = ibooker.book1D("TOB1Full", "Full Tracker Outer Barrel 1",220,0.,5.5); - htmp[1] = ibooker.book1D("TOB1Fast", "Fast Tracker Outer Barrel 1",220,0.,5.5); + htmp[0] = ibooker.book1D("TOB1Full", "Full Tracker Outer Barrel 1", 220, 0., 5.5); + htmp[1] = ibooker.book1D("TOB1Fast", "Fast Tracker Outer Barrel 1", 220, 0., 5.5); h100.push_back(htmp); // TOB2 - htmp[0] = ibooker.book1D("TOB2Full", "Full Tracker Outer Barrel 2",220,0.,5.5); - htmp[1] = ibooker.book1D("TOB2Fast", "Fast Tracker Outer Barrel 2",220,0.,5.5); + htmp[0] = ibooker.book1D("TOB2Full", "Full Tracker Outer Barrel 2", 220, 0., 5.5); + htmp[1] = ibooker.book1D("TOB2Fast", "Fast Tracker Outer Barrel 2", 220, 0., 5.5); h100.push_back(htmp); // TOB3 - htmp[0] = ibooker.book1D("TOB3Full", "Full Tracker Outer Barrel 3",220,0.,5.5); - htmp[1] = ibooker.book1D("TOB3Fast", "Fast Tracker Outer Barrel 3",220,0.,5.5); + htmp[0] = ibooker.book1D("TOB3Full", "Full Tracker Outer Barrel 3", 220, 0., 5.5); + htmp[1] = ibooker.book1D("TOB3Fast", "Fast Tracker Outer Barrel 3", 220, 0., 5.5); h100.push_back(htmp); // TOB4 - htmp[0] = ibooker.book1D("TOB4Full", "Full Tracker Outer Barrel 4",220,0.,5.5); - htmp[1] = ibooker.book1D("TOB4Fast", "Fast Tracker Outer Barrel 4",220,0.,5.5); + htmp[0] = ibooker.book1D("TOB4Full", "Full Tracker Outer Barrel 4", 220, 0., 5.5); + htmp[1] = ibooker.book1D("TOB4Fast", "Fast Tracker Outer Barrel 4", 220, 0., 5.5); h100.push_back(htmp); // TOB5 - htmp[0] = ibooker.book1D("TOB5Full", "Full Tracker Outer Barrel 5",220,0.,5.5); - htmp[1] = ibooker.book1D("TOB5Fast", "Fast Tracker Outer Barrel 5",220,0.,5.5); + htmp[0] = ibooker.book1D("TOB5Full", "Full Tracker Outer Barrel 5", 220, 0., 5.5); + htmp[1] = ibooker.book1D("TOB5Fast", "Fast Tracker Outer Barrel 5", 220, 0., 5.5); h100.push_back(htmp); // TOB6 - htmp[0] = ibooker.book1D("TOB6Full", "Full Tracker Outer Barrel 6",220,0.,5.5); - htmp[1] = ibooker.book1D("TOB6Fast", "Fast Tracker Outer Barrel 6",220,0.,5.5); + htmp[0] = ibooker.book1D("TOB6Full", "Full Tracker Outer Barrel 6", 220, 0., 5.5); + htmp[1] = ibooker.book1D("TOB6Fast", "Fast Tracker Outer Barrel 6", 220, 0., 5.5); h100.push_back(htmp); // TOB Cables - htmp[0] = ibooker.book1D("TOBCFull", "Full Tracker Outer Barrel Cables",220,0.,5.5); - htmp[1] = ibooker.book1D("TOBCFast", "Fast Tracker Outer Barrel Cables",220,0.,5.5); + htmp[0] = ibooker.book1D("TOBCFull", "Full Tracker Outer Barrel Cables", 220, 0., 5.5); + htmp[1] = ibooker.book1D("TOBCFast", "Fast Tracker Outer Barrel Cables", 220, 0., 5.5); h100.push_back(htmp); // All TOB - htmp[0] = ibooker.book1D("TOBFull", "Full Tracker Outer Barrel",220,0.,5.5); - htmp[1] = ibooker.book1D("TOBFast", "Fast Tracker Outer Barrel",220,0.,5.5); + htmp[0] = ibooker.book1D("TOBFull", "Full Tracker Outer Barrel", 220, 0., 5.5); + htmp[1] = ibooker.book1D("TOBFast", "Fast Tracker Outer Barrel", 220, 0., 5.5); h200.push_back(htmp); // TEC1 - htmp[0] = ibooker.book1D("TEC1Full", "Full Tracker EndCap 1",220,0.,5.5); - htmp[1] = ibooker.book1D("TEC1Fast", "Fast Tracker Endcap 1",220,0.,5.5); + htmp[0] = ibooker.book1D("TEC1Full", "Full Tracker EndCap 1", 220, 0., 5.5); + htmp[1] = ibooker.book1D("TEC1Fast", "Fast Tracker Endcap 1", 220, 0., 5.5); h100.push_back(htmp); // TEC2 - htmp[0] = ibooker.book1D("TEC2Full", "Full Tracker EndCap 2",220,0.,5.5); - htmp[1] = ibooker.book1D("TEC2Fast", "Fast Tracker Endcap 2",220,0.,5.5); + htmp[0] = ibooker.book1D("TEC2Full", "Full Tracker EndCap 2", 220, 0., 5.5); + htmp[1] = ibooker.book1D("TEC2Fast", "Fast Tracker Endcap 2", 220, 0., 5.5); h100.push_back(htmp); // TEC3 - htmp[0] = ibooker.book1D("TEC3Full", "Full Tracker EndCap 3",220,0.,5.5); - htmp[1] = ibooker.book1D("TEC3Fast", "Fast Tracker Endcap 3",220,0.,5.5); + htmp[0] = ibooker.book1D("TEC3Full", "Full Tracker EndCap 3", 220, 0., 5.5); + htmp[1] = ibooker.book1D("TEC3Fast", "Fast Tracker Endcap 3", 220, 0., 5.5); h100.push_back(htmp); // TEC4 - htmp[0] = ibooker.book1D("TEC4Full", "Full Tracker EndCap 4",220,0.,5.5); - htmp[1] = ibooker.book1D("TEC4Fast", "Fast Tracker Endcap 4",220,0.,5.5); + htmp[0] = ibooker.book1D("TEC4Full", "Full Tracker EndCap 4", 220, 0., 5.5); + htmp[1] = ibooker.book1D("TEC4Fast", "Fast Tracker Endcap 4", 220, 0., 5.5); h100.push_back(htmp); // TEC5 - htmp[0] = ibooker.book1D("TEC5Full", "Full Tracker EndCap 5",220,0.,5.5); - htmp[1] = ibooker.book1D("TEC5Fast", "Fast Tracker Endcap 5",220,0.,5.5); + htmp[0] = ibooker.book1D("TEC5Full", "Full Tracker EndCap 5", 220, 0., 5.5); + htmp[1] = ibooker.book1D("TEC5Fast", "Fast Tracker Endcap 5", 220, 0., 5.5); h100.push_back(htmp); // TEC6 - htmp[0] = ibooker.book1D("TEC6Full", "Full Tracker EndCap 6",220,0.,5.5); - htmp[1] = ibooker.book1D("TEC6Fast", "Fast Tracker Endcap 6",220,0.,5.5); + htmp[0] = ibooker.book1D("TEC6Full", "Full Tracker EndCap 6", 220, 0., 5.5); + htmp[1] = ibooker.book1D("TEC6Fast", "Fast Tracker Endcap 6", 220, 0., 5.5); h100.push_back(htmp); // TEC7 - htmp[0] = ibooker.book1D("TEC7Full", "Full Tracker EndCap 7",220,0.,5.5); - htmp[1] = ibooker.book1D("TEC7Fast", "Fast Tracker Endcap 7",220,0.,5.5); + htmp[0] = ibooker.book1D("TEC7Full", "Full Tracker EndCap 7", 220, 0., 5.5); + htmp[1] = ibooker.book1D("TEC7Fast", "Fast Tracker Endcap 7", 220, 0., 5.5); h100.push_back(htmp); // TEC8 - htmp[0] = ibooker.book1D("TEC8Full", "Full Tracker EndCap 8",220,0.,5.5); - htmp[1] = ibooker.book1D("TEC8Fast", "Fast Tracker Endcap 8",220,0.,5.5); + htmp[0] = ibooker.book1D("TEC8Full", "Full Tracker EndCap 8", 220, 0., 5.5); + htmp[1] = ibooker.book1D("TEC8Fast", "Fast Tracker Endcap 8", 220, 0., 5.5); h100.push_back(htmp); // TEC9 - htmp[0] = ibooker.book1D("TEC9Full", "Full Tracker EndCap 9",220,0.,5.5); - htmp[1] = ibooker.book1D("TEC9Fast", "Fast Tracker Endcap 9",220,0.,5.5); + htmp[0] = ibooker.book1D("TEC9Full", "Full Tracker EndCap 9", 220, 0., 5.5); + htmp[1] = ibooker.book1D("TEC9Fast", "Fast Tracker Endcap 9", 220, 0., 5.5); h100.push_back(htmp); // All TEC - htmp[0] = ibooker.book1D("TECFull", "Full Tracker EndCap",220,0.,5.5); - htmp[1] = ibooker.book1D("TECFast", "Fast Tracker EndCap",220,0.,5.5); + htmp[0] = ibooker.book1D("TECFull", "Full Tracker EndCap", 220, 0., 5.5); + htmp[1] = ibooker.book1D("TECFast", "Fast Tracker EndCap", 220, 0., 5.5); h200.push_back(htmp); - // All Outer - htmp[0] = ibooker.book1D("OuterFull", "Full Outer Tracker",220,0.,5.5); - htmp[1] = ibooker.book1D("OuterFast", "Fast Outer Tracker",220,0.,5.5); + // All Outer + htmp[0] = ibooker.book1D("OuterFull", "Full Outer Tracker", 220, 0., 5.5); + htmp[1] = ibooker.book1D("OuterFast", "Fast Outer Tracker", 220, 0., 5.5); h300.push_back(htmp); // Outer Cables - htmp[0] = ibooker.book1D("TECCFull", "Full Tracker Outer Cables",220,0.,5.5); - htmp[1] = ibooker.book1D("TECCFast", "Fast Tracker Outer Cables",220,0.,5.5); + htmp[0] = ibooker.book1D("TECCFull", "Full Tracker Outer Cables", 220, 0., 5.5); + htmp[1] = ibooker.book1D("TECCFast", "Fast Tracker Outer Cables", 220, 0., 5.5); h100.push_back(htmp); // All TEC - htmp[0] = ibooker.book1D("CablesFull", "Full Tracker Cables",220,0.,5.5); - htmp[1] = ibooker.book1D("CablesFast", "Fast Tracker Cables",220,0.,5.5); + htmp[0] = ibooker.book1D("CablesFull", "Full Tracker Cables", 220, 0., 5.5); + htmp[1] = ibooker.book1D("CablesFast", "Fast Tracker Cables", 220, 0., 5.5); h200.push_back(htmp); - // All - htmp[0] = ibooker.book1D("TrackerFull", "Full Tracker",220,0.,5.5); - htmp[1] = ibooker.book1D("TrackerFast", "Fast Tracker",220,0.,5.5); + // All + htmp[0] = ibooker.book1D("TrackerFull", "Full Tracker", 220, 0., 5.5); + htmp[1] = ibooker.book1D("TrackerFast", "Fast Tracker", 220, 0., 5.5); h300.push_back(htmp); // All Patrice : Finer granularity - htmp[0] = ibooker.book1D("TrackerFull2", "Full Tracker 2",550,0.,5.5); - htmp[1] = ibooker.book1D("TrackerFast2", "Fast Tracker 2",550,0.,5.5); + htmp[0] = ibooker.book1D("TrackerFull2", "Full Tracker 2", 550, 0., 5.5); + htmp[1] = ibooker.book1D("TrackerFast2", "Fast Tracker 2", 550, 0., 5.5); h300.push_back(htmp); } -void testMaterialEffects::dqmBeginRun(edm::Run const&, edm::EventSetup const& es) -{ +void testMaterialEffects::dqmBeginRun(edm::Run const&, edm::EventSetup const& es) { // init Particle data table (from Pythia) - edm::ESHandle < HepPDT::ParticleDataTable > pdt; + edm::ESHandle pdt; es.getData(pdt); mySimEvent[0]->initializePdt(&(*pdt)); mySimEvent[1]->initializePdt(&(*pdt)); - } -void -testMaterialEffects::analyze( const edm::Event& iEvent, const edm::EventSetup& iSetup ) -{ - if( ( nevt < 100 && nevt%10 == 0) || - ( nevt < 1000 && nevt%100 == 0) || - nevt%1000 == 0 ) - std::cout<<"process entry "<< nevt << std::endl; - nevt++; +void testMaterialEffects::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) { + if ((nevt < 100 && nevt % 10 == 0) || (nevt < 1000 && nevt % 100 == 0) || nevt % 1000 == 0) + std::cout << "process entry " << nevt << std::endl; + nevt++; //std::cout << "Fill full event " << std::endl; edm::Handle > fullSimTracks; - iEvent.getByLabel("g4SimHits",fullSimTracks); + iEvent.getByLabel("g4SimHits", fullSimTracks); edm::Handle > fullSimVertices; - iEvent.getByLabel("g4SimHits",fullSimVertices); - mySimEvent[0]->fill( *fullSimTracks, *fullSimVertices ); - + iEvent.getByLabel("g4SimHits", fullSimVertices); + mySimEvent[0]->fill(*fullSimTracks, *fullSimVertices); + //std::cout << "Fill fast event " << std::endl; edm::Handle > fastSimTracks; - iEvent.getByLabel("famosSimHits",fastSimTracks); + iEvent.getByLabel("famosSimHits", fastSimTracks); edm::Handle > fastSimVertices; - iEvent.getByLabel("famosSimHits",fastSimVertices); - mySimEvent[1]->fill( *fastSimTracks, *fastSimVertices ); - - for ( unsigned ievt=0; ievt<2; ++ievt ) { + iEvent.getByLabel("famosSimHits", fastSimVertices); + mySimEvent[1]->fill(*fastSimTracks, *fastSimVertices); + for (unsigned ievt = 0; ievt < 2; ++ievt) { // std::cout << "Event number " << ievt << std::endl; // mySimEvent[ievt]->print(); int nvertices = mySimEvent[ievt]->nVertices(); - for(int i=0; ivertex(i); - h0[ievt]->Fill(fabs(vertex.position().z()),vertex.position().pt()); + h0[ievt]->Fill(fabs(vertex.position().z()), vertex.position().pt()); } - - // Loop over all tracks - int ntracks = mySimEvent[ievt]->nTracks(); - - for (int i=0;inTracks(); + + for (int i = 0; i < ntracks; ++i) { FSimTrack& myTrack = mySimEvent[ievt]->track(i); std::vector myGammas; // Select the original electrons - if (abs(myTrack.type()) == 11 && myTrack.vertex().noParent()) { - int firstDaughter = -1; - int lastDaughter = -1; - unsigned nbrems=0; - unsigned nbremsmin=0; - double feta=fabs(myTrack.momentum().eta()); - // Plot electron pseudo-rapidity - h1[ievt]->Fill(feta); - - if ( myTrack.nDaughters() ) { - firstDaughter = myTrack.daughters()[0]; - lastDaughter = myTrack.daughters()[myTrack.nDaughters()-1]; - } - - XYZTLorentzVector theElectron=myTrack.momentum(); - // std::cout << " The starting electron " << theElectron << " " - // << myTrack.vertex().position() << " " - // << myTrack.endVertex().position() << " " - // << myTrack.nDaughters() << " " - // << firstDaughter << " " - // << lastDaughter << " " - // << std::endl; - - // Fill the photons. - if(!(firstDaughter<0||lastDaughter<0)) { - - for(int igamma=firstDaughter;igamma<=lastDaughter;++igamma) { - FSimTrack myGamma = mySimEvent[ievt]->track(igamma); - if(myGamma.type()!=22) continue; - XYZTLorentzVector theFather=theElectron; - theElectron=theElectron-myGamma.momentum(); - nbrems++; - if(myGamma.momentum().e() < 0.5 || -// myGamma.momentum().e() > 10. || - myGamma.momentum().e()/theElectron.e() < 0.005 ) continue; - nbremsmin++; - myGammas.push_back(igamma); - - h2[ievt]->Fill(myGamma.momentum().e()); - h3[ievt]->Fill(myGamma.momentum().e()/theFather.e()); - - } - h4[ievt]->Fill(nbrems); - h5[ievt]->Fill(nbremsmin); - } + if (abs(myTrack.type()) == 11 && myTrack.vertex().noParent()) { + int firstDaughter = -1; + int lastDaughter = -1; + unsigned nbrems = 0; + unsigned nbremsmin = 0; + double feta = fabs(myTrack.momentum().eta()); + // Plot electron pseudo-rapidity + h1[ievt]->Fill(feta); + + if (myTrack.nDaughters()) { + firstDaughter = myTrack.daughters()[0]; + lastDaughter = myTrack.daughters()[myTrack.nDaughters() - 1]; + } + + XYZTLorentzVector theElectron = myTrack.momentum(); + // std::cout << " The starting electron " << theElectron << " " + // << myTrack.vertex().position() << " " + // << myTrack.endVertex().position() << " " + // << myTrack.nDaughters() << " " + // << firstDaughter << " " + // << lastDaughter << " " + // << std::endl; + + // Fill the photons. + if (!(firstDaughter < 0 || lastDaughter < 0)) { + for (int igamma = firstDaughter; igamma <= lastDaughter; ++igamma) { + FSimTrack myGamma = mySimEvent[ievt]->track(igamma); + if (myGamma.type() != 22) + continue; + XYZTLorentzVector theFather = theElectron; + theElectron = theElectron - myGamma.momentum(); + nbrems++; + if (myGamma.momentum().e() < 0.5 || + // myGamma.momentum().e() > 10. || + myGamma.momentum().e() / theElectron.e() < 0.005) + continue; + nbremsmin++; + myGammas.push_back(igamma); + + h2[ievt]->Fill(myGamma.momentum().e()); + h3[ievt]->Fill(myGamma.momentum().e() / theFather.e()); + } + h4[ievt]->Fill(nbrems); + h5[ievt]->Fill(nbremsmin); + } } else { - continue; + continue; } // Loop over all stored brems - for(unsigned ig=0;igtrack(myGammas[ig]); - float radius = theGamma.vertex().position().pt(); - float zed = fabs(theGamma.vertex().position().z()); - float eta = fabs(theGamma.vertex().position().eta()); - - // Fill the individual layer histograms ! - bool filled = false; - for ( unsigned hist=0; histFill(eta); - filled = true; - } - } - if (!filled) h6[ievt]->Fill(zed,radius); - - // Fill the block histograms ! - filled = false; - for ( unsigned hist=0; histFill(eta); - filled = true; - } - } - if (!filled) h7[ievt]->Fill(zed,radius); + for (unsigned ig = 0; ig < myGammas.size(); ++ig) { + FSimTrack theGamma = mySimEvent[ievt]->track(myGammas[ig]); + float radius = theGamma.vertex().position().pt(); + float zed = fabs(theGamma.vertex().position().z()); + float eta = fabs(theGamma.vertex().position().eta()); + + // Fill the individual layer histograms ! + bool filled = false; + for (unsigned hist = 0; hist < h100.size() && !filled; ++hist) { + if (eta < 5. && (radius < trackerRadius[hist][ievt] && zed < trackerLength[hist][ievt])) { + h100[hist][ievt]->Fill(eta); + filled = true; + } + } + if (!filled) + h6[ievt]->Fill(zed, radius); + + // Fill the block histograms ! + filled = false; + for (unsigned hist = 0; hist < h200.size() && !filled; ++hist) { + if (eta < 5. && (radius < blockTrackerRadius[hist][ievt] && zed < blockTrackerLength[hist][ievt])) { + h200[hist][ievt]->Fill(eta); + filled = true; + } + } + if (!filled) + h7[ievt]->Fill(zed, radius); // Patrice - if ( eta > 3.) { + if (eta > 3.) { h13[ievt]->Fill(radius); h14[ievt]->Fill(radius); - if ( eta < 3.61 ) h15[ievt]->Fill(eta); - if ( eta >= 3.61 && eta < 4.835 ) h16[ievt]->Fill(eta); - if ( eta >= 4.835 && eta < 4.915 ) h17[ievt]->Fill(eta); + if (eta < 3.61) + h15[ievt]->Fill(eta); + if (eta >= 3.61 && eta < 4.835) + h16[ievt]->Fill(eta); + if (eta >= 4.835 && eta < 4.915) + h17[ievt]->Fill(eta); } - // Fill the cumulative histograms ! - for ( unsigned hist=0; hist=4 ) h300[hist][ievt]->Fill(eta); - if ( hist == 0 ) h8[ievt]->Fill(zed,radius); - if ( hist == 1 ) h9[ievt]->Fill(zed,radius); - if ( hist == 2 ) h10[ievt]->Fill(zed,radius); - if ( hist == 3 ) h11[ievt]->Fill(zed,radius); - if ( hist == 4 ) h12[ievt]->Fill(zed,radius); - } - } - + // Fill the cumulative histograms ! + for (unsigned hist = 0; hist < h300.size(); ++hist) { + if ((radius < subTrackerRadius[hist][ievt] && zed < subTrackerLength[hist][ievt]) || + (hist == 2 && radius < subTrackerRadius[1][ievt] && zed < subTrackerLength[1][ievt])) { + if ((hist <= 3 && eta < 5.) || hist >= 4) + h300[hist][ievt]->Fill(eta); + if (hist == 0) + h8[ievt]->Fill(zed, radius); + if (hist == 1) + h9[ievt]->Fill(zed, radius); + if (hist == 2) + h10[ievt]->Fill(zed, radius); + if (hist == 3) + h11[ievt]->Fill(zed, radius); + if (hist == 4) + h12[ievt]->Fill(zed, radius); + } + } } } } diff --git a/FastSimulation/MaterialEffects/test/testNuclearInteractions.cc b/FastSimulation/MaterialEffects/test/testNuclearInteractions.cc index 86da2ede57feb..98765948983b4 100644 --- a/FastSimulation/MaterialEffects/test/testNuclearInteractions.cc +++ b/FastSimulation/MaterialEffects/test/testNuclearInteractions.cc @@ -26,16 +26,15 @@ #include "TProcessID.h" class testNuclearInteractions : public DQMEDAnalyzer { - -public : +public: explicit testNuclearInteractions(const edm::ParameterSet&); ~testNuclearInteractions(); - virtual void analyze(const edm::Event&, const edm::EventSetup& ) override; - virtual void dqmBeginRun(edm::Run const&, const edm::EventSetup & ) override; - void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override; + virtual void analyze(const edm::Event&, const edm::EventSetup&) override; + virtual void dqmBeginRun(edm::Run const&, const edm::EventSetup&) override; + void bookHistograms(DQMStore::IBooker&, edm::Run const&, edm::EventSetup const&) override; + private: - // See RecoParticleFlow/PFProducer/interface/PFProducer.h edm::ParameterSet particleFilter_; bool saveNU; @@ -61,15 +60,15 @@ public : std::vector htmp; std::vector totalCharge; - std::vector< std::vector > h100; - std::vector< std::vector > h200; - std::vector< std::vector > h300; - std::vector< std::vector > trackerRadius; - std::vector< std::vector > trackerLength; - std::vector< std::vector > blockTrackerRadius; - std::vector< std::vector > blockTrackerLength; - std::vector< std::vector > subTrackerRadius; - std::vector< std::vector > subTrackerLength; + std::vector > h100; + std::vector > h200; + std::vector > h300; + std::vector > trackerRadius; + std::vector > trackerLength; + std::vector > blockTrackerRadius; + std::vector > blockTrackerLength; + std::vector > subTrackerRadius; + std::vector > subTrackerLength; std::vector tmpRadius; std::vector tmpLength; @@ -92,29 +91,28 @@ public : int totalNEvt; int totalNU; int maxNU; - }; -testNuclearInteractions::testNuclearInteractions(const edm::ParameterSet& p) : - mySimEvent(2, static_cast(0)), - h0(2,static_cast(0)), - h1(2,static_cast(0)), - h2(2,static_cast(0)), - h3(2,static_cast(0)), - h4(2,static_cast(0)), - h5(2,static_cast(0)), - h6(2,static_cast(0)), - h7(2,static_cast(0)), - h8(2,static_cast(0)), - h9(2,static_cast(0)), - h10(2,static_cast(0)), - htmp(2,static_cast(0)), - totalCharge(2,static_cast(0)), - tmpRadius(2,static_cast(0.)), - tmpLength(2,static_cast(0.)), - stoppedPions(2,static_cast(0)), - interactingPions(2,static_cast(0)), - /* +testNuclearInteractions::testNuclearInteractions(const edm::ParameterSet& p) + : mySimEvent(2, static_cast(0)), + h0(2, static_cast(0)), + h1(2, static_cast(0)), + h2(2, static_cast(0)), + h3(2, static_cast(0)), + h4(2, static_cast(0)), + h5(2, static_cast(0)), + h6(2, static_cast(0)), + h7(2, static_cast(0)), + h8(2, static_cast(0)), + h9(2, static_cast(0)), + h10(2, static_cast(0)), + htmp(2, static_cast(0)), + totalCharge(2, static_cast(0)), + tmpRadius(2, static_cast(0.)), + tmpLength(2, static_cast(0.)), + stoppedPions(2, static_cast(0)), + interactingPions(2, static_cast(0)), + /* h6(2,static_cast(0)), h7(2,static_cast(0)), h8(2,static_cast(0)), @@ -123,20 +121,17 @@ testNuclearInteractions::testNuclearInteractions(const edm::ParameterSet& p) : h11(2,static_cast(0)), h12(2,static_cast(0)), */ - intfull(0), - intfast(0), - totalNEvt(0), - totalNU(0) -{ - + intfull(0), + intfast(0), + totalNEvt(0), + totalNU(0) { // Let's just initialize the SimEvent's - particleFilter_ = p.getParameter - ( "TestParticleFilter" ); + particleFilter_ = p.getParameter("TestParticleFilter"); // Do we save the nuclear interactions? saveNU = p.getParameter("SaveNuclearInteractions"); maxNU = p.getParameter("MaxNumberOfNuclearInteractions"); - if ( saveNU ) + if (saveNU) std::cout << "Nuclear Interactions will be saved ! " << std::endl; // For the full sim @@ -146,24 +141,21 @@ testNuclearInteractions::testNuclearInteractions(const edm::ParameterSet& p) : // Where the nuclear interactions are saved; NUEventFileName = "none"; - if ( saveNU ) { - + if (saveNU) { nuEvent = new NUEvent(); - - NUEventFileName = - p.getUntrackedParameter("NUEventFile","NuclearInteractionsTest.root"); + + NUEventFileName = p.getUntrackedParameter("NUEventFile", "NuclearInteractionsTest.root"); // std::string outFileName = "NuclearInteractionsTest.root"; - outFile = new TFile(NUEventFileName.c_str(),"recreate"); + outFile = new TFile(NUEventFileName.c_str(), "recreate"); // Open the tree - nuTree = new TTree("NuclearInteractions",""); - nuTree->Branch("nuEvent","NUEvent",&nuEvent,32000,99); - + nuTree = new TTree("NuclearInteractions", ""); + nuTree->Branch("nuEvent", "NUEvent", &nuEvent, 32000, 99); } // ObjectNumber ObjectNumber = -1; - + // Beam Pipe std::vector tmpRadius = p.getUntrackedParameter >("BPCylinderRadius"); std::vector tmpLength = p.getUntrackedParameter >("BPCylinderLength"); @@ -398,7 +390,7 @@ testNuclearInteractions::testNuclearInteractions(const edm::ParameterSet& p) : blockTrackerRadius.push_back(tmpRadius); blockTrackerLength.push_back(tmpLength); - // All Outer + // All Outer subTrackerRadius.push_back(tmpRadius); subTrackerLength.push_back(tmpLength); @@ -413,42 +405,39 @@ testNuclearInteractions::testNuclearInteractions(const edm::ParameterSet& p) : blockTrackerRadius.push_back(tmpRadius); blockTrackerLength.push_back(tmpLength); - // All + // All h300.push_back(htmp); subTrackerRadius.push_back(tmpRadius); subTrackerLength.push_back(tmpLength); - } - -void testNuclearInteractions::bookHistograms(DQMStore::IBooker & ibooker, - edm::Run const & iRun, - edm::EventSetup const & iSetup) -{ +void testNuclearInteractions::bookHistograms(DQMStore::IBooker& ibooker, + edm::Run const& iRun, + edm::EventSetup const& iSetup) { ibooker.setCurrentFolder("testNuclearInteractions"); - h0[0] = ibooker.book2D("radioFull", "Full Tracker radiography", 1000, 0.,320.,1000,0., 150. ); - h0[1] = ibooker.book2D("radioFast", "Fast Tracker radiography", 1000, 0.,320.,1000,0., 150. ); - h1[0] = ibooker.book1D("vertexFull", "Full Nb of Vertices",20,-0.5,19.5); - h1[1] = ibooker.book1D("vertexFast", "Fast Nb of Vertices",20,-0.5,19.5); - h2[0] = ibooker.book1D("daughterFull", "Full Nb of daughters",20,-0.5,19.5); - h2[1] = ibooker.book1D("daughterFast", "Fast Nb of daughters",20,-0.5,19.5); - h3[0] = ibooker.book1D("ecmFull", "Full centre-of-mass energy",100,0.,10.); - h3[1] = ibooker.book1D("ecmFast", "Fast centre-of-mass energy",100,0.,10.); - h4[0] = ibooker.book1D("FecmFull", "Full c.m. energy fraction",100,0.,2.); - h4[1] = ibooker.book1D("FecmFast", "Fast c.m. energy fraction",100,0.,2.); - h5[0] = ibooker.book1D("FmomFull", "Full momemtum",100,0.,10.); - h5[1] = ibooker.book1D("FmomFast", "Fast momemtum",100,0.,10.); - h6[0] = ibooker.book1D("DeltaEFull4", "Full DeltaE",2000,-1.,4.); - h6[1] = ibooker.book1D("DeltaEFast4", "Fast DetlaE",2000,-1.,4.); - h7[0] = ibooker.book1D("DeltaEFull3", "Full DeltaE 3 daugh",2000,-1.,4.); - h7[1] = ibooker.book1D("DeltaEFast3", "Fast DetlaE 3 daugh",2000,-1.,4.); - h8[0] = ibooker.book1D("DeltaMFull4", "Full DeltaE",2000,-10.,40.); - h8[1] = ibooker.book1D("DeltaMFast4", "Fast DetlaE",2000,-10.,40.); - h9[0] = ibooker.book1D("DeltaMFull3", "Full DeltaE 3 daugh",2000,-10.,40.); - h9[1] = ibooker.book1D("DeltaMFast3", "Fast DetlaE 3 daugh",2000,-10.,40.); - h10[0] = ibooker.book1D("EafterFull", "E(after)/E(before) full",200,0.,4.); - h10[1] = ibooker.book1D("EafterFast", "E(after)/E(before) fast",200,0.,4.); + h0[0] = ibooker.book2D("radioFull", "Full Tracker radiography", 1000, 0., 320., 1000, 0., 150.); + h0[1] = ibooker.book2D("radioFast", "Fast Tracker radiography", 1000, 0., 320., 1000, 0., 150.); + h1[0] = ibooker.book1D("vertexFull", "Full Nb of Vertices", 20, -0.5, 19.5); + h1[1] = ibooker.book1D("vertexFast", "Fast Nb of Vertices", 20, -0.5, 19.5); + h2[0] = ibooker.book1D("daughterFull", "Full Nb of daughters", 20, -0.5, 19.5); + h2[1] = ibooker.book1D("daughterFast", "Fast Nb of daughters", 20, -0.5, 19.5); + h3[0] = ibooker.book1D("ecmFull", "Full centre-of-mass energy", 100, 0., 10.); + h3[1] = ibooker.book1D("ecmFast", "Fast centre-of-mass energy", 100, 0., 10.); + h4[0] = ibooker.book1D("FecmFull", "Full c.m. energy fraction", 100, 0., 2.); + h4[1] = ibooker.book1D("FecmFast", "Fast c.m. energy fraction", 100, 0., 2.); + h5[0] = ibooker.book1D("FmomFull", "Full momemtum", 100, 0., 10.); + h5[1] = ibooker.book1D("FmomFast", "Fast momemtum", 100, 0., 10.); + h6[0] = ibooker.book1D("DeltaEFull4", "Full DeltaE", 2000, -1., 4.); + h6[1] = ibooker.book1D("DeltaEFast4", "Fast DetlaE", 2000, -1., 4.); + h7[0] = ibooker.book1D("DeltaEFull3", "Full DeltaE 3 daugh", 2000, -1., 4.); + h7[1] = ibooker.book1D("DeltaEFast3", "Fast DetlaE 3 daugh", 2000, -1., 4.); + h8[0] = ibooker.book1D("DeltaMFull4", "Full DeltaE", 2000, -10., 40.); + h8[1] = ibooker.book1D("DeltaMFast4", "Fast DetlaE", 2000, -10., 40.); + h9[0] = ibooker.book1D("DeltaMFull3", "Full DeltaE 3 daugh", 2000, -10., 40.); + h9[1] = ibooker.book1D("DeltaMFast3", "Fast DetlaE 3 daugh", 2000, -10., 40.); + h10[0] = ibooker.book1D("EafterFull", "E(after)/E(before) full", 200, 0., 4.); + h10[1] = ibooker.book1D("EafterFast", "E(after)/E(before) fast", 200, 0., 4.); /* h6[0] = ibooker.book2D("radioFullRem1", "Full Tracker radiography", 1000, 0.,320.,1000,0., 150. ); h6[1] = ibooker.book2D("radioFastRem1", "Fast Tracker radiography", 1000, 0.,320.,1000,0., 150. ); @@ -466,245 +455,242 @@ void testNuclearInteractions::bookHistograms(DQMStore::IBooker & ibooker, h12[1] = ibooker.book2D("radioFastCA", "Fast CA radiography", 1000, 0.,320.,1000,0., 150. ); */ - totalCharge[0] = ibooker.book1D("ChargeFull", "Total Charge (full)",19,-9.5,9.5); - totalCharge[1] = ibooker.book1D("ChargeFast", "Total Charge (fast)",19,-9.5,9.5); + totalCharge[0] = ibooker.book1D("ChargeFull", "Total Charge (full)", 19, -9.5, 9.5); + totalCharge[1] = ibooker.book1D("ChargeFast", "Total Charge (fast)", 19, -9.5, 9.5); // Beam Pipe - htmp[0] = ibooker.book1D("BeamPipeFull", "Full Beam Pipe",120,0.,3.); - htmp[1] = ibooker.book1D("BeamPipeFast", "Fast Beam Pipe",120,0.,3.); + htmp[0] = ibooker.book1D("BeamPipeFull", "Full Beam Pipe", 120, 0., 3.); + htmp[1] = ibooker.book1D("BeamPipeFast", "Fast Beam Pipe", 120, 0., 3.); h100.push_back(htmp); // Beam Pipe (cont'd) - htmp[0] = ibooker.book1D("BPFull", "Full Beam Pipe",120,0.,3.); - htmp[1] = ibooker.book1D("BPFast", "Fast Beam Pipe",120,0.,3.); + htmp[0] = ibooker.book1D("BPFull", "Full Beam Pipe", 120, 0., 3.); + htmp[1] = ibooker.book1D("BPFast", "Fast Beam Pipe", 120, 0., 3.); h300.push_back(htmp); // PIXB1 - htmp[0] = ibooker.book1D("PXB1Full", "Full Pixel Barrel 1",120,0.,3.); - htmp[1] = ibooker.book1D("PXB1Fast", "Fast Pixel Barrel 1",120,0.,3.); + htmp[0] = ibooker.book1D("PXB1Full", "Full Pixel Barrel 1", 120, 0., 3.); + htmp[1] = ibooker.book1D("PXB1Fast", "Fast Pixel Barrel 1", 120, 0., 3.); h100.push_back(htmp); // PIXB2 - htmp[0] = ibooker.book1D("PXB2Full", "Full Pixel Barrel 2",120,0.,3.); - htmp[1] = ibooker.book1D("PXB2Fast", "Fast Pixel Barrel 2",120,0.,3.); + htmp[0] = ibooker.book1D("PXB2Full", "Full Pixel Barrel 2", 120, 0., 3.); + htmp[1] = ibooker.book1D("PXB2Fast", "Fast Pixel Barrel 2", 120, 0., 3.); h100.push_back(htmp); // PIXB3 - htmp[0] = ibooker.book1D("PXB3Full", "Full Pixel Barrel 3",120,0.,3.); - htmp[1] = ibooker.book1D("PXB3Fast", "Fast Pixel Barrel 3",120,0.,3.); + htmp[0] = ibooker.book1D("PXB3Full", "Full Pixel Barrel 3", 120, 0., 3.); + htmp[1] = ibooker.book1D("PXB3Fast", "Fast Pixel Barrel 3", 120, 0., 3.); h100.push_back(htmp); // PIXB Cables - htmp[0] = ibooker.book1D("PXBCFull", "Full Pixel Barrel Cables",120,0.,3.); - htmp[1] = ibooker.book1D("PXBCFast", "Fast Pixel Barrel Cables",120,0.,3.); + htmp[0] = ibooker.book1D("PXBCFull", "Full Pixel Barrel Cables", 120, 0., 3.); + htmp[1] = ibooker.book1D("PXBCFast", "Fast Pixel Barrel Cables", 120, 0., 3.); h100.push_back(htmp); // All Pixel Barrel - htmp[0] = ibooker.book1D("PXBFull", "Full Pixel Barrel",120,0.,3.); - htmp[1] = ibooker.book1D("PXBFast", "Fast Pixel Barrel",120,0.,3.); + htmp[0] = ibooker.book1D("PXBFull", "Full Pixel Barrel", 120, 0., 3.); + htmp[1] = ibooker.book1D("PXBFast", "Fast Pixel Barrel", 120, 0., 3.); h200.push_back(htmp); // PIXD1 - htmp[0] = ibooker.book1D("PXD1Full", "Full Pixel Disk 1",120,0.,3.); - htmp[1] = ibooker.book1D("PXD1Fast", "Fast Pixel Disk 1",120,0.,3.); + htmp[0] = ibooker.book1D("PXD1Full", "Full Pixel Disk 1", 120, 0., 3.); + htmp[1] = ibooker.book1D("PXD1Fast", "Fast Pixel Disk 1", 120, 0., 3.); h100.push_back(htmp); // PIXD2 - htmp[0] = ibooker.book1D("PXD2Full", "Full Pixel Disk 2",120,0.,3.); - htmp[1] = ibooker.book1D("PXD2Fast", "Fast Pixel Disk 2",120,0.,3.); + htmp[0] = ibooker.book1D("PXD2Full", "Full Pixel Disk 2", 120, 0., 3.); + htmp[1] = ibooker.book1D("PXD2Fast", "Fast Pixel Disk 2", 120, 0., 3.); h100.push_back(htmp); // PIXD Cables - htmp[0] = ibooker.book1D("PXDCFull", "Full Pixel Disk Cables",120,0.,3.); - htmp[1] = ibooker.book1D("PXDCFast", "Fast Pixel Disk Cables",120,0.,3.); + htmp[0] = ibooker.book1D("PXDCFull", "Full Pixel Disk Cables", 120, 0., 3.); + htmp[1] = ibooker.book1D("PXDCFast", "Fast Pixel Disk Cables", 120, 0., 3.); h100.push_back(htmp); // All Pixel Disks - htmp[0] = ibooker.book1D("PXDFull", "Full Pixel Disk",120,0.,3.); - htmp[1] = ibooker.book1D("PXDFast", "Fast Pixel Disk",120,0.,3.); + htmp[0] = ibooker.book1D("PXDFull", "Full Pixel Disk", 120, 0., 3.); + htmp[1] = ibooker.book1D("PXDFast", "Fast Pixel Disk", 120, 0., 3.); h200.push_back(htmp); // All Pixel - htmp[0] = ibooker.book1D("PixelFull", "Full Pixel",120,0.,3.); - htmp[1] = ibooker.book1D("PixelFast", "Fast Pixel",120,0.,3.); + htmp[0] = ibooker.book1D("PixelFull", "Full Pixel", 120, 0., 3.); + htmp[1] = ibooker.book1D("PixelFast", "Fast Pixel", 120, 0., 3.); h300.push_back(htmp); // TIB1 - htmp[0] = ibooker.book1D("TIB1Full", "Full Tracker Inner Barrel 1",120,0.,3.); - htmp[1] = ibooker.book1D("TIB1Fast", "Fast Tracker Inner Barrel 1",120,0.,3.); + htmp[0] = ibooker.book1D("TIB1Full", "Full Tracker Inner Barrel 1", 120, 0., 3.); + htmp[1] = ibooker.book1D("TIB1Fast", "Fast Tracker Inner Barrel 1", 120, 0., 3.); h100.push_back(htmp); // TIB2 - htmp[0] = ibooker.book1D("TIB2Full", "Full Tracker Inner Barrel 2",120,0.,3.); - htmp[1] = ibooker.book1D("TIB2Fast", "Fast Tracker Inner Barrel 2",120,0.,3.); + htmp[0] = ibooker.book1D("TIB2Full", "Full Tracker Inner Barrel 2", 120, 0., 3.); + htmp[1] = ibooker.book1D("TIB2Fast", "Fast Tracker Inner Barrel 2", 120, 0., 3.); h100.push_back(htmp); // TIB3 - htmp[0] = ibooker.book1D("TIB3Full", "Full Tracker Inner Barrel 3",120,0.,3.); - htmp[1] = ibooker.book1D("TIB3Fast", "Fast Tracker Inner Barrel 3",120,0.,3.); + htmp[0] = ibooker.book1D("TIB3Full", "Full Tracker Inner Barrel 3", 120, 0., 3.); + htmp[1] = ibooker.book1D("TIB3Fast", "Fast Tracker Inner Barrel 3", 120, 0., 3.); h100.push_back(htmp); // TIB4 - htmp[0] = ibooker.book1D("TIB4Full", "Full Tracker Inner Barrel 4",120,0.,3.); - htmp[1] = ibooker.book1D("TIB4Fast", "Fast Tracker Inner Barrel 4",120,0.,3.); + htmp[0] = ibooker.book1D("TIB4Full", "Full Tracker Inner Barrel 4", 120, 0., 3.); + htmp[1] = ibooker.book1D("TIB4Fast", "Fast Tracker Inner Barrel 4", 120, 0., 3.); h100.push_back(htmp); // TIB Cables - htmp[0] = ibooker.book1D("TIBCFull", "Full Tracker Inner Barrel Cables",120,0.,3.); - htmp[1] = ibooker.book1D("TIBCFast", "Fast Tracker Inner Barrel Cables",120,0.,3.); + htmp[0] = ibooker.book1D("TIBCFull", "Full Tracker Inner Barrel Cables", 120, 0., 3.); + htmp[1] = ibooker.book1D("TIBCFast", "Fast Tracker Inner Barrel Cables", 120, 0., 3.); h100.push_back(htmp); // All TIB - htmp[0] = ibooker.book1D("TIBFull", "Full Tracker Inner Barrel",120,0.,3.); - htmp[1] = ibooker.book1D("TIBFast", "Fast Tracker Inner Barrel",120,0.,3.); + htmp[0] = ibooker.book1D("TIBFull", "Full Tracker Inner Barrel", 120, 0., 3.); + htmp[1] = ibooker.book1D("TIBFast", "Fast Tracker Inner Barrel", 120, 0., 3.); h200.push_back(htmp); // TID1 - htmp[0] = ibooker.book1D("TID1Full", "Full Tracker Inner Disk 1",120,0.,3.); - htmp[1] = ibooker.book1D("TID1Fast", "Fast Tracker Inner Disk 1",120,0.,3.); + htmp[0] = ibooker.book1D("TID1Full", "Full Tracker Inner Disk 1", 120, 0., 3.); + htmp[1] = ibooker.book1D("TID1Fast", "Fast Tracker Inner Disk 1", 120, 0., 3.); h100.push_back(htmp); // TID2 - htmp[0] = ibooker.book1D("TID2Full", "Full Tracker Inner Disk 2",120,0.,3.); - htmp[1] = ibooker.book1D("TID2Fast", "Fast Tracker Inner Disk 2",120,0.,3.); + htmp[0] = ibooker.book1D("TID2Full", "Full Tracker Inner Disk 2", 120, 0., 3.); + htmp[1] = ibooker.book1D("TID2Fast", "Fast Tracker Inner Disk 2", 120, 0., 3.); h100.push_back(htmp); // TID3 - htmp[0] = ibooker.book1D("TID3Full", "Full Tracker Inner Disk 3",120,0.,3.); - htmp[1] = ibooker.book1D("TID3Fast", "Fast Tracker Inner Disk 3",120,0.,3.); + htmp[0] = ibooker.book1D("TID3Full", "Full Tracker Inner Disk 3", 120, 0., 3.); + htmp[1] = ibooker.book1D("TID3Fast", "Fast Tracker Inner Disk 3", 120, 0., 3.); h100.push_back(htmp); // TID Cables - htmp[0] = ibooker.book1D("TIDCFull", "Full Tracker Inner Disk Cables",120,0.,3.); - htmp[1] = ibooker.book1D("TIDCFast", "Fast Tracker Inner Disk Cables",120,0.,3.); + htmp[0] = ibooker.book1D("TIDCFull", "Full Tracker Inner Disk Cables", 120, 0., 3.); + htmp[1] = ibooker.book1D("TIDCFast", "Fast Tracker Inner Disk Cables", 120, 0., 3.); h100.push_back(htmp); // All TID - htmp[0] = ibooker.book1D("TIDFull", "Full Tracker Inner Disk",120,0.,3.); - htmp[1] = ibooker.book1D("TIDFast", "Fast Tracker Inner Disk",120,0.,3.); + htmp[0] = ibooker.book1D("TIDFull", "Full Tracker Inner Disk", 120, 0., 3.); + htmp[1] = ibooker.book1D("TIDFast", "Fast Tracker Inner Disk", 120, 0., 3.); h200.push_back(htmp); // All Inner Tracker - htmp[0] = ibooker.book1D("InnerFull", "Full Inner Tracker",120,0.,3.); - htmp[1] = ibooker.book1D("InnerFast", "Fast Inner Tracker",120,0.,3.); + htmp[0] = ibooker.book1D("InnerFull", "Full Inner Tracker", 120, 0., 3.); + htmp[1] = ibooker.book1D("InnerFast", "Fast Inner Tracker", 120, 0., 3.); h300.push_back(htmp); // TOB1 - htmp[0] = ibooker.book1D("TOB1Full", "Full Tracker Outer Barrel 1",120,0.,3.); - htmp[1] = ibooker.book1D("TOB1Fast", "Fast Tracker Outer Barrel 1",120,0.,3.); + htmp[0] = ibooker.book1D("TOB1Full", "Full Tracker Outer Barrel 1", 120, 0., 3.); + htmp[1] = ibooker.book1D("TOB1Fast", "Fast Tracker Outer Barrel 1", 120, 0., 3.); h100.push_back(htmp); // TOB2 - htmp[0] = ibooker.book1D("TOB2Full", "Full Tracker Outer Barrel 2",120,0.,3.); - htmp[1] = ibooker.book1D("TOB2Fast", "Fast Tracker Outer Barrel 2",120,0.,3.); + htmp[0] = ibooker.book1D("TOB2Full", "Full Tracker Outer Barrel 2", 120, 0., 3.); + htmp[1] = ibooker.book1D("TOB2Fast", "Fast Tracker Outer Barrel 2", 120, 0., 3.); h100.push_back(htmp); // TOB3 - htmp[0] = ibooker.book1D("TOB3Full", "Full Tracker Outer Barrel 3",120,0.,3.); - htmp[1] = ibooker.book1D("TOB3Fast", "Fast Tracker Outer Barrel 3",120,0.,3.); + htmp[0] = ibooker.book1D("TOB3Full", "Full Tracker Outer Barrel 3", 120, 0., 3.); + htmp[1] = ibooker.book1D("TOB3Fast", "Fast Tracker Outer Barrel 3", 120, 0., 3.); h100.push_back(htmp); // TOB4 - htmp[0] = ibooker.book1D("TOB4Full", "Full Tracker Outer Barrel 4",120,0.,3.); - htmp[1] = ibooker.book1D("TOB4Fast", "Fast Tracker Outer Barrel 4",120,0.,3.); + htmp[0] = ibooker.book1D("TOB4Full", "Full Tracker Outer Barrel 4", 120, 0., 3.); + htmp[1] = ibooker.book1D("TOB4Fast", "Fast Tracker Outer Barrel 4", 120, 0., 3.); h100.push_back(htmp); // TOB5 - htmp[0] = ibooker.book1D("TOB5Full", "Full Tracker Outer Barrel 5",120,0.,3.); - htmp[1] = ibooker.book1D("TOB5Fast", "Fast Tracker Outer Barrel 5",120,0.,3.); + htmp[0] = ibooker.book1D("TOB5Full", "Full Tracker Outer Barrel 5", 120, 0., 3.); + htmp[1] = ibooker.book1D("TOB5Fast", "Fast Tracker Outer Barrel 5", 120, 0., 3.); h100.push_back(htmp); // TOB6 - htmp[0] = ibooker.book1D("TOB6Full", "Full Tracker Outer Barrel 6",120,0.,3.); - htmp[1] = ibooker.book1D("TOB6Fast", "Fast Tracker Outer Barrel 6",120,0.,3.); + htmp[0] = ibooker.book1D("TOB6Full", "Full Tracker Outer Barrel 6", 120, 0., 3.); + htmp[1] = ibooker.book1D("TOB6Fast", "Fast Tracker Outer Barrel 6", 120, 0., 3.); h100.push_back(htmp); // TOB Cables - htmp[0] = ibooker.book1D("TOBCFull", "Full Tracker Outer Barrel Cables",120,0.,3.); - htmp[1] = ibooker.book1D("TOBCFast", "Fast Tracker Outer Barrel Cables",120,0.,3.); + htmp[0] = ibooker.book1D("TOBCFull", "Full Tracker Outer Barrel Cables", 120, 0., 3.); + htmp[1] = ibooker.book1D("TOBCFast", "Fast Tracker Outer Barrel Cables", 120, 0., 3.); h100.push_back(htmp); // All TOB - htmp[0] = ibooker.book1D("TOBFull", "Full Tracker Outer Barrel",120,0.,3.); - htmp[1] = ibooker.book1D("TOBFast", "Fast Tracker Outer Barrel",120,0.,3.); + htmp[0] = ibooker.book1D("TOBFull", "Full Tracker Outer Barrel", 120, 0., 3.); + htmp[1] = ibooker.book1D("TOBFast", "Fast Tracker Outer Barrel", 120, 0., 3.); h200.push_back(htmp); // TEC1 - htmp[0] = ibooker.book1D("TEC1Full", "Full Tracker EndCap 1",120,0.,3.); - htmp[1] = ibooker.book1D("TEC1Fast", "Fast Tracker Endcap 1",120,0.,3.); + htmp[0] = ibooker.book1D("TEC1Full", "Full Tracker EndCap 1", 120, 0., 3.); + htmp[1] = ibooker.book1D("TEC1Fast", "Fast Tracker Endcap 1", 120, 0., 3.); h100.push_back(htmp); // TEC2 - htmp[0] = ibooker.book1D("TEC2Full", "Full Tracker EndCap 2",120,0.,3.); - htmp[1] = ibooker.book1D("TEC2Fast", "Fast Tracker Endcap 2",120,0.,3.); + htmp[0] = ibooker.book1D("TEC2Full", "Full Tracker EndCap 2", 120, 0., 3.); + htmp[1] = ibooker.book1D("TEC2Fast", "Fast Tracker Endcap 2", 120, 0., 3.); h100.push_back(htmp); // TEC3 - htmp[0] = ibooker.book1D("TEC3Full", "Full Tracker EndCap 3",120,0.,3.); - htmp[1] = ibooker.book1D("TEC3Fast", "Fast Tracker Endcap 3",120,0.,3.); + htmp[0] = ibooker.book1D("TEC3Full", "Full Tracker EndCap 3", 120, 0., 3.); + htmp[1] = ibooker.book1D("TEC3Fast", "Fast Tracker Endcap 3", 120, 0., 3.); h100.push_back(htmp); // TEC4 - htmp[0] = ibooker.book1D("TEC4Full", "Full Tracker EndCap 4",120,0.,3.); - htmp[1] = ibooker.book1D("TEC4Fast", "Fast Tracker Endcap 4",120,0.,3.); + htmp[0] = ibooker.book1D("TEC4Full", "Full Tracker EndCap 4", 120, 0., 3.); + htmp[1] = ibooker.book1D("TEC4Fast", "Fast Tracker Endcap 4", 120, 0., 3.); h100.push_back(htmp); // TEC5 - htmp[0] = ibooker.book1D("TEC5Full", "Full Tracker EndCap 5",120,0.,3.); - htmp[1] = ibooker.book1D("TEC5Fast", "Fast Tracker Endcap 5",120,0.,3.); + htmp[0] = ibooker.book1D("TEC5Full", "Full Tracker EndCap 5", 120, 0., 3.); + htmp[1] = ibooker.book1D("TEC5Fast", "Fast Tracker Endcap 5", 120, 0., 3.); h100.push_back(htmp); // TEC6 - htmp[0] = ibooker.book1D("TEC6Full", "Full Tracker EndCap 6",120,0.,3.); - htmp[1] = ibooker.book1D("TEC6Fast", "Fast Tracker Endcap 6",120,0.,3.); + htmp[0] = ibooker.book1D("TEC6Full", "Full Tracker EndCap 6", 120, 0., 3.); + htmp[1] = ibooker.book1D("TEC6Fast", "Fast Tracker Endcap 6", 120, 0., 3.); h100.push_back(htmp); // TEC7 - htmp[0] = ibooker.book1D("TEC7Full", "Full Tracker EndCap 7",120,0.,3.); - htmp[1] = ibooker.book1D("TEC7Fast", "Fast Tracker Endcap 7",120,0.,3.); + htmp[0] = ibooker.book1D("TEC7Full", "Full Tracker EndCap 7", 120, 0., 3.); + htmp[1] = ibooker.book1D("TEC7Fast", "Fast Tracker Endcap 7", 120, 0., 3.); h100.push_back(htmp); // TEC8 - htmp[0] = ibooker.book1D("TEC8Full", "Full Tracker EndCap 8",120,0.,3.); - htmp[1] = ibooker.book1D("TEC8Fast", "Fast Tracker Endcap 8",120,0.,3.); + htmp[0] = ibooker.book1D("TEC8Full", "Full Tracker EndCap 8", 120, 0., 3.); + htmp[1] = ibooker.book1D("TEC8Fast", "Fast Tracker Endcap 8", 120, 0., 3.); h100.push_back(htmp); // TEC9 - htmp[0] = ibooker.book1D("TEC9Full", "Full Tracker EndCap 9",120,0.,3.); - htmp[1] = ibooker.book1D("TEC9Fast", "Fast Tracker Endcap 9",120,0.,3.); + htmp[0] = ibooker.book1D("TEC9Full", "Full Tracker EndCap 9", 120, 0., 3.); + htmp[1] = ibooker.book1D("TEC9Fast", "Fast Tracker Endcap 9", 120, 0., 3.); h100.push_back(htmp); // All TEC - htmp[0] = ibooker.book1D("TECFull", "Full Tracker EndCap",120,0.,3.); - htmp[1] = ibooker.book1D("TECFast", "Fast Tracker EndCap",120,0.,3.); + htmp[0] = ibooker.book1D("TECFull", "Full Tracker EndCap", 120, 0., 3.); + htmp[1] = ibooker.book1D("TECFast", "Fast Tracker EndCap", 120, 0., 3.); h200.push_back(htmp); - // All Outer - htmp[0] = ibooker.book1D("OuterFull", "Full Outer Tracker",120,0.,3.); - htmp[1] = ibooker.book1D("OuterFast", "Fast Outer Tracker",120,0.,3.); + // All Outer + htmp[0] = ibooker.book1D("OuterFull", "Full Outer Tracker", 120, 0., 3.); + htmp[1] = ibooker.book1D("OuterFast", "Fast Outer Tracker", 120, 0., 3.); h300.push_back(htmp); // Outer Cables - htmp[0] = ibooker.book1D("TECCFull", "Full Tracker Outer Cables",120,0.,3.); - htmp[1] = ibooker.book1D("TECCFast", "Fast Tracker Outer Cables",120,0.,3.); + htmp[0] = ibooker.book1D("TECCFull", "Full Tracker Outer Cables", 120, 0., 3.); + htmp[1] = ibooker.book1D("TECCFast", "Fast Tracker Outer Cables", 120, 0., 3.); h100.push_back(htmp); // All TEC - htmp[0] = ibooker.book1D("CablesFull", "Full Tracker Cables",120,0.,3.); - htmp[1] = ibooker.book1D("CablesFast", "Fast Tracker Cables",120,0.,3.); + htmp[0] = ibooker.book1D("CablesFull", "Full Tracker Cables", 120, 0., 3.); + htmp[1] = ibooker.book1D("CablesFast", "Fast Tracker Cables", 120, 0., 3.); h200.push_back(htmp); - // All - htmp[0] = ibooker.book1D("TrackerFull", "Full Tracker",120,0.,3.); - htmp[1] = ibooker.book1D("TrackerFast", "Fast Tracker",120,0.,3.); + // All + htmp[0] = ibooker.book1D("TrackerFull", "Full Tracker", 120, 0., 3.); + htmp[1] = ibooker.book1D("TrackerFast", "Fast Tracker", 120, 0., 3.); h300.push_back(htmp); } -testNuclearInteractions::~testNuclearInteractions() -{ - - if ( saveNU ) { - +testNuclearInteractions::~testNuclearInteractions() { + if (saveNU) { outFile->cd(); // Fill the last (incomplete) nuEvent nuTree->Fill(); @@ -717,80 +703,76 @@ testNuclearInteractions::~testNuclearInteractions() delete nuEvent; delete nuTree; delete outFile; - } - + // delete mySimEvent; } -void testNuclearInteractions::dqmBeginRun(edm::Run const&, const edm::EventSetup & es) -{ +void testNuclearInteractions::dqmBeginRun(edm::Run const&, const edm::EventSetup& es) { // init Particle data table (from Pythia) - edm::ESHandle < HepPDT::ParticleDataTable > pdt; + edm::ESHandle pdt; es.getData(pdt); - + mySimEvent[0]->initializePdt(&(*pdt)); mySimEvent[1]->initializePdt(&(*pdt)); - } -void -testNuclearInteractions::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup ) -{ +void testNuclearInteractions::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) { ++totalNEvt; - if ( totalNEvt/1000*1000 == totalNEvt ) - std::cout << "Number of event analysed/NU " - << totalNEvt << " / " << totalNU << std::endl; + if (totalNEvt / 1000 * 1000 == totalNEvt) + std::cout << "Number of event analysed/NU " << totalNEvt << " / " << totalNU << std::endl; std::unique_ptr nuclSimTracks(new edm::SimTrackContainer); // std::cout << "Fill full event " << std::endl; edm::Handle > fullSimTracks; - iEvent.getByLabel("g4SimHits",fullSimTracks); + iEvent.getByLabel("g4SimHits", fullSimTracks); edm::Handle > fullSimVertices; - iEvent.getByLabel("g4SimHits",fullSimVertices); - mySimEvent[0]->fill( *fullSimTracks, *fullSimVertices ); - + iEvent.getByLabel("g4SimHits", fullSimVertices); + mySimEvent[0]->fill(*fullSimTracks, *fullSimVertices); + // std::cout << "Fill fast event " << std::endl; /* */ - // if ( !saveNU ) { - edm::Handle > fastSimTracks; - iEvent.getByLabel("famosSimHits",fastSimTracks); - edm::Handle > fastSimVertices; - iEvent.getByLabel("famosSimHits",fastSimVertices); - mySimEvent[1]->fill( *fastSimTracks, *fastSimVertices ); + // if ( !saveNU ) { + edm::Handle > fastSimTracks; + iEvent.getByLabel("famosSimHits", fastSimTracks); + edm::Handle > fastSimVertices; + iEvent.getByLabel("famosSimHits", fastSimVertices); + mySimEvent[1]->fill(*fastSimTracks, *fastSimVertices); //} /* */ - + //mySimEvent[0]->print(); - XYZTLorentzVector theProtonMomentum(0.,0.,0.,0.939); + XYZTLorentzVector theProtonMomentum(0., 0., 0., 0.939); // Save the object number count for a new NUevent - if ( saveNU ) { - if ( ObjectNumber == -1 || nuEvent->nInteractions() == 1000 ) { + if (saveNU) { + if (ObjectNumber == -1 || nuEvent->nInteractions() == 1000) { ObjectNumber = TProcessID::GetObjectCount(); nuEvent->reset(); } } - for ( unsigned ievt=0; ievt<2; ++ievt ) { - + for (unsigned ievt = 0; ievt < 2; ++ievt) { // std::cout << "Event number " << ievt << std::endl; // mySimEvent[ievt]->print(); // const std::vector& fsimVertices = *(mySimEvent[ievt]->vertices() ); // if ( !fsimVertices.size() ) continue; - if ( !mySimEvent[ievt]->nVertices() ) continue; + if (!mySimEvent[ievt]->nVertices()) + continue; const FSimTrack& thePion = mySimEvent[ievt]->track(0); // h1[ievt]->Fill(fsimVertices.size()); - // if ( fsimVertices.size() == 1 ) continue; + // if ( fsimVertices.size() == 1 ) continue; h1[ievt]->Fill(mySimEvent[ievt]->nVertices()); // Count stopping particles - if ( mySimEvent[ievt]->nVertices() == 1 ) { - if ( thePion.trackerSurfaceMomentum().e() < 1E-10 ) ++stoppedPions[ievt]; + if (mySimEvent[ievt]->nVertices() == 1) { + if (thePion.trackerSurfaceMomentum().e() < 1E-10) + ++stoppedPions[ievt]; } - if ( mySimEvent[ievt]->nVertices() == 1 ) continue; + if (mySimEvent[ievt]->nVertices() == 1) + continue; const FSimVertex& thePionVertex = mySimEvent[ievt]->vertex(1); @@ -798,12 +780,11 @@ testNuclearInteractions::analyze(const edm::Event& iEvent, const edm::EventSetup double radius = thePionVertex.position().pt(); double eta = thePionVertex.position().eta(); - h0[ievt]->Fill(fabs(thePionVertex.position().z()), - thePionVertex.position().pt()); + h0[ievt]->Fill(fabs(thePionVertex.position().z()), thePionVertex.position().pt()); // Pion's number of daughters // FSimTrack& thePion = mySimEvent[ievt]->track(0); - + unsigned ndaugh = thePionVertex.nDaughters(); h2[ievt]->Fill(ndaugh); @@ -811,54 +792,56 @@ testNuclearInteractions::analyze(const edm::Event& iEvent, const edm::EventSetup // bool theSecondVertex = fsimVertices.size() > 2 ? // mySimEvent[ievt]->vertex(2).parent().id() == 0 : false; // std::cout << "Plusieurs interactions ? " << theSecondVertex << std::endl; - + // First and last daughters int firstDaughter = -1; int lastDaughter = -1; - if ( thePionVertex.nDaughters() ) { - lastDaughter = thePionVertex.daughters()[thePionVertex.nDaughters()-1]; + if (thePionVertex.nDaughters()) { + lastDaughter = thePionVertex.daughters()[thePionVertex.nDaughters() - 1]; firstDaughter = thePionVertex.daughters()[0]; } // Reject charged pion/kaon leptonic decays (already simulated in FAMOS) - // if ( thePionVertex.nDaughters() == 1 ) { + // if ( thePionVertex.nDaughters() == 1 ) { // const FSimTrack& myDaugh = mySimEvent[ievt]->track(firstDaughter); // if (abs(myDaugh.type()) == 11 || abs(myDaugh.type()) == 13 ) return; - // } - + // } + XYZTLorentzVector totMoth = thePion.momentum(); - XYZTLorentzVector totDaugh(0.,0.,0.,0.); + XYZTLorentzVector totDaugh(0., 0., 0., 0.); // double qMoth = thePion.charge(); // double qDaugh = 0; - unsigned nleptons=0; - unsigned nothers=0; - if(!(firstDaughter<0||lastDaughter<0)) { - for(int idaugh=firstDaughter;idaugh<=lastDaughter;++idaugh) { - const FSimTrack& myDaugh = mySimEvent[ievt]->track(idaugh); - totDaugh += myDaugh.momentum(); - // qDaugh += myDaugh.charge(); - // Count the leptons - if ( abs(myDaugh.type()) == 11 || abs(myDaugh.type()) == 13 ) ++nleptons; - // Count the hadrons - if ( abs(myDaugh.type()) != 111 && abs(myDaugh.type()) != 211 ) ++nothers; + unsigned nleptons = 0; + unsigned nothers = 0; + if (!(firstDaughter < 0 || lastDaughter < 0)) { + for (int idaugh = firstDaughter; idaugh <= lastDaughter; ++idaugh) { + const FSimTrack& myDaugh = mySimEvent[ievt]->track(idaugh); + totDaugh += myDaugh.momentum(); + // qDaugh += myDaugh.charge(); + // Count the leptons + if (abs(myDaugh.type()) == 11 || abs(myDaugh.type()) == 13) + ++nleptons; + // Count the hadrons + if (abs(myDaugh.type()) != 111 && abs(myDaugh.type()) != 211) + ++nothers; } } // Reject decays (less than one/four daughters, for pions and kaons) - if ( ( abs(thePion.type()) == 211 && ndaugh == 1) || - ( abs(thePion.type()) == 130 && ndaugh < 4 ) || - ( abs(thePion.type()) == 321 && ndaugh < 4 ) ) { - - double diffE = (totMoth-totDaugh).E(); - double diffP = std::sqrt((totMoth-totDaugh).Vect().Mag2()); - double diffm = totMoth.M2()-totDaugh.M2(); + if ((abs(thePion.type()) == 211 && ndaugh == 1) || (abs(thePion.type()) == 130 && ndaugh < 4) || + (abs(thePion.type()) == 321 && ndaugh < 4)) { + double diffE = (totMoth - totDaugh).E(); + double diffP = std::sqrt((totMoth - totDaugh).Vect().Mag2()); + double diffm = totMoth.M2() - totDaugh.M2(); // double diffQ = qMoth-qDaugh; - // Neutral particles (K0L) don't experience dE/dx nor multiple scattering nor B deflection. + // Neutral particles (K0L) don't experience dE/dx nor multiple scattering nor B deflection. // E,p are conserved! - if ( abs(thePion.type()) == 130 && fabs(diffE) < 1E-5 && diffP < 1E-5 ) return; - // Low-multiplicity final states with one electron or one muon + if (abs(thePion.type()) == 130 && fabs(diffE) < 1E-5 && diffP < 1E-5) + return; + // Low-multiplicity final states with one electron or one muon // usually don't come from an interaction. All pions are taken care // of by this cut - if ( nleptons == 1 ) return; + if (nleptons == 1) + return; // Reserve of tricks in case it does not work /* BaseParticlePropagator pDaugh(totDaugh,thePion.endVertex().position(),qDaugh); @@ -870,136 +853,124 @@ testNuclearInteractions::analyze(const edm::Event& iEvent, const edm::EventSetup // Charge kaons may experience dE/dx and multiple scattering -> relax the cuts h7[ievt]->Fill(diffE); h9[ievt]->Fill(diffm); - if ( abs(thePion.type()) != 211 && // Ignore pions - diffE > -1E-5 && diffE < 0.1 && // Small deltaE - to be checked as f(E) - nothers == 0 ) return; // Only pions in the decays + if (abs(thePion.type()) != 211 && // Ignore pions + diffE > -1E-5 && diffE < 0.1 && // Small deltaE - to be checked as f(E) + nothers == 0) + return; // Only pions in the decays h6[ievt]->Fill(diffE); h8[ievt]->Fill(diffm); - } + } - if ( ndaugh ) + if (ndaugh) ++interactingPions[ievt]; - else + else ++stoppedPions[ievt]; // Find the daughters, and boost them. - if(!(firstDaughter<0||lastDaughter<0)) { - + if (!(firstDaughter < 0 || lastDaughter < 0)) { // Compute the boost for the cm frame, and the cm energy. - XYZTLorentzVector theBoost = thePion.momentum()+theProtonMomentum; + XYZTLorentzVector theBoost = thePion.momentum() + theProtonMomentum; double ecm = theBoost.mag(); - theBoost /= theBoost.e(); - if ( ievt == 0 && saveNU && totalNEvt < maxNU) { - NUEvent::NUInteraction interaction; - interaction.first = nuEvent->nParticles(); - interaction.last = interaction.first + lastDaughter - firstDaughter; - nuEvent->addNUInteraction(interaction); - ++totalNU; + theBoost /= theBoost.e(); + if (ievt == 0 && saveNU && totalNEvt < maxNU) { + NUEvent::NUInteraction interaction; + interaction.first = nuEvent->nParticles(); + interaction.last = interaction.first + lastDaughter - firstDaughter; + nuEvent->addNUInteraction(interaction); + ++totalNU; } // A few checks double qTot = 0.; double eBefore = thePion.momentum().E(); double eAfter = 0.; - XYZTLorentzVector theTotal(0.,0.,0.,0.); + XYZTLorentzVector theTotal(0., 0., 0., 0.); // Rotation to bring the collision axis around z - XYZVector zAxis(0.,0.,1.); + XYZVector zAxis(0., 0., 1.); XYZVector rotationAxis = (theBoost.Vect().Cross(zAxis)).Unit(); double rotationAngle = std::acos(theBoost.Vect().Unit().Z()); - RawParticle::Rotation rotation(rotationAxis,rotationAngle); - - for(int idaugh=firstDaughter;idaugh<=lastDaughter;++idaugh) { + RawParticle::Rotation rotation(rotationAxis, rotationAngle); - // The track - const FSimTrack& myDaugh = mySimEvent[ievt]->track(idaugh); - qTot += myDaugh.charge(); - // std::cout << "Daughter " << idaugh << " " << myDaugh << std::endl; + for (int idaugh = firstDaughter; idaugh <= lastDaughter; ++idaugh) { + // The track + const FSimTrack& myDaugh = mySimEvent[ievt]->track(idaugh); + qTot += myDaugh.charge(); + // std::cout << "Daughter " << idaugh << " " << myDaugh << std::endl; RawParticle theMom(myDaugh.momentum()); - eAfter += theMom.E(); - - // Boost the track - theMom.boost(-theBoost.x(),-theBoost.y(),-theBoost.z()); - theTotal = theTotal + theMom.momentum(); - - // Rotate -> along the Z axis - theMom.rotate(rotation); - - // Save the fully simulated tracks - if ( ievt == 0 && saveNU && totalNEvt <= maxNU) { - NUEvent::NUParticle particle; - particle.px = theMom.px()/ecm; - particle.py = theMom.py()/ecm; - particle.pz = theMom.pz()/ecm; - particle.mass = theMom.mag(); - particle.id = myDaugh.type(); - nuEvent->addNUParticle(particle); - // SimTrack nuclSimTrack(myDaugh.type(),theMom/ecm,-1,-1); - // nuclSimTracks->push_back(nuclSimTrack); - } + eAfter += theMom.E(); + + // Boost the track + theMom.boost(-theBoost.x(), -theBoost.y(), -theBoost.z()); + theTotal = theTotal + theMom.momentum(); + + // Rotate -> along the Z axis + theMom.rotate(rotation); + + // Save the fully simulated tracks + if (ievt == 0 && saveNU && totalNEvt <= maxNU) { + NUEvent::NUParticle particle; + particle.px = theMom.px() / ecm; + particle.py = theMom.py() / ecm; + particle.pz = theMom.pz() / ecm; + particle.mass = theMom.mag(); + particle.id = myDaugh.type(); + nuEvent->addNUParticle(particle); + // SimTrack nuclSimTrack(myDaugh.type(),theMom/ecm,-1,-1); + // nuclSimTracks->push_back(nuclSimTrack); + } } // Save some histograms h3[ievt]->Fill(ecm); - h4[ievt]->Fill(theTotal.mag()/ecm); + h4[ievt]->Fill(theTotal.mag() / ecm); h5[ievt]->Fill(sqrt(theTotal.Vect().mag2())); - h10[ievt]->Fill(eAfter/eBefore); + h10[ievt]->Fill(eAfter / eBefore); // Total charge of daughters totalCharge[ievt]->Fill(qTot); // Fill the individual layer histograms ! bool filled = false; - for ( unsigned hist=0; histFill(eta); - filled = true; - } - } + for (unsigned hist = 0; hist < h100.size() && !filled; ++hist) { + if (radius < trackerRadius[hist][ievt] && fabs(zed) < trackerLength[hist][ievt]) { + h100[hist][ievt]->Fill(eta); + filled = true; + } + } // Fill the block histograms ! filled = false; - for ( unsigned hist=0; histFill(eta); - filled = true; - } + for (unsigned hist = 0; hist < h200.size() && !filled; ++hist) { + if (radius < blockTrackerRadius[hist][ievt] && fabs(zed) < blockTrackerLength[hist][ievt]) { + h200[hist][ievt]->Fill(eta); + filled = true; + } } // Fill the cumulative histograms ! - for ( unsigned hist=0; histFill(eta); - } + for (unsigned hist = 0; hist < h300.size(); ++hist) { + if ((radius < subTrackerRadius[hist][ievt] && fabs(zed) < subTrackerLength[hist][ievt]) || + (hist == 2 && radius < subTrackerRadius[1][ievt] && fabs(zed) < subTrackerLength[1][ievt])) { + h300[hist][ievt]->Fill(eta); + } } } - + // Save the fully simulated tracks from the nuclear interaction - if ( ievt == 0 && saveNU && totalNEvt <= maxNU ) { - if ( nuEvent->nInteractions() == 1000 ) { + if (ievt == 0 && saveNU && totalNEvt <= maxNU) { + if (nuEvent->nInteractions() == 1000) { // Reset Event object count to avoid memory overflows - TProcessID::SetObjectCount(ObjectNumber); - // Save the nuEvent - std::cout << "Saved " << nuEvent->nInteractions() - << " Interaction(s) with " << nuEvent->nParticles() - << " Particles in the NUEvent " << std::endl; - outFile->cd(); - nuTree->Fill(); - // nuTree->Print(); - + TProcessID::SetObjectCount(ObjectNumber); + // Save the nuEvent + std::cout << "Saved " << nuEvent->nInteractions() << " Interaction(s) with " << nuEvent->nParticles() + << " Particles in the NUEvent " << std::endl; + outFile->cd(); + nuTree->Fill(); + // nuTree->Print(); } - } - } - - } //define this as a plug-in diff --git a/FastSimulation/Muons/plugins/FastTSGFromIOHit.cc b/FastSimulation/Muons/plugins/FastTSGFromIOHit.cc index a004b27b8255e..a805896ef7f50 100644 --- a/FastSimulation/Muons/plugins/FastTSGFromIOHit.cc +++ b/FastSimulation/Muons/plugins/FastTSGFromIOHit.cc @@ -15,128 +15,104 @@ #include "RecoTracker/TkTrackingRegions/interface/RectangularEtaPhiTrackingRegion.h" #include "DataFormats/Math/interface/deltaPhi.h" -FastTSGFromIOHit::FastTSGFromIOHit(const edm::ParameterSet & iConfig,edm::ConsumesCollector& iC) -{ - +FastTSGFromIOHit::FastTSGFromIOHit(const edm::ParameterSet& iConfig, edm::ConsumesCollector& iC) { theCategory = "FastSimulation|Muons||FastTSGFromIOHit"; thePtCut = iConfig.getParameter("PtCut"); simTracksTk = iC.consumes(iConfig.getParameter("SimTrackCollectionLabel")); - const auto & seedLabels = iConfig.getParameter >("SeedCollectionLabels"); - for(const auto & seedLabel : seedLabels) - { - seedsTks.push_back(iC.consumes(seedLabel)); + const auto& seedLabels = iConfig.getParameter >("SeedCollectionLabels"); + for (const auto& seedLabel : seedLabels) { + seedsTks.push_back(iC.consumes(seedLabel)); } - } -FastTSGFromIOHit::~FastTSGFromIOHit() -{ +FastTSGFromIOHit::~FastTSGFromIOHit() { LogTrace(theCategory) << " FastTSGFromIOHit dtor called "; } - LogTrace(theCategory) << " FastTSGFromIOHit dtor called "; +void FastTSGFromIOHit::trackerSeeds(const TrackCand& staMuon, + const TrackingRegion& region, + const TrackerTopology* tTopo, + std::vector& result) { + // Make a ref to l2 muon + reco::TrackRef muRef(staMuon.second); -} + // Cut on muons with low momenta + if (muRef->pt() < thePtCut || muRef->innerMomentum().Rho() < thePtCut || muRef->innerMomentum().R() < 2.5) { + return; + } -void FastTSGFromIOHit::trackerSeeds(const TrackCand& staMuon, const TrackingRegion& region, const TrackerTopology *tTopo, std::vector & result) -{ - // Make a ref to l2 muon - reco::TrackRef muRef(staMuon.second); - - // Cut on muons with low momenta - if ( muRef->pt() < thePtCut - || muRef->innerMomentum().Rho() < thePtCut - || muRef->innerMomentum().R() < 2.5 ) - { - return; - } - - // Retrieve the Monte Carlo truth (SimTracks) - edm::Handle simTracks; - getEvent()->getByToken(simTracksTk,simTracks); - - // Retrieve Seed collection - std::vector > seedCollections; - seedCollections.resize(seedsTks.size()); - for ( unsigned iSeed = 0 ; iSeed < seedsTks.size() ; iSeed++) - { - getEvent()->getByToken(seedsTks[iSeed],seedCollections[iSeed]); + // Retrieve the Monte Carlo truth (SimTracks) + edm::Handle simTracks; + getEvent()->getByToken(simTracksTk, simTracks); + + // Retrieve Seed collection + std::vector > seedCollections; + seedCollections.resize(seedsTks.size()); + for (unsigned iSeed = 0; iSeed < seedsTks.size(); iSeed++) { + getEvent()->getByToken(seedsTks[iSeed], seedCollections[iSeed]); + } + + // cast the tracking region + const RectangularEtaPhiTrackingRegion& regionRef = dynamic_cast(region); + + // select and store seeds + std::set simTrackIds; + for (const auto& seeds : seedCollections) { + for (const auto& seed : *seeds) { + // Find the simtrack corresponding to the seed + TrajectorySeed::range recHitRange = seed.recHits(); + const FastTrackerRecHit* firstRecHit = (const FastTrackerRecHit*)(&(*(recHitRange.first))); + int simTrackId = firstRecHit->simTrackId(0); + const SimTrack& simTrack = (*simTracks)[simTrackId]; + + // skip if simTrack already associated to a seed + if (simTrackIds.find(simTrackId) != simTrackIds.end()) { + continue; + } + simTrackIds.insert(simTrackId); + + // filter seed + if (!clean(muRef, regionRef, &seed, simTrack)) { + continue; + } + + // store results + result.push_back(L3MuonTrajectorySeed(seed, muRef)); } - - // cast the tracking region - const RectangularEtaPhiTrackingRegion & regionRef = dynamic_cast (region); - - // select and store seeds - std::set simTrackIds; - for ( const auto & seeds : seedCollections) - { - for ( const auto & seed : *seeds) - { - // Find the simtrack corresponding to the seed - TrajectorySeed::range recHitRange = seed.recHits(); - const FastTrackerRecHit * firstRecHit = (const FastTrackerRecHit*) (&(*(recHitRange.first))); - int simTrackId = firstRecHit->simTrackId(0); - const SimTrack & simTrack = (*simTracks)[simTrackId]; - - // skip if simTrack already associated to a seed - if( simTrackIds.find(simTrackId) != simTrackIds.end() ) - { - continue; - } - simTrackIds.insert(simTrackId); - - // filter seed - if( !clean(muRef,regionRef,&seed,simTrack) ) - { - continue; - } - - // store results - result.push_back(L3MuonTrajectorySeed(seed,muRef)); - } - } + } } -bool -FastTSGFromIOHit::clean(reco::TrackRef muRef, - const RectangularEtaPhiTrackingRegion& region, - const TrajectorySeed* aSeed, - const SimTrack& theSimTrack) -{ - - // Eta cleaner - const PixelRecoRange& etaRange = region.etaRange() ; +bool FastTSGFromIOHit::clean(reco::TrackRef muRef, + const RectangularEtaPhiTrackingRegion& region, + const TrajectorySeed* aSeed, + const SimTrack& theSimTrack) { + // Eta cleaner + const PixelRecoRange& etaRange = region.etaRange(); double etaSeed = theSimTrack.momentum().Eta(); - double etaLimit = (fabs(fabs(etaRange.max())-fabs(etaRange.mean())) <0.05) ? - 0.05 : fabs(fabs(etaRange.max()) - fabs(etaRange.mean())) ; - bool inEtaRange = - etaSeed >= (etaRange.mean() - etaLimit) && - etaSeed <= (etaRange.mean() + etaLimit) ; - if ( !inEtaRange ) - { - return false; + double etaLimit = (fabs(fabs(etaRange.max()) - fabs(etaRange.mean())) < 0.05) + ? 0.05 + : fabs(fabs(etaRange.max()) - fabs(etaRange.mean())); + bool inEtaRange = etaSeed >= (etaRange.mean() - etaLimit) && etaSeed <= (etaRange.mean() + etaLimit); + if (!inEtaRange) { + return false; } - + // Phi cleaner const TkTrackingRegionsMargin& phiMargin = region.phiMargin(); - double phiSeed = theSimTrack.momentum().Phi(); - double phiLimit = (phiMargin.right() < 0.05 ) ? 0.05 : phiMargin.right(); - bool inPhiRange = - (fabs(deltaPhi(phiSeed,double(region.direction().phi()))) < phiLimit ); - if ( !inPhiRange ) - { - return false; + double phiSeed = theSimTrack.momentum().Phi(); + double phiLimit = (phiMargin.right() < 0.05) ? 0.05 : phiMargin.right(); + bool inPhiRange = (fabs(deltaPhi(phiSeed, double(region.direction().phi()))) < phiLimit); + if (!inPhiRange) { + return false; } - + // pt cleaner - double ptSeed = std::sqrt(theSimTrack.momentum().Perp2()); - double ptMin = (region.ptMin()>3.5) ? 3.5: region.ptMin(); - bool inPtRange = ptSeed >= ptMin && ptSeed<= 2*(muRef->pt()); - if ( !inPtRange ) - { - return false; + double ptSeed = std::sqrt(theSimTrack.momentum().Perp2()); + double ptMin = (region.ptMin() > 3.5) ? 3.5 : region.ptMin(); + bool inPtRange = ptSeed >= ptMin && ptSeed <= 2 * (muRef->pt()); + if (!inPtRange) { + return false; } return true; - } diff --git a/FastSimulation/Muons/plugins/FastTSGFromIOHit.h b/FastSimulation/Muons/plugins/FastTSGFromIOHit.h index a74466a25fafa..b9c52d7d342dd 100644 --- a/FastSimulation/Muons/plugins/FastTSGFromIOHit.h +++ b/FastSimulation/Muons/plugins/FastTSGFromIOHit.h @@ -23,30 +23,31 @@ class TrackingRegion; class SimTrack; class FastTSGFromIOHit : public TrackerSeedGenerator { - public: /// constructor - FastTSGFromIOHit(const edm::ParameterSet &pset,edm::ConsumesCollector& iC); + FastTSGFromIOHit(const edm::ParameterSet& pset, edm::ConsumesCollector& iC); /// destructor ~FastTSGFromIOHit() override; /// generate seed(s) for a track - void trackerSeeds(const TrackCand&, const TrackingRegion&, const TrackerTopology *tTopo, std::vector&) override; + void trackerSeeds(const TrackCand&, + const TrackingRegion&, + const TrackerTopology* tTopo, + std::vector&) override; - private: +private: bool clean(reco::TrackRef muRef, - const RectangularEtaPhiTrackingRegion& region, - const BasicTrajectorySeed* aSeed, - const SimTrack& theSimTrack); + const RectangularEtaPhiTrackingRegion& region, + const BasicTrajectorySeed* aSeed, + const SimTrack& theSimTrack); private: std::string theCategory; - - edm::EDGetTokenT simTracksTk; - std::vector > seedsTks; - double thePtCut; + edm::EDGetTokenT simTracksTk; + std::vector > seedsTks; + double thePtCut; }; -#endif +#endif diff --git a/FastSimulation/Muons/plugins/FastTSGFromL2Muon.cc b/FastSimulation/Muons/plugins/FastTSGFromL2Muon.cc index 8b6408eb68cce..8ba47988e1c28 100644 --- a/FastSimulation/Muons/plugins/FastTSGFromL2Muon.cc +++ b/FastSimulation/Muons/plugins/FastTSGFromL2Muon.cc @@ -17,37 +17,27 @@ #include -FastTSGFromL2Muon::FastTSGFromL2Muon(const edm::ParameterSet& cfg) : theConfig(cfg) -{ +FastTSGFromL2Muon::FastTSGFromL2Muon(const edm::ParameterSet& cfg) : theConfig(cfg) { produces(); - edm::ParameterSet serviceParameters = - cfg.getParameter("ServiceParameters"); + edm::ParameterSet serviceParameters = cfg.getParameter("ServiceParameters"); thePtCut = cfg.getParameter("PtCut"); theL2CollectionLabel = cfg.getParameter("MuonCollectionLabel"); theSeedCollectionLabels = cfg.getParameter >("SeedCollectionLabels"); - theSimTrackCollectionLabel = cfg.getParameter("SimTrackCollectionLabel"); + theSimTrackCollectionLabel = cfg.getParameter("SimTrackCollectionLabel"); // useTFileService_ = cfg.getUntrackedParameter("UseTFileService",false); - } -FastTSGFromL2Muon::~FastTSGFromL2Muon() -{ -} +FastTSGFromL2Muon::~FastTSGFromL2Muon() {} -void -FastTSGFromL2Muon::beginRun(edm::Run const& run, edm::EventSetup const& es) -{ - +void FastTSGFromL2Muon::beginRun(edm::Run const& run, edm::EventSetup const& es) { //region builder - edm::ParameterSet regionBuilderPSet = - theConfig.getParameter("MuonTrackingRegionBuilder"); - edm::ConsumesCollector iC = consumesCollector(); - theRegionBuilder = new MuonTrackingRegionBuilder(regionBuilderPSet,iC); - - + edm::ParameterSet regionBuilderPSet = theConfig.getParameter("MuonTrackingRegionBuilder"); + edm::ConsumesCollector iC = consumesCollector(); + theRegionBuilder = new MuonTrackingRegionBuilder(regionBuilderPSet, iC); + /* if(useTFileService_) { edm::Service fs; @@ -60,52 +50,45 @@ FastTSGFromL2Muon::beginRun(edm::Run const& run, edm::EventSetup const& es) h_nGoodSeedPerTrack = 0; } */ - } - -void -FastTSGFromL2Muon::produce(edm::Event& ev, const edm::EventSetup& es) -{ - +void FastTSGFromL2Muon::produce(edm::Event& ev, const edm::EventSetup& es) { // Initialize the output product std::unique_ptr result(new L3MuonTrajectorySeedCollection()); - + // Region builder theRegionBuilder->setEvent(ev); // Retrieve the Monte Carlo truth (SimTracks) edm::Handle theSimTracks; - ev.getByLabel(theSimTrackCollectionLabel,theSimTracks); + ev.getByLabel(theSimTrackCollectionLabel, theSimTracks); // Retrieve L2 muon collection edm::Handle l2muonH; - ev.getByLabel(theL2CollectionLabel ,l2muonH); + ev.getByLabel(theL2CollectionLabel, l2muonH); // Retrieve Seed collection unsigned seedCollections = theSeedCollectionLabels.size(); std::vector > > theSeeds; theSeeds.resize(seedCollections); unsigned seed_size = 0; - for ( unsigned iseed=0; iseedsize(); } // Loop on L2 muons - unsigned int imu=0; - unsigned int imuMax=l2muonH->size(); + unsigned int imu = 0; + unsigned int imuMax = l2muonH->size(); // std::cout << "Found " << imuMax << " L2 muons" << std::endl; - for (;imu!=imuMax;++imu){ - + for (; imu != imuMax; ++imu) { // Make a ref to l2 muon reco::TrackRef muRef(l2muonH, imu); - + // Cut on muons with low momenta - if ( muRef->pt() < thePtCut - || muRef->innerMomentum().Rho() < thePtCut - || muRef->innerMomentum().R() < 2.5 ) continue; - + if (muRef->pt() < thePtCut || muRef->innerMomentum().Rho() < thePtCut || muRef->innerMomentum().R() < 2.5) + continue; + // Define the region of interest std::unique_ptr region = theRegionBuilder->region(muRef); @@ -113,89 +96,84 @@ FastTSGFromL2Muon::produce(edm::Event& ev, const edm::EventSetup& es) std::vector tkSeeds; std::set tkIds; tkSeeds.reserve(seed_size); - for ( unsigned iseed=0; iseed > aSeedCollection = theSeeds[iseed]; unsigned nSeeds = aSeedCollection->size(); for (unsigned seednr = 0; seednr < nSeeds; ++seednr) { - - // The seed - const BasicTrajectorySeed* aSeed = &((*aSeedCollection)[seednr]); - - // Find the first hit of the Seed - TrajectorySeed::range theSeedingRecHitRange = aSeed->recHits(); - const FastTrackerRecHit * theFirstSeedingRecHit = - (const FastTrackerRecHit*) (&(*(theSeedingRecHitRange.first))); - - // The SimTrack id associated to that recHit - int simTrackId = theFirstSeedingRecHit->simTrackId(0); - - // Track already associated to a seed - std::set::iterator tkId = tkIds.find(simTrackId); - if( tkId != tkIds.end() ) continue; - - const SimTrack& theSimTrack = (*theSimTracks)[simTrackId]; - - if ( clean(muRef,region.get(),aSeed,theSimTrack) ) tkSeeds.push_back(*aSeed); - tkIds.insert(simTrackId); - - } // End loop on seeds - - } // End loop on seed collections - + // The seed + const BasicTrajectorySeed* aSeed = &((*aSeedCollection)[seednr]); + + // Find the first hit of the Seed + TrajectorySeed::range theSeedingRecHitRange = aSeed->recHits(); + const FastTrackerRecHit* theFirstSeedingRecHit = (const FastTrackerRecHit*)(&(*(theSeedingRecHitRange.first))); + + // The SimTrack id associated to that recHit + int simTrackId = theFirstSeedingRecHit->simTrackId(0); + + // Track already associated to a seed + std::set::iterator tkId = tkIds.find(simTrackId); + if (tkId != tkIds.end()) + continue; + + const SimTrack& theSimTrack = (*theSimTracks)[simTrackId]; + + if (clean(muRef, region.get(), aSeed, theSimTrack)) + tkSeeds.push_back(*aSeed); + tkIds.insert(simTrackId); + + } // End loop on seeds + + } // End loop on seed collections + // A plot // if(h_nSeedPerTrack) h_nSeedPerTrack->Fill(tkSeeds.size()); // Another plot // if(h_nGoodSeedPerTrack) h_nGoodSeedPerTrack->Fill(tkSeeds.size()); - // Now create the Muon Trajectory Seed - unsigned int is=0; - unsigned int isMax=tkSeeds.size(); - for (;is!=isMax;++is){ - result->push_back( L3MuonTrajectorySeed(tkSeeds[is], muRef)); - } // End of tk seed loop - - } // End of l2 muon loop + unsigned int is = 0; + unsigned int isMax = tkSeeds.size(); + for (; is != isMax; ++is) { + result->push_back(L3MuonTrajectorySeed(tkSeeds[is], muRef)); + } // End of tk seed loop + + } // End of l2 muon loop // std::cout << "Found " << result->size() << " seeds for muons" << std::endl; // And yet another plot // if(h_nGoodSeedPerEvent) h_nGoodSeedPerEvent->Fill(result->size()); - + //put in the event ev.put(std::move(result)); - } -bool -FastTSGFromL2Muon::clean(reco::TrackRef muRef, - RectangularEtaPhiTrackingRegion* region, - const BasicTrajectorySeed* aSeed, - const SimTrack& theSimTrack) { - - // Eta cleaner - const PixelRecoRange& etaRange = region->etaRange() ; +bool FastTSGFromL2Muon::clean(reco::TrackRef muRef, + RectangularEtaPhiTrackingRegion* region, + const BasicTrajectorySeed* aSeed, + const SimTrack& theSimTrack) { + // Eta cleaner + const PixelRecoRange& etaRange = region->etaRange(); double etaSeed = theSimTrack.momentum().Eta(); - double etaLimit = (fabs(fabs(etaRange.max())-fabs(etaRange.mean())) <0.05) ? - 0.05 : fabs(fabs(etaRange.max()) - fabs(etaRange.mean())) ; - bool inEtaRange = - etaSeed >= (etaRange.mean() - etaLimit) && - etaSeed <= (etaRange.mean() + etaLimit) ; - if ( !inEtaRange ) return false; - + double etaLimit = (fabs(fabs(etaRange.max()) - fabs(etaRange.mean())) < 0.05) + ? 0.05 + : fabs(fabs(etaRange.max()) - fabs(etaRange.mean())); + bool inEtaRange = etaSeed >= (etaRange.mean() - etaLimit) && etaSeed <= (etaRange.mean() + etaLimit); + if (!inEtaRange) + return false; + // Phi cleaner const TkTrackingRegionsMargin& phiMargin = region->phiMargin(); - double phiSeed = theSimTrack.momentum().Phi(); - double phiLimit = (phiMargin.right() < 0.05 ) ? 0.05 : phiMargin.right(); - bool inPhiRange = - (fabs(deltaPhi(phiSeed,double(region->direction().phi()))) < phiLimit ); - if ( !inPhiRange ) return false; - + double phiSeed = theSimTrack.momentum().Phi(); + double phiLimit = (phiMargin.right() < 0.05) ? 0.05 : phiMargin.right(); + bool inPhiRange = (fabs(deltaPhi(phiSeed, double(region->direction().phi()))) < phiLimit); + if (!inPhiRange) + return false; + // pt cleaner - double ptSeed = std::sqrt(theSimTrack.momentum().Perp2()); - double ptMin = (region->ptMin()>3.5) ? 3.5: region->ptMin(); - bool inPtRange = ptSeed >= ptMin && ptSeed<= 2*(muRef->pt()); + double ptSeed = std::sqrt(theSimTrack.momentum().Perp2()); + double ptMin = (region->ptMin() > 3.5) ? 3.5 : region->ptMin(); + bool inPtRange = ptSeed >= ptMin && ptSeed <= 2 * (muRef->pt()); return inPtRange; - } diff --git a/FastSimulation/Muons/plugins/FastTSGFromL2Muon.h b/FastSimulation/Muons/plugins/FastTSGFromL2Muon.h index 839e9bdb89fab..26a618c3a8e72 100644 --- a/FastSimulation/Muons/plugins/FastTSGFromL2Muon.h +++ b/FastSimulation/Muons/plugins/FastTSGFromL2Muon.h @@ -6,9 +6,12 @@ #include "DataFormats/TrackReco/interface/TrackFwd.h" #include "DataFormats/TrajectorySeed/interface/TrajectorySeedCollection.h" - #include -namespace edm { class ParameterSet; class Event; class EventSetup; } +namespace edm { + class ParameterSet; + class Event; + class EventSetup; +} // namespace edm class MuonServiceProxy; class MuonTrackingRegionBuilder; @@ -20,24 +23,20 @@ class SimTrack; // generate seeds corresponding to L2 muons // -class FastTSGFromL2Muon : public edm::stream::EDProducer <> { - - public: - +class FastTSGFromL2Muon : public edm::stream::EDProducer<> { +public: FastTSGFromL2Muon(const edm::ParameterSet& cfg); ~FastTSGFromL2Muon() override; void beginRun(edm::Run const& run, edm::EventSetup const& es) override; void produce(edm::Event& ev, const edm::EventSetup& es) override; - - private: +private: bool clean(reco::TrackRef muRef, - RectangularEtaPhiTrackingRegion* region, - const BasicTrajectorySeed* aSeed, - const SimTrack& theSimTrack); - - private: + RectangularEtaPhiTrackingRegion* region, + const BasicTrajectorySeed* aSeed, + const SimTrack& theSimTrack); +private: edm::ParameterSet theConfig; edm::InputTag theSimTrackCollectionLabel; edm::InputTag theL2CollectionLabel; @@ -52,6 +51,5 @@ class FastTSGFromL2Muon : public edm::stream::EDProducer <> { // TH1F* h_nSeedPerTrack; // TH1F* h_nGoodSeedPerTrack; // TH1F* h_nGoodSeedPerEvent; - }; #endif diff --git a/FastSimulation/Muons/plugins/FastTSGFromPropagation.cc b/FastSimulation/Muons/plugins/FastTSGFromPropagation.cc index 866cff37f3f65..724cf4f923b87 100644 --- a/FastSimulation/Muons/plugins/FastTSGFromPropagation.cc +++ b/FastSimulation/Muons/plugins/FastTSGFromPropagation.cc @@ -43,204 +43,226 @@ using namespace std; -FastTSGFromPropagation::FastTSGFromPropagation(const edm::ParameterSet& iConfig,edm::ConsumesCollector& iC) : FastTSGFromPropagation(iConfig, nullptr, iC) { -} - -FastTSGFromPropagation::FastTSGFromPropagation(const edm::ParameterSet& iConfig, const MuonServiceProxy* service, edm::ConsumesCollector& iC) : - theCategory("FastSimulation|Muons|FastTSGFromPropagation"), - theTkLayerMeasurements(), theTracker(), theNavigation(), theService(service), theUpdator(), theEstimator(), theSigmaZ(0.0), theConfig (iConfig), - theSimTrackCollectionToken_(iC.consumes(theConfig.getParameter("SimTrackCollectionLabel"))), - recHitCombinationsToken_(iC.consumes(theConfig.getParameter("HitProducer"))), - beamSpot_(iC.consumes(iConfig.getParameter("beamSpot"))), - theMeasurementTrackerEventToken_(iC.consumes(iConfig.getParameter("MeasurementTrackerEvent"))) { -} - -FastTSGFromPropagation::~FastTSGFromPropagation() { - LogTrace(theCategory) << " FastTSGFromPropagation dtor called "; -} - -void FastTSGFromPropagation::trackerSeeds(const TrackCand& staMuon, const TrackingRegion& region, - const TrackerTopology *tTopo, std::vector & result) { - - if ( theResetMethod == "discrete" ) getRescalingFactor(staMuon); +FastTSGFromPropagation::FastTSGFromPropagation(const edm::ParameterSet& iConfig, edm::ConsumesCollector& iC) + : FastTSGFromPropagation(iConfig, nullptr, iC) {} + +FastTSGFromPropagation::FastTSGFromPropagation(const edm::ParameterSet& iConfig, + const MuonServiceProxy* service, + edm::ConsumesCollector& iC) + : theCategory("FastSimulation|Muons|FastTSGFromPropagation"), + theTkLayerMeasurements(), + theTracker(), + theNavigation(), + theService(service), + theUpdator(), + theEstimator(), + theSigmaZ(0.0), + theConfig(iConfig), + theSimTrackCollectionToken_( + iC.consumes(theConfig.getParameter("SimTrackCollectionLabel"))), + recHitCombinationsToken_( + iC.consumes(theConfig.getParameter("HitProducer"))), + beamSpot_(iC.consumes(iConfig.getParameter("beamSpot"))), + theMeasurementTrackerEventToken_( + iC.consumes(iConfig.getParameter("MeasurementTrackerEvent"))) {} + +FastTSGFromPropagation::~FastTSGFromPropagation() { LogTrace(theCategory) << " FastTSGFromPropagation dtor called "; } + +void FastTSGFromPropagation::trackerSeeds(const TrackCand& staMuon, + const TrackingRegion& region, + const TrackerTopology* tTopo, + std::vector& result) { + if (theResetMethod == "discrete") + getRescalingFactor(staMuon); TrajectoryStateOnSurface staState = outerTkState(staMuon); - if ( !staState.isValid() ) { + if (!staState.isValid()) { LogTrace(theCategory) << "Error: initial state from L2 muon is invalid."; return; } - LogTrace(theCategory) << "begin of trackerSeed:\n staState pos: "< nls = theNavigation->compatibleLayers(*(staState.freeState()), oppositeToMomentum); - LogTrace(theCategory) << " compatible layers: "< alltm; - - for (std::vector::const_iterator inl = nls.begin(); - inl != nls.end(); inl++, ndesLayer++ ) { - if ( (*inl == nullptr) ) break; -// if ( (inl != nls.end()-1 ) && ( (*inl)->subDetector() == GeomDetEnumerators::TEC ) && ( (*(inl+1))->subDetector() == GeomDetEnumerators::TOB ) ) continue; - alltm = findMeasurements_new(*inl, staState); - if ( (!alltm.empty()) ) { - LogTrace(theCategory) << "final compatible layer: "< 5 ) alltm.erase(alltm.begin() + 5, alltm.end()); - - const edm::SimTrackContainer* simTracks = &(*theSimTracks); - TrajectorySeedHitCandidate theSeedHits; - std::vector outerHits; - - //std::vector tmpTS; - bool isMatch = false; - for (std::vector::const_iterator itm = alltm.begin(); itm != alltm.end(); itm++) { - const TrajectoryStateOnSurface seedState = itm->predictedState(); - double preY = seedState.globalPosition().y(); - - // Check SimTrack - FreeTrajectoryState simtrack_trackerstate; - for( unsigned icomb = 0;icomb < recHitCombinations->size();++icomb){ - const auto & recHitCombination = (*recHitCombinations)[icomb]; - if(recHitCombination.empty()) - continue; - int32_t simTrackId = recHitCombination.back()->simTrackId(0); - const SimTrack & simtrack = (*simTracks)[simTrackId]; - - GlobalPoint position(simtrack.trackerSurfacePosition().x(), - simtrack.trackerSurfacePosition().y(), - simtrack.trackerSurfacePosition().z()); - GlobalVector momentum(simtrack.trackerSurfaceMomentum().x(), - simtrack.trackerSurfaceMomentum().y(), - simtrack.trackerSurfaceMomentum().z()); - int charge = (int)simtrack.charge(); - GlobalTrajectoryParameters glb_parameters(position, momentum, charge, &*theService->magneticField().product()); - simtrack_trackerstate = FreeTrajectoryState(glb_parameters); - - unsigned int outerId = 0; - for( const auto & recHitRef : recHitCombination) { - theSeedHits = TrajectorySeedHitCandidate(recHitRef.get(), tTopo); - unsigned int id = theSeedHits.hit()->geographicalId().rawId(); - if( preY < 0 ) { - if( id > outerId ) outerId = id; - } - else { - if( id > outerId ) outerId = id; - } - } - for( const auto & recHitRef : recHitCombination ) { - theSeedHits = TrajectorySeedHitCandidate(recHitRef.get(),tTopo); - if( itm->recHit()->hit()->geographicalId().rawId() == theSeedHits.hit()->geographicalId().rawId() ) { - auto aTrackingRecHit = std::unique_ptr(theSeedHits.hit()->clone()); - TransientTrackingRecHit::ConstRecHitPointer recHit = theTTRHBuilder->build(aTrackingRecHit.get()); - if( !recHit ) continue; - TrajectoryStateOnSurface updatedTSOS = updator()->update(seedState, *(recHit)); - if( updatedTSOS.isValid() && passSelection(updatedTSOS) ) { - edm::OwnVector container; - container.push_back(recHit->hit()->clone()); - fastTrackingUtilities::setRecHitCombinationIndex(container,icomb); - TrajectorySeed ts = createSeed(updatedTSOS, container, recHit->geographicalId()); - // check direction - const TrajectorySeed* aSeed = &ts; - PTrajectoryStateOnDet PTSOD = aSeed->startingState(); - - const GeomDet *g = theGeometry->idToDet(PTSOD.detId()); - TrajectoryStateOnSurface tsos = trajectoryStateTransform::transientState(PTSOD, &(g->surface()), &*theService->magneticField().product()); - if( tsos.globalMomentum().basicVector()*seedState.globalMomentum().basicVector() < 0. ) continue; - result.push_back(ts); - isMatch = true; - } - } - } - } - } - if( !isMatch ) { - // if there is no hits w.r.t. TM, find outermost hit - for (std::vector::const_iterator itm = alltm.begin(); itm != alltm.end(); itm++) { - const TrajectoryStateOnSurface seedState = itm->predictedState(); - double preY = seedState.globalPosition().y(); - - // Check SimTrack - TrackingRecHit* aTrackingRecHit; - FreeTrajectoryState simtrack_trackerstate; - - for( unsigned icomb = 0;icomb < recHitCombinations->size();++icomb){ - const auto & recHitCombination = (*recHitCombinations)[icomb]; - if(recHitCombination.empty()) - continue; - int32_t simTrackId = recHitCombination.back()->simTrackId(0); - const SimTrack & simtrack = (*simTracks)[simTrackId]; - - GlobalPoint position(simtrack.trackerSurfacePosition().x(), - simtrack.trackerSurfacePosition().y(), - simtrack.trackerSurfacePosition().z()); - GlobalVector momentum(simtrack.trackerSurfaceMomentum().x(), - simtrack.trackerSurfaceMomentum().y(), - simtrack.trackerSurfaceMomentum().z()); - int charge = (int)simtrack.charge(); - GlobalTrajectoryParameters glb_parameters(position, momentum, charge, &*theService->magneticField().product()); - simtrack_trackerstate = FreeTrajectoryState(glb_parameters); - - unsigned int outerId = 0; - for( const auto & recHitRef : recHitCombination ) { - theSeedHits = TrajectorySeedHitCandidate(recHitRef.get(),tTopo); - unsigned int id = theSeedHits.hit()->geographicalId().rawId(); - if( preY < 0 ) { - if( id > outerId ) outerId = id; - } - else { - if( id > outerId ) outerId = id; - } - } - for( const auto & recHitRef : recHitCombination ) { - theSeedHits = TrajectorySeedHitCandidate(recHitRef.get(),tTopo); - if( outerId == theSeedHits.hit()->geographicalId().rawId() ) { - aTrackingRecHit = theSeedHits.hit()->clone(); - TransientTrackingRecHit::ConstRecHitPointer recHit = theTTRHBuilder->build(aTrackingRecHit); - if( !recHit ) continue; - TrajectoryStateOnSurface updatedTSOS = updator()->update(seedState, *(recHit)); - if( updatedTSOS.isValid() && passSelection(updatedTSOS) ) { - edm::OwnVector container; - container.push_back(recHit->hit()->clone()); - fastTrackingUtilities::setRecHitCombinationIndex(container,icomb); - TrajectorySeed ts = createSeed(updatedTSOS, container, recHit->geographicalId()); - // check direction - const TrajectorySeed* aSeed = &ts; - PTrajectoryStateOnDet PTSOD = aSeed->startingState(); - - const GeomDet *g = theGeometry->idToDet(PTSOD.detId()); - TrajectoryStateOnSurface tsos = trajectoryStateTransform::transientState(PTSOD, &(g->surface()), &*theService->magneticField().product()); - if( tsos.globalMomentum().basicVector()*seedState.globalMomentum().basicVector() < 0. ) continue; - result.push_back(ts); - } - } - } - } - } - } + if (theUpdateStateFlag) { //use updated states + std::vector alltm; + + for (std::vector::const_iterator inl = nls.begin(); inl != nls.end(); inl++, ndesLayer++) { + if ((*inl == nullptr)) + break; + // if ( (inl != nls.end()-1 ) && ( (*inl)->subDetector() == GeomDetEnumerators::TEC ) && ( (*(inl+1))->subDetector() == GeomDetEnumerators::TOB ) ) continue; + alltm = findMeasurements_new(*inl, staState); + if ((!alltm.empty())) { + LogTrace(theCategory) << "final compatible layer: " << ndesLayer; + break; + } + } - /* + if (alltm.empty()) { + LogTrace(theCategory) << " NO Measurements Found: eta: " << staState.globalPosition().eta() << "pt " + << staState.globalMomentum().perp(); + usePredictedState = true; + } else { + LogTrace(theCategory) << " Measurements for seeds: " << alltm.size(); + std::stable_sort(alltm.begin(), alltm.end(), increasingEstimate()); + if (alltm.size() > 5) + alltm.erase(alltm.begin() + 5, alltm.end()); + + const edm::SimTrackContainer* simTracks = &(*theSimTracks); + TrajectorySeedHitCandidate theSeedHits; + std::vector outerHits; + + //std::vector tmpTS; + bool isMatch = false; + for (std::vector::const_iterator itm = alltm.begin(); itm != alltm.end(); itm++) { + const TrajectoryStateOnSurface seedState = itm->predictedState(); + double preY = seedState.globalPosition().y(); + + // Check SimTrack + FreeTrajectoryState simtrack_trackerstate; + for (unsigned icomb = 0; icomb < recHitCombinations->size(); ++icomb) { + const auto& recHitCombination = (*recHitCombinations)[icomb]; + if (recHitCombination.empty()) + continue; + int32_t simTrackId = recHitCombination.back()->simTrackId(0); + const SimTrack& simtrack = (*simTracks)[simTrackId]; + + GlobalPoint position(simtrack.trackerSurfacePosition().x(), + simtrack.trackerSurfacePosition().y(), + simtrack.trackerSurfacePosition().z()); + GlobalVector momentum(simtrack.trackerSurfaceMomentum().x(), + simtrack.trackerSurfaceMomentum().y(), + simtrack.trackerSurfaceMomentum().z()); + int charge = (int)simtrack.charge(); + GlobalTrajectoryParameters glb_parameters( + position, momentum, charge, &*theService->magneticField().product()); + simtrack_trackerstate = FreeTrajectoryState(glb_parameters); + + unsigned int outerId = 0; + for (const auto& recHitRef : recHitCombination) { + theSeedHits = TrajectorySeedHitCandidate(recHitRef.get(), tTopo); + unsigned int id = theSeedHits.hit()->geographicalId().rawId(); + if (preY < 0) { + if (id > outerId) + outerId = id; + } else { + if (id > outerId) + outerId = id; + } + } + for (const auto& recHitRef : recHitCombination) { + theSeedHits = TrajectorySeedHitCandidate(recHitRef.get(), tTopo); + if (itm->recHit()->hit()->geographicalId().rawId() == theSeedHits.hit()->geographicalId().rawId()) { + auto aTrackingRecHit = std::unique_ptr(theSeedHits.hit()->clone()); + TransientTrackingRecHit::ConstRecHitPointer recHit = theTTRHBuilder->build(aTrackingRecHit.get()); + if (!recHit) + continue; + TrajectoryStateOnSurface updatedTSOS = updator()->update(seedState, *(recHit)); + if (updatedTSOS.isValid() && passSelection(updatedTSOS)) { + edm::OwnVector container; + container.push_back(recHit->hit()->clone()); + fastTrackingUtilities::setRecHitCombinationIndex(container, icomb); + TrajectorySeed ts = createSeed(updatedTSOS, container, recHit->geographicalId()); + // check direction + const TrajectorySeed* aSeed = &ts; + PTrajectoryStateOnDet PTSOD = aSeed->startingState(); + + const GeomDet* g = theGeometry->idToDet(PTSOD.detId()); + TrajectoryStateOnSurface tsos = trajectoryStateTransform::transientState( + PTSOD, &(g->surface()), &*theService->magneticField().product()); + if (tsos.globalMomentum().basicVector() * seedState.globalMomentum().basicVector() < 0.) + continue; + result.push_back(ts); + isMatch = true; + } + } + } + } + } + if (!isMatch) { + // if there is no hits w.r.t. TM, find outermost hit + for (std::vector::const_iterator itm = alltm.begin(); itm != alltm.end(); itm++) { + const TrajectoryStateOnSurface seedState = itm->predictedState(); + double preY = seedState.globalPosition().y(); + + // Check SimTrack + TrackingRecHit* aTrackingRecHit; + FreeTrajectoryState simtrack_trackerstate; + + for (unsigned icomb = 0; icomb < recHitCombinations->size(); ++icomb) { + const auto& recHitCombination = (*recHitCombinations)[icomb]; + if (recHitCombination.empty()) + continue; + int32_t simTrackId = recHitCombination.back()->simTrackId(0); + const SimTrack& simtrack = (*simTracks)[simTrackId]; + + GlobalPoint position(simtrack.trackerSurfacePosition().x(), + simtrack.trackerSurfacePosition().y(), + simtrack.trackerSurfacePosition().z()); + GlobalVector momentum(simtrack.trackerSurfaceMomentum().x(), + simtrack.trackerSurfaceMomentum().y(), + simtrack.trackerSurfaceMomentum().z()); + int charge = (int)simtrack.charge(); + GlobalTrajectoryParameters glb_parameters( + position, momentum, charge, &*theService->magneticField().product()); + simtrack_trackerstate = FreeTrajectoryState(glb_parameters); + + unsigned int outerId = 0; + for (const auto& recHitRef : recHitCombination) { + theSeedHits = TrajectorySeedHitCandidate(recHitRef.get(), tTopo); + unsigned int id = theSeedHits.hit()->geographicalId().rawId(); + if (preY < 0) { + if (id > outerId) + outerId = id; + } else { + if (id > outerId) + outerId = id; + } + } + for (const auto& recHitRef : recHitCombination) { + theSeedHits = TrajectorySeedHitCandidate(recHitRef.get(), tTopo); + if (outerId == theSeedHits.hit()->geographicalId().rawId()) { + aTrackingRecHit = theSeedHits.hit()->clone(); + TransientTrackingRecHit::ConstRecHitPointer recHit = theTTRHBuilder->build(aTrackingRecHit); + if (!recHit) + continue; + TrajectoryStateOnSurface updatedTSOS = updator()->update(seedState, *(recHit)); + if (updatedTSOS.isValid() && passSelection(updatedTSOS)) { + edm::OwnVector container; + container.push_back(recHit->hit()->clone()); + fastTrackingUtilities::setRecHitCombinationIndex(container, icomb); + TrajectorySeed ts = createSeed(updatedTSOS, container, recHit->geographicalId()); + // check direction + const TrajectorySeed* aSeed = &ts; + PTrajectoryStateOnDet PTSOD = aSeed->startingState(); + + const GeomDet* g = theGeometry->idToDet(PTSOD.detId()); + TrajectoryStateOnSurface tsos = trajectoryStateTransform::transientState( + PTSOD, &(g->surface()), &*theService->magneticField().product()); + if (tsos.globalMomentum().basicVector() * seedState.globalMomentum().basicVector() < 0.) + continue; + result.push_back(ts); + } + } + } + } + } + } + + /* for( unsigned ir = 0; ir < tmpTS.size(); ir++ ) { const BasicTrajectorySeed* aSeed = &((tmpTS)[ir]); PTrajectoryStateOnDet PTSOD = aSeed->startingState(); @@ -255,34 +277,31 @@ void FastTSGFromPropagation::trackerSeeds(const TrackCand& staMuon, const Tracki } } */ - LogTrace(theCategory) << "result: "<::const_iterator inl = nls.begin(); inl != nls.end(); inl++) { + if (!result.empty() || *inl == nullptr) { + break; + } + std::vector compatDets = (*inl)->compatibleDets(staState, *propagator(), *estimator()); + LogTrace(theCategory) << " compatDets " << compatDets.size(); + if (compatDets.empty()) + continue; + TrajectorySeed ts = createSeed(compatDets.front().second, compatDets.front().first->geographicalId()); + result.push_back(ts); + } + LogTrace(theCategory) << "result: " << result.size(); + return; } - - if ( !theUpdateStateFlag || usePredictedState ) { //use predicted states - LogTrace(theCategory) << "use predicted state: "; - for (std::vector::const_iterator inl = nls.begin(); - inl != nls.end(); inl++ ) { - - if ( !result.empty() || *inl == nullptr ) { - break; - } - std::vector compatDets = (*inl)->compatibleDets(staState, *propagator(), *estimator()); - LogTrace(theCategory) << " compatDets "<geographicalId()); - result.push_back(ts); - - } - LogTrace(theCategory) << "result: "<("MaxChi2"); theFixedErrorRescaling = theConfig.getParameter("ErrorRescaling"); @@ -291,15 +310,14 @@ void FastTSGFromPropagation::init(const MuonServiceProxy* service) { theResetMethod = theConfig.getParameter("ResetMethod"); - if (theResetMethod != "discrete" && theResetMethod != "fixed" && theResetMethod != "matrix" ) { - edm::LogError("FastTSGFromPropagation") - <<"Wrong error rescaling method: "<("SigmaZ"); edm::ParameterSet errorMatrixPset = theConfig.getParameter("errorMatrixPset"); - if ( theResetMethod == "matrix" && !errorMatrixPset.empty()){ + if (theResetMethod == "matrix" && !errorMatrixPset.empty()) { theAdjustAtIp = errorMatrixPset.getParameter("atIP"); theErrorMatrixAdjuster.reset(new MuonErrorMatrix(errorMatrixPset)); } else { - theAdjustAtIp =false; + theAdjustAtIp = false; theErrorMatrixAdjuster.reset(); } - theService->eventSetup().get().get(theTracker); + theService->eventSetup().get().get(theTracker); theNavigation.reset(new DirectTrackerNavigation(theTracker)); - edm::ESHandle geometry; + edm::ESHandle geometry; theService->eventSetup().get().get(geometry); theGeometry = &(*geometry); theService->eventSetup().get().get("WithTrackAngle", theTTRHBuilder); - } void FastTSGFromPropagation::setEvent(const edm::Event& iEvent) { - iEvent.getByToken(beamSpot_, theBeamSpot); - + // retrieve the MC truth (SimTracks) iEvent.getByToken(theSimTrackCollectionToken_, theSimTracks); iEvent.getByToken(recHitCombinationsToken_, recHitCombinations); unsigned long long newCacheId_MT = theService->eventSetup().get().cacheIdentifier(); - if ( theUpdateStateFlag && newCacheId_MT != theCacheId_MT ) { + if (theUpdateStateFlag && newCacheId_MT != theCacheId_MT) { LogTrace(theCategory) << "Measurment Tracker Geometry changed!"; theCacheId_MT = newCacheId_MT; theService->eventSetup().get().get(theMeasTracker); } - if ( theUpdateStateFlag ) { - iEvent.getByToken(theMeasurementTrackerEventToken_, theMeasTrackerEvent); - theTkLayerMeasurements = LayerMeasurements(*theMeasTracker,*theMeasTrackerEvent); + if (theUpdateStateFlag) { + iEvent.getByToken(theMeasurementTrackerEventToken_, theMeasTrackerEvent); + theTkLayerMeasurements = LayerMeasurements(*theMeasTracker, *theMeasTrackerEvent); } bool trackerGeomChanged = false; unsigned long long newCacheId_TG = theService->eventSetup().get().cacheIdentifier(); - if ( newCacheId_TG != theCacheId_TG ) { + if (newCacheId_TG != theCacheId_TG) { LogTrace(theCategory) << "Tracker Reco Geometry changed!"; theCacheId_TG = newCacheId_TG; theService->eventSetup().get().get(theTracker); trackerGeomChanged = true; } - if ( trackerGeomChanged && theTracker.product() ) { + if (trackerGeomChanged && theTracker.product()) { theNavigation.reset(new DirectTrackerNavigation(theTracker)); } } TrajectoryStateOnSurface FastTSGFromPropagation::innerState(const TrackCand& staMuon) const { - TrajectoryStateOnSurface innerTS; - if ( staMuon.first && staMuon.first->isValid() ) { + if (staMuon.first && staMuon.first->isValid()) { if (staMuon.first->direction() == alongMomentum) { innerTS = staMuon.first->firstMeasurement().updatedState(); - } - else if (staMuon.first->direction() == oppositeToMomentum) { + } else if (staMuon.first->direction() == oppositeToMomentum) { innerTS = staMuon.first->lastMeasurement().updatedState(); } } else { - innerTS = trajectoryStateTransform::innerStateOnSurface(*(staMuon.second),*theService->trackingGeometry(), &*theService->magneticField()); + innerTS = trajectoryStateTransform::innerStateOnSurface( + *(staMuon.second), *theService->trackingGeometry(), &*theService->magneticField()); } //rescale the error adjust(innerTS); - return innerTS; - + return innerTS; } TrajectoryStateOnSurface FastTSGFromPropagation::outerTkState(const TrackCand& staMuon) const { - TrajectoryStateOnSurface result; - if ( theUseVertexStateFlag && staMuon.second->pt() > 1.0 ) { - FreeTrajectoryState iniState = trajectoryStateTransform::initialFreeState(*(staMuon.second), &*theService->magneticField()); + if (theUseVertexStateFlag && staMuon.second->pt() > 1.0) { + FreeTrajectoryState iniState = + trajectoryStateTransform::initialFreeState(*(staMuon.second), &*theService->magneticField()); //rescale the error at IP - adjust(iniState); + adjust(iniState); StateOnTrackerBound fromInside(&*(theService->propagator("PropagatorWithMaterial"))); result = fromInside(iniState); @@ -416,153 +430,147 @@ TrajectoryStateOnSurface FastTSGFromPropagation::outerTkState(const TrackCand& s } TrajectorySeed FastTSGFromPropagation::createSeed(const TrajectoryStateOnSurface& tsos, const DetId& id) const { - edm::OwnVector container; return createSeed(tsos, container, id); - } -TrajectorySeed FastTSGFromPropagation::createSeed(const TrajectoryStateOnSurface& tsos, const edm::OwnVector& container, const DetId& id) const { - - PTrajectoryStateOnDet seedTSOS = trajectoryStateTransform::persistentState(tsos,id.rawId()); - return TrajectorySeed(seedTSOS,container,oppositeToMomentum); - +TrajectorySeed FastTSGFromPropagation::createSeed(const TrajectoryStateOnSurface& tsos, + const edm::OwnVector& container, + const DetId& id) const { + PTrajectoryStateOnDet seedTSOS = trajectoryStateTransform::persistentState(tsos, id.rawId()); + return TrajectorySeed(seedTSOS, container, oppositeToMomentum); } - void FastTSGFromPropagation::validMeasurements(std::vector& tms) const { - std::vector::iterator tmsend = std::remove_if(tms.begin(), tms.end(), isInvalid()); tms.erase(tmsend, tms.end()); return; - } -std::vector FastTSGFromPropagation::findMeasurements_new(const DetLayer* nl, const TrajectoryStateOnSurface& staState) const { - +std::vector FastTSGFromPropagation::findMeasurements_new( + const DetLayer* nl, const TrajectoryStateOnSurface& staState) const { std::vector result; std::vector compatDets = nl->compatibleDets(staState, *propagator(), *estimator()); - if ( compatDets.empty() ) return result; - - for (std::vector::const_iterator idws = compatDets.begin(); idws != compatDets.end(); ++idws) { - if ( idws->second.isValid() && (idws->first) ) { - std::vector tmptm = - theMeasTrackerEvent->idToDet(idws->first->geographicalId()).fastMeasurements(idws->second, idws->second, *propagator(), *estimator()); - //validMeasurements(tmptm); -// if ( tmptm.size() > 2 ) { -// std::stable_sort(tmptm.begin(),tmptm.end(),increasingEstimate()); -// result.insert(result.end(),tmptm.begin(), tmptm.begin()+2); -// } else { - result.insert(result.end(),tmptm.begin(), tmptm.end()); -// } - } + if (compatDets.empty()) + return result; + + for (std::vector::const_iterator idws = compatDets.begin(); idws != compatDets.end(); + ++idws) { + if (idws->second.isValid() && (idws->first)) { + std::vector tmptm = + theMeasTrackerEvent->idToDet(idws->first->geographicalId()) + .fastMeasurements(idws->second, idws->second, *propagator(), *estimator()); + //validMeasurements(tmptm); + // if ( tmptm.size() > 2 ) { + // std::stable_sort(tmptm.begin(),tmptm.end(),increasingEstimate()); + // result.insert(result.end(),tmptm.begin(), tmptm.begin()+2); + // } else { + result.insert(result.end(), tmptm.begin(), tmptm.end()); + // } + } } - - return result; + return result; } -std::vector FastTSGFromPropagation::findMeasurements(const DetLayer* nl, const TrajectoryStateOnSurface& staState) const { - - std::vector result = tkLayerMeasurements()->measurements((*nl), staState, *propagator(), *estimator()); +std::vector FastTSGFromPropagation::findMeasurements( + const DetLayer* nl, const TrajectoryStateOnSurface& staState) const { + std::vector result = + tkLayerMeasurements()->measurements((*nl), staState, *propagator(), *estimator()); validMeasurements(result); return result; } bool FastTSGFromPropagation::passSelection(const TrajectoryStateOnSurface& tsos) const { - if ( !theSelectStateFlag ) return true; + if (!theSelectStateFlag) + return true; else { - if ( theBeamSpot.isValid() ) { - return ( ( fabs(zDis(tsos) - theBeamSpot->z0() ) < theSigmaZ) ); - - } else { - return ( ( fabs(zDis(tsos)) < theSigmaZ) ); -// double theDxyCut = 100; -// return ( (zDis(tsos) < theSigmaZ) && (dxyDis(tsos) < theDxyCut) ); - } - } + if (theBeamSpot.isValid()) { + return ((fabs(zDis(tsos) - theBeamSpot->z0()) < theSigmaZ)); + } else { + return ((fabs(zDis(tsos)) < theSigmaZ)); + // double theDxyCut = 100; + // return ( (zDis(tsos) < theSigmaZ) && (dxyDis(tsos) < theDxyCut) ); + } + } } double FastTSGFromPropagation::dxyDis(const TrajectoryStateOnSurface& tsos) const { - return fabs(( - tsos.globalPosition().x() * tsos.globalMomentum().y() + tsos.globalPosition().y() * tsos.globalMomentum().x() )/tsos.globalMomentum().perp()); + return fabs( + (-tsos.globalPosition().x() * tsos.globalMomentum().y() + tsos.globalPosition().y() * tsos.globalMomentum().x()) / + tsos.globalMomentum().perp()); } double FastTSGFromPropagation::zDis(const TrajectoryStateOnSurface& tsos) const { - return tsos.globalPosition().z() - tsos.globalPosition().perp() * tsos.globalMomentum().z()/tsos.globalMomentum().perp(); + return tsos.globalPosition().z() - + tsos.globalPosition().perp() * tsos.globalMomentum().z() / tsos.globalMomentum().perp(); } void FastTSGFromPropagation::getRescalingFactor(const TrackCand& staMuon) { - float pt = (staMuon.second)->pt(); - if ( pt < 13.0 ) theFlexErrorRescaling = 3; - else if ( pt < 30.0 ) theFlexErrorRescaling = 5; - else theFlexErrorRescaling = 10; - return; + float pt = (staMuon.second)->pt(); + if (pt < 13.0) + theFlexErrorRescaling = 3; + else if (pt < 30.0) + theFlexErrorRescaling = 5; + else + theFlexErrorRescaling = 10; + return; } - -void FastTSGFromPropagation::adjust(FreeTrajectoryState & state) const { - +void FastTSGFromPropagation::adjust(FreeTrajectoryState& state) const { //rescale the error - if ( theResetMethod == "discreate" ) { - state.rescaleError(theFlexErrorRescaling); - return; + if (theResetMethod == "discreate") { + state.rescaleError(theFlexErrorRescaling); + return; } //rescale the error - if ( theResetMethod == "fixed" || !theErrorMatrixAdjuster) { - state.rescaleError(theFixedErrorRescaling); - return; + if (theResetMethod == "fixed" || !theErrorMatrixAdjuster) { + state.rescaleError(theFixedErrorRescaling); + return; } CurvilinearTrajectoryError oMat = state.curvilinearError(); - CurvilinearTrajectoryError sfMat = theErrorMatrixAdjuster->get(state.momentum());//FIXME with position + CurvilinearTrajectoryError sfMat = theErrorMatrixAdjuster->get(state.momentum()); //FIXME with position MuonErrorMatrix::multiply(oMat, sfMat); - - state = FreeTrajectoryState(state.parameters(), - oMat); -} -void FastTSGFromPropagation::adjust(TrajectoryStateOnSurface & state) const { + state = FreeTrajectoryState(state.parameters(), oMat); +} +void FastTSGFromPropagation::adjust(TrajectoryStateOnSurface& state) const { //rescale the error - if ( theResetMethod == "discreate" ) { - state.rescaleError(theFlexErrorRescaling); - return; + if (theResetMethod == "discreate") { + state.rescaleError(theFlexErrorRescaling); + return; } - if ( theResetMethod == "fixed" || !theErrorMatrixAdjuster) { - state.rescaleError(theFixedErrorRescaling); - return; + if (theResetMethod == "fixed" || !theErrorMatrixAdjuster) { + state.rescaleError(theFixedErrorRescaling); + return; } CurvilinearTrajectoryError oMat = state.curvilinearError(); - CurvilinearTrajectoryError sfMat = theErrorMatrixAdjuster->get(state.globalMomentum());//FIXME with position + CurvilinearTrajectoryError sfMat = theErrorMatrixAdjuster->get(state.globalMomentum()); //FIXME with position MuonErrorMatrix::multiply(oMat, sfMat); - - state = TrajectoryStateOnSurface(state.weight(), - state.globalParameters(), - oMat, - state.surface(), - state.surfaceSide()); + + state = + TrajectoryStateOnSurface(state.weight(), state.globalParameters(), oMat, state.surface(), state.surfaceSide()); } void FastTSGFromPropagation::stateOnDet(const TrajectoryStateOnSurface& ts, - unsigned int detid, - PTrajectoryStateOnDet& pts) const -{ - const AlgebraicSymMatrix55& m = ts.localError().matrix(); - int dim = 5; /// should check if corresponds to m - float localErrors[15]; - int k = 0; - for (int i=0; i(ts.surfaceSide()); - pts = PTrajectoryStateOnDet( ts.localParameters(),ts.globalMomentum().perp(), - localErrors, detid, - surfaceSide); + } + int surfaceSide = static_cast(ts.surfaceSide()); + pts = PTrajectoryStateOnDet(ts.localParameters(), ts.globalMomentum().perp(), localErrors, detid, surfaceSide); } diff --git a/FastSimulation/Muons/plugins/FastTSGFromPropagation.h b/FastSimulation/Muons/plugins/FastTSGFromPropagation.h index af87b7d0b08b2..f3cef89a800c4 100644 --- a/FastSimulation/Muons/plugins/FastTSGFromPropagation.h +++ b/FastSimulation/Muons/plugins/FastTSGFromPropagation.h @@ -34,7 +34,6 @@ #include - class LayerMeasurements; class Chi2MeasurementEstimator; class Propagator; @@ -46,21 +45,22 @@ class SimTrack; class TrackerGeometry; class TrackerTopology; - class FastTSGFromPropagation : public TrackerSeedGenerator { - public: - /// constructor - FastTSGFromPropagation(const edm::ParameterSet &pset,edm::ConsumesCollector& iC); - - FastTSGFromPropagation(const edm::ParameterSet& par, const MuonServiceProxy*,edm::ConsumesCollector& iC); - +public: + /// constructor + FastTSGFromPropagation(const edm::ParameterSet& pset, edm::ConsumesCollector& iC); + + FastTSGFromPropagation(const edm::ParameterSet& par, const MuonServiceProxy*, edm::ConsumesCollector& iC); + /// destructor ~FastTSGFromPropagation() override; /// generate seed(s) for a track - void trackerSeeds(const TrackCand&, const TrackingRegion&, - const TrackerTopology *tTopo, std::vector&) override; - + void trackerSeeds(const TrackCand&, + const TrackingRegion&, + const TrackerTopology* tTopo, + std::vector&) override; + /// initialize void init(const MuonServiceProxy*) override; @@ -69,27 +69,27 @@ class FastTSGFromPropagation : public TrackerSeedGenerator { private: /// A mere copy (without memory leak) of an existing tracking method - void stateOnDet(const TrajectoryStateOnSurface& ts, - unsigned int detid, - PTrajectoryStateOnDet& pts) const; + void stateOnDet(const TrajectoryStateOnSurface& ts, unsigned int detid, PTrajectoryStateOnDet& pts) const; TrajectoryStateOnSurface innerState(const TrackCand&) const; TrajectoryStateOnSurface outerTkState(const TrackCand&) const; - const LayerMeasurements* tkLayerMeasurements() const { return &theTkLayerMeasurements; } + const LayerMeasurements* tkLayerMeasurements() const { return &theTkLayerMeasurements; } - const TrajectoryStateUpdator* updator() const {return theUpdator.get();} + const TrajectoryStateUpdator* updator() const { return theUpdator.get(); } const Chi2MeasurementEstimator* estimator() const { return theEstimator.get(); } - edm::ESHandle propagator() const {return theService->propagator(thePropagatorName); } + edm::ESHandle propagator() const { return theService->propagator(thePropagatorName); } /// create a hitless seed from a trajectory state TrajectorySeed createSeed(const TrajectoryStateOnSurface&, const DetId&) const; /// create a seed from a trajectory state - TrajectorySeed createSeed(const TrajectoryStateOnSurface& tsos, const edm::OwnVector& container, const DetId& id) const; + TrajectorySeed createSeed(const TrajectoryStateOnSurface& tsos, + const edm::OwnVector& container, + const DetId& id) const; /// select valid measurements void validMeasurements(std::vector&) const; @@ -106,25 +106,25 @@ class FastTSGFromPropagation : public TrackerSeedGenerator { void getRescalingFactor(const TrackCand& staMuon); /// adjust the error matrix of the FTS - void adjust(FreeTrajectoryState &) const; + void adjust(FreeTrajectoryState&) const; /// adjust the error matrix of the TSOS - void adjust(TrajectoryStateOnSurface &) const; + void adjust(TrajectoryStateOnSurface&) const; double dxyDis(const TrajectoryStateOnSurface& tsos) const; double zDis(const TrajectoryStateOnSurface& tsos) const; - struct increasingEstimate{ - bool operator()(const TrajectoryMeasurement& lhs, - const TrajectoryMeasurement& rhs) const{ + struct increasingEstimate { + bool operator()(const TrajectoryMeasurement& lhs, const TrajectoryMeasurement& rhs) const { return lhs.estimate() < rhs.estimate(); } }; struct isInvalid { bool operator()(const TrajectoryMeasurement& measurement) { - return ( ((measurement).recHit() == nullptr) || !((measurement).recHit()->isValid()) || !((measurement).updatedState().isValid()) ); + return (((measurement).recHit() == nullptr) || !((measurement).recHit()->isValid()) || + !((measurement).updatedState().isValid())); } }; @@ -133,7 +133,7 @@ class FastTSGFromPropagation : public TrackerSeedGenerator { std::string theCategory; - LayerMeasurements theTkLayerMeasurements; + LayerMeasurements theTkLayerMeasurements; edm::ESHandle theTracker; @@ -141,7 +141,7 @@ class FastTSGFromPropagation : public TrackerSeedGenerator { std::unique_ptr theNavigation; - const TrackerGeometry* theGeometry; + const TrackerGeometry* theGeometry; const MuonServiceProxy* theService; @@ -159,7 +159,7 @@ class FastTSGFromPropagation : public TrackerSeedGenerator { bool theUpdateStateFlag; - std::string theResetMethod; + std::string theResetMethod; bool theSelectStateFlag; @@ -169,11 +169,11 @@ class FastTSGFromPropagation : public TrackerSeedGenerator { bool theAdjustAtIp; - double theSigmaZ; + double theSigmaZ; const edm::ParameterSet theConfig; edm::EDGetTokenT theSimTrackCollectionToken_; - edm::EDGetTokenT recHitCombinationsToken_; + edm::EDGetTokenT recHitCombinationsToken_; edm::EDGetTokenT beamSpot_; edm::EDGetTokenT theMeasurementTrackerEventToken_; @@ -182,7 +182,6 @@ class FastTSGFromPropagation : public TrackerSeedGenerator { edm::Handle recHitCombinations; edm::Handle theMeasTrackerEvent; edm::ESHandle theTTRHBuilder; - }; -#endif +#endif diff --git a/FastSimulation/Muons/plugins/SealModules.cc b/FastSimulation/Muons/plugins/SealModules.cc index cdb1e663634b4..1611d36754b02 100644 --- a/FastSimulation/Muons/plugins/SealModules.cc +++ b/FastSimulation/Muons/plugins/SealModules.cc @@ -4,8 +4,6 @@ #include "FastSimulation/Muons/plugins/FastTSGFromIOHit.h" #include "RecoMuon/TrackerSeedGenerator/interface/TrackerSeedGeneratorFactory.h" - DEFINE_FWK_MODULE(FastTSGFromL2Muon); DEFINE_EDM_PLUGIN(TrackerSeedGeneratorFactory, FastTSGFromPropagation, "FastTSGFromPropagation"); DEFINE_EDM_PLUGIN(TrackerSeedGeneratorFactory, FastTSGFromIOHit, "FastTSGFromIOHit"); - diff --git a/FastSimulation/Utilities/interface/BaseNumericalRandomGenerator.h b/FastSimulation/Utilities/interface/BaseNumericalRandomGenerator.h index 5c573c4c66e8b..111d698f71874 100644 --- a/FastSimulation/Utilities/interface/BaseNumericalRandomGenerator.h +++ b/FastSimulation/Utilities/interface/BaseNumericalRandomGenerator.h @@ -24,17 +24,12 @@ class RandomEngineAndDistribution; -class BaseNumericalRandomGenerator -{ - public: - +class BaseNumericalRandomGenerator { +public: /// Constructor that perform the necessary integration and inversion steps /// xmin and xmax are the generation bounds, n is the internal table size /// and iter is the number of iterations for the numerical part. - BaseNumericalRandomGenerator(double xmin=0., - double xmax=1., - int n=1000, - int iter=6); + BaseNumericalRandomGenerator(double xmin = 0., double xmax = 1., int n = 1000, int iter = 6); /// Default destructor virtual ~BaseNumericalRandomGenerator() {} @@ -54,22 +49,19 @@ class BaseNumericalRandomGenerator double generateLin(RandomEngineAndDistribution const*) const; // The probability density function, to be implemented in the real class - virtual double function(double x)=0; + virtual double function(double x) = 0; /// To shoot in a given interval - bool setSubInterval(double x1,double x2); - - protected: + bool setSubInterval(double x1, double x2); +protected: std::vector sampling; std::vector f; double xmin, xmax; int n, iter; double rmin, deltar; - - private: +private: int m; - }; #endif diff --git a/FastSimulation/Utilities/interface/DoubleCrystalBallGenerator.h b/FastSimulation/Utilities/interface/DoubleCrystalBallGenerator.h index d1b0b499f5008..c00a2549c2b8b 100644 --- a/FastSimulation/Utilities/interface/DoubleCrystalBallGenerator.h +++ b/FastSimulation/Utilities/interface/DoubleCrystalBallGenerator.h @@ -9,16 +9,15 @@ class RandomEngineAndDistribution; -class DoubleCrystalBallGenerator -{ - public: - //constructor - DoubleCrystalBallGenerator() { } - //destructor - virtual ~DoubleCrystalBallGenerator() {} +class DoubleCrystalBallGenerator { +public: + //constructor + DoubleCrystalBallGenerator() {} + //destructor + virtual ~DoubleCrystalBallGenerator() {} - //functions - double shoot(double mu, double sigma, double aL, double nL, double aR, double nR, - RandomEngineAndDistribution const* random); + //functions + double shoot( + double mu, double sigma, double aL, double nL, double aR, double nR, RandomEngineAndDistribution const* random); }; #endif diff --git a/FastSimulation/Utilities/interface/FamosDebug.h b/FastSimulation/Utilities/interface/FamosDebug.h index 11b111bc4b531..8340880e9b348 100644 --- a/FastSimulation/Utilities/interface/FamosDebug.h +++ b/FastSimulation/Utilities/interface/FamosDebug.h @@ -1,7 +1,7 @@ #ifndef FastSimulation_Utilities_FamosDebug_H #define FastSimulation_Utilities_FamosDebug_H -// Uncomment the following line to include the debugging code in the +// Uncomment the following line to include the debugging code in the // library // getClosestCell @@ -29,4 +29,3 @@ #endif #endif - diff --git a/FastSimulation/Utilities/interface/GammaFunctionGenerator.h b/FastSimulation/Utilities/interface/GammaFunctionGenerator.h index 1c6d110d296f4..5ca74b960d8d8 100644 --- a/FastSimulation/Utilities/interface/GammaFunctionGenerator.h +++ b/FastSimulation/Utilities/interface/GammaFunctionGenerator.h @@ -18,34 +18,31 @@ class RandomEngineAndDistribution; -class GammaFunctionGenerator -{ - public: - +class GammaFunctionGenerator { +public: /// Constructor GammaFunctionGenerator(); /// Destructor virtual ~GammaFunctionGenerator(); - - /// shoot along a gamma distribution with shape parameter alpha and scale beta + + /// shoot along a gamma distribution with shape parameter alpha and scale beta /// values > xmin double shoot(RandomEngineAndDistribution const*) const; - + /// The parameters must be set before shooting - void setParameters(double a,double b, double xm); + void setParameters(double a, double b, double xm); - private: +private: /// values 0 theGammas; - + // The gamma distribution core coefficients std::vector coreCoeff; @@ -54,21 +51,21 @@ class GammaFunctionGenerator // possibility to store different limits std::vector approxLimit; - + // boundaries double xmin; double xmax; - + // closest lower integer unsigned na; // alpha-na double frac; - // alpha function parameters - double alpha,beta; + // alpha function parameters + double alpha, beta; // Incomlete Gamma = Int(0,x)[t^(alpha-1)exp(-t)dt]/Gamma(alpha); Genfun::IncompleteGamma myIncompleteGamma; - // some useful integrals + // some useful integrals std::vector integralToApproxLimit; // if xmin>xmax diff --git a/FastSimulation/Utilities/interface/GammaNumericalGenerator.h b/FastSimulation/Utilities/interface/GammaNumericalGenerator.h index 8d722acf58d43..2ae12828576a7 100644 --- a/FastSimulation/Utilities/interface/GammaNumericalGenerator.h +++ b/FastSimulation/Utilities/interface/GammaNumericalGenerator.h @@ -9,47 +9,41 @@ class RandomEngineAndDistribution; -class GammaNumericalGenerator : public BaseNumericalRandomGenerator -{ - public: - +class GammaNumericalGenerator : public BaseNumericalRandomGenerator { +public: /// Constructor : initialization of the Random Generator - GammaNumericalGenerator(double a=0,double b=0,double x1=0,double x2=0) : - BaseNumericalRandomGenerator(x1,x2,1000), - a_(a),b_(b),valid(false) { - - if(a>0&&b>0) - { - valid=true; - initialize(); - } + GammaNumericalGenerator(double a = 0, double b = 0, double x1 = 0, double x2 = 0) + : BaseNumericalRandomGenerator(x1, x2, 1000), a_(a), b_(b), valid(false) { + if (a > 0 && b > 0) { + valid = true; + initialize(); + } } /// Default destructor ~GammaNumericalGenerator() override {} - /// Random generator + /// Random generator double gamma(RandomEngineAndDistribution const* random) const { return generate(random); } - - double gamma_exp(RandomEngineAndDistribution const* random) const {return generateExp(random);} - double gamma_lin(RandomEngineAndDistribution const* random) const {return generateLin(random);} + double gamma_exp(RandomEngineAndDistribution const* random) const { return generateExp(random); } + + double gamma_lin(RandomEngineAndDistribution const* random) const { return generateLin(random); } /// The probability density function implementation double function(double x) override { return ersatzt(x); } - inline bool isValid() const {return valid;} - - private: + inline bool isValid() const { return valid; } +private: /// Gamma Function - double ersatzt(double x) { - double bt=b_*x; - return b_*pow(bt,a_-1)*exp(-bt); + double ersatzt(double x) { + double bt = b_ * x; + return b_ * pow(bt, a_ - 1) * exp(-bt); } - - // gamma distribution parameters - double a_,b_; + + // gamma distribution parameters + double a_, b_; bool valid; }; diff --git a/FastSimulation/Utilities/interface/GaussianTail.h b/FastSimulation/Utilities/interface/GaussianTail.h index f11ce1825d19c..05448f2be74d2 100644 --- a/FastSimulation/Utilities/interface/GaussianTail.h +++ b/FastSimulation/Utilities/interface/GaussianTail.h @@ -2,32 +2,28 @@ #define FastSimulation_Utilities_GaussianTail_H // Florian Beaudette (LLR). -// 11/09/06 +// 11/09/06 // Gaussian tail generator. Copied from the GNU Scientific library class RandomEngineAndDistribution; -class GaussianTail -{ - public: - GaussianTail(double sigma=1., double threshold=2.); +class GaussianTail { +public: + GaussianTail(double sigma = 1., double threshold = 2.); ~GaussianTail(); - inline void setParameters(double sigma, double threshold) - { - sigma_= sigma; - threshold_ = threshold; - s_=threshold_/sigma_; - ssquare_ = s_ * s_; - }; + inline void setParameters(double sigma, double threshold) { + sigma_ = sigma; + threshold_ = threshold; + s_ = threshold_ / sigma_; + ssquare_ = s_ * s_; + }; double shoot(RandomEngineAndDistribution const*) const; - private: - +private: double sigma_; double threshold_; double s_; double ssquare_; - }; #endif diff --git a/FastSimulation/Utilities/interface/HistogramGenerator.h b/FastSimulation/Utilities/interface/HistogramGenerator.h index f88f094727515..bf437868e37ba 100644 --- a/FastSimulation/Utilities/interface/HistogramGenerator.h +++ b/FastSimulation/Utilities/interface/HistogramGenerator.h @@ -11,31 +11,28 @@ class RandomEngine; class TAxis; -class HistogramGenerator : public BaseNumericalRandomGenerator -{ - public: - +class HistogramGenerator : public BaseNumericalRandomGenerator { +public: /// Constructor : initialization of the Random Generator - HistogramGenerator(TH1 * histo) : - BaseNumericalRandomGenerator(histo->GetXaxis()->GetXmin(), - histo->GetXaxis()->GetXmax(), - 100000, - 3), - myHisto(histo), - theXaxis(histo->GetXaxis()), - nbins(histo->GetXaxis()->GetNbins()) - { - + HistogramGenerator(TH1* histo) + : BaseNumericalRandomGenerator(histo->GetXaxis()->GetXmin(), histo->GetXaxis()->GetXmax(), 100000, 3), + myHisto(histo), + theXaxis(histo->GetXaxis()), + nbins(histo->GetXaxis()->GetNbins()) { // std::cout << "Old xmin/xmax = " << xmin << " " << xmax << std::endl; - // Drop lowest and highest empty bins - double du = (xmax-xmin)/(float)nbins; + // Drop lowest and highest empty bins + double du = (xmax - xmin) / (float)nbins; // Restrict xmin to meaningful values - while ( function(xmin) <= 0. ) xmin += du; + while (function(xmin) <= 0.) + xmin += du; // Restrict xmax to meaningful values - while ( function(xmax) <= 0. ) xmax -= du; + while (function(xmax) <= 0.) + xmax -= du; - if ( xmin != histo->GetXaxis()->GetXmin() ) xmin -= du; - if ( xmax != histo->GetXaxis()->GetXmax() ) xmax += du; + if (xmin != histo->GetXaxis()->GetXmin()) + xmin -= du; + if (xmax != histo->GetXaxis()->GetXmax()) + xmax += du; // std::cout << "New xmin/xmax = " << xmin << " " << xmax << std::endl; @@ -49,17 +46,17 @@ class HistogramGenerator : public BaseNumericalRandomGenerator /// The probability density function implementation double function(double x) override { return ersatzt(x); } - private: +private: /// Pointer to the histogram - TH1 * myHisto; + TH1* myHisto; - /// the axis - TAxis * theXaxis; + /// the axis + TAxis* theXaxis; /// n bins int nbins; /// Gamma Function - double ersatzt(double x); + double ersatzt(double x); }; #endif diff --git a/FastSimulation/Utilities/interface/Histos.h b/FastSimulation/Utilities/interface/Histos.h index 5d371be07e010..1f6c129594a0c 100644 --- a/FastSimulation/Utilities/interface/Histos.h +++ b/FastSimulation/Utilities/interface/Histos.h @@ -16,55 +16,53 @@ #include //#include -class Histos -{ - public: - - typedef std::map::const_iterator HistoItr; +class Histos { +public: + typedef std::map::const_iterator HistoItr; static Histos* instance(); /// Destructor virtual ~Histos(); - + /// Book an histogram (1D or 2D) - void book(const std::string& name, - int nx , float xmin , float xmax, - int ny=0, float ymin=0., float ymax=0.); + void book(const std::string& name, int nx, float xmin, float xmax, int ny = 0, float ymin = 0., float ymax = 0.); // Same as before. Creates n2-n1 histos with name name+n1 ... name+n2 - void bookByNumber(const std::string& name, int n1,int n2, - int nx , float xmin , float xmax, - int ny=0, float ymin=0., float ymax=0.); - + void bookByNumber(const std::string& name, + int n1, + int n2, + int nx, + float xmin, + float xmax, + int ny = 0, + float ymin = 0., + float ymax = 0.); /// Book a TProfile - /// option="S" -> spread + /// option="S" -> spread /// "" -> error on mean (from Root documentation) - void book(const std::string& name, int nx, float xmin, float xmax, - const std::string& option); - + void book(const std::string& name, int nx, float xmin, float xmax, const std::string& option); /// Write one or all histogram(s) in a file - void put(const std::string& file, std::string name=""); + void put(const std::string& file, std::string name = ""); /// Divide two histograms and put the result in the first void divide(const std::string& h1, const std::string& h2, const std::string& h3); /// Fill an histogram - void fill(const std::string& name, float val1, float val2=1., float val3=1.); + void fill(const std::string& name, float val1, float val2 = 1., float val3 = 1.); // Fill a series of histos. The name is name+number - void fillByNumber(const std::string& name,int number,float val1,float val2=1.,float val3=1.); + void fillByNumber(const std::string& name, int number, float val1, float val2 = 1., float val3 = 1.); /// Add any object - void addObject(const std::string& name, TObject * obj); - - /// - void debug(std::string p="") const {std::cout << " Histos myMap : "<< &theHistos << " " << p <