CMS 3D CMS Logo

Public Member Functions | Private Types | Private Member Functions | Private Attributes | Static Private Attributes

EcalTrigPrimFunctionalAlgo Class Reference

#include <EcalTrigPrimFunctionalAlgo.h>

List of all members.

Public Member Functions

 EcalTrigPrimFunctionalAlgo (const edm::EventSetup &setup, int binofmax, bool tcpFormat, bool barrelOnly, bool debug, bool famos)
void run (const edm::EventSetup &, const EEDigiCollection *col, EcalTrigPrimDigiCollection &result, EcalTrigPrimDigiCollection &resultTcp)
void run (const edm::EventSetup &, const EBDigiCollection *col, EcalTrigPrimDigiCollection &result, EcalTrigPrimDigiCollection &resultTcp)
void run_part1_EB (EBDigiCollection const *col)
void run_part1_EE (EEDigiCollection const *col)
template<class Coll >
void run_part2 (const edm::EventSetup &, Coll const *col, std::vector< std::vector< std::pair< int, std::vector< typename Coll::Digi > > > > &towerMap, EcalTrigPrimDigiCollection &result, EcalTrigPrimDigiCollection &resultTcp)
void setPointers (const EcalTPGLinearizationConst *ecaltpLin, const EcalTPGPedestals *ecaltpPed, const EcalTPGSlidingWindow *ecaltpgSlidW, const EcalTPGWeightIdMap *ecaltpgWeightMap, const EcalTPGWeightGroup *ecaltpgWeightGroup, const EcalTPGFineGrainStripEE *ecaltpgFgStripEE, const EcalTPGCrystalStatus *ecaltpgBadX, const EcalTPGStripStatus *ecaltpgStripStatus)
void setPointers2 (const EcalTPGFineGrainEBGroup *ecaltpgFgEBGroup, const EcalTPGLutGroup *ecaltpgLutGroup, const EcalTPGLutIdMap *ecaltpgLut, const EcalTPGFineGrainEBIdMap *ecaltpgFineGrainEB, const EcalTPGFineGrainTowerEE *ecaltpgFineGrainTowerEE, const EcalTPGTowerStatus *ecaltpgBadTT, const EcalTPGSpike *ecaltpgSpike)
virtual ~EcalTrigPrimFunctionalAlgo ()

Private Types

enum  { nbMaxStrips_ = 5 }
enum  { nbMaxXtals_ = 5 }

Private Member Functions

template<class T >
void clean (std::vector< std::vector< std::pair< int, std::vector< T > > > > &towerMap)
template<class Coll >
void fillMap (Coll const *col, std::vector< std::vector< std::pair< int, std::vector< typename Coll::Digi > > > > &towerMap)
int findStripNr (const EBDetId &id)
int findStripNr (const EEDetId &id)
int getIndex (const EBDigiCollection *, EcalTrigTowerDetId &id)
int getIndex (const EEDigiCollection *, EcalTrigTowerDetId &id)
void init (const edm::EventSetup &)
template<class T >
void initStructures (std::vector< std::vector< std::pair< int, std::vector< T > > > > &towMap)

Private Attributes

bool barrelOnly_
int binOfMaximum_
bool debug_
EcalFenixStripestrip_
EcalFenixTcpetcp_
edm::ESHandle
< EcalTrigTowerConstituentsMap
eTTmap_
bool famos_
std::vector< std::pair< int,
EcalTrigTowerDetId > > 
hitTowers_
int maxNrSamples_
int nrTowers_
std::vector< std::vector< int > > striptp_
bool tcpFormat_
const CaloSubdetectorGeometrytheEndcapGeometry
const EcalElectronicsMappingtheMapping_
float threshold
std::vector< std::vector
< std::pair< int, std::vector
< EBDataFrame > > > > 
towerMapEB_
std::vector< std::vector
< std::pair< int, std::vector
< EEDataFrame > > > > 
towerMapEE_
std::vector
< EcalTriggerPrimitiveSample
towtp2_
std::vector
< EcalTriggerPrimitiveSample
towtp_

Static Private Attributes

static const unsigned int maxNrSamplesOut_ = 10
static const unsigned int maxNrTowers_ = 2448
static const unsigned int maxNrTPs_ = 2448
static const unsigned int nrSamples_ = 5

Detailed Description

EcalTrigPrimFunctionalAlgo is the main algorithm class for TPG It coordinates all the aother algorithms Structure is as close as possible to electronics

Author:
Ursula Berthon, Stephanie Baffioni, LLR Palaiseau
Version:
1st Version may 2006
2nd Version jul 2006
3rd Version sep 2007 introducing new Records closer to the db

EcalTrigPrimFunctionalAlgo is the main algorithm class for TPG It coordinates all the aother algorithms Structure is very close to electronics

Author:
Ursula Berthon, Stephanie Baffioni, LLR Palaiseau
Version:
1st Version may 2006
2nd Version jul 2006

Definition at line 48 of file EcalTrigPrimFunctionalAlgo.h.


Member Enumeration Documentation

anonymous enum [private]
Enumerator:
nbMaxStrips_ 

Definition at line 134 of file EcalTrigPrimFunctionalAlgo.h.

anonymous enum [private]
Enumerator:
nbMaxXtals_ 

Definition at line 135 of file EcalTrigPrimFunctionalAlgo.h.


Constructor & Destructor Documentation

EcalTrigPrimFunctionalAlgo::EcalTrigPrimFunctionalAlgo ( const edm::EventSetup setup,
int  binofmax,
bool  tcpFormat,
bool  barrelOnly,
bool  debug,
bool  famos 
) [explicit]

Definition at line 51 of file EcalTrigPrimFunctionalAlgo.cc.

References famos_, init(), and maxNrSamples_.

                                                                                                                                                    : binOfMaximum_(binofmax),
  tcpFormat_(tcpFormat), barrelOnly_(barrelOnly), debug_(debug), famos_(famos)

{
 if (famos_) maxNrSamples_=1;  //get from input??
 else maxNrSamples_=10;
 this->init(setup);
}
EcalTrigPrimFunctionalAlgo::~EcalTrigPrimFunctionalAlgo ( ) [virtual]

Definition at line 90 of file EcalTrigPrimFunctionalAlgo.cc.

References estrip_, and etcp_.

{
    delete estrip_;
    delete etcp_;
}

Member Function Documentation

template<class T >
void EcalTrigPrimFunctionalAlgo::clean ( std::vector< std::vector< std::pair< int, std::vector< T > > > > &  towerMap) [private]

Definition at line 280 of file EcalTrigPrimFunctionalAlgo.h.

References i, j, maxNrTowers_, and nbMaxStrips_.

Referenced by run_part1_EB(), and run_part1_EE().

                                                                                                   {  
  // clean internal data structures
  for (unsigned int i=0;i<maxNrTowers_;++i) 
    for (int j=0;j<nbMaxStrips_ ;++j) (towMap[i])[j].first=0;
  return;
}
template<class Coll >
void EcalTrigPrimFunctionalAlgo::fillMap ( Coll const *  col,
std::vector< std::vector< std::pair< int, std::vector< typename Coll::Digi > > > > &  towerMap 
) [private]

Definition at line 239 of file EcalTrigPrimFunctionalAlgo.h.

References findStripNr(), first, getIndex(), hitTowers_, i, getHLTprescales::index, LogDebug, nbMaxXtals_, nrTowers_, and edm::second().

Referenced by run_part1_EB(), and run_part1_EE().

