CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Public Attributes
Conv Class Reference

#include <CSCxTalk.h>

Public Member Functions

 Conv ()
 
void convolution (float *xleft_a, float *xleft_b, float *min_left, float *xright_a, float *xright_b, float *min_right, float *pTime)
 
float elec (float t, float vs)
 
void mkbins (float vs)
 
 ~Conv ()
 

Public Attributes

float conv [3][120]
 
float convd [3][120]
 
float conve [120]
 
float nconvd [3][120]
 

Detailed Description

Definition at line 5 of file CSCxTalk.h.

Constructor & Destructor Documentation

Conv::Conv ( )
inline

Definition at line 9 of file CSCxTalk.h.

9 {}
Conv::~Conv ( )
inline

Definition at line 149 of file CSCxTalk.h.

149 {}

Member Function Documentation

void Conv::convolution ( float *  xleft_a,
float *  xleft_b,
float *  min_left,
float *  xright_a,
float *  xright_b,
float *  min_right,
float *  pTime 
)
inline

Definition at line 39 of file CSCxTalk.h.

References conv, convd, conve, cross2(), i, j, relval_steps::k, prof2calltree::l, bookConverter::max, and makeMuonMisalignmentScenario::sum_x.

39  {
40  //void(convolution){
41 
42  float max, cross0,cross2,min_l,min_r,sum_x=0.0,sumx2=0.;
43  float sum_y_left=0.0,sum_y_right=0.0,sum_xy_left=0.0,sum_xy_right=0.0;
44  float a_left=0.0,a_right=0.0,b_left=0.0,b_right=0.0,chi2_left=0.0,chi2_right=0.0,chi_left=0.0,chi_right=0.0;
45  float aleft=0.0,aright=0.0,bleft=0.0,bright=0.0;
46  int i,j,k,l,imax=0;
47 
48  for(l=0;l<3;l++){
49  for(i=0;i<119;i++)conv[l][i]=0.0;
50  for(j=0;j<119;j++){
51  for(k=0;k<119;k++){
52  if(j+k<119)conv[l][j+k]=conv[l][j+k]+convd[l][j]*conve[k];
53  }
54  }
55  }
56  max=0;
57  min_l=9999999999999999.0;
58  min_r=9999999999999999.0;
59  for(i=0;i<119;i++){
60  if(conv[1][i]>max){
61  max=conv[1][i];
62  imax=i;
63  }
64  }
65 
66  //find the max peak time from 3 timebins when line intersects x axis a+b*x=0 -> x=-a/b
67  float time1=-999.0, time2=-999.0, time3=-999.0;
68  float data1=-999.0, data2=-999.0, data3=-999.0;
69  float peakTime=0.0;
70 
71  time1=imax-1;
72  time2=imax;
73  time3=imax+1;
74 
75  data1=conv[1][imax-1];
76  data2=conv[1][imax];
77  data3=conv[1][imax+1];
78 
79  peakTime=(0.5)*((time1*time1*(data3-data2)+time2*time2*(data1-data3)+time3*time3*(data2-data1))/(time1*(data3-data2)+time2*(data1-data3)+time3*(data2-data1)))*6.25;
80 
81  for(l=0;l<3;l++){
82  for(i=0;i<119;i++)conv[l][i]=conv[l][i]/max;
83  }
84 
85  int nobs = 0;
86  for (int j=0; j<119; j++){
87  if (conv[1][j]>0.6) nobs++;
88  }
89 
90  for(i=0;i<119;i++){
91  cross0=0.0;
92  cross2=0.0;
93 
94  if(conv[1][i]>0.6){
95  cross0=conv[0][i]/(conv[0][i]+conv[1][i]+conv[2][i]);
96  cross2=conv[2][i]/(conv[0][i]+conv[1][i]+conv[2][i]);
97 
98  sum_x += i;
99  sum_y_left += cross0;
100  sum_y_right += cross2;
101  sumx2 += i*i;
102  sum_xy_left += i*cross0;
103  sum_xy_right += i*cross2;
104  }
105  }
106 
107  //LMS fitting straight line y=a+b*x
108 
109  bleft = ((nobs*sum_xy_left) - (sum_x * sum_y_left))/((nobs*sumx2) - (sum_x*sum_x));
110  bright = ((nobs*sum_xy_right) - (sum_x * sum_y_right))/((nobs*sumx2) - (sum_x*sum_x));
111 
112  aleft = ((sum_y_left*sumx2)-(sum_x*sum_xy_left))/((nobs*sumx2)-(sum_x*sum_x));
113  aright = ((sum_y_right*sumx2)-(sum_x*sum_xy_right))/((nobs*sumx2)-(sum_x*sum_x));
114 
115  for(i=0;i<119;i++ ){
116  chi2_left += (cross0 -(aleft+(bleft*i)))*(cross0 -(aleft+(bleft*i)));
117  chi2_right += (cross2 -(aright+(bright*i)))*(cross2 -(aright+(bright*i)));
118  }
119 
120  if(chi_left<min_l){
121  min_l=chi_left;
122  bleft=bleft;
123  aleft=aleft;
124  }
125  if(chi_right<min_r){
126  min_r=chi_right;
127  bright=bright;
128  aright=aright;
129  }
130 
131 
132  //Now calculating parameters in ns to compensate for drift in peak time
133  b_left = bleft/6.25;
134  b_right = bright/6.25;
135 
136  a_left = aleft + (bleft*peakTime/6.25);
137  a_right = aright + (bright*peakTime/6.25);
138 
139  *xleft_a = a_left;
140  *xleft_b = b_left;
141  *min_left = chi2_left;
142  *xright_a = a_right;
143  *xright_b = b_right;
144  *min_right = chi2_right;
145  *pTime = peakTime;
146 
147  } //end CONVOLUTION
int i
Definition: DBlmapReader.cc:9
auto cross2(V1 x, V2 y) -> typename std::remove_reference< decltype(x[0])>::type
Definition: ExtVec.h:93
float conve[120]
Definition: CSCxTalk.h:154
float conv[3][120]
Definition: CSCxTalk.h:155
int j
Definition: DBlmapReader.cc:9
float convd[3][120]
Definition: CSCxTalk.h:152
float Conv::elec ( float  t,
float  vs 
)
inline

