Anp::FillMuonId Class Reference

#include <FillMuonId.h>

Inheritance diagram for Anp::FillMuonId:
Anp::AlgSnarl Anp::AlgEvent Anp::Base Anp::Base

List of all members.

Classes

struct  PlaneData

Public Types

typedef std::vector< double > ChargeVec
typedef std::map< short, float > DataMap
typedef std::map< short,
PlaneData
PMap
typedef PMap::const_iterator PIter

Public Member Functions

 FillMuonId ()
virtual ~FillMuonId ()
bool Run (Record &record)
bool Run (Event &event, const Record &record, const bool pass)
void Config (const Registry &reg)
const DataMap Run (const Track &track, const Record &record) const
void Fill (const PMap &pmap, DataMap &dmap, short base) const
const PMap Select (const Track &track, const Record &record, const std::string &opt="") const
const PMap AddCharge (const PMap &pmap, double calor, double spect) const

Private Member Functions

void Fill0 (PIter beg, PIter end, DataMap &dmap) const
void Fill1 (PIter beg, PIter end, DataMap &dmap, short base) const
void Fill2 (PIter beg, PIter end, DataMap &dmap, short base) const
void Fill3 (PIter beg, PIter end, DataMap &dmap, short base) const
void Fill4 (PIter beg, PIter end, DataMap &dmap, short base) const
const VldContext GetVldc (const Header &header) const
float GetLPos (short plane, const PMap &pmap) const
float Get (const Strip &strip, const VldContext &vldc, float lpos, short option) const

Private Attributes

short fStripWindow
short fMinViewNPlane
short fKeyBase
int fKeyPass
double fTimeWindow
double fMinStripAdc
double fMinStripMip
double fADCShiftMuon
double fADCShiftMuonSpect
double fADCShiftOther
double fADCShiftOtherSpect
bool fIsStudy
bool fFillDetec
bool fFillEvent
bool fFillShift
bool fFillShort

Detailed Description

Definition at line 31 of file FillMuonId.h.


Member Typedef Documentation

typedef std::vector<double> Anp::FillMuonId::ChargeVec

Definition at line 35 of file FillMuonId.h.

typedef std::map<short, float> Anp::FillMuonId::DataMap

Definition at line 36 of file FillMuonId.h.

typedef PMap::const_iterator Anp::FillMuonId::PIter

Definition at line 53 of file FillMuonId.h.

typedef std::map<short, PlaneData> Anp::FillMuonId::PMap

Definition at line 52 of file FillMuonId.h.


Constructor & Destructor Documentation

Anp::FillMuonId::FillMuonId (  ) 

Definition at line 28 of file FillMuonId.cxx.

00029    :fStripWindow(4),
00030     fMinViewNPlane(5),
00031     fKeyBase(7000),
00032     fKeyPass(-1),
00033     fTimeWindow((2.0*18.83 + 0.1)*1.0e-9),
00034     fMinStripAdc(0.0),
00035     fMinStripMip(0.0),
00036     fADCShiftMuon(-14.0),
00037     fADCShiftMuonSpect(-79.0),
00038     fADCShiftOther(10.0),
00039     fADCShiftOtherSpect(0.0),
00040     fIsStudy(false),
00041     fFillDetec(true),
00042     fFillEvent(true),
00043     fFillShift(false),
00044     fFillShort(false)
00045 {
00046 }

Anp::FillMuonId::~FillMuonId (  )  [virtual]

Definition at line 49 of file FillMuonId.cxx.

00050 {
00051 }


Member Function Documentation

const Anp::FillMuonId::PMap Anp::FillMuonId::AddCharge ( const PMap pmap,
double  calor,
double  spect 
) const

Definition at line 704 of file FillMuonId.cxx.

References Anp::FillMuonId::PlaneData::other_vec, Munits::second, and Anp::FillMuonId::PlaneData::track_vec.

Referenced by Run().

00707 {
00708    //
00709    // Subtract adc values for calorimeter and spectrometer strips
00710    //
00711 
00712    PMap newmap = pmap;
00713    
00714    for(PMap::iterator pit = newmap.begin(); pit != newmap.end(); ++pit)
00715    {
00716       PlaneData &data = pit -> second;
00717       
00718       if(pit -> first > 120)
00719       {
00720          std::for_each(data.track_vec.begin(), data.track_vec.end(), Anp::Fill::AddCharge(spect));
00721          std::for_each(data.other_vec.begin(), data.other_vec.end(), Anp::Fill::AddCharge(spect));
00722       }
00723       else
00724       {
00725          std::for_each(data.track_vec.begin(), data.track_vec.end(), Anp::Fill::AddCharge(calor));
00726          std::for_each(data.other_vec.begin(), data.other_vec.end(), Anp::Fill::AddCharge(calor)); 
00727       }
00728    }
00729 
00730    return newmap;
00731 }

void Anp::FillMuonId::Config ( const Registry reg  )  [virtual]

Reimplemented from Anp::AlgEvent.

Definition at line 148 of file FillMuonId.cxx.

References fADCShiftMuon, fADCShiftMuonSpect, fADCShiftOther, fADCShiftOtherSpect, fFillDetec, fFillEvent, fFillShift, fFillShort, fIsStudy, fKeyBase, fKeyPass, fMinStripAdc, fMinStripMip, fMinViewNPlane, fStripWindow, fTimeWindow, Registry::Get(), Registry::KeyExists(), and Anp::Read().

