CMS 3D CMS Logo

List of all members | Classes | Public Types | Public Member Functions | Private Attributes
MEtoEDM< T > Class Template Reference

#include <MEtoEDMFormat.h>

Classes

struct  MEtoEDMObject
 

Public Types

typedef std::vector< MEtoEDMObjectMEtoEdmObjectVector
 
typedef std::vector< uint32_t > TagList
 

Public Member Functions

bool CheckBinLabels (const TAxis *a1, const TAxis *a2)
 
const MEtoEdmObjectVectorgetMEtoEdmObject () const
 
bool mergeProduct (const MEtoEDM< T > &newMEtoEDM)
 
template<>
bool mergeProduct (const MEtoEDM< double > &newMEtoEDM)
 
template<>
bool mergeProduct (const MEtoEDM< int > &newMEtoEDM)
 
template<>
bool mergeProduct (const MEtoEDM< long long > &newMEtoEDM)
 
template<>
bool mergeProduct (const MEtoEDM< TString > &newMEtoEDM)
 
 MEtoEDM ()
 
 MEtoEDM (size_t reservedSize)
 
void putMEtoEdmObject (const std::string &name, const T &object)
 
void swap (MEtoEDM< T > &iOther)
 
virtual ~MEtoEDM ()
 

Private Attributes

MEtoEdmObjectVector MEtoEdmObject
 

Detailed Description

template<class T>
class MEtoEDM< T >

DataFormat class to hold the information from a ME tranformed into ROOT objects as appropriate

Author
M. Strang SUNY-Buffalo

Definition at line 37 of file MEtoEDMFormat.h.

Member Typedef Documentation

◆ MEtoEdmObjectVector

template<class T>
typedef std::vector<MEtoEDMObject> MEtoEDM< T >::MEtoEdmObjectVector

Definition at line 51 of file MEtoEDMFormat.h.

◆ TagList

template<class T>
typedef std::vector<uint32_t> MEtoEDM< T >::TagList

Definition at line 43 of file MEtoEDMFormat.h.

Constructor & Destructor Documentation

◆ MEtoEDM() [1/2]

template<class T>
MEtoEDM< T >::MEtoEDM ( )
inline

Definition at line 39 of file MEtoEDMFormat.h.

39 {}

◆ MEtoEDM() [2/2]

template<class T>
MEtoEDM< T >::MEtoEDM ( size_t  reservedSize)
inlineexplicit

Definition at line 40 of file MEtoEDMFormat.h.

References MEtoEDM< T >::MEtoEdmObject.

40 { MEtoEdmObject.reserve(reservedSize); }
MEtoEdmObjectVector MEtoEdmObject

◆ ~MEtoEDM()

template<class T>
virtual MEtoEDM< T >::~MEtoEDM ( )
inlinevirtual

Definition at line 41 of file MEtoEDMFormat.h.

41 {}

Member Function Documentation

◆ CheckBinLabels()

template<class T>
bool MEtoEDM< T >::CheckBinLabels ( const TAxis *  a1,
const TAxis *  a2 
)
inline

Definition at line 62 of file MEtoEDMFormat.h.

References isotrackTrainRegressor::a1, isotrackTrainRegressor::a2, mps_fire::i, and hbheRecHitProducerGPUTask_cff::label1.

Referenced by MEtoEDM< T >::mergeProduct().

62  {
63  // check that axis have same labels
64  THashList *l1 = (const_cast<TAxis *>(a1))->GetLabels();
65  THashList *l2 = (const_cast<TAxis *>(a2))->GetLabels();
66 
67  if (!l1 && !l2)
68  return true;
69  if (!l1 || !l2) {
70  return false;
71  }
72  // check now labels sizes are the same
73  if (l1->GetSize() != l2->GetSize()) {
74  return false;
75  }
76  for (int i = 1; i <= a1->GetNbins(); ++i) {
77  TString label1 = a1->GetBinLabel(i);
78  TString label2 = a2->GetBinLabel(i);
79  if (label1 != label2) {
80  return false;
81  }
82  }
83  return true;
84  }

◆ getMEtoEdmObject()

template<class T>
const MEtoEdmObjectVector& MEtoEDM< T >::getMEtoEdmObject ( ) const
inline

Definition at line 60 of file MEtoEDMFormat.h.

References MEtoEDM< T >::MEtoEdmObject.

Referenced by MEtoEDM< T >::mergeProduct().

60 { return MEtoEdmObject; }
MEtoEdmObjectVector MEtoEdmObject

◆ mergeProduct() [1/5]

template<class T>
bool MEtoEDM< T >::mergeProduct ( const MEtoEDM< T > &  newMEtoEDM)
inline

Definition at line 86 of file MEtoEDMFormat.h.

References MEtoEDM< T >::CheckBinLabels(), gather_cfg::cout, MEtoEDM< T >::getMEtoEdmObject(), mps_fire::i, dqmiolumiharvest::j, MEtoEDM< T >::MEtoEdmObject, mergeVDriftHistosByStation::name, and AlCaHLTBitMon_QueryRunRegistry::string.

86  {
87  const MEtoEdmObjectVector &newMEtoEDMObject = newMEtoEDM.getMEtoEdmObject();
88  const size_t nObjects = newMEtoEDMObject.size();
89  // NOTE: we remember the present size since we will only add content
90  // from newMEtoEDMObject after this point
91  const size_t nOldObjects = MEtoEdmObject.size();
92 
93  // if the old and new are not the same size, we want to report a problem
94  if (nObjects != nOldObjects) {
95  std::cout << "WARNING MEtoEDM::mergeProducts(): the lists of histograms to be merged have different sizes: new="
96  << nObjects << ", old=" << nOldObjects << std::endl;
97  }
98 
99  for (unsigned int i = 0; i < nObjects; ++i) {
100  unsigned int j = 0;
101  // see if the name is already in the old container up to the point where
102  // we may have added new entries in the container
103  const std::string &name = newMEtoEDMObject[i].name;
104  if (i < nOldObjects && (MEtoEdmObject[i].name == name)) {
105  j = i;
106  } else {
107  j = 0;
108  while (j < nOldObjects && (MEtoEdmObject[j].name != name))
109  ++j;
110  }
111  if (j >= nOldObjects) {
112  // this value is only in the new container, not the old one
113 #if METOEDMFORMAT_DEBUG
114  std::cout << "WARNING MEtoEDM::mergeProducts(): adding new histogram '" << name << "'" << std::endl;
115 #endif
116  MEtoEdmObject.push_back(newMEtoEDMObject[i]);
117  } else if (MEtoEdmObject[j].object.CanExtendAllAxes() && newMEtoEDMObject[i].object.CanExtendAllAxes()) {
118  TList list;
119  list.Add((TObject *)&newMEtoEDMObject[i].object);
120  if (MEtoEdmObject[j].object.Merge(&list) == -1) {
121  std::cout << "ERROR MEtoEDM::mergeProducts(): merge failed for '" << name << "'" << std::endl;
122  }
123  } else {
124  // this value is also in the new container: add the two
125  if (MEtoEdmObject[j].object.GetNbinsX() == newMEtoEDMObject[i].object.GetNbinsX() &&
126  MEtoEdmObject[j].object.GetXaxis()->GetXmin() == newMEtoEDMObject[i].object.GetXaxis()->GetXmin() &&
127  MEtoEdmObject[j].object.GetXaxis()->GetXmax() == newMEtoEDMObject[i].object.GetXaxis()->GetXmax() &&
128  MEtoEdmObject[j].object.GetNbinsY() == newMEtoEDMObject[i].object.GetNbinsY() &&
129  MEtoEdmObject[j].object.GetYaxis()->GetXmin() == newMEtoEDMObject[i].object.GetYaxis()->GetXmin() &&
130  MEtoEdmObject[j].object.GetYaxis()->GetXmax() == newMEtoEDMObject[i].object.GetYaxis()->GetXmax() &&
131  MEtoEdmObject[j].object.GetNbinsZ() == newMEtoEDMObject[i].object.GetNbinsZ() &&
132  MEtoEdmObject[j].object.GetZaxis()->GetXmin() == newMEtoEDMObject[i].object.GetZaxis()->GetXmin() &&
133  MEtoEdmObject[j].object.GetZaxis()->GetXmax() == newMEtoEDMObject[i].object.GetZaxis()->GetXmax() &&
134  CheckBinLabels((TAxis *)MEtoEdmObject[j].object.GetXaxis(),
135  (TAxis *)newMEtoEDMObject[i].object.GetXaxis()) &&
136  CheckBinLabels((TAxis *)MEtoEdmObject[j].object.GetYaxis(),
137  (TAxis *)newMEtoEDMObject[i].object.GetYaxis()) &&
138  CheckBinLabels((TAxis *)MEtoEdmObject[j].object.GetZaxis(),
139  (TAxis *)newMEtoEDMObject[i].object.GetZaxis())) {
140  MEtoEdmObject[j].object.Add(&newMEtoEDMObject[i].object);
141  } else {
142  std::cout
143  << "ERROR MEtoEDM::mergeProducts(): found histograms with different axis limits or different labels, '"
144  << name << "' not merged" << std::endl;
145 #if METOEDMFORMAT_DEBUG
146  std::cout << MEtoEdmObject[j].name << " " << newMEtoEDMObject[i].name << std::endl;
147  std::cout << MEtoEdmObject[j].object.GetNbinsX() << " " << newMEtoEDMObject[i].object.GetNbinsX()
148  << std::endl;
149  std::cout << MEtoEdmObject[j].object.GetXaxis()->GetXmin() << " "
150  << newMEtoEDMObject[i].object.GetXaxis()->GetXmin() << std::endl;
151  std::cout << MEtoEdmObject[j].object.GetXaxis()->GetXmax() << " "
152  << newMEtoEDMObject[i].object.GetXaxis()->GetXmax() << std::endl;
153  std::cout << MEtoEdmObject[j].object.GetNbinsY() << " " << newMEtoEDMObject[i].object.GetNbinsY()
154  << std::endl;
155  std::cout << MEtoEdmObject[j].object.GetYaxis()->GetXmin() << " "
156  << newMEtoEDMObject[i].object.GetYaxis()->GetXmin() << std::endl;
157  std::cout << MEtoEdmObject[j].object.GetYaxis()->GetXmax() << " "
158  << newMEtoEDMObject[i].object.GetYaxis()->GetXmax() << std::endl;
159  std::cout << MEtoEdmObject[j].object.GetNbinsZ() << " " << newMEtoEDMObject[i].object.GetNbinsZ()
160  << std::endl;
161  std::cout << MEtoEdmObject[j].object.GetZaxis()->GetXmin() << " "
162  << newMEtoEDMObject[i].object.GetZaxis()->GetXmin() << std::endl;
163  std::cout << MEtoEdmObject[j].object.GetZaxis()->GetXmax() << " "
164  << newMEtoEDMObject[i].object.GetZaxis()->GetXmax() << std::endl;
165 #endif
166  }
167  }
168  }
169  return true;
170  }
Definition: Merge.py:1
const MEtoEdmObjectVector & getMEtoEdmObject() const
Definition: MEtoEDMFormat.h:60
bool CheckBinLabels(const TAxis *a1, const TAxis *a2)
Definition: MEtoEDMFormat.h:62
std::vector< MEtoEDMObject > MEtoEdmObjectVector
Definition: MEtoEDMFormat.h:51
MEtoEdmObjectVector MEtoEdmObject

◆ mergeProduct() [2/5]

template<>
bool MEtoEDM< double >::mergeProduct ( const MEtoEDM< double > &  newMEtoEDM)
inline

Definition at line 180 of file MEtoEDMFormat.h.

References gather_cfg::cout, MEtoEDM< T >::getMEtoEdmObject(), mps_fire::i, dqmiolumiharvest::j, mergeVDriftHistosByStation::name, and AlCaHLTBitMon_QueryRunRegistry::string.

180  {
181  const MEtoEdmObjectVector &newMEtoEDMObject = newMEtoEDM.getMEtoEdmObject();
182  const size_t nObjects = newMEtoEDMObject.size();
183  // NOTE: we remember the present size since we will only add content
184  // from newMEtoEDMObject after this point
185  const size_t nOldObjects = MEtoEdmObject.size();
186 
187  // if the old and new are not the same size, we want to report a problem
188  if (nObjects != nOldObjects) {
189  std::cout << "WARNING MEtoEDM::mergeProducts(): the lists of histograms to be merged have different sizes: new="
190  << nObjects << ", old=" << nOldObjects << std::endl;
191  }
192 
193  for (unsigned int i = 0; i < nObjects; ++i) {
194  unsigned int j = 0;
195  // see if the name is already in the old container up to the point where
196  // we may have added new entries in the container
197  const std::string &name = newMEtoEDMObject[i].name;
198  if (i < nOldObjects && (MEtoEdmObject[i].name == name)) {
199  j = i;
200  } else {
201  j = 0;
202  while (j < nOldObjects && (MEtoEdmObject[j].name != name))
203  ++j;
204  }
205  if (j >= nOldObjects) {
206  // this value is only in the new container, not the old one
207 #if METOEDMFORMAT_DEBUG
208  std::cout << "WARNING MEtoEDM::mergeProducts(): adding new histogram '" << name << "'" << std::endl;
209 #endif
210  MEtoEdmObject.push_back(newMEtoEDMObject[i]);
211  }
212  }
213  return true;
214 }
const MEtoEdmObjectVector & getMEtoEdmObject() const
Definition: MEtoEDMFormat.h:60
std::vector< MEtoEDMObject > MEtoEdmObjectVector
Definition: MEtoEDMFormat.h:51
MEtoEdmObjectVector MEtoEdmObject