Definition at line 12 of file CSCxTalk.h.

References f, and cmsBatch::log.

Referenced by mkbins().

12  {
13  float f;
14  if (t<=vs){
15  f=log(t+2.5)-log(2.5);
16  }
17  else{
18  f=log(t+2.5)-log(t-50+2.5);
19  }
20  return f;
21  }//end elec
double f[11][100]
tuple log
Definition: cmsBatch.py:347
void Conv::mkbins ( float  vs)
inline

Definition at line 25 of file CSCxTalk.h.

References conve, elec(), i, relval_steps::k, and edmStreamStallGrapher::t.

25  {
26  int i,k;
27  float t;
28  for(i=0;i<120;i++) conve[i]=0.0;
29  for(i=0;i<120;i++){
30  for(k=0;k<16;k++){
31  t=(6.25*i)+(k*0.625);
32  conve[i]=conve[i]+elec(t,vs);
33  }
34  }
35  } //end mkbins
int i
Definition: DBlmapReader.cc:9
float conve[120]
Definition: CSCxTalk.h:154
float elec(float t, float vs)
Definition: CSCxTalk.h:12

Member Data Documentation

float Conv::conv[3][120]

Definition at line 155 of file CSCxTalk.h.

Referenced by convolution().

float Conv::convd[3][120]

Definition at line 152 of file CSCxTalk.h.

Referenced by convolution().

float Conv::conve[120]

Definition at line 154 of file CSCxTalk.h.

Referenced by convolution(), and mkbins().

float Conv::nconvd[3][120]

Definition at line 153 of file CSCxTalk.h.