ATLAS Offline Software
Loading...
Searching...
No Matches
IParticleHandle_Jet.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3*/
4
5
7// //
8// Implementation of class IParticleHandle_Jet //
9// //
10// //
12
13// Local
14#include "IParticleHandle_Jet.h"
16#include "AODSysCommonData.h"
18
19//VP1
20#include "VP1Base/VP1Msg.h"
21#include "VP1Utils/SoTools.h"
22
23//SoCoin
24#include <Inventor/C/errors/debugerror.h>
25#include <Inventor/nodes/SoLineSet.h>
26#include <Inventor/nodes/SoPointSet.h>
27#include <Inventor/nodes/SoVertexProperty.h>
28#include <Inventor/nodes/SoMaterial.h>
29#include <Inventor/nodes/SoCone.h>
30#include <Inventor/nodes/SoSeparator.h>
31#include <Inventor/nodes/SoTranslation.h>
32#include <Inventor/nodes/SoRotationXYZ.h>
33#include <Inventor/nodes/SoScale.h>
34#include <Inventor/nodes/SoSwitch.h>
35#include <SoDebug.h> // it's stored at /afs/cern.ch/sw/lcg/external/coin3d/3.1.3p2/x86_64-slc6-gcc47-opt/include/SoDebug.h
36
37// System of units
38#ifdef BUILDVP1LIGHT
39 #include "GeoModelKernel/Units.h"
40 #define SYSTEM_OF_UNITS GeoModelKernelUnits // --> 'GeoModelKernelUnits::cm'
41#else
42 #include "GaudiKernel/SystemOfUnits.h"
43 #define SYSTEM_OF_UNITS Gaudi::Units // --> 'Gaudi::Units::cm'
44#endif
45
49
50//____________________________________________________________________
52public:
53 // constructor and default values
54 //Imp () : theclass(0), controller(0), scale(1.0), bTaggingTagger("MV1"),bTaggingCut(0.98),randomColours(false),bTaggingSwitch(0),bTaggingTexture(0), bTaggingMaterial(0) {} // NOTE: parameters from the old JetCollection
55 //Imp () : theclass(0), scale(1.0) {} // TODO: implement the parameters above, from the old JetCollection
56
57 IParticleHandle_Jet * theclass = nullptr; // the Jet class
58 const IParticleCollHandle_Jet* theCollHandle = nullptr; // the CollHandle instance
59
60 const xAOD::Jet * m_jet = nullptr; // the single jet
61
62 SoSeparator * sep = nullptr; // everything hangs from this.
63 SoCone * cone = nullptr;//This represents the cone representing the jet.
64 SoMaterial * m_randomMat = nullptr; // random material for jets
65 SoSwitch * m_bTagged = nullptr; // switch for b-tagged jets
66 SoSwitch * m_bTaggingCollSwitch = nullptr; // switch for b-tagged jets
67
68
69 // vars to store b-tagging weights for different taggers
70 double m_bTagWeightMV1 = 0.0;
71 double m_bTagWeightMV2c20 = 0.0;
72 double m_bTagWeightMV2c10 = 0.0;
76
77
78 //QList<std::pair<xAOD::ParameterPosition, Amg::Vector3D> > parametersAndPositions; // cache // TODO: see if useful for jets
79
80 //Settings:
81 bool considerTransverseEnergies = true; // TODO: update with button connection "E/Et" (see VP1JetCollection.cxx)
82 double coneRPar = -1; // FIXME: add calculation of coneRPar, like in the old VP1 Jet
83 double scale = (10.0 * SYSTEM_OF_UNITS::m) / (100.0*SYSTEM_OF_UNITS::GeV); // the default scale of all jets: 10m/100GeV
84 double maxR = 0.0 * SYSTEM_OF_UNITS::m; // default value for maxR is 0.0
85
86 // SoLineSet * line;//This represents the line(s) representing the trackparticle. Can be interpolated.
87 // SoPointSet * points;//This represents the points(s) representing the trackparticle's parameters.
88
89
90
91 // Getters
92 double pt() const { return m_jet->pt(); }
93 double phi() const { /*VP1Msg::messageVerbose("phi: " + QString::number(m_jet->phi()) );*/ return m_jet->phi(); }
94 double eta() const { /*VP1Msg::messageVerbose("eta: " + QString::number(m_jet->eta()) );*/ return m_jet->eta(); }
95 double energy() const { return m_jet->e(); }
96 double transverseEnergy() const { return sin(2*atan(exp(-fabs(eta()))))*energy(); }
97 double coneR() const { return coneRPar > 0 ? coneRPar : 0.4; }
99
100 //Create/manipulate 3D objects:
101 void createShapeFromJetParameters(const IParticleCollHandle_Jet* collHandleJet, const double& coneR, const double& eta, const double& phi, const double& energy, const SbVec3f& origin);
102 void updateConeHeightParameters(SoCone*, SoTranslation*, const double& energy) const;
103 void updateConeHeightParameters() const;
104
105 // Update random material
106 void rerandomiseMaterial();
107
108
109};
110
111//____________________________________________________________________
113: IParticleHandleBase(ch), m_d(new Imp)
114{
115 // VP1Msg::messageVerbose("IParticleHandle_Jet::IParticleHandle_Jet() - constructor");
116 m_d->theclass = this;
117 m_d->m_jet = jet;
118
119 m_d->sep = 0;
120 m_d->cone = 0;
121 m_d->m_randomMat = 0;
122 m_d->m_bTagged = 0;
123 m_d->m_bTaggingCollSwitch = new SoSwitch();
124
125 // get b-tagging weights for different taggers
126 m_d->m_bTagWeightMV1 = getBTaggingWeight("MV1");
127 m_d->m_bTagWeightMV2c20 = getBTaggingWeight("MV2c20");
128 m_d->m_bTagWeightMV2c10 = getBTaggingWeight("MV2c10");
129 m_d->m_JetFitterCombNN_pb = getBTaggingWeight("JetFitterCombNN_pb");
130 m_d->m_JetFitterCombNN_pc = getBTaggingWeight("JetFitterCombNN_pc");
131 m_d->m_JetFitterCombNN_pu = getBTaggingWeight("JetFitterCombNN_pu");
132
133
134// m_d->theCollHandle = dynamic_cast<const IParticleCollHandle_Jet*>(collHandle());
135}
136
137//____________________________________________________________________
139{
140 // VP1Msg::messageVerbose("IParticleHandle_Jet::~IParticleHandle_Jet() - destructor");
141 if (m_d->m_randomMat) m_d->m_randomMat->unref();
142 if (m_d->cone) m_d->cone->unref();
143 if (m_d->sep) m_d->sep->unref();
144 delete m_d;
145}
146
147
148
149
150// Setter
151//____________________________________________________________________
152void IParticleHandle_Jet::setScale( const double& sc, bool useEt) { m_d->scale = sc; m_d->considerTransverseEnergies= useEt;}
153
154//____________________________________________________________________
155void IParticleHandle_Jet::setMaxR(const double& maxR) { m_d->maxR = maxR * SYSTEM_OF_UNITS::m; }
156
157//____________________________________________________________________
158void IParticleHandle_Jet::rerandomiseMaterial() {m_d->rerandomiseMaterial(); }
159
160//____________________________________________________________________
162{
163 // VP1Msg::messageVerbose("IParticleHandle_Jet::has3DObjects()");
164 return 0 != m_d->sep;
165}
166
167
168//____________________________________________________________________
170 // VP1Msg::messageVerbose("IParticleHandle_Jet::clear3DObjects()");
171
172 if (m_d->m_randomMat) {
173 m_d->m_randomMat->unref();
174 m_d->m_randomMat = 0;
175 }
176 if (m_d->cone) {
177 m_d->cone->unref();
178 m_d->cone = 0;
179 }
180 if (m_d->sep) {
181 m_d->sep->unref();
182 m_d->sep = 0;
183 }
184
185}
186
187
188
189/*
190 * This is the method which makes the 3D objects from the measurements
191 */
192//____________________________________________________________________
194
195 VP1Msg::messageVerbose("IParticleHandle_Jet::nodes()");
196
197 if (m_d->sep) {
198 VP1Msg::messageVerbose("d->sep already defined (" + VP1Msg::str(m_d->sep) + "). Returning d->sep.");
199 return m_d->sep; // FIXME - do we need to check if anything need to be redrawn?
200 }
201 if (!m_d->sep) {
202 VP1Msg::messageVerbose("d->sep not defined. Creating shapes and a new d->sep.");
203 m_d->sep = new SoSeparator();
204 m_d->sep->ref();
205 }
206
207 const IParticleCollHandle_Jet* collHandleJet = dynamic_cast<const IParticleCollHandle_Jet*>(collHandle());
208 if (not collHandleJet) return m_d->sep; //would nullptr be better?
209 SbVec3f origin(0.,0.,0.);
210 /* TODO: ask if origin info is present in xAOD, like in the old Jet class
211 if ( m_d->m_jet->origin() ) {
212 origin.setValue(m_d->m_jet->origin()->position().x(),
213 m_d->m_jet->origin()->position().y(),
214 m_d->m_jet->origin()->position().z());
215 }
216 */
217
218 const xAOD::Vertex * vtx;
219 bool exists = m_d->m_jet->getAssociatedObject(xAOD::JetAttribute::OriginVertex, vtx);
220
221 if( exists && vtx ) {
222 origin.setValue(vtx->position().x(),vtx->position().y(),vtx->position().z());
223 }
224
225
226 VP1Msg::messageVerbose("creating the shapes");
227
228
229 /*
230 * Here the 3D cone (SoCone) for the jet has to be created (and m_d->sep is updated)
231 */
232 m_d->createShapeFromJetParameters(collHandleJet, m_d->coneR(), m_d->eta(), m_d->phi(), m_d->energyForLengthAndCuts(), origin);
233
234
235 return m_d->sep;
236}
237
238//____________________________________________________________________
240 m_d->updateConeHeightParameters();
241}
242
243
244//____________________________________________________________________
245void IParticleHandle_Jet::Imp::createShapeFromJetParameters(const IParticleCollHandle_Jet* collHandleJet, const double& inputconeR, const double& eta,
246 const double& phi, const double& energy, const SbVec3f& origin)
247{
248 VP1Msg::messageVerbose("IParticleHandle_Jet::Imp::createShapeFromJetParameters()");
249
250
251
252 sep = new SoSeparator();
253 sep->ref();
254
255 cone = new SoCone();
256 cone->ref();
257
258 // coneR IS the opening half-angle of the jet, in delta phi (easy) and in
259 // delta eta (trickier)
260 // to try to get the jet extent right in eta, find theta corresponding
261 // to eta+R, eta-R, and take half of the difference:
262 double thetaMax = 2.*atan(exp(-(eta+inputconeR)));
263 double thetaMin = 2.*atan(exp(-(eta-inputconeR)));
264 double deltaTheta = fabs(thetaMax-thetaMin);
265 double etaScale = deltaTheta/(2.*inputconeR);
266
267 // Translate by half cone height and flip 180 deg so point is at IP:
268 SoTranslation *translate = new SoTranslation();
269
270 SoRotationXYZ *flip = new SoRotationXYZ();
271 flip->axis=SoRotationXYZ::Z;
272 flip->angle=M_PI;
273
274 SoRotationXYZ *ytoz = new SoRotationXYZ();
275 ytoz->axis=SoRotationXYZ::X;
276 ytoz->angle=M_PI/2.;
277
278 // Cones should now be along Z-axis,point at IP.
279 SoRotationXYZ *rotationPhi = new SoRotationXYZ();
280 rotationPhi->axis=SoRotationXYZ::Z;
281 rotationPhi->angle = phi+M_PI/2.; // starts from -y-axis in x-y plane
282 // phi is measured from x-axis, so +M_PI/2
283
284 SoRotationXYZ *rotationEta = new SoRotationXYZ();
285 double signEta = fabs(eta)/eta;
286 double theta = 2.*atan(signEta*exp(-fabs(eta)));
287 if (theta<0.)theta+=M_PI;
288 rotationEta->axis=SoRotationXYZ::X;
289 rotationEta->angle=theta;
290
291 //message("Eta: "+QString::number(eta)+" theta: "+QString::number(theta)+" phi: "+QString::number(phi));
292
294
295 // play with Scale:
296 SoScale* myScale = new SoScale();
297 //message("Eta scaling factor is "+QString::number(etaScale));
298 // maybe we need to squish along both axes...
299 myScale->scaleFactor.setValue(etaScale,1.,etaScale);
300
301 // translate to origin vertex rather than (0,0,0)
302 SoTranslation *transvertex = new SoTranslation();
303 transvertex->translation = origin;
304
305 sep->addChild(transvertex);
306 sep->addChild(rotationPhi);
307 sep->addChild(rotationEta);//theta rotation done around x-axis
308 sep->addChild(ytoz); // now it's along the z-axis
309 sep->addChild(flip); // flip so tip at origin
310 sep->addChild(translate); // back it up so base at origin // DO NOT MOVE THIS: ITS POSITION IS USED BY "updateConeHeightParameters(SoSeparator* sep,const double& energy)"
311 sep->addChild(myScale); // squeeze jet according to eta
312 //This is the point in the child sequence where we MAY add a random colour when appropriate.
313 //Thus: The translation is the SIXTH child and the cone is the LAST child.
314
315 // sep->addChild(collHandleJet->collSettingsButton().defaultParameterMaterial());
316
317 sep->addChild(collHandleJet->material());
318 // ^^ FIXME - should rearrange so we don't need to reset material
319
320 sep->addChild(cone); // starts along y-axis // DO NOT MOVE THIS: ITS POSITION IS USED BY "updateConeHeightParameters(SoSeparator* sep,const double& energy)"
321
322
323 // rendering b-tagged jets
324 SoNode * lastChild = sep->getChild( sep->getNumChildren()-1 );
325 if (lastChild->getTypeId() == SoCone::getClassTypeId())
326 {
327 VP1Msg::messageVerbose("adding b-tagging switch");
328
329 m_bTagged = new SoSwitch();
330 m_bTagged->whichChild=SO_SWITCH_ALL;
331
333
334 // add the b-tagging switch before the SoCone node
335 sep->insertChild(m_bTagged, sep->getNumChildren()-1);
336 }
337
338
339 //return sep;
340}
341
342//_____________________________________________________________________________________
343void IParticleHandle_Jet::Imp::updateConeHeightParameters(SoCone*cone, SoTranslation* trans, const double& energy) const
344{
345 VP1Msg::messageVerbose("IParticleHandle_Jet::Imp::updateConeHeightParameters()");
346
347 double h( std::fabs(scale * energy) );
348
349 // FIXME: check this! when maxR is set, what should that do?? Here it's only used as "h", but maybe it should set the max length of the cone's bottom radius?? Check with Ed!
350 if (maxR > 0.0001) { // maxR > 0. is not univocally defined, because maxR is a floating point number
351 VP1Msg::messageVerbose("maxR > 0.0001 ==> setting h = min(h, maxR)");
352 h = std::min(h, maxR);
353 }
354
355 cone->height = h;
356 cone->bottomRadius = tan(coneR()) * h;
357 trans->translation = SbVec3f(0,-0.5*h, 0);
358
359
360
361 //debug
362 SbString strHeight, strRadius;
363 (cone->height).get(strHeight);
364 (cone->bottomRadius).get(strRadius);
365// std::cout << "input - energy: " << energy << " - scale: " << scale << " - maxR: " << maxR << " - h: " << h << " --- updated cone - height: " << strHeight.getString() << " - bottom radius: " << strRadius.getString() << std::endl;
366
367 // you can also use the 'writeField()' method, direct to std output
368 //SoDebug::writeField(&(cone->height));
369
370 // QString text = "updated cone - height: " + QString::number(cone->height) + " - bottom radius: " + QString::number(cone->bottomRadius) " - translation: " + trans->translation;
371 // VP1Msg::messageVerbose(text);
372}
373
374
375//_____________________________________________________________________________________
377
378
379 if (!sep) {
380 VP1Msg::messageVerbose("sep not defined. Returning.");
381 return;
382 }
383
384 //NB: The translation is the SIXTH child and the cone is the LAST child.
385 if (sep->getNumChildren()<6) {
386 VP1Msg::messageVerbose("getNumChildren() < 6!!! Returning...");
387 return;
388 }
389
390 const double energyJet = energyForLengthAndCuts();
391
392 SoNode * sixthChild = sep->getChild(5);
393 if (sixthChild->getTypeId()!=SoTranslation::getClassTypeId()) {
394 VP1Msg::messageVerbose("6th child is not a translation!!! Returning...");
395 return;
396 }
397 SoNode * lastChild = sep->getChild(sep->getNumChildren()-1);
398 if (lastChild->getTypeId()!=SoCone::getClassTypeId()) {
399 VP1Msg::messageVerbose("lastChild is not a cone!!! Returning...");
400 return;
401 }
402 updateConeHeightParameters(static_cast<SoCone*>(lastChild),static_cast<SoTranslation*>(sixthChild), energyJet);
403}
404
405
406
407/*
408//____________________________________________________________________
409Amg::Vector3D IParticleHandle_Jet::momentum() const
410{
411 const Trk::Perigee& p = m_d->trackparticle->perigeeParameters();
412 return p.momentum();
413}
414 */
415
416//____________________________________________________________________
418{
419 return *(m_d->m_jet);
420}
421
422
423//____________________________________________________________________
425{
426 //return m_d->trackparticle->charge(); // TODO: check in Jet interface if a "charge" is defined
427 return 0; // FIXME: dummy value now
428}
429
430
431
432/*
433 * TODO: If Jet class has something like SummaryType like TrackParticle has, implement this method. Otherwise, remove it!
434 *
435 */
436/*
437//____________________________________________________________________
438unsigned IParticleHandle_Jet::summaryValue(xAOD::SummaryType type) const
439{
440 uint8_t num = 0;
441 if (m_d->trackparticle->summaryValue(num,type)){
442 return num;
443 }
444 // else...
445 VP1Msg::message("IParticleHandle_Jet::getSummaryValue - unable to retrieve the requested enum: "+VP1Msg::str(type));
446 return 999999;
447}
448 */
449
450
454//____________________________________________________________________
456{
457 QStringList l;
458
459 l << "--Jet:";
460
461 //l << IParticleHandleBase::baseInfo();
462
463 l += " - pt: " + QString::number(m_d->pt());
464 l += " - e: " + QString::number(m_d->energy());
465 l += " - eta: " + QString::number(m_d->eta());
466 l += " - phi: " + QString::number(m_d->phi());
467 l += " - m: " + QString::number(m_d->m_jet->m());
468 l += " - rapidity: " + QString::number(m_d->m_jet->rapidity());
469 l += " - type: " + QString::number(m_d->m_jet->type());
470 l += " - px: " + QString::number(m_d->m_jet->px());
471 l += " - py: " + QString::number(m_d->m_jet->py());
472 l += " - pz: " + QString::number(m_d->m_jet->pz());
473 l += " - numConstituents: " + QString::number(m_d->m_jet->numConstituents());
474
475 l += " - SizeParameter: " + QString::number(m_d->m_jet->getSizeParameter());
476// l += " - SizeParameter: " + QString::number(int(m_d->m_jet->getSizeParameter()*10));
477
478 xAOD::JetAlgorithmType::ID jetAlgID = m_d->m_jet->getAlgorithmType();
479 std::string algName = xAOD::JetAlgorithmType::algName(jetAlgID);
480 l += " - AlgorithmType: " + QString::fromStdString( algName );
481
482 xAOD::JetInput::Type jetAlgType = m_d->m_jet->getInputType();
483 std::string inputType = xAOD::JetInput::typeName(jetAlgType);
484 l += " - InputType: " + QString::fromStdString( inputType );
485
486
487 l += " - 'MV2c20' b-tagging weight: " + QString::number( m_d->m_bTagWeightMV2c20 );
488 l += " - 'MV2c10' b-tagging weight: " + QString::number( m_d->m_bTagWeightMV2c10 );
489 l += " - 'MV1' b-tagging weight: " + QString::number( m_d->m_bTagWeightMV1 );
490
491
492 l << "------";
493
494 return l;
495}
496
500//____________________________________________________________________
502{
503
504 QString l;
505
506 l += "pt: " + QString::number(m_d->pt());
507 l += ", e: " + QString::number(m_d->energy());
508 l += ", eta: " + QString::number(m_d->eta());
509 l += ", phi: " + QString::number(m_d->phi());
510 l += ", MV2c20: " + QString::number( m_d->m_bTagWeightMV2c20 );
511 l += ", MV2c10: " + QString::number( m_d->m_bTagWeightMV2c10 );
512 l += ", MV1: " + QString::number( m_d->m_bTagWeightMV1 );
513
514 return l;
515}
516
517
521//____________________________________________________________________
522void IParticleHandle_Jet::fillObjectBrowser( QList<QTreeWidgetItem *>& listOfItems)
523{
524 IParticleHandleBase::fillObjectBrowser(listOfItems); // Obligatory!
525
526 QTreeWidgetItem* TSOSitem = new QTreeWidgetItem(browserTreeItem());
527
528 // Jet "Object" title, in the Browser window
529 TSOSitem->setText(0, QString("Info:" ) );
530
531 QString dParameters("(");
532
533 // jet info and parameters,
534 // they go in the "Information" column in the Browser window
535 // see: http://acode-browser.usatlas.bnl.gov/lxr/source/atlas/Event/xAOD/xAODJet/xAODJet/versions/Jet_v1.h
536 //
537
538 dParameters+="pt: ";
539 dParameters+=QString::number(m_d->pt());
540 dParameters+=", e: ";
541 dParameters+=QString::number(m_d->energy());
542 dParameters+=", eta: ";
543 dParameters+=QString::number(m_d->eta());
544 dParameters+=", phi: ";
545 dParameters+=QString::number(m_d->phi());
546 dParameters+=", m: ";
547 dParameters+=QString::number(m_d->m_jet->m());
548 dParameters+=", rapidity: ";
549 dParameters+=QString::number(m_d->m_jet->rapidity());
550
551 dParameters+="";
552
553 dParameters+=")";
554
555 dParameters += " [more info in the main Message Box]";
556
557 TSOSitem->setText(1, dParameters );
558
559
560}
561
562
563
564
565//____________________________________________________________________
567 /*VP1Msg::messageVerbose("phi: " + QString::number(m_jet->phi()) );*/
568 return m_d->phi();
569}
570
571
572//____________________________________________________________________
574 /*VP1Msg::messageVerbose("eta: " + QString::number(m_jet->eta()) );*/
575 return m_d->eta();
576}
577
578
579//____________________________________________________________________
580double IParticleHandle_Jet::energy() const { return m_d->energy(); }
581
582
583//____________________________________________________________________
584double IParticleHandle_Jet::energyForCuts() const { return m_d->energyForLengthAndCuts(); }
585
586
587//____________________________________________________________________
588double IParticleHandle_Jet::transverseEnergy() const { return m_d->transverseEnergy(); } //sin(2*atan(exp(-fabs(eta()))))*energy();
589
590
591//____________________________________________________________________
593{
594 VP1Msg::messageVerbose("IParticleHandle_Jet::Imp::rerandomiseMaterial()");
595
596 // TODO: Move to HSV system, instead of RGB, and make random colors more contrasting
597
598
599 //Fixme: share this code with other systems!!
600 if ( !m_randomMat ) { //We will anyway rerandomize it when we need it
601 VP1Msg::messageVerbose("'m_randomMat not set. Returning.");
602 return;
603 }
604
605 double r2 = 0.3*0.3;
606 unsigned i(0);
607 double r,g,b;
608 bool ok;
609 while (true) {
610 r = (rand() / static_cast<double>(RAND_MAX));
611 g = (rand() / static_cast<double>(RAND_MAX));
612 b = (rand() / static_cast<double>(RAND_MAX));
613 ok = true;
614 //For now we make sure that we avoid black and red. This should be updated from bgd and highlight col automatically! (fixme).
615 // -> and we should probably also make sure that tracks close in (eta,phi) are well separated in colour-space.
616 if ( (r-1.0)*(r-1.0)+g*g+b*b < r2*0.5 )//avoid red (distance)
617 ok = false;
618 else if ( r*r/(r*r+g*g+b*b) > 0.8 )//avoid red (angle)
619 ok = false;
620 else if ( r*r+g*g+b*b < r2*2.0 )//avoid black
621 ok = false;
622 if (ok)
623 break;
624 ++i;
625 if (i>50 ) {
626 r2 *= 0.99;//To avoid problem in case we add too many forbidden spheres.
627 if (i>1000) {
628 //Just a safety
629 VP1Msg::messageVerbose("IParticleHandle_Jet::Imp::rerandomiseMaterial() - Warning: Random colour could"
630 " not be selected such as to satisfy all separation criterias");
631 break;
632 }
633 }
634 }
635
637}
638
639
640//____________________________________________________________________
641//void IParticleHandle_Jet::Imp::updateMaterial()
642void IParticleHandle_Jet::updateMaterial(bool isRandomColors)
643{
644 VP1Msg::messageVerbose("IParticleHandle_Jet::Imp::updateMaterial()");
645
646 // check if we have 3D objects; if not, return
647 if ( m_d->sep == 0 )
648 return;
649
650 if (!isRandomColors && !m_d->m_randomMat)
651 return;//m_randomMat can never have been attached
652
653 if (isRandomColors && !m_d->m_randomMat) {
654 m_d->m_randomMat = new SoMaterial;
655 m_d->m_randomMat->ref();
657 }
658
659
660 int i = m_d->sep->findChild(m_d->m_randomMat);
661
662 if ( (i>=0) == isRandomColors ) {
663 VP1Msg::messageVerbose("(i>=0)==isRandomColors. Returning.");
664 return;
665 }
666
667 if (!isRandomColors )
668 m_d->sep->removeChild(m_d->m_randomMat);
669 else
670 m_d->sep->insertChild(m_d->m_randomMat, m_d->sep->getNumChildren()-1);
671}
672
673
674//____________________________________________________________________
675void IParticleHandle_Jet::updateBTaggingSwitch(SoSwitch *bTaggingSwitch)
676{
677 VP1Msg::messageVerbose("IParticleHandle_Jet::updateBTaggingSwitch()");
678
679 std::cout << "old switch: " << m_d->m_bTaggingCollSwitch << " - new: " << bTaggingSwitch << std::endl;
680
681 // remove the old switch
682 m_d->m_bTagged->removeChild(m_d->m_bTaggingCollSwitch);
683
684 // updating the jet switch with the Coll switch
685 m_d->m_bTaggingCollSwitch = 0;
686 m_d->m_bTaggingCollSwitch = bTaggingSwitch;
687
688 // add the new switch to the internal b-tagging switch
689 m_d->m_bTagged->addChild( bTaggingSwitch );
690
691}
692
693
694//____________________________________________________________________
695void IParticleHandle_Jet::updateBTagging(const std::string& bTaggingTagger, const double& bTaggingCut)
696{
697 VP1Msg::messageVerbose("IParticleHandle_Jet::updateBTagging()");
698
699 // get the b-tagging "weight" (the discriminant)
700 //double bTaggingWeight = 0.99; // dummy value for debug only!!!
701 double bTaggingWeight = getBTaggingWeight(bTaggingTagger); // actual value
702
703 std::cout << "B-TAG UPDATE - jet eta: " << m_d->eta() << ", phi: " << m_d->phi() << " - tagger: " << bTaggingTagger << " - cut: " << bTaggingCut << " - weight: " << bTaggingWeight;
704
705 if (bTaggingWeight > bTaggingCut) {
706 m_d->m_bTagged->whichChild = SO_SWITCH_ALL;
707 std::cout << " ON" << std::endl;
708 }
709 else {
710 m_d->m_bTagged->whichChild = SO_SWITCH_NONE;
711 std::cout << " OFF" << std::endl;
712 }
713
714 // for debug: dumping the content of the whole node
715 // SoTools::dumpNode(m_d->sep);
716}
717
718//____________________________________________________________________
719double IParticleHandle_Jet::getBTaggingWeight(const std::string& tagger)
720{
721 double weight = 0.0;
722
723 const xAOD::BTagging * myBTag = nullptr;
724 myBTag = xAOD::BTaggingUtilities::getBTagging( *m_d->m_jet );
725
726 if (myBTag == nullptr) {
727 VP1Msg::messageWarningRed("It was not possible to access the pointer to b-tagging info, for the selected collection! Returning 'weight': 0.0"); //("It was not possible to access the tagger '"+ tagger +"' for the selected collection: " + m_d->m_jet->getInputType() + m_d->m_jet->getAlgorithmType() );
728 return weight;
729 }
730
731
732
733 // const xAOD::BTagging * myBTag = nullptr;
734 // myBTag = d->m_jet->btagging();
735
736 // if (myBTag == nullptr) {
737 // VP1Msg::messageWarningRed("It was not possible to access the pointer to b-tagging info, for the selected collection! Returning 'weight': 0.0"); //("It was not possible to access the tagger '"+ tagger +"' for the selected collection: " + d->m_jet->getInputType() + d->m_jet->getAlgorithmType() );
738 // return weight;
739 // }
740
741
742 // TODO: add the other taggers
743
744// if (tagger == "MV1")
745// weight = myBTag->MV1_discriminant();
746
747 /* these methods have been removed in xAODBTagging-00-00-35 (cfr. SVN changesets 797165 + 801102)
748 else if (tagger == "JetFitterCombNN_pb")
749 weight = myBTag->JetFitterCombNN_pb();
750 else if (tagger == "JetFitterCombNN_pc")
751 weight = myBTag->JetFitterCombNN_pc();
752 else if (tagger == "JetFitterCombNN_pu")
753 weight = myBTag->JetFitterCombNN_pu();
754 */
755
756// else if (tagger=="MV2c20")
757 if (tagger=="MV2c20")
758 /*const bool hasMv2c20 =*/ myBTag->MVx_discriminant("MV2c20", weight);
759 else if (tagger=="MV2c10")
760 /*const bool hasMv2c10 =*/ myBTag->MVx_discriminant("MV2c10", weight);
761 else if (tagger=="MV2c00")
762 /*const bool hasMv2c00 =*/ myBTag->MVx_discriminant("MV2c00", weight);
763 else
764 VP1Msg::message("Tagger '" + QString::fromStdString(tagger) + "' not found! Returning weight=0.0 ...");
765
766 return weight;
767}
768
769void IParticleHandle_Jet::dumpToJSON( std::ofstream& str) const {
770 str << "\"coneR\":"<<m_d->coneR() <<", ";
771 str << "\"phi\":" <<m_d->phi() <<", ";
772 str << "\"eta\":" <<m_d->eta() <<", ";
773 str << "\"energy\":" <<m_d->energyForLengthAndCuts();
774}
775
776
#define M_PI
Scalar theta() const
theta method
static Double_t sc
const AODCollHandleBase * collHandle() const
void updateMaterial()
Called after some configuration related to material changes.
QTreeWidgetItem * browserTreeItem() const
Return the QTreeWidgetItem;.
virtual void fillObjectBrowser(QList< QTreeWidgetItem * > &list)
Create and fill the object browser QTreeWidgetItem.
Header file for AthHistogramAlgorithm.
Base class for collections holding AOD objects of iParticle type Handles pt etc cuts Local data:
IParticleHandleBase(IParticleCollHandleBase *)
void updateConeHeightParameters(SoCone *, SoTranslation *, const double &energy) const
void createShapeFromJetParameters(const IParticleCollHandle_Jet *collHandleJet, const double &coneR, const double &eta, const double &phi, const double &energy, const SbVec3f &origin)
IParticleHandle_Jet * theclass
const IParticleCollHandle_Jet * theCollHandle
virtual void clear3DObjects()
Delete objects.
virtual double charge() const
Returns unknown() in case of trouble.
double getBTaggingWeight(const std::string &tagger)
void updateBTagging(const std::string &bTaggingTagger, const double &bTaggingCut)
IParticleHandle_Jet(IParticleCollHandleBase *, const xAOD::Jet *)
void setMaxR(const double &maxR)
virtual bool has3DObjects()
Returns true if the 3D objects have been created.
virtual void dumpToJSON(std::ofstream &) const
virtual SoNode * nodes()
Returns the 3Dobjects.
void fillObjectBrowser(QList< QTreeWidgetItem * > &listOfItems)
This gives the list of object's properties, shown in the 'Information' field in the Browser,...
void updateBTaggingSwitch(SoSwitch *bTaggingSwitch)
QString shortInfo() const
This returns the information shown about the object in the object browser.
void setScale(const double &sc, bool useEt)
const xAOD::IParticle & iParticle() const
virtual QStringList clicked() const
This gives the complete information about the object, shown in the main Message Box.
static void setMaterialParameters(SoMaterial *m, const QColor &, const double &brightness=0.0, const double &transp=0.0)
static void messageVerbose(const QString &)
Definition VP1Msg.cxx:84
static void message(const QString &, IVP1System *sys=0)
Definition VP1Msg.cxx:30
static void messageWarningRed(const QString &str, IVP1System *sys=0)
Definition VP1Msg.cxx:57
SoMaterial * material() const
static QString str(const QString &s)
Definition VP1String.h:49
bool MVx_discriminant(const std::string &taggername, double &value) const
Class providing the definition of the 4-vector interface.
const Amg::Vector3D & position() const
Returns the 3-pos.
bool exists(const std::string &filename)
does a file exist
int r
Definition globals.cxx:22
T * get(TKey *tobj)
get a TObject* from a TKey* (why can't a TObject be a TKey?)
Definition hcg.cxx:130
const BTagging * getBTagging(const SG::AuxElement &part)
Access the default xAOD::BTagging object associated to an object.
const std::string & algName(ID id)
Converts a JetAlgorithmType::ID into a string.
ID
//////////////////////////////////////// JetAlgorithmType::ID defines most common physics jet finding...
const std::string & typeName(Type id)
Jet_v1 Jet
Definition of the current "jet version".
BTagging_v1 BTagging
Definition of the current "BTagging version".
Definition BTagging.h:17
Vertex_v1 Vertex
Define the latest version of the vertex class.