Go to the documentation of this file.00001
00002
00003 #include "GeneratorInterface/GenFilters/interface/BHFilter.h"
00004 #include "DataFormats/Common/interface/Handle.h"
00005
00006 using namespace std;
00007 namespace cms
00008
00009 {
00010 BHFilter::BHFilter(const edm::ParameterSet& conf): conf_(conf)
00011 {
00012 rBounds = conf_.getParameter< vector<double> >("radii");
00013 zBounds = conf_.getParameter< vector<double> >("zeds");
00014 bFields = conf_.getParameter< vector<double> >("bfiel");
00015 bReduction = conf_.getParameter< double >("factor");
00016 trig_ = conf_.getParameter< int >("trig_type");
00017 trig2_ = conf_.getParameter< int >("scintillators_type");
00018
00019 for ( unsigned i=0; i<bFields.size(); ++i ) {
00020 bFields[i] *= bReduction;
00021 cout << "r/z/b = " << rBounds[i] << " " << zBounds[i] << " " << bFields[i] << endl;
00022 }
00023
00024 if(trig_==0){ cout <<endl << "trigger is both + and - BSC " << endl;}
00025 if(trig_==1){ cout <<endl << "trigger is + side BSC " << endl;}
00026 if(trig_==-1){ cout <<endl << "trigger is - side BSC " << endl;}
00027
00028 cout << endl;
00029
00030 if(trig2_==0){ cout <<endl << "trigger is both PADs and DISKs " << endl;}
00031 if(trig2_==-1){ cout <<endl << "trigger is only PADs " << endl;}
00032 if(trig2_==1){ cout <<endl << "trigger is only DISKs " << endl;}
00033
00034 if(trig_!=0 && trig_!=-1 && trig_!=1 && trig2_!=0 && trig2_!=-1 && trig2_!=1)
00035 {
00036 cout <<endl << endl <<endl<< "WARNING!! BSC trigger/scintillator type not properly defined " << endl;
00037 cout <<endl << endl <<endl<< "WARNING!! BSC trigger/scintillator type not properly defined " << endl << endl << endl;
00038 }
00039
00040 }
00041
00042 bool BHFilter::filter(edm::Event& iEvent, const edm::EventSetup& iSetup)
00043 {
00044
00045
00046 edm::Handle<edm::HepMCProduct>HepMCEvt;
00047 iEvent.getByLabel("generator","",HepMCEvt);
00048 const HepMC::GenEvent* MCEvt = HepMCEvt->GetEvent();
00049
00050 BaseParticlePropagator PP;
00051 map<unsigned,XYZTLorentzVector> myHits;
00052
00053
00054
00055 for(HepMC::GenEvent::particle_const_iterator i=MCEvt->particles_begin(); i != MCEvt->particles_end();++i)
00056 {
00057
00058
00059
00060 pad_plus = false;
00061 pad_minus = false;
00062 circ_plus = false;
00063 circ_minus = false;
00064
00065 int myId = (*i)->pdg_id();
00066
00067
00068 const HepMC::GenVertex * vertex_=(*i)->production_vertex();
00069 double xv = vertex_->position().x();
00070 double yv = vertex_->position().y();
00071 double zv = vertex_->position().z();
00072 double tv = vertex_->position().t();
00073 XYZTLorentzVector vertex = XYZTLorentzVector(xv,yv,zv,tv);
00074
00075
00076
00077
00078 XYZTLorentzVector momentum = XYZTLorentzVector(((*i)->momentum()).x(), ((*i)->momentum()).y(), ((*i)->momentum()).z(), ((*i)->momentum()).t());
00079
00080 RawParticle myMuon(-momentum, vertex/10.);
00081
00082 if ( myId < 0 )
00083 myMuon.setCharge(-1.);
00084 else
00085 myMuon.setCharge(+1.);
00086
00087 BaseParticlePropagator PP(myMuon,0.,0.,0.);
00088
00089
00090 float x0= vertex.x();
00091 float y0= vertex.y();
00092 float z0= vertex.z();
00093 float px0=momentum.x();
00094 float py0=momentum.y();
00095 float pz0=momentum.z();
00096
00097
00098
00099
00100
00101
00102 float zs = 10860.;
00103 float ys = (zs-z0)*(py0/pz0)+y0;
00104 float xs = (ys-y0)*(px0/py0)+x0;
00105
00106
00107 if(xs<0 && ys>0) {xs=-xs;}
00108 if(xs>0 && ys<0) {ys=-ys;}
00109 if(xs<0 && ys<0) {xs=-xs; ys=-ys;}
00110
00111
00112
00113 float A[2]={732.7, 24.7};
00114 float B[2]={895.3, 187.3};
00115 float C[2]={144.0, 850.2};
00116 float D[2]={69.8, 776.0};
00117 float m1=(B[1]-A[1])/(B[0]-A[0]);
00118 float m2=(C[1]-B[1])/(C[0]-B[0]);
00119 float m3=(D[1]-C[1])/(D[0]-C[0]);
00120 float m4=(A[1]-D[1])/(A[0]-D[0]);
00121 float y1=m1*(xs-A[0])+A[1];
00122 float y2=m2*(xs-B[0])+B[1];
00123 float y3=m3*(xs-C[0])+C[1];
00124 float y4=m4*(xs-D[0])+D[1];
00125
00126
00127
00128
00129
00130
00131 if(ys>y1 && ys<y2 && ys<y3 && ys>y4)
00132 {
00133 pad_plus = true;
00134
00135 }
00136
00137 if((ys<sqrt(450*450-xs*xs) && ys>sqrt(208*208-xs*xs)) || (ys<sqrt(450*450-xs*xs) && xs>208))
00138 {
00139 circ_plus = true;
00140
00141 }
00142
00143
00144
00145 zs = -10860.;
00146 ys = (zs-z0)*(py0/pz0)+y0;
00147 xs = (ys-y0)*(px0/py0)+x0;
00148
00149
00150
00151
00152 if(xs<0 && ys>0) {xs=-xs;}
00153 if(xs>0 && ys<0) {ys=-ys;}
00154 if(xs<0 && ys<0) {xs=-xs; ys=-ys;}
00155
00156
00157
00158 y1=m1*(xs-A[0])+A[1];
00159 y2=m2*(xs-B[0])+B[1];
00160 y3=m3*(xs-C[0])+C[1];
00161 y4=m4*(xs-D[0])+D[1];
00162
00163
00164
00165
00166
00167 if(ys>y1 && ys<y2 && ys<y3 && ys>y4)
00168 {
00169 pad_minus = true;
00170
00171 }
00172
00173 if((ys<sqrt(450*450-xs*xs) && ys>sqrt(208*208-xs*xs)) || (ys<sqrt(450*450-xs*xs) && xs>208))
00174 {
00175 circ_minus = true;
00176
00177 }
00178
00179
00180
00181
00182 if(trig2_==-1)
00183 {
00184 pad_plus = false;
00185 pad_minus = false;
00186 }
00187 if(trig2_==1)
00188 {
00189 circ_plus = false;
00190 circ_minus = false;
00191 }
00192
00193 if(trig_==0 && (pad_plus || circ_plus) && (pad_minus || circ_minus) )
00194 {
00195
00196 return true;
00197 }
00198 if(trig_==1 && (pad_plus || circ_plus))
00199 {
00200
00201 return true;
00202 }
00203 if(trig_==-1 && (pad_minus || circ_minus))
00204 {
00205
00206 return true;
00207 }
00208
00209 }
00210
00211 return false;
00212
00213 }
00214
00215
00216
00217 }