CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
edanalyzer.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: anlzrname
4 // Class: anlzrname
5 //
13 //
14 // Original Author: John Doe
15 // Created: day-mon-xx
16 // RCS(Id)
17 //
18 //
19 
20 
21 // system include files
22 #include <memory>
23 
24 // user include files
27 
30 
32 @example_track #include "FWCore/Utilities/interface/InputTag.h"
33 @example_track #include "DataFormats/TrackReco/interface/Track.h"
34 @example_track #include "DataFormats/TrackReco/interface/TrackFwd.h"
35 @example_histo #include "FWCore/ServiceRegistry/interface/Service.h"
36 @example_histo #include "CommonTools/UtilAlgos/interface/TFileService.h"
37 @example_histo #include "TH1.h"
38 //
39 // class declaration
40 //
41 
42 class anlzrname : public edm::EDAnalyzer {
43  public:
44  explicit anlzrname(const edm::ParameterSet&);
45  ~anlzrname();
46 
47  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
48 
49 
50  private:
51  virtual void beginJob() ;
52  virtual void analyze(const edm::Event&, const edm::EventSetup&);
53  virtual void endJob() ;
54 
55  virtual void beginRun(edm::Run const&, edm::EventSetup const&);
56  virtual void endRun(edm::Run const&, edm::EventSetup const&);
57  virtual void beginLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&);
58  virtual void endLuminosityBlock(edm::LuminosityBlock const&, edm::EventSetup const&);
59 
60  // ----------member data ---------------------------
61 @example_track edm::InputTag trackTags_; //used to select what tracks to read from configuration file
62 @example_histo TH1D * histo;
63 };
64 
65 //
66 // constants, enums and typedefs
67 //
68 
69 //
70 // static data member definitions
71 //
72 
73 //
74 // constructors and destructor
75 //
77 @example_track :
78 @example_track trackTags_(iConfig.getUntrackedParameter<edm::InputTag>("tracks"))
79 
80 {
81  //now do what ever initialization is needed
82 @example_histo edm::Service<TFileService> fs;
83 @example_histo histo = fs->make<TH1D>("charge" , "Charges" , 200 , -2 , 2 );
84 
85 }
86 
87 
89 {
90 
91  // do anything here that needs to be done at desctruction time
92  // (e.g. close files, deallocate resources etc.)
93 
94 }
95 
96 
97 //
98 // member functions
99 //
100 
101 // ------------ method called for each event ------------
102 void
104 {
105  using namespace edm;
106 
107 @example_track using reco::TrackCollection;
108 
109 @example_track Handle<TrackCollection> tracks;
110 @example_track iEvent.getByLabel(trackTags_,tracks);
111 @example_track for(TrackCollection::const_iterator itTrack = tracks->begin();
112 @example_track itTrack != tracks->end();
113 @example_track ++itTrack) {
114 @example_track_histo int charge = 0;
115 @example_track charge = itTrack->charge();
116 @example_histo histo->Fill( charge );
117 @example_track }
118 
119 #ifdef THIS_IS_AN_EVENT_EXAMPLE
121  iEvent.getByLabel("example",pIn);
122 #endif
123 
124 #ifdef THIS_IS_AN_EVENTSETUP_EXAMPLE
125  ESHandle<SetupData> pSetup;
126  iSetup.get<SetupRecord>().get(pSetup);
127 #endif
128 }
129 
130 
131 // ------------ method called once each job just before starting event loop ------------
132 void
134 {
135 }
136 
137 // ------------ method called once each job just after ending the event loop ------------
138 void
140 {
141 }
142 
143 // ------------ method called when starting to processes a run ------------
144 void
146 {
147 }
148 
149 // ------------ method called when ending the processing of a run ------------
150 void
152 {
153 }
154 
155 // ------------ method called when starting to processes a luminosity block ------------
156 void
158 {
159 }
160 
161 // ------------ method called when ending the processing of a luminosity block ------------
162 void
164 {
165 }
166 
167 // ------------ method fills 'descriptions' with the allowed parameters for the module ------------
168 void
170  //The following says we do not know what parameters are allowed so do no validation
171  // Please change this to state exactly what you do use, even if it is no parameters
173  desc.setUnknown();
174  descriptions.addDefault(desc);
175 @example_track
176 @example_track //Specify that only 'tracks' is allowed
177 @example_track //To use, remove the default given above and uncomment below
178 @example_track //ParameterSetDescription desc;
179 @example_track //desc.addUntracked<edm::InputTag>("tracks","ctfWithMaterialTracks");
180 @example_track //descriptions.addDefault(desc);
181 }
182 
183 //define this as a plug-in
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
virtual void analyze(const edm::Event &, const edm::EventSetup &)
Definition: edanalyzer.cc:103
virtual void endRun(edm::Run const &, edm::EventSetup const &)
Definition: edanalyzer.cc:151
std::vector< Track > TrackCollection
collection of Tracks
Definition: TrackFwd.h:10
tuple histo
Definition: trackerHits.py:12
double charge(const std::vector< uint8_t > &Ampls)
example_track edm::InputTag trackTags_
Definition: edanalyzer.cc:61
virtual void endLuminosityBlock(edm::LuminosityBlock const &, edm::EventSetup const &)
Definition: edanalyzer.cc:163
int iEvent
Definition: GenABIO.cc:243
void addDefault(ParameterSetDescription const &psetDescription)
virtual void beginRun(edm::Run const &, edm::EventSetup const &)
Definition: edanalyzer.cc:145
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:355
tuple tracks
Definition: testEve_cfg.py:39
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Definition: edanalyzer.cc:169
const T & get() const
Definition: EventSetup.h:55
virtual void beginJob()
Definition: edanalyzer.cc:133
bool include(const CollT &coll, const ItemT &item)
virtual void beginLuminosityBlock(edm::LuminosityBlock const &, edm::EventSetup const &)
Definition: edanalyzer.cc:157
example_histo TH1D * histo
Definition: edanalyzer.cc:62
virtual void endJob()
Definition: edanalyzer.cc:139
Definition: Run.h:32
anlzrname(const edm::ParameterSet &)
Definition: edanalyzer.cc:76