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 }
DTMuonLocalAlignment::xSlSL3
float xSlSL3[5]
Definition: DTMuonLocalAlignment.h:59
counter
Definition: counter.py:1
DTMuonLocalAlignment::sr
int sr[5]
Definition: DTMuonLocalAlignment.h:75
DTMuonLocalAlignment::dxdzSlSL3
float dxdzSlSL3[5]
Definition: DTMuonLocalAlignment.h:60
mps_fire.i
i
Definition: mps_fire.py:355
makeMuonMisalignmentScenario.matrix
list matrix
Definition: makeMuonMisalignmentScenario.py:141
DTMuonSLToSL::returnCSLMatrix
TMatrixD returnCSLMatrix(float, float, float)
Definition: DTMuonSLToSL.cc:126
DTMuonSLToSL::cov
float cov[3][3]
Definition: DTMuonSLToSL.h:37
relativeConstraints.station
station
Definition: relativeConstraints.py:67
electronAnalyzer_cfi.MinPt
MinPt
Definition: electronAnalyzer_cfi.py:36
DTMuonLocalAlignment::dxdzSlSL1
float dxdzSlSL1[5]
Definition: DTMuonLocalAlignment.h:54
DTMuonLocalAlignment::xSL3SL1
float xSL3SL1[5]
Definition: DTMuonLocalAlignment.h:64
DTMuonLocalAlignment::xSL1SL3
float xSL1SL3[5]
Definition: DTMuonLocalAlignment.h:58
genfragment_ptgun_cfg.MaxPt
MaxPt
Definition: genfragment_ptgun_cfg.py:12
DDAxes::x
DTMuonSLToSL::ptMin
float ptMin
Definition: DTMuonSLToSL.h:40
DTMuonLocalAlignment::wh
int wh[5]
Definition: DTMuonLocalAlignment.h:73
DTMuonSLToSL::ttreeOutput
TTree * ttreeOutput
Definition: DTMuonSLToSL.h:42
DTMuonLocalAlignment::zc
float zc[5][14]
Definition: DTMuonLocalAlignment.h:67
DTMuonLocalAlignment::st
int st[5]
Definition: DTMuonLocalAlignment.h:74
DTMuonLocalAlignment::ntuplePath
std::string ntuplePath
Definition: DTMuonLocalAlignment.h:28
alignCSCRings.s
s
Definition: alignCSCRings.py:92
DTMuonSLToSL.h
DTMuonSLToSL::calculationSLToSL
void calculationSLToSL()
Definition: DTMuonSLToSL.cc:21
vertices_cff.x
x
Definition: vertices_cff.py:29
DTMuonSLToSL::srC
int srC
Definition: DTMuonSLToSL.h:35
DTMuonSLToSL::phiy
float phiy
Definition: DTMuonSLToSL.h:36
DTMuonSLToSL::DTMuonSLToSL
DTMuonSLToSL(std::string, int, float, float, TFile *)
Definition: DTMuonSLToSL.cc:3
DTMuonLocalAlignment::xSlSL1
float xSlSL1[5]
Definition: DTMuonLocalAlignment.h:53
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
DTMuonLocalAlignment::nseg
int nseg
Definition: DTMuonLocalAlignment.h:39
makeMuonMisalignmentScenario.wheel
wheel
Definition: makeMuonMisalignmentScenario.py:319
counter
static std::atomic< unsigned int > counter
Definition: SharedResourceNames.cc:15
HltBtagPostValidation_cff.c
c
Definition: HltBtagPostValidation_cff.py:31
DTMuonSLToSL::~DTMuonSLToSL
~DTMuonSLToSL()
Definition: DTMuonSLToSL.cc:19
DTMuonLocalAlignment::tali
TChain * tali
Definition: DTMuonLocalAlignment.h:32
DTMuonLocalAlignment::f
TFile * f
Definition: DTMuonLocalAlignment.h:34
DTMuonLocalAlignment::numberOfRootFiles
int numberOfRootFiles
Definition: DTMuonLocalAlignment.h:30
DTMuonSLToSL::setBranchTree
void setBranchTree()
Definition: DTMuonSLToSL.cc:152
DTMuonSLToSL::dx
float dx
Definition: DTMuonSLToSL.h:36
DTMuonSLToSL::returnbSLMatrix
TMatrixD returnbSLMatrix(float, float, float)
Definition: DTMuonSLToSL.cc:142
DTMuonSLToSL::whC
int whC
Definition: DTMuonSLToSL.h:35
DTMuonLocalAlignment::pt
float pt
Definition: DTMuonLocalAlignment.h:38
DTMuonSLToSL::stC
int stC
Definition: DTMuonSLToSL.h:35
castor_dqm_sourceclient_file_cfg.path
path
Definition: castor_dqm_sourceclient_file_cfg.py:37
DTMuonLocalAlignment::initNTuples
void initNTuples(int)
Definition: DTMuonLocalAlignment.cc:6
DTMuonLocalAlignment::nhits
int nhits[5]
Definition: DTMuonLocalAlignment.h:42
DTMuonSLToSL::dz
float dz
Definition: DTMuonSLToSL.h:36
DTMuonSLToSL::ptMax
float ptMax
Definition: DTMuonSLToSL.h:40