ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/MitPhysics/Utils/interface/MuonTools.h
(Generate patch)

Comparing UserCode/MitPhysics/Utils/interface/MuonTools.h (file contents):
Revision 1.2 by ceballos, Tue Nov 11 21:21:28 2008 UTC vs.
Revision 1.3 by loizides, Thu Nov 27 16:28:58 2008 UTC

# Line 1 | Line 1
1 + //--------------------------------------------------------------------------------------------------
2 + // $Id$
3 + //
4 + // MuonTools
5 + //
6 + // Isolation functions to compute various kinds of isolation.
7 + // http://cmslxr.fnal.gov/lxr/source/RecoMuon/MuonIdentification/
8 + // http://cmslxr.fnal.gov/lxr/source/DataFormats/MuonReco/
9 + // Authors: P.Harris, C.Loizides
10 + //--------------------------------------------------------------------------------------------------
11 +
12   #ifndef MITPHYSICS_UTIL_MUONTOOLS_H
13   #define MITPHYSICS_UTIL_MUONTOOLS_H
3 #include <vector>
4 #include <iostream>
14  
15 < #include "TH2D.h"
7 < #include "TFile.h"
8 < #include "MitAna/DataTree/interface/Collections.h"
15 > #include "MitAna/DataTree/interface/Muon.h"
16   #include "MitCommon/MathTools/interface/MathUtils.h"
17 + #include "TH2D.h"
18  
19   namespace mithep {
20    class MuonTools {
21 <  public:
22 <    MuonTools();
23 <    ~MuonTools();
24 <    double getCaloCompatability(mithep::Muon* iMuon,bool iEMSpecial, bool iCorrectedHCAL);
25 <    enum selection {
26 <      AllArbitrated,
27 <      PromptTight,
28 <      TMLastStationLoose,
29 <      TMLastStationTight,
30 <      TMOneStationLoose,
31 <      TMOneStationTight,
32 <      TM2DCompatibilityLoose,
33 <      TM2DCompatibilityTight
34 <    };
35 <    static inline double sigWeight(double iVal0,double iVal1) {
36 <      if(iVal1 < 1.) return 1;
37 <      if(iVal0 < 3. && iVal1 > 3.) {
38 <        double lVal = TMath::Max(iVal0,1.);
39 <        return 1/TMath::Power(lVal,0.25);
40 <      }
41 <      double lVal = TMath::Max(iVal1,1.);
42 <      return 1/TMath::Power(lVal,0.25);
43 <    }
44 <    static inline int lastHit(mithep::Muon *iMuon) {
45 <      int lId = -1;
46 <      for(int i0 = 0; i0 < 8; i0++) {
47 <        if(iMuon->GetDX(i0) < 99999 || iMuon->GetDY(i0) < 99999) lId = i0;
48 <      }
49 <      return lId;
50 <    }
51 <    static inline int maxChamberId(mithep::Muon* iMuon,double iMaxD,double iMaxP) {
52 <      int lId = -1;
53 <      for(int i0 = 0; i0 < 8; i0++) {
54 <        if(iMuon->GetTrackDist(i0)                            < iMaxD &&
55 <           iMuon->GetTrackDist(i0)/iMuon->GetTrackDistErr(i0) < iMaxP) {
56 <          if(iMuon->GetDX(i0) >= 999999) {lId = i0;} else {lId = -1;}
57 <        }
58 <      }
59 <      return lId;
60 <    }
61 <    static inline int lastStation(mithep::Muon* iMuon,double iMaxD,double iMaxP) {
62 <      int lId = -1;
63 <      for(int i0 = 0; i0 < 8; i0++) {
64 <        if((lId % 4) > (i0 % 4)) continue;
65 <        if(iMuon->GetTrackDist(i0)                            < iMaxD &&
66 <           iMuon->GetTrackDist(i0)/iMuon->GetTrackDistErr(i0) < iMaxP) lId = i0;
67 <      }
68 <      return lId;
69 <    }
70 <    static inline int lastStation(mithep::Muon* iMuon,int iMax=8) {
71 <      int lId = -1; if(iMax > 8) iMax = 8;
72 <      for(int i0 = 0; i0 < iMax; i0++) {if(iMuon->StationBit(i0) && ((lId % 4) < (i0 % 4)))lId = i0;}
73 <      return lId;
74 <    }
75 <    static inline bool overflow(TH2D *iHist,double lVal0,double lVal1) {
76 <      if(iHist == 0) return true;
77 <      if(iHist ->GetXaxis()->FindBin(lVal0) == 0               ||
78 <         iHist ->GetXaxis()->FindBin(lVal0) >  iHist->GetNbinsX() ||
79 <         iHist ->GetYaxis()->FindBin(lVal0) == 0               ||
80 <         iHist ->GetYaxis()->FindBin(lVal0) >  iHist->GetNbinsY()) return true;
81 <      return false;
82 <    }
21 >    public:
22 >      MuonTools(const char *mutemp="$CMSSW_BASE/src/MitPhysics/data/MuonCaloTemplate.root",
23 >                const char *pitemp="$CMSSW_BASE/src/MitPhysics/data/PionCaloTemplate.root");
24 >      ~MuonTools();
25 >
26 >      enum ESelType {
27 >        kAllArbitrated,
28 >        kPromptTight,
29 >        kTMLastStationLoose,
30 >        kTMLastStationTight,
31 >        kTMOneStationLoose,
32 >        kTMOneStationTight,
33 >        kTM2DCompatibilityLoose,
34 >        kTM2DCompatibilityTight
35 >      };
36 >
37 >      Bool_t      Init(const char *mutemp, const char *pitemp);
38 >      Bool_t      IsGood(const mithep::Muon *iMuon, ESelType iSel) const;
39 >
40 >    protected:
41 >      void        DeleteHistos();
42 >      Double_t    GetCaloCompatability(const mithep::Muon *iMuon,
43 >                                       Bool_t iEMSpecial, Bool_t iCorrectedHCAL) const;
44 >      Double_t    GetSegmentCompatability(const mithep::Muon *iMuon)             const;
45 >      Bool_t      Overflow(const TH2D *iHist, Double_t lVal0, Double_t lVal1)    const;
46 >      Double_t    SigWeight(Double_t iVal0, Double_t iVal1)                      const;
47 >
48 >    private:
49 >      Bool_t      fIsInit;              //!
50 >      TH2D       *fmuon_em_etaEmi;      //!
51 >      TH2D       *fmuon_had_etaEmi;     //!
52 >      TH2D       *fmuon_had_etaTmi;     //!
53 >      TH2D       *fmuon_em_etaB;        //!
54 >      TH2D       *fmuon_had_etaB;       //!
55 >      TH2D       *fmuon_ho_etaB;        //!
56 >      TH2D       *fmuon_had_etaTpl;     //!
57 >      TH2D       *fmuon_em_etaEpl;      //!
58 >      TH2D       *fmuon_had_etaEpl;     //!
59 >      TH2D       *fpion_em_etaEmi;      //!
60 >      TH2D       *fpion_had_etaEmi;     //!
61 >      TH2D       *fpion_had_etaTmi;     //!
62 >      TH2D       *fpion_em_etaB;        //!
63 >      TH2D       *fpion_had_etaB;       //!
64 >      TH2D       *fpion_ho_etaB;        //!
65 >      TH2D       *fpion_had_etaTpl;     //!
66 >      TH2D       *fpion_em_etaEpl;      //!
67 >      TH2D       *fpion_had_etaEpl;     //!
68 >
69 >      TH2D       *LoadHisto(const char *fname, TFile *file)                      const;
70 >  };
71 > }
72 >
73 > //--------------------------------------------------------------------------------------------------
74 > inline Double_t mithep::MuonTools::SigWeight(Double_t iVal0, Double_t iVal1) const
75 > {
76 >  //
77 >
78 >  if (iVal1 < 1.)
79 >    return 1.;
80 >  if (iVal0 < 3. && iVal1 > 3.) {
81 >    Double_t lVal = TMath::Max(iVal0,1.);
82 >    return 1./TMath::Power(lVal,0.25);
83 >  }
84 >
85 >  Double_t lVal = TMath::Max(iVal1,1.);
86 >  return 1./TMath::Power(lVal,0.25);
87 > }
88 >
89 > //--------------------------------------------------------------------------------------------------
90 > inline Bool_t mithep::MuonTools::Overflow(const TH2D *iHist, Double_t lVal0, Double_t lVal1) const
91 > {
92 >  // Check if values are in overflow bins of given histogram.
93 >
94 >  if(iHist == 0)
95 >    return kTRUE;
96 >
97 >  if (iHist ->GetXaxis()->FindBin(lVal0) == 0                  ||
98 >      iHist ->GetXaxis()->FindBin(lVal0) >  iHist->GetNbinsX() ||
99 >      iHist ->GetYaxis()->FindBin(lVal0) == 0                  ||
100 >      iHist ->GetYaxis()->FindBin(lVal0) >  iHist->GetNbinsY()) {
101 >    return kTRUE;
102 >  }
103 >  return kFALSE;
104 > }
105 > #endif
106 >
107 > #if 0
108      static inline MCParticle* etaPhiMatch(MCParticleCol* iMCParts,Muon *iMuon) {
109 <      mithep::MCParticle *lMC = 0; double lDR = 1.; double lPt = -1.;
110 <      for(unsigned int i0 = 0; i0 < iMCParts->GetEntries(); i0++) {
109 >      mithep::MCParticle *lMC = 0; Double_t lDR = 1.; Double_t lPt = -1.;
110 >      for(unsigned Int_t i0 = 0; i0 < iMCParts->GetEntries(); i0++) {
111          mithep::MCParticle* pMC = iMCParts->At(i0);
112          if(pMC->Status() != 1) continue;
113 <        double pDR = mithep::MathUtils::DeltaR(pMC->Mom(),iMuon->Mom());
113 >        Double_t pDR = mithep::MathUtils::DeltaR(pMC->Mom(),iMuon->Mom());
114          if(pDR > lDR && pDR > 0.01) continue;
115          if(fabs(pMC->Pt()) < lPt)   continue;
116          lDR = pDR;
# Line 87 | Line 120 | namespace mithep {
120        return lMC;
121      }
122      static inline Muon* match(MuonCol* iMuons,Track *iTrack) {
123 <      mithep::Muon *lMuon = 0; double lDR = 1.; double lPt = -1.;
124 <      for(unsigned int i0 = 0; i0 < iMuons->GetEntries(); i0++) {
123 >      mithep::Muon *lMuon = 0; Double_t lDR = 1.; Double_t lPt = -1.;
124 >      for(unsigned Int_t i0 = 0; i0 < iMuons->GetEntries(); i0++) {
125          mithep::Muon* pMuon = iMuons->At(i0);
126 <        double pDR = mithep::MathUtils::DeltaR(pMuon->Mom(),iTrack->Mom4(0.109));
126 >        Double_t pDR = mithep::MathUtils::DeltaR(pMuon->Mom(),iTrack->Mom4(0.109));
127          if(pDR > lDR && pDR > 0.01) continue;
128          if(fabs(pMuon->Pt()) < lPt)   continue;
129          lDR   = pDR;
# Line 99 | Line 132 | namespace mithep {
132        }
133        return lMuon;
134      }
135 <    static inline int NSegments(mithep::Muon *iMuon) {
103 <      int lNSegs = 0;
104 <      for(int i0 = 0; i0 < 8; i0++) {
105 <        if(iMuon->StationBit(i0)) lNSegs++;
106 <      }
107 <      return lNSegs;
108 <    }
109 <    static inline bool promptTight(int iId,Muon *iMuon) {
110 <      const mithep::Track *lTrack = 0;
111 <      if(iId == 0                              ) lTrack = iMuon->GlobalTrk();
112 <      if(iId == 1 || (iId == -1 && lTrack == 0)) lTrack = iMuon->TrackerTrk();
113 <      if(iId == 2 || (iId == -1 && lTrack == 0)) lTrack = iMuon->StandaloneTrk();
114 <      if(lTrack == 0) return 0;
115 <      if(lTrack->NHits() < 11)                                        return false;
116 <      if(lTrack->Chi2()/lTrack->Ndof() > 10.)                         return false;
117 <      if(lTrack->D0() > 0.2)                                          return false;
118 <      if((lastHit(iMuon)% 4) == 0)                                    return false;
119 <      return true;
120 <    }
121 <    static inline bool TMLastStation(Muon *iMuon,double iDYMin = 3., double iPYMin = 3.,double iDXMin = 3., double iPXMin = 3.,int iN = 2) {
122 <      if(iMuon->NSegments()       < iN)               return false; //2Last 1One
123 <      int lLast = lastStation(iMuon,-3.,-3.);                       //Last Required Station
124 <      if(lLast < 0)                                   return false;
125 <      if(iMuon->GetDX(lLast)  > 9999.)                return false;
126 <      lLast = lastStation(iMuon);                                   //No Requirements Imply StationMask (Segment and Track Arbitrated)
127 <      if(lLast < 0)                                   return false;
128 <      if(!(fabs(iMuon->GetDX(lLast))      < iDXMin  ||
129 <           fabs(iMuon->GetPullX(lLast))   < iPXMin))  return false;
130 <      if(lLast == 3) lLast = lastStation(iMuon,3);
131 <      if(lLast < 0)                                   return false;
132 <      if(!(fabs(iMuon->GetDY(lLast))      < iDYMin ||               //Old Code it was 9999
133 <           fabs(iMuon->GetPullY(lLast))   < iPYMin))  return false;
134 <      return true;
135 <    }
136 <    static inline bool TMOneStation(Muon *iMuon,double iDYMin = 3., double iPYMin = 3.,double iDXMin = 3., double iPXMin = 3.,int iN = 1) {
137 <      if(iMuon->NSegments()       < iN)               return false; //2Last 1One
138 <      bool pGoodX  = false; bool pBadY = false;
139 <      for(int i0 = 0; i0 < 8; i0++) {
140 <        if((fabs(iMuon->GetDX(i0))      < iDXMin  ||
141 <            fabs(iMuon->GetPullX(i0))   < iPXMin)) pGoodX = true;
142 <        if(pGoodX                                 &&
143 <           (fabs(iMuon->GetDY(i0))      < iDYMin  ||
144 <            fabs(iMuon->GetPullY(i0))   < iPYMin))  return true;
145 <        if(fabs(iMuon->GetDY(i0)) < 999999) pBadY = true;
146 <        if(i0 == 3 && pGoodX && !pBadY)             return true;
147 <      }
148 <      return false;
149 <    }
150 <    static inline double getCaloCompatabilitySlowly(mithep::Muon* iMuon,bool iEMSpecial, bool iCorrectedHCAL) {
151 <      std::cout << "Warning Loading Compatability Slowly" << std::endl;
152 <      TFile* lPion_templates = new TFile("MitCommon/MuonTools/data/PionCaloTemplate.root","READ");
153 <      TFile* lMuon_templates = new TFile("MitCommon/MuonTools/data/MuonCaloTemplate.root","READ");
154 <      TH2D* lpion_em_etaEmi  = (TH2D*) lPion_templates->Get("em_etaEmi");
155 <      TH2D* lpion_had_etaEmi = (TH2D*) lPion_templates->Get("had_etaEmi");
156 <      TH2D* lpion_had_etaTmi = (TH2D*) lPion_templates->Get("had_etaTmi");
157 <      TH2D* lpion_em_etaB    = (TH2D*) lPion_templates->Get("em_etaB")   ;
158 <      TH2D* lpion_had_etaB   = (TH2D*) lPion_templates->Get("had_etaB")  ;
159 <      TH2D* lpion_ho_etaB    = (TH2D*) lPion_templates->Get("ho_etaB")   ;
160 <      TH2D* lpion_had_etaTpl = (TH2D*) lPion_templates->Get("had_etaTpl");
161 <      TH2D* lpion_em_etaEpl  = (TH2D*) lPion_templates->Get("em_etaEpl") ;
162 <      TH2D* lpion_had_etaEpl = (TH2D*) lPion_templates->Get("had_etaEpl");
163 <      TH2D* lmuon_em_etaEmi  = (TH2D*) lMuon_templates->Get("em_etaEmi") ;
164 <      TH2D* lmuon_had_etaEmi = (TH2D*) lMuon_templates->Get("had_etaEmi");
165 <      TH2D* lmuon_had_etaTmi = (TH2D*) lMuon_templates->Get("had_etaTmi");
166 <      TH2D* lmuon_em_etaB    = (TH2D*) lMuon_templates->Get("em_etaB")   ;
167 <      TH2D* lmuon_had_etaB   = (TH2D*) lMuon_templates->Get("had_etaB")  ;
168 <      TH2D* lmuon_ho_etaB    = (TH2D*) lMuon_templates->Get("ho_etaB")   ;
169 <      TH2D* lmuon_had_etaTpl = (TH2D*) lMuon_templates->Get("had_etaTpl");
170 <      TH2D* lmuon_em_etaEpl  = (TH2D*) lMuon_templates->Get("em_etaEpl");
171 <      TH2D* lmuon_had_etaEpl = (TH2D*) lMuon_templates->Get("had_etaEpl");
172 <
173 <      double lEta = -1.; double lP = -1;
174 <      double lEM  = -5.;      double lHad = 0;      double lHO = 0;
175 <      lEta = iMuon->Eta();
176 <      lP   = iMuon->P();
177 <      if(lP >= 2000.) lP = 1999.9;
178 <      if(!iEMSpecial || iMuon->EmEnergy() != 0.) lEM  = iMuon->EmEnergy();
179 <      lHad = iMuon->HadEnergy();
180 <      lHO  = iMuon->HoEnergy();
181 <      if(lP < 0. )           return 0.5;
182 <      if(fabs(lEta) >  2.5 ) return 0.5;
183 <      TH2D* lTMuonHad = NULL;
184 <      TH2D* lTPionHad = NULL;
185 <      TH2D* lTMuonHo  = NULL;
186 <      TH2D* lTPionHo  = NULL;
187 <      TH2D* lTMuonEm  = NULL;
188 <      TH2D* lTPionEm  = NULL;
189 <
190 <      if(fabs(lEta) >=  1.27) {
191 <        if(iCorrectedHCAL) lHad *= 1.8/2.2;
192 <        if(lEta > 0) {
193 <          lTPionHad = lpion_had_etaEpl;
194 <          lTMuonHad = lmuon_had_etaEpl;
195 <        } else {
196 <          lTPionHad = lpion_had_etaEmi;
197 <          lTMuonHad = lmuon_had_etaEmi;
198 <        }
199 <      }
200 <      if(fabs(lEta) <  1.27  && fabs(lEta) >=  1.1 ) {
201 <        if(iCorrectedHCAL)    lHad *= (1.8/(-2.2*fabs(lEta)+5.5));
202 <        if(lEta > 0) {
203 <          lTPionHad  = lpion_had_etaTpl;
204 <          lTMuonHad  = lmuon_had_etaTpl;
205 <        } else {
206 <          lTPionHad  = lpion_had_etaTmi;
207 <          lTMuonHad  = lmuon_had_etaTmi;
208 <        }
209 <      }
210 <      if(fabs(lEta) <  1.1) {
211 <        if(iCorrectedHCAL)    lHad *= sin(2*atan(exp(iMuon->Eta())));
212 <        lTPionHad  = lpion_had_etaB;
213 <        lTMuonHad  = lmuon_had_etaB;
214 <      }
215 <      if(lEta >  1.479  ) {
216 <        lTPionEm  = lpion_em_etaEpl;
217 <        lTMuonEm  = lmuon_em_etaEpl;
218 <      }
219 <      if(fabs(lEta) <=  1.479) {
220 <        lTPionEm  = lpion_em_etaB;
221 <        lTMuonEm  = lmuon_em_etaB;
222 <      }
223 <      if(lEta < -1.479 ) {
224 <        lTPionEm  = lpion_em_etaEmi;
225 <        lTMuonEm  = lmuon_em_etaEmi;
226 <      }
227 <      if(fabs(lEta) < 1.28) {
228 <        lTPionHo  = lpion_ho_etaB;
229 <        lTMuonHo  = lmuon_ho_etaB;
230 <      }
135 > #endif
136  
232      double lPBX = 1.;     double lPSX = 1.;
233      double lPBY = 1.;     double lPSY = 1.;
234      double lPBZ = 1.;     double lPSZ = 1.;
235      if(!overflow(lTPionEm, lP,lEM))  lPBX =  lTPionEm ->GetBinContent(lTPionEm ->GetXaxis()->FindBin(lP),lTPionEm ->GetYaxis()->FindBin(lEM) );
236      if(!overflow(lTPionHad,lP,lHad)) lPBY =  lTPionHad->GetBinContent(lTPionHad->GetXaxis()->FindBin(lP),lTPionHad->GetYaxis()->FindBin(lHad));
237      if(!overflow(lTPionHo, lP,lHO))  lPBZ =  lTPionHo ->GetBinContent(lTPionHo ->GetXaxis()->FindBin(lP),lTPionHo ->GetYaxis()->FindBin(lHO) );
238      if(!overflow(lTMuonEm, lP,lEM )) lPSX =  lTMuonEm ->GetBinContent(lTMuonEm ->GetXaxis()->FindBin(lP),lTMuonEm ->GetYaxis()->FindBin(lEM) );
239      if(!overflow(lTMuonHad,lP,lHad)) lPSY =  lTMuonHad->GetBinContent(lTMuonHad->GetXaxis()->FindBin(lP),lTMuonHad->GetYaxis()->FindBin(lHad));
240      if(!overflow(lTMuonHo ,lP,lHO))  lPSZ =  lTMuonHo ->GetBinContent(lTMuonHo ->GetXaxis()->FindBin(lP),lTMuonHo ->GetYaxis()->FindBin(lHO) );
241
242      if(lPSX == 0. || lPBX == 0. || (lEM <= 0. && !iEMSpecial)) {lPSX = 1.; lPBX = 1.;}
243      if(lPSY == 0. || lPBY == 0. || lHad == 0.) {lPSY = 1.; lPBY = 1.;}
244      if(lPSZ == 0. || lPBZ == 0. || lHO  == 0.) {lPSZ = 1.; lPBZ = 1.;}
245      lPion_templates->Close();
246      lMuon_templates->Close();
247      if((lPSX*lPSY*lPSZ+lPBX*lPBY*lPBZ) > 0.) return lPSX*lPSY*lPSZ/(lPSX*lPSY*lPSZ+lPBX*lPBY*lPBZ);
248      return 0.5;
249    }
250    static inline float getSegmentCompatability(const mithep::Muon* iMuon) {
251      int lNStationsCrossed = 0;
252      int lNStationsSegment = 0;
253      
254      std::vector<int>   lStTrack(8);
255      std::vector<int>   lStSegmentmatch(8);
256      std::vector<int>   lStCrossed(8);
257      std::vector<float> lStBoundary(8);
258      std::vector<float> lStWeight(8);
259      float lWeight    = 0.;
260      bool  lAdjust    = true;
261      for(int i0 = 0; i0 < 8; i0++) {
262        if(iMuon->GetTrackDist(i0) < 999999. ) {
263          lNStationsCrossed++;
264          lStCrossed[i0]  = 1;
265          lStBoundary[i0] = 0.;
266          if(iMuon->GetTrackDist(i0) > -10. ) lStBoundary[i0] = iMuon->GetTrackDist(i0);
267        }
268        if(iMuon->GetDX(i0) < 999999.) { //Use iMuon->GetSegmentX--> CHECK
269          lNStationsSegment++;
270          lStSegmentmatch[i0] = 1;
271        }
272        if(iMuon->GetDY(i0) < 999999.) lAdjust = false;
273      }
274      int lPCross = -1;
275      const float lAtWeight = 0.5;
276      for(int i0 = 0; i0< 8; i0++)     {
277        lStWeight[i0] = 0;
278        if(lStCrossed[i0] > 0 )        { lPCross++;
279        switch ( lNStationsCrossed ) {
280        case 1 :
281          lStWeight[i0] =  1.;
282          break;
283        case 2 :
284          if     ( lPCross  == 0 ) lStWeight[i0] =  0.33;
285          else   lStWeight[i0] =  0.67;
286          break;
287        case 3 :
288          if     ( lPCross == 0 ) lStWeight[i0] =  0.23;
289          else if( lPCross == 1 ) lStWeight[i0] =  0.33;
290          else                    lStWeight[i0] =  0.44;
291          break;
292        case 4 :
293          if     ( lPCross == 0 ) lStWeight[i0] =  0.10;
294          else if( lPCross == 1 ) lStWeight[i0] =  0.20;
295          else if( lPCross == 2 ) lStWeight[i0] =  0.30;
296          else                    lStWeight[i0] =  0.40;
297          break;
298          
299        default :
300          lStWeight[i0] = 1./lNStationsCrossed;
301        }
302        
303        if(lStSegmentmatch[i0] <= 0 && lStBoundary[i0] != 0. ) {
304          lStWeight[i0] *= lAtWeight*0.5*(TMath::Erf(lStBoundary[i0]/6.)+1.);
305        } else if(lStSegmentmatch[i0] <= 0 && lStBoundary[i0] == 0) {lStWeight[i0] = 0.;}
306        
307        if( lStSegmentmatch[i0] > 0) {
308          double lP2X = TMath::Power(iMuon->GetPullX(i0),2.);
309          double lP2Y = TMath::Power(iMuon->GetPullY(i0),2.);
310          double lD2X = TMath::Power(iMuon->GetDX(i0),2.);
311          double lD2Y = TMath::Power(iMuon->GetDY(i0),2.);
312          if( iMuon->GetDY(i0) < 999999 && iMuon->GetDX(i0) < 999999) {
313            lStWeight[i0] *= sigWeight(sqrt(lD2X+lD2Y),sqrt(lP2X+lP2Y));
314          } else if (iMuon->GetDY(i0) >= 999999 && i0 < 4) {
315            lStWeight[i0] *= sigWeight(iMuon->GetDX(i0),iMuon->GetPullX(i0));
316          } else if(i0 < 4) {
317            lStWeight[i0] *= sigWeight(iMuon->GetDY(i0),iMuon->GetPullY(i0));
318          }
319        }
320        }
321        lWeight += lStWeight[i0];
322      }
323      if(lNStationsCrossed == 0) lWeight = 0.5;
324      return lWeight;
325    }
326    static inline bool isGoodMuon(mithep::Muon *iMuon,selection iSelection) {
327      double lVal = 0;
328      switch(iSelection) {
329      case AllArbitrated:
330        if(iMuon->StandaloneTrk() != 0 || iMuon->GlobalTrk()!= 0)  return true;
331        if(iMuon->NSegments() > 0) return true;
332        return false;
333        break;
334      case PromptTight:
335        return promptTight(-1,iMuon);
336        break;
337      case TMOneStationLoose:
338        return TMOneStation(iMuon,99999,999999);
339      case TMOneStationTight:
340        return TMOneStation(iMuon);
341      case TMLastStationLoose:
342        return TMLastStation(iMuon,999999,999999);
343        break;
344      case TMLastStationTight:
345        return TMLastStation(iMuon);
346        break;
347      case TM2DCompatibilityLoose:
348        lVal             = 1.2*getSegmentCompatability(iMuon);
349        if(lVal/1.2 == 0.5) return false;
350        //if(fClass ) lVal += 0.8*getCaloCompatability(iMuon,true,true);
351        lVal += 0.8*getCaloCompatabilitySlowly(iMuon,true,true);
352        if(lVal > 0.7) return true;
353        return false;
354        break;
355      case TM2DCompatibilityTight:
356        lVal             = 1.2*getSegmentCompatability(iMuon);
357        if(lVal/1.2 == 0.5) return false;
358        //if(fClass ) lVal += 0.8*getCaloCompatability(iMuon,true,true);
359        lVal += 0.8*getCaloCompatabilitySlowly(iMuon,true,true);
360        if(lVal > 1.0) return true;
361        return false;
362        break;
363      default:
364        return false;
365      }
366      return false;
367    }
368    bool isGood(mithep::Muon *iMuon,selection iSelection);
369  private:
370    TFile *fMuon_templates;
371    TFile *fPion_templates;
372    TH2D* fpion_em_etaEmi;
373    TH2D* fpion_had_etaEmi;
374    TH2D* fpion_had_etaTmi;
375    TH2D* fpion_em_etaB;
376    TH2D* fpion_had_etaB;
377    TH2D* fpion_ho_etaB;
378    TH2D* fpion_had_etaTpl;
379    TH2D* fpion_em_etaEpl;
380    TH2D* fpion_had_etaEpl;
381    TH2D* fmuon_em_etaEmi;
382    TH2D* fmuon_had_etaEmi;
383    TH2D* fmuon_had_etaTmi;
384    TH2D* fmuon_em_etaB;
385    TH2D* fmuon_had_etaB;
386    TH2D* fmuon_ho_etaB;
387    TH2D* fmuon_had_etaTpl;
388    TH2D* fmuon_em_etaEpl;
389    TH2D* fmuon_had_etaEpl;
390  };
391 }
137  
393 #endif

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines