CMS 3D CMS Logo

Classes | Enumerations | Functions

ecaldqm Namespace Reference

Classes

struct  MeInfo
class  MeInfoMap

Enumerations

enum  BinningType { kCrystal, kSuperCrystal, kTriggerTower }
enum  Directions { kLeft, kRight }
enum  ObjectType {
  kFullEE, kEEp, kEEm, kEEpFar,
  kEEpNear, kEEmFar, kEEmNear, kSM
}

Functions

MonitorElementbookME (DQMStore *dqmStore, const std::string &name, const std::string &title, const std::string &className, ObjectType otype, BinningType btype=kCrystal, int ism=0, double lowZ=0., double highZ=0., const char *option="s")
void calcBins (int binWidth, int divisor, long int start_time, long int last_time, long int current_time, long int &binDiff, long int &diff)
TObject * cloneIt (MonitorElement *me, std::string histo)
void fillME (MonitorElement *me, const EEDetId &id, double wz=1., double wprof=1.)
void fillME (MonitorElement *me, const EcalTrigTowerDetId &id, double wz=1., double wprof=1.)
void fillME (MonitorElement *me, const EcalScDetId &id, double wz=1., double wprof=1.)
void getAverageFromTProfile (TProfile *p, double &mean, double &rms)
double getBinContentME (MonitorElement *me, const EEDetId &id)
double getBinContentME (MonitorElement *me, const EcalScDetId &id)
double getBinContentME (MonitorElement *me, const EcalTrigTowerDetId &id)
double getBinEntriesME (MonitorElement *me, const EcalScDetId &id)
double getBinEntriesME (MonitorElement *me, const EcalTrigTowerDetId &id)
double getBinEntriesME (MonitorElement *me, const EEDetId &id)
double getBinErrorME (MonitorElement *me, const EEDetId &id)
double getBinErrorME (MonitorElement *me, const EcalScDetId &id)
double getBinErrorME (MonitorElement *me, const EcalTrigTowerDetId &id)
int getBinME (MonitorElement *me, const EEDetId &id)
int getBinME (MonitorElement *me, const EcalScDetId &id)
int getBinME (MonitorElement *me, const EcalTrigTowerDetId &id)
void getMeanRms (TObject *pre, TObject *cur, double &mean, double &rms)
void setBinContentME (MonitorElement *me, const EEDetId &id, double content)
void setBinContentME (MonitorElement *me, const EcalScDetId &id, double content)
void setBinContentME (MonitorElement *me, const EcalTrigTowerDetId &id, double content)
void setBinEntriesME (MonitorElement *me, const EEDetId &id, double entries)
void setBinEntriesME (MonitorElement *me, const EcalTrigTowerDetId &id, double entries)
void setBinEntriesME (MonitorElement *me, const EcalScDetId &id, double entries)
void setBinErrorME (MonitorElement *me, const EcalTrigTowerDetId &id, double error)
void setBinErrorME (MonitorElement *me, const EcalScDetId &id, double error)
void setBinErrorME (MonitorElement *me, const EEDetId &id, double error)
void shift (TH1 *h, Directions d, int bins)
void shift2Left (TH1 *h, int bins)
void shift2Right (TH1 *h, int bins)
void shiftAxis (TH1 *h, Directions d, double shift)

Enumeration Type Documentation

Enumerator:
kCrystal 
kSuperCrystal 
kTriggerTower 

Definition at line 32 of file GeometryHelper.h.

Enumerator:
kLeft 
kRight 

Definition at line 23 of file UtilFunctions.h.

                  {
    kLeft,
    kRight
  };
Enumerator:
kFullEE 
kEEp 
kEEm 
kEEpFar 
kEEpNear 
kEEmFar 
kEEmNear 
kSM 

Definition at line 23 of file GeometryHelper.h.


Function Documentation

MonitorElement * ecaldqm::bookME ( DQMStore dqmStore,
const std::string &  name,
const std::string &  title,
const std::string &  className,
ObjectType  otype,
BinningType  btype = kCrystal,
int  ism = 0,
double  lowZ = 0.,
double  highZ = 0.,
const char *  option = "s" 
)

Definition at line 48 of file GeometryHelper.cc.

References DQMStore::book2D(), DQMStore::bookProfile2D(), Numbers::ix0EE(), Numbers::iy0EE(), kCrystal, kEEm, kEEmFar, kEEmNear, kEEp, kEEpFar, kEEpNear, kFullEE, kSM, kSuperCrystal, kTriggerTower, NULL, and ecaldqm::MeInfoMap::set().

  {
    if( !dqmStore ) return NULL;

    if( className != "TH2F" && className != "TProfile2D" ) return NULL;

    Double_t xmin, ymin;
    Double_t xmax, ymax;

    xmin = ymin = 0.;
    xmax = ymax = 0.;

    switch(otype){
    case kFullEE:
      xmax = 200.;
      ymax = 100.;
      break;
    case kEEp:
    case kEEm:
      xmax = 100.;
      ymax = 100.;
      break;
    case kEEpFar:
    case kEEmFar:
      xmin = 50.;
      xmax = 100.;
      ymax = 100.;
      break;
    case kEEpNear:
    case kEEmNear:
      xmax = 50.;
      ymax = 100.;
      break;
    case kSM:
      xmin = Numbers::ix0EE(ism);
      xmax = xmin + 50;
      ymin = Numbers::iy0EE(ism);
      ymax = ymin + 50;
      break;
    }

    Int_t nBinsX, nBinsY;

    switch(btype){
    case kCrystal:
    case kTriggerTower:
      nBinsX = (Int_t)(xmax - xmin);
      nBinsY = (Int_t)(ymax - ymin);
      break;
    case kSuperCrystal:
      nBinsX = (Int_t)(xmax - xmin) / 5;
      nBinsY = (Int_t)(ymax - ymin) / 5;
      break;
    default:
      nBinsX = nBinsY = 0;
      break;
    }

    MonitorElement *me;

    if( className == "TH2F" )
      me = dqmStore->book2D(name, title, nBinsX, xmin, xmax, nBinsY, ymin, ymax);
    else
      me = dqmStore->bookProfile2D(name, title, nBinsX, xmin, xmax, nBinsY, ymin, ymax, lowZ, highZ);

    MeInfoMap::set( me, otype, btype, ism );

    return me;
  }
