CMS 3D CMS Logo

Public Member Functions | Private Member Functions | Private Attributes

DTBtiCard Class Reference

#include <DTBtiCard.h>

Inheritance diagram for DTBtiCard:
DTCache< T, Coll > DTGeomSupplier

List of all members.

Public Member Functions

std::vector< DTBtiChip * > btiList (int)
 Returns the active BTI list in a given superlayer.
void clearCache ()
 Clear all BTI stuff (map & cache)
DTConfigBticonfig_bti (DTBtiId &btiid) const
 Return bti chip configuration.
bool debug () const
 Return TU debug flag.
 DTBtiCard (DTTrigGeom *)
 Constructor.
DTBtiChipgetBTI (int sl, int n) const
 Returns the required BTI. Return 0 if it doesn't exist.
DTBtiChipgetBTI (const DTBtiId &btiid) const
 Returns the required BTI. Return 0 if it doesn't exist.
LocalVector localDirection (const DTTrigData *) const
 NEWGEO Local direction in chamber of a trigger-data object.
LocalPoint localPosition (const DTTrigData *) const
 NEWGEO Local position in chamber of a trigger-data object.
virtual void reconstruct (const DTDigiCollection dtDigis)
void setConfig (const DTConfigManager *conf)
 Set configuration.
DTBtiTrigstoreTrigger (DTBtiTrigData)
bool useAcceptParamFlag ()
 Return acceptance flag.
 ~DTBtiCard ()
 Destructor.

Private Member Functions

DTBtiChipactiveGetBTI (int sl, int n)
 Returns the required DTBtiChip. Create it if it doesn't exist.
DTBtiChipactiveGetBTI (const DTBtiId &btiid)
 Returns the required DTBtiChip. Create it if it doesn't exist.
void loadBTI (const DTDigiCollection dtDigis)
 store digi's in DTBtiChip's
void localClear ()
 clear the BTI maps
void runBTI ()
 run DTBtiChip algorithm

Private Attributes

BTIContainer _btimap [3]
ConfBtiMap _conf_bti_map
bool _debug
std::vector< DTDigi * > _digis
bool _flag_acc
DTConfigPedestals_pedestals

Detailed Description

Contains active DTBtiChips

Date:
2010/11/11 16:26:54
Revision:
1.12
Author:
C. Grandi, S. Vanini

Modifications: V/05 S.Vanini : modified to run with new geometry III/07 : SV configuration with DTConfigManager

Definition at line 61 of file DTBtiCard.h.


Constructor & Destructor Documentation

DTBtiCard::DTBtiCard ( DTTrigGeom geom)

Constructor.

Definition at line 62 of file DTBtiCard.cc.

                                     : 
  DTGeomSupplier(geom) {

        //_configBti = new DTConfigBti(bti_pset);
        //_configBti->print();

        //DTChamberId sid = ChamberId();
        //_conf_bti_map = conf_manager->getDTConfigBtiMap(sid); 
        //_debug = conf_manager->getDTTPGDebug();

        //_finedelay   = conf_manager->getDTConfigTrigUnit(sid)->MCSetupTime();
        //_MCdelay     = conf_manager->getDTConfigTrigUnit(sid)->MCDigiOffset();

        
        
}
DTBtiCard::~DTBtiCard ( )

Destructor.

Definition at line 83 of file DTBtiCard.cc.

References localClear().

                     {

  localClear();
  //delete _conf_Bti;
  
}

Member Function Documentation

DTBtiChip * DTBtiCard::activeGetBTI ( int  sl,
int  n 
) [private]

Returns the required DTBtiChip. Create it if it doesn't exist.

Definition at line 406 of file DTBtiCard.cc.

References _btimap, config_bti(), gather_cfg::cout, DTConfigBti::debug(), debug(), DTCache< T, Coll >::end(), DTGeomSupplier::geom(), n, DTTrigGeom::nCell(), evf::utils::sid, and DTTrigGeom::statId().

