ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/auterman/Demo/JetID/src/JetID.cc
Revision: 1.1.1.1 (vendor branch)
Committed: Mon Apr 14 12:45:47 2008 UTC (17 years ago) by auterman
Content type: text/plain
Branch: tex, JetID, MAIN
Changes since 1.1: +0 -0 lines
Log Message:
A JetID skeleton

File Contents

# User Rev Content
1 auterman 1.1 // -*- C++ -*-
2     //
3     // Package: JetID
4     // Class: JetID
5     //
6     /**\class JetID JetID.cc Demo/JetID/src/JetID.cc
7    
8     Description: <one line class summary>
9    
10     Implementation:
11     <Notes on implementation>
12     */
13     //
14     // Original Author: Christian AUTERMANN
15     // Created: Mon Apr 14 11:37:04 CEST 2008
16     // $Id$
17     //
18     //
19    
20    
21     // system include files
22     #include <memory>
23    
24     // user include files
25     #include "FWCore/Framework/interface/Frameworkfwd.h"
26     #include "FWCore/Framework/interface/EDProducer.h"
27    
28     #include "FWCore/Framework/interface/Event.h"
29     #include "FWCore/Framework/interface/MakerMacros.h"
30    
31     #include "FWCore/ParameterSet/interface/ParameterSet.h"
32     #include "DataFormats/Common/interface/ValueMap.h"
33     #include "DataFormats/JetReco/interface/CaloJet.h"
34     //
35     // class decleration
36     //
37    
38     class JetID : public edm::EDProducer {
39     public:
40     explicit JetID(const edm::ParameterSet&);
41     ~JetID();
42    
43     typedef edm::ValueMap<double> JetIDMap;
44    
45     private:
46     virtual void beginJob(const edm::EventSetup&) ;
47     virtual void produce(edm::Event&, const edm::EventSetup&);
48     virtual void endJob() ;
49    
50     // ----------member data ---------------------------
51     edm::InputTag _Jets;
52     };
53    
54     //
55     // constants, enums and typedefs
56     //
57    
58     //
59     // static data member definitions
60     //
61    
62     //
63     // constructors and destructor
64     //
65     JetID::JetID(const edm::ParameterSet& iConfig) :
66     _Jets( iConfig.getParameter<edm::InputTag>( "Jets" ) )
67     {
68     //register your products
69     produces<JetIDMap>();
70     }
71    
72    
73     JetID::~JetID()
74     {
75    
76     // do anything here that needs to be done at desctruction time
77     // (e.g. close files, deallocate resources etc.)
78    
79     }
80    
81    
82     //
83     // member functions
84     //
85    
86     // ------------ method called to produce the data ------------
87     void
88     JetID::produce(edm::Event& iEvent, const edm::EventSetup& iSetup)
89     {
90     using namespace edm;
91     using namespace reco;
92    
93     //Jets
94     Handle<edm::View<CaloJet> > pJets;
95     iEvent.getByLabel(_Jets,pJets);
96    
97     //create map passing the handle to the matched collection
98     std::auto_ptr<JetIDMap> jetID(new JetIDMap);
99     JetIDMap::Filler filler(*jetID);
100     {
101     size_t n = pJets->size();
102     std::vector<double> id(n);
103     for(size_t i = 0; i != n; ++i) {
104     id[i] = (double)i; //"ID" is exemplarily no of the jet
105     }
106     filler.insert(pJets, id.begin(), id.end());
107     }
108     // really fill the association map
109     filler.fill();
110     // put into the event
111     iEvent.put(jetID);
112     }
113    
114     // ------------ method called once each job just before starting event loop ------------
115     void
116     JetID::beginJob(const edm::EventSetup&)
117     {
118     }
119    
120     // ------------ method called once each job just after ending the event loop ------------
121     void
122     JetID::endJob() {
123     }
124    
125     //define this as a plug-in
126     DEFINE_FWK_MODULE(JetID);