CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
DQMFolder.cc
Go to the documentation of this file.
1 // $Id: DQMFolder.cc,v 1.2 2011/03/07 15:31:32 mommsen Exp $
3 
5 
6 #include "TH1.h"
7 #include "TObjString.h"
8 #include "TProfile.h"
9 
10 #include "classlib/utils/Regexp.h"
11 
12 // 15-Jul-2008, KAB: copied from DQMStore
13 static const lat::Regexp s_rxmeval ("^<(.*)>(i|f|s|t|qr)=(.*)</\\1>$");
14 
15 using namespace stor;
16 
17 
19 {}
20 
22 {
23  for (DQMObjectsMap::const_iterator it = dqmObjects_.begin(),
24  itEnd = dqmObjects_.end(); it != itEnd; ++it)
25  {
26  TObject* object = it->second;
27  if ( object != NULL ) { delete(object); }
28  }
29  dqmObjects_.clear();
30 }
31 
32 void DQMFolder::addObjects(std::vector<TObject*> toList)
33 {
34  for (std::vector<TObject*>::const_iterator it = toList.begin(), itEnd = toList.end();
35  it != itEnd; ++it)
36  {
37  TObject* object = *it;
38  if (object)
39  {
40  std::string objectName = getSafeMEName(object);
41 
42  DQMObjectsMap::iterator pos = dqmObjects_.lower_bound(objectName);
43  if ( pos == dqmObjects_.end() || (dqmObjects_.key_comp()(objectName, pos->first)) )
44  {
45  pos = dqmObjects_.insert(pos,
46  DQMFolder::DQMObjectsMap::value_type(objectName, object));
47  }
48  else
49  {
50  TObject* storedObject = pos->second;
51  if ( object->InheritsFrom("TProfile") &&
52  storedObject->InheritsFrom("TProfile") )
53  {
54  TProfile* newProfile = static_cast<TProfile*>(object);
55  TProfile* storedProfile = static_cast<TProfile*>(storedObject);
56  if (newProfile->GetEntries() > 0)
57  {
58  storedProfile->Add(newProfile);
59  }
60  }
61  else if ( object->InheritsFrom("TH1") &&
62  storedObject->InheritsFrom("TH1") )
63  {
64  TH1* newHistogram = static_cast<TH1*>(object);
65  TH1* storedHistogram = static_cast<TH1*>(storedObject);
66  if (newHistogram->GetEntries() > 0)
67  {
68  storedHistogram->Add(newHistogram);
69  }
70  }
71  else
72  {
73  // 15-Jul-2008, KAB - switch to the first instance at the
74  // request of Andreas Meyer...
75 
77  //delete(storedObject);
78  //folder->dqmObjects_[objectName] = object->Clone(object->GetName());
79  }
80  delete(object);
81  }
82  }
83  }
84 }
85 
86 void DQMFolder::fillObjectVector(std::vector<TObject*>& vector) const
87 {
88  for ( DQMObjectsMap::const_iterator it = dqmObjects_.begin(), itEnd = dqmObjects_.end();
89  it != itEnd; ++it )
90  {
91  vector.push_back(it->second);
92  }
93 }
94 
95 // 15-Jul-2008, KAB - this method should probably exist in DQMStore
96 // rather than here, but I'm going for expediency...
97 // The main purpose of the method is to pull out the ME name
98 // from scalar MEs (ints, floats, strings)
99 std::string DQMFolder::getSafeMEName(TObject *object)
100 {
101  std::string rawName = object->GetName();
102  std::string safeName = rawName;
103 
104  lat::RegexpMatch patternMatch;
105  if (dynamic_cast<TObjString *>(object) &&
106  s_rxmeval.match(rawName, 0, 0, &patternMatch)) {
107  safeName = patternMatch.matchString(rawName, 1);
108  }
109 
110  return safeName;
111 }
112 
113 
#define NULL
Definition: scimark2.h:8
DQMObjectsMap dqmObjects_
Definition: DQMFolder.h:38
static const lat::Regexp s_rxmeval("^<(.*)>(i|f|s|t|qr)=(.*)</\\1>$")
Container::value_type value_type
void fillObjectVector(std::vector< TObject * > &) const
Definition: DQMFolder.cc:86
list object
Definition: dbtoconf.py:77
void addObjects(std::vector< TObject * >)
Definition: DQMFolder.cc:32
static std::string getSafeMEName(TObject *object)
Definition: DQMFolder.cc:99