CMS 3D CMS Logo

Public Member Functions | Private Member Functions | Private Attributes

DTTracoCard Class Reference

#include <DTTracoCard.h>

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

List of all members.

Public Member Functions

void clearCache ()
 Clear all traco stuff (cache & map)
DTConfigLUTsconfig_luts () const
 Return LUTS config for this chamber (=minicrate)
bool debug ()
 Return TU debug flag.
 DTTracoCard (DTTrigGeom *, DTBtiCard *, DTTSTheta *)
 Constructor.
DTTracoChipgetTRACO (const DTTracoId &tracoid) const
 Returns the required DTTracoChip. Return 0 if it doesn't exist.
DTTracoChipgetTRACO (int n) const
 Returns the required DTTracoChip. 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.
bool lutFromDBFlag ()
 Return lut computation option (DB/geometry)
virtual void reconstruct ()
 Load BTIs triggers and run TRACOs algorithm.
void setConfig (const DTConfigManager *conf)
 Set configuration.
DTTracoTrigstoreTrigger (DTTracoTrigData)
std::vector< DTTracoChip * > tracoList ()
 Returns the active TRACO list.
DTTSThetaTSTh () const
 Return TSTheta.
bool useAcceptParamFlag ()
 Return acceptance flag.
 ~DTTracoCard ()
 Destructor.

Private Member Functions

DTTracoChipactiveGetTRACO (int)
 Returns the required DTTracoChip. Create it if it doesn't exist.
DTTracoChipactiveGetTRACO (const DTTracoId &tracoid)
 Returns the required DTTracoChip. Create it if it doesn't exist.
DTConfigTracoconfig_traco (const DTTracoId &tracoid) const
 Return single TRACO config.
void loadTRACO ()
 store BTI triggers in TRACO's
void localClear ()
 clear the TRACO map
void runTRACO ()
 run TRACO algorithm

Private Attributes

DTBtiCard_bticard
DTConfigLUTs_conf_luts
ConfTracoMap _conf_traco_map
bool _debug
bool _flag_acc
bool _lut_from_db
TRACOContainer _tracomap
DTTSTheta_tstheta

Detailed Description

Contains active DTTracoChips

Date:
2009/11/12 14:33:22
Revision:
1.10
Author:
C. Grandi, S. Vanini

Modifications: III/07 : SV configuration with DTConfigManager

Definition at line 60 of file DTTracoCard.h.


Constructor & Destructor Documentation

DTTracoCard::DTTracoCard ( DTTrigGeom geo,
DTBtiCard bticard,
DTTSTheta tstheta 
)

Constructor.

Definition at line 49 of file DTTracoCard.cc.

                      : DTGeomSupplier(geo) , 
  _bticard(bticard), _tstheta(tstheta) { 

}
DTTracoCard::~DTTracoCard ( )

Destructor.

Definition at line 59 of file DTTracoCard.cc.

References localClear().

                         {

localClear();

}

Member Function Documentation

DTTracoChip * DTTracoCard::activeGetTRACO ( int  n) [private]

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

Definition at line 289 of file DTTracoCard.cc.

References _tracomap, config_traco(), DTGeomSupplier::geom(), n, evf::utils::sid, and DTTrigGeom::statId().

Referenced by activeGetTRACO(), loadTRACO(), and storeTrigger().

                                 {

  // the traco identifier
  DTChamberId sid = geom()->statId();
  DTTracoId _id = DTTracoId(sid,n);
 
  DTTracoChip* traco = 0;
  TRACO_iter ptraco = _tracomap.find(n);
  if( ptraco!=_tracomap.end() ) {
    traco=(*ptraco).second;
  } else {
    traco = new DTTracoChip(this,n,config_traco(_id));
    _tracomap[n]=traco;
  }
  return traco;
}
DTTracoChip* DTTracoCard::activeGetTRACO ( const DTTracoId tracoid) [inline, private]

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

Definition at line 130 of file DTTracoCard.h.

References activeGetTRACO(), and DTTracoId::traco().

                                                          {
      return activeGetTRACO(tracoid.traco());
    }
void DTTracoCard::clearCache ( )

