1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
|
// -*- C++ -*-
//
// Package: __subsys__/__pkgname__
// Class: __class__
//
/**\class __class__ __class__.cc __subsys__/__pkgname__/plugins/__class__.cc
Description: [one line class summary]
Implementation:
[Notes on implementation]
*/
//
// Original Author: __author__
// Created: __date__
//
//
// system include files
#include <memory>
// user include files
#include "FWCore/Framework/interface/Frameworkfwd.h"
#include "FWCore/Framework/interface/one/EDAnalyzer.h"
#include "FWCore/Framework/interface/Event.h"
#include "FWCore/Framework/interface/MakerMacros.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "FWCore/Utilities/interface/InputTag.h"
#include "DataFormats/TrackReco/interface/Track.h"
#include "DataFormats/TrackReco/interface/TrackFwd.h"
@example_histo#include "FWCore/ServiceRegistry/interface/Service.h"
@example_histo#include "CommonTools/UtilAlgos/interface/TFileService.h"
@example_histo#include "TH1.h"
//
// class declaration
//
// If the analyzer does not use TFileService, please remove
// the template argument to the base class so the class inherits
// from edm::one::EDAnalyzer<>
// This will improve performance in multithreaded jobs.
using reco::TrackCollection;
class __class__ : public edm::one::EDAnalyzer<edm::one::SharedResources> {
public:
explicit __class__(const edm::ParameterSet&);
~__class__() override;
static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
private:
void beginJob() override;
void analyze(const edm::Event&, const edm::EventSetup&) override;
void endJob() override;
// ----------member data ---------------------------
edm::EDGetTokenT<TrackCollection> tracksToken_; //used to select what tracks to read from configuration file
#ifdef THIS_IS_AN_EVENTSETUP_EXAMPLE
edm::ESGetToken<SetupData, SetupRecord> setupToken_;
#endif
@example_histo TH1I* histo;
};
//
// constants, enums and typedefs
//
//
// static data member definitions
//
//
// constructors and destructor
//
__class__::__class__(const edm::ParameterSet& iConfig)
: tracksToken_(consumes<TrackCollection>(iConfig.getUntrackedParameter<edm::InputTag>("tracks"))) {
#ifdef THIS_IS_AN_EVENTSETUP_EXAMPLE
setupDataToken_ = esConsumes<SetupData, SetupRecord>();
#endif
//now do what ever initialization is needed
@example_histo usesResource("TFileService");
@example_histo edm::Service<TFileService> fs;
@example_histo histo = fs->make<TH1I>("charge", "Charges", 2, -1, 1);
}
__class__::~__class__() {
// do anything here that needs to be done at desctruction time
// (e.g. close files, deallocate resources etc.)
//
// please remove this method altogether if it would be left empty
}
//
// member functions
//
// ------------ method called for each event ------------
void __class__::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup) {
using namespace edm;
for (const auto& track : iEvent.get(tracksToken_)) {
// do something with track parameters, e.g, plot the charge.
// int charge = track.charge();
@example_histo histo->Fill(track.charge());
}
#ifdef THIS_IS_AN_EVENTSETUP_EXAMPLE
// if the SetupData is always needed
auto setup = iSetup.getData(setupToken_);
// if need the ESHandle to check if the SetupData was there or not
auto pSetup = iSetup.getHandle(setupToken_);
#endif
}
// ------------ method called once each job just before starting event loop ------------
void __class__::beginJob() {
// please remove this method if not needed
}
// ------------ method called once each job just after ending the event loop ------------
void __class__::endJob() {
// please remove this method if not needed
}
// ------------ method fills 'descriptions' with the allowed parameters for the module ------------
void __class__::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
//The following says we do not know what parameters are allowed so do no validation
// Please change this to state exactly what you do use, even if it is no parameters
edm::ParameterSetDescription desc;
desc.setUnknown();
descriptions.addDefault(desc);
//Specify that only 'tracks' is allowed
//To use, remove the default given above and uncomment below
//edm::ParameterSetDescription desc;
//desc.addUntracked<edm::InputTag>("tracks", edm::InputTag("ctfWithMaterialTracks"));
//descriptions.addWithDefaultLabel(desc);
}
//define this as a plug-in
DEFINE_FWK_MODULE(__class__);
|