CMS 3D CMS Logo

Classes | Public Types | Public Member Functions | Private Attributes

MEtoEDM< T > Class Template Reference

#include <MEtoEDMFormat.h>

List of all members.

Classes

struct  MEtoEDMObject

Public Types

typedef std::vector
< MEtoEDMObject
MEtoEdmObjectVector
typedef std::vector< uint32_t > TagList

Public Member Functions

const MEtoEdmObjectVectorgetMEtoEdmObject () const
template<>
bool mergeProduct (const MEtoEDM< TString > &newMEtoEDM)
template<>
bool mergeProduct (const MEtoEDM< double > &newMEtoEDM)
template<>
bool mergeProduct (const MEtoEDM< int > &newMEtoEDM)
template<>
bool mergeProduct (const MEtoEDM< long long > &newMEtoEDM)
bool mergeProduct (const MEtoEDM< T > &newMEtoEDM)
 MEtoEDM (size_t reservedSize)
 MEtoEDM ()
void putMEtoEdmObject (const std::string &name, const TagList &tags, 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

Date:
2010/09/14 09:12:54
Revision:
1.28
Author:
M. Strang SUNY-Buffalo

Definition at line 37 of file MEtoEDMFormat.h.


Member Typedef Documentation

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

Definition at line 55 of file MEtoEDMFormat.h.

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

Definition at line 46 of file MEtoEDMFormat.h.


Constructor & Destructor Documentation

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

Definition at line 40 of file MEtoEDMFormat.h.

{}
template<class T>
MEtoEDM< T >::MEtoEDM ( size_t  reservedSize) [inline, explicit]

Definition at line 41 of file MEtoEDMFormat.h.

References MEtoEDM< T >::MEtoEdmObject.

                                        {
    MEtoEdmObject.reserve(reservedSize);
  }
template<class T>
virtual MEtoEDM< T >::~MEtoEDM ( ) [inline, virtual]

Definition at line 44 of file MEtoEDMFormat.h.

{}

Member Function Documentation

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

Definition at line 68 of file MEtoEDMFormat.h.

References MEtoEDM< T >::MEtoEdmObject.

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

    { return MEtoEdmObject; }
template<>
bool MEtoEDM< double >::mergeProduct ( const MEtoEDM< double > &  newMEtoEDM) [inline]

Definition at line 149 of file MEtoEDMFormat.h.

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

{
  const MEtoEdmObjectVector &newMEtoEDMObject = newMEtoEDM.getMEtoEdmObject();
  const size_t nObjects = newMEtoEDMObject.size();
  //  NOTE: we remember the present size since we will only add content
  //        from newMEtoEDMObject after this point
  const size_t nOldObjects = MEtoEdmObject.size();

  // if the old and new are not the same size, we want to report a problem
  if (nObjects != nOldObjects) {
    std::cout << "WARNING MEtoEDM::mergeProducts(): the lists of histograms to be merged have different sizes: new=" << nObjects << ", old=" << nOldObjects << std::endl;
  }

  for (unsigned int i = 0; i < nObjects; ++i) {
    unsigned int j = 0;
    // see if the name is already in the old container up to the point where
    // we may have added new entries in the container
    const std::string& name = newMEtoEDMObject[i].name;
    if (i < nOldObjects && (MEtoEdmObject[i].name == name)) {
      j = i;
    } else {
      j = 0;
      while (j <  nOldObjects && (MEtoEdmObject[j].name != name) ) ++j;
    }
    if (j >= nOldObjects) {
      // this value is only in the new container, not the old one
#if debug
      std::cout << "WARNING MEtoEDM::mergeProducts(): adding new histogram '" << name << "'" << std::endl;
#endif
      MEtoEdmObject.push_back(newMEtoEDMObject[i]);
    }
  }
  return true;
}
template<>
bool MEtoEDM< long long >::mergeProduct ( const MEtoEDM< long long > &  newMEtoEDM) [inline]

Definition at line 234 of file MEtoEDMFormat.h.

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

{
  const MEtoEdmObjectVector &newMEtoEDMObject = newMEtoEDM.getMEtoEdmObject();
  const size_t nObjects = newMEtoEDMObject.size();
  //  NOTE: we remember the present size since we will only add content
  //        from newMEtoEDMObject after this point
  const size_t nOldObjects = MEtoEdmObject.size();

  // if the old and new are not the same size, we want to report a problem
  if (nObjects != nOldObjects) {
    std::cout << "WARNING MEtoEDM::mergeProducts(): the lists of histograms to be merged have different sizes: new=" << nObjects << ", old=" << nOldObjects << std::endl;
  }

  for (unsigned int i = 0; i < nObjects; ++i) {
    unsigned int j = 0;
    // see if the name is already in the old container up to the point where
    // we may have added new entries in the container
    const std::string& name = newMEtoEDMObject[i].name;
    if (i < nOldObjects && (MEtoEdmObject[i].name == name)) {
      j = i;
    } else {
      j = 0;
      while (j <  nOldObjects && (MEtoEdmObject[j].name != name) ) ++j;
    }
    if (j >= nOldObjects) {
      // this value is only in the new container, not the old one
#if debug
      std::cout << "WARNING MEtoEDM::mergeProducts(): adding new histogram '" << name << "'" << std::endl;
#endif
      MEtoEdmObject.push_back(newMEtoEDMObject[i]);
    } else {
      // this value is also in the new container: add the two
      if ( MEtoEdmObject[j].name.find("EventInfo/processedEvents") != std::string::npos ) {
        MEtoEdmObject[j].object += (newMEtoEDMObject[i].object);
      }
      if ( MEtoEdmObject[j].name.find("EventInfo/iEvent") != std::string::npos ||
           MEtoEdmObject[j].name.find("EventInfo/iLumiSection") != std::string::npos) {
        if (MEtoEdmObject[j].object < newMEtoEDMObject[i].object) {
          MEtoEdmObject[j].object = (newMEtoEDMObject[i].object);
        }
      }
    }
  }
  return true;
}
template<>
bool MEtoEDM< int >::mergeProduct ( const MEtoEDM< int > &  newMEtoEDM) [inline]

Definition at line 186 of file MEtoEDMFormat.h.

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

{
  const MEtoEdmObjectVector &newMEtoEDMObject = newMEtoEDM.getMEtoEdmObject();
  const size_t nObjects = newMEtoEDMObject.size();
  //  NOTE: we remember the present size since we will only add content
  //        from newMEtoEDMObject after this point
  const size_t nOldObjects = MEtoEdmObject.size();

  // if the old and new are not the same size, we want to report a problem
  if (nObjects != nOldObjects) {
    std::cout << "WARNING MEtoEDM::mergeProducts(): the lists of histograms to be merged have different sizes: new=" << nObjects << ", old=" << nOldObjects << std::endl;
  }

  for (unsigned int i = 0; i < nObjects; ++i) {
    unsigned int j = 0;
    // see if the name is already in the old container up to the point where
    // we may have added new entries in the container
    const std::string& name = newMEtoEDMObject[i].name;
    if (i < nOldObjects && (MEtoEdmObject[i].name == name)) {
      j = i;
    } else {
      j = 0;
      while (j <  nOldObjects && (MEtoEdmObject[j].name != name) ) ++j;
    }
    if (j >= nOldObjects) {
      // this value is only in the new container, not the old one
#if debug
      std::cout << "WARNING MEtoEDM::mergeProducts(): adding new histogram '" << name << "'" << std::endl;
#endif
      MEtoEdmObject.push_back(newMEtoEDMObject[i]);
    } else {
      // this value is also in the new container: add the two
      if ( MEtoEdmObject[j].name.find("EventInfo/processedEvents") != std::string::npos ) {
        MEtoEdmObject[j].object += (newMEtoEDMObject[i].object);
      }
      if ( MEtoEdmObject[j].name.find("EventInfo/iEvent") != std::string::npos ||
           MEtoEdmObject[j].name.find("EventInfo/iLumiSection") != std::string::npos) {
        if (MEtoEdmObject[j].object < newMEtoEDMObject[i].object) {
          MEtoEdmObject[j].object = (newMEtoEDMObject[i].object);
        }
      }
    }
  }
  return true;
}
template<>
bool MEtoEDM< TString >::mergeProduct ( const MEtoEDM< TString > &  newMEtoEDM) [inline]

Definition at line 282 of file MEtoEDMFormat.h.

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

{
  const MEtoEdmObjectVector &newMEtoEDMObject = newMEtoEDM.getMEtoEdmObject();
  const size_t nObjects = newMEtoEDMObject.size();
  //  NOTE: we remember the present size since we will only add content
  //        from newMEtoEDMObject after this point
  const size_t nOldObjects = MEtoEdmObject.size();

  // if the old and new are not the same size, we want to report a problem
  if (nObjects != nOldObjects) {
    std::cout << "WARNING MEtoEDM::mergeProducts(): the lists of histograms to be merged have different sizes: new=" << nObjects << ", old=" << nOldObjects << std::endl;
  }

  for (unsigned int i = 0; i < nObjects; ++i) {
    unsigned int j = 0;
    // see if the name is already in the old container up to the point where
    // we may have added new entries in the container
    const std::string& name = newMEtoEDMObject[i].name;
    if (i < nOldObjects && (MEtoEdmObject[i].name == name)) {
      j = i;
    } else {
      j = 0;
      while (j <  nOldObjects && (MEtoEdmObject[j].name != name) ) ++j;
    }
    if (j >= nOldObjects) {
      // this value is only in the new container, not the old one
#if debug
      std::cout << "WARNING MEtoEDM::mergeProducts(): adding new histogram '" << name << "'" << std::endl;
#endif
      MEtoEdmObject.push_back(newMEtoEDMObject[i]);
    }
  }
  return true;
}
template<class T>
bool MEtoEDM< T >::mergeProduct ( const MEtoEDM< T > &  newMEtoEDM) [inline]

Definition at line 71 of file MEtoEDMFormat.h.

References gather_cfg::cout, MEtoEDM< T >::getMEtoEdmObject(), i, j, list(), MEtoEDM< T >::MEtoEdmObject, and mergeVDriftHistosByStation::name.

                                                  {
    const MEtoEdmObjectVector &newMEtoEDMObject = newMEtoEDM.getMEtoEdmObject();
    const size_t nObjects = newMEtoEDMObject.size();
    //  NOTE: we remember the present size since we will only add content
    //        from newMEtoEDMObject after this point
    const size_t nOldObjects = MEtoEdmObject.size();

   // if the old and new are not the same size, we want to report a problem
   if (nObjects != nOldObjects) {
     std::cout << "WARNING MEtoEDM::mergeProducts(): the lists of histograms to be merged have different sizes: new=" << nObjects << ", old=" << nOldObjects << std::endl;
   }

   for (unsigned int i = 0; i < nObjects; ++i) {
     unsigned int j = 0;
     // see if the name is already in the old container up to the point where
     // we may have added new entries in the container
     const std::string& name = newMEtoEDMObject[i].name;
     if (i < nOldObjects && (MEtoEdmObject[i].name == name)) {
       j = i;
     } else {
       j = 0;
       while (j <  nOldObjects && (MEtoEdmObject[j].name != name) ) ++j;
     }
     if (j >= nOldObjects) {
       // this value is only in the new container, not the old one
#if debug
       std::cout << "WARNING MEtoEDM::mergeProducts(): adding new histogram '" << name << "'" << std::endl;
#endif
       MEtoEdmObject.push_back(newMEtoEDMObject[i]);
     } else if (MEtoEdmObject[j].object.TestBit(TH1::kCanRebin) == true && newMEtoEDMObject[i].object.TestBit(TH1::kCanRebin) == true) {
       TList list;
       list.Add((TObject*)&newMEtoEDMObject[i].object);
       if (MEtoEdmObject[j].object.Merge(&list) == -1) {
         std::cout << "ERROR MEtoEDM::mergeProducts(): merge failed for '" << name << "'" <<  std::endl;
       }
     } else {
       // this value is also in the new container: add the two 
       if (MEtoEdmObject[j].object.GetNbinsX()           == newMEtoEDMObject[i].object.GetNbinsX()           &&
           MEtoEdmObject[j].object.GetXaxis()->GetXmin() == newMEtoEDMObject[i].object.GetXaxis()->GetXmin() &&
           MEtoEdmObject[j].object.GetXaxis()->GetXmax() == newMEtoEDMObject[i].object.GetXaxis()->GetXmax() &&
           MEtoEdmObject[j].object.GetNbinsY()           == newMEtoEDMObject[i].object.GetNbinsY()           &&
           MEtoEdmObject[j].object.GetYaxis()->GetXmin() == newMEtoEDMObject[i].object.GetYaxis()->GetXmin() &&
           MEtoEdmObject[j].object.GetYaxis()->GetXmax() == newMEtoEDMObject[i].object.GetYaxis()->GetXmax() &&
           MEtoEdmObject[j].object.GetNbinsZ()           == newMEtoEDMObject[i].object.GetNbinsZ()           &&
           MEtoEdmObject[j].object.GetZaxis()->GetXmin() == newMEtoEDMObject[i].object.GetZaxis()->GetXmin() &&
           MEtoEdmObject[j].object.GetZaxis()->GetXmax() == newMEtoEDMObject[i].object.GetZaxis()->GetXmax()) {
         MEtoEdmObject[j].object.Add(&newMEtoEDMObject[i].object);
       } else {
          std::cout << "ERROR MEtoEDM::mergeProducts(): found histograms with different axis limits, '" << name << "' not merged" <<  std::endl;
#if debug
          std::cout << MEtoEdmObject[j].name                         << " " << newMEtoEDMObject[i].name                         << std::endl;
          std::cout << MEtoEdmObject[j].object.GetNbinsX()           << " " << newMEtoEDMObject[i].object.GetNbinsX()           << std::endl;
          std::cout << MEtoEdmObject[j].object.GetXaxis()->GetXmin() << " " << newMEtoEDMObject[i].object.GetXaxis()->GetXmin() << std::endl;
          std::cout << MEtoEdmObject[j].object.GetXaxis()->GetXmax() << " " << newMEtoEDMObject[i].object.GetXaxis()->GetXmax() << std::endl;
          std::cout << MEtoEdmObject[j].object.GetNbinsY()           << " " << newMEtoEDMObject[i].object.GetNbinsY()           << std::endl;
          std::cout << MEtoEdmObject[j].object.GetYaxis()->GetXmin() << " " << newMEtoEDMObject[i].object.GetYaxis()->GetXmin() << std::endl;
          std::cout << MEtoEdmObject[j].object.GetYaxis()->GetXmax() << " " << newMEtoEDMObject[i].object.GetYaxis()->GetXmax() << std::endl;
          std::cout << MEtoEdmObject[j].object.GetNbinsZ()           << " " << newMEtoEDMObject[i].object.GetNbinsZ()           << std::endl;
          std::cout << MEtoEdmObject[j].object.GetZaxis()->GetXmin() << " " << newMEtoEDMObject[i].object.GetZaxis()->GetXmin() << std::endl;
          std::cout << MEtoEdmObject[j].object.GetZaxis()->GetXmax() << " " << newMEtoEDMObject[i].object.GetZaxis()->GetXmax() << std::endl;
#endif
       }
     }
   }
   return true;
  }
template<class T>
void MEtoEDM< T >::putMEtoEdmObject ( const std::string &  name,
const TagList tags,
const T object 
) [inline]
template<class T>
void MEtoEDM< T >::swap ( MEtoEDM< T > &  iOther) [inline]

Definition at line 138 of file MEtoEDMFormat.h.

References MEtoEDM< T >::MEtoEdmObject.

                                {
    MEtoEdmObject.swap(iOther.MEtoEdmObject);
  }

Member Data Documentation

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