Clear all traco stuff (cache & map)

Reimplemented from DTCache< T, Coll >.

Definition at line 70 of file DTTracoCard.cc.

References localClear().

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

DTConfigLUTs* DTTracoCard::config_luts ( ) const [inline]

Return LUTS config for this chamber (=minicrate)

Definition at line 110 of file DTTracoCard.h.

References _conf_luts.

Referenced by DTTracoChip::DTTracoChip().

{ return _conf_luts; } 
DTConfigTraco * DTTracoCard::config_traco ( const DTTracoId tracoid) const [private]

Return single TRACO config.

Definition at line 464 of file DTTracoCard.cc.

References _conf_traco_map, gather_cfg::cout, DTTracoId::sector(), DTTracoId::station(), DTTracoId::traco(), and DTTracoId::wheel().

Referenced by activeGetTRACO(), localDirection(), and localPosition().

{
  //loop on map to find traco
  ConfTracoMap::const_iterator titer = _conf_traco_map.find(tracoid);
  if (titer == _conf_traco_map.end()){
    std::cout << "DTTracoCard::config_traco : TRACO (" << tracoid.wheel()
              << "," << tracoid.sector()
              << "," << tracoid.station()
              << "," << tracoid.traco()
              << ") not found, return 0" << std::endl;
    return 0;
  }

  return const_cast<DTConfigTraco*>(&(*titer).second);
} 
bool DTTracoCard::debug ( ) [inline]

Return TU debug flag.

Definition at line 78 of file DTTracoCard.h.

References _debug.

Referenced by loadTRACO(), localDirection(), and runTRACO().

{return _debug;}
DTTracoChip * DTTracoCard::getTRACO ( int  n) const

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

Definition at line 307 of file DTTracoCard.cc.

References _tracomap.

Referenced by getTRACO(), and DTTracoChip::setFlag().

                                 {
  TRACO_const_iter ptraco = _tracomap.find(n);
  if( ptraco==_tracomap.end() ) return 0;
  return (*ptraco).second;
}
DTTracoChip* DTTracoCard::getTRACO ( const DTTracoId tracoid) const [inline]

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

Definition at line 87 of file DTTracoCard.h.

References getTRACO(), and DTTracoId::traco().

                                                          {
      return getTRACO(tracoid.traco());
    }
void DTTracoCard::loadTRACO ( ) [private]

store BTI triggers in TRACO's

Definition at line 107 of file DTTracoCard.cc.

References _bticard, _flag_acc, activeGetTRACO(), DTTracoChip::add_btiT(), DTCache< T, Coll >::begin(), DTConfigBti::CH(), DTConfigBti::CL(), DTBtiCard::config_bti(), gather_cfg::cout, debug(), DTCache< T, Coll >::end(), DTGeomSupplier::geom(), DTConfigBti::LH(), DTConfigBti::LL(), localClear(), DTConfig::NBTITC, AlCaHLTBitMon_ParallelJobs::p, pos, DTConfigBti::RH(), DTConfigBti::RL(), DTGeomSupplier::sector(), DTGeomSupplier::station(), relval_parameters_module::step, and DTGeomSupplier::wheel().

