File indexing completed on 2024-04-06 12:13:09
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020 #include <memory>
0021 #include <iostream>
0022
0023 #include "TCanvas.h"
0024
0025 #include "__subsys__/__pkgname__/interface/__class__.h"
0026 #include "DataFormats/Common/interface/Handle.h"
0027 #include "FWCore/Framework/interface/Event.h"
0028
0029 @example_track#include "DataFormats/TrackReco/interface/Track.h"
0030 @example_track#include "DataFormats/TrackReco/interface/TrackFwd.h"
0031
0032
0033
0034 @example_trackconst char* const kPt = "pt";
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045
0046 __class__Worker::__class__Worker(const TList* fromSelector, TList& out) {
0047
0048
0049 @example_track h_pt = new TH1F(kPt, "P_t", 100, 0, 100);
0050 @example_track out.Add(h_pt);
0051 }
0052
0053 __class__Worker::~__class__Worker() {}
0054
0055
0056 void __class__Worker::process(const edm::Event& iEvent) {
0057 using namespace edm;
0058 @example_track using reco::TrackCollection;
0059 @example_track
0060 @example_track Handle<TrackCollection> tracks;
0061 @example_track iEvent.getByLabel("ctfWithMaterialTracks", tracks);
0062 @example_track for (const auto& track : *tracks) {
0063 @example_track h_pt->Fill(track.pt());
0064 @example_track }
0065
0066
0067
0068
0069
0070
0071
0072 }
0073
0074
0075
0076 void __class__Worker::postProcess(TList& out) {}
0077
0078
0079
0080
0081 __class__::__class__() {}
0082
0083 __class__::~__class__() {}
0084
0085
0086 void __class__::begin(TList*& toWorkers) {}
0087
0088
0089
0090 void __class__::terminate(TList& fromWorkers) {
0091 using namespace std;
0092 auto canvas = std::make_unique<TCanvas>();
0093
0094
0095
0096
0097
0098
0099
0100
0101
0102 @example_track
0103 @example_track {
0104 @example_track TObject* hist = fromWorkers.FindObject(kPt);
0105 @example_track if (nullptr != hist) {
0106 @example_track hist->Draw();
0107 @example_track canvas->SaveAs("pt.jpg");
0108 @example_track } else {
0109 @example_track cout << "no '" << kPt << "' histogram" << endl;
0110 @example_track }
0111 @example_track }
0112 }