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 *)
 
void newEvent (const edm::EventBase *iEvent)
 
void setContext (fireworks::Context *)
 
void setFrom (const FWConfiguration &) override
 
 ~FWEventItemsManager () override
 
- Public Member Functions inherited from FWConfigurable
 FWConfigurable ()
 
virtual ~FWConfigurable ()
 

Public Attributes

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

Private Member Functions

 FWEventItemsManager (const FWEventItemsManager &)=delete
 
const FWEventItemsManageroperator= (const FWEventItemsManager &)=delete
 
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()) {}

◆ ~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.

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 }

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

◆ FWEventItemsManager() [2/2]

FWEventItemsManager::FWEventItemsManager ( const FWEventItemsManager )
privatedelete

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.

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 }

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.Task::remove(), SequenceTypes.Task::replace(), and setFrom().

◆ addTo()

void FWEventItemsManager::addTo ( FWConfiguration iTo) const
overridevirtual

Implements FWConfigurable.

Definition at line 143 of file FWEventItemsManager.cc.

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 }

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

◆ 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.

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 }

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

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

◆ 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.

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 }

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

Referenced by FWGUIEventDataAdder::addNewItem().

◆ 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.

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 }

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

◆ operator=()

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

◆ 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.

288  {
289  assert(iItem->id() < m_items.size());
290  removingItem_(iItem);
291  m_items[iItem->id()] = nullptr;
292 }

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

Referenced by add().

◆ setContext()

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

Definition at line 294 of file FWEventItemsManager.cc.

294 { m_context = iContext; }

References m_context.

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

◆ 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.

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 }

References add(), FWConfiguration::addKeyValue(), cms::cuda::assert(), clearItems(), fireworks::Context::colorManager(), submitPVResolutionJobs::desc, Calorimetry_cff::dp, FWConfiguration::keyValues(), kTrue(), phase1PixelTopology::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().

Member Data Documentation

◆ goingToClearItems_

sigc::signal<void> FWEventItemsManager::goingToClearItems_

◆ m_accessorFactory

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

Definition at line 89 of file FWEventItemsManager.h.

Referenced by add().

◆ m_changeManager

FWModelChangeManager* FWEventItemsManager::m_changeManager
private

Definition at line 85 of file FWEventItemsManager.h.

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

◆ m_context

fireworks::Context* FWEventItemsManager::m_context
private

Definition at line 86 of file FWEventItemsManager.h.

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

◆ m_event

const edm::EventBase* FWEventItemsManager::m_event
private

Definition at line 88 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().