◆ mergeProduct() [3/5]

template<>
bool MEtoEDM< int >::mergeProduct ( const MEtoEDM< int > &  newMEtoEDM)
inline

Definition at line 217 of file MEtoEDMFormat.h.

References gather_cfg::cout, MEtoEDM< T >::getMEtoEdmObject(), mps_fire::i, dqmiolumiharvest::j, mergeVDriftHistosByStation::name, and AlCaHLTBitMon_QueryRunRegistry::string.

217  {
218  const MEtoEdmObjectVector &newMEtoEDMObject = newMEtoEDM.getMEtoEdmObject();
219  const size_t nObjects = newMEtoEDMObject.size();
220  // NOTE: we remember the present size since we will only add content
221  // from newMEtoEDMObject after this point
222  const size_t nOldObjects = MEtoEdmObject.size();
223 
224  // if the old and new are not the same size, we want to report a problem
225  if (nObjects != nOldObjects) {
226  std::cout << "WARNING MEtoEDM::mergeProducts(): the lists of histograms to be merged have different sizes: new="
227  << nObjects << ", old=" << nOldObjects << std::endl;
228  }
229 
230  for (unsigned int i = 0; i < nObjects; ++i) {
231  unsigned int j = 0;
232  // see if the name is already in the old container up to the point where
233  // we may have added new entries in the container
234  const std::string &name = newMEtoEDMObject[i].name;
235  if (i < nOldObjects && (MEtoEdmObject[i].name == name)) {
236  j = i;
237  } else {
238  j = 0;
239  while (j < nOldObjects && (MEtoEdmObject[j].name != name))
240  ++j;
241  }
242  if (j >= nOldObjects) {
243  // this value is only in the new container, not the old one
244 #if METOEDMFORMAT_DEBUG
245  std::cout << "WARNING MEtoEDM::mergeProducts(): adding new histogram '" << name << "'" << std::endl;
246 #endif
247  MEtoEdmObject.push_back(newMEtoEDMObject[i]);
248  } else {
249  // this value is also in the new container: add the two
250  if (MEtoEdmObject[j].name.find("EventInfo/processedEvents") != std::string::npos) {
251  MEtoEdmObject[j].object += (newMEtoEDMObject[i].object);
252  }
253  if (MEtoEdmObject[j].name.find("EventInfo/iEvent") != std::string::npos ||
254  MEtoEdmObject[j].name.find("EventInfo/iLumiSection") != std::string::npos) {
255  if (MEtoEdmObject[j].object < newMEtoEDMObject[i].object) {
256  MEtoEdmObject[j].object = (newMEtoEDMObject[i].object);
257  }
258  }
259  }
260  }
261  return true;
262 }
const MEtoEdmObjectVector & getMEtoEdmObject() const
Definition: MEtoEDMFormat.h:60
std::vector< MEtoEDMObject > MEtoEdmObjectVector
Definition: MEtoEDMFormat.h:51
MEtoEdmObjectVector MEtoEdmObject

◆ mergeProduct() [4/5]

template<>
bool MEtoEDM< long long >::mergeProduct ( const MEtoEDM< long long > &  newMEtoEDM)
inline

Definition at line 265 of file MEtoEDMFormat.h.

References gather_cfg::cout, MEtoEDM< T >::getMEtoEdmObject(), mps_fire::i, dqmiolumiharvest::j, mergeVDriftHistosByStation::name, and AlCaHLTBitMon_QueryRunRegistry::string.

