CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Public Attributes | Private Member Functions | Private Attributes
FWEventItemsManager Class Reference

#include <Fireworks/Core/interface/FWEventItemsManager.h>

Inheritance diagram for FWEventItemsManager:
FWConfigurable

Public Types

typedef std::vector< FWEventItem * >::const_iterator const_iterator
 

Public Member Functions

FWEventItemadd (const FWPhysicsObjectDesc &iItem, const FWConfiguration *pbConf=nullptr, bool doSetEvent=true)
 
void addTo (FWConfiguration &) const override
 
const_iterator begin () const
 NOTE: iterator is allowed to return a null object for items that have been removed. More...
 
void clearItems ()
 
const_iterator end () const
 
const FWEventItemfind (const std::string &iName) const
 
 FWEventItemsManager (FWModelChangeManager *)
 
 FWEventItemsManager (const FWEventItemsManager &)=delete
 
void newEvent (const edm::EventBase *iEvent)
 
const FWEventItemsManageroperator= (const FWEventItemsManager &)=delete
 
void setContext (fireworks::Context *)
 
void setFrom (const FWConfiguration &) override
 
 ~FWEventItemsManager () override
 
- Public Member Functions inherited from FWConfigurable
 FWConfigurable ()
 
 FWConfigurable (const FWConfigurable &)=delete
 
const FWConfigurableoperator= (const FWConfigurable &)=delete
 
virtual ~FWConfigurable ()
 

Public Attributes

sigc::signal< void()> goingToClearItems_
 
sigc::signal< void(FWEventItem *)> newItem_
 
sigc::signal< void(const FWEventItem *)> removingItem_
 

Private Member Functions

void removeItem (const FWEventItem *)
 

Private Attributes

std::shared_ptr< FWItemAccessorFactorym_accessorFactory
 
FWModelChangeManagerm_changeManager
 
fireworks::Contextm_context
 
const edm::EventBasem_event
 
std::vector< FWEventItem * > m_items
 

Detailed Description

Description: Manages multiple FWEventItems

Usage: <usage>

Definition at line 44 of file FWEventItemsManager.h.

Member Typedef Documentation

◆ const_iterator

Definition at line 50 of file FWEventItemsManager.h.

Constructor & Destructor Documentation

◆ FWEventItemsManager() [1/2]

FWEventItemsManager::FWEventItemsManager ( FWModelChangeManager iManager)

Definition at line 41 of file FWEventItemsManager.cc.

42  : m_changeManager(iManager), m_context(nullptr), m_event(nullptr), m_accessorFactory(new FWItemAccessorFactory()) {}
FWModelChangeManager * m_changeManager
const edm::EventBase * m_event
std::shared_ptr< FWItemAccessorFactory > m_accessorFactory
fireworks::Context * m_context

◆ ~FWEventItemsManager()

FWEventItemsManager::~FWEventItemsManager ( )
override

FWEventItemsManager has ownership of the items it contains.

Note that because of the way we keep track of removed items, m_items[i] could actually be 0 for indices corresponding to removed items.

Definition at line 55 of file FWEventItemsManager.cc.

References MillePedeFileConverter_cfg::e, mps_fire::i, and m_items.

55  {
56  for (size_t i = 0, e = m_items.size(); i != e; ++i)
57  delete m_items[i];
58 
59  m_items.clear();
60 }
std::vector< FWEventItem * > m_items

◆ FWEventItemsManager() [2/2]

FWEventItemsManager::FWEventItemsManager ( const FWEventItemsManager )
delete

Member Function Documentation

◆ add()

FWEventItem * FWEventItemsManager::add ( const FWPhysicsObjectDesc iItem,
const FWConfiguration pbConf = nullptr,
bool  doSetEvent = true 
)

Definition at line 77 of file FWEventItemsManager.cc.

References FWColorManager::colorHasIndex(), fireworks::Context::colorManager(), fwLog, FWColorManager::getDefaultStartColorIndex(), fwlog::kWarning, m_accessorFactory, m_changeManager, m_context, m_event, m_items, newItem_, removeItem(), and groupFilesInBlocks::temp.

Referenced by FWGUIEventDataAdder::addNewItem(), counter.Counter::register(), SequenceTypes._TaskBase::remove(), SequenceTypes._TaskBase::replace(), and setFrom().