Referenced by activeGetBTI(), loadBTI(), and storeTrigger().

                                    {

  DTBtiChip* bti=0;
  //check if BTi is out of range before all
  if( n<1 || n>geom()->nCell(sl) ){
    if(debug()){
      std::cout << "DTBtiCard::activeGetBTI :";
      std::cout << " invalid bti number: " << n;
      std::cout << " not in range [1," << geom()->nCell(sl) << "]";
      std::cout << " dummy BTI returned!" << std::endl;
    }
    sl = 1;
    n = 999;
    return bti;
  }

  // get configuration for this chip Identifier
  DTChamberId sid = geom()->statId();
  DTBtiId _id = DTBtiId(sid, sl, n); 

  //debug this chip
  int _debug_bti = config_bti(_id)->debug();

  if(_debug_bti==3){
    std::cout << "DTBtiCard::activeGetBTI :";
    std::cout << " bti number: " << n << std::endl;
  }

  if( sl<1 || sl>3){
    if(_debug_bti>1){
      std::cout << "DTBtiCard::activeGetBTI :";
      std::cout << " invalid superlayer number: " << sl;
      std::cout << " dummy BTI returned!" << std::endl;
    }
    sl = 1;
    n = 999;
    return bti; 
  }

  BTI_iter pbti = _btimap[sl-1].find(n);
  if( pbti!=_btimap[sl-1].end() ) {
    bti = (*pbti).second;
  } else {
    bti = new DTBtiChip(this, geom(),sl,n, config_bti(_id));
    _btimap[sl-1][n]=bti;
  }
  return bti;
}
DTBtiChip* DTBtiCard::activeGetBTI ( const DTBtiId btiid) [inline, private]

Returns the required DTBtiChip. Create it if it doesn't exist.

Definition at line 123 of file DTBtiCard.h.

References activeGetBTI(), DTBtiId::bti(), and DTBtiId::superlayer().

                                                  {
      return activeGetBTI(btiid.superlayer(),btiid.bti());
    }
std::vector< DTBtiChip * > DTBtiCard::btiList ( int  sl)

Returns the active BTI list in a given superlayer.

Definition at line 471 of file DTBtiCard.cc.

References _btimap, DTCache< T, Coll >::begin(), gather_cfg::cout, L1TEmulatorMonitor_cff::p, and DTCache< T, Coll >::size().

                         {

  std::vector<DTBtiChip*> blist;

  if(size()<1)return blist;

  if(sl<1||sl>3){
    std::cout << "DTBtiCard::btiList :";
    std::cout << " invalid superlayer number: " << sl;
    std::cout << " empty list returned" << std::endl;
    return blist;
  }

  for(BTI_const_iter p=_btimap[sl-1].begin();p!=_btimap[sl-1].end();p++){
    blist.push_back((*p).second);
  }
  return blist;

}
void DTBtiCard::clearCache ( )

Clear all BTI stuff (map & cache)

Reimplemented from DTCache< T, Coll >.

Definition at line 95 of file DTBtiCard.cc.

References localClear().

Referenced by reconstruct(), and DTTrig::triggerReco().

DTConfigBti * DTBtiCard::config_bti ( DTBtiId btiid) const

Return bti chip configuration.

Definition at line 676 of file DTBtiCard.cc.

References _conf_bti_map, DTBtiId::bti(), gather_cfg::cout, DTBtiId::sector(), DTBtiId::station(), DTBtiId::superlayer(), and DTBtiId::wheel().

Referenced by activeGetBTI(), DTTracoCard::loadTRACO(), localDirection(), and localPosition().

{
  //loop on map to find bti
  ConfBtiMap::const_iterator biter = _conf_bti_map.find(btiid);
  if (biter == _conf_bti_map.end()){
    std::cout << "DTBtiCard::config_bti : BTI (" << btiid.wheel()
              << "," << btiid.sector()
              << "," << btiid.station()
              << "," << btiid.superlayer()
              << "," << btiid.bti()
              << ") not found, return 0" << std::endl;
    return 0;
  }

  return const_cast<DTConfigBti*>(&(*biter).second);

}
bool DTBtiCard::debug ( ) const [inline]

Return TU debug flag.

Definition at line 78 of file DTBtiCard.h.

References _debug.

Referenced by activeGetBTI(), loadBTI(), localDirection(), localPosition(), and runBTI().