{
  typedef typename Coll::Digi Digi;

  // implementation for Barrel and Endcap

  if (col) {
    nrTowers_=0;
    LogDebug("EcalTPG") <<"Fill mapping, Collection size = "<<col->size();
    for(unsigned int i = 0; i < col->size() ; ++i) {
      Digi samples((*col)[i]); 
      EcalTrigTowerDetId coarser=(*eTTmap_).towerOf(samples.id());
      int index=getIndex(col,coarser);
      int stripnr=findStripNr(samples.id());

      int filled=0;
      for (unsigned int ij=0;ij<towerMap[index].size();++ij) filled+=towerMap[index][ij].first;
      if (!filled) {
        hitTowers_[nrTowers_++]=std::pair <int,EcalTrigTowerDetId>(index,coarser);
      }

      //FIXME: temporary protection
      int ncryst=towerMap[index][stripnr-1].first;
      if (ncryst>=nbMaxXtals_ ) {
        edm::LogError("EcalTrigPrimFunctionAlgo")<<"! Too many xtals for TT "<<coarser<<" stripnr "<<stripnr<<" xtalid "<<samples.id() ;
        continue;
      }
      ((towerMap[index])[stripnr-1].second)[ncryst]=samples;
      (towerMap[index])[stripnr-1].first++;
    }
  
    LogDebug("EcalTPG")<<"fillMap"<<"[EcalTrigPrimFunctionalAlgo] (found " 
                       << col->size() << " frames in "<< towerMap.size() << " towers) ";
  }
  else {
    LogDebug("EcalTPG")<<"FillMap - FillMap Collection size=0 !!!!";
  }
}
int EcalTrigPrimFunctionalAlgo::findStripNr ( const EBDetId id) [private]

Definition at line 114 of file EcalTrigPrimFunctionalAlgo.cc.

References n, and nbMaxStrips_.

Referenced by fillMap().

                                                             {
  int stripnr;
  int n=((id.ic()-1)%100)/20; //20 corresponds to 4 * ecal_barrel_crystals_per_strip FIXME!!
  if (id.ieta()<0) stripnr = n+1;
  else stripnr =nbMaxStrips_ - n; 
  return stripnr;
}
int EcalTrigPrimFunctionalAlgo::findStripNr ( const EEDetId id) [private]
int EcalTrigPrimFunctionalAlgo::getIndex ( const EEDigiCollection ,
EcalTrigTowerDetId id 
) [inline, private]

Definition at line 96 of file EcalTrigPrimFunctionalAlgo.h.

                                                                  {
    int ind=(id.ietaAbs()-18)*72 + id.iphi();
    if (id.zside()<0) ind+=792;
    return ind;
  }
int EcalTrigPrimFunctionalAlgo::getIndex ( const EBDigiCollection ,
EcalTrigTowerDetId id 
) [inline, private]

Definition at line 94 of file EcalTrigPrimFunctionalAlgo.h.

Referenced by fillMap().

{return id.hashedIndex();}
void EcalTrigPrimFunctionalAlgo::init ( const edm::EventSetup setup) [private]
template<class T >
void EcalTrigPrimFunctionalAlgo::initStructures ( std::vector< std::vector< std::pair< int, std::vector< T > > > > &  towMap) [private]

Definition at line 288 of file EcalTrigPrimFunctionalAlgo.h.

References i, maxNrSamples_, maxNrTowers_, nbMaxStrips_, nbMaxXtals_, and striptp_.

Referenced by init().

                                                                                                            {  
  //initialise internal data structures

  std::vector <T> vec0(nbMaxXtals_ );
  std::vector<std::pair<int,std::vector<T> > > vec1(nbMaxStrips_);
  for (int i=0;i<nbMaxStrips_ ;++i) vec1[i]=std::pair<int,std::vector<T> >(0,vec0);
  towMap.resize(maxNrTowers_); 
  for (unsigned int i=0;i<maxNrTowers_;++i) towMap[i]=vec1;
  
  std::vector<int> vecint(maxNrSamples_);
  striptp_.resize(nbMaxStrips_);
  for (int i=0;i<nbMaxStrips_;++i) striptp_[i]=vecint;
  
}
void EcalTrigPrimFunctionalAlgo::run ( const edm::EventSetup setup,
const EEDigiCollection col,
EcalTrigPrimDigiCollection result,
EcalTrigPrimDigiCollection resultTcp 
)

Definition at line 105 of file EcalTrigPrimFunctionalAlgo.cc.

References run_part1_EE(), run_part2(), and towerMapEE_.

{

  run_part1_EE(col);
  run_part2(setup, col,towerMapEE_,result,resultTcp);
}
void EcalTrigPrimFunctionalAlgo::run ( const edm::EventSetup setup,
const EBDigiCollection col,
EcalTrigPrimDigiCollection result,
EcalTrigPrimDigiCollection resultTcp 
)

Definition at line 96 of file EcalTrigPrimFunctionalAlgo.cc.

References run_part1_EB(), run_part2(), and towerMapEB_.