265  {
266  const MEtoEdmObjectVector &newMEtoEDMObject = newMEtoEDM.getMEtoEdmObject();
267  const size_t nObjects = newMEtoEDMObject.size();
268  // NOTE: we remember the present size since we will only add content
269  // from newMEtoEDMObject after this point
270  const size_t nOldObjects = MEtoEdmObject.size();
271 
272  // if the old and new are not the same size, we want to report a problem
273  if (nObjects != nOldObjects) {
274  std::cout << "WARNING MEtoEDM::mergeProducts(): the lists of histograms to be merged have different sizes: new="
275  << nObjects << ", old=" << nOldObjects << std::endl;
276  }
277 
278  for (unsigned int i = 0; i < nObjects; ++i) {
279  unsigned int j = 0;
280  // see if the name is already in the old container up to the point where
281  // we may have added new entries in the container
282  const std::string &name = newMEtoEDMObject[i].name;
283  if (i < nOldObjects && (MEtoEdmObject[i].name == name)) {
284  j = i;
285  } else {
286  j = 0;
287  while (j < nOldObjects && (MEtoEdmObject[j].name != name))
288  ++j;
289  }
290  if (j >= nOldObjects) {
291  // this value is only in the new container, not the old one
292 #if METOEDMFORMAT_DEBUG
293  std::cout << "WARNING MEtoEDM::mergeProducts(): adding new histogram '" << name << "'" << std::endl;
294 #endif
295  MEtoEdmObject.push_back(newMEtoEDMObject[i]);
296  } else {
297  // this value is also in the new container: add the two
298  if (MEtoEdmObject[j].name.find("EventInfo/processedEvents") != std::string::npos) {
299  MEtoEdmObject[j].object += (newMEtoEDMObject[i].object);
300  }
301  if (MEtoEdmObject[j].name.find("EventInfo/iEvent") != std::string::npos ||
302  MEtoEdmObject[j].name.find("EventInfo/iLumiSection") != std::string::npos) {
303  if (MEtoEdmObject[j].object < newMEtoEDMObject[i].object) {
304  MEtoEdmObject[j].object = (newMEtoEDMObject[i].object);
305  }
306  }
307  }
308  }
309  return true;
310 }
const MEtoEdmObjectVector & getMEtoEdmObject() const
Definition: MEtoEDMFormat.h:60
std::vector< MEtoEDMObject > MEtoEdmObjectVector
Definition: MEtoEDMFormat.h:51
MEtoEdmObjectVector MEtoEdmObject

◆ mergeProduct() [5/5]

template<>
bool MEtoEDM< TString >::mergeProduct ( const MEtoEDM< TString > &  newMEtoEDM)
inline

Definition at line 313 of file MEtoEDMFormat.h.

References gather_cfg::cout, MEtoEDM< T >::getMEtoEdmObject(), mps_fire::i, dqmiolumiharvest::j, mergeVDriftHistosByStation::name, and AlCaHLTBitMon_QueryRunRegistry::string.

313  {
314  const MEtoEdmObjectVector &newMEtoEDMObject = newMEtoEDM.getMEtoEdmObject();
315  const size_t nObjects = newMEtoEDMObject.size();
316  // NOTE: we remember the present size since we will only add content
317  // from newMEtoEDMObject after this point
318  const size_t nOldObjects = MEtoEdmObject.size();
319 
320  // if the old and new are not the same size, we want to report a problem
321  if (nObjects != nOldObjects) {
322  std::cout << "WARNING MEtoEDM::mergeProducts(): the lists of histograms to be merged have different sizes: new="
323  << nObjects << ", old=" << nOldObjects << std::endl;
324  }
325 
326  for (unsigned int i = 0; i < nObjects; ++i) {
327  unsigned int j = 0;
328  // see if the name is already in the old container up to the point where
329  // we may have added new entries in the container
330  const std::string &name = newMEtoEDMObject[i].name;
331  if (i < nOldObjects && (MEtoEdmObject[i].name == name)) {
332  j = i;
333  } else {
334  j = 0;
335  while (j < nOldObjects && (MEtoEdmObject[j].name != name))
336  ++j;
337  }
338  if (j >= nOldObjects) {
339  // this value is only in the new container, not the old one
340 #if METOEDMFORMAT_DEBUG
341  std::cout << "WARNING MEtoEDM::mergeProducts(): adding new histogram '" << name << "'" << std::endl;
342 #endif
343  MEtoEdmObject.push_back(newMEtoEDMObject[i]);
344  }
345  }
346  return true;
347 }
const MEtoEdmObjectVector & getMEtoEdmObject() const
Definition: MEtoEDMFormat.h:60
std::vector< MEtoEDMObject > MEtoEdmObjectVector
Definition: MEtoEDMFormat.h:51
MEtoEdmObjectVector MEtoEdmObject

◆ putMEtoEdmObject()

template<class T>
void MEtoEDM< T >::putMEtoEdmObject ( const std::string &  name,
const T object 
)
inline

◆ swap()

template<class T>
void MEtoEDM< T >::swap ( MEtoEDM< T > &  iOther)
inline

Definition at line 172 of file MEtoEDMFormat.h.

References MEtoEDM< T >::MEtoEdmObject.

172 { MEtoEdmObject.swap(iOther.MEtoEdmObject); }
MEtoEdmObjectVector MEtoEdmObject

Member Data Documentation

◆ MEtoEdmObject

template<class T>
MEtoEdmObjectVector MEtoEDM< T >::MEtoEdmObject
private