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)
 
DeltaOutput Deltas (MatchingOutput Mout, int zone, int winner)
 

Function Documentation

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

Definition at line 280 of file Deltas.h.

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

Referenced by L1TMuonEndCapTrackProducer::produce().

280  {
281 
282  DeltaOutput output;output.SetNull();
283 
284  std::vector<DeltaOutput> o (3,output);
285  std::vector<std::vector<DeltaOutput>> out (4,o);
286 
287  for(int zone=0;zone<4;zone++){
288 
289  for(int winner=0;winner<3;winner++){
290 
291 
292  out[zone][winner] = Deltas(Mout, zone, winner);
293  }
294  }
295 
296 
297 
298  return out;
299 }
DeltaOutput Deltas(MatchingOutput Mout, int zone, int winner)
Definition: Deltas.h:12
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.

need to fix still////

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

if(vstat && verbose){std::cout<<"vstat = "<<vstat<<std::endl;}

vstatindex[11] is a list of possible combinations of valid and present stations in order of increasing quality(i.e. if all stations are present and valid it's better to take delta 12 and 23 as opposed to delta 14 and 34 . Binary representation is below stations 3 and 4 present –> 0xc –> 1100 stations 2 and 4 present –> 0xa –> 1010 stations 2 and 3 present –> 0x6 –> 0110 stations 2,3 and 4 present –> 0xe –> 1110 stations 1 and 4 present –> 0x9 –> 1001 stations 1 and 3 present –> 0x5 –> 0101 stations 1,3 and 4 present –> 0xd –> 1101 stations 1 and 2 present –> 0x3 –> 0011 stations 1,2 and 4 present –> 0xb –> 1011 stations 1,2 and 3 present –> 0x7 –> 0111 all stations present –> 0xf –> 1111

index on which entry of vstatindex[11] to choose for both dphi and dtheta

here we separate stations 3 and 4////

Definition at line 12 of file Deltas.h.

References funct::abs(), EnergyCorrector::c, ztail::d, i, j, cmsLHEtoEOSManager::l, convertSQLitetoXML_cfg::output, AlCaHLTBitMon_ParallelJobs::p, colinearityKinematic::Phi, phi(), MatchingOutput::PhiMatch(), indexGen::s2, MatchingOutput::SetPhOut(), Winner::SetRank(), DeltaOutput::SetValues(), theta(), MatchingOutput::ThetaMatch(), and MatchingOutput::Winners().

Referenced by CalcDeltas(), and DeltaOutput::SetValues().

12  {
13 
14  //bool verbose = false;
15 
16  PhOutput phmatch = Mout.PhiMatch();
17  ThOutput thmatch = Mout.ThetaMatch();
18 
19  /*for comparison only
20  for(int xx=0;xx<4;xx++){
21 
22  if(phmatch[zone][winner][xx].Phi() != -999 && verbose)
23  std::cout<<"phmatch["<<zone<<"]["<<winner<<"]["<<xx<<"] = "<<phmatch[zone][winner][xx].Phi()<<"\n\n";
24  }
25  */
26 
30  int dphi[6] = {-999,-999,-999,-999,-999,-999};
31  int dtmp[6] = {-999,-999,-999,-999,-999,-999};
32  int dtmpi[6] = {-999,-999,-999,-999,-999,-999};
33  int dth[6][4] = {{-999,-999,-999,-999},{-999,-999,-999,-999},{-999,-999,-999,-999},{-999,-999,-999,-999},{-999,-999,-999,-999},{-999,-999,-999,-999}};
34 
35 
36  for(int s1=0;s1<3;s1++){
37 
38  for(int s2=s1+1;s2<4;s2++){
39 
43 
44  if((s1 == 0) && (phmatch[zone][winner][s1].Phi() != -999) && (phmatch[zone][winner][s2].Phi() != -999)){ //if using station one and both hits are valid
45 
46  dphi[s2-1] = phmatch[zone][winner][s1].Phi() - phmatch[zone][winner][s2].Phi();
47  }
48  else if((s1 != 0) && (phmatch[zone][winner][s1].Phi() != -999) && (phmatch[zone][winner][s2].Phi() != -999)){//if not using station one and both hits are valid
49 
50  dphi[s1+s2] = phmatch[zone][winner][s1].Phi() - phmatch[zone][winner][s2].Phi();
51  }
52 
53 
57 
58  for(int i=0;i<2;i++){
59 
60 
61  for(int j=0;j<2;j++){
62 
63  int thi = thmatch[zone][winner][s1][i].Theta();
64  int thj = thmatch[zone][winner][s2][j].Theta();
65  int deltath = thi - thj;
66 
67 
68  if((s1 == 0) && (thi != -999) && (thj != -999)){
69 
70  if(!i){dth[s2-1][i+j] = deltath;}
71  else{dth[s2-1][i+j+1] = deltath;}
72 
73 
74  }
75  else if((s1 != 0) && (thi != -999) && (thj != -999)){
76 
77  if(!i){dth[s1+s2][i+j] = deltath;}
78  else{dth[s1+s2][i+j+1] = deltath;}
79  }
80 
81  }
82  }
83 
84  }
85  }
86 
87 
88  int vmask[3] = {0,0,0};
89  const unsigned int mask[6] = {0x3,0x5,0x9,0x6,0xa,0xc};
102  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...
103 
104  for(int p=0;p<6;p++){
105 
106  //if(dphi[p] != -999 && verbose)
107  // std::cout<<"dphi["<<p<<"] = "<<dphi[p]<<"\n\n";
108 
109  for(int l=0;l<4;l++){
110 
111  //if(dth[p][l] != -999 && verbose){std::cout<<"dth["<<p<<"]["<<l<<"] = "<<dth[p][l]<<"\n\n";}
112 
113  if(abs(dth[p][l]) < fabs(dtmp[p])){//get best dtheta(i.e. the smallest)
114 
115  //if(verbose) std::cout<<"chose second hit theta index-"<<p<<std::endl;
116 
117  dtmp[p] = dth[p][l];
118 
119  dtmpi[p] = l;//says which combination of dth is the one to choose (because there are 4 possible as stated above^)
120  }
121  }
122 
123 
124  if((abs(dtmp[p]) <= 4) && (dtmp[p] != -999)){//if dtheta is small enought and valid
125 
126  //std::cout<<"valid "<<p<<std::endl;
127 
128  vmask[mindex[p]] |= mask[p];
129  }
130  }
131 
132  //for(int q=0;q<3;q++){
133  // if(vmask[q] && verbose)
134  // std::cout<<"vmask["<<q<<"] = "<<vmask[q]<<std::endl;
135  //}
136 
137 
138  unsigned int vstat = vmask[0];
139 
140  //if(vstat && verbose){std::cout<<"vstat = "<<vstat<<std::endl;}
141 
142  if( !vstat || (vstat & vmask[1])){vstat |= vmask[1];}
143 
145 
146  if( !vstat || (vstat & vmask[2])){vstat |= vmask[2];}
147 
148  //if(vstat && verbose){std::cout<<"vstat = "<<vstat<<std::endl;}
149 
150  const unsigned int vstatindex[11] = {0xc,0xa,0x6,0xe,0x9,0x5,0xd,0x3,0xb,0x7,0xf};
168  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}};
169 
170  std::vector<int> d (2,-999);
171  std::vector<std::vector<int>> deltas (2,d);//deltas[0]->dPhi & deltas[1]->dTheta
172 
173 
174 
175  for(int c=0;c<11;c++){
176 
177  if(vstat == vstatindex[c]){
178 
179  deltas[0][0] = dphi[viindex[0][c]];
180  deltas[0][1] = dphi[viindex[1][c]];
181  deltas[1][0] = dtmp[viindex[0][c]];
182  deltas[1][1] = dtmp[viindex[1][c]];
183  }
184  }
185 
187  int phi = 0, theta = 0, id = 0;
188  if(vstat & 2){//ME2 Present
189 
190  //phi is simple, we have only one per station to choose from
191  phi = phmatch[zone][winner][1].Phi();
192 
193  //for theta, select delta to best station, use dtmpi as index
194  if(dtmp[0] != -999){
195 
196  if(dtmpi[0] < 2)
197  id = 1;
198 
199 
200  theta = thmatch[zone][winner][1][id].Theta();
201  }
202  else if(dtmp[3] != -999){
203 
204  if(dtmpi[3] > 1)
205  id = 1;
206 
207 
208  theta = thmatch[zone][winner][1][id].Theta();
209  }
210  else if(dtmp[4] != -999){
211 
212  if(dtmpi[4] > 1)
213  id = 1;
214 
215 
216  theta = thmatch[zone][winner][1][id].Theta();
217  }
218 
219  }
220  else if(vstat & 4){//ME3 Present, but not ME2
221 
222  phi = phmatch[zone][winner][2].Phi();
223 
224  if(dtmp[1] != -999){
225 
226  if(dtmpi[1] < 2)
227  id = 1;
228 
229 
230  theta = thmatch[zone][winner][2][id].Theta();
231  }
232  else if(dtmp[5] != -999){
233 
234  if(dtmpi[5] > 1)
235  id = 1;
236 
237 
238  theta = thmatch[zone][winner][2][id].Theta();
239  }
240  }
241  else if(vstat & 8){//ME4 Present but not ME2 or ME3
242 
243  phi = phmatch[zone][winner][3].Phi();
244  if(dtmp[2] != -999){
245 
246  if(dtmpi[2] < 2)
247  id = 1;
248 
249 
250  theta = thmatch[zone][winner][3][id].Theta();
251  }
252  }
253 
254 
256 
257  int rank = (Mout.Winners()[zone][winner].Rank()<<1);
258 
259 
261  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
262  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
263  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
264  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
265 
266  if(vstat == 0 || vstat == 1 || vstat == 2 || vstat == 4 || vstat == 8){rank = 0;}//removes single, and ME3--ME4 hit combinations
267 
269  Mout.SetPhOut(phmatch);
270  Winner win = Mout.Winners()[zone][winner];
271  win.SetRank(rank);
272 
273  output.SetValues(Mout,deltas,phi,theta,win);
274 
275  return output;
276 
277 
278 }
int i
Definition: DBlmapReader.cc:9
void SetPhOut(PhOutput ph_output)
ThOutput ThetaMatch()
std::vector< std::vector< Winner > > Winners()
Geom::Theta< T > theta() const
Definition: deltas.h:18
tuple s2
Definition: indexGen.py:106
tuple d
Definition: ztail.py:151
void SetRank(int rank)
std::vector< std::vector< std::vector< std::vector< ConvertedHit > > > > ThOutput
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
int j
Definition: DBlmapReader.cc:9
void SetValues(MatchingOutput Mout, std::vector< std::vector< int >> Deltas, int Phi, int Theta, Winner winner)
Geom::Phi< T > phi() const
PhOutput PhiMatch()
std::vector< std::vector< std::vector< ConvertedHit > > > PhOutput