{return _debug;}
DTBtiChip * DTBtiCard::getBTI ( int  sl,
int  n 
) const

Returns the required BTI. Return 0 if it doesn't exist.

Definition at line 456 of file DTBtiCard.cc.

References _btimap, gather_cfg::cout, and DTCache< T, Coll >::end().

Referenced by getBTI().

                                     {
  if(sl<1||sl>3||n==999){
    std::cout << "DTBtiCard::getBTI :";
    std::cout << " invalid superlayer number: " << sl;
    std::cout << " 0 returned!" << std::endl;
    return 0;
  }
  BTI_const_iter pbti = _btimap[sl-1].find(n);
  if( pbti==_btimap[sl-1].end() ){ 
    return 0;
  }
  return (*pbti).second;
}
DTBtiChip* DTBtiCard::getBTI ( const DTBtiId btiid) const [inline]

Returns the required BTI. Return 0 if it doesn't exist.

Definition at line 84 of file DTBtiCard.h.

References DTBtiId::bti(), getBTI(), and DTBtiId::superlayer().

                                                  {
      return getBTI(btiid.superlayer(),btiid.bti());
    }
void DTBtiCard::loadBTI ( const DTDigiCollection  dtDigis) [private]

store digi's in DTBtiChip's

Definition at line 258 of file DTBtiCard.cc.

References _digis, _pedestals, activeGetBTI(), DTBtiChip::add_digi(), gather_cfg::cout, debug(), DTGeomSupplier::geom(), DTConfigPedestals::getOffset(), localClear(), DTTrigGeom::mapTubeInFEch(), redigi_cff::pdigi, DTGeomSupplier::sector(), DTGeomSupplier::station(), DTSuperLayerId::superlayer(), and DTGeomSupplier::wheel().

Referenced by reconstruct().

                                                 {
  
  localClear();

  if(debug()){
    std::cout << "DTBtiCard::loadBTI called for wheel=" << wheel() ;
    std::cout << ", station=" << station();
    std::cout << ", sector="  << sector() << std::endl;
  }
  
  DTDigiCollection::DigiRangeIterator detUnitIt;
  for (detUnitIt=dtDigis.begin();
       detUnitIt!=dtDigis.end();
       ++detUnitIt){
    
    const DTLayerId& id = (*detUnitIt).first;
    const DTDigiCollection::Range& range = (*detUnitIt).second;
    
    // DTLayerId print-out
    if(debug()){
      std::cout<<"--------------"<<std::endl;
      std::cout<<"id: "<<id;
    }
    
    // Loop over the digis of this DetUnit
    for (DTDigiCollection::const_iterator digiIt = range.first;
         digiIt!=range.second;
         ++digiIt){

      int tube = (*digiIt).wire();
      const DTWireId tubeid(id,tube);
      float tdrift = (*digiIt).time() - _pedestals->getOffset(tubeid);

      if ( debug() ){  
        std::cout << " digi time : " << (*digiIt).time();
        std::cout << " pedestal offset : " << _pedestals->getOffset(tubeid) << std::endl;
        std::cout << " drift time after subtraction : " << tdrift << std::endl;
      }
        

      if(tdrift<500 && tdrift>-500){
        if(debug()) 
                (*digiIt).print();

        // get bti number for access to the configuration for this bti chip : SV
        // FIX: for the moment take first bti configuration!!!!! ok fixed
        DTSuperLayerId slnum = id.superlayerId();
        //DTChamberId dtcham =id.chamberId();
        int sln = slnum.superlayer();
        int layn = id.layer();
        //int tube = (*digiIt).wire();

        // map in FE channel number: SL theta tubes are numbered inversely w.r.t. hardware setup in new geometry 19/06/06
        // assign ch numbers to btis: in new geometry does not depend on layer staggering anymore! Same staggering anywhere.
        //int nch = geom()->mapTubeInFEch(sln,layn,tube);
        //      int nbti = nch + geom()->layerFEStaggering(sln,layn);
        
        int nch = geom()->mapTubeInFEch(sln,layn,tube);
        int nbti = nch ; 

        if(debug()){
          std::cout << "FE ch " << nch;
          std::cout << " of bti " << nbti;
//        std::cout << " staggering " <<  geom()->layerFEStaggering(sln,layn);
          std::cout << " now nbti is " << nch <<  std::endl;
//        std::cout << " SL phi offset " << geom()->phiSLOffset() << std::endl; 
        }
        
        // FIXED get configuration for the nbti chip Identifier, and from it MCdelay + finedelay
        //DTChamberId sid = geom()->statId();
        //DTBtiId _id = DTBtiId(sid, sln, nbti); 

        DTDigi* pdigi = new DTDigi((*digiIt).wire(),tdrift);
        _digis.push_back(const_cast<DTDigi*>(pdigi) );
        
        
        switch(layn) {
        case 1:
          if(activeGetBTI(sln, nbti  )) activeGetBTI(sln, nbti  )->add_digi(4, pdigi);
          if(activeGetBTI(sln, nbti-1)) activeGetBTI(sln, nbti-1)->add_digi(8, pdigi);
          break;
        case 2:
          if(activeGetBTI(sln, nbti  )) activeGetBTI(sln, nbti  )->add_digi(2, pdigi);
          if(activeGetBTI(sln, nbti-1)) activeGetBTI(sln, nbti-1)->add_digi(6, pdigi);
          break;
        case 3:
          if(activeGetBTI(sln, nbti  )) activeGetBTI(sln, nbti  )->add_digi(3, pdigi);
          if(activeGetBTI(sln, nbti-1)) activeGetBTI(sln, nbti-1)->add_digi(7, pdigi);
          break;
        case 4:
          if(activeGetBTI(sln, nbti  )) activeGetBTI(sln, nbti  )->add_digi(1, pdigi);
          if(activeGetBTI(sln, nbti-1)) activeGetBTI(sln, nbti-1)->add_digi(5, pdigi);
          if(activeGetBTI(sln, nbti-2)) activeGetBTI(sln, nbti-2)->add_digi(9, pdigi);
          break;
        }
      }//end loop on digi
      //    }//end loop on lay
      //  }//end loop on sl
    }
  }
}
void DTBtiCard::localClear ( ) [private]