00149 {
00150    //
00151    // Configure self
00152    //
00153 
00154    int value_int = 0;
00155    if(reg.Get("FillMuonIdStripWindow", value_int) && value_int >= 0)
00156    {
00157       fStripWindow = value_int;
00158    }
00159 
00160    value_int = 0;
00161    if(reg.Get("FillMuonIdMinViewNPlane", value_int) && value_int >= 0)
00162    {
00163       fMinViewNPlane = value_int;
00164    }
00165 
00166    value_int = 0;
00167    if(reg.Get("FillMuonIdKeyBase", value_int) && value_int >= 0)
00168    {
00169       fKeyBase = value_int;
00170    }
00171 
00172    double value_double = 0;
00173    if(reg.Get("FillMuonIdTimeWindow", value_double) && value_double > 0.0)
00174    {
00175       fTimeWindow = value_double;
00176    }
00177 
00178    //
00179    // Configure minimum strip ADC or MIP and ADC shift for tuning
00180    //
00181    reg.Get("FillMuonIdKeyPass",            fKeyPass);
00182    reg.Get("FillMuonIdMinStripAdc",        fMinStripAdc);
00183    reg.Get("FillMuonIdMinStripMip",        fMinStripMip);
00184    reg.Get("FillMuonIdADCShiftMuon",       fADCShiftMuon);
00185    reg.Get("FillMuonIdADCShiftMuonSpect",  fADCShiftMuonSpect);
00186    reg.Get("FillMuonIdADCShiftOther",      fADCShiftOther);
00187    reg.Get("FillMuonIdADCShiftOtherSpect", fADCShiftOtherSpect);
00188 
00189    Anp::Read(reg, "FillMuonIdStudy", fIsStudy);
00190    Anp::Read(reg, "FillMuonIdDetec", fFillDetec);
00191    Anp::Read(reg, "FillMuonIdEvent", fFillEvent);
00192    Anp::Read(reg, "FillMuonIdShift", fFillShift);
00193    Anp::Read(reg, "FillMuonIdShort", fFillShort);
00194 
00195    if(reg.KeyExists("PrintConfig"))
00196    {
00197       cout << "FillMuonId::Config" << endl
00198            << "   StripWindow = "        << fStripWindow << endl
00199            << "   MinViewNPlane = "      << fMinViewNPlane << endl
00200            << "   KeyBase = "            << fKeyBase << endl
00201            << "   KeyPass = "            << fKeyPass << endl
00202            << "   TimeWindow = "         << fTimeWindow << endl
00203            << "   MinStripAdc = "        << fMinStripAdc << endl
00204            << "   MinStripMip = "        << fMinStripMip << endl
00205            << "   ADCShiftMuon = "       << fADCShiftMuon << endl
00206            << "   ADCShiftMuonSpect = "  << fADCShiftMuonSpect << endl
00207            << "   ADCShiftOther = "      << fADCShiftOther << endl
00208            << "   ADCShiftOtherSpect = " << fADCShiftOtherSpect << endl
00209            << "   IsStudy = "            << fIsStudy << endl
00210            << "   FillDetec = "          << fFillDetec << endl
00211            << "   FillEvent = "          << fFillEvent << endl
00212            << "   FillShift = "          << fFillShift << endl
00213            << "   FillShort = "          << fFillShort << endl;
00214    }
00215 }

void Anp::FillMuonId::Fill ( const PMap pmap,
DataMap dmap,
short  base 
) const

add all strips within 4 strips and 40 ns window of track

in increasing sigcor values. Divide sorted list of strips

Definition at line 334 of file FillMuonId.cxx.

References fFillShort, Fill1(), Fill2(), Fill3(), and Fill4().

Referenced by Run().

00336 {
00337    // fill variables used for muon identification
00338    // there are 4 variables filled:
00339    // 1) remove first couple track planes and compute mean strip sigcor
00340    //    for remaining track strips
00341    // 2) removed first couple planes from track, then
00343    //    and then sort these selected strips
00345    //    approximately in half and take ratio of lower half over 
00346    //    upper half
00347    // 3) removed first couple planes from track,then for 
00348    //    remaining track strips compute mean strip sigcor
00349    //    for whole track and for last 20% of track
00350    //    take ratio of 20% mean over whole mean
00351    // 4) remove first 30% of track planes, add strips
00352    //    within 4 strip window and 40 ns around track
00353    //    take ratio of track strips' sigcor over all plane's
00354    //     strips' sigcor in window
00355 
00356    PIter end_22_it = pmap.end();
00357    PIter end_24_it = pmap.end();
00358 
00359    if(fFillShort)
00360    {
00361       end_22_it = pmap.begin();
00362       end_24_it = pmap.begin();
00363    }
00364    else
00365    {
00366       short i_frac = 0, pdistance = 0;
00367       for(PIter pit = pmap.begin(); pit != pmap.end(); ++pit)
00368       {
00369          const short frac = (10 * pdistance)/pmap.size();      
00370          
00371          ++pdistance;
00372       
00373          if(pmap.size() > 9 && frac == i_frac)
00374          {
00375             continue;
00376          }
00377          
00378          // !!! hardcoded number !!!
00379          if(i_frac == 2 && end_22_it == pmap.end())
00380          {
00381             end_22_it = pit;
00382          }
00383          
00384          // !!! hardcoded number !!!
00385          if(i_frac == 4 && end_24_it == pmap.end())
00386          {
00387             end_24_it = pit;
00388          }
00389          
00390          ++i_frac;
00391       }
00392    }
00393 
00394    FillMuonId::Fill1(end_22_it, pmap.end(), dmap, base);
00395    FillMuonId::Fill2(end_22_it, pmap.end(), dmap, base);
00396    FillMuonId::Fill3(end_22_it, pmap.end(), dmap, base);
00397    FillMuonId::Fill4(end_24_it, pmap.end(), dmap, base);
00398 }

