test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Functions
Deltas.h File Reference
#include "L1Trigger/L1TMuonEndCap/interface/EmulatorClasses.h"

Go to the source code of this file.

Functions

std::vector< std::vector
< DeltaOutput > > 
CalcDeltas (MatchingOutput Mout)
 
DeltaOutArr3 CalcDeltas_Hold (const std::vector< MatchingOutput > &Mout)
 
DeltaOutput Deltas (MatchingOutput Mout, int zone, int winner)
 

Function Documentation

std::vector<std::vector<DeltaOutput> > CalcDeltas ( MatchingOutput  Mout)

Definition at line 209 of file Deltas.h.

References Deltas(), connectstrParser::o, GenerateHcalLaserBadRunList::out, convertSQLitetoXML_cfg::output, and DeltaOutput::SetNull().

209  {
210 
211  DeltaOutput output;output.SetNull();
212 
213  std::vector<DeltaOutput> o (3,output);
214  std::vector<std::vector<DeltaOutput>> out (4,o);
215 
216  for(int zone=0;zone<4;zone++){
217  for(int winner=0;winner<3;winner++){
218  out[zone][winner] = Deltas(Mout, zone, winner);
219  }
220  }
221 
222  return out;
223 }
DeltaOutput Deltas(MatchingOutput Mout, int zone, int winner)
Definition: Deltas.h:14
DeltaOutArr3 CalcDeltas_Hold ( const std::vector< MatchingOutput > &  Mout)

Definition at line 225 of file Deltas.h.

References Deltas(), convertSQLitetoXML_cfg::output, Output, DeltaOutput::SetNull(), and DeltaOutArr3::x.

Referenced by L1TMuonEndCapTrackProducer::produce().

225  {
226 
228  output.SetNull();
229  DeltaOutArr3 Output = { {{{output}}} };
230 
231  for(int bx=0;bx<3;bx++){
232  for(int zone=0;zone<4;zone++){
233  for(int winner=0;winner<3;winner++){
234  Output.x[bx][zone][winner] = Deltas(Mout[bx], zone, winner);
235  }
236  }
237  }
238 
239  return Output;
240 
241 }
DeltaOutput Deltas(MatchingOutput Mout, int zone, int winner)
Definition: Deltas.h:14
DeltaOutput x[3][4][3]
#define Output(cl)
Definition: vmac.h:192
DeltaOutput Deltas ( MatchingOutput  Mout,
int  zone,
int  winner 
)

Set Null dphi and dtheta arrays///

dphi index order runs like (dphi12,dphi13,dphi14,dphi23,dphi24,dphi34) hence the calc delta phis /// indexing procedure dphi[s2-1] for the first 3 and dphi[s1+s2] for the rest

There is a further index on dTh because there are 4 dth combinations calc delta theta /// possible if there are two theta segments for both stations.

the mask[6] is a way to indicate which stations are present and valid

it is clearer to see in binary below

stations 1 and 2 present and valid –> 0x3 –> 0011 stations 1 and 3 present and valid –> 0x5 –> 0101 stations 1 and 4 present and valid –> 0x9 –> 1001 stations 2 and 3 present and valid –> 0x6 –> 0110 stations 2 and 4 present and valid –> 0xa –> 1010 stations 3 and 4 present and valid –> 0xc –> 1100

here we separate stations 3 and 4////

Definition at line 14 of file Deltas.h.

References funct::abs(), ConvertedHit::AllThetas(), ztail::d, i, convertSQLitetoXML_cfg::output, AlCaHLTBitMon_ParallelJobs::p, ConvertedHit::Phi(), phi(), MatchingOutput::PhiMatch(), indexGen::s2, MatchingOutput::SetPhOut(), Winner::SetRank(), DeltaOutput::SetValues(), reco::t2, theta(), MatchingOutput::ThetaMatch(), MatchingOutput::Winners(), and PhOutput::x.

Referenced by CalcDeltas(), and CalcDeltas_Hold().

