83 mctruthMatchingInfo_ =
89 inputTagEcalRecHitsEB_
91 inputTagEcalRecHitsEE_
99 produces<reco::PFSimParticleCollection>();
102 (
"ParticleFilter" );
104 mySimEvent =
new FSimEvent( particleFilter_ );
123 mySimEvent->initializePdt(&(*pdt));
131 LogDebug(
"PFSimParticleProducer")<<
"START event: "<<iEvent.
id().
event()
132 <<
" in run "<<iEvent.
id().
run()<<endl;
138 std::vector<unsigned> recTrackSimID;
144 typedef std::pair<double, unsigned> hitSimID;
145 typedef std::list< std::pair<double, unsigned> >::iterator ITM;
146 std::vector< std::list <hitSimID> > caloHitsEBID(62000);
147 std::vector<double> caloHitsEBTotE(62000,0.0);
149 if(mctruthMatchingInfo_){
158 = iEvent.
getByLabel(inputTagFamosSimHits_,pcalohits);
163 err<<
"could not find pcaloHit "<<
"famosSimHits:EcalHitsEB";
164 LogError(
"PFSimParticleProducer")<<err.str()<<endl;
174 edm::PCaloHitContainer::const_iterator it
175 = pcalohits.
product()->begin();
176 edm::PCaloHitContainer::const_iterator itend
192 if(it->energy() > 0.0) {
193 std::pair<double, unsigned> phitsimid
194 = make_pair(it->energy(),it->geantTrackId());
195 caloHitsEBID[
detid.hashedIndex()].push_back(phitsimid);
196 caloHitsEBTotE[
detid.hashedIndex()]
207 LogDebug(
"PFSimParticleProducer")<<
"getting PFRecTracks"<<endl;
208 iEvent.
getByLabel(inputTagRecTracks_, recTracks);
211 LogError(
"PFSimParticleProducer")<<err
212 <<
" cannot get collection "
213 <<
"particleFlowBlock"<<
":"
220 getSimIDs( recTracks, recTrackSimID );
225 if( processParticles_) {
227 auto_ptr< reco::PFSimParticleCollection >
235 err<<
"cannot find sim tracks: "<<inputTagSim_;
236 LogError(
"PFSimParticleProducer")<<err.str()<<endl;
244 found = iEvent.
getByLabel(inputTagSim_,simVertices);
247 <<
"cannot find sim vertices: "<<inputTagSim_<<endl;
259 mySimEvent->fill( *simTracks, *simVertices );
265 for(
unsigned i=0;
i<mySimEvent->nTracks();
i++) {
280 unsigned recTrackID = 99999;
281 vector<unsigned> recHitContrib;
282 vector<double> recHitContribFrac;
284 if(mctruthMatchingInfo_){
286 for(
unsigned lo=0; lo<recTrackSimID.size();
288 if(
i == recTrackSimID[lo] ) {
300 bool found = iEvent.
getByLabel(inputTagEcalRecHitsEB_,
304 err<<
"could not find rechits "<< inputTagEcalRecHitsEB_;
305 LogError(
"PFSimParticleProducer")<<err.str()<<endl;
315 = rhcHandle.
product()->begin();
319 for(;it_rh!=itend_rh;++it_rh)
328 ITM it_phit = caloHitsEBID[rhit_hi].begin();
329 ITM itend_phit = caloHitsEBID[rhit_hi].end();
330 for(;it_phit!=itend_phit;++it_phit)
332 if(
i == it_phit->second)
336 bool alreadyin =
false;
337 for(
unsigned ihit = 0; ihit < recHitContrib.size();
339 if(
detid.rawId() == recHitContrib[ihit])
343 double pcalofraction = 0.0;
344 if(caloHitsEBTotE[rhit_hi] != 0.0)
346 = (it_phit->first/caloHitsEBTotE[rhit_hi])*100.0;
349 recHitContrib.push_back(it_rh->id());
350 recHitContribFrac.push_back(pcalofraction);
381 originVtx.position().y(),
382 originVtx.position().z() );
394 particle.addPoint(pointOrig);
414 particle.addPoint(pointEnd);
418 particle.addPoint(dummy);
428 posLayer1, momLayer1);
430 particle.addPoint( layer1Pt );
436 particle.addPoint(dummy);
445 posLayer2, momLayer2);
447 particle.addPoint( layer2Pt );
453 particle.addPoint(dummy);
465 particle.addPoint( ecalPt );
471 particle.addPoint(dummy);
476 particle.addPoint(dummy);
487 posHCALin, momHCALin);
489 particle.addPoint( hcalPtin );
498 posHCALout, momHCALout);
500 particle.addPoint( hcalPtout );
509 posHOEntrance, momHOEntrance);
511 particle.addPoint( hoPtin );
519 particle.addPoint(dummy);
522 pOutputPFSimParticleCollection->push_back( particle );
525 iEvent.
put(pOutputPFSimParticleCollection);
530 <<
" in run "<<iEvent.
id().
run()<<endl;
534 std::vector<unsigned>& recTrackSimID )
540 for(
unsigned i=0;
i<trackh->size();
i++) {
552 = trackref->recHitsBegin();
554 = trackref->recHitsEnd();
556 it != rhitend; it++){
558 if( (*it)->isValid() ){
568 recTrackSimID.push_back( rechit->
simtrackId() );
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
double z() const
z of vertex
virtual void beginRun(const edm::Run &r, const edm::EventSetup &c) override
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)
const int & simtrackId() const
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.
const RawParticle & ecalEntrance() const
The particle at ECAL entrance.
const FSimVertex & vertex() const
Origin vertex.
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
true particle for particle flow
T const * product() const
XYZPointD XYZPoint
point in space with cartesian internal representation
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