CMS 3D CMS Logo

TSelector.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: __subsys__/__pkgname__
4 // Class: __class__
5 //
6 /*
7 
8  Description: [one line class summary]
9 
10  Implementation:
11  [Notes on implementation]
12 */
13 //
14 // Original Author: __author__
15 // Created: __date__
16 //
17 //
18 
19 // system include files
20 #include <memory>
21 #include <iostream>
22 
23 #include "TCanvas.h"
24 // user include files
25 #include "__subsys__/__pkgname__/plugins/__class__.h"
28 
29 @example_track#include "DataFormats/TrackReco/interface/Track.h"
30 //
31 // constants shared between the Selector and the Workers
32 //
33 @example_trackconst char* const kPt = "pt";
34 //const char* const kA = "a";
35 
36 //===============================================
37 //A worker processes the events.
38 // A new worker is created each time the events are processed
39 //===============================================
40 
41 // ------------ constructed for each PROOF Node ------------
42 // The arguments are
43 // fromSelector: these are copies of values set in the selector and sent to all workers
44 // out: these are the items which will be passed back to the selector (e.g. histograms)
45 __class__Worker::__class__Worker(const TList* fromSelector, TList& out) {
46  //h_a = new TH1F( kA , "a" , 100, 0, 20 );
47  //out.Add(h_a);
48 @example_track h_pt = new TH1F(kPt, "P_t", 100, 0, 100);
49 @example_track out.Add(h_pt);
50 }
51 
53 }
54 // ------------ method called for each event ------------
56  using namespace edm;
57 @example_track using reco::TrackCollection;
58 @example_track
59 @example_track Handle<TrackCollection> tracks;
60 @example_track iEvent.getByLabel("ctfWithMaterialTracks", tracks);
61 @example_track for (const auto& track : *tracks) {
62 @example_track h_pt->Fill(itTrack->pt());
63 @example_track }
64 
65  //using namespace edmtest;
66  //edm::Handle<ThingCollection> hThings;
67  //iEvent.getByLabel("Thing", hThings);
68  //for (const auto& thing : *hThings) {
69  // h_a ->Fill(it->a);
70  //}
71 }
72 
73 // ------------ called after processing the events ------------
74 // The argument is the same as for the constructor
76 }
77 
78 //===============================================
79 //Only one Selector is made per job. It gets all the results from each worker.
80 //===============================================
82 }
83 
85 }
86 
87 // ------------ called just before all workers are constructed ------------
88 void __class__::begin(TList*& toWorkers) {
89 }
90 
91 // ------------ called after all workers have finished ------------
92 // The argument 'fromWorkers' contains the accumulated output of all Workers
93 void __class__::terminate(TList& fromWorkers) {
94  using namespace std;
95  auto canvas = std::make_unique<TCanvas>();
96  //{
97  // TObject* hist = fromWorkers.FindObject(kA);
98  // if (nullptr != hist) {
99  // hist->Draw();
100  // canvas->SaveAs("a.jpg");
101  // } else {
102  // cout << "no '" << kA << "' histogram" << endl;
103  // }
104  //
105 @example_track
106 @example_track {
107 @example_track TObject* hist = fromWorkers.FindObject(kPt);
108 @example_track if (nullptr != hist) {
109 @example_track hist->Draw();
110 @example_track canvas->SaveAs("pt.jpg");
111 @example_track } else {
112 @example_track cout << "no '" << kPt << "' histogram" << endl;
113 @example_track }
114 @example_track }
115 }
kPt
example_track example_trackconst char *const kPt
Definition: TSelector.cc:33
svgfig.canvas
def canvas(*sub, **attr)
Definition: svgfig.py:482
Handle.h
__class__::__class__
__class__()
Definition: Skeleton.cc:29
HLT_FULL_cff.track
track
Definition: HLT_FULL_cff.py:11713
edm
HLT enums.
Definition: AlignableModifier.h:19
gather_cfg.cout
cout
Definition: gather_cfg.py:144
__class__::terminate
void terminate(TList &)
Definition: TSelector.cc:93
edm::Handle
Definition: AssociativeIterator.h:50
__class__::begin
void begin(TList *&)
Definition: TSelector.cc:88
__class__Worker::postProcess
void postProcess(TList &)
Definition: TSelector.cc:75
Event.h
tracks
const uint32_t *__restrict__ const HitContainer *__restrict__ TkSoA *__restrict__ tracks
Definition: CAHitNtupletGeneratorKernelsImpl.h:159
gpuVertexFinder::hist
__shared__ Hist hist
Definition: gpuClusterTracksDBSCAN.h:48
iEvent
int iEvent
Definition: GenABIO.cc:224
__class__Worker::~__class__Worker
~__class__Worker()
Definition: TSelector.cc:52
__class__::~__class__
virtual ~__class__()
Definition: DQMEDAnalyzer.cc:85
std
Definition: JetResolutionObject.h:76
__class__Worker::__class__Worker
__class__Worker(const TList *, TList &)
Definition: TSelector.cc:45
include
bool include(const CollT &coll, const ItemT &item)
Definition: EcalDetIdToBeRecoveredProducer.cc:71
MillePedeFileConverter_cfg.out
out
Definition: MillePedeFileConverter_cfg.py:31
__class__Worker::h_pt
example_track TH1F * h_pt
Definition: TSelector.h:31
edm::Event
Definition: Event.h:73
__class__Worker::process
void process(const edm::Event &iEvent)
Definition: TSelector.cc:55
reco::TrackCollection
std::vector< Track > TrackCollection
collection of Tracks
Definition: TrackFwd.h:14