75 tokenSim_ = consumes<std::vector<SimTrack> >(inputTagSim_);
76 tokenSimVertices_ = consumes<std::vector<SimVertex> >(inputTagSim_);
82 tokenFamosSimHits_ = consumes<edm::PCaloHitContainer>(inputTagFamosSimHits_);
83 mctruthMatchingInfo_ =
88 tokenRecTracks_ = consumes<reco::PFRecTrackCollection>(inputTagRecTracks_);
91 tokenEcalRecHitsEB_ = consumes<EcalRecHitCollection>(inputTagEcalRecHitsEB_);
94 = consumes<EcalRecHitCollection>(inputTagEcalRecHitsEE_);
101 produces<reco::PFSimParticleCollection>();
104 (
"ParticleFilter" );
106 mySimEvent =
new FSimEvent( particleFilter_ );
123 mySimEvent->initializePdt(&(*pdt));
126 LogDebug(
"PFSimParticleProducer")<<
"START event: "<<iEvent.
id().
event()
127 <<
" in run "<<iEvent.
id().
run()<<endl;
133 std::vector<unsigned> recTrackSimID;
139 typedef std::pair<double, unsigned> hitSimID;
140 typedef std::list< std::pair<double, unsigned> >::iterator ITM;
141 std::vector< std::list <hitSimID> > caloHitsEBID(62000);
142 std::vector<double> caloHitsEBTotE(62000,0.0);
144 if(mctruthMatchingInfo_){
153 = iEvent.
getByToken(tokenFamosSimHits_,pcalohits);
158 err<<
"could not find pcaloHit "<<
"famosSimHits:EcalHitsEB";
159 LogError(
"PFSimParticleProducer")<<err.str()<<endl;
169 edm::PCaloHitContainer::const_iterator it
170 = pcalohits.
product()->begin();
171 edm::PCaloHitContainer::const_iterator itend
187 if(it->energy() > 0.0) {
188 std::pair<double, unsigned> phitsimid
189 = make_pair(it->energy(),it->geantTrackId());
190 caloHitsEBID[
detid.hashedIndex()].push_back(phitsimid);
191 caloHitsEBTotE[
detid.hashedIndex()]
202 LogDebug(
"PFSimParticleProducer")<<
"getting PFRecTracks"<<endl;
203 iEvent.
getByToken(tokenRecTracks_, recTracks);
206 LogError(
"PFSimParticleProducer")<<err
207 <<
" cannot get collection "
208 <<
"particleFlowBlock"<<
":"
215 getSimIDs( recTracks, recTrackSimID );
220 if( processParticles_) {
222 auto_ptr< reco::PFSimParticleCollection >
230 err<<
"cannot find sim tracks: "<<inputTagSim_;
231 LogError(
"PFSimParticleProducer")<<err.str()<<endl;
239 found = iEvent.
getByToken(tokenSimVertices_,simVertices);
242 <<
"cannot find sim vertices: "<<inputTagSim_<<endl;
254 mySimEvent->fill( *simTracks, *simVertices );
260 for(
unsigned i=0;
i<mySimEvent->nTracks();
i++) {
275 unsigned recTrackID = 99999;
276 vector<unsigned> recHitContrib;
277 vector<double> recHitContribFrac;
279 if(mctruthMatchingInfo_){
281 for(
unsigned lo=0; lo<recTrackSimID.size();
283 if(
i == recTrackSimID[lo] ) {
295 bool found = iEvent.
getByToken(tokenEcalRecHitsEB_,
299 err<<
"could not find rechits "<< inputTagEcalRecHitsEB_;
300 LogError(
"PFSimParticleProducer")<<err.str()<<endl;
310 = rhcHandle.
product()->begin();
314 for(;it_rh!=itend_rh;++it_rh)
323 ITM it_phit = caloHitsEBID[rhit_hi].begin();
324 ITM itend_phit = caloHitsEBID[rhit_hi].end();
325 for(;it_phit!=itend_phit;++it_phit)
327 if(
i == it_phit->second)
331 bool alreadyin =
false;
332 for(
unsigned ihit = 0; ihit < recHitContrib.size();
334 if(
detid.rawId() == recHitContrib[ihit])
338 double pcalofraction = 0.0;
339 if(caloHitsEBTotE[rhit_hi] != 0.0)
341 = (it_phit->first/caloHitsEBTotE[rhit_hi])*100.0;
344 recHitContrib.push_back(it_rh->id());
345 recHitContribFrac.push_back(pcalofraction);
376 originVtx.position().y(),
377 originVtx.position().z() );
389 particle.addPoint(pointOrig);
409 particle.addPoint(pointEnd);
413 particle.addPoint(dummy);
423 posLayer1, momLayer1);
425 particle.addPoint( layer1Pt );
431 particle.addPoint(dummy);
440 posLayer2, momLayer2);
442 particle.addPoint( layer2Pt );
448 particle.addPoint(dummy);
460 particle.addPoint( ecalPt );
466 particle.addPoint(dummy);
471 particle.addPoint(dummy);
482 posHCALin, momHCALin);
484 particle.addPoint( hcalPtin );
493 posHCALout, momHCALout);
495 particle.addPoint( hcalPtout );
504 posHOEntrance, momHOEntrance);
506 particle.addPoint( hoPtin );
514 particle.addPoint(dummy);
517 pOutputPFSimParticleCollection->push_back( particle );
520 iEvent.
put(pOutputPFSimParticleCollection);
525 <<
" in run "<<iEvent.
id().
run()<<endl;
529 std::vector<unsigned>& recTrackSimID )
535 for(
unsigned i=0;
i<trackh->size();
i++) {
547 = trackref->recHitsBegin();
549 = trackref->recHitsEnd();
551 it != rhitend; it++){
553 if( (*it)->isValid() ){
563 for(
unsigned int st_index=0;st_index<rechit->
nSimTrackIds();++st_index){
564 recTrackSimID.push_back(rechit->
simTrackId(st_index));
PFSimParticleProducer(const edm::ParameterSet &)
T getParameter(std::string const &) const
EventNumber_t event() const
T getUntrackedParameter(std::string const &, T const &) const
reconstructed track used as an input to particle flow
bool noEndVertex() const
no end vertex
float charge() const
charge
const RawParticle & hoEntrance() const
The particle at HCAL exir.
const FSimVertex & endVertex() const
end vertex
const RawParticle & hcalExit() const
The particle at HCAL exir.
double y() const
y of vertex
bool getByToken(EDGetToken token, Handle< PROD > &result) const
double z() const
z of vertex
const XYZTLorentzVector & momentum() const
Temporary (until move of SimTrack to Mathcore) - No! Actually very useful.
const RawParticle & layer1Entrance() const
The particle at Preshower Layer 1.
std::vector< EcalRecHit >::const_iterator const_iterator
std::vector< PFSimParticle > PFSimParticleCollection
collection of PFSimParticle objects
const std::vector< int > & daughters() const
Vector of daughter indices.
double x() const
x of vertex
const reco::TrackRef & trackRef() const
void getData(T &iHolder) const
virtual void produce(edm::Event &, const edm::EventSetup &) override
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
int hashedIndex(int ieta, int iphi)
Point of closest approach from beam axis (initial point in the case of PFSimParticle) ...
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
const math::XYZTLorentzVector & position() const
Temporary (until CMSSW moves to Mathcore) - No ! Actually very useful.
virtual int32_t simTrackId(size_t i) const
const RawParticle & ecalEntrance() const
The particle at ECAL entrance.
const FSimVertex & vertex() const
Origin vertex.
true particle for particle flow
T const * product() const
XYZPointD XYZPoint
point in space with cartesian internal representation
virtual size_t nSimTrackIds() const
int type() const
particle type (HEP PDT convension)
int id() const
the index in FBaseSimEvent and other vectors
const RawParticle & layer2Entrance() const
The particle at Preshower Layer 2.
bool noMother() const
no mother particle
const RawParticle & hcalEntrance() const
The particle at HCAL entrance.
A PFTrack holds several trajectory points, which basically contain the position and momentum of a tra...
void getSimIDs(const TrackHandle &trackh, std::vector< unsigned > &recTrackSimID)
const FSimTrack & mother() const
mother
TrackingRecHitCollection::base::const_iterator trackingRecHit_iterator
iterator over a vector of reference to TrackingRecHit in the same collection