![]() |
![]() |
#include <RecoEgamma/EgammaPhotonProducers/interface/ConvertedPhotonProducer.h>
Definition at line 33 of file ConvertedPhotonProducer.h.
ConvertedPhotonProducer::ConvertedPhotonProducer | ( | const edm::ParameterSet & | ps | ) |
Definition at line 45 of file ConvertedPhotonProducer.cc.
References bcBarrelCollection_, bcEndcapCollection_, conf_, conversionIOTrackProducer_, conversionOITrackProducer_, ConvertedPhotonCollection_, edm::ParameterSet::getParameter(), inOutTrackSCAssociationCollection_, LogDebug, nEvt_, outInTrackSCAssociationCollection_, scHybridBarrelProducer_, scIslandEndcapProducer_, theEcalImpactPositionFinder_, theTrackPairFinder_, and theVertexFinder_.
00045 : 00046 00047 conf_(config), 00048 theTrackPairFinder_(0), 00049 theVertexFinder_(0), 00050 theEcalImpactPositionFinder_(0) 00051 00052 { 00053 00054 00055 00056 LogDebug("ConvertedPhotonProducer") << " ConvertedPhotonProducer CTOR " << "\n"; 00057 00058 00059 00060 // use onfiguration file to setup input collection names 00061 00062 //bcProducer_ = conf_.getParameter<std::string>("bcProducer"); 00063 bcBarrelCollection_ = conf_.getParameter<edm::InputTag>("bcBarrelCollection"); 00064 bcEndcapCollection_ = conf_.getParameter<edm::InputTag>("bcEndcapCollection"); 00065 00066 scHybridBarrelProducer_ = conf_.getParameter<edm::InputTag>("scHybridBarrelProducer"); 00067 scIslandEndcapProducer_ = conf_.getParameter<edm::InputTag>("scIslandEndcapProducer"); 00068 00069 // scHybridBarrelCollection_ = conf_.getParameter<std::string>("scHybridBarrelCollection"); 00070 // scIslandEndcapCollection_ = conf_.getParameter<std::string>("scIslandEndcapCollection"); 00071 00072 00073 conversionOITrackProducer_ = conf_.getParameter<std::string>("conversionOITrackProducer"); 00074 conversionIOTrackProducer_ = conf_.getParameter<std::string>("conversionIOTrackProducer"); 00075 00076 outInTrackSCAssociationCollection_ = conf_.getParameter<std::string>("outInTrackSCAssociation"); 00077 inOutTrackSCAssociationCollection_ = conf_.getParameter<std::string>("inOutTrackSCAssociation"); 00078 00079 00080 // use onfiguration file to setup output collection names 00081 ConvertedPhotonCollection_ = conf_.getParameter<std::string>("convertedPhotonCollection"); 00082 00083 00084 // Register the product 00085 produces< reco::ConversionCollection >(ConvertedPhotonCollection_); 00086 00087 // instantiate the Track Pair Finder algorithm 00088 theTrackPairFinder_ = new ConversionTrackPairFinder (); 00089 // instantiate the Vertex Finder algorithm 00090 theVertexFinder_ = new ConversionVertexFinder (); 00091 00092 00093 // Inizilize my global event counter 00094 nEvt_=0; 00095 00096 00097 theEcalImpactPositionFinder_ =0; 00098 00099 }
ConvertedPhotonProducer::~ConvertedPhotonProducer | ( | ) |
Definition at line 101 of file ConvertedPhotonProducer.cc.
References theTrackPairFinder_, and theVertexFinder_.
00101 { 00102 00103 00104 delete theTrackPairFinder_; 00105 delete theVertexFinder_; 00106 00107 00108 }
void ConvertedPhotonProducer::beginRun | ( | edm::Run & | r, | |
edm::EventSetup const & | es | |||
) | [virtual] |
Reimplemented from edm::EDProducer.
Definition at line 116 of file ConvertedPhotonProducer.cc.
References edm::EventSetup::get(), theEcalImpactPositionFinder_, and theMF_.
00116 { 00117 00118 00119 //get magnetic field 00120 edm::LogInfo("ConvertedPhotonProducer") << " get magnetic field" << "\n"; 00121 theEventSetup.get<IdealMagneticFieldRecord>().get(theMF_); 00122 00123 // instantiate the algorithm for finding the position of the track extrapolation at the Ecal front face 00124 theEcalImpactPositionFinder_ = new ConversionTrackEcalImpactPoint ( &(*theMF_) ); 00125 00126 00127 }
void ConvertedPhotonProducer::buildCollections | ( | const edm::Handle< edm::View< reco::CaloCluster > > & | scHandle, | |
const edm::Handle< edm::View< reco::CaloCluster > > & | bcHandle, | |||
std::map< std::vector< reco::TransientTrack >, reco::CaloClusterPtr > & | allPairs, | |||
reco::ConversionCollection & | outputConvPhotonCollection | |||
) | [private] |
Definition at line 270 of file ConvertedPhotonProducer.cc.
References edm::PtrVectorBase::clear(), reco::Conversion::conversionVertex(), GenMuonPlsPt100GeV_cfg::cout, direction, e, end, cms::Exception::explainSelf(), ConversionTrackEcalImpactPoint::find(), i, reco::Vertex::isValid(), LogDebug, python::multivaluedict::map(), ConversionTrackEcalImpactPoint::matchingBC(), p4, reco::TrackTransientTrack::persistentTrackRef(), reco::Vertex::position(), edm::PtrVector< T >::push_back(), ConversionVertexFinder::run(), theEcalImpactPositionFinder_, and theVertexFinder_.
Referenced by produce().
00275 { 00276 00277 // Loop over SC in the barrel and reconstruct converted photons 00278 int myCands=0; 00279 reco::CaloClusterPtrVector scPtrVec; 00280 for (unsigned i = 0; i < scHandle->size(); ++i ) { 00281 00282 reco::CaloClusterPtr aClus= scHandle->ptrAt(i); 00283 00284 std::vector<edm::Ref<reco::TrackCollection> > trackPairRef; 00285 LogDebug("ConvertedPhotonProducer") << "ConvertedPhotonProducer SC energy " << aClus->energy() << " eta " << aClus->eta() << " phi " << aClus->phi() << "\n"; 00286 00287 00289 const reco::Particle::Point vtx( 0, 0, 0 ); 00290 reco::Vertex theConversionVertex; 00291 00292 math::XYZVector direction =aClus->position() - vtx; 00293 math::XYZVector momentum = direction.unit() * aClus->energy(); 00294 const reco::Particle::LorentzVector p4(momentum.x(), momentum.y(), momentum.z(), aClus->energy() ); 00295 00296 int nFound=0; 00297 if ( allPairs.size() ) { 00298 00299 nFound=0; 00300 00301 00302 for ( std::map<std::vector<reco::TransientTrack>, reco::CaloClusterPtr>::const_iterator iPair= allPairs.begin(); iPair!= allPairs.end(); ++iPair ) { 00303 scPtrVec.clear(); 00304 00305 reco::CaloClusterPtr caloPtr=iPair->second; 00306 if ( !( aClus == caloPtr ) ) continue; 00307 00308 scPtrVec.push_back(aClus); 00309 nFound++; 00310 00311 00312 const string metname = "ConvertedPhotons|ConvertedPhotonProducer"; 00313 if ( (iPair->first).size() > 1 ) { 00314 try{ 00315 00316 TransientVertex trVtx=theVertexFinder_->run(iPair->first); 00317 theConversionVertex= trVtx; 00318 00319 } 00320 catch ( cms::Exception& e ) { 00321 std::cout << " cms::Exception caught in ConvertedPhotonProducer::produce" << "\n" ; 00322 edm::LogWarning(metname) << "cms::Exception caught in ConvertedPhotonProducer::produce\n" 00323 << e.explainSelf(); 00324 00325 } 00326 00327 } 00328 00329 00330 std::vector<math::XYZPoint> trkPositionAtEcal = theEcalImpactPositionFinder_->find( iPair->first, bcHandle ); 00331 std::vector<reco::CaloClusterPtr> matchingBC = theEcalImpactPositionFinder_->matchingBC(); 00332 00333 00334 /* 00335 for ( unsigned int i=0; i< matchingBC.size(); ++i) { 00336 if ( matchingBC[i].isNull() ) std::cout << " This ref to BC is null: skipping " << "\n"; 00337 else 00338 std::cout << " BC energy " << matchingBC[i]->energy() << "\n"; 00339 } 00340 */ 00341 00342 00344 trackPairRef.clear(); 00345 00346 00347 for ( std::vector<reco::TransientTrack>::const_iterator iTk=(iPair->first).begin(); iTk!= (iPair->first).end(); ++iTk) { 00348 LogDebug("ConvertedPhotonProducer") << " ConvertedPhotonProducer Transient Tracks in the pair charge " << iTk->charge() << " Num of RecHits " << iTk->recHitsSize() << " inner momentum " << iTk->track().innerMomentum() << "\n"; 00349 00350 const reco::TrackTransientTrack* ttt = dynamic_cast<const reco::TrackTransientTrack*>(iTk->basicTransientTrack()); 00351 reco::TrackRef myTkRef= ttt->persistentTrackRef(); 00352 00353 LogDebug("ConvertedPhotonProducer") << " ConvertedPhotonProducer Ref to Rec Tracks in the pair charge " << myTkRef->charge() << " Num of RecHits " << myTkRef->recHitsSize() << " inner momentum " << myTkRef->innerMomentum() << "\n"; 00354 00355 00356 trackPairRef.push_back(myTkRef); 00357 00358 } 00359 00360 00361 00362 LogDebug("ConvertedPhotonProducer") << " ConvertedPhotonProducer SC energy " << aClus->energy() << "\n"; 00363 LogDebug("ConvertedPhotonProducer") << " ConvertedPhotonProducer photon p4 " << p4 << "\n"; 00364 LogDebug("ConvertedPhotonProducer") << " ConvertedPhotonProducer vtx " << vtx.x() << " " << vtx.y() << " " << vtx.z() << "\n"; 00365 if( theConversionVertex.isValid() ) { 00366 00367 LogDebug("ConvertedPhotonProducer") << " ConvertedPhotonProducer theConversionVertex " << theConversionVertex.position().x() << " " << theConversionVertex.position().y() << " " << theConversionVertex.position().z() << "\n"; 00368 00369 } 00370 LogDebug("ConvertedPhotonProducer") << " ConvertedPhotonProducer trackPairRef " << trackPairRef.size() << "\n"; 00371 00372 00373 reco::Conversion newCandidate(scPtrVec, trackPairRef, trkPositionAtEcal, theConversionVertex, matchingBC); 00374 outputConvPhotonCollection.push_back(newCandidate); 00375 00376 00377 00378 myCands++; 00379 LogDebug("ConvertedPhotonProducer") << " ConvertedPhotonProducer Put the ConvertedPhotonCollection a candidate in the Barrel " << "\n"; 00380 00381 } 00382 00383 } 00384 00385 00386 if ( allPairs.size() ==0 || nFound ==0) { 00387 LogDebug("ConvertedPhotonProducer") << " ConvertedPhotonProducer GOLDEN PHOTON ?? Zero Tracks " << "\n"; 00388 LogDebug("ConvertedPhotonProducer") << " ConvertedPhotonProducer SC energy " << aClus->energy() << "\n"; 00389 LogDebug("ConvertedPhotonProducer") << " ConvertedPhotonProducer photon p4 " << p4 << "\n"; 00390 LogDebug("ConvertedPhotonProducer") << " ConvertedPhotonProducer vtx " << vtx.x() << " " << vtx.y() << " " << vtx.z() << "\n"; 00391 LogDebug("ConvertedPhotonProducer") << " ConvertedPhotonProducer trackPairRef " << trackPairRef.size() << "\n"; 00392 00393 std::vector<math::XYZPoint> trkPositionAtEcal; 00394 std::vector<reco::CaloClusterPtr> matchingBC; 00395 00396 scPtrVec.clear(); 00397 scPtrVec.push_back(aClus); 00398 reco::Conversion newCandidate(scPtrVec, trackPairRef, trkPositionAtEcal, theConversionVertex, matchingBC); 00399 outputConvPhotonCollection.push_back(newCandidate); 00400 00401 00402 if ( newCandidate.conversionVertex().isValid() ) 00403 LogDebug("ConvertedPhotonProducer") << " ConvertedPhotonProducer theConversionVertex " << newCandidate.conversionVertex().position().x() << " " << newCandidate.conversionVertex().position().y() << " " << newCandidate.conversionVertex().position().z() << "\n"; 00404 00405 00406 00407 00408 myCands++; 00409 LogDebug("ConvertedPhotonProducer") << " ConvertedPhotonProducer Put the ConvertedPhotonCollection a candidate in the Barrel " << "\n"; 00410 00411 } 00412 00413 00414 00415 00416 00417 } 00418 00419 00420 00421 00422 00423 }
Reimplemented from edm::EDProducer.
Definition at line 132 of file ConvertedPhotonProducer.cc.
References LogDebug, and nEvt_.
00132 { 00133 00134 edm::LogInfo("ConvertedPhotonProducer") << " Analyzed " << nEvt_ << "\n"; 00135 LogDebug("ConvertedPhotonProducer") << "ConvertedPhotonProducer::endJob Analyzed " << nEvt_ << " events " << "\n"; 00136 00137 00138 }
void ConvertedPhotonProducer::endRun | ( | edm::Run & | r, | |
edm::EventSetup const & | es | |||
) | [virtual] |
Reimplemented from edm::EDProducer.
Definition at line 110 of file ConvertedPhotonProducer.cc.
References theEcalImpactPositionFinder_.
00110 { 00111 delete theEcalImpactPositionFinder_; 00112 00113 }
void ConvertedPhotonProducer::produce | ( | edm::Event & | evt, | |
const edm::EventSetup & | es | |||
) | [virtual] |
Implements edm::EDProducer.
Definition at line 142 of file ConvertedPhotonProducer.cc.
References bcBarrelCollection_, bcEndcapCollection_, buildCollections(), conversionIOTrackProducer_, conversionOITrackProducer_, ConvertedPhotonCollection_, GenMuonPlsPt100GeV_cfg::cout, edm::EventSetup::get(), edm::Event::getByLabel(), edm::Event::id(), inOutTrackSCAssociationCollection_, edm::Handle< T >::isValid(), edm::InputTag::label(), LogDebug, nEvt_, outInTrackSCAssociationCollection_, edm::Event::put(), ConversionTrackPairFinder::run(), scHybridBarrelProducer_, scIslandEndcapProducer_, and theTrackPairFinder_.
00142 { 00143 00144 using namespace edm; 00145 nEvt_++; 00146 00147 LogDebug("ConvertedPhotonProducer") << "ConvertedPhotonProduce::produce event number " << theEvent.id() << " Global counter " << nEvt_ << "\n"; 00148 00149 // 00150 // create empty output collections 00151 // 00152 // Converted photon candidates 00153 reco::ConversionCollection outputConvPhotonCollection; 00154 std::auto_ptr<reco::ConversionCollection> outputConvPhotonCollection_p(new reco::ConversionCollection); 00155 00156 00157 // Get the Super Cluster collection in the Barrel 00158 bool validBarrelSCHandle=true; 00159 edm::Handle<edm::View<reco::CaloCluster> > scBarrelHandle; 00160 theEvent.getByLabel(scHybridBarrelProducer_,scBarrelHandle); 00161 if (!scBarrelHandle.isValid()) { 00162 edm::LogError("ConvertedPhotonProducer") << "Error! Can't get the product "<<scHybridBarrelProducer_.label(); 00163 validBarrelSCHandle=false; 00164 } 00165 00166 // Get the Super Cluster collection in the Endcap 00167 bool validEndcapSCHandle=true; 00168 edm::Handle<edm::View<reco::CaloCluster> > scEndcapHandle; 00169 theEvent.getByLabel(scIslandEndcapProducer_,scEndcapHandle); 00170 if (!scEndcapHandle.isValid()) { 00171 edm::LogError("ConvertedPhotonProducer") << "Error! Can't get the product "<<scIslandEndcapProducer_.label(); 00172 validEndcapSCHandle=false; 00173 } 00174 00175 00177 bool validTrackInputs=true; 00178 Handle<reco::TrackCollection> outInTrkHandle; 00179 theEvent.getByLabel(conversionOITrackProducer_, outInTrkHandle); 00180 if (!outInTrkHandle.isValid()) { 00181 std::cout << "Error! Can't get the conversionOITrack " << "\n"; 00182 edm::LogError("ConvertedPhotonProducer") << "Error! Can't get the conversionOITrack " << "\n"; 00183 validTrackInputs=false; 00184 } 00185 LogDebug("ConvertedPhotonProducer")<< "ConvertedPhotonProducer outInTrack collection size " << (*outInTrkHandle).size() << "\n"; 00186 00187 00189 Handle<reco::TrackCaloClusterPtrAssociation> outInTrkSCAssocHandle; 00190 theEvent.getByLabel( conversionOITrackProducer_, outInTrackSCAssociationCollection_, outInTrkSCAssocHandle); 00191 if (!outInTrkSCAssocHandle.isValid()) { 00192 std::cout << "Error! Can't get the product " << outInTrackSCAssociationCollection_.c_str() <<"\n"; 00193 edm::LogError("ConvertedPhotonProducer") << "Error! Can't get the product " << outInTrackSCAssociationCollection_.c_str() <<"\n"; 00194 validTrackInputs=false; 00195 } 00196 00198 Handle<reco::TrackCollection> inOutTrkHandle; 00199 theEvent.getByLabel(conversionIOTrackProducer_, inOutTrkHandle); 00200 if (!inOutTrkHandle.isValid()) { 00201 std::cout << "Error! Can't get the conversionIOTrack " << "\n"; 00202 edm::LogError("ConvertedPhotonProducer") << "Error! Can't get the conversionIOTrack " << "\n"; 00203 validTrackInputs=false; 00204 } 00205 LogDebug("ConvertedPhotonProducer") << " ConvertedPhotonProducer inOutTrack collection size " << (*inOutTrkHandle).size() << "\n"; 00206 00207 00209 Handle<reco::TrackCaloClusterPtrAssociation> inOutTrkSCAssocHandle; 00210 theEvent.getByLabel( conversionIOTrackProducer_, inOutTrackSCAssociationCollection_, inOutTrkSCAssocHandle); 00211 if (!inOutTrkSCAssocHandle.isValid()) { 00212 std::cout << "Error! Can't get the product " << inOutTrackSCAssociationCollection_.c_str() <<"\n"; 00213 edm::LogError("ConvertedPhotonProducer") << "Error! Can't get the product " << inOutTrackSCAssociationCollection_.c_str() <<"\n"; 00214 validTrackInputs=false; 00215 } 00216 00217 00218 // Get the basic cluster collection in the Barrel 00219 bool validBarrelBCHandle=true; 00220 edm::Handle<edm::View<reco::CaloCluster> > bcBarrelHandle; 00221 theEvent.getByLabel( bcBarrelCollection_, bcBarrelHandle); 00222 if (!bcBarrelHandle.isValid()) { 00223 edm::LogError("ConvertedPhotonProducer") << "Error! Can't get the product "<<bcBarrelCollection_.label(); 00224 validBarrelBCHandle=false; 00225 } 00226 00227 00228 // Get the basic cluster collection in the Endcap 00229 bool validEndcapBCHandle=true; 00230 edm::Handle<edm::View<reco::CaloCluster> > bcEndcapHandle; 00231 theEvent.getByLabel( bcEndcapCollection_, bcEndcapHandle); 00232 if (!bcEndcapHandle.isValid()) { 00233 edm::LogError("ConvertedPhotonProducer") << "Error! Can't get the product "<<bcEndcapCollection_.label(); 00234 validEndcapBCHandle=true; 00235 } 00236 00237 00238 // Transform Track into TransientTrack (needed by the Vertex fitter) 00239 edm::ESHandle<TransientTrackBuilder> theTransientTrackBuilder; 00240 theEventSetup.get<TransientTrackRecord>().get("TransientTrackBuilder",theTransientTrackBuilder); 00241 00242 00243 if ( validTrackInputs ) { 00244 //do the conversion: 00245 std::vector<reco::TransientTrack> t_outInTrk = ( *theTransientTrackBuilder ).build(outInTrkHandle ); 00246 std::vector<reco::TransientTrack> t_inOutTrk = ( *theTransientTrackBuilder ).build(inOutTrkHandle ); 00247 00248 00250 // std::map<std::vector<reco::TransientTrack>, const reco::SuperCluster*> allPairs; 00251 std::map<std::vector<reco::TransientTrack>, reco::CaloClusterPtr> allPairs; 00252 allPairs = theTrackPairFinder_->run(t_outInTrk, outInTrkHandle, outInTrkSCAssocHandle, t_inOutTrk, inOutTrkHandle, inOutTrkSCAssocHandle ); 00253 LogDebug("ConvertedPhotonProducer") << "ConvertedPhotonProducer allPairs.size " << allPairs.size() << "\n"; 00254 00255 buildCollections(scBarrelHandle, bcBarrelHandle, allPairs, outputConvPhotonCollection); 00256 buildCollections(scEndcapHandle, bcEndcapHandle, allPairs, outputConvPhotonCollection); 00257 } 00258 00259 // put the product in the event 00260 outputConvPhotonCollection_p->assign(outputConvPhotonCollection.begin(),outputConvPhotonCollection.end()); 00261 LogDebug("ConvertedPhotonProducer") << " ConvertedPhotonProducer Putting in the event converted photon candidates " << (*outputConvPhotonCollection_p).size() << "\n"; 00262 theEvent.put( outputConvPhotonCollection_p, ConvertedPhotonCollection_); 00263 00264 00265 00266 00267 }
Definition at line 66 of file ConvertedPhotonProducer.h.
Referenced by ConvertedPhotonProducer(), and produce().
Definition at line 67 of file ConvertedPhotonProducer.h.
Referenced by ConvertedPhotonProducer(), and produce().
std::string ConvertedPhotonProducer::conversionIOTrackProducer_ [private] |
Definition at line 56 of file ConvertedPhotonProducer.h.
Referenced by ConvertedPhotonProducer(), and produce().
std::string ConvertedPhotonProducer::conversionOITrackProducer_ [private] |
Definition at line 55 of file ConvertedPhotonProducer.h.
Referenced by ConvertedPhotonProducer(), and produce().
std::string ConvertedPhotonProducer::ConvertedPhotonCollection_ [private] |
Definition at line 63 of file ConvertedPhotonProducer.h.
Referenced by ConvertedPhotonProducer(), and produce().
std::string ConvertedPhotonProducer::inOutTrackSCAssociationCollection_ [private] |
Definition at line 60 of file ConvertedPhotonProducer.h.
Referenced by ConvertedPhotonProducer(), and produce().
int ConvertedPhotonProducer::nEvt_ [private] |
Definition at line 80 of file ConvertedPhotonProducer.h.
Referenced by ConvertedPhotonProducer(), endJob(), and produce().
std::string ConvertedPhotonProducer::outInTrackSCAssociationCollection_ [private] |
Definition at line 59 of file ConvertedPhotonProducer.h.
Referenced by ConvertedPhotonProducer(), and produce().
Definition at line 68 of file ConvertedPhotonProducer.h.
Referenced by ConvertedPhotonProducer(), and produce().
Definition at line 69 of file ConvertedPhotonProducer.h.
Referenced by ConvertedPhotonProducer(), and produce().
Definition at line 78 of file ConvertedPhotonProducer.h.
Referenced by beginRun(), buildCollections(), ConvertedPhotonProducer(), and endRun().
Definition at line 76 of file ConvertedPhotonProducer.h.
Referenced by ConvertedPhotonProducer(), produce(), and ~ConvertedPhotonProducer().
Definition at line 77 of file ConvertedPhotonProducer.h.
Referenced by buildCollections(), ConvertedPhotonProducer(), and ~ConvertedPhotonProducer().