void ecaldqm::calcBins ( int  binWidth,
int  divisor,
long int  start_time,
long int  last_time,
long int  current_time,
long int &  binDiff,
long int &  diff 
)

Definition at line 29 of file UtilFunctions.cc.

References evf::utils::start_time.

Referenced by EBTrendTask::analyze(), EETrendClient::analyze(), EETrendTask::analyze(), and EBTrendClient::analyze().

                                                     {

    // changing arguments : binDiff, diff

    // binWidth : time interval
    // divisor : time unit - for minute case divisor is 60 and for hour case 3600
    // start_time : initial time when the job started
    // last_time : the last updated time before calling the current "analyze" function
    // current_time : the current time inside "analyze" fucntion
    // binDiff : the bin difference for the current time compared to the bin location of the last time
    // diff : time difference between the current time and the last time

    long int diff_current_start = current_time - start_time;
    long int diff_last_start = last_time - start_time;

    // --------------------------------------------------
    // Calculate time interval and bin width
    // --------------------------------------------------

    binDiff = diff_current_start/divisor/binWidth - diff_last_start/divisor/binWidth;
    diff = (current_time - last_time)/divisor;

    if(diff >= binWidth) {
      while(diff >= binWidth) diff -= binWidth;
    }

  } // calcBins
TObject * ecaldqm::cloneIt ( MonitorElement me,
std::string  histo 
)

Definition at line 257 of file UtilFunctions.cc.

References MonitorElement::getRootObject(), runTheMatrix::ret, and indexGen::title.

Referenced by EETrendClient::analyze(), and EBTrendClient::analyze().

                                                        {

    // The cloned object, ret should be deleted after using it.

    TObject* ret = 0;

    if(!me) return ret;

    std::string title = histo + " Clone";
    ret = (TObject*) (me->getRootObject()->Clone(title.c_str()));

    return ret;
  }
void ecaldqm::fillME ( MonitorElement me,
const EEDetId id,
double  wz = 1.,
double  wprof = 1. 
)

Definition at line 119 of file GeometryHelper.cc.

References ecaldqm::MeInfo::btype, MonitorElement::DQM_KIND_TH2F, MonitorElement::DQM_KIND_TPROFILE2D, MonitorElement::Fill(), ecaldqm::MeInfoMap::get(), Numbers::getEcalScDetId(), Numbers::getElectronicsMapping(), EcalElectronicsMapping::getTriggerElectronicsId(), EcalElectronicsMapping::getTrigTowerDetId(), info, kCrystal, kFullEE, MonitorElement::kind(), kSM, kSuperCrystal, kTriggerTower, Association::map, ecaldqm::MeInfo::otype, x, and detailsBasic3DVector::y.

  {

    if( !me ) return;

    const MeInfo *info = MeInfoMap::get( me );

    if( !info ) return;

    if(info->btype == kCrystal){

      float x = id.ix() - 0.5;
      float y = id.iy() - 0.5;
      if( info->otype == kSM && id.zside() < 0 ) x = 100 - x;
      if( info->otype == kFullEE && id.zside() > 0 ) x += 100;

      if( me->kind() == MonitorElement::DQM_KIND_TH2F ) me->Fill( x, y, wz );
      else if( me->kind() == MonitorElement::DQM_KIND_TPROFILE2D ) me->Fill( x, y, wz, wprof );
      return;

    }else if(info->btype == kSuperCrystal){

      EcalScDetId scid( Numbers::getEcalScDetId( id ) );
      fillME( me, scid, wz, wprof );
      return;

    }else if(info->btype == kTriggerTower){

      const EcalElectronicsMapping *map = Numbers::getElectronicsMapping();
      EcalTriggerElectronicsId teid( map->getTriggerElectronicsId( id ) );
      EcalTrigTowerDetId ttid( map->getTrigTowerDetId( teid.tccId(), teid.ttId() ) );
      fillME( me, ttid, wz, wprof );
      return;

    }

  }
void ecaldqm::fillME ( MonitorElement me,
const EcalTrigTowerDetId id,
double  wz = 1.,
double  wprof = 1. 
)

Definition at line 202 of file GeometryHelper.cc.

References ecaldqm::MeInfo::btype, Numbers::crystals(), MonitorElement::DQM_KIND_TH2F, MonitorElement::DQM_KIND_TPROFILE2D, MonitorElement::Fill(), ecaldqm::MeInfoMap::get(), info, EEDetId::ix(), EEDetId::iy(), kCrystal, kFullEE, MonitorElement::kind(), kSM, kTriggerTower, ecaldqm::MeInfo::otype, x, detailsBasic3DVector::y, and EEDetId::zside().

  {

    if( !me ) return;

    const MeInfo *info = MeInfoMap::get( me );

    if( !info ) return;

    if(info->btype == kTriggerTower || info->btype == kCrystal){

      std::vector<DetId> vcry = *( Numbers::crystals( id ) );
      for(unsigned u = 0; u < vcry.size(); u++){
        EEDetId cid( vcry[u] );

        float x = cid.ix() - 0.5;
        float y = cid.iy() - 0.5;
        if( info->otype == kSM && cid.zside() < 0 ) x = 100 - x;
        if( info->otype == kFullEE && cid.zside() > 0 ) x += 100;

        if( me->kind() == MonitorElement::DQM_KIND_TH2F ) me->Fill( x, y, wz );
        else if( me->kind() == MonitorElement::DQM_KIND_TPROFILE2D ) me->Fill( x, y, wz, wprof );
      }
      return;

    }

  }