clear the BTI maps

Definition at line 117 of file DTBtiCard.cc.

References _btimap, _digis, DTCache< T, Coll >::begin(), i, and L1TEmulatorMonitor_cff::p.

Referenced by clearCache(), loadBTI(), and ~DTBtiCard().

                     {
// Clear the maps
  for(int i=0; i<3; i++){
    for(BTI_iter p=_btimap[i].begin();p!=_btimap[i].end();p++){
      delete (*p).second;
    }
    _btimap[i].clear();
  }

  //clear digis
  std::vector<DTDigi*>::const_iterator p;
  for(p=_digis.begin();p<_digis.end();p++)
    delete (*p);
  _digis.clear();
}
LocalVector DTBtiCard::localDirection ( const DTTrigData tr) const [virtual]

NEWGEO Local direction in chamber of a trigger-data object.

Implements DTGeomSupplier.

Definition at line 600 of file DTBtiCard.cc.

References DTBtiTrigData::btiSL(), DTTrigGeom::cellH(), DTTrigGeom::cellPitch(), config_bti(), funct::cos(), gather_cfg::cout, debug(), DTGeomSupplier::geom(), DTBtiTrigData::K(), DTTrigGeom::localPosition(), DTBtiTrigData::parentId(), DTBtiTrigData::print(), funct::sin(), DTConfigBti::ST(), x, detailsBasic3DVector::y, and z.

                                                    {
//NEWGEO
 DTBtiTrigData* trig = dynamic_cast<DTBtiTrigData*>(const_cast<DTTrigData*>(tr));
 //this method is only for check purpose
  if(!trig) {
    std::cout << "DTBtiCard::localDirection called with wrong argument!" << std::endl;
    return LocalVector(0,0,0);
  }

  //FE position
  //int FE = geom()->posFE(trig->parentId().superlayer());

  // psi in BTI frame
  DTBtiId _btiid = trig->parentId();
  float psi = atan((float)(trig->K() - config_bti(_btiid)->ST())*geom()->cellPitch()
                   /(2*geom()->cellH() * config_bti(_btiid)->ST()));
  // (xd,yd,zd) in chamber frame
  float xd=0;
  float yd=0;
  float zd=-cos(psi);
  if(trig->btiSL()==2) 
    yd = sin(psi);
  else
    xd = -sin(psi);

// 17/07/06 Ths should be obsolete in CMSSW
//   if(FE==1){//FE in negative y
//       xd = - xd;
//       yd = - yd;
//  }

  if(debug()){
    //BTI position in chamber frame
    float xb = geom()->localPosition(trig->parentId()).x();
    float yb = geom()->localPosition(trig->parentId()).y();
    float zb = geom()->localPosition(trig->parentId()).z();
  
    std::cout << "DTBtiCard::localDirection of BTI in ("<<xb<<","<<yb<<","<<zb<<")"<<std::endl;
    std::cout << " called for trig "; 
    trig->print(); 
    std::cout << "in Local Direction ("<<xd<<","<<yd<<","<<zd<<")"<<std::endl;
  }

  return LocalVector(xd,yd,zd);
}
LocalPoint DTBtiCard::localPosition ( const DTTrigData tr) const [virtual]

