ATLAS Offline Software
IParticleHandle_Jet.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2021 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 //____________________________________________________________________
52 public:
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;
73  double m_JetFitterCombNN_pb = 0.0;
74  double m_JetFitterCombNN_pc = 0.0;
75  double m_JetFitterCombNN_pu = 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
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 //____________________________________________________________________
152 void IParticleHandle_Jet::setScale( const double& sc, bool useEt) { m_d->scale = sc; m_d->considerTransverseEnergies= useEt;}
153 
154 //____________________________________________________________________
155 void IParticleHandle_Jet::setMaxR(const double& maxR) { m_d->maxR = maxR * SYSTEM_OF_UNITS::m; }
156 
157 //____________________________________________________________________
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;
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 //____________________________________________________________________
241 }
242 
243 
244 //____________________________________________________________________
245 void 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 
332  m_bTagged->addChild(m_bTaggingCollSwitch);
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 //_____________________________________________________________________________________
343 void 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 //____________________________________________________________________
409 Amg::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 //____________________________________________________________________
438 unsigned 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 //____________________________________________________________________
455 QStringList IParticleHandle_Jet::clicked() const
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 
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 //____________________________________________________________________
522 void 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 //____________________________________________________________________
566 double IParticleHandle_Jet::phi() const {
567  /*VP1Msg::messageVerbose("phi: " + QString::number(m_jet->phi()) );*/
568  return m_d->phi();
569 }
570 
571 
572 //____________________________________________________________________
573 double IParticleHandle_Jet::eta() const {
574  /*VP1Msg::messageVerbose("eta: " + QString::number(m_jet->eta()) );*/
575  return m_d->eta();
576 }
577 
578 
579 //____________________________________________________________________
580 double IParticleHandle_Jet::energy() const { return m_d->energy(); }
581 
582 
583 //____________________________________________________________________
585 
586 
587 //____________________________________________________________________
588 double 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 
636  VP1MaterialButton::setMaterialParameters(m_randomMat,r, g, b, 0.1, 0.5 );
637 }
638 
639 
640 //____________________________________________________________________
641 //void IParticleHandle_Jet::Imp::updateMaterial()
642 void 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 //____________________________________________________________________
675 void 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
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 //____________________________________________________________________
695 void 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 //____________________________________________________________________
719 double IParticleHandle_Jet::getBTaggingWeight(std::string tagger)
720 {
721  double weight = 0.0;
722 
723  const xAOD::BTagging * myBTag = nullptr;
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 
769 void 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 
IParticleHandle_Jet::Imp::m_randomMat
SoMaterial * m_randomMat
Definition: IParticleHandle_Jet.cxx:64
AODHandleBase::updateMaterial
void updateMaterial()
Called after some configuration related to material changes.
Definition: AODHandleBase.cxx:208
IParticleHandle_Jet::Imp::coneRPar
double coneRPar
Definition: IParticleHandle_Jet.cxx:82
beamspotman.r
def r
Definition: beamspotman.py:676
BTaggingUtilities.h
IParticleHandle_Jet::Imp
Definition: IParticleHandle_Jet.cxx:51
sendEI_SPB.ch
ch
Definition: sendEI_SPB.py:35
SoTools.h
IParticleHandle_Jet::Imp::m_bTagged
SoSwitch * m_bTagged
Definition: IParticleHandle_Jet.cxx:65
IParticleHandle_Jet::Imp::createShapeFromJetParameters
void createShapeFromJetParameters(const IParticleCollHandle_Jet *collHandleJet, const double &coneR, const double &eta, const double &phi, const double &energy, const SbVec3f &origin)
Definition: IParticleHandle_Jet.cxx:245
python.SystemOfUnits.m
int m
Definition: SystemOfUnits.py:91
IParticleHandle_Jet::Imp::updateConeHeightParameters
void updateConeHeightParameters() const
Definition: IParticleHandle_Jet.cxx:376
phi
Scalar phi() const
phi method
Definition: AmgMatrixBasePlugin.h:64
IParticleHandle_Jet::Imp::phi
double phi() const
Definition: IParticleHandle_Jet.cxx:93
IParticleHandle_Jet::Imp::sep
SoSeparator * sep
Definition: IParticleHandle_Jet.cxx:62
VP1StdCollection::material
SoMaterial * material() const
Definition: VP1StdCollection.cxx:220
IParticleHandle_Jet::iParticle
const xAOD::IParticle & iParticle() const
Definition: IParticleHandle_Jet.cxx:417
eta
Scalar eta() const
pseudorapidity method
Definition: AmgMatrixBasePlugin.h:79
Monitored::Z
@ Z
Definition: HistogramFillerUtils.h:24
VP1Msg.h
IParticleHandle_Jet::clear3DObjects
virtual void clear3DObjects()
Delete objects.
Definition: IParticleHandle_Jet.cxx:169
xAOD::Jet_v1::getAssociatedObject
const T * getAssociatedObject(const std::string &name) const
get a single associated object this compact form throws an exception if the object is not existing
xAOD::JetAlgorithmType::algName
const std::string & algName(ID id)
Converts a JetAlgorithmType::ID into a string.
Definition: JetContainerInfo.cxx:67
theta
Scalar theta() const
theta method
Definition: AmgMatrixBasePlugin.h:71
CSV_InDetExporter.new
new
Definition: CSV_InDetExporter.py:145
M_PI
#define M_PI
Definition: ActiveFraction.h:11
AODHandleBase::collHandle
const AODCollHandleBase * collHandle() const
Definition: AODHandleBase.h:55
AODHandleBase::fillObjectBrowser
virtual void fillObjectBrowser(QList< QTreeWidgetItem * > &list)
Create and fill the object browser QTreeWidgetItem.
Definition: AODHandleBase.cxx:288
IParticleHandle_Jet::transverseEnergy
double transverseEnergy() const
Definition: IParticleHandle_Jet.cxx:588
xAOD::Jet_v1::phi
virtual double phi() const
The azimuthal angle ( ) of the particle.
Definition: Jet_v1.cxx:54
UploadAMITag.l
list l
Definition: UploadAMITag.larcaf.py:158
IParticleHandle_Jet::Imp::updateConeHeightParameters
void updateConeHeightParameters(SoCone *, SoTranslation *, const double &energy) const
Definition: IParticleHandle_Jet.cxx:343
xAOD::Vertex_v1::position
const Amg::Vector3D & position() const
Returns the 3-pos.
IParticleHandle_Jet::Imp::transverseEnergy
double transverseEnergy() const
Definition: IParticleHandle_Jet.cxx:96
xAOD::Jet_v1::getAlgorithmType
JetAlgorithmType::ID getAlgorithmType() const
Definition: Jet_v1.cxx:249
drawFromPickle.exp
exp
Definition: drawFromPickle.py:36
xAOD::IParticle
Class providing the definition of the 4-vector interface.
Definition: Event/xAOD/xAODBase/xAODBase/IParticle.h:40
xAOD::Jet_v1::getInputType
JetInput::Type getInputType() const
Definition: Jet_v1.cxx:253
yodamerge_tmp.scale
scale
Definition: yodamerge_tmp.py:138
xAOD::JetInput::typeName
const std::string & typeName(Type id)
Definition: JetContainerInfo.cxx:199
VP1String::str
static QString str(const QString &s)
Definition: VP1String.h:49
IParticleHandle_Jet::clicked
virtual QStringList clicked() const
This gives the complete information about the object, shown in the main Message Box.
Definition: IParticleHandle_Jet.cxx:455
drawFromPickle.atan
atan
Definition: drawFromPickle.py:36
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
IParticleHandle_Jet::getBTaggingWeight
double getBTaggingWeight(std::string tagger)
Definition: IParticleHandle_Jet.cxx:719
IParticleHandle_Jet::Imp::energy
double energy() const
Definition: IParticleHandle_Jet.cxx:95
IParticleHandle_Jet::~IParticleHandle_Jet
virtual ~IParticleHandle_Jet()
Definition: IParticleHandle_Jet.cxx:138
Monitored::X
@ X
Definition: HistogramFillerUtils.h:24
IParticleHandle_Jet::Imp::m_JetFitterCombNN_pb
double m_JetFitterCombNN_pb
Definition: IParticleHandle_Jet.cxx:73
dqt_zlumi_pandas.weight
int weight
Definition: dqt_zlumi_pandas.py:200
IParticleHandle_Jet
Definition: IParticleHandle_Jet.h:32
IParticleHandle_Jet::dumpToJSON
virtual void dumpToJSON(std::ofstream &) const
Definition: IParticleHandle_Jet.cxx:769
IParticleHandle_Jet::nodes
virtual SoNode * nodes()
Returns the 3Dobjects.
Definition: IParticleHandle_Jet.cxx:193
xAOD::Jet_v1::pz
float pz() const
The z-component of the jet's momentum.
Definition: Jet_v1.cxx:99
xAOD::Jet_v1::type
virtual Type::ObjectType type() const
The type of the object as a simple enumeration.
Definition: Jet_v1.cxx:85
xAOD::JetAttribute::OriginVertex
@ OriginVertex
Definition: JetAttributes.h:255
jet
Definition: JetCalibTools_PlotJESFactors.cxx:23
jobOptions_CavernBackground.inputType
inputType
Definition: jobOptions_CavernBackground.py:21
LArG4FSStartPointFilter.rand
rand
Definition: LArG4FSStartPointFilter.py:80
ParticleGun_FastCalo_ChargeFlip_Config.energy
energy
Definition: ParticleGun_FastCalo_ChargeFlip_Config.py:78
IParticleCollHandle_Jet
Definition: IParticleCollHandle_Jet.h:26
lumiFormat.i
int i
Definition: lumiFormat.py:92
IParticleHandle_Jet::m_d
Imp * m_d
Definition: IParticleHandle_Jet.h:82
IParticleHandle_Jet::charge
virtual double charge() const
Returns unknown() in case of trouble.
Definition: IParticleHandle_Jet.cxx:424
VP1MaterialButton::setMaterialParameters
static void setMaterialParameters(SoMaterial *m, const QColor &, const double &brightness=0.0, const double &transp=0.0)
Definition: VP1MaterialButton.cxx:802
python.CaloCondTools.g
g
Definition: CaloCondTools.py:15
xAOD::Jet_v1::getSizeParameter
float getSizeParameter() const
Definition: Jet_v1.cxx:245
IParticleHandle_Jet::Imp::m_bTagWeightMV1
double m_bTagWeightMV1
Definition: IParticleHandle_Jet.cxx:70
extractSporadic.h
list h
Definition: extractSporadic.py:97
IParticleHandle_Jet::Imp::theclass
IParticleHandle_Jet * theclass
Definition: IParticleHandle_Jet.cxx:57
IParticleHandleBase
Definition: IParticleHandleBase.h:42
IParticleHandle_Jet::Imp::rerandomiseMaterial
void rerandomiseMaterial()
Definition: IParticleHandle_Jet.cxx:592
IParticleHandle_Jet::Imp::energyForLengthAndCuts
double energyForLengthAndCuts() const
Definition: IParticleHandle_Jet.cxx:98
IParticleHandle_Jet::shortInfo
QString shortInfo() const
This returns the information shown about the object in the object browser.
Definition: IParticleHandle_Jet.cxx:501
IParticleHandle_Jet::energyForCuts
double energyForCuts() const
Definition: IParticleHandle_Jet.cxx:584
IParticleHandle_Jet::Imp::cone
SoCone * cone
Definition: IParticleHandle_Jet.cxx:63
AODHandleBase::browserTreeItem
QTreeWidgetItem * browserTreeItem() const
Return the QTreeWidgetItem;.
Definition: AODHandleBase.cxx:311
drawFromPickle.tan
tan
Definition: drawFromPickle.py:36
IParticleHandle_Jet::eta
double eta() const
Definition: IParticleHandle_Jet.cxx:573
IParticleHandle_Jet::Imp::m_JetFitterCombNN_pc
double m_JetFitterCombNN_pc
Definition: IParticleHandle_Jet.cxx:74
IParticleHandle_Jet::Imp::scale
double scale
Definition: IParticleHandle_Jet.cxx:83
xAOD::JetAlgorithmType::ID
ID
//////////////////////////////////////// JetAlgorithmType::ID defines most common physics jet finding...
Definition: JetContainerInfo.h:29
IParticleHandle_Jet::Imp::pt
double pt() const
Definition: IParticleHandle_Jet.cxx:92
IParticleHandle_Jet::energy
double energy() const
Definition: IParticleHandle_Jet.cxx:580
xAOD::Jet_v1::py
float py() const
The y-component of the jet's momentum.
Definition: Jet_v1.cxx:94
IParticleHandle_Jet::Imp::m_jet
const xAOD::Jet * m_jet
Definition: IParticleHandle_Jet.cxx:60
xAOD::BTagging_v1
Definition: BTagging_v1.h:39
xAOD::JetInput::Type
Type
Definition: JetContainerInfo.h:54
AODSysCommonData.h
IParticleHandle_Jet::updateBTagging
void updateBTagging(const std::string &bTaggingTagger, const double &bTaggingCut)
Definition: IParticleHandle_Jet.cxx:695
xAOD::Jet_v1::rapidity
virtual double rapidity() const
The true rapidity (y) of the particle.
Definition: Jet_v1.cxx:67
IParticleHandle_Jet::Imp::considerTransverseEnergies
bool considerTransverseEnergies
Definition: IParticleHandle_Jet.cxx:81
xAOD::Jet_v1::eta
virtual double eta() const
The pseudorapidity ( ) of the particle.
Definition: Jet_v1.cxx:49
min
#define min(a, b)
Definition: cfImp.cxx:40
grepfile.sep
sep
Definition: grepfile.py:38
BTaggingContainer.h
IParticleHandle_Jet::rerandomiseMaterial
void rerandomiseMaterial()
Definition: IParticleHandle_Jet.cxx:158
python.selection.number
number
Definition: selection.py:20
xAOD::Jet_v1::px
float px() const
The x-component of the jet's momentum.
Definition: Jet_v1.cxx:90
plotBeamSpotMon.b
b
Definition: plotBeamSpotMon.py:77
IParticleHandle_Jet::Imp::m_JetFitterCombNN_pu
double m_JetFitterCombNN_pu
Definition: IParticleHandle_Jet.cxx:75
IParticleHandle_Jet::Imp::m_bTagWeightMV2c10
double m_bTagWeightMV2c10
Definition: IParticleHandle_Jet.cxx:72
VP1Msg::messageVerbose
static void messageVerbose(const QString &)
Definition: VP1Msg.cxx:84
IParticleCollHandle_Jet.h
IParticleHandle_Jet::Imp::m_bTaggingCollSwitch
SoSwitch * m_bTaggingCollSwitch
Definition: IParticleHandle_Jet.cxx:66
IParticleHandle_Jet::setScale
void setScale(const double &sc, bool useEt)
Definition: IParticleHandle_Jet.cxx:152
IParticleHandle_Jet::has3DObjects
virtual bool has3DObjects()
Returns true if the 3D objects have been created.
Definition: IParticleHandle_Jet.cxx:161
IParticleHandle_Jet::Imp::maxR
double maxR
Definition: IParticleHandle_Jet.cxx:84
xAOD::BTaggingUtilities::getBTagging
const BTagging * getBTagging(const SG::AuxElement &part)
Access the default xAOD::BTagging object associated to an object.
Definition: BTaggingUtilities.cxx:37
JetCollectionSettingsButton.h
xAOD::Jet_v1
Class describing a jet.
Definition: Jet_v1.h:57
VertexContainer.h
IParticleHandle_Jet::phi
double phi() const
Definition: IParticleHandle_Jet.cxx:566
xAOD::Jet_v1::m
virtual double m() const
The invariant mass of the particle.
Definition: Jet_v1.cxx:59
h
xAOD::Vertex_v1
Class describing a Vertex.
Definition: Vertex_v1.h:42
VP1Msg::message
static void message(const QString &, IVP1System *sys=0)
Definition: VP1Msg.cxx:30
xAOD::Jet_v1::e
virtual double e() const
The total energy of the particle.
Definition: Jet_v1.cxx:63
IParticleHandle_Jet::IParticleHandle_Jet
IParticleHandle_Jet(IParticleCollHandleBase *, const xAOD::Jet *)
Definition: IParticleHandle_Jet.cxx:112
IParticleHandle_Jet::Imp::m_bTagWeightMV2c20
double m_bTagWeightMV2c20
Definition: IParticleHandle_Jet.cxx:71
IParticleHandle_Jet::updateBTaggingSwitch
void updateBTaggingSwitch(SoSwitch *bTaggingSwitch)
Definition: IParticleHandle_Jet.cxx:675
IParticleHandle_Jet::Imp::eta
double eta() const
Definition: IParticleHandle_Jet.cxx:94
get
T * get(TKey *tobj)
get a TObject* from a TKey* (why can't a TObject be a TKey?)
Definition: hcg.cxx:127
IParticleHandle_Jet::setMaxR
void setMaxR(const double &maxR)
Definition: IParticleHandle_Jet.cxx:155
str
Definition: BTagTrackIpAccessor.cxx:11
VP1Msg::messageWarningRed
static void messageWarningRed(const QString &str, IVP1System *sys=0)
Definition: VP1Msg.cxx:57
IParticleHandle_Jet::Imp::theCollHandle
const IParticleCollHandle_Jet * theCollHandle
Definition: IParticleHandle_Jet.cxx:58
python.dummyaccess.exists
def exists(filename)
Definition: dummyaccess.py:9
drawFromPickle.sin
sin
Definition: drawFromPickle.py:36
IParticleHandle_Jet::updateHeight
void updateHeight()
Definition: IParticleHandle_Jet.cxx:239
xAOD::Jet_v1::numConstituents
size_t numConstituents() const
Number of constituents in this jets (this is valid even when reading a file where the constituents ha...
Definition: Jet_v1.cxx:153
IParticleCollHandleBase
Base class for collections holding AOD objects of iParticle type Handles pt etc cuts Local data:
Definition: IParticleCollHandleBase.h:50
xAOD::Jet_v1::pt
virtual double pt() const
The transverse momentum ( ) of the particle.
Definition: Jet_v1.cxx:44
GeV
#define GeV
Definition: CaloTransverseBalanceVecMon.cxx:30
IParticleHandle_Jet::fillObjectBrowser
void fillObjectBrowser(QList< QTreeWidgetItem * > &listOfItems)
This gives the list of object's properties, shown in the 'Information' field in the Browser,...
Definition: IParticleHandle_Jet.cxx:522
IParticleHandle_Jet.h
IParticleHandle_Jet::Imp::coneR
double coneR() const
Definition: IParticleHandle_Jet.cxx:97
xAOD::BTagging_v1::MVx_discriminant
bool MVx_discriminant(const std::string &taggername, double &value) const
Definition: BTagging_v1.cxx:381