void Anp::FillMuonId::Fill0 ( PIter  beg,
PIter  end,
DataMap dmap 
) const [private]

Definition at line 734 of file FillMuonId.cxx.

References fKeyBase.

Referenced by Run().

00735 {
00736   // this function computes track length in scintillator planes
00737 
00738    const float nplane_scint = std::distance(beg, end);
00739 
00740    if(nplane_scint < 1.0)
00741    {
00742       cerr << "FillMuonId::Fill0() - zero number of scintillator planes" << endl;
00743    }
00744 
00745    --end;
00746 
00747    const float nplane_steel = end -> first - beg -> first + 1;
00748 
00749    // this function computes track length in scintillator and steel planes
00750    if(!dmap.insert(DataMap::value_type(fKeyBase + 1, nplane_scint)).second)
00751    {
00752       cerr << "FillMuonId::Select() - failed to add data" << endl;
00753    }
00754    if(!dmap.insert(DataMap::value_type(fKeyBase + 2, nplane_steel)).second)
00755    {
00756       cerr << "FillMuonId::Select() - failed to add data" << endl;
00757    }  
00758 }

void Anp::FillMuonId::Fill1 ( PIter  beg,
PIter  end,
DataMap dmap,
short  base 
) const [private]

Definition at line 761 of file FillMuonId.cxx.

References count, fKeyBase, Munits::second, and Anp::FillMuonId::PlaneData::track_vec.

Referenced by Fill().

00762 {
00763    // this function computes mean strip sigcor per strip
00764    // perhaps should use per plane?
00765 
00766    double sum = 0.0;
00767    unsigned short countnear=0;
00768    unsigned short count = 0;
00769 
00770    for(PIter pit = beg; pit != end; ++pit)
00771    {
00772       const PlaneData &data = pit -> second;
00773 
00774       sum += std::accumulate(data.track_vec.begin(), data.track_vec.end(), 0.0);
00775       for( ChargeVec::const_iterator dit = data.track_vec.begin(); dit!= data.track_vec.end(); dit++)
00776         {
00777           if((*dit)>0.5 && (*dit)<1.5) countnear++;
00778         }
00779       count += data.track_vec.size();
00780    }
00781 
00782    if(count < 1)
00783    {
00784       cerr << "FillMuonId::Fill1() - track has no strips" << endl;
00785       return;
00786    }
00787    
00788    const float par = sum/double(count);
00789 
00790    if(!dmap.insert(DataMap::value_type(fKeyBase + base + 10, par)).second)
00791    {
00792       cerr << "FillMuonId::Fill1() - failed to add data" << endl;
00793    }
00794    if(!dmap.insert(DataMap::value_type(fKeyBase + base + 11, countnear/count)).second)
00795    {
00796      cerr << "FillMuonId::Fill1() - failed to add data" << endl;
00797    }
00798 
00799 }

void Anp::FillMuonId::Fill2 ( PIter  beg,
PIter  end,
DataMap dmap,
short  base 
) const [private]

Definition at line 802 of file FillMuonId.cxx.

References count, fIsStudy, fKeyBase, Anp::FillMuonId::PlaneData::other_vec, Munits::second, size, and Anp::FillMuonId::PlaneData::track_vec.

Referenced by Fill().