void ecaldqm::fillME ( MonitorElement me,
const EcalScDetId id,
double  wz = 1.,
double  wprof = 1. 
)

Definition at line 158 of file GeometryHelper.cc.

References ecaldqm::MeInfo::btype, EcalElectronicsMapping::dccTowerConstituents(), MonitorElement::DQM_KIND_TH2F, MonitorElement::DQM_KIND_TPROFILE2D, MonitorElement::Fill(), ecaldqm::MeInfoMap::get(), EcalElectronicsMapping::getDCCandSC(), Numbers::getElectronicsMapping(), info, EEDetId::ix(), EEDetId::iy(), kCrystal, kFullEE, MonitorElement::kind(), kSM, kSuperCrystal, Association::map, ecaldqm::MeInfo::otype, AlCaHLTBitMon_ParallelJobs::p, x, detailsBasic3DVector::y, and EEDetId::zside().

  {

    if( !me ) return;

    const MeInfo *info = MeInfoMap::get( me );

    if( !info ) return;

    if(info->btype == kCrystal){

      const EcalElectronicsMapping *map = Numbers::getElectronicsMapping();
      std::pair<int,int> p = map->getDCCandSC( id );
      std::vector<DetId> vcry = map->dccTowerConstituents( p.first, p.second );
      for(unsigned u = 0; u < vcry.size(); u++){
        EEDetId cid( vcry[u] );

        float x = cid.ix() - 0.5;
        float y = cid.iy() - 0.5;
        if( info->otype == kSM && cid.zside() < 0 ) x = 100 - x;
        if( info->otype == kFullEE && cid.zside() > 0 ) x += 100;

        if( me->kind() == MonitorElement::DQM_KIND_TH2F ) me->Fill( x, y, wz );
        else if( me->kind() == MonitorElement::DQM_KIND_TPROFILE2D ) me->Fill( x, y, wz, wprof );

      }
      return;

    }else if(info->btype == kSuperCrystal){

      float x = id.ix() * 5 - 2.5;
      float y = id.iy() * 5 - 2.5;
      if( info->otype == kSM && id.zside() < 0 ) x = 100 - x;
      if( info->otype == kFullEE && id.zside() > 0 ) x += 100;

      if( me->kind() == MonitorElement::DQM_KIND_TH2F ) me->Fill( x, y, wz );
      else if( me->kind() == MonitorElement::DQM_KIND_TPROFILE2D ) me->Fill( x, y, wz, wprof );
      return;

    }

  }
void ecaldqm::getAverageFromTProfile ( TProfile *  p,
double &  mean,
double &  rms 
)

Definition at line 191 of file UtilFunctions.cc.

References i, pileupCalc::nbins, mathSSE::sqrt(), and detailsBasic3DVector::y.

Referenced by getMeanRms().

                                                                      {

    // changing arguments : mean, rms
    mean = rms = 0.0;

    if(!p) return;

    int nbins = p->GetXaxis()->GetNbins();
    double y = 0.0;
    double y2 = 0.0;
    for(int i=1; i<=nbins; i++){
      y += p->GetBinContent(i);
      y2 += y*y;
    }
    mean = y/nbins;
    rms = std::sqrt(y2/nbins - mean*mean);

  } // getAverageFromTProfile
double ecaldqm::getBinContentME ( MonitorElement me,
const EEDetId id 
)

Definition at line 383 of file GeometryHelper.cc.

References MonitorElement::DQM_KIND_TH1F, getBinME(), MonitorElement::getRootObject(), and MonitorElement::kind().

  {
    if( !me ) return 0.;
    if( me->kind() < MonitorElement::DQM_KIND_TH1F ) return 0.;

    return ((TH1 *)me->getRootObject())->GetBinContent( getBinME( me, id ) );
  }
double ecaldqm::getBinContentME ( MonitorElement me,
const EcalScDetId id 
)

Definition at line 392 of file GeometryHelper.cc.

References MonitorElement::DQM_KIND_TH1F, getBinME(), MonitorElement::getRootObject(), and MonitorElement::kind().

  {
    if( !me ) return 0.;
    if( me->kind() < MonitorElement::DQM_KIND_TH1F ) return 0.;

    return ((TH1 *)me->getRootObject())->GetBinContent( getBinME( me, id ) );
  }
double ecaldqm::getBinContentME ( MonitorElement me,
const EcalTrigTowerDetId id 
)

Definition at line 401 of file GeometryHelper.cc.

References ecaldqm::MeInfo::btype, Numbers::crystals(), MonitorElement::DQM_KIND_TH1F, ecaldqm::MeInfoMap::get(), getBinME(), MonitorElement::getRootObject(), info, MonitorElement::kind(), and kTriggerTower.

  {
    if( !me ) return 0.;
    if( me->kind() < MonitorElement::DQM_KIND_TH1F ) return 0.;

    const MeInfo *info = MeInfoMap::get( me );
    if( !info || info->btype != kTriggerTower ) return 0.;

    std::vector<DetId> *crystals = Numbers::crystals( id );
    if( !crystals->size() ) return 0.;

    return ((TH1 *)me->getRootObject())->GetBinContent( getBinME( me, EEDetId( crystals->at(0) ) ) );
  }
double ecaldqm::getBinEntriesME ( MonitorElement me,
const EcalScDetId id 
)