77  {
79 
80  if (!m_context->colorManager()->colorHasIndex(temp.displayProperties().color())) {
81  FWDisplayProperties prop(temp.displayProperties());
82  fwLog(fwlog::kWarning) << Form(
83  "FWEventItemsManager::add(const FWPhysicsObjectDesc& iItem), color index not valid. Set Color idex to %d\n",
86  temp.setDisplayProperties(prop);
87  }
88 
89  m_items.push_back(new FWEventItem(m_context, m_items.size(), m_accessorFactory->accessorFor(temp.type()), temp, pbc));
90  newItem_(m_items.back());
91  m_items.back()->goingToBeDestroyed_.connect(std::bind(&FWEventItemsManager::removeItem, this, std::placeholders::_1));
92  if (doSetEvent && m_event) {
94  m_items.back()->setEvent(m_event);
95  }
96  return m_items.back();
97 }
FWModelChangeManager * m_changeManager
void removeItem(const FWEventItem *)
sigc::signal< void(FWEventItem *)> newItem_
static Color_t getDefaultStartColorIndex()
bool colorHasIndex(Color_t) const
const edm::EventBase * m_event
std::shared_ptr< FWItemAccessorFactory > m_accessorFactory
#define fwLog(_level_)
Definition: fwLog.h:45
fireworks::Context * m_context
std::vector< FWEventItem * > m_items
FWColorManager * colorManager() const
Definition: Context.h:58

◆ addTo()

void FWEventItemsManager::addTo ( FWConfiguration iTo) const
overridevirtual

Implements FWConfigurable.

Definition at line 143 of file FWEventItemsManager.cc.

References FWConfiguration::addKeyValue(), cms::cuda::assert(), fireworks::Context::colorManager(), DTskim_cfg::dataType, ALPAKA_ACCELERATOR_NAMESPACE::vertexFinder::it, kColor(), kFalse(), kFilterExpression(), kIsVisible(), kLayer(), kModuleLabel(), kProcessName(), kProductInstanceLabel(), kPurpose(), kTransparency(), kTrue(), kType(), m_context, m_items, and l1tGTMenu_BTagSeeds_cff::os.

143  {
145  assert(nullptr != cm);
146  for (std::vector<FWEventItem*>::const_iterator it = m_items.begin(); it != m_items.end(); ++it) {
147  if (!*it)
148  continue;
149  FWConfiguration conf(6);
150  edm::TypeWithDict dataType((*((*it)->type()->GetTypeInfo())));
152 
153  conf.addKeyValue(kType, FWConfiguration(dataType.name()));
154  conf.addKeyValue(kModuleLabel, FWConfiguration((*it)->moduleLabel()));
155  conf.addKeyValue(kProductInstanceLabel, FWConfiguration((*it)->productInstanceLabel()));
156  conf.addKeyValue(kProcessName, FWConfiguration((*it)->processName()));
157  conf.addKeyValue(kFilterExpression, FWConfiguration((*it)->filterExpression()));
158  {
159  std::ostringstream os;
160  os << (*it)->defaultDisplayProperties().color();
161  conf.addKeyValue(kColor, FWConfiguration(os.str()));
162  }
163  conf.addKeyValue(kIsVisible, FWConfiguration((*it)->defaultDisplayProperties().isVisible() ? kTrue : kFalse));
164  {
165  std::ostringstream os;
166  os << (*it)->layer();
167  conf.addKeyValue(kLayer, FWConfiguration(os.str()));
168  }
169  conf.addKeyValue(kPurpose, (*it)->purpose());
170  {
171  std::ostringstream os;
172  os << static_cast<int>((*it)->defaultDisplayProperties().transparency());
173  conf.addKeyValue(kTransparency, FWConfiguration(os.str()));
174  }
175 
176  FWConfiguration pbTmp;
177  (*it)->getConfig()->addTo(pbTmp);
178  conf.addKeyValue("PBConfig", pbTmp, true);
179 
180  iTo.addKeyValue((*it)->name(), conf, true);
181  }
182 }
static const std::string kModuleLabel("moduleLabel")
static const std::string kTrue("t")
static const std::string kType("type")
assert(be >=bs)
static const std::string kColor("color")
static const std::string kProductInstanceLabel("productInstanceLabel")
static const std::string kFilterExpression("filterExpression")
static const std::string kProcessName("processName")
static const std::string kFalse("f")
static const std::string kLayer("layer")
FWConfiguration & addKeyValue(const std::string &, const FWConfiguration &)
static const std::string kTransparency("transparency")
static const std::string kIsVisible("isVisible")
static const std::string kPurpose("purpose")
fireworks::Context * m_context
std::vector< FWEventItem * > m_items
FWColorManager * colorManager() const
Definition: Context.h:58

◆ begin()

FWEventItemsManager::const_iterator FWEventItemsManager::begin ( void  ) const

◆ clearItems()

void FWEventItemsManager::clearItems ( void  )

Clear all the items in the model.

Notice that a previous implementation was setting all the items to 0, I guess to track accessing delete items.

Definition at line 117 of file FWEventItemsManager.cc.

References MillePedeFileConverter_cfg::e, goingToClearItems_, mps_fire::i, B2GTnPMonitor_cfi::item, and m_items.

Referenced by FWPartialConfigLoadGUI::Load(), and setFrom().

117  {
118  for (size_t i = 0, e = m_items.size(); i != e; ++i) {
120  if (item) {
121  item->destroy();
122  }
123  m_items[i] = nullptr;
124  }
126 
127  m_items.clear();
128 }
std::vector< FWEventItem * > m_items
sigc::signal< void()> goingToClearItems_

◆ end()

FWEventItemsManager::const_iterator FWEventItemsManager::end ( void  ) const

◆ find()

const FWEventItem * FWEventItemsManager::find ( const std::string &  iName) const

Look up an item by name.

Definition at line 304 of file FWEventItemsManager.cc.

References MillePedeFileConverter_cfg::e, mps_fire::i, B2GTnPMonitor_cfi::item, and m_items.

Referenced by FWGUIEventDataAdder::addNewItem().

304  {
305  for (size_t i = 0, e = m_items.size(); i != e; ++i) {
306  const FWEventItem* item = m_items[i];
307  if (item && item->name() == iName)
308  return item;
309  }
310  return nullptr;
311 }
std::vector< FWEventItem * > m_items

◆ newEvent()

void FWEventItemsManager::newEvent ( const edm::EventBase iEvent)

Prepare to handle a new event by associating all the items to watch it.

Definition at line 102 of file FWEventItemsManager.cc.

References MillePedeFileConverter_cfg::e, mps_fire::i, iEvent, B2GTnPMonitor_cfi::item, m_changeManager, m_event, and m_items.

102  {
104  m_event = iEvent;
105  for (size_t i = 0, e = m_items.size(); i != e; ++i) {
107  if (item)
108  item->setEvent(iEvent);
109  }
110 }
FWModelChangeManager * m_changeManager
int iEvent
Definition: GenABIO.cc:224
const edm::EventBase * m_event
std::vector< FWEventItem * > m_items

◆ operator=()

const FWEventItemsManager& FWEventItemsManager::operator= ( const FWEventItemsManager )
delete

◆ removeItem()

void FWEventItemsManager::removeItem ( const FWEventItem iItem)
private

Remove one item.

Notice that rather than erasing the item from the list, it is preferred to set it to zero, I guess to catch accesses to remove items and to avoid having to recalculate the current selection.

GE: I think this is a broken way of handling removal of objects. The object should be properly deleted and the current selection should be updated accordingly.

Definition at line 288 of file FWEventItemsManager.cc.

References cms::cuda::assert(), FWEventItem::id(), m_items, and removingItem_.

Referenced by add().

288  {
289  assert(iItem->id() < m_items.size());
290  removingItem_(iItem);
291  m_items[iItem->id()] = nullptr;
292 }
unsigned int id() const
Definition: FWEventItem.cc:433
assert(be >=bs)
sigc::signal< void(const FWEventItem *)> removingItem_
std::vector< FWEventItem * > m_items

◆ setContext()

void FWEventItemsManager::setContext ( fireworks::Context iContext)

Definition at line 294 of file FWEventItemsManager.cc.

References m_context.

Referenced by CmsShowMain::CmsShowMain(), and FWFFLooper::FWFFLooper().

294 { m_context = iContext; }
fireworks::Context * m_context

◆ setFrom()

void FWEventItemsManager::setFrom ( const FWConfiguration iFrom)
overridevirtual

This is responsible for resetting the status of items from configuration

Implements FWConfigurable.

Definition at line 186 of file FWEventItemsManager.cc.

References add(), FWConfiguration::addKeyValue(), cms::cuda::assert(), clearItems(), fireworks::Context::colorManager(), submitPVResolutionJobs::desc, Calorimetry_cff::dp, ALPAKA_ACCELERATOR_NAMESPACE::vertexFinder::it, FWConfiguration::keyValues(), kTrue(), nano_mu_digi_cff::layer, m_changeManager, m_context, m_event, HerwigMaxPtPartonFilter_cfi::moduleLabel, Skims_PA_cff::name, FWColorManager::oldColorToIndex(), SimL1EmulatorRepack_CalouGT_cff::processName, hgcalPlots::purpose, edm::second(), AlCaHLTBitMon_QueryRunRegistry::string, FWConfiguration::valueForKey(), and FWConfiguration::version().

186  {
188  assert(nullptr != cm);
189 
190  clearItems();
191  const FWConfiguration::KeyValues* keyValues = iFrom.keyValues();
192 
193  if (keyValues == nullptr)
194  return;
195 
196  std::vector<FWEventItem*> newItems;
197  newItems.reserve(keyValues->size());
198 
199  for (FWConfiguration::KeyValues::const_iterator it = keyValues->begin(); it != keyValues->end(); ++it) {
200  const std::string& name = it->first;
201  const FWConfiguration& conf = it->second;
202  const FWConfiguration::KeyValues* keyValues = conf.keyValues();
203  assert(nullptr != keyValues);
204  const std::string& type = (*keyValues)[0].second.value();
205  const std::string& moduleLabel = (*keyValues)[1].second.value();
206  const std::string& productInstanceLabel = (*keyValues)[2].second.value();
207  const std::string& processName = (*keyValues)[3].second.value();
208  const std::string& filterExpression = (*keyValues)[4].second.value();
209  const std::string& sColor = (*keyValues)[5].second.value();
210  const bool isVisible = (*keyValues)[6].second.value() == kTrue;
211 
212  unsigned int colorIndex;
213  if (conf.version() < 5) {
214  std::istringstream is(sColor);
215  Color_t color;
216  is >> color;
217  colorIndex = cm->oldColorToIndex(color, conf.version());
218  } else {
219  // In version 4 we assume:
220  // fireworks colors start at ROOT index 1000
221  // geometry colors start at ROOT index 1100
222  // We save them as such -- no conversions needed.
223  std::istringstream is(sColor);
224  is >> colorIndex;
225  }
226 
227  int transparency = 0;
228 
229  // Read transparency from file. We don't care about checking errors
230  // because strtol returns 0 in that case.
231  if (conf.version() > 3)
232  transparency = strtol((*keyValues)[9].second.value().c_str(), nullptr, 10);
233 
234  FWDisplayProperties dp(colorIndex, isVisible, transparency);
235 
236  unsigned int layer = strtol((*keyValues)[7].second.value().c_str(), nullptr, 10);
237 
238  //For older configs assume name is the same as purpose
240  if (conf.version() > 1)
241  purpose = (*keyValues)[8].second.value();
242 
243  FWConfiguration* proxyConfig =
244  (FWConfiguration*)conf.valueForKey("PBConfig") ? new FWConfiguration(*conf.valueForKey("PBConfig")) : nullptr;
245 
246  // beckward compatibilty for obsolete proxy builders
247  if (conf.version() < 6) {
248  assert(proxyConfig == nullptr);
249  if (purpose == "VerticesWithTracks") {
250  purpose = "Vertices";
251  proxyConfig = new FWConfiguration();
252  FWConfiguration vTmp;
253  vTmp.addKeyValue("Draw Tracks", FWConfiguration("1"));
254  proxyConfig->addKeyValue("Var", vTmp, true);
255  }
256  }
257 
259  TClass::GetClass(type.c_str()),
260  purpose,
261  dp,
262  moduleLabel,
263  productInstanceLabel,
264  processName,
265  filterExpression,
266  layer);
267 
268  newItems.push_back(add(desc, proxyConfig, false));
269  }
270 
271  if (m_event) {
273  for (auto ip : newItems)
274  ip->setEvent(m_event);
275  }
276 }
FWModelChangeManager * m_changeManager
static const std::string kTrue("t")
assert(be >=bs)
U second(std::pair< T, U > const &p)
FWEventItem * add(const FWPhysicsObjectDesc &iItem, const FWConfiguration *pbConf=nullptr, bool doSetEvent=true)
std::vector< std::pair< std::string, FWConfiguration > > KeyValues
FWConfiguration & addKeyValue(const std::string &, const FWConfiguration &)
const edm::EventBase * m_event
const FWConfiguration * valueForKey(const std::string &iKey) const
fireworks::Context * m_context
const KeyValues * keyValues() const
Color_t oldColorToIndex(Color_t, int version) const
FWColorManager * colorManager() const
Definition: Context.h:58
unsigned int version() const

