CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
ChargeAssignment.h
Go to the documentation of this file.
1 //
6 // From Andrew Brinkerhoff:
7 // Mode is a bitword defined by which stations have LCTs in the track.
8 // It is defined as 8 x (station 1) + 4 x (station 2) + 2 x (station 3) + 1 x (station 4)
9 // Modes 11, 13, & 14 all have an LCT in station 1, plus an LCT in two other stations
10 // Mode 15 has LCTs in all four stations.
11 // These are our "SingleMu" quality modes (Quality >= 12)
12 
13 #ifndef ADD_ChargeAssignment
14 #define ADD_ChargeAssignment
15 
16 
17 int getCharge(int phi1, int phi2, int phi3, int phi4, int mode){
18 
19  // -1 = postive physical charge to match pdgId code (i.e. -13 is positive, anti-muon). +1 = negative physical charge.
20  // Also matches DN-2015/017 format for track finder --> uGMT interface format, where 0 indicates positive, 1 negative.
21  int emuCharge = 0;
22  int phidiffs[6] = {phi2 - phi1, phi3 - phi1, phi4 - phi1, phi3 - phi2, phi4 - phi2, phi4 - phi3};
23 
24  if(mode == 15 ){
25  if(phidiffs[0] > 0)
26  emuCharge = 1;
27  else if(phidiffs[0] == 0 && phidiffs[1] < 0)
28  emuCharge = 1;
29  else if(phidiffs[1] == 0 && phidiffs[2] < 0)
30  emuCharge = 1;
31  else
32  emuCharge = -1;
33  }
34 
35  if(mode == 14){
36  if(phidiffs[0] < 0)
37  emuCharge = -1;
38  else if(phidiffs[0] == 0 && phidiffs[1] < 0)
39  emuCharge = -1;
40  else
41  emuCharge = 1;
42  }
43 
44  if(mode == 13){
45  if(phidiffs[0] > 0)
46  emuCharge = 1;
47  else if(phidiffs[0] == 0 && phidiffs[2] < 0)
48  emuCharge = 1;
49  else
50  emuCharge = -1;
51  }
52 
53  if(mode == 12){
54  if(phidiffs[0] > 0)
55  emuCharge = 1;
56  else
57  emuCharge = -1;
58  }
59 
60  if(mode == 11){
61  if(phidiffs[1] > 0)
62  emuCharge = 1;
63  else if(phidiffs[1] == 0 && phidiffs[2] < 0)
64  emuCharge = 1;
65  else
66  emuCharge = -1;
67  }
68 
69  if(mode == 10){
70  if(phidiffs[1] > 0)
71  emuCharge = 1;
72  else
73  emuCharge = -1;
74  }
75 
76  if(mode == 9){
77  if(phidiffs[2] > 0)
78  emuCharge = 1;
79  else
80  emuCharge = -1;
81  }
82 
83  if(mode == 7){
84  if(phidiffs[3] > 0)
85  emuCharge = 1;
86  else if(phidiffs[3] == 0 && phidiffs[4] < 0)
87  emuCharge = 1;
88  else
89  emuCharge = -1;
90  }
91 
92  if(mode == 6){
93  if(phidiffs[3] > 0)
94  emuCharge = 1;
95  else
96  emuCharge = -1;
97  }
98 
99  if(mode == 5){
100  if(phidiffs[4] > 0)
101  emuCharge = 1;
102  else
103  emuCharge = -1;
104  }
105 
106  if(mode == 3){
107  if(phidiffs[5] > 0)
108  emuCharge = 1;
109  else
110  emuCharge = -1;
111  }
112 
113  int charge = 0;
114  if(emuCharge == 1)
115  charge = 1;
116 
117  return charge;
118 
119 }
120 
121 #endif
int getCharge(int phi1, int phi2, int phi3, int phi4, int mode)