Skip to content

Commit

Permalink
Merge CMSSW_9_4_X into CMSSW_9_4_AN_X.
Browse files Browse the repository at this point in the history
  • Loading branch information
cmsbuild committed Oct 13, 2018
2 parents effc4ef + 1a1a5c7 commit 70cbc4a
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 13 deletions.
Expand Up @@ -25,6 +25,12 @@ namespace fastsim
*/
StraightTrajectory(const Particle & particle) : Trajectory(particle) {;}

//! Use Copy Constructor.
/*
\param trajectory StraightTrajectory does not have any special attribues so it can be copied right away
*/
StraightTrajectory(const Trajectory & trajectory) : Trajectory(trajectory) {;}

//! Check if an intersection of the trajectory with a barrel layer exists.
/*!
There is always an intersection between a straight line and a barrel layer unless the trajectory is parallel to z axis. In this case, the particle is not propagated anyways since it will not hit any detector material.
Expand Down
Expand Up @@ -13,6 +13,7 @@
#include "FWCore/Framework/interface/ESHandle.h"
#include "FWCore/Framework/interface/LuminosityBlock.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"
#include "FWCore/Framework/interface/ESWatcher.h"

// data formats
#include "SimDataFormats/GeneratorProducts/interface/HepMCProduct.h"
Expand Down Expand Up @@ -83,7 +84,9 @@ class FastSimProducer : public edm::stream::EDProducer<> {
std::unique_ptr<RandomEngineAndDistribution> _randomEngine; //!< The random engine

bool simulateCalorimetry;
std::unique_ptr<CalorimetryManager> myCalorimetry; // unfortunately, default constructor cannot be called
edm::ESWatcher<CaloGeometryRecord> watchCaloGeometry_;
edm::ESWatcher<CaloTopologyRecord> watchCaloTopology_;
std::unique_ptr<CalorimetryManager> myCalorimetry; // unfortunately, default constructor cannot be called
bool simulateMuons;

fastsim::Decayer decayer_; //!< Handles decays of non-stable particles using pythia
Expand Down Expand Up @@ -197,17 +200,20 @@ FastSimProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup)
// Initialize the calorimeter geometry
if(simulateCalorimetry)
{
edm::ESHandle<CaloGeometry> pG;
iSetup.get<CaloGeometryRecord>().get(pG);
myCalorimetry->getCalorimeter()->setupGeometry(*pG);

edm::ESHandle<CaloTopology> theCaloTopology;
iSetup.get<CaloTopologyRecord>().get(theCaloTopology);
myCalorimetry->getCalorimeter()->setupTopology(*theCaloTopology);
myCalorimetry->getCalorimeter()->initialize(geometry_.getMagneticFieldZ(math::XYZTLorentzVector(0., 0., 0., 0.)));
if(watchCaloGeometry_.check(iSetup) || watchCaloTopology_.check(iSetup)){
edm::ESHandle<CaloGeometry> pG;
iSetup.get<CaloGeometryRecord>().get(pG);
myCalorimetry->getCalorimeter()->setupGeometry(*pG);

edm::ESHandle<CaloTopology> theCaloTopology;
iSetup.get<CaloTopologyRecord>().get(theCaloTopology);
myCalorimetry->getCalorimeter()->setupTopology(*theCaloTopology);
myCalorimetry->getCalorimeter()->initialize(geometry_.getMagneticFieldZ(math::XYZTLorentzVector(0., 0., 0., 0.)));

myCalorimetry->getHFShowerLibrary()->initHFShowerLibrary(iSetup);
myCalorimetry->getHFShowerLibrary()->initHFShowerLibrary(iSetup);
}

// Important: this also cleans the calorimetry information from the last event
myCalorimetry->initialize(_randomEngine.get());
}

Expand Down
Expand Up @@ -97,7 +97,7 @@ double fastsim::HelixTrajectory::nextCrossingTimeC(const BarrelSimplifiedGeometr
{
// Should not be reached: Full Propagation does always have a solution "if(crosses(layer)) == -1"
// Even if particle is outside all layers -> can turn around in magnetic field
throw cms::Exception("FastSimulation") << "HelixTrajectory: should not be reached (no solution).";
return -1;
}

// Uses a numerically more stable procedure:
Expand Down Expand Up @@ -147,7 +147,8 @@ double fastsim::HelixTrajectory::nextCrossingTimeC(const BarrelSimplifiedGeometr
if(std::abs(layer.getRadius() - getRadParticle(phi1)) > 1.0e-2
|| std::abs(layer.getRadius() - getRadParticle(phi2)) > 1.0e-2)
{
return ((StraightTrajectory*) this)->nextCrossingTimeC(layer, onLayer);
StraightTrajectory traj(*this);
return traj.nextCrossingTimeC(layer, onLayer);
}

// if the particle is already on the layer, we need to make sure the 2nd solution is picked.
Expand Down
Expand Up @@ -91,7 +91,10 @@ std::unique_ptr<fastsim::Particle> fastsim::ParticleManager::nextParticle(const
const HepPDT::ParticleData * particleData = particleDataTable_->particle(HepPDT::ParticleID(particle->pdgId()));
if(!particleData)
{
throw cms::Exception("fastsim::ParticleManager") << "unknown pdg id: " << particle->pdgId() << std::endl;
// in very few events the Decayer (pythia) produces high mass resonances that are for some reason not present in the table (even though they should technically be)
// they have short lifetimes, so decay them right away (charge and lifetime cannot be taken from table)
particle->setRemainingProperLifeTimeC(0.);
particle->setCharge(0.);
}

// set lifetime
Expand Down

0 comments on commit 70cbc4a

Please sign in to comment.