00803 {
00804    // this function finds all strips within 4 strip window of track
00805    // these strips are sorted in increasing sigcor values
00806    // sigcor sum of lower ?% of strips is divided by sigcor sum 
00807    // of remaining strips
00808    
00809    ChargeVec svec;
00810    float plane_nstrip = 0.0, other_nstrip = 0.0;
00811    
00812    for(PIter pit = beg; pit != end; ++pit)
00813    {
00814       const PlaneData &data = pit -> second;
00815 
00816       plane_nstrip += data.track_vec.size() + data.track_vec.size();
00817       other_nstrip += data.other_vec.size();
00818 
00819       svec.insert(svec.end(), data.track_vec.begin(), data.track_vec.end());
00820       svec.insert(svec.end(), data.other_vec.begin(), data.other_vec.end());
00821    }
00822    
00823    //
00824    // Sort strip by pulse height
00825    //
00826    std::sort(svec.begin(), svec.end());
00827    
00828    const short size = svec.size();   
00829    if(size < 1)
00830    {
00831       cerr << "FillMuonId::Fill2() - strip vector is too short" << endl;
00832       return;
00833    }
00834    
00835    double lower_charge = 0.0, upper_charge = 0.0;
00836    double lower_nstrip = 0.0, upper_nstrip = 0.0;
00837    
00838    unsigned short count = 0;
00839    for(ChargeVec::const_iterator sit = svec.begin(); sit != svec.end(); ++sit)
00840    {
00841       // !!! hardcoded number !!!
00842       if((10 * count)/size < 4)
00843       {
00844          lower_charge += *sit;
00845          lower_nstrip += 1.0;
00846       }
00847       else
00848       {
00849          upper_charge += *sit;
00850          upper_nstrip += 1.0;
00851       }
00852       
00853       ++count;
00854    }
00855    
00856    if(upper_nstrip < 1.0 || lower_nstrip < 1.0 || short(count) != size)
00857    {
00858       cerr << "FillMuonId::Fill2() - failed to split track" << endl;
00859       return;
00860    }
00861    
00862    const double lower_mean = lower_charge/lower_nstrip;
00863    const double upper_mean = upper_charge/upper_nstrip;
00864    
00865    if(!(upper_mean > 0.0))
00866    {
00867       cerr << "FillMuonId::Fill2() -  upper sum is not positive" << endl;
00868       return;
00869    }
00870   
00871    const float par = lower_mean/upper_mean;
00872 
00873    if(!dmap.insert(DataMap::value_type(fKeyBase + base + 20, par)).second)
00874    {
00875       cerr << "FillMuonId::Fill2() - failed to add data" << endl;
00876    }
00877    
00878    //
00879    // Do not fill special variables when running production
00880    //
00881    if(!fIsStudy) return;
00882 
00883    if(!dmap.insert(DataMap::value_type(fKeyBase + base + 21, lower_mean)).second)
00884    {
00885       cerr << "FillMuonId::Fill2() - failed to add data" << endl;
00886    }
00887    if(!dmap.insert(DataMap::value_type(fKeyBase + base + 22, upper_mean)).second)
00888    {
00889       cerr << "FillMuonId::Fill2() - failed to add data" << endl;
00890    }
00891    if(!dmap.insert(DataMap::value_type(fKeyBase + base + 23, plane_nstrip)).second)
00892    {
00893       cerr << "FillMuonId::Fill2() - failed to add track data" << endl;
00894    }
00895    if(!dmap.insert(DataMap::value_type(fKeyBase + base + 24, other_nstrip)).second)
00896    {
00897       cerr << "FillMuonId::Fill2() - failed to add track data" << endl;
00898    }
00899    if(plane_nstrip > 0.0)
00900    {
00901       if(!dmap.insert(DataMap::value_type(fKeyBase + base + 25, other_nstrip/plane_nstrip)).second)
00902       {
00903          cerr << "FillMuonId::Fill2() - failed to add track data" << endl;
00904       }
00905    }
00906 }

void Anp::FillMuonId::Fill3 ( PIter  beg,
PIter  end,
DataMap dmap,
short  base 
) const [private]

Definition at line 909 of file FillMuonId.cxx.

References fFillShort, fIsStudy, fKeyBase, Anp::FillMuonId::PlaneData::other_vec, Munits::second, and Anp::FillMuonId::PlaneData::track_vec.

Referenced by Fill().

00910 {
00911    // this function computes mean strip sigcor in last 20% of track
00912    // and total mean strip sigcor
00913    // no strips around a track are included
00914 
00915    const unsigned short psize = std::distance(beg, end);
00916    if(psize < 1)
00917    {
00918       cerr << "FillMuonId::Fill3() - track has no strips" << endl;
00919       return;
00920    }
00921    if(psize< 5 && fFillShort) return ;
00922    double lower_charge = 0.0, upper_charge = 0.0;
00923    double lower_nplane = 0.0, upper_nplane = 0.0;
00924 
00925    unsigned short pcount = 0;
00926    for(PIter pit = beg; pit != end; ++pit)
00927    {
00928       const PlaneData &data = pit -> second;
00929 
00930       const double tcharge = std::accumulate(data.track_vec.begin(), data.track_vec.end(), 0.0);
00931       const double ocharge = std::accumulate(data.other_vec.begin(), data.other_vec.end(), 0.0);
00932 
00933       // !!! hardcoded number !!!
00934       if((10 * pcount)/psize < 8)
00935       {
00936          lower_charge += tcharge;
00937          lower_charge += ocharge;
00938          lower_nplane += 1.0;
00939       }
00940       else
00941       {
00942          upper_charge += tcharge;
00943          upper_charge += ocharge;
00944          upper_nplane += 1.0;
00945       }
00946 
00947       ++pcount;
00948    }
00949 
00950    if(upper_nplane < 1.0 || lower_nplane < 1.0 || pcount != psize)
00951    {
00952       cerr << "upper, lower, pcount, psize = "
00953            << upper_nplane << ", "
00954            << lower_nplane << ", "
00955            << pcount << ", "
00956            << psize << endl;
00957       cerr << "FillMuonId::Fill3() - failed to split track" << endl;
00958       return;
00959    }
00960    
00961    const double total_mean = (lower_charge + upper_charge)/double(psize);  
00962    const double upper_mean = upper_charge/upper_nplane;
00963 
00964    if(!(total_mean > 0.0) && !(total_mean < 0.0))
00965    {
00966       cerr << "FillMuonId::Fill3() - mean charge is zero" << endl;
00967       return;
00968    }
00969 
00970    const float ratio = upper_mean/total_mean;
00971 
00972    if(!dmap.insert(DataMap::value_type(fKeyBase + base + 30, ratio)).second)
00973    {
00974       cerr << "FillMuonId::Fill3() - failed to add track data" << endl;
00975    }
00976 
00977    //
00978    // do not fill special variables when running production
00979    //
00980    if(!fIsStudy) return;
00981 
00982    if(!dmap.insert(DataMap::value_type(fKeyBase + base + 31, total_mean)).second)
00983    {
00984       cerr << "FillMuonId::Fill3() - failed to add track data" << endl;
00985    }
00986    if(!dmap.insert(DataMap::value_type(fKeyBase + base + 32, upper_mean)).second)
00987    {
00988       cerr << "FillMuonId::Fill3() - failed to add track data" << endl;
00989    }
00990 }

