CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 
20 // system include files
21 #include <memory>
22 #include <iostream>
23 
24 #include "TCanvas.h"
25 // user include files
26 #include "__subsys__/__pkgname__/plugins/__class__.h"
29 
30 @example_track #include "DataFormats/TrackReco/interface/Track.h"
31 //
32 // constants shared between the Selector and the Workers
33 //
34 @example_track const char* const kPt = "pt";
35 //const char* const kA = "a";
36 
37 //===============================================
38 //A worker processes the events.
39 // A new worker is created each time the events are processed
40 //===============================================
41 
42 // ------------ constructed for each PROOF Node ------------
43 // The arguments are
44 // fromSelector: these are copies of values set in the selector and sent to all workers
45 // out: these are the items which will be passed back to the selector (e.g. histograms)
46 __class__Worker::__class__Worker(const TList* fromSelector, TList& out ) {
47  //h_a = new TH1F( kA , "a" , 100, 0, 20 );
48  //out.Add(h_a);
49 @example_track h_pt = new TH1F(kPt, "P_t",100,0,100);
50 @example_track out.Add(h_pt);
51 }
52 
54 {
55 }
56 // ------------ method called for each event ------------
57 void
59  using namespace edm;
60 @example_track using reco::TrackCollection;
61 
62 @example_track Handle<TrackCollection> tracks;
63 @example_track iEvent.getByLabel("ctfWithMaterialTracks",tracks);
64 @example_track for(TrackCollection::const_iterator itTrack = tracks->begin();
65 @example_track itTrack != tracks->end();
66 @example_track ++itTrack) {
67 @example_track h_pt->Fill(itTrack->pt());
68 @example_track }
69 
70 // using namespace edmtest;
71 // edm::Handle<ThingCollection> hThings;
72 // iEvent.getByLabel("Thing",hThings);
73 // for ( ThingCollection::const_iterator it = hThings->begin();
74 // it != hThings->end(); ++it ) {
75 // h_a ->Fill( it->a );
76 // }
77 
78 }
79 
80 // ------------ called after processing the events ------------
81 // The argument is the same as for the constructor
82 void
84 {
85 }
86 
87 
88 //===============================================
89 //Only one Selector is made per job. It gets all the results from each worker.
90 //===============================================
92 {
93 }
94 
96 {
97 }
98 
99 // ------------ called just before all workers are constructed ------------
100 void __class__::begin(TList*& toWorkers)
101 {
102 }
103 
104 // ------------ called after all workers have finished ------------
105 // The argument 'fromWorkers' contains the accumulated output of all Workers
106 void __class__::terminate(TList& fromWorkers) {
107  using namespace std;
108  std::auto_ptr<TCanvas> canvas( new TCanvas() );
109 // {
110 // TObject* hist = fromWorkers.FindObject(kA);
111 // if(0!=hist) {
112 // hist->Draw();
113 // canvas->SaveAs( "a.jpg" );
114 // } else {
115 // cout <<"no '"<<kA<<"' histogram"<<endl;
116 // }
117  // }
118 
119 @example_track {
120 @example_track TObject* hist = fromWorkers.FindObject(kPt);
121 @example_track if(0!=hist) {
122 @example_track hist->Draw();
123 @example_track canvas->SaveAs( "pt.jpg" );
124 @example_track } else {
125 @example_track cout <<"no '"<<kPt<<"' histogram"<<endl;
126 @example_track }
127 @example_track }
128 
129 }
void process(const edm::Event &iEvent)
Definition: TSelector.cc:58
example_track example_track const char *const kPt
Definition: TSelector.cc:34
std::vector< Track > TrackCollection
collection of Tracks
Definition: TrackFwd.h:14
example_track TH1F * h_pt
Definition: TSelector.h:31
__class__()
Definition: Skeleton.cc:30
def canvas
Definition: svgfig.py:481
int iEvent
Definition: GenABIO.cc:230
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:420
tuple out
Definition: dbtoconf.py:99
void postProcess(TList &)
Definition: TSelector.cc:83
tuple tracks
Definition: testEve_cfg.py:39
virtual ~__class__()
Definition: EDAnalyzer.cc:89
bool include(const CollT &coll, const ItemT &item)
tuple cout
Definition: gather_cfg.py:121
__class__Worker(const TList *, TList &)
Definition: TSelector.cc:46
void terminate(TList &)
Definition: TSelector.cc:106
void begin(TList *&)
Definition: TSelector.cc:100