23 namespace HepMC {
class GenParticle;
class GenEvent; }
37 bool fillIndices(
const HepMC::GenEvent * mc, std::vector<const HepMC::GenParticle*>& particles, std::vector<int>& barCodeVector,
int offset);
81 using namespace HepMC;
88 abortOnUnknownPDGCode_( cfg.getUntrackedParameter<bool>(
"abortOnUnknownPDGCode",
true ) ),
89 saveBarCodes_( cfg.getUntrackedParameter<bool>(
"saveBarCodes",
false ) ),
91 doSubEvent_(cfg.getUntrackedParameter<bool>(
"doSubEvent",
false )),
92 useCF_(cfg.getUntrackedParameter<bool>(
"useCrossingFrame",
false ))
94 produces<GenParticleCollection>();
97 produces<vector<int> >().setBranchAlias( alias +
"BarCodes" );
115 map<int, int>::const_iterator
f =
chargeMap_.find(
id );
119 <<
"invalid PDG id: " <<
id << endl;
131 for( HepPDT::ParticleDataTable::const_iterator
p = pdt->begin();
p != pdt->end(); ++
p ) {
134 int q3 =
id.threeCharge();
135 if ( apdgId < PDGCacheMax && pdgId > 0 ) {
151 size_t totalSize = 0;
152 const GenEvent * mc = 0;
153 std::vector<Handle<HepMCProduct> > heps;
161 npiles = cfhepmcprod->
size();
162 for(
unsigned int icf = 0; icf < npiles; ++icf){
166 for(
size_t i = 0;
i < npiles; ++
i){
169 heps.push_back(handle);
171 totalSize += heps[
i]->GetEvent()->particles_size();
176 mc = mcp->GetEvent();
179 <<
"HepMC has null pointer to GenEvent" << endl;
180 totalSize = mc->particles_size();
184 const size_t size = totalSize;
185 vector<const HepMC::GenParticle *> particles( size );
188 auto_ptr<vector<int> > barCodeVector(
new vector<int>( size ) );
193 size_t suboffset = 0;
197 for(
size_t i = 0;
i < npiles; ++
i){
200 else mc = heps[
i]->GetEvent();
204 const HepMC::HeavyIon * hi = mc->heavy_ion();
205 if(hi && hi->Ncoll_hard() > 1) isHI =
true;
206 size_t num_particles = mc->particles_size();
207 fillIndices(mc, particles, *barCodeVector, offset);
209 for(
size_t i = offset;
i < offset + num_particles; ++
i ) {
218 for(
size_t d = offset; d < offset + num_particles; ++ d ) {
220 const GenVertex * productionVertex = part->production_vertex();
222 if ( productionVertex != 0 ) {
223 sub_id = productionVertex->id();
224 if(!isHI) sub_id = 0;
228 const GenVertex * endVertex = part->end_vertex();
229 if(endVertex != 0) sub_id = endVertex->id();
230 else throw cms::Exception(
"SubEventID" )<<
"SubEvent not determined. Particle has no production and no end vertex!"<<endl;
232 if(sub_id < 0) sub_id = 0;
233 int new_id = sub_id + suboffset;
236 cands[d].setCollisionId(new_id);
237 LogDebug(
"VertexId")<<
"SubEvent offset 3 : "<<suboffset;
241 nsub = hi->Ncoll_hard()+1;
246 offset += num_particles;
252 for(
size_t i = 0;
i < particles.size(); ++
i ) {
261 for(
size_t d = 0; d < cands.size(); ++ d ) {
263 const GenVertex * productionVertex = part->production_vertex();
266 cands[d].setCollisionId(0);
273 if(cfhepmcprod)
delete cfhepmcprod;
279 int pdgId = part->pdg_id();
285 const GenVertex *
v = part->production_vertex();
287 ThreeVector vtx = v->point3d();
298 const GenVertex * productionVertex = part->production_vertex();
299 size_t numberOfMothers = productionVertex->particles_in_size();
300 if ( numberOfMothers > 0 ) {
301 GenVertex::particles_in_const_iterator motherIt = productionVertex->particles_in_const_begin();
302 for( ; motherIt != productionVertex->particles_in_const_end(); motherIt++) {
315 HepMC::GenEvent::particle_const_iterator
begin = mc->particles_begin(),
end = mc->particles_end();
316 for( HepMC::GenEvent::particle_const_iterator
p = begin;
p !=
end; ++
p ) {
318 size_t barCode_this_event = particle->barcode();
319 size_t barCode = barCode_this_event +
offset;
322 <<
"barcodes are duplicated! " << endl;
323 particles[
idx] = particle;
324 barCodeVector[
idx] = barCode;
325 barcodes_.insert( make_pair(barCode_this_event, idx ++) );
GenParticleProducer(const edm::ParameterSet &)
constructor
std::vector< GenParticle > GenParticleCollection
collection of GenParticles
T getParameter(std::string const &) const
bool abortOnUnknownPDGCode_
unknown code treatment flag
T getUntrackedParameter(std::string const &, T const &) const
bool fillDaughters(reco::GenParticleCollection &cand, const HepMC::GenParticle *part, size_t index)
edm::InputTag src_
source collection name
void setCollisionId(int s)
std::vector< int > chargeP_
charge indices
std::map< int, size_t > barcodes_
#define DEFINE_FWK_MODULE(type)
edm::Ref< GenParticleCollection > GenParticleRef
persistent reference to a GenParticle
~GenParticleProducer()
destructor
virtual void produce(edm::Event &e, const edm::EventSetup &) override
process one event
int chargeTimesThree(int) const
void getData(T &iHolder) const
U second(std::pair< T, U > const &p)
reco::GenParticleRefProd ref_
void resetDaughters(const edm::ProductID &id)
set daughters product ID
bool firstEvent_
whether the first event was looked at
virtual void setStatus(int status) GCC11_FINAL
set status word
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
unsigned int offset(bool)
virtual void setVertex(const Point &vertex)
set vertex
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
RefProd< PROD > getRefBeforePut()
virtual void setThreeCharge(Charge qx3) GCC11_FINAL
set electric charge
bool fillIndices(const HepMC::GenEvent *mc, std::vector< const HepMC::GenParticle * > &particles, std::vector< int > &barCodeVector, int offset)
bool convertParticle(reco::GenParticle &cand, const HepMC::GenParticle *part)
const T & getObject(unsigned int ip) const
const HepMC::GenEvent * GetEvent() const
static const double mmToCm
tuple idx
DEBUGGING if hasattr(process,"trackMonIterativeTracking2012"): print "trackMonIterativeTracking2012 D...
std::map< int, int > chargeMap_
T const * product() const
math::XYZTLorentzVector LorentzVector
Lorentz vector.
bool doSubEvent_
input & output modes
std::vector< int > chargeM_
virtual void setP4(const LorentzVector &p4) GCC11_FINAL
set 4-momentum
ProductID id() const
Accessor for product ID.
math::XYZPoint Point
point in the space
bool saveBarCodes_
save bar-codes
std::vector< std::string > vectorSrc_
virtual void setPdgId(int pdgId) GCC11_FINAL
tuple size
Write out results.
static const int PDGCacheMax