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