Referenced by reconstruct().

                       {
 
  localClear();

  if(debug()){
    std::cout << "DTTracoCard::loadTRACO called for wheel=" << wheel() ;
    std::cout <<                                ", station=" << station();
    std::cout <<                                ", sector="  << sector() << std::endl;
  }

  int maxtc = int(ceil( float(geom()->nCell(1)) / float(DTConfig::NBTITC) ));

  // loop on all BTI triggers
  std::vector<DTBtiTrigData>::const_iterator p;
  std::vector<DTBtiTrigData>::const_iterator pend=_bticard->end();
  for(p=_bticard->begin();p!=pend;p++){
    if(debug()){
      std::cout << "Found bti trigger: ";
      (*p).print();
    }

    // BTI data
    int nbti    = (*p).btiNumber();
    int nsl     = (*p).btiSL(); 
    int step    = (*p).step();
    int K       = (*p).K();
    DTBtiId id_bti = (*p).parentId();

    DTConfigBti* conf_bti = _bticard->config_bti( id_bti ); 
    int LL      = conf_bti->LL();
    int LH      = conf_bti->LH();
    int CL      = conf_bti->CL();
    int CH      = conf_bti->CH();
    int RL      = conf_bti->RL();
    int RH      = conf_bti->RH();
/*
    if(debug())
      std::cout << "Bti trigger acceptances: \n" 
                << " LL " << LL << ", LH " << LH << "\n"
                << " CL " << CL << ", CH " << CH << "\n"
                << " RL " << RL << ", RH " << RH << std::endl;
*/
    // assign BTI to TRACO (central TRACO for sl=3); ntc=1,2...maxtc
    int ntc = static_cast<int>((nbti-1)/DTConfig::NBTITC)+1;
    if( ntc<1 || ntc>maxtc ) 
      continue;
    
    if(debug())
      std::cout << "Bti trigger assigned to traco " << ntc << " (maxtc " << maxtc << ")" << std::endl;

    // TRACO information
    DTTracoId tracoid = DTTracoId(wheel(),station(),sector(),ntc);
     
    // position inside TRACO: 
    int pos = nbti-(ntc-1)*DTConfig::NBTITC;

    // store trigger in TRACO. Create TRACO if it doesn't exist
    // SV tb2003 : check if traco is connected!

    // SV 091103 : add bti trigger filtering in acceptance windows
    // if flag is useAcceptParam() = true

    // Load master TRACO plane
    if( nsl==1 ) {
      if( !_flag_acc || (K>=CL && K<=CH) )
        activeGetTRACO(ntc)->add_btiT( step, pos, &(*p) );
      else
        if(debug())
          std::cout     << "ATTENTION: in TRACO n. " << ntc 
                        << " bti pos " << pos << " trigger K= " << K 
                        << " outside acceptance " << CL << "<K<" << CH << std::endl;
    } 

    // Load slave TRACO plane
    if( nsl==3 ) {
      // 3 TRACO's
      //for(int tci=-1;tci<=1;tci++) {
      //  if( (ntc+tci)>0 && (ntc+tci)<=maxtc )
      //    activeGetTRACO(ntc+tci)->add_btiT( step, pos+8-4*tci, &(*p) );
      //  else{
      //    if(debug())
      //      std::cout << "ATTENTION: traco " << ntc+tci << " is disconnected!" << std::endl;
      //  }

      // Left Traco
      if( (ntc-1)>0 && (ntc-1)<=maxtc ) {
        if( !_flag_acc || (K>=LL && K<=LH) ) {
          activeGetTRACO(ntc-1)->add_btiT( step, pos+8-4*(-1), &(*p) );
        } else {
          if(debug()) {
            std::cout   << "ATTENTION: in TRACO n. " << ntc-1
                        << " bti pos " << pos+8-4*(-1) << " trigger K= " << K 
                        << " outside acceptance " << LL << "<K<" << LH << std::endl;
          }
        }
      }

      // Central Traco
      if( (ntc)>0 && (ntc)<=maxtc ) {
        if( !_flag_acc || (K>=CL && K<=CH) ) {
          activeGetTRACO(ntc)->add_btiT( step, pos+8-4*(0), &(*p) );
        } else {
          if(debug())
            std::cout   << "ATTENTION: in TRACO n. " << ntc 
                        << " bti pos " << pos+8-4*(0) << " trigger K= " << K 
                        << " outside acceptance " << CL << "<K<" << CH << std::endl;
        }
      }
      
      // Right Traco
      if( (ntc+1)>0 && (ntc+1)<=maxtc ) {
        if( !_flag_acc || (K>=RL && K<=RH) ) {
          activeGetTRACO(ntc+1)->add_btiT( step, pos+8-4*(+1), &(*p) );
        } else {
          if(debug())
            std::cout   << "ATTENTION: in TRACO n. " << ntc+1 
                        << " bti pos " << pos+8-4*(+1) << " trigger K= " << K 
                        << " outside acceptance " << RL << "<K<" << RH << std::endl;
        }
      }
    }

    // Filter Theta BTIs -> this is done in DTBtiChip 

  }//end loop on bti trigs
}
void DTTracoCard::localClear ( ) [private]

