CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_4_5_patch3/src/SimGeneral/MixingModule/plugins/InputAnalyzer.cc

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 //
00003 // Package:    InputAnalyzer
00004 // Class:      InputAnalyzer
00005 // 
00013 //
00014 // Original Author:  Emilia Lubenova Becheva
00015 //         Created:  Mon Apr 20 13:43:06 CEST 2009
00016 // $Id: InputAnalyzer.cc,v 1.3 2011/11/15 21:57:47 gowdy Exp $
00017 //
00018 //
00019 
00020 
00021 // system include files
00022 #include <memory>
00023 
00024 // user include files
00025 #include "FWCore/Framework/interface/Frameworkfwd.h"
00026 #include "FWCore/Framework/interface/EDAnalyzer.h"
00027 
00028 #include "FWCore/Framework/interface/Event.h"
00029 #include "FWCore/Framework/interface/MakerMacros.h"
00030 
00031 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00032 
00033 
00034 #include "DataFormats/Provenance/interface/ProductID.h"
00035 #include "DataFormats/Common/interface/Handle.h"
00036 
00037 #include "FWCore/Utilities/interface/InputTag.h"
00038 
00039 #include "InputAnalyzer.h"
00040 
00041 #include "SimDataFormats/Track/interface/SimTrackContainer.h"
00042 #include "SimDataFormats/CrossingFrame/interface/PCrossingFrame.h"
00043 
00044 //
00045 // constructors and destructor
00046 //
00047 namespace edm
00048 {
00049 
00050 InputAnalyzer::InputAnalyzer(const edm::ParameterSet& iConfig)
00051 {
00052 
00053  dataStep2_ = iConfig.getParameter<bool>("dataStep2");
00054  
00055  if (dataStep2_)
00056    // The data file contain the PCrossingFrame<SimTrack> 
00057    label_   = iConfig.getParameter<edm::InputTag>("collPCF");
00058  else 
00059    // The data file contain the SimTrack
00060    label_   = iConfig.getParameter<edm::InputTag>("collSimTrack");
00061 }
00062 
00063 
00064 InputAnalyzer::~InputAnalyzer()
00065 {
00066 }
00067 
00068 
00069 //
00070 // member functions
00071 //
00072 
00073 // ------------ method called to for each event  ------------
00074 void
00075 InputAnalyzer::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup)
00076 {
00077   std::cout << " dataStep2_ = " << dataStep2_ << std::endl;
00078   
00079   if (!dataStep2_){
00080   // Get the SimTrack collection
00081   
00082     //double simPt=0;
00083    int i=0;
00084    
00085    // Get the SimTrack collection from the event
00086    edm::Handle<SimTrackContainer> simTracks;
00087    bool gotTracks = iEvent.getByLabel(label_,simTracks);
00088    
00089    if (!gotTracks)
00090    {  
00091       std::cout<<"-> Could not read SimTracks !!!!"<<std::endl;
00092    }
00093    else{
00094       std::cout<<"-> Could read SimTracks !!!!"<<std::endl;
00095       
00096    }
00097 
00098   
00099    // Loop over the tracks
00100    SimTrackContainer::const_iterator simTrack;
00101    for (simTrack = simTracks->begin(); simTrack != simTracks->end(); ++simTrack){
00102     i++;
00103     
00104     //simPt=(*simTrack).momentum().Pt();
00105     //std::cout << " # i = " << i << " simPt = " << simPt << std::endl;
00106    
00107    }
00108    
00109    
00110  }
00111  else{
00112  // Get the PCrossingFrame collection given as signal
00113    
00114     edm::Handle<PCrossingFrame<SimTrack> > cf_simtrack;
00115     bool gotTracks = iEvent.getByLabel("CFWriter","g4SimHits",cf_simtrack);
00116     
00117     if (!gotTracks)
00118     {  
00119       std::cout<<"-> Could not read PCrossingFrame<SimTracks> !!!!"<<std::endl;
00120     }
00121     else
00122       std::cout<<"-> Could read PCrossingFrame<SimTracks> !!!!"<<std::endl;
00123       
00124    }
00125 }
00126 
00127 
00128 // ------------ method called once each job just before starting event loop  ------------
00129 void InputAnalyzer::beginJob()
00130 {
00131 }
00132 
00133 // ------------ method called once each job just after ending the event loop  ------------
00134 void 
00135 InputAnalyzer::endJob() {
00136 }
00137 
00138 }//edm