CMS 3D CMS Logo

Public Member Functions | Protected Member Functions

DCCEETCCBlock Class Reference

#include <DCCEETCCBlock.h>

Inheritance diagram for DCCEETCCBlock:
DCCTCCBlock DCCDataBlockPrototype

List of all members.

Public Member Functions

void addTriggerPrimitivesToCollection ()
 DCCEETCCBlock (DCCDataUnpacker *u, EcalElectronicsMapper *m, DCCEventBlock *e, bool unpacking)
unsigned int getLength ()
void updateCollectors ()

Protected Member Functions

bool checkTccIdAndNumbTTs ()

Detailed Description

Definition at line 32 of file DCCEETCCBlock.h.


Constructor & Destructor Documentation

DCCEETCCBlock::DCCEETCCBlock ( DCCDataUnpacker u,
EcalElectronicsMapper m,
DCCEventBlock e,
bool  unpacking 
)

Class constructor

Definition at line 7 of file DCCEETCCBlock.cc.

References DCCDataBlockPrototype::blockLength_.

                                                                                                             : 
DCCTCCBlock(u,m,e,unpack)
{
   blockLength_ = 0;
  
}

Member Function Documentation

void DCCEETCCBlock::addTriggerPrimitivesToCollection ( ) [virtual]

Reimplemented from DCCTCCBlock.

Definition at line 19 of file DCCEETCCBlock.cc.

References DCCEventBlock::bx(), DCCDataBlockPrototype::data_, dcc_FOV_0, dcc_FOV_1, dcc_FOV_2, DCCDataBlockPrototype::event_, DCCEventBlock::fov(), EcalElectronicsMapper::getActiveDCC(), EcalElectronicsMapper::getPSInputDigiPointer(), EcalElectronicsMapper::getTPPointer(), i, EcalElectronicsMapper::isTCCExternal(), DCCEventBlock::l1A(), DCCDataBlockPrototype::mapper_, DCCTCCBlock::nTTs_, NUMB_PSEUDOSTRIPS, NUMB_TTS_TPG1, NUMB_TTS_TPG2, NUMB_TTS_TPG2_DUPL, evf::evtn::offset(), DCCTCCBlock::pPS_, DCCTCCBlock::ps_, DCCTCCBlock::pTP_, EcalTriggerPrimitiveDigi::setSample(), EcalPseudoStripInputDigi::setSampleValue(), DCCDataUnpacker::silentMode_, DCCTCCBlock::tccId_, and groupFilesInBlocks::tt.

                                                    {
  
  //point to trigger data
  data_++;

  bool processTPG2(true) ;
  unsigned int psInputCounter(0);
  
  uint16_t * tccP_= reinterpret_cast< uint16_t * >(data_);
  
  
  int dccFOV =  event_->fov();
  if (! (dccFOV==dcc_FOV_0 || dccFOV==dcc_FOV_1 || dccFOV==dcc_FOV_2) ){
    if( ! DCCDataUnpacker::silentMode_ ){
      edm::LogWarning("IncorrectEvent") 
        <<"\n FOV value in data is: " << dccFOV <<
        "At event: "  <<event_->l1A()<<" with bx "<<event_->bx()<<" in fed <<"<<mapper_->getActiveDCC()
        <<"\n TCC id "<<tccId_<<" FOV "<< dccFOV << " which is not a foreseen value. Setting it to: " << dcc_FOV_2;
    }
    dccFOV=dcc_FOV_2;
  }
  
  
  // MC raw data based on CMS NOTE 2005/021 
  // (and raw data when FOV was unassigned, earlier than mid 2008)   
    if (dccFOV == dcc_FOV_0)
      {

        // Unpack TPG1 pseudostrip input block
        if(ps_){ 
          for(unsigned int i = 1; i<= NUMB_PSEUDOSTRIPS; i++, tccP_++, psInputCounter++){
            pPS_= mapper_->getPSInputDigiPointer(tccId_,psInputCounter);
            if(!pPS_) continue;
            pPS_->setSampleValue(0, *tccP_ );
            (*pss_)->push_back(*pPS_);
          }
        }
  
        // Unpack TPG1 trigger primitive block
        // loop over tp_counter=i and navigate forward in raw (tccP_)
        for(unsigned int i = 1; i<= NUMB_TTS_TPG1; i++, tccP_++){//16
          
          if( i<= nTTs_){
            pTP_ = mapper_->getTPPointer(tccId_,i);  // pointer to tp digi container
            if(pTP_) pTP_->setSample(0, *tccP_ );    // fill it
          }else {
            processTPG2 = false;
            break;
          }
          // adding trigger primitive digi to the collection
          (*tps_)->push_back(*pTP_);
        }
        
        
        if(processTPG2){
          
          // Unpack TPG2 pseudostrip input block
          if(ps_){ 
            for(unsigned int i = 1; i<= NUMB_PSEUDOSTRIPS; i++, tccP_++, psInputCounter++){
              if (i<=NUMB_TTS_TPG2_DUPL) continue;
              //fill pseudostrip container
              pPS_= mapper_->getPSInputDigiPointer(tccId_,psInputCounter);
              if(!pPS_) continue;
              pPS_->setSampleValue(0, *tccP_ );
              (*pss_)->push_back(*pPS_);
            }
          }
          
          
          // Unpack TPG2 trigger primitive block
          for(unsigned int i = 1; i<= NUMB_TTS_TPG2; i++, tccP_++){//12
            unsigned int tt = i+NUMB_TTS_TPG1;
            
            if( tt <= nTTs_){
              pTP_ = mapper_->getTPPointer(tccId_,tt);
              if(pTP_) pTP_->setSample(0, *tccP_ ); 
            }
            else break;
            // adding trigger primitive digi to the collection
            (*tps_)->push_back(*pTP_);
          }
          
        }// end if(processTPG2)
        
      }// end FOV==0
    
      // real data since ever FOV was initialized; only 2 used >= June 09  
    else if (dccFOV == dcc_FOV_1  || dccFOV == dcc_FOV_2) 
      {
        
        // Unpack TPG1 pseudostrip input block
        if(ps_){ 
          for(unsigned int i = 1; i<= NUMB_PSEUDOSTRIPS; i++, tccP_++, psInputCounter++){
            pPS_= mapper_->getPSInputDigiPointer(tccId_,psInputCounter);
            if(!pPS_) continue;
            pPS_->setSampleValue(0, *tccP_ );
            (*pss_)->push_back(*pPS_);
          }
        }
        
        int offset(0);
        // Unpack TPG1 trigger primitive block
        // loop over tp_counter=i and navigate forward in raw (tccP_)
        for(unsigned int i = 1; i<= NUMB_TTS_TPG1; i++, tccP_++){//16
          
          if( i<= nTTs_){
            if(mapper_->isTCCExternal(tccId_)){
              if(i>8 && i<=16 ) continue;   // skip blank tp's [9,16]
              if(i>8  )         offset=8;   // 
              if(i>24 )         continue;   // skip blank tp's [25, 28]
            }
            
            pTP_ = mapper_->getTPPointer(tccId_,i-offset);  // pointer to tp digi container
            if(pTP_) pTP_->setSample(0, *tccP_ );    // fill it
            
          }else {
            processTPG2 = false;
            break;
          }
          // adding trigger primitive digi to the collection
          (*tps_)->push_back(*pTP_);
        }
        
        if(processTPG2){
          
          // Unpack TPG2 pseudostrip input block
          if(ps_){ 
            for(unsigned int i = 1; i<= NUMB_PSEUDOSTRIPS; i++, tccP_++, psInputCounter++){
              if (i<=NUMB_TTS_TPG2_DUPL) continue;
              //fill pseudostrip container
              pPS_= mapper_->getPSInputDigiPointer(tccId_,psInputCounter);
              if(!pPS_) continue;
              pPS_->setSampleValue(0, *tccP_ );
              (*pss_)->push_back(*pPS_);
            }
          }
          
          
          // Unpack TPG2 trigger primitive block
          for(unsigned int i = 1; i<= NUMB_TTS_TPG2; i++, tccP_++){//12
            unsigned int tt = i+NUMB_TTS_TPG1;
            
            if( i<= nTTs_){
              if(mapper_->isTCCExternal(tccId_)){
                if(tt>8 && tt<=16 ) continue;   // skip blank tp's [9,16]
                if(tt>8  )          offset=8;    // 
                if(tt>24 )          continue;    // skip blank tp's [25, 28]
              }
              
              pTP_ = mapper_->getTPPointer(tccId_,tt-offset);
              if(pTP_) pTP_->setSample(0, *tccP_ ); 
            }
            else break;
            // adding trigger primitive digi to the collection
            (*tps_)->push_back(*pTP_);
          }
        }// end if(processTPG2)
      }// end FOV==1 or 2
}
bool DCCEETCCBlock::checkTccIdAndNumbTTs ( ) [protected, virtual]