Referenced by EcalTrigPrimProducer::produce().

{
  run_part1_EB(col);
  run_part2(setup,col,towerMapEB_,result,resultTcp);
}
void EcalTrigPrimFunctionalAlgo::run_part1_EB ( EBDigiCollection const *  col)

Definition at line 130 of file EcalTrigPrimFunctionalAlgo.cc.

References clean(), fillMap(), and towerMapEB_.

Referenced by run().

                                                                         {
  clean(towerMapEB_);
  // loop over dataframes and fill map 
  fillMap(col,towerMapEB_);
}
void EcalTrigPrimFunctionalAlgo::run_part1_EE ( EEDigiCollection const *  col)

Definition at line 136 of file EcalTrigPrimFunctionalAlgo.cc.

References clean(), fillMap(), and towerMapEE_.

Referenced by run().

                                                                         {
  clean(towerMapEE_);
  // loop over dataframes and fill map 
  fillMap(col,towerMapEE_);
}
template<class Coll >
void EcalTrigPrimFunctionalAlgo::run_part2 ( const edm::EventSetup setup,
Coll const *  col,
std::vector< std::vector< std::pair< int, std::vector< typename Coll::Digi > > > > &  towerMap,
EcalTrigPrimDigiCollection result,
EcalTrigPrimDigiCollection resultTcp 
)

Definition at line 141 of file EcalTrigPrimFunctionalAlgo.h.

References binOfMaximum_, EcalTriggerPrimitiveDigi::compressedEt(), EcalEndcap, estrip_, etcp_, first, castor_dqm_sourceclient_file_cfg::firstSample, EcalFenixStrip::getFGVB(), hitTowers_, i, EcalTrigTowerDetId::ietaAbs(), getHLTprescales::index, EcalTrigTowerDetId::iphi(), castor_dqm_sourceclient_file_cfg::lastSample, LogDebug, nrSamples_, nrTowers_, phi, EcalFenixTcp::process(), EcalFenixStrip::process(), edm::SortedCollection< T, SORT >::push_back(), edm::second(), EcalFenixStripFgvbEE::setbadStripMissing(), EcalTriggerPrimitiveDigi::setSample(), EcalTriggerPrimitiveDigi::setSize(), striptp_, EcalTrigTowerDetId::subDet(), tcpFormat_, towtp2_, towtp_, and EcalTrigTowerDetId::zside().

Referenced by run().

