Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:30:36

0001 // -*- C++ -*-
0002 //
0003 // Package:    InputAnalyzer
0004 // Class:      InputAnalyzer
0005 //
0006 /**\class InputAnalyzer InputAnalyzer.cc Analyzer/InputAnalyzer/src/InputAnalyzer.cc
0007 
0008  Description: Get the data from the source file using getByLabel method.
0009 
0010  Implementation:
0011     
0012 */
0013 //
0014 // Original Author:  Emilia Lubenova Becheva
0015 //         Created:  Mon Apr 20 13:43:06 CEST 2009
0016 //
0017 //
0018 
0019 // system include files
0020 #include <memory>
0021 
0022 // user include files
0023 #include "FWCore/Framework/interface/Frameworkfwd.h"
0024 
0025 #include "FWCore/Framework/interface/Event.h"
0026 #include "FWCore/Framework/interface/MakerMacros.h"
0027 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0028 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0029 
0030 #include "DataFormats/Provenance/interface/ProductID.h"
0031 #include "DataFormats/Common/interface/Handle.h"
0032 
0033 #include "FWCore/Utilities/interface/InputTag.h"
0034 
0035 #include "InputAnalyzer.h"
0036 
0037 //
0038 // constructors and destructor
0039 //
0040 namespace edm {
0041 
0042   InputAnalyzer::InputAnalyzer(const edm::ParameterSet& iConfig) {
0043     dataStep2_ = iConfig.getParameter<bool>("dataStep2");
0044 
0045     labelPCF_ = consumes<PCrossingFrame<SimTrack>>(iConfig.getParameter<edm::InputTag>("collPCF"));
0046 
0047     //will only be needed if not Step2:
0048     labelSimTr_ = consumes<SimTrackContainer>(iConfig.getParameter<edm::InputTag>("collSimTrack"));
0049   }
0050 
0051   InputAnalyzer::~InputAnalyzer() {}
0052 
0053   //
0054   // member functions
0055   //
0056 
0057   // ------------ method called to for each event  ------------
0058   void InputAnalyzer::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) {
0059     edm::LogVerbatim("InputAnalyzer") << " dataStep2_ = " << dataStep2_;
0060 
0061     if (!dataStep2_) {
0062       // Get the SimTrack collection
0063 
0064       // Get the SimTrack collection from the event
0065       edm::Handle<SimTrackContainer> simTracks;
0066       bool gotTracks = iEvent.getByToken(labelSimTr_, simTracks);
0067 
0068       if (!gotTracks) {
0069         edm::LogVerbatim("InputAnalyzer") << "-> Could not read SimTracks !!!!";
0070       } else {
0071         edm::LogVerbatim("InputAnalyzer") << "-> Could read SimTracks !!!!";
0072       }
0073 #ifdef EDM_ML_DEBUG
0074       // Loop over the tracks
0075       double simPt = 0;
0076       int i = 0;
0077 
0078       SimTrackContainer::const_iterator simTrack;
0079       for (simTrack = simTracks->begin(); simTrack != simTracks->end(); ++simTrack) {
0080         i++;
0081 
0082         simPt = (*simTrack).momentum().Pt();
0083         edm::LogVerbatim("InputAnalyzer") << " # i = " << i << " simPt = " << simPt;
0084       }
0085 #endif
0086     } else {
0087       // Get the PCrossingFrame collection given as signal
0088 
0089       edm::Handle<PCrossingFrame<SimTrack>> cf_simtrack;
0090       bool gotTracks = iEvent.getByToken(labelPCF_, cf_simtrack);
0091 
0092       if (!gotTracks) {
0093         edm::LogVerbatim("InputAnalyzer") << "-> Could not read PCrossingFrame<SimTracks> !!!!";
0094       } else
0095         edm::LogVerbatim("InputAnalyzer") << "-> Could read PCrossingFrame<SimTracks> !!!!";
0096     }
0097   }
0098 
0099   // ------------ method called once each job just before starting event loop  ------------
0100   void InputAnalyzer::beginJob() {}
0101 
0102   // ------------ method called once each job just after ending the event loop  ------------
0103   void InputAnalyzer::endJob() {}
0104 
0105 }  // namespace edm