Member Data Documentation

◆ goingToClearItems_

sigc::signal<void()> FWEventItemsManager::goingToClearItems_

◆ m_accessorFactory

std::shared_ptr<FWItemAccessorFactory> FWEventItemsManager::m_accessorFactory
private

Definition at line 90 of file FWEventItemsManager.h.

Referenced by add().

◆ m_changeManager

FWModelChangeManager* FWEventItemsManager::m_changeManager
private

Definition at line 86 of file FWEventItemsManager.h.

Referenced by add(), newEvent(), and setFrom().

◆ m_context

fireworks::Context* FWEventItemsManager::m_context
private

Definition at line 87 of file FWEventItemsManager.h.

Referenced by add(), addTo(), setContext(), and setFrom().

◆ m_event

const edm::EventBase* FWEventItemsManager::m_event
private

Definition at line 89 of file FWEventItemsManager.h.

Referenced by add(), newEvent(), and setFrom().

◆ m_items

std::vector<FWEventItem*> FWEventItemsManager::m_items
private

◆ newItem_

sigc::signal<void(FWEventItem*)> FWEventItemsManager::newItem_

◆ removingItem_

sigc::signal<void(const FWEventItem*)> FWEventItemsManager::removingItem_

Definition at line 74 of file FWEventItemsManager.h.

Referenced by removeItem().