CMS 3D CMS Logo

BHFilter.cc
Go to the documentation of this file.
1 // livio.fano@cern.ch
2 
5 
6 using namespace std;
7 namespace cms
8 
9 {
10 BHFilter::BHFilter(const edm::ParameterSet& conf): conf_(conf)
11 {
12  rBounds = conf_.getParameter< vector<double> >("radii");
13  zBounds = conf_.getParameter< vector<double> >("zeds");
14  bFields = conf_.getParameter< vector<double> >("bfiel");
15  bReduction = conf_.getParameter< double >("factor");
16  trig_ = conf_.getParameter< int >("trig_type");
17  trig2_ = conf_.getParameter< int >("scintillators_type");
18 
19  for ( unsigned i=0; i<bFields.size(); ++i ) {
20  bFields[i] *= bReduction;
21  cout << "r/z/b = " << rBounds[i] << " " << zBounds[i] << " " << bFields[i] << endl;
22  }
23 
24  if(trig_==0){ cout <<endl << "trigger is both + and - BSC " << endl;}
25  if(trig_==1){ cout <<endl << "trigger is + side BSC " << endl;}
26  if(trig_==-1){ cout <<endl << "trigger is - side BSC " << endl;}
27 
28  cout << endl;
29 
30  if(trig2_==0){ cout <<endl << "trigger is both PADs and DISKs " << endl;}
31  if(trig2_==-1){ cout <<endl << "trigger is only PADs " << endl;}
32  if(trig2_==1){ cout <<endl << "trigger is only DISKs " << endl;}
33 
34  if(trig_!=0 && trig_!=-1 && trig_!=1 && trig2_!=0 && trig2_!=-1 && trig2_!=1)
35  {
36  cout <<endl << endl <<endl<< "WARNING!! BSC trigger/scintillator type not properly defined " << endl;
37  cout <<endl << endl <<endl<< "WARNING!! BSC trigger/scintillator type not properly defined " << endl << endl << endl;
38  }
39 
40 }
41 
43 {
44 
45 
47  iEvent.getByLabel("generator","unsmeared",HepMCEvt);
48  const HepMC::GenEvent* MCEvt = HepMCEvt->GetEvent();
49 
51  map<unsigned,XYZTLorentzVector> myHits;
52 
53 
54 
55  for(HepMC::GenEvent::particle_const_iterator i=MCEvt->particles_begin(); i != MCEvt->particles_end();++i)
56  {
57 
58 
59 
60  pad_plus = false;
61  pad_minus = false;
62  circ_plus = false;
63  circ_minus = false;
64 
65  int myId = (*i)->pdg_id();
66 
67 
68  const HepMC::GenVertex * vertex_=(*i)->production_vertex();
69  double xv = vertex_->position().x();
70  double yv = vertex_->position().y();
71  double zv = vertex_->position().z();
72  double tv = vertex_->position().t();
73  XYZTLorentzVector vertex = XYZTLorentzVector(xv,yv,zv,tv);
74 
75  //vertex_->position();
76 
77  // HepMC::FourVector
78  XYZTLorentzVector momentum = XYZTLorentzVector(((*i)->momentum()).x(), ((*i)->momentum()).y(), ((*i)->momentum()).z(), ((*i)->momentum()).t());
79 
80  RawParticle myMuon(-momentum, vertex/10.);
81 
82  if ( myId < 0 )
83  myMuon.setCharge(-1.);
84  else
85  myMuon.setCharge(+1.);
86 
87  BaseParticlePropagator PP(myMuon,0.,0.,0.);
88 
89 
90  float x0= vertex.x();
91  float y0= vertex.y();
92  float z0= vertex.z();
93  float px0=momentum.x();
94  float py0=momentum.y();
95  float pz0=momentum.z();
96 
97  // beam 1 or 2 ?
98  // propagator -> need to be implemented
99 
100 
101  // intersection point - particle/BSC1
102  float zs = 10860.;
103  float ys = (zs-z0)*(py0/pz0)+y0;
104  float xs = (ys-y0)*(px0/py0)+x0;
105 
106 
107  if(xs<0 && ys>0) {xs=-xs;}
108  if(xs>0 && ys<0) {ys=-ys;}
109  if(xs<0 && ys<0) {xs=-xs; ys=-ys;}
110 
111 
112  // scintillator pads
113  float A[2]={732.7, 24.7};
114  float B[2]={895.3, 187.3};
115  float C[2]={144.0, 850.2};
116  float D[2]={69.8, 776.0};
117  float m1=(B[1]-A[1])/(B[0]-A[0]);
118  float m2=(C[1]-B[1])/(C[0]-B[0]);
119  float m3=(D[1]-C[1])/(D[0]-C[0]);
120  float m4=(A[1]-D[1])/(A[0]-D[0]);
121  float y1=m1*(xs-A[0])+A[1];
122  float y2=m2*(xs-B[0])+B[1];
123  float y3=m3*(xs-C[0])+C[1];
124  float y4=m4*(xs-D[0])+D[1];
125 
126 
127 
128 
129  // trigger conditions
130 
131  if(ys>y1 && ys<y2 && ys<y3 && ys>y4)
132  {
133  pad_plus = true;
134  // cout << " trig1+" << endl;
135  }
136 
137  if((ys<sqrt(450*450-xs*xs) && ys>sqrt(208*208-xs*xs)) || (ys<sqrt(450*450-xs*xs) && xs>208))
138  {
139  circ_plus = true;
140  // cout << " trig2+" << endl;
141  }
142 
143 
144  // intersection point - particle/BSC2
145  zs = -10860.;
146  ys = (zs-z0)*(py0/pz0)+y0;
147  xs = (ys-y0)*(px0/py0)+x0;
148 
149  // cout << endl << " xs ys zs " << xs << " " << ys << " " << zs;
150 
151 
152  if(xs<0 && ys>0) {xs=-xs;}
153  if(xs>0 && ys<0) {ys=-ys;}
154  if(xs<0 && ys<0) {xs=-xs; ys=-ys;}
155 
156 
157  // scintillator pads
158  y1=m1*(xs-A[0])+A[1];
159  y2=m2*(xs-B[0])+B[1];
160  y3=m3*(xs-C[0])+C[1];
161  y4=m4*(xs-D[0])+D[1];
162 
163 
164 
165  // trigger conditions
166 
167  if(ys>y1 && ys<y2 && ys<y3 && ys>y4)
168  {
169  pad_minus = true;
170  // cout << " trig1-" << endl;
171  }
172 
173  if((ys<sqrt(450*450-xs*xs) && ys>sqrt(208*208-xs*xs)) || (ys<sqrt(450*450-xs*xs) && xs>208))
174  {
175  circ_minus = true;
176  // cout << " trig2-" << endl;
177  }
178 
179 
180  // final selection
181 
182  if(trig2_==-1)
183  {
184  pad_plus = false;
185  pad_minus = false;
186  }
187  if(trig2_==1)
188  {
189  circ_plus = false;
190  circ_minus = false;
191  }
192 
193  if(trig_==0 && (pad_plus || circ_plus) && (pad_minus || circ_minus) )
194  {
195  // cout << "triggg 0 " << endl;
196  return true;
197  }
198  if(trig_==1 && (pad_plus || circ_plus))
199  {
200  // cout << "triggg 1 " << endl;
201  return true;
202  }
203  if(trig_==-1 && (pad_minus || circ_minus))
204  {
205  // cout << "triggg -1 " << endl;
206  return true;
207  }
208 
209  }
210 
211  return false;
212 
213 }
214 
215 
216 
217 }
T getParameter(std::string const &) const
bool circ_minus
Definition: BHFilter.h:44
std::vector< double > bFields
Definition: BHFilter.h:35
double bReduction
Definition: BHFilter.h:36
bool pad_minus
Definition: BHFilter.h:42
bool circ_plus
Definition: BHFilter.h:43
bool pad_plus
Definition: BHFilter.h:41
int iEvent
Definition: GenABIO.cc:224
T sqrt(T t)
Definition: SSEVec.h:18
bool filter(edm::Event &iEvent, edm::EventSetup const &c) override
Definition: BHFilter.cc:42
static const std::string B
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:480
Namespace of DDCMS conversion namespace.
std::vector< double > zBounds
Definition: BHFilter.h:33
const HepMC::GenEvent * GetEvent() const
Definition: HepMCProduct.h:38
DecomposeProduct< arg, typename Div::arg > D
Definition: Factorize.h:152
std::vector< double > rBounds
Definition: BHFilter.h:34
math::XYZTLorentzVector XYZTLorentzVector
Definition: RawParticle.h:27
edm::ParameterSet conf_
Definition: BHFilter.h:30