NEWGEO Local position in chamber of a trigger-data object.

Implements DTGeomSupplier.

Definition at line 553 of file DTBtiCard.cc.

References DTBtiTrigData::btiSL(), DTTrigGeom::cellPitch(), config_bti(), gather_cfg::cout, debug(), DTGeomSupplier::geom(), DTTrigGeom::localPosition(), DTBtiTrigData::parentId(), DTBtiTrigData::print(), DTConfigBti::ST(), DTBtiTrigData::X(), x, detailsBasic3DVector::y, and z.

                                                   {
//NEWGEO!!!
 DTBtiTrigData* trig = dynamic_cast<DTBtiTrigData*>(const_cast<DTTrigData*>(tr));
 if(!trig) {
    std::cout << "DTBtiCard::localPosition called with wrong argument!" << std::endl;
    return LocalPoint(0,0,0);
  }

  //BTI position in chamber frame
  float x = geom()->localPosition(trig->parentId()).x();
  float y = geom()->localPosition(trig->parentId()).y();
  float z = geom()->localPosition(trig->parentId()).z();
  
  //FE position
  //int FE = geom()->posFE(trig->parentId().superlayer());

  //trigger position in the BTI frame
  float xt = 0;
  float yt = 0;

  DTBtiId _btiid = trig->parentId();
  float xtrig = (float)trig->X() * geom()->cellPitch() / (config_bti(_btiid)->ST());
  if(trig->btiSL()==2) 
    yt = - xtrig;
  else
    xt = + xtrig;

//   17/07/06 Should be obsolete in CMSSW
//   if(FE==1){//FE in negative y
//       xt = - xt;
//       yt = - yt;
//   }



  if(debug()){
    std::cout << "DTBtiCard::localPosition of BTI in ("<<x<<","<<y<<","<<z<<")"<<std::endl;
    std::cout << " called for trig "; 
    trig->print(); 
    std::cout << "in Local Point ("<<x+xt<<","<<y+yt<<","<<z<<")"<<std::endl;
  }

  return LocalPoint(x+xt,y+yt,z);
}
virtual void DTBtiCard::reconstruct ( const DTDigiCollection  dtDigis) [inline, virtual]

Definition at line 103 of file DTBtiCard.h.

References clearCache(), loadBTI(), and runBTI().

Referenced by DTTrig::triggerReco().

{ clearCache();loadBTI(dtDigis); runBTI(); }
void DTBtiCard::runBTI ( ) [private]

run DTBtiChip algorithm

Definition at line 361 of file DTBtiCard.cc.

References _btimap, DTCache< T, Coll >::_cache, DTCache< T, Coll >::begin(), gather_cfg::cout, debug(), DTConfig::NSTEPF, DTConfig::NSTEPL, DTBtiChip::nTrig(), DTBtiChip::number(), DTBtiChip::run(), DTGeomSupplier::sector(), DTCache< T, Coll >::size(), DTGeomSupplier::station(), launcher::step, DTBtiChip::triggerData(), and DTGeomSupplier::wheel().

