test
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 
7 int getCharge(int phi1, int phi2, int phi3, int phi4, int mode){
8 
9  // -1 = postive physical charge to match pdgId code (i.e. -13 is positive, anti-muon). +1 = negative physical charge.
10  // Also matches DN-2015/017 format for track finder --> uGMT interface format, where 0 indicates positive, 1 negative.
11  int emuCharge = 0;
12  int phidiffs[6] = {phi2 - phi1, phi3 - phi1, phi4 - phi1, phi3 - phi2, phi4 - phi2, phi4 - phi3};
13 
14  if(mode == 15 ){
15  if(phidiffs[0] > 0)
16  emuCharge = 1;
17  else if(phidiffs[0] == 0 && phidiffs[1] < 0)
18  emuCharge = 1;
19  else if(phidiffs[1] == 0 && phidiffs[2] < 0)
20  emuCharge = 1;
21  else
22  emuCharge = -1;
23  }
24 
25  if(mode == 14){
26 
27  if(phidiffs[0] < 0)
28  emuCharge = -1;
29  else if(phidiffs[0] == 0 && phidiffs[1] < 0)
30  emuCharge = -1;
31  else
32  emuCharge = 1;
33  }
34 
35  if(mode == 13){
36  if(phidiffs[0] > 0)
37  emuCharge = 1;
38  else if(phidiffs[0] == 0 && phidiffs[2] < 0)
39  emuCharge = 1;
40  else
41  emuCharge = -1;
42  }
43 
44  if(mode == 12){
45  if(phidiffs[0] > 0)
46  emuCharge = 1;
47  else
48  emuCharge = -1;
49  }
50 
51  if(mode == 11){
52  if(phidiffs[1] > 0)
53  emuCharge = 1;
54  else if(phidiffs[1] == 0 && phidiffs[2] < 0)
55  emuCharge = 1;
56  else
57  emuCharge = -1;
58  }
59 
60  if(mode == 10){
61  if(phidiffs[1] > 0)
62  emuCharge = 1;
63  else
64  emuCharge = -1;
65  }
66 
67  if(mode == 9){
68  if(phidiffs[2] > 0)
69  emuCharge = 1;
70  else
71  emuCharge = -1;
72  }
73 
74  if(mode == 7){
75  if(phidiffs[3] > 0)
76  emuCharge = 1;
77  else if(phidiffs[3] == 0 && phidiffs[4] < 0)
78  emuCharge = 1;
79  else
80  emuCharge = -1;
81  }
82 
83  if(mode == 6){
84  if(phidiffs[3] > 0)
85  emuCharge = 1;
86  else
87  emuCharge = -1;
88  }
89 
90  if(mode == 5){
91  if(phidiffs[4] > 0)
92  emuCharge = 1;
93  else
94  emuCharge = -1;
95  }
96 
97  if(mode == 3){
98  if(phidiffs[5] > 0)
99  emuCharge = 1;
100  else
101  emuCharge = -1;
102  }
103 
104  int charge = 0;
105  if(emuCharge == 1)
106  charge = 1;
107 
108  return charge;
109 
110 }
int getCharge(int phi1, int phi2, int phi3, int phi4, int mode)