void Anp::FillMuonId::Fill4 ( PIter  beg,
PIter  end,
DataMap dmap,
short  base 
) const [private]

Definition at line 993 of file FillMuonId.cxx.

References fIsStudy, fKeyBase, Anp::FillMuonId::PlaneData::other_vec, Munits::second, Anp::FillMuonId::PlaneData::track_vec, and Anp::FillMuonId::PlaneData::view.

Referenced by Fill().

00994 {
00995    // this function computes ratio of track sigcor to sigcor of strips near track
00996    // use strips within time and strip window around track
00997 
00998    double track_charge = 0.0, other_charge = 0.0;
00999    double track_chargeU = 0.0, other_chargeU = 0.0;
01000    double track_chargeV = 0.0, other_chargeV = 0.0;
01001 
01002 
01003    for(PIter pit = beg; pit != end; ++pit)
01004    {
01005       const PlaneData &data = pit -> second;
01006 
01007       track_charge += std::accumulate(data.track_vec.begin(), data.track_vec.end(), 0.0);
01008       other_charge += std::accumulate(data.other_vec.begin(), data.other_vec.end(), 0.0);
01009       if(data.view==1)
01010       {
01011         track_chargeU += std::accumulate(data.track_vec.begin(), data.track_vec.end(), 0.0);
01012         other_chargeU += std::accumulate(data.other_vec.begin(), data.other_vec.end(), 0.0);
01013       }
01014       else{
01015         track_chargeV += std::accumulate(data.track_vec.begin(), data.track_vec.end(), 0.0);
01016         other_chargeV += std::accumulate(data.other_vec.begin(), data.other_vec.end(), 0.0);
01017       }
01018    }
01019 
01020    const double total_charge = other_charge + track_charge;
01021    const double total_chargeU = other_chargeU + track_chargeU;
01022    const double total_chargeV = other_chargeV + track_chargeV;
01023 
01024    if(!(total_charge > 0.0) && !(total_charge < 0.0))
01025    {
01026      //      cerr << "FillMuonId::Fill4() - total charge is zero" << endl;
01027       return;
01028    }
01029    
01030    if(!(total_chargeU > 0.0) && !(total_chargeU < 0.0))
01031      {
01032        //       cerr << "FillMuonId::Fill4() - total charge is zero" << endl;
01033        return;
01034      }
01035    if(!(total_chargeV > 0.0) && !(total_chargeV < 0.0))
01036      {
01037        //       cerr << "FillMuonId::Fill4() - total charge is zero" << endl;
01038        return;
01039      }
01040 
01041    const float par = track_charge/total_charge;
01042    const float parU = track_chargeU/total_chargeU;
01043    const float parV = track_chargeV/total_chargeV;
01044 
01045    if(!dmap.insert(DataMap::value_type(fKeyBase + base + 40, par)).second)
01046    {
01047       cerr << "FillMuonId::Fill4() - failed to add track data" << endl;
01048    }
01049 
01050    if(!dmap.insert(DataMap::value_type(fKeyBase + base + 51, parU)).second)
01051      {
01052        cerr << "FillMuonId::Fill4() - failed to add track data" << endl;
01053      }
01054    if(!dmap.insert(DataMap::value_type(fKeyBase + base + 52, parV)).second)
01055      {
01056        cerr << "FillMuonId::Fill4() - failed to add track data" << endl;
01057      }
01058    float best =0; float worst=0;
01059    if(best<parU){ best=parU; worst = parV;}
01060    if(best<parV){ best=parV; worst = parU;}
01061    if(!dmap.insert(DataMap::value_type(fKeyBase + base + 50, best)).second)
01062      {
01063        cerr << "FillMuonId::Fill4() - failed to add track data" << endl;
01064      }
01065    if(!dmap.insert(DataMap::value_type(fKeyBase + base + 60, worst)).second)
01066      {
01067        cerr << "FillMuonId::Fill4() - failed to add track data" << endl;
01068      }
01069 
01070 
01071    //
01072    // do not fill special variables when running production
01073    //
01074    if(!fIsStudy) return;
01075 
01076    if(!dmap.insert(DataMap::value_type(fKeyBase + base + 41, track_charge)).second)
01077    {
01078       cerr << "FillMuonId::Fill4() - failed to add track data" << endl;
01079    }
01080    if(!dmap.insert(DataMap::value_type(fKeyBase + base + 42, other_charge)).second)
01081    {
01082       cerr << "FillMuonId::Fill4() - failed to add track data" << endl;
01083    }
01084 }

float Anp::FillMuonId::Get ( const Strip strip,
const VldContext vldc,
float  lpos,
short  option 
) const [private]

Definition at line 1180 of file FillMuonId.cxx.

References Calibrator::GetAttenCorrected(), VldContext::GetDetector(), Anp::Strip::GetEncoded(), Calibrator::GetMIP(), UgliGeomHandle::GetStripHandle(), UgliStripHandle::GlobalToLocal(), Calibrator::Instance(), Anp::Strip::IsUview(), UgliGeomHandle::IsValid(), StripEnd::kEast, Detector::kFar, Detector::kNear, StripEnd::kWest, PlexStripEndId::SetEnd(), Anp::Strip::SigCor(), Anp::Strip::SigCorEast(), Anp::Strip::SigCorWest(), Anp::Strip::TPos(), and Anp::Strip::ZPos().