Referenced by reconstruct().

                  {

  int nbtisig = _btimap[0].size()+_btimap[1].size()+_btimap[2].size();

  if(debug()){
    std::cout << "DTBtiCard::runBTI called for wheel=" << wheel() ;
    std::cout <<                               ", station=" << station();
    std::cout <<                               ", sector="  << sector();
    std::cout << ", " << nbtisig
         << " BTIs with signal" << std::endl;
  }

  if( nbtisig){

    if(debug()){
      std::cout << "====================================================" << std::endl;
      std::cout << "              BTI triggers                          " << std::endl; 
    }


    // run DTBtiChip algorithm on all non-empty BTI
    for(int sl=1;sl<=3;sl++){
      if(_btimap[sl-1].size()>0){
        BTI_iter pbti;
        for(pbti=_btimap[sl-1].begin(); pbti!=_btimap[sl-1].end(); pbti++) {
            DTBtiChip* bti = (*pbti).second; 
          if(bti->number()<200)
            bti->run();
          for(int step=DTConfig::NSTEPF; step<=DTConfig::NSTEPL; step++){
            if(bti->nTrig(step)>0) {
              _cache.push_back( bti->triggerData(step,1) );
              //localPosition(&(bti->triggerData(step,1))); 
              //localDirection(&(bti->triggerData(step,1))); 
             }
            }
        }
      }
    }

    if(debug())
      std::cout << "====================================================" << std::endl;
  }//end if(nbtisig)
}
void DTBtiCard::setConfig ( const DTConfigManager conf)
DTBtiTrig * DTBtiCard::storeTrigger ( DTBtiTrigData  td)

Returns a DTBtiTrig corresponding to a DTBtiTrigData. Creates the corresponding BTI chip if needed and stores the trigger

Definition at line 492 of file DTBtiCard.cc.

References activeGetBTI(), DTBtiChip::addTrig(), DTBtiId::bti(), gather_cfg::cout, DTBtiTrigData::parentId(), DTGeomSupplier::sector(), DTBtiId::sector(), DTGeomSupplier::station(), DTBtiId::station(), DTBtiTrigData::step(), DTBtiId::superlayer(), DTBtiId::wheel(), and DTGeomSupplier::wheel().

                                        {
  DTBtiId btiid = td.parentId();
  if(!(btiid.wheel()==wheel() &&
       btiid.sector()==sector() &&
       btiid.station()==station()) ) return 0;
  std::cout << "DTBtiCard::trigger: trigger not belonging to this card! ";
  std::cout << "card=(" << wheel() << "," << station() << "," << sector() << ") ";
  std::cout << "trig=(" << btiid.wheel() << "," << btiid.station() << "," 
       << btiid.sector() << ")";
  // get the appropriate BTI
  DTBtiChip* bti = activeGetBTI(btiid.superlayer(), btiid.bti());
  // create a new trigger in the BTI
  DTBtiTrig* trig = new DTBtiTrig(bti,td);
  // add the trigger to the BTI
  bti->addTrig(td.step(),trig);
  // return the trigger
  return trig;
}
bool DTBtiCard::useAcceptParamFlag ( ) [inline]

Return acceptance flag.

Definition at line 109 of file DTBtiCard.h.

References _flag_acc.

Referenced by DTBtiChip::DTBtiChip().

{ return _flag_acc; } 

Member Data Documentation

Definition at line 132 of file DTBtiCard.h.

Referenced by activeGetBTI(), btiList(), getBTI(), localClear(), and runBTI().

Definition at line 133 of file DTBtiCard.h.

Referenced by config_bti(), and setConfig().

bool DTBtiCard::_debug [private]

Definition at line 137 of file DTBtiCard.h.

Referenced by debug(), and setConfig().

std::vector<DTDigi*> DTBtiCard::_digis [private]

Definition at line 135 of file DTBtiCard.h.

Referenced by loadBTI(), and localClear().

bool DTBtiCard::_flag_acc [private]

Definition at line 140 of file DTBtiCard.h.

Referenced by setConfig(), and useAcceptParamFlag().

Definition at line 138 of file DTBtiCard.h.

Referenced by loadBTI(), and setConfig().