CMS 3D CMS Logo

DTMuonSLToSL.cc
Go to the documentation of this file.
2 
3 DTMuonSLToSL::DTMuonSLToSL(std::string path, int n_files, float MaxPt, float MinPt, TFile *f_) {
5  numberOfRootFiles = n_files;
6 
7  f = f_;
8 
9  ptMax = MaxPt;
10  ptMin = MinPt;
11 
12  setBranchTree();
13 
14  initNTuples(0);
15 
17 }
18 
20 
22  TMatrixD ****C13 = new TMatrixD ***[5];
23  TMatrixD ****b13 = new TMatrixD ***[5];
24  TMatrixD ****C31 = new TMatrixD ***[5];
25  TMatrixD ****b31 = new TMatrixD ***[5];
26 
27  for (int whI = -2; whI < 3; ++whI) {
28  C13[whI + 2] = new TMatrixD **[4];
29  b13[whI + 2] = new TMatrixD **[4];
30  C31[whI + 2] = new TMatrixD **[4];
31  b31[whI + 2] = new TMatrixD **[4];
32  for (int stI = 1; stI < 5; ++stI) {
33  C13[whI + 2][stI - 1] = new TMatrixD *[14];
34  b13[whI + 2][stI - 1] = new TMatrixD *[14];
35  C31[whI + 2][stI - 1] = new TMatrixD *[14];
36  b31[whI + 2][stI - 1] = new TMatrixD *[14];
37  for (int seI = 1; seI < 15; ++seI) {
38  if (seI > 12 && stI != 4)
39  continue;
40  C13[whI + 2][stI - 1][seI - 1] = new TMatrixD(3, 3);
41  b13[whI + 2][stI - 1][seI - 1] = new TMatrixD(3, 1);
42  C31[whI + 2][stI - 1][seI - 1] = new TMatrixD(3, 3);
43  b31[whI + 2][stI - 1][seI - 1] = new TMatrixD(3, 1);
44  }
45  }
46  }
47 
48  //Run over the TTree
49  Int_t nentries = (Int_t)tali->GetEntries();
50  for (Int_t i = 0; i < nentries; i++) {
51  tali->GetEntry(i);
52  //Basic cuts
53  if (pt > ptMax || pt < ptMin)
54  continue;
55 
56  bool repeatedHits = false;
57  for (int counter = 0; counter < nseg; ++counter) {
58  //Make sure there are no repeated hits
59  for (int counterHi = 0; counterHi < nhits[counter]; counterHi++) {
60  for (int counterHj = 0; counterHj < nhits[counter]; counterHj++) {
61  if (counterHi == counterHj)
62  continue;
63  if (zc[counter][counterHi] == zc[counter][counterHj]) {
64  repeatedHits = true;
65  }
66  }
67  }
68  if (repeatedHits == true)
69  continue;
70 
71  float x_13 = xSlSL3[counter];
72  float xp_13 = xSL1SL3[counter];
73  float x_31 = xSlSL1[counter];
74  float xp_31 = xSL3SL1[counter];
75  //float tanphi = dxdzSl[counter];
76  float tanphi_13 = dxdzSlSL1[counter];
77  float tanphi_31 = dxdzSlSL3[counter];
78  int wheel = wh[counter];
79  int station = st[counter];
80  int sector = sr[counter];
81 
82  if (fabs(x_13 - xp_13) < 3 && fabs(x_31 - xp_31) && fabs(tanphi_13 - tanphi_31) < 0.06) {
83  *(C13[wheel + 2][station - 1][sector - 1]) += returnCSLMatrix(x_13, xp_13, tanphi_13);
84  *(b13[wheel + 2][station - 1][sector - 1]) += returnbSLMatrix(x_13, xp_13, tanphi_13);
85 
86  *(C31[wheel + 2][station - 1][sector - 1]) += returnCSLMatrix(x_31, xp_31, tanphi_31);
87  *(b31[wheel + 2][station - 1][sector - 1]) += returnbSLMatrix(x_31, xp_31, tanphi_31);
88  }
89  }
90  }
91 
92  for (int wheel = -2; wheel < 3; ++wheel) {
93  for (int station = 1; station < 5; ++station) {
94  for (int sector = 1; sector < 15; ++sector) {
95  if (sector > 12 && station != 4)
96  continue;
97  TMatrixD solution13(3, 1);
98  TMatrixD solution31(3, 1);
99  TMatrixD C31_copy = *(C31[wheel + 2][station - 1][sector - 1]);
100  TMatrixD C13_copy = *(C13[wheel + 2][station - 1][sector - 1]);
101  TMatrixD b31_copy = *(b31[wheel + 2][station - 1][sector - 1]);
102  TMatrixD b13_copy = *(b13[wheel + 2][station - 1][sector - 1]);
103 
104  C31_copy.Invert();
105  C13_copy.Invert();
106  solution13 = C13_copy * b13_copy;
107  solution31 = C31_copy * b31_copy;
108  whC = wheel;
109  stC = station;
110  srC = sector;
111  dx = solution13(0, 0);
112  dz = solution13(1, 0);
113  phiy = solution13(2, 0);
114  for (int c = 0; c < 3; ++c) {
115  for (int s = 0; s < 3; ++s) {
116  cov[c][s] = C13_copy(c, s);
117  }
118  }
119  ttreeOutput->Fill();
120  }
121  }
122  }
123  f->Write();
124 }
125 
126 TMatrixD DTMuonSLToSL::returnCSLMatrix(float x, float xp, float tanphi) {
127  TMatrixD matrix(3, 3);
128 
129  matrix(0, 0) = 1.0;
130  matrix(1, 0) = tanphi;
131  matrix(0, 1) = tanphi;
132  matrix(1, 1) = tanphi * tanphi;
133  matrix(0, 2) = tanphi * xp;
134  matrix(2, 0) = tanphi * xp;
135  matrix(2, 2) = tanphi * tanphi * xp * xp;
136  matrix(2, 1) = tanphi * tanphi * xp;
137  matrix(1, 2) = tanphi * tanphi * xp;
138 
139  return matrix;
140 }
141 
142 TMatrixD DTMuonSLToSL::returnbSLMatrix(float x, float xp, float tanphi) {
143  TMatrixD matrix(3, 1);
144 
145  matrix(0, 0) = -(x - xp);
146  matrix(1, 0) = -(x - xp) * tanphi;
147  matrix(2, 0) = -(x - xp) * tanphi * xp;
148 
149  return matrix;
150 }
151 
153  ttreeOutput = new TTree("DTSLToSLResult", "DTSLToSLResult");
154 
155  ttreeOutput->Branch("wh", &whC, "wh/F");
156  ttreeOutput->Branch("st", &stC, "st/F");
157  ttreeOutput->Branch("sr", &srC, "sr/F");
158  ttreeOutput->Branch("dx", &dx, "dx/F");
159  ttreeOutput->Branch("dz", &dz, "dz/F");
160  ttreeOutput->Branch("phiy", &phiy, "phiy/F");
161  ttreeOutput->Branch("cov", cov, "cov[3][3]/F");
162 }
TTree * ttreeOutput
Definition: DTMuonSLToSL.h:42
void setBranchTree()
void calculationSLToSL()
Definition: DTMuonSLToSL.cc:21
DTMuonSLToSL(std::string, int, float, float, TFile *)
Definition: DTMuonSLToSL.cc:3
static std::atomic< unsigned int > counter
float x
TMatrixD returnCSLMatrix(float, float, float)
float cov[3][3]
Definition: DTMuonSLToSL.h:37
TMatrixD returnbSLMatrix(float, float, float)