Doubt regarding definition of Missing hits

Can someone please clarify the definition of missing hits? From Line 201 in
ElectronAnalyzer.cc" of POET repository what I have understood is, it is the difference between the number of Expected hits and Hit Pattern (Observed hits) which would tell us whether there are any gaps in the trajectory. Following this definition, the distribution I made for missing hits in the ECAL Barrel is given below:

Now this distribution of missing hits has negative values in its range. This would imply the number of Observed hits is more than the Expected Hits. How can this be possible?
Furthermore, since missing hits is a positive integer what is the motivation behind putting the ‘less than’ sign while imposing the constraint missing_hits <= 0 throughout the CMSSW workbook?

Would also appreciate if someone could point me to the definition of trackerExpectedHitsInner().numberOfHits() .

Hello,

The definition in line 201 was incorrect and will be updated.

The missing hits here actually refer to the number of tracker layers crossed before the first hit. From section 5.3 of this electron reconstruction reference: “When photon conversions take place inside the volume of the tracker, the first hit on electron tracks from the converted photons is often not located in the innermost layer of the tracker, and missing hits are therefore present in that region. For prompt electrons, whose trajectories start from the beamline, no missing hits are expected in the inner layers.”

To correct this issue we update the definition to just:
int missing_hits = itElec->gsfTrack()->trackerExpectedHitsInner().numberOfHits();

This alone gives us the value we’re looking for. You can see the definition here.

We will also update the constraint missing_hits <= 0 to missing_hits == 0 for clarity though this will not change the function of the code.

Testing the update gives results like this which are expected (note that missing hits branch is not included in default electron analyzer):