Reimplemented from DCCTCCBlock.

Definition at line 182 of file DCCEETCCBlock.cc.

References DCCEventBlock::bx(), DCCDataBlockPrototype::event_, EcalElectronicsMapper::getActiveDCC(), EcalElectronicsMapper::getActiveSM(), EcalElectronicsMapper::getTccs(), DCCEventBlock::l1A(), m, DCCDataBlockPrototype::mapper_, DCCTCCBlock::nTTs_, DCCDataUnpacker::silentMode_, and DCCTCCBlock::tccId_.

                                        {
  
        
  bool tccFound(false);
  bool errorOnNumbOfTTs(false);
  const int  activeDCC =  mapper_->getActiveSM();
  std::vector<unsigned int> * m = mapper_->getTccs(activeDCC);
  std::vector<unsigned int>::iterator it;
  for(it= m->begin();it!=m->end();it++){
    if((*it) == tccId_){
      tccFound=true;
     
          /*
            expNumbTTs_= 28; //separate from inner and outer tcc 
            For inner TCCs you expect 28 TTs (4 in phi, 7 in eta).
            For outer TCCs you expect 16 TTs (4 in phi, 4 in eta).
            to implement : map tccid-> number of tts

            Pascal P.: For outer board, only 16 TPs are meaningful but 28 are sent.
            - [1,8] are meaningful 
            - [9,16] are empty ie should be skipped by unpacker 
            - [17, 24] are meaningful 
            - [25, 28] are empty ie should be skipped by unpacker 
          */

          if( nTTs_ != 28 && nTTs_ !=16 ){
            if( ! DCCDataUnpacker::silentMode_ ){
          edm::LogWarning("IncorrectBlock") 
            <<"Error on event "<<event_->l1A()<<" with bx "<<event_->bx()<<" in fed <<"<<mapper_->getActiveDCC()
           <<"\n TCC id "<<tccId_<<" has "<<nTTs_<<" Trigger Towers (only 28 or 16 are the expected values in EE)"
           <<"\n => Skipping to next fed block...";
          errorOnNumbOfTTs = true; 
          //todo : add to error collection   
            }
          }
    }
  }
        
  if(!tccFound){

    if( ! DCCDataUnpacker::silentMode_ ){
      edm::LogWarning("IncorrectBlock") 
        <<"Error on event "<<event_->l1A()<<" with bx "<<event_->bx()<<" in fed <<"<<mapper_->getActiveDCC()
        <<"\n TCC id "<<tccId_<<" is not valid for this dcc "
        <<"\n => Skipping to next fed block...";
       //todo : add to error collection   
     }
  }
  

 return (tccFound || errorOnNumbOfTTs);

}
unsigned int DCCEETCCBlock::getLength ( ) [virtual]

Reimplemented from DCCDataBlockPrototype.

Definition at line 237 of file DCCEETCCBlock.cc.

References B_MASK, DCCDataBlockPrototype::data_, NUMB_PSEUDOSTRIPS, NUMB_TTS_TPG1, NUMB_TTS_TPG2, DCCTCCBlock::ps_, TCC_PS_B, and groupFilesInBlocks::temp.

                                     {

  uint64_t * temp = data_;
  temp++;

  ps_       = ( *temp>>TCC_PS_B ) & B_MASK;   
   
  unsigned int numbTps = (NUMB_TTS_TPG1 + NUMB_TTS_TPG2);
  if(ps_){ numbTps += 2*NUMB_PSEUDOSTRIPS;}
  
  unsigned int length = numbTps/4 + 2; //header and trailer
  if(numbTps%4) length++ ;
  
  
  return length;

}
void DCCEETCCBlock::updateCollectors ( ) [virtual]