iLCSoft / MarlinTrkProcessors

Collection of Tracking Relelated Processors Based on MarlinTrk
GNU General Public License v3.0
1 stars 28 forks source link

RefitProcessor crashes with default (-1) InitialTrackState option #60

Open dudarboh opened 2 years ago

dudarboh commented 2 years ago

Issue

As title says RefitProcessor crashes with uncaught exception using default (-1) InitialTrackState option.

Reproduce

source /cvmfs/ilc.desy.de/sw/x86_64_gcc82_centos7/v02-02-03/init_ilcsoft.sh

steering file:

<marlin>
    <constants>
    </constants>

    <global>
        <parameter name="LCIOInputFiles">
            /pnfs/desy.de/ilc/prod/ilc/mc-2020/ild/rec/250-SetA/2f_hadronic_eL_pR/ILD_l5_o1_v02/v02-02/00015161/000/rv02-02.sv02-02.mILD_l5_o1_v02.E250-SetA.I500010.P2f_z_h.eL.pR.n000_052.d_rec_00015161_219.slcio
        </parameter>
        <parameter name="MaxRecordNumber" value="0" />
        <parameter name="SkipNEvents" value="0" />
        <parameter name="SupressCheck" value="false" />
        <parameter name="AllowToModifyEvent" value="false" />

    </global>

    <execute>
        <processor name="InitDD4hep" />
        <processor name="MyTestRefitProcessorProton" />
    </execute>

    <processor name="InitDD4hep" type="InitializeDD4hep">
        <parameter name="DD4hepXMLFile" type="string">
            /cvmfs/ilc.desy.de/sw/x86_64_gcc82_centos7/v02-02/lcgeo/v00-16-06/ILD/compact/ILD_l5_o1_v02/ILD_l5_o1_v02.xml
        </parameter>
    </processor>

    <processor name="MyTestRefitProcessorProton" type="RefitProcessor">
      <!--RefitProcessor refits an input track collection, producing a new collection of tracks. Proton mass hypothesis-->
      <!--Use Energy Loss in Fit-->
      <parameter name="EnergyLossOn" type="bool">true</parameter>
      <!--Fit direction: -1: backward [default], +1: forward-->
      <parameter name="FitDirection" type="int">-1</parameter>
      <!--Value used for the initial d0 variance of the trackfit-->
      <parameter name="InitialTrackErrorD0" type="float">1e+06</parameter>
      <!--Value used for the initial omega variance of the trackfit-->
      <parameter name="InitialTrackErrorOmega" type="float">0.00001</parameter>
      <!--Value used for the initial phi0 variance of the trackfit-->
      <parameter name="InitialTrackErrorPhi0" type="float">100</parameter>
      <!--Value used for the initial tanL variance of the trackfit-->
      <parameter name="InitialTrackErrorTanL" type="float">100</parameter>
      <!--Value used for the initial z0 variance of the trackfit-->
      <parameter name="InitialTrackErrorZ0" type="float">1e+06</parameter>
      <!--TrackState to use for initialization of the fit: -1: refit from hits [default], 1: AtIP, 2: AtFirstHit, 3: AtLastHit, 4:AtCalo-->
      <parameter name="InitialTrackState" type="int">-1</parameter>
      <!--Name of the input track collection-->
      <parameter name="InputTrackCollectionName" type="string" lcioInType="Track">MarlinTrkTracks</parameter>
      <!--Name of the MCParticle-Track Relations collection for input tracks-->
      <parameter name="InputTrackRelCollection" type="string" lcioInType="LCRelation" />
      <!--Maximum Chi-squared value allowed when assigning a hit to a track-->
      <!--  <parameter name="MaxChi2PerHit" type="float">100 </parameter>-->
      <!--Use MultipleScattering in Fit-->
      <!--  <parameter name="MultipleScatteringOn" type="bool">true </parameter>-->
      <!--Name of the output track collection-->
      <parameter name="OutputTrackCollectionName" type="string" lcioOutType="Track">MarlinTrkTracksProton</parameter>
      <!--Name of the MCParticle-Track Relations collection for output tracks-->
      <parameter name="OutputTrackRelCollection" type="string" lcioOutType="LCRelation">MarlinTrkTracksProtonMCP</parameter>
      <!--particle mass that is used in the fit - default is the pion mass: 0.13957018 )-->
      <parameter name="ParticleMass" type="double">0.93828</parameter>
      <!--Smooth All Mesurement Sites in Fit-->
      <!--  <parameter name="SmoothOn" type="bool">false </parameter>-->
      <!--Name of the track fitting system to be used (KalTest, DDKalTest, aidaTT, ... )-->
      <parameter name="TrackSystemName" type="string">DDKalTest</parameter>
      <!--verbosity level of this processor ("DEBUG0-4,MESSAGE0-4,WARNING0-4,ERROR0-4,SILENT")-->
      <!-- <parameter name="Verbosity" type="string">MESSAGE</parameter> -->
    </processor>
</marlin>

Output:

[ DEBUG4 "MyTestRefitProcessorProton"] MarlinTrk::createFit ndof_added = 462
[ DEBUG5 "MyTestRefitProcessorProton"] MarlinTrk::createFit : null pointer for pre_fit given - will fall back  to default initialisation ...
Error in <operator()>: Request row(1) outside matrix range of 0 - 1
[ ERROR "MyTestRefitProcessorProton"] RefitProcessor::processEvent: EVENT: << 20401 >> exception caught and rethown. Track = 0x16182660
[ DEBUG2 "MyTestRefitProcessorProton"]   **** MarlinDDKalTest::includeEnergyLoss( 1 ) called 
[ DEBUG2 "MyTestRefitProcessorProton"]   **** MarlinDDKalTest::includeMultipleScattering( 1 ) called 
 ***********************************************
 A runtime error occured - (uncaught exception):
      MarlinTrk::Exception: Track fit cannot be initialised from 1 Dimensional hits. Use method MarlinDDKalTestTrack::initialise( bool fitDirection )
 Marlin will have to be terminated, sorry.
 ***********************************************
dudarboh commented 2 years ago

I think this can be fixed if one uses createFinalisedLCIOTrack( ..., const EVENT::FloatVec& initial_cov_for_prefit, ...)` it constructs pre-fit automatically ensuring that there are enough 3D hits to reconstruct it.

instead of currently used: createFinalisedLCIOTrack(..., EVENT::TrackState* pre_fit, ...)

Which immediately calls int fit_status = createFit(hit_list, marlinTrk, pre_fit, bfield_z, fit_direction, maxChi2Increment); even if the pre_fit is a nullptr.

dudarboh commented 2 years ago

It was actually intentionally changed in the refit processor a while ago here: https://github.com/iLCSoft/MarlinTrkProcessors/commit/3a6683d06e294ebbee6b24a9579561589e404c4a?diff=unified#

@gaede do you recall the reason for this?