{
  typedef typename Coll::Digi Digi;
 
  // prepare writing of TP-s

  int firstSample = binOfMaximum_-1 -nrSamples_/2;
  int lastSample = binOfMaximum_-1 +nrSamples_/2;
  int nrTP=0;
  std::vector<typename Coll::Digi> dummy;
  EcalTriggerPrimitiveDigi tptow[2];
  EcalTriggerPrimitiveDigi tptowTcp[2];
  
  estrip_->getFGVB()->setbadStripMissing(false);

  for(int itow=0;itow<nrTowers_;++itow) 
    {

      int index=hitTowers_[itow].first;
      const EcalTrigTowerDetId &thisTower=hitTowers_[itow].second;

      // loop over all strips assigned to this trigger tower
      int nstr=0;
      for(unsigned int i = 0; i < towerMap[itow].size();++i)
        {
          std::vector<Digi> &df = (towerMap[index])[i].second;//vector of dataframes for this strip, size; nr of crystals/strip

          if ((towerMap[index])[i].first > 0) {  
            estrip_->process(setup,df,(towerMap[index])[i].first,striptp_[nstr++]);
          }
        }//loop over strips in one tower

      bool isInInnerRings=false;
      if (thisTower.subDet()==EcalEndcap && (thisTower.ietaAbs()==27 || thisTower.ietaAbs()==28 )) isInInnerRings=true;
      etcp_->process(setup,dummy,striptp_,nstr,towtp_,towtp2_,isInInnerRings,thisTower);

      // prepare TP-s
      // special treatment for 2 inner endcap rings
      int nrTowers;
      if (isInInnerRings)
        {
          nrTowers=2;
          int phi=2*((thisTower.iphi()-1)/2);
          tptow[0]=EcalTriggerPrimitiveDigi(EcalTrigTowerDetId(thisTower.zside(),thisTower.subDet(),thisTower.ietaAbs(),phi+1));
          tptow[1]=EcalTriggerPrimitiveDigi(EcalTrigTowerDetId(thisTower.zside(),thisTower.subDet(),thisTower.ietaAbs(),phi+2));

          if (tcpFormat_){
            tptowTcp[0]=EcalTriggerPrimitiveDigi(EcalTrigTowerDetId(thisTower.zside(),thisTower.subDet(),thisTower.ietaAbs(),phi+1));
            tptowTcp[1]=EcalTriggerPrimitiveDigi(EcalTrigTowerDetId(thisTower.zside(),thisTower.subDet(),thisTower.ietaAbs(),phi+2));
          }
        }else {
          nrTowers=1;
          tptow[0]=EcalTriggerPrimitiveDigi(thisTower);
          if (tcpFormat_)   tptowTcp[0]=EcalTriggerPrimitiveDigi(thisTower);
        }

      // now fill in
      for (int nrt=0;nrt<nrTowers;nrt++) {
        (tptow[nrt]).setSize(nrSamples_);
        if (towtp_.size()<nrSamples_)  {  //FIXME: only once
          edm::LogWarning("") <<"Too few samples produced, nr is "<<towtp_.size();
          break;
        }
        int isam=0;
        for (int i=firstSample;i<=lastSample;++i) {
          tptow[nrt].setSample(isam++,EcalTriggerPrimitiveSample(towtp_[i]));
        }
        nrTP++; 
        LogDebug("EcalTPG") <<" For tower "<<itow<<" created TP nr "<<nrTP<<" with Et "<<tptow[nrt].compressedEt();
        result.push_back(tptow[nrt]);
      }

      if (tcpFormat_) {

        for (int nrt=0;nrt<nrTowers;nrt++) {
          tptowTcp[nrt].setSize(nrSamples_);
          if (towtp2_.size()<nrSamples_)  {  //FIXME: only once
            edm::LogWarning("") <<"Too few samples produced, nr is "<<towtp2_.size();
            break;
          }
          int isam=0;
          for (int i=firstSample;i<=lastSample;++i) {
            if (nrTowers<=1)  tptowTcp[nrt].setSample(isam++,EcalTriggerPrimitiveSample(towtp2_[i]));
            else {
              int et=towtp2_[i].compressedEt()/2;
              tptowTcp[nrt].setSample(isam++,EcalTriggerPrimitiveSample(et,towtp2_[i].fineGrain(),towtp2_[i].ttFlag()));
            }
          }
          resultTcp.push_back(tptowTcp[nrt]);
        }
      }
    } 
  return;
}
void EcalTrigPrimFunctionalAlgo::setPointers ( const EcalTPGLinearizationConst ecaltpLin,
const EcalTPGPedestals ecaltpPed,
const EcalTPGSlidingWindow ecaltpgSlidW,
const EcalTPGWeightIdMap ecaltpgWeightMap,
const EcalTPGWeightGroup ecaltpgWeightGroup,
const EcalTPGFineGrainStripEE ecaltpgFgStripEE,
const EcalTPGCrystalStatus ecaltpgBadX,
const EcalTPGStripStatus ecaltpgStripStatus 
) [inline]

Definition at line 66 of file EcalTrigPrimFunctionalAlgo.h.

References estrip_, and EcalFenixStrip::setPointers().

Referenced by EcalTrigPrimProducer::getRecords().

                                                                                                                                                                                                                                                                                                                                                                                {
    estrip_->setPointers(ecaltpPed,ecaltpLin,ecaltpgWeightMap,ecaltpgWeightGroup,ecaltpgSlidW,ecaltpgFgStripEE,ecaltpgBadX,ecaltpgStripStatus);

  }
void EcalTrigPrimFunctionalAlgo::setPointers2 ( const EcalTPGFineGrainEBGroup ecaltpgFgEBGroup,
const EcalTPGLutGroup ecaltpgLutGroup,
const EcalTPGLutIdMap ecaltpgLut,
const EcalTPGFineGrainEBIdMap ecaltpgFineGrainEB,
const EcalTPGFineGrainTowerEE ecaltpgFineGrainTowerEE,
const EcalTPGTowerStatus ecaltpgBadTT,
const EcalTPGSpike ecaltpgSpike 
) [inline]