01182 {
01183    //
01184    // Calibrate strip pulse height from sigcor to sigmap or from sigmap to mip
01185    //
01186 
01187    float upos = -1.0, vpos = -1.0;
01188    if(strip.IsUview())
01189    {
01190       upos = strip.TPos();
01191       vpos = lpos;
01192    }
01193    else
01194    {
01195       upos = lpos;      
01196       vpos = strip.TPos();
01197    }
01198 
01199    UgliGeomHandle ugh(vldc);
01200    if(!ugh.IsValid())
01201    {
01202       cerr << "FillMuonId::Get - invalid UgliGeomHandle: " << vldc << endl;
01203       return 0.0;
01204    }
01205  
01206    const PlexStripEndId seid(strip.GetEncoded());
01207    const UgliStripHandle ush = ugh.GetStripHandle(seid);
01208   
01209    if(!ush.IsValid())
01210    {
01211       cerr << "FillMuonId::Get - invalid UgliStripHandle: " << seid << endl;
01212       return 0.0;
01213    }
01214 
01215    const TVector3 guvz(upos, vpos, strip.ZPos());
01216    const TVector3 lxyz = ush.GlobalToLocal(guvz, false);
01217    
01218    float sigmap = 0.0, sigmap_east = -1.0, sigmap_west = -1.0;
01219    if(vldc.GetDetector() == Detector::kNear)
01220    {
01221       sigmap = Calibrator::Instance().GetAttenCorrected(strip.SigCor(), lxyz.x(), seid);
01222    }
01223    else if(vldc.GetDetector() == Detector::kFar)
01224    {
01225       PlexStripEndId seid_far(seid);
01226       Calibrator &calibrator = Calibrator::Instance();
01227 
01228       if(strip.SigCorEast() > 0.0)
01229       {
01230          seid_far.SetEnd(StripEnd::kEast);
01231          sigmap_east = calibrator.GetAttenCorrected(strip.SigCorEast(), lxyz.x(), seid_far);
01232          sigmap += sigmap_west;
01233       }
01234 
01235       if(strip.SigCorWest() > 0.0)
01236       {      
01237          seid_far.SetEnd(StripEnd::kWest);
01238          sigmap_east = calibrator.GetAttenCorrected(strip.SigCorWest(), lxyz.x(), seid_far);
01239          sigmap += sigmap_east;
01240       }      
01241    }
01242    else
01243    {
01244       cerr << "FillMuonId::Get - unknown detector" << endl;
01245       return 0.0;
01246    }
01247 
01248    //
01249    // Just want sigmap pulse height
01250    //
01251    if(option == 1) return sigmap;
01252 
01253    float mip = 0.0;
01254    if(vldc.GetDetector() == Detector::kNear)
01255    {
01256       mip = Calibrator::Instance().GetMIP(sigmap, seid);
01257    }
01258    else if(vldc.GetDetector() == Detector::kFar)
01259    {
01260       PlexStripEndId seid_far(seid);
01261 
01262       if(sigmap_east > 0.0)
01263       {
01264          seid_far.SetEnd(StripEnd::kEast);
01265          mip += Calibrator::Instance().GetMIP(sigmap_east, seid_far);
01266       }
01267 
01268       if(sigmap_west > 0.0)
01269       {      
01270          seid_far.SetEnd(StripEnd::kWest);
01271          mip = Calibrator::Instance().GetMIP(sigmap_west, seid_far);
01272       }
01273    }
01274 
01275    return mip;
01276 }

float Anp::FillMuonId::GetLPos ( short  plane,
const PMap pmap 
) const [private]

Definition at line 1117 of file FillMuonId.cxx.

References Munits::second, and Anp::FillMuonId::PlaneData::tpos.

01118 {
01119    // 
01120    // Find longitudinal hit position using nearby planes
01121    //
01122 
01123    map<short, float> fmap;
01124    
01125    for(PMap::const_iterator pit = pmap.begin(); pit != pmap.end(); ++pit)
01126    {
01127       const short diff = plane - pit -> first;
01128 
01129       const PlaneData &data = pit -> second;
01130 
01131       // easiest solution: return tpos in the previous plane
01132       if(diff == -1)
01133       {
01134          return data.tpos;
01135       }
01136 
01137       // skip strips in same plane view
01138       if( int(std::abs(diff)) % 2 == 0)
01139       {
01140          continue;
01141       }
01142 
01143       if(!fmap.insert(map<short, float>::value_type(diff, data.tpos)).second)
01144       {
01145          cerr << "FillMuonId::GetLPos - duplicate plane difference" << endl;
01146       }
01147    }
01148 
01149    if(fmap.empty())
01150    {
01151       cerr << "FillMuonId::GetLPos - no planes in orthogonal view" << endl;
01152       return -100.0;
01153    }
01154 
01155    map<short, float>::iterator dit_pos = fmap.begin();
01156    map<short, float>::iterator dit_neg = fmap.begin();
01157    for(map<short, float>::iterator dit = fmap.begin(); dit != fmap.end(); ++dit)
01158    {
01159       const short diff = dit -> first;
01160       if(diff < 0)
01161       {
01162          if(abs(dit_neg -> first) > abs(diff))
01163          {
01164             dit_neg = dit;
01165          }
01166       }
01167       if(diff > 0)
01168       {
01169          if(abs(dit_pos -> first) > abs(diff))
01170          {
01171             dit_pos = dit;
01172          }
01173       }
01174    }
01175 
01176    return 0.5*(dit_pos -> second + dit_neg -> second);
01177 }

