ATLAS Offline Software
Loading...
Searching...
No Matches
IParticleCollHandle_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 IParticleCollHandle_Jet //
9// //
10// Author: Riccardo-Maria BIANCHI (rbianchi@cern.ch) //
11// Initial version: May 2014 //
12// //
14
15//Local
17#include "IParticleHandle_Jet.h"
19#include "AODSysCommonData.h"
20
21//VP1
22#include "VP1Base/IVP1System.h"
23#include "VP1Base/VP1Msg.h"
26#ifndef BUILDVP1LIGHT
29#endif // BUILDVP1LIGHT
30
31//Qt
32#include <QStringList>
33
34//xAOD
36
37
38// Coin3D
39#include <Inventor/C/errors/debugerror.h>
40#include <Inventor/nodes/SoSeparator.h>
41#include <Inventor/nodes/SoSwitch.h>
42#include <Inventor/nodes/SoMaterial.h>
43//#include "Inventor/nodes/SoDrawStyle.h"
44//#include "Inventor/nodes/SoLightModel.h"
45#include <Inventor/nodes/SoTexture2.h>
46
48
49#ifdef BUILDVP1LIGHT
50 #include <QSettings>
51 #include "xAODRootAccess/Init.h"
53#endif // BUILDVP1LIGHT
54
55// System of units
56#ifdef BUILDVP1LIGHT
57 #include "GeoModelKernel/Units.h"
58 #define SYSTEM_OF_UNITS GeoModelKernelUnits // --> 'GeoModelKernelUnits::cm'
59#else
60 #include "GaudiKernel/SystemOfUnits.h"
61 #define SYSTEM_OF_UNITS Gaudi::Units // --> 'Gaudi::Units::cm'
62#endif
63
64//____________________________________________________________________
65#if defined BUILDVP1LIGHT
67 {
68 return sys->getObjectList(xAOD::Type::Jet);
69 }
70#else
75#endif // BUILDVP1LIGHT
76
77//____________________________________________________________________
79public:
80
81 Imp () : theclass(nullptr), updateGUICounter(0), collSettingsButton(nullptr), scale(1.0),
82 randomColours(false), m_jetMaterialDefault(nullptr), bTaggingTagger("MV1"),
83 bTaggingCut(0.98), bTaggingSwitch(nullptr),
84 bTaggingTexture(nullptr), bTaggingMaterial(nullptr) {}
85
86 QString name;
87
91 #ifdef BUILDVP1LIGHT
92 QStringList jetList;
93 #endif // BUILDVP1LIGHT
94
95 // settings
96 double scale = 1.0; // dummy value. The actual default value is set in the IParticleHandle_Jet::Imp class definition.
97 bool randomColours = false;
98 bool isMaxR = false; // default
99 double maxR = 1.0; // dummy value. The actual default value is set in the IParticleHandle_Jet::Imp class definition.
100
101 // jet materials
103
104 // b-tagging
105 std::string bTaggingTagger;
107 SoSwitch *bTaggingSwitch;
108 SoTexture2* bTaggingTexture;
109 SoMaterial* bTaggingMaterial;
110
111
112 // SoMaterial* defaultParametersMaterial; /// This will be given to the VP1MaterialButton in
113
114
115
116 void possiblyUpdateGUI() {//Fixme: to IParticleCollHandleBase
117 if (!((updateGUICounter++)%50)) {
118 theclass->systemBase()->updateGUI();
119 }
120 }
121};
122
123//____________________________________________________________________
125const QString& name, xAOD::Type::ObjectType type)
127{
128 m_d->theclass = this;
129 m_d->updateGUICounter = 0;
130 m_d->collSettingsButton=0;
131
132 m_d->name = name;
133
134 //==========
135 // b-tagging
136 m_d->bTaggingSwitch=new SoSwitch;
137 m_d->bTaggingSwitch->whichChild=SO_SWITCH_ALL;
138 // new b-tagged jets and material
139 m_d->bTaggingTexture = new SoTexture2;
140 m_d->bTaggingMaterial = new SoMaterial;
141
142
143 //The object names should not contain all sorts of funky chars (mat button style sheets wont work for instance):
144 QString safetext(text());
145 safetext.replace(' ','_');
146 safetext.replace('[','_');
147 safetext.replace(']','_');
148 safetext.replace('/','_');
149 safetext.replace('.','_');
150 safetext.replace(',','_');
151 safetext.replace('<','_');
152 safetext.replace('>','_');
153 safetext.replace('&','_');
154
155 // m_d->defaultParametersMaterial = new SoMaterial;
156 // m_d->defaultParametersMaterial->setName(("IParticleCollHandle_Jet"+safetext).toStdString().c_str());
157 // m_d->defaultParametersMaterial->ref();
158 // m_d->matButton->setDefaultParameterMaterial(m_d->defaultParametersMaterial); FIXME
159}
160
161//____________________________________________________________________
163{
164 // m_d->defaultParametersMaterial->unref();
165
166 if (m_d->bTaggingSwitch) m_d->bTaggingSwitch->unref();
167
168 delete m_d;
169}
170
171//____________________________________________________________________
173{
174 messageDebug("IParticleCollHandle_Jet::init()");
175
176 m_d->collSettingsButton = new JetCollectionSettingsButton(0, 25, m_d->name); // 0 and 25 are default values
177 m_d->collSettingsButton->setMaterialText(name());
178
179 // 1st - CALLING THE "init" OF THE BASE CLASS
180 // NOTE!!
181 // It must be called before other material/button settings,
182 // otherwise they get overridden
183 // std::cout<<"Calling VP1StdCollection::init with m_d->matButton (JetCollectionSettingsButton)="<<m_d->matButton<<std::endl;
184 VP1StdCollection::init(m_d->collSettingsButton); //--->this call is required!! Passing in m_d->collSettingsButton means we have the more complex button that allows cuts
185 setupSettingsFromController(common()->controller());
186 connect(this,SIGNAL(visibilityChanged(bool)),this,SLOT(collVisibilityChanged(bool)));
187
188
189 // create semi-transparent material for all jets, with the default color
190 m_d->m_jetMaterialDefault = VP1MaterialButton::createMaterial(defaultColor(), 0.2, 0.3); // RGBcolor, brightness, transparency
191 m_d->m_jetMaterialDefault->ref();
192 // init material for all jets
193 m_d->collSettingsButton->setMaterial(m_d->m_jetMaterialDefault);
194 messageVerbose("set new jet color=" + str(m_d->collSettingsButton->getMaterialButton()->lastAppliedDiffuseColour()));
195
196
197 // std::cout<<"IParticleCollHandle_Jet::init 2"<<std::endl;
198 // std::cout<<"swi: "<<collSwitch()<<std::endl;
199 // std::cout<<"sep: "<<collSep()<<std::endl;
200 // std::cout<<"mat: "<<material()<<std::endl;
201
202 // collSwitch()->addChild(m_d->collSettingsButton->trackLightModel()); // TODO: update for jets
203 // collSwitch()->addChild(m_d->collSettingsButton->trackDrawStyle()); // TODO: update for jets
204
205 //==========
206 // b-tagging
207 if(m_d->collSettingsButton->is_bTaggingSkinEnabled()) {
208 setBTaggingSkin(m_d->collSettingsButton->bTaggingSkin());
209 // m_d->bTaggingSwitch->addChild(m_d->bTaggingTexture);
210 }
211 else if (m_d->collSettingsButton->is_bTaggingMaterialEnabled()) {
213 // m_d->bTaggingMaterial = controller->bTaggingMaterial();
214 // m_d->bTaggingSwitch->addChild(m_d->bTaggingMaterial);
215 }
216 else {
217 messageVerbose("Info - No b-tag rendering selected.");
218 }
219
220 // we want these nodes to stay around even when removed from nodes, thus we increment the ref count by one
221 m_d->bTaggingSwitch->ref();
222 // m_d->bTaggingTexture->ref();
223 // m_d->bTaggingMaterial->ref();
224
225}
226
227
228//____________________________________________________________________
230{
231 messageDebug("IParticleCollHandle_Jet::setupSettingsFromControllerSpecific()");
232
233 JetCollectionSettingsButton* controller = m_d->collSettingsButton;
234
235 //cuts
236 connect(controller,SIGNAL(cutAllowedPtChanged(const VP1Interval&)),this,SLOT(setCutAllowedPt(const VP1Interval&)));
237 setCutAllowedPt(controller->cutAllowedPt());
238
239 connect(controller,SIGNAL(cutAllowedEtaChanged(const VP1Interval&)),this,SLOT(setCutAllowedEta(const VP1Interval&)));
240 setCutAllowedEta(controller->cutAllowedEta());
241
242 connect(controller,SIGNAL(cutAllowedPhiChanged(const QList<VP1Interval>&)),this,SLOT(setCutAllowedPhi(const QList<VP1Interval>&)));
243 setCutAllowedPhi(controller->cutAllowedPhi());
244
245 // // Parameters
246 // connect(controller,SIGNAL(showParametersChanged(bool)), this,SLOT(showParametersChanged(bool)));
247 // connect(controller,SIGNAL(colourParametersByTypeChanged(bool)),this,SLOT(showParametersChanged(bool)));
248 // Just reusing the same slot, since it doesn't
249
250 // scale
251 connect(controller,SIGNAL(scaleChanged(const double&)),this,SLOT(setScale(const double&)));
252 setScale( this->scale() );
253
254 // random jet colors
255 connect(controller,SIGNAL(rerandomise()),this,SLOT(rerandomise()));
256 connect(controller,SIGNAL(randomJetColoursChanged(const bool&)),this,SLOT(setRandomJetColours(const bool&)));
258
259 // maxR
260 connect(controller, SIGNAL(maxRChanged(const double&)), this, SLOT(setMaxR(const double&)));
261
262 // b-tagging
263 connect(controller, SIGNAL(bTaggingEnabledChanged(const bool&)), this, SLOT(setBTaggingEnabled(const bool&)));
264 setBTaggingEnabled(controller->bTaggingEnabled());
265 connect(controller, SIGNAL(bTaggingTaggerChanged(const QString &)), this, SLOT(setBTaggingTagger(const QString &)));
266 setBTaggingTagger(controller->bTaggingTagger());
267 connect(controller, SIGNAL(bTaggingCutChanged(const double &)), this, SLOT(setBTaggingCut(const double &)));
268 setBTaggingCut(controller->bTaggingCut());
269 connect(controller,SIGNAL(bTaggingRenderingMaterialChanged(const bool&)), this, SLOT(setBTaggingMaterialChanged(const bool&)));
270
271 connect(controller,SIGNAL(bTaggingRenderingSkinChanged(const bool&)), this, SLOT(setBTaggingSkinChanged(const bool&)));
272}
273
274//SoMaterial* IParticleCollHandle_Jet::defaultParameterMaterial() const {
275// return m_d->defaultParametersMaterial;
276//}
277
278
280 if (!m_d->collSettingsButton){
281 messageVerbose("Jet - No collSettingsButton set! Can't call init(), so crash is imminent...");
282 throw std::runtime_error("Jet - No collSettingsButton set!");
283 }
284 return *m_d->collSettingsButton;
285}
286
287
288
289//____________________________________________________________________
291{
292
293 messageVerbose("IParticleCollHandle_Jet::setScale() - scale: " + QString::number(sca));
294
295 if (getHandlesList().isEmpty()) {
296 messageVerbose("no jet handles defined! returning.");
297 return;
298 }
299 if (m_d->scale == sca)
300 return;
301
302 bool isEt = sca>0;
303 double tmpScale = std::max(1*SYSTEM_OF_UNITS::mm/(100*SYSTEM_OF_UNITS::GeV),
304 std::min(99*SYSTEM_OF_UNITS::m/(1*SYSTEM_OF_UNITS::MeV),
305 // m_d->collSettingsButton->lengthOf100GeV() * Gaudi::Units::m/(100.0*Gaudi::Units::GeV)));
306 std::fabs(sca) * SYSTEM_OF_UNITS::m/(100.0*SYSTEM_OF_UNITS::GeV)));
307
308 m_d->scale = isEt ? tmpScale : -tmpScale;
309
310 if (!isLoaded())
311 return;
312
313 messageVerbose("Scale change: to "+str(m_d->scale/(SYSTEM_OF_UNITS::m/(100.0 * SYSTEM_OF_UNITS::GeV)))+" m/100GeV. Updating "+str(getHandlesList().count())+" jets");
314 // std::cout << "Scale change: d->scale/(SYSTEM_OF_UNITS::m/(100.0*SYSTEM_OF_UNITS::GeV)))" << "m/100GeV. Updating " << getHandlesList().count() << " jets" << std::endl;
315
318 AODHandleBase* handle=0;
319 while ((handle=getNextHandle()))
320 {
321 IParticleHandle_Jet* jet = dynamic_cast<IParticleHandle_Jet*>(handle);
322 if (jet && jet->has3DObjects()) {
323 jet->setScale(tmpScale, isEt);
324 jet->updateHeight();
325 } else {
326 message("ERROR Handle of wrong type!");
327 }
328 }
330}
331
332//____________________________________________________________________
334{
335 return m_d->scale;
336}
337
338//____________________________________________________________________
340{
341 return m_d->maxR;
342}
343
344
345//____________________________________________________________________
347{
348 messageVerbose("IParticleCollHandle_Jet::setMaxR() - maxR: " + QString::number(maxR));
349 // messageVerbose("setMaxR to: " + str(maxR)+str(", from: ")+str(m_d->maxR));
350
351 if (m_d->maxR == maxR){ // no changes
352 messageDebug("no changes, returning...");
353 return;
354 }
355
356 m_d->maxR = maxR;
357
358 if (!isLoaded()) {
359 messageDebug("is not loaded, returning...");
360 return;
361 }
362
363 messageDebug("modifying MaxR for all jets...");
366 AODHandleBase* handle=0;
367 while ((handle=getNextHandle()))
368 {
369 IParticleHandle_Jet* jet = dynamic_cast<IParticleHandle_Jet*>(handle);
370 if (jet && jet->has3DObjects()) {
371 jet->setMaxR(m_d->maxR);
372 jet->updateHeight();
373 } else {
374 message("ERROR Handle of wrong type!");
375 }
376 }
378}
379
380
381//____________________________________________________________________
383{
384 VP1Msg::messageVerbose("IParticleCollHandle_Jet::isRandomColors()");
385 return m_d->randomColours;
386}
387
389//bool IParticleCollHandle_Jet::isMaxR() const
390//{
391// VP1Msg::messageVerbose("IParticleCollHandle_Jet::isMaxR()");
392// return m_d->isMaxR;
393//}
394
395
396//____________________________________________________________________
398{
399 messageVerbose("IParticleCollHandle_Jet::setRandomJetColours() - b: "+QString::number(b));
400
401 if (m_d->randomColours == b)
402 return;
403
404 m_d->randomColours = b;
405
406 if (!isLoaded())
407 return;
408
410 int ijet = 0;
412 AODHandleBase* handle=0;
413 while ((handle=getNextHandle()))
414 {
415 ++ijet;
416 IParticleHandle_Jet* jet = dynamic_cast<IParticleHandle_Jet*>(handle);
417 if (jet && jet->has3DObjects()) {
418 messageVerbose("considering jet: "+QString::number(ijet));
419 int randomColors = isRandomColors();
420 messageVerbose("setting random material on jet: "+QString::number(ijet)+" - random colors? "+QString::number(randomColors));
421 // std::cout << "isRandomColors() --> " << isRandomColors() << std::endl;
422 jet->updateMaterial( randomColors );
423
424 } else {
425 message("ERROR Handle of wrong type!");
426 }
427 }
429}
430
431//____________________________________________________________________
433{
434 messageVerbose("IParticleCollHandle_Jet::rerandomise()");
435
436 if (!isLoaded()) {
437 messageVerbose("IParticleCollHandle_Jet::rerandomise() - Returning.");
438 return;
439 }
440 if (!isRandomColors()) {
441 VP1Msg::message("'Random jet colours' is not checked. Nothing to do. Returning.");
442 return;
443 }
444
447 AODHandleBase* handle=0;
448 while ((handle=getNextHandle()))
449 {
450 IParticleHandle_Jet* jet = dynamic_cast<IParticleHandle_Jet*>(handle);
451 if (jet && jet->has3DObjects()) {
452 jet->rerandomiseMaterial();
453 } else {
454 message("ERROR Handle of wrong type!");
455 }
456 }
458}
459
460//____________________________________________________________________
462{
463 messageVerbose("loading Jet collection");
464
465 //Get collection:
466 const xAOD::JetContainer * coll(nullptr);
467
468 #if defined BUILDVP1LIGHT
469 // // Get the name of the application:
470 // const char* appName = "VP1Light";
471
472 // // Initialize the environment:
473 // if( !xAOD::Init( appName ).isSuccess() ) {
474 // message("Failed to execute xAOD::Init");
475 // return false;
476 // }
477
478 // Retrieve objects from the event
479 if( !(systemBase()->getEvent())->retrieve( coll, name().toStdString()).isSuccess() ) {
480 QString errMsg = "Failed to retrieve " + name();
481 message("Error: Could not retrieve collection with key="+name());
482 return false;
483 }
484 #else
485 if (!VP1SGAccessHelper(systemBase()).retrieve(coll, name())) {
486 message("Error: Could not retrieve Jet collection with key="+name());
487 return false;
488 } else {
489 messageDebug("Jet collection '"+name()+"' loaded");
490 }
491 #endif // BUILDVP1LIGHT
492
493
494 // // Retrieve the xAOD particles:
495 // const xAOD::JetContainer* xaod = evtStore()->retrieve<const xAOD::JetContainer>( m_JetCollection );
496
497 // Check that the auxiliary store association was made successfully:
498 if( ! coll->hasStore() ) {
499 message("No auxiliary store got associated to the Jet container with key: " +name());
500 }
501
502 // This is needed for now, until the issues around the DV code are
503 // sorted out...
504 const_cast< xAOD::JetContainer* >( coll )->setStore(
505 ( SG::IAuxStore* ) coll->getConstStore() );
506
507 //Make appropriate Jet handles:
508 // hintNumberOfTracksInEvent(coll->size());
509 xAOD::JetContainer::const_iterator it, itEnd = coll->end();
510 for ( it = coll->begin() ; it != itEnd; ++it) {
511 m_d->possiblyUpdateGUI();
512 if (!*it) {
513 messageDebug("WARNING: Ignoring null Jet pointer.");
514 continue;
515 }
516 /*
517 if ((*it)->charge()==0.0) {
518 messageDebug("WARNING: Ignoring which claims to be neutral (charge()==0.0).");
519 continue;
520 }
521 */
522 addHandle(new IParticleHandle_Jet(this,*it));
523 }
524
525 // get handles list and update locally
526 // m_d->jets = this->getHandlesList();
527
528 return true;
529}
530
531//Cuts:
532//____________________________________________________________________
534 messageVerbose("IParticleCollHandle_Jet::cut()");
535
536 if (IParticleHandle_Jet* handle = dynamic_cast<IParticleHandle_Jet*>(c))
537 {
538
539 //------ ENERGY CUTS
540 messageVerbose("jet's energy, allowedPt^2, PtAll: - " + QString::number(handle->energyForCuts()) + " - " + getCutAllowedPt().toString() + " - " + QString::number(int(getPtAllowall())) );
541 double jEnergy = handle->energyForCuts();
542 double jEnergySqr = jEnergy * jEnergy; // in IParticleCollHandleBase the allowedPt is stored as squared, to avoid square-root operations
543 if (!getPtAllowall() && !getCutAllowedPt().contains(jEnergySqr) ) {
544 messageVerbose("Pt cut not passed");
545 return false;
546 } else {
547 messageVerbose("Pt cut passed!!");
548 }
549
550 //------ ETA CUTS
551 messageVerbose("jet's eta, etaCut, EtaAll: " + QString::number(handle->eta()) + " - " + getCutAllowedEta().toString() + " - " + QString::number(int(getEtaAllowall())) );
552 if (!getEtaAllowall() && !getCutAllowedEta().contains(handle->eta())) {
553 messageVerbose("Eta cut not passed");
554 return false;
555 }
556
557 //------ PHI CUTS
558 if (!getPhiAllowall() ) {
559 double phi = handle->phi();
560 bool ok(false);
561 for (const VP1Interval& phirange : getCutAllowedPhi() ) {
562 messageVerbose("jet's phi, phiCut, PhiAll: " + QString::number(phi) + " - " + phirange.toString() + " - " + QString::number(int(getPhiAllowall())) );
563 if (phirange.contains(phi)||phirange.contains(phi+2*M_PI)||phirange.contains(phi-2*M_PI)) {
564 ok = true;
565 break;
566 }
567 }
568 if (!ok) {
569 messageVerbose("Phi cut not passed");
570 return false;
571 }
572 }
573
574 //------ OTHER CUTS
575 messageVerbose("Other cuts??? Calling base method...");
576 if (!IParticleCollHandleBase::cut(handle))
577 return false;
578
579 } // if(dynamic_cast)
580 else{
581 messageVerbose("Not a IParticleCollHandle_Jet. Calling base method...");
582 if (!IParticleCollHandleBase::cut(handle))
583 return false;
584 }
585
586 return true; //default
587
588}
589
590
591
592//____________________________________________________________________
594 messageVerbose("IParticleCollHandle_Jet::showParametersChanged to "+str(val));
596}
597
598
599//____________________________________________________________________
601 messageVerbose("IParticleCollHandle_Jet::setBTaggingEnabled - "+str(flag));
602 m_d->bTaggingSwitch->whichChild = (flag ? SO_SWITCH_ALL : SO_SWITCH_NONE);
603 if (flag) {
604 setBTaggingMaterialChanged(true); // we set default "Material"
605 }
606}
607
608
609//____________________________________________________________________
610void IParticleCollHandle_Jet::setBTaggingSkin(const QString &filename){
611
612 if (m_d->collSettingsButton->bTaggingRenderingSkin()) {
613
614 //remove the previous skin and material
615 m_d->bTaggingSwitch->removeChild(m_d->bTaggingTexture);
616 m_d->bTaggingSwitch->removeChild(m_d->bTaggingMaterial);
617 // delete m_d->bTaggingTexture;
618 // delete m_d->bTaggingMaterial;
619 m_d->bTaggingTexture = 0;
620 m_d->bTaggingMaterial = 0;
621
622 // setting the texture
623 m_d->bTaggingTexture = new SoTexture2;
624 m_d->bTaggingMaterial = new SoMaterial;
625
626 // original from Joe, for skins/textures
627 std::string fName = PathResolver::find_file (filename.toStdString()+".png", "DATAPATH");
628 messageVerbose("texture found: " + QString::fromStdString(fName) );
629 m_d->bTaggingTexture->filename.setValue(fName.c_str());
630
631 // adding the texture to the SoSwitch
632 m_d->bTaggingSwitch->addChild(m_d->bTaggingTexture);
633 }
634
635 updateBTaggingSwitchAllJets(); // update switch all jets
636 updateBTaggingAllJets(); // update cut for all jets
637}
638
639//____________________________________________________________________
641{
642 messageVerbose("IParticleCollHandle_Jet::setBTaggingMaterial()");
643
644 if (m_d->collSettingsButton->bTaggingRenderingMaterial()) {
645
646 messageVerbose("Updating the material node");
647
648 //remove the previous skin and material
649 m_d->bTaggingSwitch->removeChild(m_d->bTaggingTexture);
650 m_d->bTaggingSwitch->removeChild(m_d->bTaggingMaterial);
651 // delete m_d->bTaggingTexture;
652 // delete m_d->bTaggingMaterial;
653 m_d->bTaggingTexture = 0;
654 m_d->bTaggingMaterial = 0;
655
656 // float r = 0.4; float g = 0.15; float b = 0.0; float br = 0.8; float tr = 0.3; // reddish color
657 // VP1MaterialButton::setMaterialParameters( mat, r, g, b, br /*brightness*/, tr /*transparency*/ );
658
659 if (! mat) {
660 messageVerbose("taking the material from the controller");
661 m_d->bTaggingMaterial = m_d->collSettingsButton->bTaggingMaterial();
662 m_d->bTaggingSwitch->addChild( m_d->bTaggingMaterial );
663 }
664 else {
665 messageVerbose("taking the argument material");
666 m_d->bTaggingMaterial = mat;
667 m_d->bTaggingSwitch->addChild( m_d->bTaggingMaterial );
668 }
669
670 //std::cout << "--> new mat: " << m_d->bTaggingMaterial << std::endl;
671
672 updateBTaggingSwitchAllJets(); // update switch all jets
673 updateBTaggingAllJets(); // update cut for all jets
674 }
675}
676
677
678//____________________________________________________________________
680
681 // std::cout << "current bTaggingTagger: " << m_d->bTaggingTagger << " - new: " << tagger << std::endl;
682
683 if (m_d->bTaggingTagger == tagger.toStdString())
684 return;
685
686 m_d->bTaggingTagger = tagger.toStdString();
687
688 if (!isLoaded())
689 return;
690
691 messageVerbose("BTaggingTagger change to: " +tagger+ " (with cut: " + QString::number(m_d->bTaggingCut) + "). Updating "+str(getHandlesList().count())+" jets");
692
693 updateBTaggingAllJets(); // update all jets
694}
695
696
697//____________________________________________________________________
699
700 if (m_d->bTaggingCut == wCut)
701 return;
702
703 m_d->bTaggingCut = wCut;
704
705 if (!isLoaded())
706 return;
707
708 messageVerbose("BTaggingCut change to "+str(m_d->bTaggingCut)+". Updating "+str(getHandlesList().count())+" jets");
709
710 updateBTaggingAllJets(); // update all jets
711
712}
713
714//____________________________________________________________________
716{
717 messageVerbose("IParticleCollHandle_Jet::updateBTaggingAllJets()");
720 AODHandleBase* handle=0;
721 while ((handle=getNextHandle()))
722 {
723 IParticleHandle_Jet* jet = dynamic_cast<IParticleHandle_Jet*>(handle);
724 if (jet && jet->has3DObjects()) {
725 jet->updateBTagging(m_d->bTaggingTagger, m_d->bTaggingCut);
726 } else {
727 message("ERROR Handle of wrong type!");
728 }
729 }
731}
732
733//____________________________________________________________________
735{
736 messageVerbose("IParticleCollHandle_Jet::updateBTaggingSwitchAllJets()");
739 AODHandleBase* handle=0;
740 while ((handle=getNextHandle()))
741 {
742 IParticleHandle_Jet* jet = dynamic_cast<IParticleHandle_Jet*>(handle);
743 if (jet && jet->has3DObjects()) {
744 jet->updateBTaggingSwitch(m_d->bTaggingSwitch);
745 } else {
746 message("ERROR Handle of wrong type!");
747 }
748 }
750}
751
752
753//____________________________________________________________________
755{
756 if (ok) {
757 messageVerbose("IParticleCollHandle_Jet::setBTaggingMaterialChanged()");
759 }
760}
761
762//____________________________________________________________________
764 if (ok)
765 setBTaggingSkin(m_d->collSettingsButton->bTaggingSkin());
766}
767
768
769//____________________________________________________________________
771{
772 messageDebug("IParticleCollHandle_Jet::persistifiableState() - start...");
773
774 // if (!m_d->matButton) {
775 // message("ERROR: persistifiableState() called before init()");
776 // return QByteArray();
777 // }
778
779
780 VP1Serialise serialise(1/*version*/);
781
782 // settings
783 serialise.disableUnsavedChecks();
784
785 // SAVE THE CHECKED/UNCHECKED STATUS OF THE COLLECTION
786 serialise.save(visible());
787
788 // SAVE THE MATERIAL BUTTON
789 //Q_ASSERT(m_d->matButton&&"Did you forget to call init() on this VP1StdCollection?");
790 //serialise.save(m_d->matButton->saveState());
791
792 // SAVE THE EXTRA-STATES
793 serialise.save(extraWidgetsState());//version 1+
794
795 // SAVE MATERIAL SETTINGS / CUTS
796 serialise.save(m_d->collSettingsButton->saveState());
797
798 messageDebug("IParticleCollHandle_Jet::persistifiableState() - end.");
799 return serialise.result();
800}
801
802//____________________________________________________________________
803void IParticleCollHandle_Jet::setState(const QByteArray&state)
804{
805 messageDebug("IParticleCollHandle_Jet::setState()");
806
807 VP1Deserialise des(state);
809 if (des.version()!=0&&des.version()!=1) {
810 messageDebug("Warning: Ignoring state with wrong version");
811 return;
812 }
813
814 // save state
815
816 bool vis = des.restoreBool();
817
818 // QByteArray matState = des.restoreByteArray();
819 // m_d->matButton->restoreFromState(matState);
820 QByteArray extraWidgetState = des.version()>=1 ? des.restoreByteArray() : QByteArray();
821 setVisible(vis);
822
823 if (extraWidgetState!=QByteArray())
824 setExtraWidgetsState(extraWidgetState);
825
826 // MATERIAL SETTINGS / CUTS
827 messageDebug("restoring material collection button...");
828 des.restore(m_d->collSettingsButton);
829
830 messageDebug("reset all caches storing values for cuts...");
832
833 messageDebug("recheck all handles...");
835
836}
837
838
840{
841 // kinetic cuts
842 setCutAllowedPt(m_d->collSettingsButton->cutAllowedPt());
843 setCutAllowedEta(m_d->collSettingsButton->cutAllowedEta());
844 setCutAllowedPhi(m_d->collSettingsButton->cutAllowedPhi());
845 setScale( this->scale() );
846 // colouring
847 setRandomJetColours(m_d->collSettingsButton->randomJetColours());
848 // b-tagging
849 setBTaggingEnabled(m_d->collSettingsButton->bTaggingEnabled());
850 setBTaggingTagger(m_d->collSettingsButton->bTaggingTagger());
851 setBTaggingCut(m_d->collSettingsButton->bTaggingCut());
852 // maxR
853 setMaxR(m_d->collSettingsButton->maxR());
854}
855
856void IParticleCollHandle_Jet::dumpToJSON( std::ofstream& str) const {
857 str << "\""<<name().toLatin1().data()<<"\":{";
858
859 unsigned int num=0;
860 for (auto handle : getHandlesList() ) {
861 if (handle->visible()) {
862 if (num) str <<",\n";
863 handle->dumpToJSON(str);
864 }
865 }
866
867 str << "}";
868}
869
#define M_PI
Scalar phi() const
phi method
const AODSysCommonData * common() const
void recheckCutStatusOfAllVisibleHandles()
void setExtraWidgetsState(const QByteArray &)
QByteArray extraWidgetsState() const
void setupSettingsFromController(const AODSystemController *)
const QString & name() const
DataModel_detail::const_iterator< DataVector > const_iterator
Definition DataVector.h:838
const_iterator end() const noexcept
Return a const_iterator pointing past the end of the collection.
const_iterator begin() const noexcept
Return a const_iterator pointing at the beginning of the collection.
const VP1Interval & getCutAllowedEta()
IParticleCollHandleBase(AODSysCommonData *, const QString &name, xAOD::Type::ObjectType)
virtual AODHandleBase * getNextHandle()
void setCutAllowedPt(const VP1Interval &)
const QList< VP1Interval > & getCutAllowedPhi()
const VP1Interval & getCutAllowedPt()
virtual bool cut(AODHandleBase *)
QList< AODHandleBase * > getHandlesList() const
void setCutAllowedPhi(const QList< VP1Interval > &)
void setCutAllowedEta(const VP1Interval &)
JetCollectionSettingsButton * collSettingsButton
virtual void setupSettingsFromControllerSpecific(const AODSystemController *)
For extensions specific to this collection.
void setBTaggingMaterialChanged(const bool &)
void setBTaggingSkinChanged(const bool &ok)
void setMaxR(const double &max)
void setState(const QByteArray &)
Provide specific implementation.
QByteArray persistifiableState() const
Provide specific implementation.
virtual void init(VP1MaterialButtonBase *matBut=0)
void setBTaggingMaterial(SoMaterial *mat=NULL)
virtual void dumpToJSON(std::ofstream &) const
void setBTaggingTagger(const QString &)
const JetCollectionSettingsButton & collSettingsButton() const
virtual bool cut(AODHandleBase *)
IParticleCollHandle_Jet(AODSysCommonData *, const QString &name, xAOD::Type::ObjectType type)
static QStringList availableCollections(IVP1System *)
void setBTaggingSkin(const QString &filename)
virtual QColor defaultColor() const
QList< VP1Interval > cutAllowedPhi() const
static std::string find_file(const std::string &logical_file_name, const std::string &search_path)
Interface for non-const operations on an auxiliary store.
Definition IAuxStore.h:48
QByteArray restoreByteArray()
void disableUnrestoredChecks()
void restore(QCheckBox *sb)
qint32 version() const
void messageVerbose(const QString &) const
void message(const QString &) const
IVP1System * systemBase() const
void messageDebug(const QString &) const
static SoMaterial * createMaterial(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
QStringList getKeys() const
virtual void largeChangesEnd()
virtual void init(VP1MaterialButtonBase *button=0)
virtual void largeChangesBegin()
void visibilityChanged(bool)
QString text() const
bool contains(const std::string &s, const std::string &regx)
does a string contain the substring
Definition hcg.cxx:114
int count(std::string s, const std::string &regx)
count how many occurances of a regx are in a string
Definition hcg.cxx:146
ObjectType
Type of objects that have a representation in the xAOD EDM.
Definition ObjectType.h:32
@ Jet
The object is a jet.
Definition ObjectType.h:40
JetContainer_v1 JetContainer
Definition of the current "jet container version".