Definition at line 458 of file GeometryHelper.cc.

References MonitorElement::DQM_KIND_TPROFILE2D, getBinME(), MonitorElement::getRootObject(), and MonitorElement::kind().

  {
    if( !me ) return 0.;
    if( me->kind() != MonitorElement::DQM_KIND_TPROFILE2D ) return 0.;

    return ((TProfile2D *)me->getRootObject())->GetBinEntries( getBinME( me, id ) );
  }
double ecaldqm::getBinEntriesME ( MonitorElement me,
const EcalTrigTowerDetId id 
)

Definition at line 467 of file GeometryHelper.cc.

References ecaldqm::MeInfo::btype, Numbers::crystals(), MonitorElement::DQM_KIND_TPROFILE2D, ecaldqm::MeInfoMap::get(), getBinME(), MonitorElement::getRootObject(), info, MonitorElement::kind(), and kTriggerTower.

  {
    if( !me ) return 0.;
    if( me->kind() != MonitorElement::DQM_KIND_TPROFILE2D ) return 0.;

    const MeInfo *info = MeInfoMap::get( me );
    if( !info || info->btype != kTriggerTower ) return 0.;

    std::vector<DetId> *crystals = Numbers::crystals( id );
    if( !crystals->size() ) return 0.;


    return ((TProfile2D *)me->getRootObject())->GetBinEntries( getBinME( me, EEDetId( crystals->at(0) ) ) );
  }
double ecaldqm::getBinEntriesME ( MonitorElement me,
const EEDetId id 
)

Definition at line 449 of file GeometryHelper.cc.

References MonitorElement::DQM_KIND_TPROFILE2D, getBinME(), MonitorElement::getRootObject(), and MonitorElement::kind().

  {
    if( !me ) return 0.;
    if( me->kind() != MonitorElement::DQM_KIND_TPROFILE2D ) return 0.;

    return ((TProfile2D *)me->getRootObject())->GetBinEntries( getBinME( me, id ) );
  }
double ecaldqm::getBinErrorME ( MonitorElement me,
const EEDetId id 
)

Definition at line 416 of file GeometryHelper.cc.

References MonitorElement::DQM_KIND_TH1F, getBinME(), MonitorElement::getRootObject(), and MonitorElement::kind().

  {
    if( !me ) return 0.;
    if( me->kind() < MonitorElement::DQM_KIND_TH1F ) return 0.;

    return ((TH1 *)me->getRootObject())->GetBinError( getBinME( me, id ) );
  }
double ecaldqm::getBinErrorME ( MonitorElement me,
const EcalScDetId id 
)

Definition at line 425 of file GeometryHelper.cc.

References MonitorElement::DQM_KIND_TH1F, getBinME(), MonitorElement::getRootObject(), and MonitorElement::kind().

  {
    if( !me ) return 0.;
    if( me->kind() < MonitorElement::DQM_KIND_TH1F ) return 0.;

    return ((TH1 *)me->getRootObject())->GetBinError( getBinME( me, id ) );
  }
double ecaldqm::getBinErrorME ( MonitorElement me,
const EcalTrigTowerDetId id 
)

Definition at line 434 of file GeometryHelper.cc.

References ecaldqm::MeInfo::btype, Numbers::crystals(), MonitorElement::DQM_KIND_TH1F, ecaldqm::MeInfoMap::get(), getBinME(), MonitorElement::getRootObject(), info, MonitorElement::kind(), and kTriggerTower.

  {
    if( !me ) return 0.;
    if( me->kind() < MonitorElement::DQM_KIND_TH1F ) return 0.;

    const MeInfo *info = MeInfoMap::get( me );
    if( !info || info->btype != kTriggerTower ) return 0.;

    std::vector<DetId> *crystals = Numbers::crystals( id );
    if( !crystals->size() ) return 0.;

    return ((TH1 *)me->getRootObject())->GetBinError( getBinME( me, EEDetId( crystals->at(0) ) ) );
  }
int ecaldqm::getBinME ( MonitorElement me,
const EEDetId id 
)

Definition at line 232 of file GeometryHelper.cc.

References ecaldqm::MeInfo::btype, MonitorElement::DQM_KIND_TH2F, MonitorElement::DQM_KIND_TH3F, MonitorElement::DQM_KIND_TPROFILE, ecaldqm::MeInfoMap::get(), info, ecalpyutils::ism(), ecaldqm::MeInfo::ism, Numbers::ix0EE(), Numbers::iy0EE(), kEEm, kEEmFar, kEEmNear, kEEp, kEEpFar, kEEpNear, kFullEE, MonitorElement::kind(), kSM, kSuperCrystal, ecaldqm::MeInfo::otype, and pileupReCalc_HLTpaths::scale.

Referenced by getBinContentME(), getBinEntriesME(), getBinErrorME(), setBinContentME(), setBinEntriesME(), and setBinErrorME().

  {
    if( !me ) return -1;
    int kind = me->kind();
    if( kind < MonitorElement::DQM_KIND_TH2F || 
        kind == MonitorElement::DQM_KIND_TPROFILE ||
        kind == MonitorElement::DQM_KIND_TH3F ) return -1;

    const MeInfo *info = MeInfoMap::get( me );
    if( !info ) return -1;

    int ix = id.ix();
    int iy = id.iy();
    int zside = id.zside();
    int nx;
    int ism = info->ism;

    if(info->otype == kSM){

      if(zside > 0){
        ix -= Numbers::ix0EE(ism);
        iy -= Numbers::iy0EE(ism);
      }else{
        ix = 101 - ix - Numbers::ix0EE(ism);
        iy -= Numbers::iy0EE(ism);
      }
      nx = 50;

    }else{

      switch(info->otype){
      case kFullEE:
        if(zside > 0) ix += 100;
        nx = 200;
        break;
      case kEEp:
        if(zside < 0) return -1;
        nx = 100;
        break;
      case kEEm:
        if(zside > 0) return -1;
        nx = 100;
        break;
      case kEEpFar:
        if(zside < 0 || ix > 50) return -1;
        nx = 50;
        break;
      case kEEpNear:
        if(zside < 0 || ix < 51) return -1;
        ix -= 50;
        nx = 50;
        break;
      case kEEmFar:
        if(zside > 0 || ix > 50) return -1;
        nx = 50;
        break;
      case kEEmNear:
        if(zside > 0 || ix < 51) return -1;
        ix -= 50;
        nx = 50;
        break;
      default:
        return -1;
      }

    }

    int scale = info->btype == kSuperCrystal ? 5 : 1;
    ix = (ix - 1) / scale + 1;
    iy = (iy - 1) / scale + 1;
    nx = nx / scale;

    return iy * (nx + 2) + ix;
  }
