CMS 3D CMS Logo

edanalyzer.cc

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 //
00003 // Package:    anlzrname
00004 // Class:      anlzrname
00005 // 
00013 //
00014 // Original Author:  John Doe
00015 //         Created:  day-mon-xx
00016 // RCS(Id)
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 @example_track #include "FWCore/Utilities/interface/InputTag.h"
00033 @example_track #include "DataFormats/TrackReco/interface/Track.h"
00034 @example_track #include "DataFormats/TrackReco/interface/TrackFwd.h"
00035 @example_histo #include "FWCore/ServiceRegistry/interface/Service.h"
00036 @example_histo #include "PhysicsTools/UtilAlgos/interface/TFileService.h"
00037 @example_histo #include "TH1.h"
00038 //
00039 // class decleration
00040 //
00041 
00042 class anlzrname : public edm::EDAnalyzer {
00043    public:
00044       explicit anlzrname(const edm::ParameterSet&);
00045       ~anlzrname();
00046 
00047 
00048    private:
00049       virtual void beginJob(const edm::EventSetup&) ;
00050       virtual void analyze(const edm::Event&, const edm::EventSetup&);
00051       virtual void endJob() ;
00052 
00053       // ----------member data ---------------------------
00054 @example_track       edm::InputTag trackTags_; //used to select what tracks to read from configuration file
00055 @example_histo       TH1D * histo; 
00056 };
00057 
00058 //
00059 // constants, enums and typedefs
00060 //
00061 
00062 //
00063 // static data member definitions
00064 //
00065 
00066 //
00067 // constructors and destructor
00068 //
00069 anlzrname::anlzrname(const edm::ParameterSet& iConfig)
00070 @example_track :
00071 @example_track  trackTags_(iConfig.getUntrackedParameter<edm::InputTag>("tracks"))
00072 
00073 {
00074    //now do what ever initialization is needed
00075 @example_histo   edm::Service<TFileService> fs;
00076 @example_histo   histo = fs->make<TH1D>("charge" , "Charges" , 200 , -2 , 2 );
00077 
00078 }
00079 
00080 
00081 anlzrname::~anlzrname()
00082 {
00083  
00084    // do anything here that needs to be done at desctruction time
00085    // (e.g. close files, deallocate resources etc.)
00086 
00087 }
00088 
00089 
00090 //
00091 // member functions
00092 //
00093 
00094 // ------------ method called to for each event  ------------
00095 void
00096 anlzrname::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup)
00097 {
00098    using namespace edm;
00099 
00100 @example_track   using reco::TrackCollection;
00101 
00102 @example_track    Handle<TrackCollection> tracks;
00103 @example_track    iEvent.getByLabel(trackTags_,tracks);
00104 @example_track    for(TrackCollection::const_iterator itTrack = tracks->begin();
00105 @example_track        itTrack != tracks->end();                      
00106 @example_track        ++itTrack) {
00107 @example_track_histo       int charge = 0;
00108 @example_track       charge = itTrack->charge();  
00109 @example_histo       histo->Fill( charge );
00110 @example_track    }
00111 
00112 #ifdef THIS_IS_AN_EVENT_EXAMPLE
00113    Handle<ExampleData> pIn;
00114    iEvent.getByLabel("example",pIn);
00115 #endif
00116    
00117 #ifdef THIS_IS_AN_EVENTSETUP_EXAMPLE
00118    ESHandle<SetupData> pSetup;
00119    iSetup.get<SetupRecord>().get(pSetup);
00120 #endif
00121 }
00122 
00123 
00124 // ------------ method called once each job just before starting event loop  ------------
00125 void 
00126 anlzrname::beginJob(const edm::EventSetup&)
00127 {
00128 }
00129 
00130 // ------------ method called once each job just after ending the event loop  ------------
00131 void 
00132 anlzrname::endJob() {
00133 }
00134 
00135 //define this as a plug-in
00136 DEFINE_FWK_MODULE(anlzrname);

Generated on Tue Jun 9 17:36:40 2009 for CMSSW by  doxygen 1.5.4