hgcalPlots.purpose
purpose
Definition: hgcalPlots.py:2679
fwLog
#define fwLog(_level_)
Definition: fwLog.h:45
mps_fire.i
i
Definition: mps_fire.py:428
kType
static const std::string kType("type")
FWEventItemsManager::add
FWEventItem * add(const FWPhysicsObjectDesc &iItem, const FWConfiguration *pbConf=nullptr, bool doSetEvent=true)
Definition: FWEventItemsManager.cc:77
fireworks::Context::colorManager
FWColorManager * colorManager() const
Definition: Context.h:58
FWEventItemsManager::clearItems
void clearItems()
Definition: FWEventItemsManager.cc:117
FWEventItemsManager::m_context
fireworks::Context * m_context
Definition: FWEventItemsManager.h:86
kTransparency
static const std::string kTransparency("transparency")
FWEventItemsManager::m_items
std::vector< FWEventItem * > m_items
Definition: FWEventItemsManager.h:84
cms::cuda::assert
assert(be >=bs)
edm::second
U second(std::pair< T, U > const &p)
Definition: ParameterSet.cc:222
FWEventItem::id
unsigned int id() const
Definition: FWEventItem.cc:433
FWEventItemsManager::goingToClearItems_
sigc::signal< void > goingToClearItems_
Definition: FWEventItemsManager.h:75
FWItemAccessorFactory
Definition: FWItemAccessorFactory.h:31
groupFilesInBlocks.temp
list temp
Definition: groupFilesInBlocks.py:142
DTskim_cfg.dataType
dataType
Definition: DTskim_cfg.py:56
FWConfiguration::KeyValues
std::vector< std::pair< std::string, FWConfiguration > > KeyValues
Definition: FWConfiguration.h:40
kFalse
static const std::string kFalse("f")
kProductInstanceLabel
static const std::string kProductInstanceLabel("productInstanceLabel")
FWEventItemsManager::m_accessorFactory
std::shared_ptr< FWItemAccessorFactory > m_accessorFactory
Definition: FWEventItemsManager.h:89
Calorimetry_cff.dp
dp
Definition: Calorimetry_cff.py:158
kIsVisible
static const std::string kIsVisible("isVisible")
FWChangeSentry
Definition: FWModelChangeManager.h:68
kPurpose
static const std::string kPurpose("purpose")
FWConfiguration::valueForKey
const FWConfiguration * valueForKey(const std::string &iKey) const
Definition: FWConfiguration.cc:122
phase1PixelTopology::layer
constexpr std::array< uint8_t, layerIndexSize > layer
Definition: phase1PixelTopology.h:99
edm::TypeWithDict
Definition: TypeWithDict.h:38
type
type
Definition: SiPixelVCal_PayloadInspector.cc:39
FWPhysicsObjectDesc
Definition: FWPhysicsObjectDesc.h:30
FWEventItemsManager::removeItem
void removeItem(const FWEventItem *)
Definition: FWEventItemsManager.cc:288
iEvent
int iEvent
Definition: GenABIO.cc:224
fwlog::kWarning
Definition: fwLog.h:35
B2GTnPMonitor_cfi.item
item
Definition: B2GTnPMonitor_cfi.py:147
FWColorManager::getDefaultStartColorIndex
static Color_t getDefaultStartColorIndex()
Definition: FWColorManager.cc:38
FWConfiguration::version
unsigned int version() const
Definition: FWConfiguration.h:49
FWColorManager
Definition: FWColorManager.h:45
FWColorManager::oldColorToIndex
Color_t oldColorToIndex(Color_t, int version) const
Definition: FWColorManager.cc:275
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
FWEventItemsManager::m_changeManager
FWModelChangeManager * m_changeManager
Definition: FWEventItemsManager.h:85
SimL1EmulatorRepack_CalouGT_cff.processName
processName
Definition: SimL1EmulatorRepack_CalouGT_cff.py:17
FWDisplayProperties
Definition: FWDisplayProperties.h:28
FWConfiguration::addKeyValue
FWConfiguration & addKeyValue(const std::string &, const FWConfiguration &)
Definition: FWConfiguration.cc:58
kModuleLabel
static const std::string kModuleLabel("moduleLabel")
submitPVResolutionJobs.desc
string desc
Definition: submitPVResolutionJobs.py:251
FWEventItem
Definition: FWEventItem.h:56
kTrue
static const std::string kTrue("t")
kProcessName
static const std::string kProcessName("processName")
FWConfiguration::keyValues
const KeyValues * keyValues() const
Definition: FWConfiguration.h:51
FWColorManager::colorHasIndex
bool colorHasIndex(Color_t) const
Definition: FWColorManager.cc:267
FWEventItemsManager::newItem_
sigc::signal< void, FWEventItem * > newItem_
Definition: FWEventItemsManager.h:73
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
FWConfiguration
Definition: FWConfiguration.h:31
HerwigMaxPtPartonFilter_cfi.moduleLabel
moduleLabel
Definition: HerwigMaxPtPartonFilter_cfi.py:4
kColor
static const std::string kColor("color")
FWEventItemsManager::m_event
const edm::EventBase * m_event
Definition: FWEventItemsManager.h:88
kLayer
static const std::string kLayer("layer")
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37
kFilterExpression
static const std::string kFilterExpression("filterExpression")
FWEventItemsManager::removingItem_
sigc::signal< void, const FWEventItem * > removingItem_
Definition: FWEventItemsManager.h:74