int ecaldqm::getBinME ( MonitorElement me,
const EcalScDetId id 
)

Definition at line 308 of file GeometryHelper.cc.

References ecaldqm::MeInfo::btype, MonitorElement::DQM_KIND_TH2F, MonitorElement::DQM_KIND_TH3F, MonitorElement::DQM_KIND_TPROFILE, ecaldqm::MeInfoMap::get(), info, ecalpyutils::ism(), ecaldqm::MeInfo::ism, Numbers::ix0EE(), Numbers::iy0EE(), kEEm, kEEmFar, kEEmNear, kEEp, kEEpFar, kEEpNear, kFullEE, MonitorElement::kind(), kSM, kSuperCrystal, and ecaldqm::MeInfo::otype.

  {
    if( !me ) return -1;
    int kind = me->kind();
    if( kind < MonitorElement::DQM_KIND_TH2F || 
        kind == MonitorElement::DQM_KIND_TPROFILE ||
        kind == MonitorElement::DQM_KIND_TH3F ) return -1;

    const MeInfo *info = MeInfoMap::get( me );
    if( !info ) return -1;

    if(info->btype != kSuperCrystal) return -1;

    int ix = id.ix();
    int iy = id.iy();
    int zside = id.zside();
    int nx;
    int ism = info->ism;

    if(info->otype == kSM){

      if(zside > 0){
        ix -= Numbers::ix0EE(ism) / 5;
        iy -= Numbers::iy0EE(ism) / 5;
      }else{
        ix = 21 - ix - Numbers::ix0EE(ism) / 5;
        iy -= Numbers::iy0EE(ism) / 5;
      }
      nx = 10;

    }else{

      switch(info->otype){
      case kFullEE:
        if(zside > 0) ix += 20;
        nx = 40;
        break;
      case kEEp:
        if(zside < 0) return -1;
        nx = 20;
        break;
      case kEEm:
        if(zside > 0) return -1;
        nx = 20;
        break;
      case kEEpFar:
        if(zside < 0 || ix > 10) return -1;
        nx = 10;
        break;
      case kEEpNear:
        if(zside < 0 || ix < 11) return -1;
        ix -= 10;
        nx = 10;
        break;
      case kEEmFar:
        if(zside > 0 || ix > 10) return -1;
        nx = 10;
        break;
      case kEEmNear:
        if(zside > 0 || ix < 11) return -1;
        ix -= 10;
        nx = 10;
        break;
      default:
        return -1;
      }

    }

    return iy * (nx + 2) + ix;

  }
int ecaldqm::getBinME ( MonitorElement me,
const EcalTrigTowerDetId id 
)
void ecaldqm::getMeanRms ( TObject *  pre,
TObject *  cur,
double &  mean,
double &  rms 
)

Definition at line 213 of file UtilFunctions.cc.

References getAverageFromTProfile(), mergeVDriftHistosByStation::name, and mathSSE::sqrt().

Referenced by EETrendClient::analyze(), and EBTrendClient::analyze().

                                                                         {

    // changing arguments : mean, rms

    mean = rms = 0.0;

    if(!cur) return;

    TString name(cur->IsA()->GetName());

    if(name.Contains("TProfile")) {
      getAverageFromTProfile((TProfile*)cur,mean,rms);
    }
    else if(name.Contains("TH2")) {
      if(pre) {
        mean = ((TH2F*)cur)->GetEntries() - ((TH2F*)pre)->GetEntries();
        if(mean < 0) return;
        rms = std::sqrt(mean);
      }
      else {
        mean = ((TH2F*)cur)->GetEntries();
        if(mean < 0) return;
        rms = std::sqrt(mean);
      }
      float nxybins = ((TH2F*)cur)->GetNbinsX()*((TH2F*)cur)->GetNbinsY();
      if(nxybins < 1.) nxybins = 1.;
      mean /= nxybins;
      rms /= nxybins;
    }
    else if(name.Contains("TH1")) {
      if(pre) {
        ((TH1F*)pre)->Sumw2();
        ((TH1F*)pre)->Add((TH1F*)pre,(TH1F*)cur,-1,1);
        mean = ((TH1F*)pre)->GetMean();
        rms = ((TH1F*)pre)->GetRMS();
      }
      else {
        mean = ((TH1F*)cur)->GetMean();
        rms = ((TH1F*)cur)->GetRMS();
      }
    }

  } // getMeanRms
void ecaldqm::setBinContentME ( MonitorElement me,
const EEDetId id,
double  content 
)

Definition at line 483 of file GeometryHelper.cc.

References ecaldqm::MeInfo::btype, MonitorElement::DQM_KIND_TH1F, ecaldqm::MeInfoMap::get(), getBinME(), Numbers::getEcalScDetId(), Numbers::getElectronicsMapping(), MonitorElement::getRootObject(), EcalElectronicsMapping::getTriggerElectronicsId(), info, kCrystal, MonitorElement::kind(), kSuperCrystal, kTriggerTower, Association::map, and EcalElectronicsMapping::ttConstituents().

  {
    if( !me ) return;
    if( me->kind() < MonitorElement::DQM_KIND_TH1F ) return;

    const MeInfo *info = MeInfoMap::get( me );
    if( !info ) return;

    if(info->btype == kCrystal){

      ((TH1 *)me->getRootObject())->SetBinContent( getBinME( me, id ), content );
      return;

    }else if(info->btype == kSuperCrystal){

      EcalScDetId scid( Numbers::getEcalScDetId( id ) );
      ((TH1 *)me->getRootObject())->SetBinContent( getBinME( me, id ), content );
      return;

    }else if(info->btype == kTriggerTower){

      const EcalElectronicsMapping *map = Numbers::getElectronicsMapping();
      EcalTriggerElectronicsId teid( map->getTriggerElectronicsId( id ) );
      std::vector<DetId> vcry = map->ttConstituents( teid.tccId(), teid.ttId() );
      for(unsigned u = 0; u < vcry.size(); u++)
        ((TH1 *)me->getRootObject())->SetBinContent( getBinME( me, EEDetId(vcry[u]) ), content );
      return;

    }
  }
void ecaldqm::setBinContentME ( MonitorElement me,
const EcalScDetId id,
double  content 
)

Definition at line 515 of file GeometryHelper.cc.

References ecaldqm::MeInfo::btype, EcalElectronicsMapping::dccTowerConstituents(), MonitorElement::DQM_KIND_TH1F, ecaldqm::MeInfoMap::get(), getBinME(), EcalElectronicsMapping::getDCCandSC(), Numbers::getElectronicsMapping(), MonitorElement::getRootObject(), info, kCrystal, MonitorElement::kind(), kSuperCrystal, Association::map, and AlCaHLTBitMon_ParallelJobs::p.

  {
    if( !me ) return;
    if( me->kind() < MonitorElement::DQM_KIND_TH1F ) return;

    const MeInfo *info = MeInfoMap::get( me );
    if( !info ) return;

    if(info->btype == kCrystal){

      const EcalElectronicsMapping *map = Numbers::getElectronicsMapping();
      std::pair<int,int> p = map->getDCCandSC( id );
      std::vector<DetId> vcry = map->dccTowerConstituents( p.first, p.second );
      for(unsigned u = 0; u < vcry.size(); u++)
        ((TH1 *)me->getRootObject())->SetBinContent( getBinME( me, EEDetId(vcry[u]) ), content );
      return;

    }else if(info->btype == kSuperCrystal){

      ((TH1 *)me->getRootObject())->SetBinContent( getBinME( me, id ), content );
      return;

    }
  }
void ecaldqm::setBinContentME ( MonitorElement me,
const EcalTrigTowerDetId id,
double  content 
)

Definition at line 541 of file GeometryHelper.cc.

References ecaldqm::MeInfo::btype, Numbers::crystals(), MonitorElement::DQM_KIND_TH1F, ecaldqm::MeInfoMap::get(), getBinME(), MonitorElement::getRootObject(), info, kCrystal, MonitorElement::kind(), and kTriggerTower.

  {
    if( !me ) return;
    if( me->kind() < MonitorElement::DQM_KIND_TH1F ) return;

    const MeInfo *info = MeInfoMap::get( me );
    if( !info ) return;

    if(info->btype == kCrystal || info->btype == kTriggerTower){

      std::vector<DetId> *crystals = Numbers::crystals( id );
      for(unsigned u = 0; u < crystals->size(); u++)
        ((TH1 *)me->getRootObject())->SetBinContent( getBinME( me, EEDetId(crystals->at(u)) ), content );
      return;

    }
  }
void ecaldqm::setBinEntriesME ( MonitorElement me,
const EEDetId id,
double  entries 
)

Definition at line 637 of file GeometryHelper.cc.

References ecaldqm::MeInfo::btype, MonitorElement::DQM_KIND_TPROFILE2D, python::tagInventory::entries, ecaldqm::MeInfoMap::get(), getBinME(), Numbers::getEcalScDetId(), Numbers::getElectronicsMapping(), MonitorElement::getRootObject(), EcalElectronicsMapping::getTriggerElectronicsId(), info, kCrystal, MonitorElement::kind(), kSuperCrystal, kTriggerTower, Association::map, and EcalElectronicsMapping::ttConstituents().

  {
    if( !me ) return;
    if( me->kind() != MonitorElement::DQM_KIND_TPROFILE2D ) return;

    const MeInfo *info = MeInfoMap::get( me );
    if( !info ) return;

    if(info->btype == kCrystal){

      ((TProfile2D *)me->getRootObject())->SetBinEntries( getBinME( me, id ), entries );
      return;

    }else if(info->btype == kSuperCrystal){

      EcalScDetId scid( Numbers::getEcalScDetId( id ) );
      ((TProfile2D *)me->getRootObject())->SetBinError( getBinME( me, id ), entries );
      return;

    }else if(info->btype == kTriggerTower){

      const EcalElectronicsMapping *map = Numbers::getElectronicsMapping();
      EcalTriggerElectronicsId teid( map->getTriggerElectronicsId( id ) );
      std::vector<DetId> vcry = map->ttConstituents( teid.tccId(), teid.ttId() );
      for(unsigned u = 0; u < vcry.size(); u++)
        ((TProfile2D *)me->getRootObject())->SetBinError( getBinME( me, EEDetId(vcry[u]) ), entries );
      return;

    }

  }
