ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/LJMet/Utils/src/PlotReco.cc
(Generate patch)

Comparing UserCode/LJMet/Utils/src/PlotReco.cc (file contents):
Revision 1.1 by kukartse, Tue Nov 10 22:29:35 2009 UTC vs.
Revision 1.3 by kukartse, Sun Dec 6 21:06:12 2009 UTC

# Line 28 | Line 28
28   #include "DataFormats/BeamSpot/interface/BeamSpot.h"
29   #include "DataFormats/EgammaCandidates/interface/GsfElectron.h"
30   #include "DataFormats/Math/interface/deltaR.h"
31 + #include "FWCore/ServiceRegistry/interface/Service.h"
32 + #include "PhysicsTools/UtilAlgos/interface/TFileService.h"
33  
34   using namespace edm;
35  
36   PlotReco::PlotReco(const edm::ParameterSet& iConfig){
37    std::cout << "=======>: PlotReco::PlotReco()" << std::endl;
38 +
39 +  //
40 +  //_____ init TFileService, needed for the output root file
41 +  //
42 +  edm::Service<TFileService> fs;
43 +  _tree = fs->make<TTree>("ttljets", "ttljets", 64000000);
44 +
45 +  irun = 0;
46 +  ievent = 0;
47 +  ilumi = 0;
48 +  njets = 0;
49 +  jet1_pt = -1.0;
50 +  jet1_eta = -1.0;
51 +  jet1_phi = -1.0;
52   }
53  
54  
# Line 42 | Line 58 | PlotReco::~PlotReco()
58   }
59  
60  
61 + void PlotReco::init_leaves(void){
62 +  ievent = ilumi = irun = njets = -1;
63 +  jet1_pt = jet1_eta = jet1_phi = -10.0;
64 +  jet_pt.clear();
65 +  jet_eta.clear();
66 +  jet_phi.clear();
67 +  track_pt.clear();
68 +  track_eta.clear();
69 +  track_phi.clear();
70 + }
71 +
72   void
73   PlotReco::analyze(const edm::Event& iEvent, const edm::EventSetup& iSetup)
74   {
75    std::cout << "=======>: PlotReco::analyze()" << std::endl;
76 +
77 +  // tree leaves cleanup
78 +  init_leaves();
79 +
80    //
81    //_____ event book keeping
82    //
83 <  unsigned int irun   = (unsigned int)iEvent.id().run();
83 >  irun   = (unsigned int)iEvent.id().run();
84    // this will work starting with CMSSW_340:
85    //unsigned int ilumi  = (unsigned int)iEvent.id().luminosityBlock();
86 <  unsigned int ilumi  = (unsigned int)iEvent.getLuminosityBlock().luminosityBlock();
87 <  unsigned int ievent = (unsigned int)iEvent.id().event();
86 >  ilumi  = (unsigned int)iEvent.getLuminosityBlock().luminosityBlock();
87 >  ievent = (unsigned int)iEvent.id().event();
88    cout << std::endl << "===> Provenance: " << std::endl;
89    cout << "Run, lumi, event: " << irun << ", " << ilumi << ", "<< ievent << std::endl;
90    //
# Line 62 | Line 93 | PlotReco::analyze(const edm::Event& iEve
93    std::cout << std::endl << "===> Check PAT jets: " << std::endl;
94    Handle< vector< reco::CaloJet > > jets;
95    iEvent . getByLabel( "kt4CaloJets", jets );
96 <  int jet_coll_size = jets->size();
97 <  cout << "jet collection size: "<< jet_coll_size << endl;
98 <  if (jet_coll_size>0){
99 <    double _pt = (*jets)[0].pt();
100 <    double _eta = (*jets)[0].eta();
101 <    cout << "pT= " << _pt << ", eta=" << _eta << std::endl;
96 >  njets = jets->size();
97 >  cout << "jet collection size: "<< njets << endl;
98 >  if (njets>0){
99 >    jet1_pt = (*jets)[0].pt();
100 >    jet1_eta = (*jets)[0].eta();
101 >    jet1_phi = (*jets)[0].phi();
102 >    cout << "pT= " << jet1_pt << ", eta=" << jet1_eta << std::endl;
103 >  }
104 >  for(std::vector<reco::CaloJet>::const_iterator jet = jets->begin();
105 >      jet != jets->end();
106 >      ++jet){
107 >    jet_pt.push_back(jet->pt());
108    }
109    //
110    //_____ check trigger
# Line 98 | Line 135 | PlotReco::analyze(const edm::Event& iEve
135        << "No beam spot available in the event \n";
136    }
137    cout << beamSpot.x0() << "   " << beamSpot.y0() << "   " << beamSpot.z0() << std::endl;
138 +  //
139 +  //_____ tracking ____________________________________________________________
140 +  //
141 +  //
142 +  Handle<std::vector<reco::Track> > generalTracks;
143 +  iEvent.getByLabel("generalTracks", generalTracks);
144 +  for(std::vector<reco::Track>::const_iterator track = generalTracks->begin();
145 +      track != generalTracks->end();
146 +      ++track){
147 +    double gTrackPt = track->pt();
148 +    double gTrackEta = track->eta();
149 +    double gTrackPhi = track->phi();
150 +    cout << gTrackPt << endl;
151 +    cout << gTrackPt << endl;
152 +    cout << gTrackPt << endl<<endl;
153 +  }
154 +  //vector<reco::Track>               "globalCosmicMuons"     ""            "EXPRESS."                                                                          
155 +  //vector<reco::Track>               "globalMuons"           ""            "EXPRESS."                                                                          
156 +  //vector<reco::Track>               "globalSETMuons"        ""            "EXPRESS."                                                                          
157 +  //vector<reco::Track>               "pixelTracks"           ""            "EXPRESS."                                                                          
158 +  //vector<reco::Track>               "standAloneMuons"       ""            "EXPRESS."    
159 +  //
160 +  //_____ fill the tree
161 +  _tree -> Fill();
162   }
163  
164  
# Line 105 | Line 166 | void
166   PlotReco::beginJob()
167   {
168    std::cout << "=======>: PlotReco::beginJob()" << std::endl;
169 +
170 +  _tree -> Branch("event", &ievent, "event/I" );
171 +  _tree -> Branch("lumi", &ilumi, "lumi/I" );
172 +  _tree -> Branch("run", &irun, "run/I" );
173 +  _tree -> Branch("njets", &njets, "njets/I" );
174 +  _tree -> Branch("jet_pt", &jet_pt );
175 +  _tree -> Branch("jet1_pt", &jet1_pt, "jet1_pt/D" );
176 +  _tree -> Branch("jet1_eta", &jet1_eta, "jet1_eta/D" );
177 +  _tree -> Branch("jet1_phi", &jet1_phi, "jet1_phi/D" );
178   }
179  
180  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines