34 <<
"--------------------------------------------------------------------\n" 35 <<
"dRMax = " << dRMax <<
'\n' 36 <<
"dPhiMax = " << dPhiMax <<
'\n' 37 <<
"dRIntMax = " << dRIntMax <<
'\n' 38 <<
"dPhiIntMax = " << dPhiIntMax <<
'\n' 39 <<
"chi2Max = " << chi2Max <<
'\n' 40 <<
"wideSeg = " << wideSeg <<
'\n' 41 <<
"minLayersApart = " << minLayersApart << std::endl;
63 int recHits_per_layer[6] = {0,0,0,0,0,0};
65 if (rechits.size()>150){
66 return std::vector<CSCSegment>();
69 for(
unsigned int i = 0;
i < rechits.size();
i++) {
70 recHits_per_layer[rechits[
i]->cscDetId().layer()-1]++;
71 layerIndex[
i] = rechits[
i]->cscDetId().layer();
76 reverse(layerIndex.begin(), layerIndex.end());
77 reverse(rechits.begin(), rechits.end());
79 if (rechits.size() < 2) {
80 return std::vector<CSCSegment>();
100 std::vector<CSCSegment> segments;
105 bool search_disp =
false;
108 int npass = (
wideSeg > 1.)? 3 : 2;
109 for (
int ipass = 0; ipass < npass; ++ipass) {
117 if(used[i1-ib])used_rh++;
121 if(
doCollisions && search_disp &&
int(rechits.size()-used_rh)>2){
135 for(
unsigned int n_seg_min = 6u; n_seg_min > 2u + iadd; --n_seg_min){
137 std::array<BoolContainer, 120> common_used_it = {};
138 for (
unsigned int i = 0;
i < common_used_it.size();
i++) {
139 common_used_it[
i] = common_used;
142 float min_chi[120] = {9999};
144 bool first_proto_segment =
true;
148 if(used[i1-ib] || recHits_per_layer[
int(layerIndex[i1-ib])-1]>25 || (n_seg_min == 3 && used3p[i1-
ib]))
continue;
149 int layer1 = layerIndex[i1-
ib];
152 if(used[i2-ib] || recHits_per_layer[
int(layerIndex[i2-ib])-1]>25 || (n_seg_min == 3 && used3p[i2-
ib]))
continue;
153 int layer2 = layerIndex[i2-
ib];
154 if((
abs(layer2 - layer1) + 1) <
int(n_seg_min))
break;
158 if (!
addHit(h1, layer1))
continue;
159 if (!
addHit(h2, layer2))
continue;
172 if(first_proto_segment){
174 min_chi[0] = sfit_->chi2();
176 first_proto_segment =
false;
180 min_chi[common_it] = sfit_->chi2();
183 int iter = common_it;
184 for(iu = ib; iu != ie; ++iu) {
188 for(
int k = 0;
k < iter+1;
k++){
189 if(common_used_it[
k][iu-ib] ==
true){
192 for(ik = ib; ik != ie; ++ik) {
193 if(common_used_it[
k][ik-ib] ==
true){
194 common_used_it[merge_nr][ik-
ib] =
true;
195 common_used_it[
k][ik-
ib] =
false;
199 if(min_chi[
k] < min_chi[merge_nr]){
200 min_chi[merge_nr] = min_chi[
k];
201 best_proto_segment[merge_nr] = best_proto_segment[
k];
202 best_proto_segment[
k].clear();
226 for(
int j = 0;j < common_it+1; j++){
228 best_proto_segment[j].clear();
234 sfit_->localdir(), sfit_->covarianceMatrix(), sfit_->chi2());
236 segments.push_back(
temp);
261 std::vector<CSCSegment>::iterator it =segments.begin();
262 bool good_segs =
false;
263 while(it != segments.end()) {
264 if ((*it).nRecHits() > 3){
281 std::vector<CSCSegment>::iterator it =segments.begin();
282 while(it != segments.end()) {
283 if((*it).nRecHits() == 3){
284 bool found_common =
false;
285 const std::vector<CSCRecHit2D>& theseRH = (*it).specificRecHits();
287 if(used[i1-ib] && used3p[i1-ib]){
290 int sh1layer =
id.
layer();
291 int RH_centerid = sh1->
nStrips()/2;
292 int RH_centerStrip = sh1->
channels(RH_centerid);
294 std::vector<CSCRecHit2D>::const_iterator sh;
295 for(sh = theseRH.begin(); sh != theseRH.end(); ++sh){
298 int shlayer = idRH.
layer();
299 int SegRH_centerid = sh->nStrips()/2;
300 int SegRH_centerStrip = sh->channels(SegRH_centerid);
301 int SegRH_wg = sh->hitWire();
302 if(sh1layer == shlayer && SegRH_centerStrip == RH_centerStrip && SegRH_wg == RH_wg){
304 segments.erase(it,(it+1));
310 if(found_common)
break;
312 if(!found_common)++it;
337 int layer = layerIndex[
i-
ib];
339 if (layerIndex[
i-ib] == layerIndex[i1-ib] || layerIndex[
i-ib] == layerIndex[i2-ib] || used[
i-ib])
continue;
356 float maxWG_width[10] = {0, 0, 4.1, 5.69, 2.49, 5.06, 2.49, 5.06, 1.87, 5.06};
361 if(iStn == 0 || iStn == 1){
363 maxWG_width[0] = 9.25;
364 maxWG_width[1] = 9.25;
366 if (wg_num > 1 && wg_num < 48){
367 maxWG_width[0] = 3.14;
368 maxWG_width[1] = 3.14;
371 maxWG_width[0] = 10.75;
372 maxWG_width[1] = 10.75;
387 if (gp2.
perp() > ((gp1.
perp() -
dRMax*maxWG_width[iStn])*h2z)/h1z && gp2.
perp() < ((gp1.
perp() +
dRMax*maxWG_width[iStn])*h2z)/h1z){
396 float strip_width[10] = {0.003878509, 0.002958185, 0.002327105, 0.00152552, 0.00465421, 0.002327105, 0.00465421, 0.002327105, 0.00465421, 0.002327105};
406 if(err_stpos_h1>0.25*strip_width[iStn] || err_stpos_h2>0.25*strip_width[iStn])dphi_incr = 0.5*strip_width[iStn];
416 float strip_width[10] = {0.003878509, 0.002958185, 0.002327105, 0.00152552, 0.00465421, 0.002327105, 0.00465421, 0.002327105, 0.00465421, 0.002327105};
421 float err_stpos_h1 = (*(
proto_segment.begin()))->errorWithinStrip();
422 float err_stpos_h2 = (*(
proto_segment.begin()+1))->errorWithinStrip();
426 float hphi = hp.
phi();
430 float phidif = sphi-hphi;
441 float stpos = (*h).positionWithinStrip();
442 bool centr_str =
false;
443 if(iStn != 0 && iStn != 1){
444 if (stpos > -0.25 && stpos < 0.25) centr_str =
true;
446 if(err_stpos_h1<0.25*strip_width[iStn] || err_stpos_h2<0.25*strip_width[iStn] || err_stpos_h < 0.25*strip_width[iStn]){
447 dphi_incr = 0.5*strip_width[iStn];
449 if(centr_str) pos_str = 1.3;
455 float r_interpolated =
fit_r_phi(r_glob,layer);
456 float dr = fabs(r_interpolated - R);
457 float maxWG_width[10] = {0, 0, 4.1, 5.69, 2.49, 5.06, 2.49, 5.06, 1.87, 5.06};
460 if(iStn == 0 || iStn == 1){
462 maxWG_width[0] = 9.25;
463 maxWG_width[1] = 9.25;
465 if (wg_num > 1 && wg_num < 48){
466 maxWG_width[0] = 3.14;
467 maxWG_width[1] = 3.14;
470 maxWG_width[0] = 10.75;
471 maxWG_width[1] = 10.75;
478 if ( !
sfit_ )
return 0.;
483 float x = gp.
x() + (gv.
x()/gv.
z())*(z - gp.
z());
484 float y = gp.
y() + (gv.
y()/gv.
z())*(z - gp.
z());
485 float phi = atan2(y, x);
486 if (phi < 0.
f ) phi += 2. *
M_PI;
495 unsigned int iadd = ( rechitsInChamber.size() > 20)? 1 : 0;
509 for(iu = ib; iu != rechitsInChamber.end(); ++iu) {
520 ChamberHitContainer::const_iterator it;
522 if (((*it)->cscDetId().layer() == layer) && (aHit != (*it)))
543 for (
int i=1;
i<7;
i++){
544 if (
points(
i-1)== 0.)
continue;
550 float delta = 2*Sxx - Sx*Sx;
551 float intercept = (Sxx*Sy - Sx*Sxy)/delta;
552 float slope = (2*Sxy - Sx*Sy)/delta;
553 return (intercept + slope*layer);
558 ChamberHitContainer::const_iterator iRH_worst;
565 buffer.reserve(init_size);
567 ChamberHitContainer::iterator
min;
573 if(kLayer < min_layer){
578 buffer.push_back(*min);
583 for (ChamberHitContainer::const_iterator
cand = buffer.begin();
cand != buffer.end();
cand++) {
590 int kRing = idRH.
ring();
594 int centerid = iRHp->
nStrips()/2;
595 int centerStrip = iRHp->
channels(centerid);
596 float stpos = (*iRHp).positionWithinStrip();
597 se(kLayer-1) = (*iRHp).errorWithinStrip();
599 if (kStation == 1 && (kRing == 1 || kRing == 4)) sp(kLayer-1) = stpos + centerStrip;
601 if (kLayer == 1 || kLayer == 3 || kLayer == 5) sp(kLayer-1) = stpos + centerStrip;
602 if (kLayer == 2 || kLayer == 4 || kLayer == 6) sp(kLayer-1) = stpos - 0.5 + centerStrip;
606 fitX(sp, se, -1, -1, chi2_str);
616 ChamberHitContainer::const_iterator rh_to_be_deleted_1;
617 ChamberHitContainer::const_iterator rh_to_be_deleted_2;
623 int z1 = idRH1.
layer();
625 for (ChamberHitContainer::const_iterator i2 = i1+1; i2 !=
proto_segment.end(); ++i2) {
629 int z2 = idRH2.
layer();
633 if (ir == i1 || ir == i2)
continue;
638 int worst_layer = idRH.
layer();
642 if (
i == i1 ||
i == i2 ||
i == ir)
continue;
643 float slope = (sp(z2-1)-sp(z1-1))/(z2-z1);
644 float intersept = sp(z1-1) - slope*z1;
647 float di = fabs(sp(z-1) - intersept - slope*z);
652 bad_layer = worst_layer;
654 rh_to_be_deleted_1 = ir;
659 fitX(sp, se, bad_layer, -1, chi2_str);
665 if (iworst > -1 && (nhits-1) > n_seg_min && (chi2_str) >
chi2_str_*chi2D_iadd){
674 int z1 = idRH1.
layer();
676 for ( ChamberHitContainer::const_iterator i2 = i1+1; i2 !=
proto_segment.end(); ++i2) {
680 int z2 = idRH2.
layer();
685 if (ir == i1 || ir == i2 )
continue;
688 int worst_layer = idRH.
layer();
691 if (ir2 == i1 || ir2 == i2 || ir2 ==ir )
continue;
696 int worst_layer2 = idRH.
layer();
700 if (
i == i1 ||
i == i2 ||
i == ir||
i == ir2 )
continue;
701 float slope = (sp(z2-1)-sp(z1-1))/(z2-z1);
702 float intersept = sp(z1-1) - slope*z1;
705 float di = fabs(sp(z-1) - intersept - slope*z);
712 bad_layer = worst_layer;
713 bad_layer2 = worst_layer2;
714 rh_to_be_deleted_1 = ir;
715 rh_to_be_deleted_2 = ir2;
721 fitX(sp, se, bad_layer ,bad_layer2, chi2_str);
727 if( iworst2-1 >= 0 && iworst2 <=
int(
proto_segment.size()) ) {
742 for (
int i=1;
i<7;
i++){
743 if (
i == ir ||
i == ir2 ||
points(
i-1) == 0.)
continue;
747 Sy = Sy + (
points(
i-1)/sigma2);
748 Sx = Sx + ((i1)/sigma2);
749 Sxx = Sxx + (i1*i1)/sigma2;
750 Sxy = Sxy + (((i1)*
points(
i-1))/sigma2);
752 float delta = S*Sxx - Sx*Sx;
753 float intercept = (Sxx*Sy - Sx*Sxy)/delta;
754 float slope = (S*Sxy - Sx*Sy)/delta;
758 for (
int i=1;
i<7;
i++){
759 if (
i == ir ||
i == ir2 ||
points(
i-1) == 0.)
continue;
761 chi2_str = chi2_str + chi_str*chi_str;
763 return (intercept + slope*0);
770 if ((*it)->cscDetId().layer() == layer)
777 ChamberHitContainer::const_iterator it;
779 if ((*it)->cscDetId().layer() == layer)
789 std::unique_ptr<CSCSegFit> oldfit;
796 if ( (
sfit_->chi2() >= oldfit->chi2() ) || !ok ) {
805 std::unique_ptr<CSCSegFit> oldfit;
T getParameter(std::string const &) const
bool areHitsCloseInR(const CSCRecHit2D *h1, const CSCRecHit2D *h2) const
Utility functions.
CSCDetId cscDetId() const
ROOT::Math::SVector< double, 6 > SVector6
Typedefs.
void flagHitsAsUsed(const ChamberHitContainer &rechitsInChamber, BoolContainer &used) const
std::vector< const CSCRecHit2D * >::const_iterator ChamberHitContainerCIt
static const double slope[3]
GlobalPoint toGlobal(const Local2DPoint &lp) const
Conversion to the global R.F. from the R.F. of the GeomDet.
Geom::Phi< T > phi() const
bool isSegmentGood(const ChamberHitContainer &rechitsInChamber) const
void updateParameters(void)
std::vector< CSCSegment > run(const CSCChamber *aChamber, const ChamberHitContainer &rechits)
bool isHitNearSegment(const CSCRecHit2D *h) const
int channels(unsigned int i) const
Extracting strip channel numbers comprising the rechit - low.
const Surface::PositionType & position() const
The position (origin of the R.F.)
bool replaceHit(const CSCRecHit2D *h, int layer)
ChamberHitContainer proto_segment
float fit_r_phi(SVector6 points, int layer) const
std::vector< CSCSegment > buildSegments(const ChamberHitContainer &rechits)
const CSCChamber * theChamber
unsigned int nStrips() const
Abs< T >::type abs(const T &t)
void tryAddingHitsToSegment(const ChamberHitContainer &rechitsInChamber, const BoolContainer &used, const LayerIndex &layerIndex, const ChamberHitContainerCIt i1, const ChamberHitContainerCIt i2)
const CSCLayer * layer(CSCDetId id) const
Return the layer corresponding to the given id.
void compareProtoSegment(const CSCRecHit2D *h, int layer)
static const std::string kLayer("layer")
CSCSegAlgoRU(const edm::ParameterSet &ps)
Constructor.
std::vector< const CSCRecHit2D * > ChamberHitContainer
std::vector< bool > BoolContainer
std::vector< int > LayerIndex
float phiAtZ(float z) const
unsigned short iChamberType()
bool areHitsCloseInGlobalPhi(const CSCRecHit2D *h1, const CSCRecHit2D *h2) const
float fitX(SVector6 points, SVector6 errors, int ir, int ir2, float &chi2_str)
bool hasHitOnLayer(int layer) const
double S(const TLorentzVector &, const TLorentzVector &)
short int hitWire() const
L1A.
void baseline(int n_seg_min)
float errorWithinStrip() const
The uncertainty of the estimated position within the strip.
LocalPoint localPosition() const
bool addHit(const CSCRecHit2D *hit, int layer)
Utility functions.
std::unique_ptr< CSCSegFit > sfit_
void increaseProtoSegment(const CSCRecHit2D *h, int layer, int chi2_factor)