void ecaldqm::setBinEntriesME ( MonitorElement me,
const EcalTrigTowerDetId id,
double  entries 
)

Definition at line 696 of file GeometryHelper.cc.

References ecaldqm::MeInfo::btype, Numbers::crystals(), MonitorElement::DQM_KIND_TPROFILE2D, python::tagInventory::entries, ecaldqm::MeInfoMap::get(), getBinME(), MonitorElement::getRootObject(), info, kCrystal, MonitorElement::kind(), and kTriggerTower.

  {
    if( !me ) return;
    if( me->kind() != MonitorElement::DQM_KIND_TPROFILE2D ) return;

    const MeInfo *info = MeInfoMap::get( me );
    if( !info ) return;

    if(info->btype == kCrystal || info->btype == kTriggerTower){

      std::vector<DetId> *crystals = Numbers::crystals( id );
      for(unsigned u = 0; u < crystals->size(); u++)
        ((TProfile2D *)me->getRootObject())->SetBinError( getBinME( me, EEDetId(crystals->at(u)) ), entries );
      return;

    }
  }
void ecaldqm::setBinEntriesME ( MonitorElement me,
const EcalScDetId id,
double  entries 
)

Definition at line 670 of file GeometryHelper.cc.

References ecaldqm::MeInfo::btype, EcalElectronicsMapping::dccTowerConstituents(), MonitorElement::DQM_KIND_TPROFILE2D, python::tagInventory::entries, ecaldqm::MeInfoMap::get(), getBinME(), EcalElectronicsMapping::getDCCandSC(), Numbers::getElectronicsMapping(), MonitorElement::getRootObject(), info, kCrystal, MonitorElement::kind(), kSuperCrystal, Association::map, and AlCaHLTBitMon_ParallelJobs::p.

  {
    if( !me ) return;
    if( me->kind() != MonitorElement::DQM_KIND_TPROFILE2D ) return;

    const MeInfo *info = MeInfoMap::get( me );
    if( !info ) return;

    if(info->btype == kCrystal){

      const EcalElectronicsMapping *map = Numbers::getElectronicsMapping();
      std::pair<int,int> p = map->getDCCandSC( id );
      std::vector<DetId> vcry = map->dccTowerConstituents( p.first, p.second );
      for(unsigned u = 0; u < vcry.size(); u++)
        ((TProfile2D *)me->getRootObject())->SetBinEntries( getBinME( me, EEDetId(vcry[u]) ), entries );
      return;

    }else if(info->btype == kSuperCrystal){

      ((TProfile2D *)me->getRootObject())->SetBinError( getBinME( me, id ), entries );
      return;

    }
  }
void ecaldqm::setBinErrorME ( MonitorElement me,
const EcalTrigTowerDetId id,
double  error 
)

Definition at line 618 of file GeometryHelper.cc.

References ecaldqm::MeInfo::btype, Numbers::crystals(), MonitorElement::DQM_KIND_TH1F, error, ecaldqm::MeInfoMap::get(), getBinME(), MonitorElement::getRootObject(), info, kCrystal, MonitorElement::kind(), and kTriggerTower.

  {
    if( !me ) return;
    if( me->kind() < MonitorElement::DQM_KIND_TH1F ) return;

    const MeInfo *info = MeInfoMap::get( me );
    if( !info ) return;

    if(info->btype == kCrystal || info->btype == kTriggerTower){

      std::vector<DetId> *crystals = Numbers::crystals( id );
      for(unsigned u = 0; u < crystals->size(); u++)
        ((TH1 *)me->getRootObject())->SetBinError( getBinME( me, EEDetId(crystals->at(u)) ), error );
      return;

    }
  }
void ecaldqm::setBinErrorME ( MonitorElement me,
const EcalScDetId id,
double  error 
)

Definition at line 592 of file GeometryHelper.cc.

References ecaldqm::MeInfo::btype, EcalElectronicsMapping::dccTowerConstituents(), MonitorElement::DQM_KIND_TH1F, error, ecaldqm::MeInfoMap::get(), getBinME(), EcalElectronicsMapping::getDCCandSC(), Numbers::getElectronicsMapping(), MonitorElement::getRootObject(), info, kCrystal, MonitorElement::kind(), kSuperCrystal, Association::map, and AlCaHLTBitMon_ParallelJobs::p.

  {
    if( !me ) return;
    if( me->kind() < MonitorElement::DQM_KIND_TH1F ) return;

    const MeInfo *info = MeInfoMap::get( me );
    if( !info ) return;

    if(info->btype == kCrystal){

      const EcalElectronicsMapping *map = Numbers::getElectronicsMapping();
      std::pair<int,int> p = map->getDCCandSC( id );
      std::vector<DetId> vcry = map->dccTowerConstituents( p.first, p.second );
      for(unsigned u = 0; u < vcry.size(); u++)
        ((TH1 *)me->getRootObject())->SetBinError( getBinME( me, EEDetId(vcry[u]) ), error );
      return;

    }else if(info->btype == kSuperCrystal){

      ((TH1 *)me->getRootObject())->SetBinError( getBinME( me, id ), error );
      return;

    }
  }
void ecaldqm::setBinErrorME ( MonitorElement me,
const EEDetId id,
double  error 
)

Definition at line 560 of file GeometryHelper.cc.