const VldContext Anp::FillMuonId::GetVldc ( const Header header  )  const [private]

Definition at line 1087 of file FillMuonId.cxx.

References Anp::Header::IsData(), Anp::Header::IsFar(), Anp::Header::IsNear(), SimFlag::kData, Detector::kFar, SimFlag::kMC, Detector::kNear, SimFlag::kUnknown, Detector::kUnknown, Anp::Header::NSec(), and Anp::Header::Sec().

01088 {
01089    const VldTimeStamp time(header.Sec(), header.NSec());
01090    if(header.IsData())
01091    {
01092       if(header.IsNear())
01093       {
01094          return VldContext(Detector::kNear, SimFlag::kData, time);
01095       }
01096       else if(header.IsFar())
01097       {
01098          return VldContext(Detector::kFar, SimFlag::kData, time);
01099       }
01100    }
01101    else
01102    {
01103       if(header.IsNear())
01104       {
01105          return VldContext(Detector::kNear, SimFlag::kMC, time);
01106       }
01107       else if(header.IsFar())
01108       {
01109          return VldContext(Detector::kFar, SimFlag::kMC, time);
01110       }
01111    }
01112 
01113    return VldContext(Detector::kUnknown, SimFlag::kUnknown, time);   
01114 }

const Anp::FillMuonId::DataMap Anp::FillMuonId::Run ( const Track track,
const Record record 
) const

add all strips within 4 strips and 40 ns window of track

in increasing sigcor values. Divide sorted list of strips

Definition at line 218 of file FillMuonId.cxx.

References AddCharge(), fADCShiftMuon, fADCShiftMuonSpect, fADCShiftOther, fADCShiftOtherSpect, fFillDetec, fFillShift, Fill(), Fill0(), Anp::Record::FindStdHep(), fKeyBase, Anp::Record::GetHeader(), Anp::Header::IsData(), Select(), Anp::Record::StdHepBeg(), and Anp::Record::StdHepEnd().

00219 {
00220    // fill variables used for muon identification
00221    // there are 4 variables filled:
00222    // 1) remove first few track planes and compute mean strip sigcor
00223    //    for remaining track strips
00224    // 2) removed first few planes from track, then
00226    //    and then sort these selected strips
00228    //    approximately in half and take ratio of lower half over 
00229    //    upper half
00230    // 3) removed first few planes from track,then for 
00231    //    remaining track strips compute mean strip sigcor
00232    //    for whole track and for last 20% of track
00233    //    take ratio of 20% mean over whole mean
00234    // 4) remove first 30% of track planes, add strips
00235    //    within 4 strip window and 40 ns around track
00236    //    take ratio of track strips' sigcor over all plane's
00237    //     strips' sigcor in window
00238    //
00239    // This function has hard coded key base values
00240    //
00241    
00242 
00243    DataMap dmap;
00244    
00245    //
00246    // Fill truth variable used by training algorithm(s)
00247    //
00248    short track_is_muon = -1;
00249    if(!record.GetHeader().IsData() && record.StdHepBeg() != record.StdHepEnd())
00250    {
00251       StdHepIter stdhep = record.FindStdHep(track);
00252       if(stdhep != record.StdHepEnd())
00253       {
00254          if(stdhep -> IsMuon()) track_is_muon = 1;
00255          else                   track_is_muon = 0;
00256          
00257          if(!dmap.insert(DataMap::value_type(fKeyBase, static_cast<float>(track_is_muon))).second)
00258          {
00259             cerr << "FillMuonId::Run - failed to insert value at " << fKeyBase << " key" << endl;
00260          }
00261       }
00262       else
00263       {
00264          cerr << "FillMuonId::Run - failed to find StdHep record" << endl;
00265          return dmap;
00266       }
00267    }
00268 
00269    //
00270    // Collect strips that we will use to compute variables...
00271    //
00272    const PMap pall = FillMuonId::Select(track, record);
00273    
00274    //
00275    // Track does not pass selection requirement
00276    //
00277    if(pall.empty()) return dmap;
00278 
00279    //
00280    // Fill variables using all of the detector planes
00281    //
00282    if(fFillDetec) FillMuonId::Fill(pall, dmap, 0);
00283 
00284    //
00285    // Fill number of track planes variable (once, using all detector planes)
00286    //
00287    FillMuonId::Fill0(pall.begin(), pall.end(), dmap);
00288    //
00289    // Fill tuned (ADC added or subtracted) variables
00290    //
00291    if(fFillShift)
00292    {      
00293       PMap pnew;
00294       if     (track_is_muon == 1) pnew = AddCharge(pall, fADCShiftMuon,  fADCShiftMuonSpect);
00295       else if(track_is_muon == 0) pnew = AddCharge(pall, fADCShiftOther, fADCShiftOtherSpect);
00296 
00297       if(!pnew.empty()) FillMuonId::Fill(pnew, dmap, 100);
00298    }
00299 
00300    //
00301    // Fill variables using calorimeter only strips
00302    // 
00303    const PMap pcal = FillMuonId::Select(track, record, "calor");
00304    if(!pcal.empty())
00305    {
00306       FillMuonId::Fill(pcal, dmap, 200);
00307    }   
00308 
00309    //
00310    // Fill variables using MIP calibrated strip charge
00311    //
00312    if(fFillDetec)
00313    {
00314       const PMap pmip = FillMuonId::Select(track, record, "mip");
00315       if(!pmip.empty())
00316       {
00317          FillMuonId::Fill(pmip, dmap, 300);
00318       }
00319    }
00320 
00321    //
00322    // Fill variables using MIP calibrated calorimeter strip charge
00323    //
00324    const PMap pmipcal = FillMuonId::Select(track, record, "calor mip");
00325    if(!pmipcal.empty())
00326    {
00327       FillMuonId::Fill(pmipcal, dmap, 400);
00328    }
00329 
00330    return dmap;
00331 }

