Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2022-01-02 23:15:08

0001 #include "DataFormats/Common/interface/Handle.h"
0002 #include "FWCore/Framework/interface/Event.h"
0003 #include "FWCore/Framework/interface/EventSetup.h"
0004 #include "FWCore/Framework/interface/MakerMacros.h"
0005 #include "FWCore/PluginManager/interface/ModuleDef.h"
0006 #include "SimGeneral/TrackingAnalysis/test/TrackingTruthOutputTest.h"
0007 
0008 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0009 
0010 #include "SimDataFormats/CrossingFrame/interface/CrossingFrame.h"
0011 #include "SimDataFormats/CrossingFrame/interface/MixCollection.h"
0012 #include "SimDataFormats/TrackingAnalysis/interface/TrackingParticle.h"
0013 #include "SimDataFormats/TrackingAnalysis/interface/TrackingVertexContainer.h"
0014 
0015 #include "SimDataFormats/GeneratorProducts/interface/HepMCProduct.h"
0016 
0017 typedef edm::RefVector<std::vector<TrackingParticle>> TrackingParticleContainer;
0018 typedef std::vector<TrackingParticle> TrackingParticleCollection;
0019 
0020 typedef TrackingParticleRefVector::iterator tp_iterator;
0021 typedef TrackingVertex::genv_iterator genv_iterator;
0022 typedef TrackingVertex::g4v_iterator g4v_iterator;
0023 
0024 TrackingTruthOutputTest::TrackingTruthOutputTest(const edm::ParameterSet &conf) { conf_ = conf; }
0025 
0026 void TrackingTruthOutputTest::analyze(const edm::Event &event, const edm::EventSetup &c) {
0027   using namespace std;
0028 
0029   edm::Handle<TrackingParticleCollection> mergedPH;
0030   edm::Handle<TrackingVertexCollection> mergedVH;
0031 
0032   edm::InputTag trackingTruth = conf_.getUntrackedParameter<edm::InputTag>("trackingTruth");
0033 
0034   event.getByLabel(trackingTruth, mergedPH);
0035   event.getByLabel(trackingTruth, mergedVH);
0036 
0037   if (conf_.getUntrackedParameter<bool>("dumpVertexes")) {
0038     std::cout << std::endl << "Dumping merged vertices: " << std::endl;
0039     for (TrackingVertexCollection::const_iterator iVertex = mergedVH->begin(); iVertex != mergedVH->end(); ++iVertex) {
0040       std::cout << std::endl << *iVertex;
0041       std::cout << "Daughters of this vertex:" << std::endl;
0042       for (tp_iterator iTrack = iVertex->daughterTracks_begin(); iTrack != iVertex->daughterTracks_end(); ++iTrack)
0043         std::cout << **iTrack;
0044     }
0045     std::cout << std::endl;
0046   }
0047 
0048   if (conf_.getUntrackedParameter<bool>("dumpOnlyBremsstrahlung")) {
0049     std::cout << std::endl << "Dumping only merged tracks: " << std::endl;
0050     for (TrackingParticleCollection::const_iterator iTrack = mergedPH->begin(); iTrack != mergedPH->end(); ++iTrack)
0051       if (iTrack->g4Tracks().size() > 1)
0052         std::cout << *iTrack << std::endl;
0053   } else {
0054     std::cout << std::endl << "Dump of merged tracks: " << std::endl;
0055     for (TrackingParticleCollection::const_iterator iTrack = mergedPH->begin(); iTrack != mergedPH->end(); ++iTrack)
0056       std::cout << *iTrack << std::endl;
0057   }
0058 }
0059 
0060 DEFINE_FWK_MODULE(TrackingTruthOutputTest);