001
002
003
004
005
006
007
008
009
010
011
012
013
014
015
016
017
018
019
020
021 #include "JetTagTools/JetFitterTag.h"
022
023
024
025 #include "JetTagEvent/ISvxAssociation.h"
026 #include "JetEvent/Jet.h"
027 #include "JetTagEvent/TrackAssociation.h"
028 #include "JetTagInfo/TruthInfo.h"
029 #include "JetTagTools/HistoHelperRoot.h"
030 #include "Particle/TrackParticle.h"
031 #include "TrkParticleBase/TrackParticleBase.h"
032
033 #include "JetTagTools/JetFitterNtupleWriter.h"
034 #include "JetTagTools/JetFitterLikelihood.h"
035 #include "JetTagTools/JetFitterNNTool.h"
036 #include "JetTagTools/JetFitterVariablesFactory.h"
037 #include <cmath>
038 #include <sstream>
039
040 #include "CLHEP/Vector/LorentzVector.h"
041
042 #include "VxSecVertex/VxSecVertexInfo.h"
043 #include "VxSecVertex/VxJetFitterVertexInfo.h"
044 #include "VxJetVertex/VxJetCandidate.h"
045 #include "VxJetVertex/SelectedTracksInJet.h"
046 #include "VxJetVertex/TwoTrackVerticesInJet.h"
047
048 #include "JetTagInfo/JetFitterTagInfo.h"
049 #include "JetTagInfo/BaseTagInfo.h"
050 #include "JetTagInfo/ITagInfo.h"
051
052
053
054 namespace Analysis {
055
056 JetFitterTag::JetFitterTag(const std::string& t, const std::string& n, const IInterface* p)
057 : AthAlgTool(t,n,p),
058 m_runModus("analysis"),
059 m_ntupleWriter("Analysis::JetFitterNtupleWriter"),
060 m_variablesFactory("Analysis::JetFitterVariablesFactory"),
061 m_likelihood("Analysis::JetFitterLikelihood"),
062 m_NN("Analysis::JetFitterNNTool"),
063 m_secVxFinderName("InDetJetFitterVxFinder"),
064 m_useNN(false),
065 m_useNNwithIP3d(false),
066 m_IP3DinfoName("IP3D"),
067 m_storeOnlyBaseObject(false)
068 {
069
070
071
072
073 m_hypothese.push_back("bottom");
074 m_hypothese.push_back("light");
075 m_hypothese.push_back("charm");
076
077
078 declareInterface<ITagTool>(this);
079
080 declareProperty("Runmodus", m_runModus);
081 declareProperty("useVariables", m_useVariables);
082 declareProperty("ListHypotheses",m_hypothese);
083
084 declareProperty("truthMatchingName", m_truthMatchingName = "TruthInfo");
085 declareProperty("purificationDeltaR", m_purificationDeltaR = 0.8);
086 declareProperty("jetPtMinRef", m_jetPtMinRef = 15.*GeV);
087 declareProperty("jetCollectionList", m_jetCollectionList);
088 m_jetCollectionList.push_back("Cone4H1Tower");
089 m_jetCollectionList.push_back("Cone7H1Tower");
090 m_jetCollectionList.push_back("Kt4H1Tower");
091 m_jetCollectionList.push_back("Kt6H1Tower");
092 m_jetCollectionList.push_back("Cone4H1Topo");
093 m_jetCollectionList.push_back("Cone7H1Topo");
094 m_jetCollectionList.push_back("Kt4H1Topo");
095 m_jetCollectionList.push_back("Kt6H1Topo");
096 declareProperty("jetCollectionListVeto", m_jetCollectionListVeto);
097 declareProperty("useForcedCalibration", m_doForcedCalib = false);
098 declareProperty("ForcedCalibrationName", m_ForcedCalibName = "Cone4H1Tower");
099
100
101 declareProperty("JetFitterNtupleWriter",m_ntupleWriter);
102 declareProperty("JetFitterVariablesFactory",m_variablesFactory);
103 declareProperty("JetFitterLikelihood",m_likelihood);
104 declareProperty("JetFitterNNTool",m_NN);
105 declareProperty("SecVxFinderName",m_secVxFinderName);
106
107 declareProperty("useNN",m_useNN);
108 declareProperty("useNNWithIP3D",m_useNNwithIP3d);
109 declareProperty("IP3DinfoName",m_IP3DinfoName);
110
111 declareProperty("storeOnlyBaseObject",m_storeOnlyBaseObject);
112
113 }
114
115 JetFitterTag::~JetFitterTag() {
116
117 }
118
119
120 StatusCode JetFitterTag::initialize() {
121
122 StatusCode sc = m_ntupleWriter.retrieve();
123 if( StatusCode::SUCCESS != sc ) {
124 ATH_MSG_ERROR(" creation of Analysis::JetFitterNtupleWriter : " << m_ntupleWriter << " failed.");
125 return sc;
126 }
127
128
129 sc = m_variablesFactory.retrieve();
130 if( StatusCode::SUCCESS != sc ) {
131 ATH_MSG_ERROR(" creation of Analysis::JetFitterVariablesFactory : " << m_variablesFactory << " failed");
132 return sc;
133 }
134
135 if (!m_useNN)
136 {
137
138
139 sc = m_likelihood.retrieve();
140 if( StatusCode::SUCCESS != sc ) {
141 ATH_MSG_ERROR(" creation of Analysis::JetFitterLikelihood : " << m_likelihood << " failed");
142 return sc;
143 }
144 }
145 else
146 {
147
148 sc = m_NN.retrieve();
149 if( StatusCode::SUCCESS != sc ) {
150 ATH_MSG_ERROR(" creation of Analysis::JetFitterNNTool : " << m_NN<< " failed");
151 return sc;
152 }
153 }
154
155
156
157
158
159
160 if (m_doForcedCalib) {
161 if (std::find( m_jetCollectionList.begin(),
162 m_jetCollectionList.end(),
163 m_ForcedCalibName ) == m_jetCollectionList.end()) {
164 ATH_MSG_ERROR("Error, forced calibration to an unloaded one");
165 return StatusCode::FAILURE;
166 }
167 }
168
169
170
171
172
173 if( m_runModus == "analysis" ) {
174
175 std::vector<std::string>::const_iterator hypbegin=m_hypothese.begin();
176 std::vector<std::string>::const_iterator hypend=m_hypothese.end();
177
178 for(std::vector<std::string>::const_iterator hypiter=hypbegin;hypiter!=hypend;
179 ++hypiter) {
180 if (!m_useNN)
181 {
182 m_likelihood->initializeCalibrationFile(*hypiter);
183
184
185
186
187
188
189
190
191
192
193
194
195
196 }
197 }
198 }
199
200
201
202
203 if( m_runModus == "reference" ) {
204
205 std::vector<std::string>::const_iterator strbegin=m_jetCollectionList.begin();
206 std::vector<std::string>::const_iterator strend=m_jetCollectionList.end();
207
208 for (std::vector<std::string>::const_iterator striter=strbegin;
209 striter!=strend;++striter) {
210
211 m_ntupleWriter->bookNtuple(*striter);
212
213 }
214
215 }
216
217 return StatusCode::SUCCESS;
218 }
219
220
221 void JetFitterTag::finalizeHistos() {
222 }
223
224
225
226 StatusCode JetFitterTag::finalize() {
227 return StatusCode::SUCCESS;
228 }
229
230 void JetFitterTag::tagJet(Jet& jetToTag) {
231
232
233 std::string author = jetToTag.jetAuthor();
234
235 if (std::find( m_jetCollectionListVeto.begin(),
236 m_jetCollectionListVeto.end(),
237 author ) != m_jetCollectionListVeto.end()) {
238 ATH_MSG_DEBUG( " No Fit for " << jetToTag.jetAuthor() << " will be performed ");
239 return;
240 }
241
242 if (m_doForcedCalib) {
243 author = m_ForcedCalibName;
244 } else {
245
246 if (std::find( m_jetCollectionList.begin(),
247 m_jetCollectionList.end(),
248 author ) == m_jetCollectionList.end()) {
249 ATH_MSG_DEBUG("Jet Algorithm " << jetToTag.jetAuthor() << " not found in the standard list");
250 ATH_MSG_DEBUG("Trying to find a similar one...");
251 if (author.find("Cone4",0) != std::string::npos) author = "Cone4H1Tower";
252 else if (author.find("Cone",0) != std::string::npos) author = "Cone7H1Tower";
253 else if (author.find("Kt4",0) != std::string::npos) author = "Cone4H1Tower";
254 else if (author.find("Kt6",0) != std::string::npos) author = "Cone7H1Tower";
255 else {
256 ATH_MSG_DEBUG("None found, taking " << m_ForcedCalibName << " calibration");
257 author = m_ForcedCalibName;
258 }
259 }
260 }
261
262
263 std::string label = "N/A";
264 std::string pref = "";
265 if( m_runModus == "reference" ) {
266
267 if( jetToTag.pt()>m_jetPtMinRef && fabs(jetToTag.eta())<2.5 ) {
268
269 const TruthInfo* mcinfo = jetToTag.tagInfo<TruthInfo>("TruthInfo");
270 double deltaRmin(0.);
271 if( mcinfo ) {
272 label = mcinfo->jetTruthLabel();
273
274 double deltaRtoClosestB = mcinfo->deltaRMinTo("B");
275 double deltaRtoClosestC = mcinfo->deltaRMinTo("C");
276 deltaRmin = deltaRtoClosestB < deltaRtoClosestC ? deltaRtoClosestB : deltaRtoClosestC;
277
278 double deltaRtoClosestT = mcinfo->deltaRMinTo("T");
279 deltaRmin = deltaRtoClosestT < deltaRmin ? deltaRtoClosestT : deltaRmin;
280 } else {
281 ATH_MSG_ERROR("No TruthInfo ! Cannot run on reference mode !");
282 return;
283 }
284
285 ATH_MSG_VERBOSE(" label " << label << " m_hypothese.size() " << m_hypothese.size());
286
287
288 if ( ( ( "B"==label || "C"==label || "N/A"==label) && m_hypothese.size()==3 ) ||
289 ( ( "B"==label || "N/A"==label) && m_hypothese.size()==2 ) ) {
290 if ("B"==label) {
291 pref = m_hypothese[0];
292 } else if ("N/A"==label) {
293 pref = m_hypothese[1];
294 } else if ("C" == label) {
295 pref = m_hypothese[2];
296 }
297 }
298 }
299 }
300
301
302
303 HepLorentzVector jetDirection(jetToTag.px(),jetToTag.py(),jetToTag.pz(),jetToTag.e());
304
305
306
307
308 const ISvxAssociation* newSvxAssociation=jetToTag.getAssociation<ISvxAssociation>(m_secVxFinderName);
309
310 if (newSvxAssociation==0) {
311 ATH_MSG_DEBUG( " No JetFitter vertex found, attached to the Jet as association. Not going on with tagging...");
312 return;
313 }
314
315 const Trk::VxSecVertexInfo* myVertexInfo=newSvxAssociation->vertexInfo();
316 if (myVertexInfo==0) {
317 ATH_MSG_WARNING(" Could not get the vertex info from the JetAssociation! Strange...");
318 return;
319 }
320
321 const std::vector<Trk::VxCandidate*> & myVertices=myVertexInfo->vertices();
322 Trk::VxJetCandidate* myVxJetCandidate=dynamic_cast<Trk::VxJetCandidate*>(myVertices[0]);
323
324 if (myVxJetCandidate==0) {
325 ATH_MSG_WARNING(" No correct VxJetCandidate could be retrieved. JetFitter is not doing any tag on this jet");
326 return;
327 }
328
329 const Trk::VxJetFitterVertexInfo* myJetFitterInfo=dynamic_cast<const Trk::VxJetFitterVertexInfo*>(myVertexInfo);
330
331 const Trk::TwoTrackVerticesInJet* myTwoTrackVertices=0;
332 const Trk::SelectedTracksInJet* mySelectedTracksInJet=0;
333
334 if (myJetFitterInfo!=0)
335 {
336 myTwoTrackVertices=myJetFitterInfo->getTwoTrackVerticesInJet();
337 if (myTwoTrackVertices==0) {
338 ATH_MSG_WARNING(" No two track vertices in Jet found. Skipping...");
339 }
340
341 mySelectedTracksInJet=myJetFitterInfo->getSelectedTracksInJet();
342 if (mySelectedTracksInJet==0) {
343 ATH_MSG_WARNING(" No selected tracks in Jet found. Skipping...");
344 }
345 }
346 else
347 {
348 ATH_MSG_DEBUG(" No new JetFitter Vertex Info found: normal if running JetFitter version 1.");
349 }
350
351
352
353
354 JetFitterTagInfo* theVariables=m_variablesFactory->getITagInfoObject(*myVxJetCandidate,
355 myTwoTrackVertices,
356 mySelectedTracksInJet,
357 jetToTag);
358
359
360
361
362
363 if( m_runModus == "reference" ) {
364 m_ntupleWriter->fillNtuple(pref,jetToTag.jetAuthor(),*theVariables,jetToTag);
365 }
366
367
368 if(m_runModus=="analysis") {
369
370
371 if (!m_useNN)
372 {
373
374 std::vector<std::string>::const_iterator hypbegin=m_hypothese.begin();
375 std::vector<std::string>::const_iterator hypend=m_hypothese.end();
376
377 for(std::vector<std::string>::const_iterator hypiter=hypbegin;hypiter!=hypend;
378 ++hypiter) {
379 m_likelihood->fillLikelihoodValues(*theVariables,author,*hypiter);
380 }
381
382 }
383 else
384 {
385
386 if (m_useNNwithIP3d)
387 {
388 const JetTagInfoBase* pos(jetToTag.tagInfo(m_IP3DinfoName));
389
390 if (pos==0)
391 {
392 ATH_MSG_WARNING("Could not find IP3D tag to combine it with JetFitter. Tag name: " << m_IP3DinfoName);
393 }
394 else
395 {
396 const std::vector<double>& prob = pos->tagLikelihood();
397 double pb = prob[0];
398 double pu = prob[1];
399 double w = 0.;
400 if (pb <= 0. || pu <= 0.) {
401 ATH_MSG_WARNING("At least one IP3D prob. null (or negative !?) for JetFitter : pb,pu = " << pb << " " << pu << ", conservatively putting the weight to 0");
402 } else {
403 w = log(pb/pu);
404 }
405
406 m_NN->fillLikelihoodValues(*theVariables,
407 author,
408 jetToTag.pt(),
409 jetToTag.eta(),
410 w);
411 }
412 }
413 else
414 {
415 m_NN->fillLikelihoodValues(*theVariables,
416 author,
417 jetToTag.pt(),
418 jetToTag.eta());
419 }
420 }
421
422
423 JetTagInfoBase* myInfoToStore=0;
424
425 if (m_storeOnlyBaseObject)
426 {
427 myInfoToStore=new BaseTagInfo(*theVariables);
428 delete theVariables;
429 theVariables=0;
430 }
431 else
432 {
433 myInfoToStore=theVariables;
434 }
435
436 jetToTag.addInfo(myInfoToStore);
437 myInfoToStore->makeValid();
438
439 }
440 }
441
442 }
443
444
| Due to the LXR bug, the updates fail sometimes to remove references to deleted files. The Saturday's full rebuilds fix these problems |
|
This page was automatically generated by the
LXR engine.
|
|