14  {
15 
16  //bool verbose = false;
17 
18  PhOutput phmatch = Mout.PhiMatch();
19  ThOutput thmatch = Mout.ThetaMatch();
20  // ThOutput2 t2 = Mout.TMatch2(); // Unused ... also we later declare an "unsigned int t2" - confusing! - AWB 29.08.16
21 
25  int dphi[6] = {-999,-999,-999,-999,-999,-999};
26  int dtmp2[6] = {-999,-999,-999,-999,-999,-999};
27  int dtmp2_ths[6][2] = {{-999,-999},{-999,-999},{-999,-999},{-999,-999},{-999,-999},{-999,-999}};
28 
29 
30  for(int s1=0;s1<3;s1++){
31 
32  for(int s2=s1+1;s2<4;s2++){
33 
37 
38  if((s1 == 0) && (phmatch.x[zone][winner][s1].Phi() != -999) && (phmatch.x[zone][winner][s2].Phi() != -999)){ //if using station one and both hits are valid
39 
40  dphi[s2-1] = phmatch.x[zone][winner][s1].Phi() - phmatch.x[zone][winner][s2].Phi();
41  }
42  else if((s1 != 0) && (phmatch.x[zone][winner][s1].Phi() != -999) && (phmatch.x[zone][winner][s2].Phi() != -999)){//if not using station one and both hits are valid
43 
44  dphi[s1+s2] = phmatch.x[zone][winner][s1].Phi() - phmatch.x[zone][winner][s2].Phi();
45  }
46 
47 
51 
52  for(unsigned int t1=0;t1<phmatch.x[zone][winner][s1].AllThetas().size();t1++){
53  for(unsigned int t2=0;t2<phmatch.x[zone][winner][s2].AllThetas().size();t2++){
54 
55  int dth_tmp = phmatch.x[zone][winner][s2].AllThetas()[t2] - phmatch.x[zone][winner][s1].AllThetas()[t1];
56 
57  if(s1 == 0){
58 
59  if(dtmp2[s2-1] == -999){
60  dtmp2[s2-1] = dth_tmp;
61  dtmp2_ths[s2-1][0] = phmatch.x[zone][winner][s1].AllThetas()[t1];
62  dtmp2_ths[s2-1][1] = phmatch.x[zone][winner][s2].AllThetas()[t2];
63  }
64  else if(abs(dth_tmp) < abs(dtmp2[s2-1])){
65  dtmp2[s2-1] = dth_tmp;
66  dtmp2_ths[s2-1][0] = phmatch.x[zone][winner][s1].AllThetas()[t1];
67  dtmp2_ths[s2-1][1] = phmatch.x[zone][winner][s2].AllThetas()[t2];
68  }
69 
70  }
71  else{
72 
73  if(dtmp2[s2+s1] == -999){
74  dtmp2[s2+s1] = dth_tmp;
75  dtmp2_ths[s1+s2][0] = phmatch.x[zone][winner][s1].AllThetas()[t1];
76  dtmp2_ths[s2+s1][1] = phmatch.x[zone][winner][s2].AllThetas()[t2];
77  }
78  else if(abs(dth_tmp) < abs(dtmp2[s2+s1])){
79  dtmp2[s2+s1] = dth_tmp;
80  dtmp2_ths[s1+s2][0] = phmatch.x[zone][winner][s1].AllThetas()[t1];
81  dtmp2_ths[s2+s1][1] = phmatch.x[zone][winner][s2].AllThetas()[t2];
82  }
83  }
84 
85  }
86  }
87 
88  }
89  }
90 
91  int vmask[3] = {0,0,0};
92  const unsigned int mask[6] = {0x3,0x5,0x9,0x6,0xa,0xc};
105  const unsigned int mindex[6] = {0,0,0,1,1,2};//vmasindex-->says that the first three entries of mask belong to vmask[0] etc...
106 
107  for(int p=0;p<6;p++){
108 
109  if((abs(dtmp2[p]) <= 4) && (dtmp2[p] != -999)){//if dtheta is small enought and valid
110  vmask[mindex[p]] |= mask[p];
111  }
112  }
113 
114  unsigned int vstat = vmask[0];
115 
116  if( !vstat || (vstat & vmask[1])){vstat |= vmask[1];}
117  if( !vstat || (vstat & vmask[2])){vstat |= vmask[2];}
118 
119  //if(vstat ){std::cout<<"vstat = "<<vstat<<std::endl;}//
120  /*
121  //const unsigned int vstatindex[11] = {0xc,0xa,0x6,0xe,0x9,0x5,0xd,0x3,0xb,0x7,0xf};
139  //const unsigned int viindex[2][11] = {{5,4,3,3,2,1,1,0,0,0,0},{5,4,3,5,2,1,5,0,4,3,3}};///index on which entry of vstatindex[11] to choose for both dphi and dtheta
140  */
141 
142  std::vector<int> d (6,-999);
143  std::vector<std::vector<int>> deltas (2,d);//deltas[0]->dPhi & deltas[1]->dTheta
144 
145  for(int i=0;i<6;i++){
146 
147  deltas[0][i] = dphi[i];
148  deltas[1][i] = dtmp2[i];
149  }
150 
152  int phi = 0, theta = 0;//, id = 0;
153  if(vstat & 2){//ME2 Present
154 
155  //phi is simple, we have only one per station to choose from
156  phi = phmatch.x[zone][winner][1].Phi();
157 
158  //for theta, select delta to best station, use dtmpi as index
159  if(dtmp2[0] != -999){
160  theta = dtmp2_ths[0][1];//t2[zone][winner][1][id];
161  }
162  else if(dtmp2[3] != -999){
163  theta = dtmp2_ths[3][0];//t2[zone][winner][1][id];
164  }
165  else if(dtmp2[4] != -999){
166  theta = dtmp2_ths[4][0];//t2[zone][winner][1][id];
167  }
168 
169  }
170  else if(vstat & 4){//ME3 Present, but not ME2
171 
172  phi = phmatch.x[zone][winner][2].Phi();
173  if(dtmp2[1] != -999){
174  theta = dtmp2_ths[1][1];//t2[zone][winner][2][id];
175  }
176  else if(dtmp2[5] != -999){
177  theta = dtmp2_ths[5][0];//t2[zone][winner][2][id];
178  }
179  }
180  else if(vstat & 8){//ME4 Present but not ME2 or ME3
181  phi = phmatch.x[zone][winner][3].Phi();
182  if(dtmp2[2] != -999){
183  theta = dtmp2_ths[2][1];//t2[zone][winner][3][id];
184  }
185  }
186 
188 
189  int rank = (Mout.Winners()[zone][winner].Rank()<<1);
190 
191  //if(rank) std::cout<<"rank = "<<rank<<"\n";
193  if(vstat & 8){rank |= 1;}else{rank &= 0x7e;}//if station 4 add to rank, else keep everythign and zero the bit which indicates station 4 is present
194  if(vstat & 4){rank |= 2;}else{rank &= 0x7d;}//if station 3 add to rank, else keep everythign and zero the bit which indicates station 3 is present
195  if(vstat & 2){rank |= 8;}else{rank &= 0x77;}//if station 2 add to rank, else keep everythign and zero the bit which indicates station 2 is present
196  if(vstat & 1){rank |= 32;}else{rank &= 0x5f;}//if station 1 add to rank, else keep everythign and zero the bit which indicates station 1 is present
197  if(vstat == 0 || vstat == 1 || vstat == 2 || vstat == 4 || vstat == 8){rank = 0;}//removes single, and ME3--ME4 hit combinations
199  Mout.SetPhOut(phmatch);
200  Winner win = Mout.Winners()[zone][winner];
201  win.SetRank(rank);
202 
203  output.SetValues(Mout,deltas,phi,theta,win);
204 
205  return output;
206 
207 }
int i
Definition: DBlmapReader.cc:9
void SetPhOut(PhOutput ph_output)
ThOutput ThetaMatch()
std::vector< std::vector< Winner > > Winners()
ConvertedHit x[4][3][4]
Geom::Theta< T > theta() const
Definition: deltas.h:18
tuple s2
Definition: indexGen.py:106
tuple d
Definition: ztail.py:151
auto const T2 &decltype(t1.eta()) t2
Definition: deltaR.h:16
void SetRank(int rank)
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
std::vector< int > AllThetas()
void SetValues(MatchingOutput Mout, std::vector< std::vector< int >> Deltas, int Phi, int Theta, Winner winner)
Geom::Phi< T > phi() const
PhOutput PhiMatch()