CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
ConeIsolation.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: ConeIsolation
4 // Class: ConeIsolation
5 //
13 //
14 // Original Author: Simone Gennai
15 // Created: Thu Apr 6 09:56:23 CEST 2006
16 // $Id: ConeIsolation.cc,v 1.2 2011/10/12 09:00:41 fwyzard Exp $
17 //
18 //
19 
20 
21 // system include files
22 #include <memory>
23 
24 // user include files
27 
30 
32 
36 
40 
44 
45 using namespace reco;
46 using namespace edm;
47 using namespace std;
48 
49 //
50 // constructors and destructor
51 //
53 {
54  jetTrackSrc = iConfig.getParameter<InputTag>("JetTrackSrc");
55  vertexSrc = iConfig.getParameter<InputTag>("vertexSrc");
56  usingVertex = iConfig.getParameter<bool>("useVertex");
57  usingBeamSpot = iConfig.getParameter<bool>("useBeamSpot"); //If false the OfflinePrimaryVertex will be used.
58  beamSpotProducer = iConfig.getParameter<edm::InputTag>("BeamSpotProducer");
59  m_algo = new ConeIsolationAlgorithm(iConfig);
60 
61  produces<reco::JetTagCollection>();
62  produces<reco::IsolatedTauTagInfoCollection>();
63 
64 
65 
66 }
67 
68 
70 {
71  delete m_algo;
72 }
73 
74 
75 
76 //
77 // member functions
78 //
79 // ------------ method called to produce the data ------------
80 void
82 {
83  using namespace edm;
84  //Get jets with tracks
86  iEvent.getByLabel(jetTrackSrc,jetTracksAssociation);
87 
88  std::auto_ptr<reco::JetTagCollection> tagCollection;
89  std::auto_ptr<reco::IsolatedTauTagInfoCollection> extCollection( new reco::IsolatedTauTagInfoCollection() );
90 if (not jetTracksAssociation->empty()) {
91  RefToBaseProd<reco::Jet> prod( jetTracksAssociation->begin()->first );
92  tagCollection.reset( new reco::JetTagCollection(prod) );
93  } else {
94  tagCollection.reset( new reco::JetTagCollection() );
95  }
96 
98  e(0,0)=1;
99  e(1,1)=1;
100  e(2,2)=1;
101  Vertex::Point p(0,0,-1000);
102  Vertex myPVtmp(p,e);//Fake vertex to be used in case no vertex is found
103  Vertex myPV;
104 
105  //Get pixel vertices
107  iEvent.getByLabel(vertexSrc,vertices);
108  const reco::VertexCollection vertCollection = *(vertices.product());
109  //Check if there is the PV!!!!
110  if(vertCollection.begin() != vertCollection.end())
111  myPVtmp = *(vertCollection.begin());
112 
113  //In case the beam spot is used, the Z of the vertex still comes from the PV, while the (x,y) is taken from the beamspot
114  reco::BeamSpot vertexBeamSpot;
115  edm::Handle<reco::BeamSpot> recoBeamSpotHandle;
116 
117  if(usingBeamSpot)
118  {
119  //Create a new vertex with the information on x0 and Y0 from the beamspot, to be used in HLT.
120  iEvent.getByLabel(beamSpotProducer,recoBeamSpotHandle);
121  vertexBeamSpot = *recoBeamSpotHandle;
122  Vertex::Point bspoint(vertexBeamSpot.x0(),vertexBeamSpot.y0(),myPVtmp.z());
123  Vertex combinedVertex = Vertex(bspoint,myPVtmp.error(),myPVtmp.chi2(),myPVtmp.ndof(),myPVtmp.tracksSize());
124  myPV = combinedVertex;
125  }else{
126  myPV = myPVtmp;
127  }
128 
129  for (unsigned int i = 0; i < jetTracksAssociation->size(); ++i)
130  {
131  pair<float,IsolatedTauTagInfo> myPair =m_algo->tag(edm::Ref<JetTracksAssociationCollection>(jetTracksAssociation,i),myPV);
132  tagCollection->setValue(i, myPair.first);
133  extCollection->push_back(myPair.second);
134  }
135 
136  iEvent.put(extCollection);
137  iEvent.put(tagCollection);
138 
139 }
140 
141 //define this as a plug-in
142 //DEFINE_FWK_MODULE(ConeIsolation);
143 
T getParameter(std::string const &) const
int i
Definition: DBlmapReader.cc:9
math::Error< dimension >::type Error
covariance error matrix (3x3)
Definition: Vertex.h:44
std::vector< Vertex > VertexCollection
collection of Vertex objects
Definition: VertexFwd.h:9
int iEvent
Definition: GenABIO.cc:243
virtual void produce(edm::Event &, const edm::EventSetup &)
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:85
std::vector< IsolatedTauTagInfo > IsolatedTauTagInfoCollection
double chi2() const
chi-squares
Definition: Vertex.h:82
double z() const
y coordinate
Definition: Vertex.h:99
math::XYZPoint Point
point in the space
Definition: Vertex.h:40
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:356
double ndof() const
Definition: Vertex.h:89
Error error() const
return SMatrix
Definition: Vertex.h:116
ConeIsolation(const edm::ParameterSet &)
size_t tracksSize() const
number of tracks
Definition: Vertex.cc:35