bool Anp::FillMuonId::Run ( Event event,
const Record record,
const bool  pass 
) [virtual]

Implements Anp::AlgEvent.

Definition at line 124 of file FillMuonId.cxx.

References it, Anp::LongestTrack(), Run(), Munits::second, and Anp::Record::TrackEnd().

00125 { 
00126    if(!pass)
00127    {
00128       return true;
00129    }
00130    
00131    const TrackIter track = Anp::LongestTrack(event, record);
00132    if(track == record.TrackEnd())
00133    {
00134       return true;
00135    }
00136 
00137    const DataMap dmap = Run(*track, record);
00138    
00139    for(DataMap::const_iterator it = dmap.begin(); it != dmap.end(); ++it)
00140    {
00141       event.Add(it -> first, it -> second);
00142    }
00143 
00144    return true;
00145 }

bool Anp::FillMuonId::Run ( Record record  )  [virtual]

Implements Anp::AlgSnarl.

Definition at line 65 of file FillMuonId.cxx.

References Anp::Record::EventBegIterator(), Anp::Record::EventEndIterator(), fFillEvent, fKeyPass, it, Anp::LongestTrack(), Munits::second, Anp::Record::TrackBegIterator(), Anp::Record::TrackEnd(), and Anp::Record::TrackEndIterator().

Referenced by Run().

00066 {
00067    map<short, const DataMap> track_dmap;
00068 
00069    for(TrackIterator track = record.TrackBegIterator(); track != record.TrackEndIterator(); ++track)
00070    {
00071       //
00072       // Check if KeyPass exists
00073       //
00074       if(fKeyPass > 0 && !(track -> KeyExists(fKeyPass)))
00075       {
00076          continue;
00077       }
00078 
00079       const DataMap dmap = FillMuonId::Run(*track, record);
00080 
00081       for(DataMap::const_iterator it = dmap.begin(); it != dmap.end(); ++it)
00082       {
00083          track -> Add(it -> first, it -> second);
00084       }
00085 
00086       if(!track_dmap.insert(map<short, const DataMap>::value_type(track -> TrackIndex(), dmap)).second)
00087       {
00088          cerr << "FillMuonId::Run - duplicate track index " << track -> TrackIndex() << endl;
00089       }
00090    }
00091 
00092    if(!fFillEvent || track_dmap.empty())
00093    {
00094       return true;
00095    }
00096 
00097    for(EventIterator event = record.EventBegIterator(); event != record.EventEndIterator(); ++event)
00098    {
00099       const TrackIter track = Anp::LongestTrack(*event, record);
00100       if(track == record.TrackEnd())
00101       {
00102          continue;
00103       }
00104 
00105       map<short, const DataMap>::const_iterator dit = track_dmap.find(track -> TrackIndex());
00106       if(dit == track_dmap.end())
00107       {
00108          cerr << "FillMuonId::Run - failed to find track index " << track -> TrackIndex() << endl;
00109          continue;
00110       }
00111       
00112       const DataMap &dmap = dit -> second;
00113 
00114       for(DataMap::const_iterator it = dmap.begin(); it != dmap.end(); ++it)
00115       {
00116          event -> Add(it -> first, it -> second);
00117       }     
00118    } 
00119 
00120    return true;
00121 }

const PMap Anp::FillMuonId::Select ( const Track track,
const Record record,
const std::string &  opt = "" 
) const

Referenced by Run().


Member Data Documentation

Definition at line 99 of file FillMuonId.h.

Referenced by Config(), and Run().

Definition at line 100 of file FillMuonId.h.

Referenced by Config(), and Run().

Definition at line 102 of file FillMuonId.h.

Referenced by Config(), and Run().

Definition at line 103 of file FillMuonId.h.

Referenced by Config(), and Run().

Definition at line 106 of file FillMuonId.h.

Referenced by Config(), and Run().

Definition at line 107 of file FillMuonId.h.

Referenced by Config(), and Run().

Definition at line 108 of file FillMuonId.h.

Referenced by Config(), and Run().

Definition at line 109 of file FillMuonId.h.

Referenced by Config(), Fill(), and Fill3().

bool Anp::FillMuonId::fIsStudy [private]

Definition at line 105 of file FillMuonId.h.

Referenced by Config(), Fill2(), Fill3(), and Fill4().

short Anp::FillMuonId::fKeyBase [private]

Definition at line 91 of file FillMuonId.h.

Referenced by Config(), Fill0(), Fill1(), Fill2(), Fill3(), Fill4(), and Run().

Definition at line 92 of file FillMuonId.h.

Referenced by Config(), and Run().

Definition at line 96 of file FillMuonId.h.

Referenced by Config().

Definition at line 97 of file FillMuonId.h.

Referenced by Config().

Definition at line 90 of file FillMuonId.h.

Referenced by Config().

Definition at line 89 of file FillMuonId.h.

Referenced by Config().

double Anp::FillMuonId::fTimeWindow [private]

Definition at line 94 of file FillMuonId.h.

Referenced by Config().


The documentation for this class was generated from the following files:

Generated on 11 Jan 2018 for loon by  doxygen 1.6.1