CMS 3D CMS Logo

stor::DQMInstance Class Reference

#include <EventFilter/StorageManager/interface/DQMInstance.h>

List of all members.

Public Member Functions

 DQMInstance (int runNumber, int lumiSection, int instance, int purgeTime, int readyTime)
DQMGroupgetDQMGroup (std::string groupName)
TTimeStamp * getFirstUpdate ()
int getInstance ()
int getLastEvent ()
TTimeStamp * getLastUpdate ()
int getLumiSection ()
int getPurgeTime ()
int getReadyTime ()
int getRunNumber ()
bool isReady (int currentTime)
bool isStale (int currentTime)
int updateObject (std::string groupName, std::string objectDirectory, TObject *object, int eventNumber)
int writeFile (std::string filePrefix, bool endRunFlag)
 ~DQMInstance ()

Static Public Member Functions

static std::string getSafeMEName (TObject *object)

Public Attributes

std::map< std::string, DQMGroup * > dqmGroups_

Protected Attributes

TTimeStamp * firstUpdate_
int instance_
int lastEvent_
TTimeStamp * lastUpdate_
int lumiSection_
int nUpdates_
int purgeTime_
int readyTime_
int runNumber_


Detailed Description

Definition at line 68 of file DQMInstance.h.


Constructor & Destructor Documentation

DQMInstance::DQMInstance ( int  runNumber,
int  lumiSection,
int  instance,
int  purgeTime,
int  readyTime 
)

Definition at line 91 of file DQMInstance.cc.

References firstUpdate_, and lastUpdate_.

00095                                        :
00096   runNumber_(runNumber),
00097   lumiSection_(lumiSection),
00098   instance_(instance),
00099   nUpdates_(0),
00100   purgeTime_(purgeTime),
00101   readyTime_(readyTime)
00102 {
00103   firstUpdate_ = new TTimeStamp();
00104   lastUpdate_  = new TTimeStamp();
00105 }

DQMInstance::~DQMInstance (  ) 

Definition at line 108 of file DQMInstance.cc.

References dqmGroups_, firstUpdate_, group, lastUpdate_, and NULL.

00109 {
00110   if ( firstUpdate_ != NULL ) { delete(firstUpdate_);}
00111   if ( lastUpdate_ != NULL )  { delete(lastUpdate_);}
00112 
00113   for (std::map<std::string, DQMGroup * >::iterator i0 = 
00114          dqmGroups_.begin(); i0 != dqmGroups_.end() ; ++i0)
00115   {
00116     DQMGroup  * group     = i0->second;
00117     if ( group != NULL ) { delete(group); } 
00118   }
00119 }


Member Function Documentation

DQMGroup * DQMInstance::getDQMGroup ( std::string  groupName  ) 

Definition at line 310 of file DQMInstance.cc.

References dqmGroups_.

Referenced by stor::DQMServiceManager::getBestDQMGroupDescriptor().

00311 { return(dqmGroups_[groupName]);}

TTimeStamp* stor::DQMInstance::getFirstUpdate (  )  [inline]

Definition at line 86 of file DQMInstance.h.

References firstUpdate_.

00086 { return(firstUpdate_);}

int stor::DQMInstance::getInstance (  )  [inline]

Definition at line 82 of file DQMInstance.h.

References instance_.

Referenced by stor::DQMServiceManager::manageDQMEventMsg().

00082 { return(instance_);}

int stor::DQMInstance::getLastEvent (  )  [inline]

Definition at line 80 of file DQMInstance.h.

References lastEvent_.

00080 { return(lastEvent_);}

TTimeStamp* stor::DQMInstance::getLastUpdate (  )  [inline]

Definition at line 87 of file DQMInstance.h.

References lastUpdate_.

00087 { return(lastUpdate_);}

int stor::DQMInstance::getLumiSection (  )  [inline]

Definition at line 81 of file DQMInstance.h.

References lumiSection_.

Referenced by stor::DQMServiceManager::manageDQMEventMsg(), and stor::DQMServiceManager::writeAndPurgeDQMInstances().

00081 { return(lumiSection_);}

int stor::DQMInstance::getPurgeTime (  )  [inline]

Definition at line 83 of file DQMInstance.h.

References purgeTime_.

00083 { return(purgeTime_);}

int stor::DQMInstance::getReadyTime (  )  [inline]

Definition at line 84 of file DQMInstance.h.

References readyTime_.

00084 { return(readyTime_);}

int stor::DQMInstance::getRunNumber (  )  [inline]

Definition at line 79 of file DQMInstance.h.

References runNumber_.

Referenced by stor::DQMServiceManager::manageDQMEventMsg().

00079 { return(runNumber_);}

std::string DQMInstance::getSafeMEName ( TObject *  object  )  [static]

Definition at line 317 of file DQMInstance.cc.

References lat::RegexpMatch::matchString(), and s_rxmeval().

Referenced by edm::DQMHttpSource::getOneDQMEvent(), and updateObject().

00318 {
00319   std::string rawName = object->GetName();
00320   std::string safeName = rawName;
00321 
00322   lat::RegexpMatch patternMatch;
00323   if (dynamic_cast<TObjString *>(object) &&
00324       s_rxmeval.match(rawName, 0, 0, &patternMatch)) {
00325     safeName = patternMatch.matchString(rawName, 1);
00326   }
00327 
00328   return safeName;
00329 }

bool DQMInstance::isReady ( int  currentTime  ) 

Definition at line 175 of file DQMInstance.cc.

References dqmGroups_, group, stor::DQMGroup::isReady(), and NULL.

Referenced by stor::DQMServiceManager::writeAndPurgeDQMInstances().

00176 {
00177   bool readyFlag = true;
00178 
00179   // 29-Oct-2008, KAB - if there are no groups, switch
00180   // the default to false so that newly constructed DQMInstance
00181   // objects don't report ready==true before any groups have
00182   // even been created.
00183   if (dqmGroups_.size() == 0) readyFlag = false;
00184 
00185   for (std::map<std::string, DQMGroup * >::iterator i0 = 
00186          dqmGroups_.begin(); i0 != dqmGroups_.end() ; ++i0)
00187   {
00188     DQMGroup  * group     = i0->second;
00189     if ( group != NULL && ! group->isReady(currentTime) ) {
00190       readyFlag = false;
00191     }
00192   }
00193   return readyFlag;
00194 }

bool DQMInstance::isStale ( int  currentTime  ) 

Definition at line 196 of file DQMInstance.cc.

References lastUpdate_, and purgeTime_.

Referenced by stor::DQMServiceManager::writeAndPurgeDQMInstances().

00197 {
00198   return( ( currentTime - lastUpdate_->GetSec() ) > purgeTime_);
00199 }

int DQMInstance::updateObject ( std::string  groupName,
std::string  objectDirectory,
TObject *  object,
int  eventNumber 
)

Definition at line 122 of file DQMInstance.cc.

References stor::DQMGroup::dqmFolders_, dqmGroups_, stor::DQMFolder::dqmObjects_, getSafeMEName(), group, stor::DQMGroup::incrementUpdates(), lastEvent_, lastUpdate_, NULL, nUpdates_, readyTime_, and stor::DQMGroup::setLastEvent().

Referenced by stor::DQMServiceManager::manageDQMEventMsg().

00126 {
00127   lastEvent_ = eventNumber;
00128   std::string objectName = getSafeMEName(object);
00129   DQMGroup * group = dqmGroups_[groupName];
00130   if ( group == NULL )
00131   {
00132     group = new DQMGroup(readyTime_);
00133     dqmGroups_[groupName] = group;
00134   }
00135 
00136   DQMFolder * folder = group->dqmFolders_[objectDirectory];
00137   if ( folder == NULL )
00138   {
00139     folder = new DQMFolder();
00140     group->dqmFolders_[objectDirectory] = folder;
00141   }
00142 
00143   group->setLastEvent(eventNumber);
00144   TObject * storedObject = folder->dqmObjects_[objectName];
00145   if ( storedObject == NULL )
00146   {
00147     folder->dqmObjects_[objectName] = object->Clone(object->GetName());
00148   }
00149   else
00150   {
00151     if ( object->InheritsFrom("TH1") && 
00152          storedObject->InheritsFrom("TH1") )
00153     {
00154       TH1 * newHistogram    = (TH1 *)object;
00155       TH1 * storedHistogram = (TH1 *)storedObject;
00156       storedHistogram->Add(newHistogram);
00157     }
00158     else
00159     {
00160       // 15-Jul-2008, KAB - switch to the first instance at the 
00161       // request of Andreas Meyer...
00162 
00164       //delete(storedObject);
00165       //folder->dqmObjects_[objectName] = object->Clone(object->GetName());
00166     }
00167   }
00168 
00169   group->incrementUpdates();
00170   nUpdates_++;
00171   lastUpdate_->Set();
00172   return(nUpdates_);
00173 }

int DQMInstance::writeFile ( std::string  filePrefix,
bool  endRunFlag 
)

Definition at line 201 of file DQMInstance.cc.

References stor::DQMGroup::dqmFolders_, dqmGroups_, lat::endl(), FDEBUG, file, aod_PYTHIA_cfg::fileName, group, i1, i2, j, lumiSection_, NULL, path(), runNumber_, and cmsScimarkStop::tokens.

Referenced by stor::DQMServiceManager::writeAndPurgeDQMInstances().

00202 {
00203   int reply = 0;
00204   char fileName[1024];
00205   TTimeStamp now;
00206   now.Set();
00207   std::string runString("Run ");
00208   runString.append(boost::lexical_cast<std::string>(runNumber_));
00209 
00210   for (std::map<std::string, DQMGroup * >::iterator i0 = 
00211          dqmGroups_.begin(); i0 != dqmGroups_.end() ; ++i0)
00212   {
00213     DQMGroup * group = i0->second;
00214     if (endRunFlag) {
00215       sprintf(fileName,"%s/DQM_V0001_EvF_R%9.9d.root", 
00216               filePrefix.c_str(), runNumber_);
00217     }
00218     else {
00219       sprintf(fileName,"%s/DQM_V0001_EvF_R%9.9d_L%6.6d.root", 
00220               filePrefix.c_str(), runNumber_, lumiSection_);
00221     }
00222 
00223     TFile * file = new TFile(fileName,"UPDATE");
00224     if (( file != NULL ) && file->IsOpen())
00225     {
00226       int ctr=0;
00227 
00228       // First create directories inside the root file
00229       TString token("/");
00230       for ( std::map<std::string, DQMFolder *>::iterator i1 = 
00231               group->dqmFolders_.begin(); i1 != group->dqmFolders_.end(); ++i1)
00232       {
00233         std::string folderName = i1->first;
00234         TString path(folderName.c_str());
00235         DQMFolder * folder = i1->second;
00236 
00237         TObjArray * tokens = path.Tokenize(token);
00238 
00239         // 15-Oct-2008, KAB - add several extra levels to the
00240         // directory structure to match consumer-based histograms.
00241         // The TObjArray is the owner of the memory used by its elements,
00242         // so it takes care of deleting the extra entries that we add.
00243         TObjString * tmpEntry;
00244         int origSize = tokens->GetEntries();
00245         if (origSize >= 2) {
00246           tokens->Expand(origSize + 3);
00247         }
00248         else {
00249           tokens->Expand(origSize + 2);
00250         }
00251         for (int idx = origSize-1; idx >= 0; --idx) {
00252           tmpEntry = (TObjString *) tokens->RemoveAt(idx);
00253           if (origSize >= 2 && idx > 0) {
00254             tokens->AddAt(tmpEntry, idx+3);
00255           }
00256           else {
00257             tokens->AddAt(tmpEntry, idx+2);
00258           }
00259         }
00260         if (origSize >= 2) {
00261           tmpEntry = new TObjString("Run summary");
00262           tokens->AddAt(tmpEntry, 3);
00263         }
00264         tmpEntry = new TObjString(runString.c_str());
00265         tokens->AddAt(tmpEntry, 1);
00266         tmpEntry = new TObjString("DQMData");
00267         tokens->AddAt(tmpEntry, 0);
00268 
00269         int nTokens = tokens->GetEntries();
00270         TDirectory * newDir = NULL;
00271         TDirectory * oldDir = (TDirectory *)file;
00272         for ( int j=0; j<nTokens; j++)
00273         {
00274           TString newDirName = ((TObjString *)tokens->At(j))->String();
00275           oldDir->cd();
00276           newDir = oldDir->GetDirectory(newDirName.Data(),kFALSE,"cd");
00277           if ( newDir == NULL )
00278           {
00279             newDir = oldDir->mkdir(newDirName.Data());
00280           }
00281           oldDir = newDir;
00282         }
00283         delete(tokens);
00284         oldDir->cd();
00285 
00286         for ( std::map<std::string, TObject *>::iterator i2 = 
00287               folder->dqmObjects_.begin(); i2 != folder->dqmObjects_.end(); 
00288               ++i2)
00289         {
00290           std::string objectName = i2->first;
00291           TObject *object = i2->second;
00292           if ( object != NULL ) 
00293           {
00294             object->Write();
00295             reply++;
00296             ctr++;
00297           }
00298         }
00299       }
00300       file->Close();
00301       delete(file);
00302       chmod(fileName,S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH );
00303       FDEBUG(1) << "Wrote file " << fileName << " " << ctr << " objects"
00304                 << std::endl; 
00305     }
00306   }
00307   return(reply);
00308 }


Member Data Documentation

std::map<std::string, DQMGroup *> stor::DQMInstance::dqmGroups_

Definition at line 96 of file DQMInstance.h.

Referenced by getDQMGroup(), isReady(), updateObject(), writeFile(), and ~DQMInstance().

TTimeStamp* stor::DQMInstance::firstUpdate_ [protected]

Definition at line 105 of file DQMInstance.h.

Referenced by DQMInstance(), getFirstUpdate(), and ~DQMInstance().

int stor::DQMInstance::instance_ [protected]

Definition at line 104 of file DQMInstance.h.

Referenced by getInstance().

int stor::DQMInstance::lastEvent_ [protected]

Definition at line 102 of file DQMInstance.h.

Referenced by getLastEvent(), and updateObject().

TTimeStamp* stor::DQMInstance::lastUpdate_ [protected]

Definition at line 106 of file DQMInstance.h.

Referenced by DQMInstance(), getLastUpdate(), isStale(), updateObject(), and ~DQMInstance().

int stor::DQMInstance::lumiSection_ [protected]

Definition at line 103 of file DQMInstance.h.

Referenced by getLumiSection(), and writeFile().

int stor::DQMInstance::nUpdates_ [protected]

Definition at line 107 of file DQMInstance.h.

Referenced by updateObject().

int stor::DQMInstance::purgeTime_ [protected]

Definition at line 108 of file DQMInstance.h.

Referenced by getPurgeTime(), and isStale().

int stor::DQMInstance::readyTime_ [protected]

Definition at line 109 of file DQMInstance.h.

Referenced by getReadyTime(), and updateObject().

int stor::DQMInstance::runNumber_ [protected]

Definition at line 101 of file DQMInstance.h.

Referenced by getRunNumber(), and writeFile().


The documentation for this class was generated from the following files:
Generated on Tue Jun 9 18:52:50 2009 for CMSSW by  doxygen 1.5.4