test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
TrackAnalysisAlgorithm.cc
Go to the documentation of this file.
6 #include <TCanvas.h>
7 #include <TList.h>
8 #include <TH1.h>
9 #include <iostream>
10 using namespace examples;
11 using namespace std;
12 using namespace edm;
13 using namespace reco;
14 
15 const char * TrackAnalysisAlgorithm::kPt = "pt";
16 const char * TrackAnalysisAlgorithm::kEta = "eta";
17 
19  cout << ">> booking histograms" << endl;
20  out.Add( h_pt = new TH1F( kPt , "pt" , 100, 0, 20 ) );
21  out.Add( h_eta = new TH1F( kEta, "#eta", 100, -3, 3 ) );
22 }
23 
25  cout << ">> processing event " << endl;
27  event.getByLabel( "ctfWithMaterialTracks", tracks );
28 
29  cout << ">> tracks found:" << tracks->size() << endl;
30  for ( size_t i = 0; i < tracks->size(); ++i ) {
31  const Track & track = ( * tracks )[ i ];
32  h_pt ->Fill( track.pt() );
33  h_eta->Fill( track.eta() );
34  cout << ">> pt, eta: " << track.pt() << ", " << track.eta() << endl;
35  }
36 }
37 
39  cout << ">> nothing to be done in post-processing" << endl;
40 }
41 
43  cout << ">> terminating" << endl;
44  TCanvas canvas;
45  draw( out, canvas, kPt );
46  draw( out, canvas, kEta );
47 }
48 
49 void TrackAnalysisAlgorithm::draw( const TList & out, TCanvas & canvas, const char * k ) {
50  TObject * hist = out.FindObject( k );
51  if( 0 != hist ) {
52  hist->Draw();
53  canvas.SaveAs( ( string( k ) + ".jpg" ).c_str() );
54  } else {
55  cerr <<">> no '" << k << "' histogram" << endl;
56  }
57 }
int i
Definition: DBlmapReader.cc:9
example_track example_track const char *const kPt
Definition: TSelector.cc:34
def canvas
Definition: svgfig.py:481
double eta() const
pseudorapidity of momentum vector
Definition: TrackBase.h:646
void process(const edm::Event &)
process one event
static void draw(const TList &, TCanvas &, const char *)
draw an histogram
double pt() const
track transverse momentum
Definition: TrackBase.h:616
static void terminate(TList &)
terminate processing
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger but the state exists so we define the behavior If all triggers are the negative crieriion will lead to accepting the event(this again matches the behavior of"!*"before the partial wildcard feature was incorporated).The per-event"cost"of each negative criterion with multiple relevant triggers is about the same as!*was in the past
static const char * kPt
histogram names
tuple tracks
Definition: testEve_cfg.py:39
TrackAnalysisAlgorithm(const TList *, TList &)
constructor
void postProcess(TList &)
post process
tuple cout
Definition: gather_cfg.py:145