Definition at line 70 of file EcalTrigPrimFunctionalAlgo.h.

References etcp_, and EcalFenixTcp::setPointers().

Referenced by EcalTrigPrimProducer::getRecords().

                                                        {
   
  etcp_->setPointers(ecaltpgFgEBGroup,ecaltpgLutGroup,ecaltpgLut,ecaltpgFineGrainEB,ecaltpgFineGrainTowerEE,ecaltpgBadTT,ecaltpgSpike);
  }

Member Data Documentation

Definition at line 115 of file EcalTrigPrimFunctionalAlgo.h.

Referenced by init().

Definition at line 111 of file EcalTrigPrimFunctionalAlgo.h.

Referenced by init(), and run_part2().

Definition at line 116 of file EcalTrigPrimFunctionalAlgo.h.

Referenced by init().

Definition at line 105 of file EcalTrigPrimFunctionalAlgo.h.

Referenced by init().

Definition at line 117 of file EcalTrigPrimFunctionalAlgo.h.

Referenced by EcalTrigPrimFunctionalAlgo(), and init().

std::vector<std::pair<int,EcalTrigTowerDetId> > EcalTrigPrimFunctionalAlgo::hitTowers_ [private]

Definition at line 130 of file EcalTrigPrimFunctionalAlgo.h.

Referenced by fillMap(), init(), and run_part2().

Definition at line 112 of file EcalTrigPrimFunctionalAlgo.h.

Referenced by EcalTrigPrimFunctionalAlgo(), init(), and initStructures().

const unsigned int EcalTrigPrimFunctionalAlgo::maxNrSamplesOut_ = 10 [static, private]

Definition at line 120 of file EcalTrigPrimFunctionalAlgo.h.

Referenced by init().

const unsigned int EcalTrigPrimFunctionalAlgo::maxNrTowers_ = 2448 [static, private]

Definition at line 121 of file EcalTrigPrimFunctionalAlgo.h.

Referenced by clean(), init(), and initStructures().

const unsigned int EcalTrigPrimFunctionalAlgo::maxNrTPs_ = 2448 [static, private]

Definition at line 122 of file EcalTrigPrimFunctionalAlgo.h.

const unsigned int EcalTrigPrimFunctionalAlgo::nrSamples_ = 5 [static, private]

Definition at line 119 of file EcalTrigPrimFunctionalAlgo.h.

Referenced by run_part2().

Definition at line 124 of file EcalTrigPrimFunctionalAlgo.h.

Referenced by fillMap(), and run_part2().

std::vector<std::vector<int> > EcalTrigPrimFunctionalAlgo::striptp_ [private]

Definition at line 127 of file EcalTrigPrimFunctionalAlgo.h.

Referenced by initStructures(), and run_part2().

Definition at line 114 of file EcalTrigPrimFunctionalAlgo.h.

Referenced by init(), and run_part2().

Definition at line 106 of file EcalTrigPrimFunctionalAlgo.h.

Referenced by init().

Definition at line 107 of file EcalTrigPrimFunctionalAlgo.h.

Referenced by findStripNr(), and init().

Definition at line 109 of file EcalTrigPrimFunctionalAlgo.h.

std::vector<std::vector<std::pair<int,std::vector<EBDataFrame> > > > EcalTrigPrimFunctionalAlgo::towerMapEB_ [private]

Definition at line 128 of file EcalTrigPrimFunctionalAlgo.h.

Referenced by init(), run(), and run_part1_EB().

std::vector<std::vector<std::pair<int,std::vector<EEDataFrame> > > > EcalTrigPrimFunctionalAlgo::towerMapEE_ [private]

Definition at line 129 of file EcalTrigPrimFunctionalAlgo.h.

Referenced by init(), run(), and run_part1_EE().

Definition at line 132 of file EcalTrigPrimFunctionalAlgo.h.

Referenced by init(), and run_part2().

Definition at line 131 of file EcalTrigPrimFunctionalAlgo.h.

Referenced by init(), and run_part2().