References ecaldqm::MeInfo::btype, MonitorElement::DQM_KIND_TH1F, error, ecaldqm::MeInfoMap::get(), getBinME(), Numbers::getEcalScDetId(), Numbers::getElectronicsMapping(), MonitorElement::getRootObject(), EcalElectronicsMapping::getTriggerElectronicsId(), info, kCrystal, MonitorElement::kind(), kSuperCrystal, kTriggerTower, Association::map, and EcalElectronicsMapping::ttConstituents().

  {
    if( !me ) return;
    if( me->kind() < MonitorElement::DQM_KIND_TH1F ) return;

    const MeInfo *info = MeInfoMap::get( me );
    if( !info ) return;

    if(info->btype == kCrystal){

      ((TH1 *)me->getRootObject())->SetBinError( getBinME( me, id ), error );
      return;

    }else if(info->btype == kSuperCrystal){

      EcalScDetId scid( Numbers::getEcalScDetId( id ) );
      ((TH1 *)me->getRootObject())->SetBinError( getBinME( me, id ), error );
      return;

    }else if(info->btype == kTriggerTower){

      const EcalElectronicsMapping *map = Numbers::getElectronicsMapping();
      EcalTriggerElectronicsId teid( map->getTriggerElectronicsId( id ) );
      std::vector<DetId> vcry = map->ttConstituents( teid.tccId(), teid.ttId() );
      for(unsigned u = 0; u < vcry.size(); u++)
        ((TH1 *)me->getRootObject())->SetBinError( getBinME( me, EEDetId(vcry[u]) ), error );
      return;

    }
  }
void ecaldqm::shift ( TH1 *  h,
Directions  d,
int  bins 
)

Definition at line 58 of file UtilFunctions.cc.

References h, i, j, kLeft, kRight, and AlCaHLTBitMon_ParallelJobs::p.

Referenced by shift2Left(), and shift2Right().

  {
    if(!bins || !h) return;
    if(h->GetXaxis()->IsVariableBinSize()) return;

    if(bins < 0){
      bins = -bins;
      d = d==kRight ? kLeft : kRight;
    }

    if(!h->GetSumw2()) h->Sumw2();
    int nBins = h->GetXaxis()->GetNbins();
    if(bins >= nBins){
      h->Reset();
      return;
    }

    // the first bin goes to underflow
    // each bin moves to the right

    int firstBin, lastBin, bound, increment;
    switch(d){
    case kRight:
      firstBin = nBins + 1;
      lastBin = 0;
      bound = bins;
      increment = -1;
      break;
    case kLeft:
      firstBin = 0;
      lastBin = nBins + 1;
      bound = nBins - bins + 1;
      increment = 1;
      break;
    default:
      return;
    }

    int shift = increment * bins;

    if( h->IsA() == TClass::GetClass("TProfile") ){

      TProfile *p = static_cast<TProfile *>(h);

      // by shifting n bin to the left, the number of entries are
      // reduced by the number in n bins including the underflow bin.
      double nentries = p->GetEntries();
      for(int i = firstBin; i != firstBin + shift; i += increment) nentries -= p->GetBinEntries(i);
      p->SetEntries(nentries);

      TArrayD* sumw2 = p->GetSumw2();

      for(int i = firstBin; i != bound; i += increment){
        // GetBinContent returns binContent/binEntries
        p->SetBinContent( i, p->GetBinContent( i+shift ) * p->GetBinEntries( i+shift ) );
        p->SetBinEntries( i, p->GetBinEntries( i+shift ) );
        sumw2->SetAt( sumw2->GetAt( i+shift ), i );
      }

      for(int i = bound; i != lastBin + increment; i += increment){
        p->SetBinContent( i, 0 );
        p->SetBinEntries( i, 0 );
        sumw2->SetAt( 0., i );
      }

    }else if( h->InheritsFrom("TH2") ){

      TH2 *h2 = static_cast<TH2 *>(h);
      int nBinsY = h2->GetYaxis()->GetNbins();

      // assumes sum(binContent) == entries
      double nentries = h2->GetEntries();
      for(int i = firstBin; i != firstBin + shift; i += increment)
        for(int j=0 ; j<=nBinsY+1 ; j++) nentries -= h2->GetBinContent(i,j);

      h2->SetEntries(nentries);

      for(int i = firstBin; i != bound; i += increment)
        for(int j = 0; j <= nBinsY + 1; j++)
          h2->SetBinContent( i, j, h2->GetBinContent(i+shift, j) );

      for(int i = bound; i != lastBin + increment; i += increment)
        for(int j = 0; j <= nBinsY + 1; j++)
          h2->SetBinContent( i, j, 0 );
          
    }else if( h->InheritsFrom("TH1") ){ // any other histogram class

      // assumes sum(binContent) == entries
      double nentries = h->GetEntries();
      for(int i = firstBin; i != firstBin + shift; i += increment) nentries -= h->GetBinContent(i);

      h->SetEntries(nentries);

      for(int i = firstBin; i != bound; i += increment)
        h->SetBinContent( i, h->GetBinContent(i+shift) );

      for(int i = bound; i != lastBin + increment; i += increment)
        h->SetBinContent( i, 0 );
    }


  }
void ecaldqm::shift2Left ( TH1 *  h,
int  bins 
)

Definition at line 166 of file UtilFunctions.cc.

References kLeft, and shift().

  {
    shift(h, kLeft, bins);
  }
void ecaldqm::shift2Right ( TH1 *  h,
int  bins 
)
void ecaldqm::shiftAxis ( TH1 *  h,
Directions  d,
double  shift 
)

Definition at line 173 of file UtilFunctions.cc.

References kLeft, kRight, and pileupCalc::nbins.

  {
    if( !h ) return;
    TAxis *xax = h->GetXaxis();
    if( h->GetXaxis()->IsVariableBinSize() ) return;

    double xmax = xax->GetXmax();
    double xmin = xax->GetXmin();
    int nbins = xax->GetNbins();

    if(d == kRight)
      xax->Set(nbins, xmin - shift, xmax - shift);
    else if(d == kLeft)
      xax->Set(nbins, xmin + shift, xmax + shift);
  }