Fork me on GitHub

Changeset 9666d3b in git for modules/StatusPidFilter.cc


Ignore:
Timestamp:
Apr 11, 2018, 4:19:18 PM (7 years ago)
Author:
Ulrike Schnoor <ulrike.schnoor@…>
Branches:
ImprovedOutputFile, Timing, dual_readout, llp, master
Children:
6ba7847
Parents:
6f96f62 (diff), a670493 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

merged the upstream/master

File:
1 edited

Legend:

Unmodified
Added
Removed
  • modules/StatusPidFilter.cc

    r6f96f62 r9666d3b  
    5151using namespace std;
    5252
     53namespace {
     54  // integer power (faster than TMath::Pow() + cast to integer)
     55  int ipow(int base, int exp)
     56  {
     57      int result = 1;
     58      while (exp)
     59      {
     60          if (exp & 1)
     61              result *= base;
     62          exp >>= 1;
     63          base *= base;
     64      }
     65
     66      return result;
     67  }
     68
     69  // standalone function to extract the i-th digit from a number (counting from 0 = rightmost, etc..)
     70  int digit(int val, int i)
     71  {
     72      int y    = ipow(10,i);
     73      int z    = val/y;
     74      int val2 = val / (y * 10);
     75      return (z - val2*10);
     76  }
     77
     78  //  return the first two digits if this is a "fundamental" particle
     79  //  ID = 100 is a special case (internal generator ID's are 81-100)
     80  //  also, 101 and 102 are now used (by HepPID) for geantinos
     81  int fundamentalID(int pdgCode)
     82  {
     83      pdgCode = abs(pdgCode);
     84      if( ( digit(pdgCode, 9) == 1 ) && ( digit(pdgCode, 8) == 0 ) ) { return 0; }
     85      if( digit(pdgCode, 2) == 0 && digit(pdgCode, 3) == 0) {
     86          return pdgCode%10000;
     87      } else if( pdgCode <= 102 ) {
     88          return pdgCode;
     89      } else {
     90          return 0;
     91      }
     92  }
     93
     94  bool hasBottom(int pdgCode)
     95  {
     96      if ( (pdgCode/10000000) > 0)
     97        return false;
     98      if (pdgCode <= 100)
     99        return false;
     100      if (fundamentalID(pdgCode) <= 100 && fundamentalID(pdgCode) > 0)
     101        return false;
     102      if( digit(pdgCode, 3) == 5 || digit(pdgCode, 2) == 5 || digit(pdgCode, 1) == 5 )
     103        return true;     
     104      return false;
     105  }
     106
     107  bool isTauDaughter(int pdgCode, int M1, const TObjArray *fInputArray){
     108    //not needed, just to speed up the code - can be further refined but gives only negligible improvement:
     109    if ( pdgCode==15 || pdgCode<11 || (pdgCode > 22 && pdgCode < 100) || pdgCode>1000 )
     110      return false;
     111
     112    if ( M1 < 0 )
     113      return false;
     114
     115    Candidate *mother;
     116    mother = static_cast<Candidate*>(fInputArray->At( M1 ));
     117    if ( TMath::Abs(mother->PID) == 15 )
     118      return true;
     119
     120    return false;
     121  }
     122
     123}
     124
     125
    53126//------------------------------------------------------------------------------
    54127
     
    117190    if(pdgCode > 22 && pdgCode < 43) pass = kTRUE;
    118191
    119     if(!pass || candidate->Momentum.Pt() < fPTMin) continue;
     192    //Stable photons
     193    if(pdgCode == 22 && status==1) pass = kTRUE;
     194
     195    // logic ported from HepPDF: http://lcgapp.cern.ch/project/simu/HepPDT/HepPDT.2.05.02/html/ParticleID_8cc-source.html#l00081
     196    bool is_b_hadron = hasBottom(pdgCode);
     197    bool is_b_quark  = (pdgCode == 5);
     198
     199    bool is_tau_daughter = isTauDaughter(pdgCode, candidate->M1, fInputArray);
     200
     201    if (is_b_hadron)
     202      pass = kTRUE;
     203
     204    if (is_tau_daughter)
     205      pass = kTRUE;
     206
     207    // fPTMin not applied to b_hadrons / b_quarks to allow for b-enriched sample stitching
     208    // fPTMin not applied to tau decay products to allow visible-tau four momentum determination
     209    if(!pass || (candidate->Momentum.Pt() < fPTMin && !(is_b_hadron || is_b_quark || is_tau_daughter)) ) continue;
    120210
    121211    fOutputArray->Add(candidate);
Note: See TracChangeset for help on using the changeset viewer.