4 #include "kaltest/TKalDetCradle.h"
5 #include "kaltest/TVKalDetector.h"
6 #include "kaltest/THelicalTrack.h"
8 #include "DDKalTest/DDVMeasLayer.h"
9 #include "DDKalTest/DDKalDetector.h"
10 #include "DDKalTest/DDCylinderMeasLayer.h"
29 #include "streamlog/streamlog.h"
39 streamlog_out( DEBUG4 ) <<
" MarlinDDKalTest - initializing the detector ..." <<
std::endl ;
41 _det =
new TKalDetCradle ;
42 _det->SetOwner(
true ) ;
48 streamlog_out( DEBUG4 ) <<
" MarlinDDKalTest - established " <<
std::endl ;
53 #ifdef MARLINTRK_DIAGNOSTICS_ON
56 for(
auto* ddKalDet :
_detectors ) {
delete ddKalDet; }
86 streamlog_out( DEBUG5 ) <<
" -------------------------------------------------------------------------------- " <<
std::endl ;
87 streamlog_out( DEBUG5 ) <<
" MarlinDDKalTest::init() called with the following options : " <<
std::endl ;
88 streamlog_out( DEBUG5 ) << this->
getOptions() ;
89 streamlog_out( DEBUG5 ) <<
" -------------------------------------------------------------------------------- " <<
std::endl ;
93 streamlog_out( DEBUG5 ) <<
" MarlinDDKalTest::init() - already initialized - only options are set .. " <<
std::endl ;
99 streamlog_out( DEBUG5 ) <<
" ##################### MarlinDDKalTest::init() - initializing " <<
std::endl ;
101 dd4hep::Detector& lcdd = dd4hep::Detector::getInstance();
104 DDCylinderMeasLayer* ipLayer = 0 ;
123 if( name.
find(
"ecal" ) != std::string::npos ){
133 dd4hep::DetElement
det = *it ;
135 streamlog_out( DEBUG5 ) <<
" MarlinDDKalTest::init() - creating DDKalDetector for : " << det.name() <<
std::endl ;
142 _det->Install( *kalDet ) ;
145 Int_t nLayers = kalDet->GetEntriesFast() ;
150 for(
int i=0; i < nLayers; ++i ) {
151 const TVSurface* tvs =
static_cast<const TVSurface*
>( kalDet->At( i ) );
153 double s = tvs->GetSortingPolicy() ;
154 if( s < minS && dynamic_cast< DDCylinderMeasLayer* > ( kalDet->At( i) ) ) {
156 ipLayer =
dynamic_cast< DDCylinderMeasLayer*
> ( kalDet->At( i) ) ;
160 if( streamlog_level( DEBUG5 ) ) {
165 file.
open( s.
str().c_str() , std::ofstream::out ) ;
168 for(
unsigned i=0,N=kalDet->GetEntriesFast() ; i<N ;++i){
169 DDVMeasLayer* ml =
dynamic_cast<DDVMeasLayer*
> ( kalDet->At( i ) ) ;
170 TVSurface* surf =
dynamic_cast<TVSurface*
> ( kalDet->At( i ) ) ;
171 smap[ surf->GetSortingPolicy() ] = ml ;
174 bf.setValue( itm->second->getCellIDs()[0] ) ;
175 file <<
" " <<
std::scientific <<
std::setw(10) << itm->first <<
"\t" << bf.valueString() << *itm->second->surface() <<
"\n" ;
188 streamlog_out( MESSAGE ) <<
" MarlinDDKalTest: install IP layer at radius : " << minS <<
std::endl ;
196 streamlog_out( DEBUG4 ) <<
" MarlinDDKalTest - number of layers = " <<
_det->GetEntriesFast() <<
std::endl ;
199 if( streamlog_level( DEBUG ) ) {
203 for(
unsigned i=0,N=
_det->GetEntriesFast() ; i<N ;++i){
205 DDVMeasLayer* ml =
dynamic_cast<DDVMeasLayer*
> (
_det->At( i ) ) ;
207 bf.setValue( ml->getLayerID() ) ;
209 TVSurface* s =
dynamic_cast<TVSurface*
> (
_det->At( i ) ) ;
211 streamlog_out( DEBUG ) <<
" *** meas. layer : " << bf.valueString() <<
" sorting: " << s->GetSortingPolicy() <<
std::endl ;
225 errorMsg <<
"MarlinDDKalTest::createTrack: Fitter not initialised. MarlinDDKalTest::init() must be called before MarlinDDKalTest::createTrack()" <<
std::endl ;
236 streamlog_out( DEBUG2 ) <<
" **** MarlinDDKalTest::includeMultipleScattering( " << msOn <<
" ) called " <<
std::endl ;
249 streamlog_out( DEBUG2 ) <<
" **** MarlinDDKalTest::includeEnergyLoss( " << energyLossOn <<
" ) called " <<
std::endl ;
251 if( energyLossOn ==
true ) {
252 _det->SwitchOnDEDX();
255 _det->SwitchOffDEDX();
262 if( ! measmodules.
empty() ) {
265 errorMsg <<
"MarlinDDKalTest::getSensitiveMeasurementModulesForLayer vector passed as second argument is not empty " <<
std::endl ;
270 streamlog_out( DEBUG0 ) <<
"MarlinDDKalTest::getSensitiveMeasurementModulesForLayer: layerID = " << layerID <<
std::endl;
285 bf.setValue( layerID ) ;
286 bf[lcio::LCTrackerCellID::module()] = 0 ;
287 bf[lcio::LCTrackerCellID::sensor()] = 0 ;
288 layerID = bf.lowWord();
301 if( ! measmodules.
empty() ) {
304 errorMsg <<
"MarlinDDKalTest::getSensitiveMeasurementLayer vector passed as second argument is not empty " <<
std::endl ;
324 Int_t nLayers = detector->GetEntriesFast() ;
326 for(
int i=0; i < nLayers; ++i ) {
328 const DDVMeasLayer* ml =
dynamic_cast<const DDVMeasLayer*
>( detector->At( i ) );
332 errorMsg <<
"MarlinDDKalTest::storeActiveMeasurementLayerIDs dynamic_cast to DDVMeasLayer* failed " <<
std::endl ;
336 if( ml->IsActive() ) {
341 while ( it!=ml->getCellIDs().
end() ) {
343 int sensitive_element_id = *it;
349 int subdet_layer_id = ml->getLayerID() ;
353 streamlog_out(DEBUG0) <<
"MarlinDDKalTest::storeActiveMeasurementLayerIDs added active layer with "
354 <<
" LayerID = " << subdet_layer_id <<
" and DetElementIDs " ;
356 for (it = ml->getCellIDs().
begin(); it!=ml->getCellIDs().
end(); ++it) {
358 streamlog_out(DEBUG0) <<
" : " << *it ;
375 THelicalTrack helix = hel;
377 double deflection_to_point = 0 ;
378 helix.MoveTo( point, deflection_to_point , 0 , 0) ;
380 bool isfwd = ((helix.GetKappa() > 0 && deflection_to_point < 0) || (helix.GetKappa() <= 0 && deflection_to_point > 0)) ?
true :
false;
382 int mode = isfwd ? -1 : +1 ;
388 int nsufaces =
_det->GetEntriesFast();
390 const TVSurface* ml_retval =
nullptr;
391 double min_deflection = DBL_MAX;
393 for(
int i=0; i<nsufaces; ++i) {
395 double defection_angle = 0 ;
396 TVector3 crossing_point ;
398 const TVSurface *sfp =
static_cast<const TVSurface *
>(
_det->At(i));
400 int does_cross = sfp->CalcXingPointWith(helix, crossing_point, defection_angle, mode) ;
404 const double deflection = fabs( deflection_to_point - defection_angle ) ;
406 if( deflection < min_deflection ) {
420 min_deflection = deflection ;
428 return dynamic_cast<const DDVMeasLayer *
>(ml_retval);
441 const DDVMeasLayer* ml = 0;
448 if( meas_modules.
size() == 0 ) {
454 errorMsg <<
"MarlinDDKalTest::findMeasLayer module id unkown: moduleID = " << detElementID
459 else if (meas_modules.
size() == 1) {
461 ml = meas_modules[0] ;
466 bool surf_found(
false);
469 for(
unsigned int i=0; i < meas_modules.
size(); ++i) {
473 const TVSurface* surf = 0;
475 if( ! (surf = dynamic_cast<const TVSurface*> ( meas_modules[i] )) ) {
477 errorMsg <<
"MarlinDDKalTest::findMeasLayer dynamic_cast failed for surface type: moduleID = " << detElementID <<
std::endl ;
481 bool hit_on_surface = surf->IsOnSurface(point);
483 if( (!surf_found) && hit_on_surface ){
485 ml = meas_modules[i] ;
489 else if( surf_found && hit_on_surface ) {
492 errorMsg <<
"MarlinDDKalTest::findMeasLayer point found to be on two surfaces: moduleID = " << detElementID <<
std::endl ;
498 streamlog_out(DEBUG1) <<
"MarlinDDKalTest::findMeasLayer point not found to be on any surface matching moduleID = "
500 <<
": x = " << point.x()
501 <<
" y = " << point.y()
502 <<
" z = " << point.z()
506 streamlog_out(DEBUG1) <<
"MarlinDDKalTest::findMeasLayer point found to be on surface matching moduleID = "
508 <<
": x = " << point.x()
509 <<
" y = " << point.y()
510 <<
" z = " << point.z()
MarlinTrk::IMarlinTrack * createTrack()
instantiate its implementation of the IMarlinTrack
void registerOptions()
Register the possible configuration options.
void storeActiveMeasurementModuleIDs(TVKalDetector *detector)
Store active measurement module IDs for a given TVKalDetector needed for navigation.
virtual const double * getPosition() const =0
virtual void setOption(unsigned CFGOption, bool val)
Sets the specified option ( one of the constants defined in IMarlinTrkSystem::CFG ) to the given valu...
static const unsigned usedEdx
Use multiple scattering in the track fits.
std::multimap< int, const DDVMeasLayer * > _active_measurement_modules_by_layer
virtual void setOption(unsigned CFGOption, bool val)
Sets the specified option ( one of the constants defined in IMarlinTrkSystem::CFG ) to the given valu...
const DDVMeasLayer * getLastMeasLayer(THelicalTrack const &helix, TVector3 const &point) const
std::vector< DDKalDetector * > _detectors
virtual std::string name()
the name of the implementation
void getSensitiveMeasurementModulesForLayer(int layerID, std::vector< const DDVMeasLayer * > &measmodules) const
Store active measurement module IDs needed for navigation.
void init()
initialise track fitter system
std::string valueString() const
void getSensitiveMeasurementModules(int detElementID, std::vector< const DDVMeasLayer * > &measmodules) const
Store active measurement module IDs needed for navigation.
const DDCylinderMeasLayer * _ipLayer
std::multimap< int, const DDVMeasLayer * > _active_measurement_modules
MarlinDDKalTest()
Default c'tor.
Interface for generic tracks in MarlinTrk.
friend class MarlinDDKalTestTrack
~MarlinDDKalTest()
d'tor
static const std::string & encoding_string()
bool getOption(unsigned CFGOption)
Return the option's current value - false if option not defined.
void setValue(lcio::long64 value)
virtual int getCellID0() const =0
const DDVMeasLayer * findMeasLayer(EVENT::TrackerHit *trkhit) const
std::string getOptions()
String with all configuration options and their current values.
T back_inserter(T...args)
void includeEnergyLoss(bool on)
take energy loss into account during the fit
Exception thrown in IMarlinTrk namespace (implemetations of IMarlinTrkSystem and IMarlinTrack).
static const unsigned useQMS
Use multiple scattering in the track fits.
void includeMultipleScattering(bool on)
take multiple scattering into account during the fit