CMS 3D CMS Logo

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 //
17 //
18 
19 
20 // system include files
21 #include <memory>
22 
23 // user include files
26 
31 
35 
39 
43 
45 
46 using namespace reco;
47 using namespace edm;
48 using namespace std;
49 
50 //
51 // constructors and destructor
52 //
54 {
55  jetTrackTag = iConfig.getParameter<InputTag>("JetTrackSrc");
56  jetTrackToken = consumes<reco::JetTracksAssociationCollection>(jetTrackTag);
57  vertexTag = iConfig.getParameter<InputTag>("vertexSrc");
58  vertexToken = consumes<reco::VertexCollection>(vertexTag);
59  beamSpotTag = iConfig.getParameter<edm::InputTag>("BeamSpotProducer");
60  beamSpotToken = consumes<reco::BeamSpot>(beamSpotTag);
61  usingBeamSpot = iConfig.getParameter<bool>("useBeamSpot"); //If false the OfflinePrimaryVertex will be used.
62 
63  m_algo = new ConeIsolationAlgorithm(iConfig);
64 
65  produces<reco::JetTagCollection>();
66  produces<reco::IsolatedTauTagInfoCollection>();
67 
68 }
69 
70 
72 {
73  delete m_algo;
74 }
75 
76 
77 
78 //
79 // member functions
80 //
81 
82 void
85  desc.add<edm::InputTag>("JetTrackSrc",edm::InputTag("ic5JetTracksAssociatorAtVertex"));
86  desc.add<edm::InputTag>("vertexSrc",edm::InputTag("offlinePrimaryVertices"));
87  desc.add<edm::InputTag>("BeamSpotProducer",edm::InputTag("offlineBeamSpot"));
88  desc.add<bool>("useBeamSpot",false);
90  descriptions.add("coneIsolationTauJetTags", desc);
91 }
92 
93 // ------------ method called to produce the data ------------
94 void
96 {
97  using namespace edm;
98  //Get jets with tracks
100  iEvent.getByToken(jetTrackToken,jetTracksAssociation);
101 
102  std::unique_ptr<reco::JetTagCollection> tagCollection;
103  std::unique_ptr<reco::IsolatedTauTagInfoCollection> extCollection( new reco::IsolatedTauTagInfoCollection() );
104  if (not jetTracksAssociation->empty()) {
105  RefToBaseProd<reco::Jet> prod( edm::makeRefToBaseProdFrom(jetTracksAssociation->begin()->first, iEvent) );
106  tagCollection.reset( new reco::JetTagCollection(prod) );
107  } else {
108  tagCollection.reset( new reco::JetTagCollection() );
109  }
110 
112  e(0,0)=1;
113  e(1,1)=1;
114  e(2,2)=1;
115  Vertex::Point p(0,0,-1000);
116  Vertex myPVtmp(p,e);//Fake vertex to be used in case no vertex is found
117  Vertex myPV;
118 
119  //Get pixel vertices
121  iEvent.getByToken(vertexToken,vertices);
122  const reco::VertexCollection vertCollection = *(vertices.product());
123  //Check if there is the PV!!!!
124  if(vertCollection.begin() != vertCollection.end())
125  myPVtmp = *(vertCollection.begin());
126 
127  //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
128  reco::BeamSpot vertexBeamSpot;
129  edm::Handle<reco::BeamSpot> recoBeamSpotHandle;
130 
131  if(usingBeamSpot)
132  {
133  //Create a new vertex with the information on x0 and Y0 from the beamspot, to be used in HLT.
134  iEvent.getByToken(beamSpotToken,recoBeamSpotHandle);
135  vertexBeamSpot = *recoBeamSpotHandle;
136  Vertex::Point bspoint(vertexBeamSpot.x0(),vertexBeamSpot.y0(),myPVtmp.z());
137  Vertex combinedVertex = Vertex(bspoint,myPVtmp.error(),myPVtmp.chi2(),myPVtmp.ndof(),myPVtmp.tracksSize());
138  myPV = combinedVertex;
139  }else{
140  myPV = myPVtmp;
141  }
142 
143  for (unsigned int i = 0; i < jetTracksAssociation->size(); ++i)
144  {
145  pair<float,IsolatedTauTagInfo> myPair =m_algo->tag(edm::Ref<JetTracksAssociationCollection>(jetTracksAssociation,i),myPV);
146  tagCollection->setValue(i, myPair.first);
147  extCollection->push_back(myPair.second);
148  }
149 
150  iEvent.put(std::move(extCollection));
151  iEvent.put(std::move(tagCollection));
152 
153 }
154 
155 //define this as a plug-in
156 //DEFINE_FWK_MODULE(ConeIsolation);
157 
T getParameter(std::string const &) const
static void fillDescription(edm::ParameterSetDescription &desc)
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:122
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:457
math::Error< dimension >::type Error
covariance error matrix (3x3)
Definition: Vertex.h:43
std::vector< Vertex > VertexCollection
collection of Vertex objects
Definition: VertexFwd.h:9
int iEvent
Definition: GenABIO.cc:230
virtual void produce(edm::Event &, const edm::EventSetup &)
std::vector< IsolatedTauTagInfo > IsolatedTauTagInfoCollection
double chi2() const
chi-squares
Definition: Vertex.h:98
double z() const
z coordinate
Definition: Vertex.h:115
math::XYZPoint Point
point in the space
Definition: Vertex.h:39
ParameterDescriptionBase * add(U const &iLabel, T const &value)
double ndof() const
Definition: Vertex.h:105
T const * product() const
Definition: Handle.h:81
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
Error error() const
return SMatrix
Definition: Vertex.h:139
RefToBaseProd< T > makeRefToBaseProdFrom(RefToBase< T > const &iRef, Event const &iEvent)
fixed size matrix
HLT enums.
double y0() const
y coordinate
Definition: BeamSpot.h:66
ConeIsolation(const edm::ParameterSet &)
const_iterator begin() const
def move(src, dest)
Definition: eostools.py:510
size_t tracksSize() const
number of tracks
Definition: Vertex.cc:71
size_type size() const
double x0() const
x coordinate
Definition: BeamSpot.h:64