//=============================================================================
// Initialization
//=============================================================================
StatusCode PatPixelHitManager::initialize() {
	m_event_number = 0;
	m_max_hits = 0;
  StatusCode sc = GaudiTool::initialize(); // must be executed first
  if ( sc.isFailure() ) return sc;  // error printed already by GaudiAlgorithm

  if ( msgLevel(MSG::DEBUG) ) debug() << "==> Initialize" << endmsg;

  m_veloPix      = getDet<DeVeloPix>( DeVeloPixLocation::Default );

  // make sure we are up-to-date on populated VELO stations
  registerCondition( (*(m_veloPix->leftSensorsBegin()))->geometry(), &PatPixelHitManager::rebuildGeometry );
  registerCondition( (*(m_veloPix->rightSensorsBegin()))->geometry(), &PatPixelHitManager::rebuildGeometry );

  // first update
  sc = updMgrSvc()->update(this);
  if(!sc.isSuccess()) {
    return Error( "Failed to update station structure." );
  }

  // invalidate measurements at the beginning of each event
  incSvc()->addListener(this, IncidentType::BeginEvent);

  m_pool.resize( 10000 );
  m_nextInPool = m_pool.begin();
  m_maxSize = 0;
  m_eventReady = false;

  return StatusCode::SUCCESS;
}
Beispiel #2
0
//=============================================================================
// Initialization
//=============================================================================
StatusCode DeFTDetector::initialize(){

  StatusCode sc = DetectorElement::initialize(); // must be executed first
  if ( sc.isFailure() ) return sc;

  /// Create a MsgStream object with an add-hoc name (the second argument),
  /// instead of the ususual name(), which gives a too long string
  if ( !m_msg ) m_msg.reset( new MsgStream( msgSvc(), "DeFTDetector" ) );

  *m_msg << MSG::DEBUG << "==> Initialize DeFTDetector" << endmsg;

  //load ftversion
  m_FTversion = ( exists("FTversion") ? this->params()->param<int>("FTversion") : 0 );

  *m_msg << MSG::INFO << "Current FT geometry version =   " <<  m_FTversion<<endmsg;

  /// Fill in the vectors holding pointers to the Daugther DetElements
  // loop over stations

  const IDetectorElement::IDEContainer & detelems = childIDetectorElements();
  updMgrSvc()->registerCondition( this, geometry(), &DeFTDetector::geometryUpdate );

  if( m_FTversion >= 20 ){    //geom 20,4x,5x...
    for (auto iS = detelems.begin(); iS != detelems.end(); ++iS) {
      SmartDataPtr<DeFTStation> station(dataSvc(), (*iS)->name());
      if (station  ) {
        /// fill the vector of stations
        m_stations.push_back(station);
        // register UMS dependency
        updMgrSvc()->registerCondition( this, station->geometry(), &DeFTDetector::geometryUpdate );
        ///loop over layers and fill the vector of layers

        if( ! (station->childIDetectorElements().empty()) ){
          for (auto iL = station->childIDetectorElements().begin() ;
               iL != station->childIDetectorElements().end(); ++iL) {
           SmartDataPtr<DeFTLayer>  layer (dataSvc(),(*iL)->name());

           if ( layer ) {
            m_layers.push_back(layer);
            updMgrSvc()->registerCondition( this, layer->geometry(), &DeFTDetector::geometryUpdate );
            //*m_msg << MSG::INFO <<"registered FT  layer "<< iL - station->childIDetectorElements().begin() <<endmsg;
            ///loop over modules and fill the vector of modules
            if( !(layer ->childIDetectorElements().empty()) ){
            for (auto iM = layer->childIDetectorElements().begin(); iM != layer->childIDetectorElements().end(); ++iM) {
              SmartDataPtr<DeFTModule> module (dataSvc(),(*iM)->name());
              if ( module ) {
                m_modules.push_back(module);
                updMgrSvc()->registerCondition( this,
                                                module->geometry(), &DeFTDetector::geometryUpdate );

                if( ! (module ->childIDetectorElements().empty()) ){
                ///loop over fibremodules and fill the vector of fibremodules
                  for (auto iFM = module ->childIDetectorElements().begin();
                       iFM != module->childIDetectorElements().end() ; ++iFM) {
                    if ( std::string::npos != (*iFM)->name().find(m_FibreModuleNameSpec) ){

                      SmartDataPtr<DeFTFibreModule> fibremodule (dataSvc(),(*iFM)->name());
                      if ( fibremodule) {
                        m_fibremodules.push_back(fibremodule);
                        updMgrSvc()->registerCondition( this,
                                     fibremodule->geometry(), &DeFTDetector::geometryUpdate );
                        //*m_msg << MSG::INFO <<"registered FT fibremodule "
                        //       << iFM - module->childIDetectorElements().begin() <<endmsg;

                        if( ! (fibremodule ->childIDetectorElements().empty()) ){
                           ///loop over fibremats and fill the vector of fibremats
                           for (auto iFMat = fibremodule ->childIDetectorElements().begin() ;
                                iFMat != fibremodule ->childIDetectorElements().end() ; ++iFMat) {
                             if ( std::string::npos != (*iFMat)->name().find(m_FibreMatNameSpec) ){

                               SmartDataPtr<DeFTFibreMat> fibremat (dataSvc(),(*iFMat)->name());
                               if ( fibremat) {
                                 m_fibremats.push_back(fibremat);
                                 updMgrSvc()->registerCondition( this,
                                              fibremat->geometry(), &DeFTDetector::geometryUpdate );

                               }} // tests for  existance of fibremat

                           } // loop fibremat

                           } // test existance of children of fibre module


                      }} //tests for existance of fibre module
                }// loop fibremodules
                }//test existance of chilren of module


              }// test existanace of module
            } //loop modules
            } // test existance of children of layer

          }  //test existance of layer
          } // loop layers
        } // test of existance of children of station

      }// test existance of station
    } // loop stations

  }else if ( m_FTversion < 20 )  {
    // old version of geometry; to become obsolete
    for (auto iS = this->childBegin(); iS != this->childEnd(); ++iS) {
      DeFTStation* station = dynamic_cast<DeFTStation*>(*iS);
      if ( station ) {
        /// fill the vector of stations
        m_stations.push_back(station);
        ///loop over layers and fill the vector of bilayers
        for (auto iBL = (*iS)->childBegin(); iBL!= (*iS)->childEnd(); ++iBL) {
          DeFTBiLayer* bilayer = dynamic_cast<DeFTBiLayer*>(*iBL);
          if ( bilayer ) {
            m_bilayers.push_back(bilayer);
            ///loop over modules and fill the vector of modules
            for (auto iL = (*iBL)->childBegin(); iL!= (*iBL)->childEnd(); ++iL) {
              DeFTLayer* layer = dynamic_cast<DeFTLayer*>(*iL);
              if ( layer ) {
                m_layers.push_back(layer);
              }
            } // loop layers
          }
        }//loop bilayers
      }
    } // loop stations
  }


  ///>>> print the layer properties <<<///
  if ( m_msg->level() <= MSG::DEBUG ) {

    if( m_FTversion >= 20 ){

      ///loop over fibremats
      for (auto iFMat = fibremats().begin(); iFMat != fibremats().end(); ++iFMat) {
        DeFTFibreMat* fibremat = dynamic_cast<DeFTFibreMat*>(*iFMat);
        if ( fibremat ) {

          *m_msg << MSG::DEBUG << "Properties of FT fibreMat with ID " << fibremat->FibreMatID() << ":" << endmsg;
          *m_msg << MSG::DEBUG << "\tIn layer  " << fibremat->layer()  <<  endmsg;
          *m_msg << MSG::DEBUG << "\tIn module " << fibremat->module() <<  endmsg;
          *m_msg << MSG::DEBUG << "\tIs bottom " << fibremat->isBottom() <<  endmsg;
          *m_msg << MSG::DEBUG<< "\tGeometrical borders of fibremat: " << endmsg;
          *m_msg << MSG::DEBUG<< format("\txMin/xMax = %.1f / %.1f      yMin/yMax = %.1f / %.1f      zMin/zMax = %.1f / %.1f mm",
                                        fibremat->fibreMatMinX(), fibremat->fibreMatMaxX(),
                                        fibremat->fibreMatMinY(), fibremat->fibreMatMaxY(),
                                        fibremat->fibreMatMinZ(), fibremat->fibreMatMaxZ())<< endmsg;
          *m_msg << MSG::DEBUG<< "\tGeometrical borders of corresponding layer: " << endmsg;
          *m_msg << MSG::DEBUG<< format("\txMin/xMax = %.1f / %.1f      yMin/yMax = %.1f / %.1f      zMin/zMax = %.1f / %.1f mm",
                                        fibremat->layerMinX(), fibremat->layerMaxX(),
                                        fibremat->layerMinY(), fibremat->layerMaxY(),
                                        fibremat->layerMinZ(), fibremat->layerMaxZ())<< endmsg;
          *m_msg << MSG::DEBUG<< "\tBeam pipe radius: " << format("%7.1f mm", fibremat->layerInnerHoleRadius())<< endmsg;
          *m_msg << MSG::DEBUG<< "\tStereo angle: " << format("%.1f degrees", fibremat->angle()/Gaudi::Units::degree)<< endmsg;
          *m_msg << MSG::DEBUG<< "\tSlope dzDy: " << format("%.5f rad", fibremat->slopeDzDy())<< endmsg;
          *m_msg << MSG::DEBUG<< endmsg;

        }
      }
    }
  }

  /// sort the fibremats according to their fibreMatID
  std::sort(m_fibremats.begin(), m_fibremats.end(),
            [](const DeFTFibreMat* lhs, const DeFTFibreMat* rhs){ return lhs->FibreMatID() < rhs->FibreMatID(); });


    // trigger first UMS update
  const StatusCode update = updMgrSvc()->update(this);

  return ( sc && update) ;
}