CMS 3D CMS Logo

Functions
PtAssignment_FullPrecision.h File Reference
#include "EmulatorClasses.h"
#include "L1TMuonEndCapTrackProducer.h"
#include "Forest.h"
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

Go to the source code of this file.

Functions

float CalculatePt_FullPrecision (L1TMuon::InternalTrack track)
 

Function Documentation

float CalculatePt_FullPrecision ( L1TMuon::InternalTrack  track)

Mode Variables ////

Definition at line 13 of file PtAssignment_FullPrecision.h.

References gather_cfg::cout, dir, PVValHelper::eta, EnergyCorrector::etas, f, L1TMuon::InternalTrack::getStubs(), mps_fire::i, cmsBatch::log, ALCARECOPromptCalibProdSiPixelAli0T_cff::mode, L1TMuon::InternalTrack::phis, L1TForest::predictEvents(), alignCSCRings::s, findQualityFiles::size, funct::tan(), L1TMuon::InternalTrack::theta, TagProbeFitTreeAnalyzer_cfi::Variables, x(), and detailsBasic3DVector::y.

13  {
14 
15  bool verbose = false;
16 
17  int dphi[6] = {-999,-999,-999,-999,-999,-999}, deta[6] = {-999,-999,-999,-999,-999,-999};
18  int clct[4] = {-999,-999,-999,-999}, cscid[4] = {-999,-999,-999,-999};
19  int phis[4] = {-999,-999,-999,-999}, etas[4] = {-999,-999,-999,-999}, mode = 0;;
20 
21  float theta_angle = ((track.theta)*0.2874016 + 8.5)*(3.14159265359/180);
22  float eta = (-1)*log(tan(theta_angle/2));
23 
24  const TriggerPrimitiveStationMap stubs = track.getStubs();
25 
26  if(verbose) std::cout<<"Track eta = "<<eta<<" and has hits in stations ";//
27 
28  int x=0;
29  for(unsigned int s=8;s<12;s++){
30  if((stubs.find(s)->second).size() == 1){
31 
32  if(verbose) std::cout<<(stubs.find(s)->second)[0]->detId<CSCDetId>().station()<<" ";
33 
34  etas[s-8] = (fabs((stubs.find(s)->second)[0]->getCMSGlobalEta()) + 0.9)/(0.0125);
35  phis[s-8] = track.phis[x];//(stubs.find(s)->second)[0]->getCMSGlobalPhi();//
36  clct[s-8] = (stubs.find(s)->second)[0]->getPattern();
37  cscid[s-8] = (stubs.find(s)->second)[0]->Id();
38 
39  switch(s-7){
40  case 1: mode |= 1;break;
41  case 2: mode |= 2;break;
42  case 3: mode |= 4;break;
43  case 4: mode |= 8;break;
44  default: mode |= 0;
45  }
46  x++;
47  }
48  }
49 
50  if(verbose) std::cout<<"\nMode = "<<mode<<std::endl;
51 
55 
56  if(phis[0] > 0 && phis[1] > 0){
57  dphi[0] = phis[1] - phis[0];
58  deta[0] = etas[1] - etas[0];
59  }
60  if(phis[0] > 0 && phis[2] > 0){
61  dphi[1] = phis[2] - phis[0];
62  deta[1] = etas[2] - etas[0];
63  }
64  if(phis[0] > 0 && phis[3] > 0){
65  dphi[2] = phis[3] - phis[0];
66  deta[2] = etas[3] - etas[0];
67  }
68  if(phis[1] > 0 && phis[2] > 0){
69  dphi[3] = phis[2] - phis[1];
70  deta[3] = etas[2] - etas[1];
71  }
72  if(phis[1] > 0 && phis[3] > 0){
73  dphi[4] = phis[3] - phis[1];
74  deta[4] = etas[3] - etas[1];
75  }
76  if(phis[2] > 0 && phis[3] > 0){
77  dphi[5] = phis[3] - phis[2];
78  deta[5] = etas[3] - etas[2];
79  }
80 
81 
82  if(verbose){
83  for(int f=0;f<4;f++){
84  std::cout<<"\nphis["<<f<<"] = "<<phis[f]<<" and etas = "<<etas[f]<<std::endl;
85  std::cout<<"\nclct["<<f<<"] = "<<clct[f]<<" and cscid = "<<cscid[f]<<std::endl;
86  }
87 
88  for(int u=0;u<6;u++)
89  std::cout<<"\ndphi["<<u<<"] = "<<dphi[u]<<" and deta = "<<deta[u]<<std::endl;
90  }
91 
92  float MpT = -1;//final pT to return
93 
94 
98 
99  int size[13] = {4,0,4,4,5,0,4,4,5,4,5,5,6};
100  int Variables[20] = {dphi[0], dphi[1], dphi[2], dphi[3], dphi[4], dphi[5], deta[0], deta[1], deta[2], deta[3], deta[4], deta[5],
101  clct[0], clct[1], clct[2], clct[3], cscid[0], cscid[1], cscid[2], cscid[3]};
102 
103 
107 
108  //ModeVariables is a 2D arrary indexed by [TrackMode(13 Total Listed Below)][VariableNumber(20 Total Constructed Above)]
109 
110  //3:TrackEta:dPhi12:dEta12:CLCT1:cscid1
111  //4:Single Station Track Not Possible
112  //5:TrackEta:dPhi13:dEta13:CLCT1:cscid1
113  //6:TrackEta:dPhi23:dEta23:CLCT2:cscid2
114  //7:TrackEta:dPhi12:dPhi23:dEta13:CLCT1:cscid1
115  //8:Single Station Track Not Possible
116  //9:TrackEta:dPhi14:dEta14:CLCT1:cscid1
117  //10:TrackEta:dPhi24:dEta24:CLCT2:cscid2
118  //11:TrackEta:dPhi12:dPhi24:dEta14:CLCT1:cscid1
119  //12:TrackEta:dPhi34:dEta34:CLCT3:cscid3
120  //13:TrackEta:dPhi13:dPhi34:dEta14:CLCT1:cscid1
121  //14:TrackEta:dPhi23:dPhi34:dEta24:CLCT2:cscid2
122  //15:TrackEta:dPhi12:dPhi23:dPhi34:dEta14:CLCT1:cscid1
123 
124  int ModeVariables[13][6] = {{0,6,12,16,-999,-999},{-999,-999,-999,-999,-999,-999},{1,7,12,16,-999,-999},{3,9,13,17,-999,-999},{0,3,7,12,16,-999},
125  {-999,-999,-999,-999,-999,-999},{2,8,12,16,-999,-999},{4,10,13,17,-999,-999},{0,4,8,12,16,-999},{5,11,14,18,-999,-999},
126  {1,5,8,12,16,-999},{3,5,10,13,17,-999},{0,3,5,8,12,16}};
127 
128 
132  //float gpt = -1;
133  for(int i=3;i<16;i++){
134 
135  if(i != mode)
136  continue;
137 
138  if(verbose) std::cout<<"\nMode = "<<mode<<"\n\n";
139 
140  L1TForest *forest = new L1TForest();
141  const char *dir = "L1Trigger/L1TMuon/data/emtf_luts/ModeVariables/trees";
142  std::stringstream ss;
143  ss << dir << "/" << mode;//
144 
145  forest-> loadL1TForestFromXML(ss.str().c_str(),64);
146 
147  std::vector<Double_t> Data;
148  Data.push_back(1.0);
149  Data.push_back(eta);
150  for(int y=0;y<size[mode-3];y++){
151 
152  Data.push_back(Variables[ModeVariables[mode-3][y]]);
153  if(verbose) std::cout<<"Generalized Variables "<<y<<" "<<Variables[ModeVariables[mode-3][y]]<<"\n";
154  }
155 
156  if(verbose){
157  std::cout<<"Data.size() = "<<Data.size()<<"\n";
158  for(int i=0;i<5;i++)
159  std::cout<<"Data["<<i<<"] = "<<Data[i]<<"\n";
160  }
161 
162  Event *event = new Event();
163  event->data = Data;
164 
165  std::vector<Event*> vevent;
166  vevent.push_back(event);
167 
168  forest->predictEvents(vevent,64);
169 
170  float OpT = vevent[0]->predictedValue;
171  MpT = 1/OpT;
172  }
173 
174  return MpT;
175 }
size
Write out results.
void predictEvents(std::vector< emtf::Event * > &eventsp, unsigned int trees)
Definition: Forest.cc:413
const TriggerPrimitiveStationMap & getStubs() const
T x() const
Cartesian x coordinate.
Tan< T >::type tan(const T &t)
Definition: Tan.h:22
double f[11][100]
std::vector< int > phis
dbl *** dir
Definition: mlp_gen.cc:35
std::map< unsigned, TriggerPrimitiveCollection > TriggerPrimitiveStationMap
Definition: event.py:1