#include <FastSimulation/Muons/interface/FML1PtSmearer.h>
Public Member Functions | |
FML1PtSmearer (const RandomEngine *engine) | |
Constructor (read in the parametrizations from a data file). | |
bool | smear (SimpleL1MuGMTCand *) |
smear the transverse momentum of a SimplL1MuGMTCand | |
~FML1PtSmearer () | |
Destructor. | |
Private Member Functions | |
float | ChargeMisIdent (int ieta, double pt) |
int | IndexOfPtgen (float pt) |
Private Attributes | |
const RandomEngine * | random |
float | resolution [DIMRES] |
Static Private Attributes | |
static const int | DIMRES = 3*NPT*NPTL1 |
static const int | NPT = 136 |
static const int | NPTL1 = 31 |
The output momentum is generated according to the probablility that a MC muon with the same pt leads to that (discrete) momentum value in the GMT.
Definition at line 16 of file FML1PtSmearer.h.
FML1PtSmearer::FML1PtSmearer | ( | const RandomEngine * | engine | ) |
Constructor (read in the parametrizations from a data file).
Definition at line 16 of file FML1PtSmearer.cc.
References GenMuonPlsPt100GeV_cfg::cout, lat::endl(), f1, mergeAndRegister_online::fname, i, j, FileInPath::name(), NPT, NPTL1, funct::num(), path(), resolution, and sum().
00017 : random(engine) { 00018 00019 string fname = "FastSimulation/Muons/data/resolutionL1.data"; 00020 // std::string path(std::getenv("CMSSW_SEARCH__PATH")); 00021 std::string path(getenv("CMSSW_SEARCH_PATH")); 00022 FileInPath f1(path,fname); 00023 if ( f1() == 0) { 00024 std::cout << "File " << fname << " not found in " << path << std::endl; 00025 throw Genexception(" resolution list not found for FastMuonLvl1Trigger."); 00026 } else { 00027 cout << "Reading " << f1.name() << std::endl; 00028 } 00029 std::ifstream & listfile = *f1(); 00030 00031 int ind; 00032 float num=0.; 00033 for (int ieta=0; ieta<3; ieta++) { 00034 for (int i=0; i<NPT; i++) { 00035 float sum = 0.; 00036 ind = i*NPTL1 + ieta*(NPT*NPTL1); 00037 for (int j=0; j<NPTL1; j++) { 00038 listfile >> num; 00039 sum += num; 00040 resolution[ind]=sum; 00041 ind++; 00042 } 00043 ind = i*NPTL1 + ieta*(NPT*NPTL1); 00044 for (int j=0; j<NPTL1 ; j++){ 00045 resolution[ind] /= sum; 00046 ind++; 00047 } 00048 } 00049 } 00050 00051 }
FML1PtSmearer::~FML1PtSmearer | ( | ) |
float FML1PtSmearer::ChargeMisIdent | ( | int | ieta, | |
double | pt | |||
) | [inline, private] |
Definition at line 40 of file FML1PtSmearer.h.
Referenced by smear().
00040 { 00041 float df=0.; 00042 switch (ieta) { 00043 case 0: 00044 df = 2.16909e-03 + 1.95708e-04*pt ; 00045 break; 00046 case 1: 00047 if (pt>500.) pt = 500.; 00048 df = 1.00445e-02 + 1.15253e-03*pt - 7.73819e-07*pt*pt ; 00049 break; 00050 case 2: 00051 if (pt>200.) pt = 200.; 00052 df = 5.00580e-02 + 5.88949e-03*pt - 2.98100e-05*pt*pt + 5.02454e-08*pt*pt*pt ; 00053 break; 00054 } 00055 return (df<0.5? df: 0.5) ; 00056 }
int FML1PtSmearer::IndexOfPtgen | ( | float | pt | ) | [private] |
Definition at line 99 of file FML1PtSmearer.cc.
Referenced by smear().
00099 { 00100 00101 static float vecpt[NPT] = { 00102 1., 2., 3., 4., 5., 6., 7., 8., 9., 00103 10., 11., 12., 13., 14., 15., 16., 17., 18., 19., 00104 20., 21., 22., 23., 24., 25., 26., 27., 28., 29., 00105 30., 31., 32., 33., 34., 35., 36., 37., 38., 39., 00106 40., 41., 42., 43., 44., 45., 46., 47., 48., 49., 00107 50., 51., 52., 53., 54., 55., 56., 57., 58., 59., 00108 60., 61., 62., 63., 64., 65., 66., 67., 68., 69., 00109 70., 71., 72., 73., 74., 75., 76., 77., 78., 79., 00110 80., 81., 82., 83., 84., 85., 86., 87., 88., 89., 00111 90., 91., 92., 93., 94., 95., 96., 97., 98., 99., 00112 100., 110., 120., 130., 140., 150., 160., 170., 180., 190., 00113 200., 210., 220., 230., 240., 250., 260., 270., 280., 290., 00114 300., 310., 320., 330., 340., 350., 360., 370., 380., 390., 00115 400., 500., 600., 700., 800., 900., 1000. }; 00116 00117 for (int i=0; i<NPT; i++) { 00118 if (pt<vecpt[i]) return i; 00119 } 00120 return NPT; 00121 }
bool FML1PtSmearer::smear | ( | SimpleL1MuGMTCand * | aMuon | ) |
smear the transverse momentum of a SimplL1MuGMTCand
Definition at line 57 of file FML1PtSmearer.cc.
References SimpleL1MuGMTCand::charge(), ChargeMisIdent(), counter(), RandomEngine::flatShoot(), SimpleL1MuGMTCand::getMomentum(), IndexOfPtgen(), NPT, NPTL1, SimpleL1MuGMTCand::ptScale, random, resolution, SimpleL1MuGMTCand::setCharge(), L1MuGMTCand::setPtPacked(), L1MuGMTCand::setPtValue(), and SimpleL1MuGMTCand::smearedPt().
Referenced by ParamL3MuonProducer::produce(), and FastL1MuonProducer::produce().
00057 { 00058 // get and smear the pt 00059 double Pt=aMuon->smearedPt(); 00060 double AbsEta=fabs(aMuon->getMomentum().eta()); 00061 00062 bool StatusCode=true; 00063 00064 if (AbsEta>2.40 || Pt<3) { StatusCode=false;} 00065 00066 if (StatusCode){ 00067 00068 int ieta = 0; 00069 if (AbsEta<1.04) ieta = 0 ; 00070 else if (AbsEta<2.07) ieta = 1 ; 00071 else if (AbsEta<2.40) ieta = 2 ; 00072 00073 int counter = 0; 00074 int ipt = IndexOfPtgen(Pt); 00075 int ind = counter + ipt*NPTL1 + ieta*(NPT*NPTL1); 00076 double prob = random->flatShoot(); 00077 while ( (prob > resolution[ind]) && counter<NPTL1 ){ 00078 counter++; 00079 ind++; 00080 } 00081 counter++; 00082 aMuon->setPtPacked(counter & 31); 00083 aMuon->setPtValue(SimpleL1MuGMTCand::ptScale[counter]); 00084 00085 prob = random->flatShoot(); 00086 if (prob <= ChargeMisIdent(ieta,Pt)) { 00087 int OldCharge = aMuon->charge(); 00088 int NewCharge = -OldCharge; 00089 aMuon->setCharge(NewCharge); 00090 } 00091 00092 } 00093 00094 return StatusCode; 00095 00096 }
const int FML1PtSmearer::DIMRES = 3*NPT*NPTL1 [static, private] |
Definition at line 37 of file FML1PtSmearer.h.
const int FML1PtSmearer::NPT = 136 [static, private] |
Definition at line 36 of file FML1PtSmearer.h.
Referenced by FML1PtSmearer(), IndexOfPtgen(), and smear().
const int FML1PtSmearer::NPTL1 = 31 [static, private] |
const RandomEngine* FML1PtSmearer::random [private] |
float FML1PtSmearer::resolution[DIMRES] [private] |