clear the TRACO map

Definition at line 98 of file DTTracoCard.cc.

References _tracomap, and AlCaHLTBitMon_ParallelJobs::p.

Referenced by clearCache(), loadTRACO(), and ~DTTracoCard().

                       {
  // Clear the map
  for(TRACO_iter p=_tracomap.begin();p!=_tracomap.end();p++){
    delete (*p).second;
  }
  _tracomap.clear();
}
LocalVector DTTracoCard::localDirection ( const DTTrigData tr) const [virtual]

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

Implements DTGeomSupplier.

Definition at line 429 of file DTTracoCard.cc.

References DTTrigGeom::cellPitch(), config_traco(), funct::cos(), gather_cfg::cout, debug(), DTTrigGeom::distSL(), DTGeomSupplier::geom(), DTTracoTrigData::K(), DTTracoTrigData::parentId(), and funct::sin().

Referenced by DTTracoChip::calculateAngles(), and DTTSPhi::localDirection().

                                                      {
  //NEWGEO
  DTTracoTrigData* trig = dynamic_cast<DTTracoTrigData*>(const_cast<DTTrigData*>(tr));
  if(!trig) {
    std::cout << "DTtracoCard::localDirection called with wrong argument!" << std::endl;
    return LocalVector(0,0,0);
  }

  //FE position
  //int FE = geom()->posFE(3);

  float psi = atan((float)(trig->K())*geom()->cellPitch()
                   /( geom()->distSL() * config_traco(trig->parentId())->BTIC()) );

  if(config_traco(trig->parentId())->debug()==4)
    std::cout << "K " << trig->K() << " == psi " << psi << " in FE frame " << std::endl;
    
  // (xd,yd,zd) in chamber frame
  float xd=-sin(psi);
  float yd=0;
  float zd=-cos(psi);

  // 10/07/06 Not needed anymore (chages in geometry)
  // if(FE==1){//FE in negative y
  //    xd = - xd;
  //}

 
  if(config_traco(trig->parentId())->debug()==4)
    std::cout << "Direction in chamber frame is (" << xd << "," << yd << "," << zd << ")" << std::endl;
 
  return LocalVector(xd,yd,zd);
}
LocalPoint DTTracoCard::localPosition ( const DTTrigData tr) const [virtual]

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

Implements DTGeomSupplier.

Definition at line 376 of file DTTracoCard.cc.

References DTTrigGeom::cellPitch(), config_traco(), gather_cfg::cout, DTTrigGeom::distSL(), DTGeomSupplier::geom(), DTTrigGeom::localPosition(), DTTracoTrigData::parentId(), DTTracoTrigData::posIn(), DTTracoTrigData::posOut(), DTTracoTrigData::X(), x, detailsBasic3DVector::y, and z.

Referenced by DTTSPhi::localPosition().

                                                     {
  //NEWGEO
  DTTracoTrigData* trig = dynamic_cast<DTTracoTrigData*>(const_cast<DTTrigData*>(tr));
  if(!trig) {
    std::cout << "DTTracoCard::localPosition called with wrong argument!" << std::endl;
    return LocalPoint(0,0,0);
  }
  float x = geom()->localPosition(trig->parentId()).x();
  float y = geom()->localPosition(trig->parentId()).y();
  float z = geom()->localPosition(trig->parentId()).z();

  float trig_pos = geom()->cellPitch() * ( (float)trig->X() / (float)(config_traco(trig->parentId())->BTIC()));

//  10/7/06 May be not needed anymore in new geometry 
//   if(geom()->posFE(1)==1)
//   trig_pos = -trig_pos;

  x += trig_pos;

  // If not correlated get the position of the SL instead of the chamber center
  // z axis toward vertex
  if(trig->posIn()==0 ) {
    z -= 0.5 * geom()->distSL(); // no inner ==> only outer
  } 
  else if(trig->posOut()==0) {
    z += 0.5 * geom()->distSL(); // no outer ==> only inner
  }
  return LocalPoint(x,y,z);
}
bool DTTracoCard::lutFromDBFlag ( ) [inline]

Return lut computation option (DB/geometry)

Definition at line 116 of file DTTracoCard.h.

References _lut_from_db.

Referenced by DTTracoChip::calculateAngles(), DTTracoChip::DTTracoChip(), and DTTracoChip::~DTTracoChip().

{ return _lut_from_db; }
virtual void DTTracoCard::reconstruct ( ) [inline, virtual]

Load BTIs triggers and run TRACOs algorithm.

Reimplemented from DTCache< T, Coll >.

Definition at line 107 of file DTTracoCard.h.

References clearCache(), loadTRACO(), and runTRACO().

Referenced by DTTrig::triggerReco().

void DTTracoCard::runTRACO ( ) [private]

run TRACO algorithm

Definition at line 235 of file DTTracoCard.cc.

References DTCache< T, Coll >::_cache, _tracomap, gather_cfg::cout, debug(), DTConfig::NSTEPF, DTConfig::NSTEPL, DTTracoChip::nTrig(), DTTracoChip::run(), DTGeomSupplier::sector(), DTGeomSupplier::station(), relval_parameters_module::step, DTTracoChip::triggerData(), DTTracoChip::useSecondTrack(), and DTGeomSupplier::wheel().

Referenced by reconstruct().

                      {

  if(debug()){
    std::cout << "DTTracoCard:runTRACO called for wheel=" << wheel() ;
    std::cout <<                               ", station=" << station();
    std::cout <<                               ", sector="  << sector();
    std::cout << ", " << _tracomap.size() << " TRACOs with signal" << std::endl;
  }

  // run TRACO algorithm on all non-empty TRACO
  if(_tracomap.size()>0){

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


    TRACO_iter ptraco;
    for(ptraco=_tracomap.begin(); ptraco!=_tracomap.end(); ptraco++) {
      DTTracoChip* traco = (*ptraco).second;
      traco->run();
      for(int step=DTConfig::NSTEPF; step<=DTConfig::NSTEPL; step++){
        if( traco->nTrig(step)>0 ){ 
          _cache.push_back( traco->triggerData(step,1) );
          /*
          std::cout<<"first bti sl3: "<<geom()->localPosition(DTBtiId(wheel(),station(),sector(),3,1))<<std::endl;
          std::cout<<"traco pos: " << geom()->localPosition((traco->triggerData(step,1).parentId()))<<std::endl; 
          traco->triggerData(step,1).print();
          std::cout<<"pos: " << localPosition(&(traco->triggerData(step,1))) << std::endl;
          std::cout<<"dir: " << localDirection(&(traco->triggerData(step,1))) << std::endl;
          std::cout << std::endl;
          */
        }  
        // Store second track only if no first track at previous BX
          if( traco->nTrig(step)>1 && traco->useSecondTrack(step) ){
            _cache.push_back( traco->triggerData(step,2) );
          /*
          std::cout<<"first bti sl3: "<<geom()->localPosition(DTBtiId(wheel(),station(),sector(),3,1))<<std::endl;
          std::cout<<"traco pos: " << geom()->localPosition((traco->triggerData(step,2).parentId()))<<std::endl; 
          traco->triggerData(step,2).print();
          std::cout<<"pos: " << localPosition(&(traco->triggerData(step,2))) << std::endl;
          std::cout<<"dir: " << localDirection(&(traco->triggerData(step,2))) << std::endl;
          std::cout << std::endl;
          */
        }
      }
    }
    if(debug())
      std::cout << "====================================================" << std::endl;
  }
}
void DTTracoCard::setConfig ( const DTConfigManager conf)

Set configuration.

Definition at line 78 of file DTTracoCard.cc.

References _conf_luts, _conf_traco_map, _debug, _flag_acc, _lut_from_db, DTGeomSupplier::ChamberId(), DTConfigManager::getDTConfigLUTs(), DTConfigManager::getDTConfigTracoMap(), DTConfigManager::getDTTPGDebug(), DTConfigManager::lutFromDB(), evf::utils::sid, and DTConfigManager::useAcceptParam().

Referenced by DTSCTrigUnit::setConfig().

                                                 {
  // get traco configuration map  
  DTChamberId sid = ChamberId();
  _conf_traco_map = conf->getDTConfigTracoMap(sid);     
  _debug = conf->getDTTPGDebug();

  // get bti acceptance flag
  _flag_acc = conf->useAcceptParam();

  // get lut computation flag
  _lut_from_db = conf->lutFromDB();

  // get lut configuration for this chamber
  // 100511 SV only if luts are read from OMDS
  if(_lut_from_db)
    _conf_luts = conf->getDTConfigLUTs(sid);

}
DTTracoTrig * DTTracoCard::storeTrigger ( DTTracoTrigData  td)

Returns a DTTracoTrig corresponding to a DTTracoTrigData. Creates the corresponding TRACO chip if needed and stores the trigger

Definition at line 328 of file DTTracoCard.cc.

References activeGetTRACO(), DTTracoChip::addTrig(), gather_cfg::cout, DTTracoTrigData::parentId(), DTTracoId::sector(), DTGeomSupplier::sector(), DTTracoId::station(), DTGeomSupplier::station(), DTTracoTrigData::step(), DTTracoId::traco(), DTGeomSupplier::wheel(), and DTTracoId::wheel().

                                            {
  DTTracoId tracoid = td.parentId();
  if(!(tracoid.wheel()==wheel() &&
       tracoid.sector()==sector() &&
       tracoid.station()==station()) ) return 0;
  std::cout << "DTTracoChip::trigger: trigger not belonging to this card! ";
  std::cout << "card=(" << wheel() << "," << station() << "," << sector() << ") ";
  std::cout << "trig=(" << tracoid.wheel() << "," << tracoid.station() << "," 
       << tracoid.sector() << ")";
  // get the appropriate Traco
  DTTracoChip* traco = activeGetTRACO(tracoid.traco());
  // create a new trigger in the Traco
  DTTracoTrig* trig = new DTTracoTrig(traco,td);
  // add the trigger to the Traco
  traco->addTrig(td.step(),trig);
  // return the trigger
  return trig;
}
std::vector< DTTracoChip * > DTTracoCard::tracoList ( )

Returns the active TRACO list.

Definition at line 314 of file DTTracoCard.cc.

References _tracomap, AlCaHLTBitMon_ParallelJobs::p, and DTCache< T, Coll >::size().

                       {

  std::vector<DTTracoChip*> blist;

  if(size()<1)return blist;

  for(TRACO_const_iter p=_tracomap.begin();p!=_tracomap.end();p++){
    blist.push_back((*p).second);
  }
  return blist;

}
DTTSTheta* DTTracoCard::TSTh ( ) const [inline]

Return TSTheta.

Definition at line 81 of file DTTracoCard.h.

References _tstheta.

Referenced by DTTracoChip::storeUncorr().

{ return _tstheta; }
bool DTTracoCard::useAcceptParamFlag ( ) [inline]

Return acceptance flag.

Definition at line 113 of file DTTracoCard.h.

References _flag_acc.

Referenced by DTTracoChip::add_btiT().

{ return _flag_acc; } 

Member Data Documentation

Definition at line 142 of file DTTracoCard.h.

Referenced by loadTRACO().

Definition at line 148 of file DTTracoCard.h.

Referenced by config_luts(), and setConfig().

Definition at line 146 of file DTTracoCard.h.

Referenced by config_traco(), and setConfig().

bool DTTracoCard::_debug [private]

Definition at line 150 of file DTTracoCard.h.

Referenced by debug(), and setConfig().

bool DTTracoCard::_flag_acc [private]

Definition at line 152 of file DTTracoCard.h.

Referenced by loadTRACO(), setConfig(), and useAcceptParamFlag().

bool DTTracoCard::_lut_from_db [private]

Definition at line 153 of file DTTracoCard.h.

Referenced by lutFromDBFlag(), and setConfig().

Definition at line 145 of file DTTracoCard.h.

Referenced by activeGetTRACO(), getTRACO(), localClear(), runTRACO(), and tracoList().

Definition at line 143 of file DTTracoCard.h.

Referenced by TSTh().