101 LogTrace(
"CSCSegAlgoST") <<
"[CSCSegAlgoST::run] build segments in chamber " <<
theChamber->
id();
104 std::vector<CSCSegment> segments_temp;
105 std::vector<CSCSegment> segments;
106 std::vector<ChamberHitContainer> rechits_clusters;
111 for(
int a = 0;
a<5; ++
a) {
112 for(
int b = 0;
b<5; ++
b) {
142 for(std::vector<ChamberHitContainer>::iterator sub_rechits = rechits_clusters.begin(); sub_rechits != rechits_clusters.end(); ++sub_rechits ) {
144 segments_temp.clear();
148 segments.insert( segments.end(), segments_temp.begin(), segments_temp.end() );
152 segments_temp.clear();
155 segments.swap(segments_temp);
168 segments_temp.clear();
171 segments.swap(segments_temp);
195 std::vector<CSCSegment> segments_temp;
196 std::vector<ChamberHitContainer> rechits_clusters;
198 const float chi2ndfProbMin = 1.0e-4;
202 int hit_nr_worst = -1;
205 for(std::vector<CSCSegment>::iterator it=segments.begin(); it != segments.end(); ++it) {
210 if( !use_brute_force ) {
212 float chisq = (*it).chi2();
213 int nhits = (*it).nRecHits();
220 globZ = globalPosition.
z();
226 std::vector<CSCRecHit2D> theseRecHits = (*it).specificRecHits();
227 std::vector<CSCRecHit2D>::const_iterator iRH_worst;
230 float xdist_local_worst_sig = -99999.;
231 float xdist_local_2ndworst_sig = -99999.;
232 float xdist_local_sig = -99999.;
238 for ( std::vector<CSCRecHit2D>::const_iterator iRH = theseRecHits.begin(); iRH != theseRecHits.end(); ++iRH) {
243 float loc_x_at_target ;
248 loc_x_at_target = 0.;
255 LocalPoint localPositionRH = (*iRH).localPosition();
258 LocalError rerrlocal = (*iRH).localPositionError();
259 float xxerr = rerrlocal.
xx();
261 float target_z = globalPositionRH.
z();
264 loc_x_at_target = localPos.
x() + (segDir.
x()/fabs(segDir.
z())*( target_z - globZ ));
269 loc_x_at_target = localPos.
x() + ((-1)*segDir.
x()/fabs(segDir.
z())*( target_z - globZ ));
276 xdist_local_sig = fabs((localPositionRH.
x() -loc_x_at_target)/(xxerr));
278 if( xdist_local_sig > xdist_local_worst_sig ) {
279 xdist_local_2ndworst_sig = xdist_local_worst_sig;
280 xdist_local_worst_sig = xdist_local_sig;
283 hit_nr_worst = hit_nr;
285 else if(xdist_local_sig > xdist_local_2ndworst_sig) {
286 xdist_local_2ndworst_sig = xdist_local_sig;
295 if ( xdist_local_worst_sig / xdist_local_2ndworst_sig < 1.5 ) {
305 std::vector< CSCRecHit2D > buffer;
306 std::vector< std::vector< CSCRecHit2D > > reduced_segments;
307 std::vector< CSCRecHit2D > theseRecHits = (*it).specificRecHits();
308 float best_red_seg_prob = 0.0;
312 if(
ChiSquaredProbability((
double)(*it).chi2(),(double)((2*(*it).nRecHits())-4)) < chi2ndfProbMin ) {
314 buffer = theseRecHits;
318 if( use_brute_force ) {
319 for(
size_t bi = 0; bi < buffer.size(); ++bi) {
320 reduced_segments.push_back(buffer);
321 reduced_segments[bi].erase(reduced_segments[bi].
begin()+(bi),reduced_segments[bi].
begin()+(bi+1));
326 if( hit_nr_worst >= 0 && hit_nr_worst <=
int(buffer.size()) ) {
328 buffer.erase(buffer.begin()+(hit_nr_worst),buffer.begin()+(hit_nr_worst+1));
329 reduced_segments.push_back(buffer);
333 reduced_segments.push_back(buffer);
339 for(
size_t iSegment=0; iSegment<reduced_segments.size(); ++iSegment) {
342 for(
size_t m = 0;
m<reduced_segments[iSegment].size(); ++
m ) {
403 std::vector<ChamberHitContainer> rechits_clusters;
409 float dXclus_box = 0.0;
410 float dYclus_box = 0.0;
412 std::vector<const CSCRecHit2D*>
temp;
414 std::vector< ChamberHitContainer > seeds;
416 std::vector<float> running_meanX;
417 std::vector<float> running_meanY;
419 std::vector<float> seed_minX;
420 std::vector<float> seed_maxX;
421 std::vector<float> seed_minY;
422 std::vector<float> seed_maxY;
431 for(
unsigned int i = 0;
i < rechits.size(); ++
i) {
435 temp.push_back(rechits[
i]);
437 seeds.push_back(temp);
442 running_meanX.push_back( rechits[i]->localPosition().
x() );
443 running_meanY.push_back( rechits[i]->localPosition().
y() );
446 seed_minX.push_back( rechits[i]->localPosition().
x() );
447 seed_maxX.push_back( rechits[i]->localPosition().
x() );
448 seed_minY.push_back( rechits[i]->localPosition().
y() );
449 seed_maxY.push_back( rechits[i]->localPosition().
y() );
454 for(
size_t NNN = 0; NNN < seeds.size(); ++NNN) {
456 for(
size_t MMM = NNN+1; MMM < seeds.size(); ++MMM) {
457 if(running_meanX[MMM] == 999999. || running_meanX[NNN] == 999999. ) {
458 LogDebug(
"CSCSegment|CSC") <<
"CSCSegmentST::clusterHits: Warning: Skipping used seeds, this should happen - inform developers!";
468 if ( running_meanX[NNN] > running_meanX[MMM] ) dXclus_box = seed_minX[NNN] - seed_maxX[MMM];
469 else dXclus_box = seed_minX[MMM] - seed_maxX[NNN];
470 if ( running_meanY[NNN] > running_meanY[MMM] ) dYclus_box = seed_minY[NNN] - seed_maxY[MMM];
471 else dYclus_box = seed_minY[MMM] - seed_maxY[NNN];
479 running_meanX[MMM] = (running_meanX[NNN]*seeds[NNN].size() + running_meanX[MMM]*seeds[MMM].size()) / (seeds[NNN].
size()+seeds[MMM].size());
480 running_meanY[MMM] = (running_meanY[NNN]*seeds[NNN].size() + running_meanY[MMM]*seeds[MMM].size()) / (seeds[NNN].
size()+seeds[MMM].size());
483 if ( seed_minX[NNN] <= seed_minX[MMM] ) seed_minX[MMM] = seed_minX[NNN];
484 if ( seed_maxX[NNN] > seed_maxX[MMM] ) seed_maxX[MMM] = seed_maxX[NNN];
485 if ( seed_minY[NNN] <= seed_minY[MMM] ) seed_minY[MMM] = seed_minY[NNN];
486 if ( seed_maxY[NNN] > seed_maxY[MMM] ) seed_maxY[MMM] = seed_maxY[NNN];
489 seeds[MMM].insert(seeds[MMM].
end(),seeds[NNN].
begin(),seeds[NNN].
end());
492 running_meanX[NNN] = 999999.;
493 running_meanY[NNN] = 999999.;
505 for(
size_t NNN = 0; NNN < seeds.size(); ++NNN) {
506 if(running_meanX[NNN] == 999999.)
continue;
507 rechits_clusters.push_back(seeds[NNN]);
512 return rechits_clusters;
518 std::vector<ChamberHitContainer> rechits_chains;
521 std::vector<const CSCRecHit2D*>
temp;
523 std::vector< ChamberHitContainer > seeds;
525 std::vector <bool> usedCluster;
531 for(
unsigned int i = 0;
i < rechits.size(); ++
i) {
533 temp.push_back(rechits[
i]);
534 seeds.push_back(temp);
535 usedCluster.push_back(
false);
538 bool gangedME11a =
false;
544 for(
size_t NNN = 0; NNN < seeds.size(); ++NNN) {
545 for(
size_t MMM = NNN+1; MMM < seeds.size(); ++MMM) {
546 if(usedCluster[MMM] || usedCluster[NNN]){
560 bool goodToMerge =
isGoodToMerge(gangedME11a, seeds[NNN], seeds[MMM]);
566 seeds[MMM].insert(seeds[MMM].
end(),seeds[NNN].
begin(),seeds[NNN].
end());
569 usedCluster[NNN] =
true;
582 for(
size_t NNN = 0; NNN < seeds.size(); ++NNN) {
583 if(usedCluster[NNN])
continue;
584 rechits_chains.push_back(seeds[NNN]);
589 return rechits_chains;
593 for(
size_t iRH_new = 0;iRH_new<newChain.size();++iRH_new){
594 int layer_new = newChain[iRH_new]->cscDetId().layer()-1;
595 int middleStrip_new = newChain[iRH_new]->nStrips()/2;
596 int centralStrip_new = newChain[iRH_new]->channels(middleStrip_new);
597 int centralWire_new = newChain[iRH_new]->hitWire();
598 bool layerRequirementOK =
false;
599 bool stripRequirementOK =
false;
600 bool wireRequirementOK =
false;
601 bool goodToMerge =
false;
602 for(
size_t iRH_old = 0;iRH_old<oldChain.size();++iRH_old){
603 int layer_old = oldChain[iRH_old]->cscDetId().layer()-1;
604 int middleStrip_old = oldChain[iRH_old]->nStrips()/2;
605 int centralStrip_old = oldChain[iRH_old]->channels(middleStrip_old);
606 int centralWire_old = oldChain[iRH_old]->hitWire();
615 if(layer_new==layer_old+1 || layer_new==layer_old-1 ||
616 layer_new==layer_old+2 || layer_new==layer_old-2 ||
617 layer_new==layer_old+3 || layer_new==layer_old-3 ||
618 layer_new==layer_old+4 || layer_new==layer_old-4 ){
619 layerRequirementOK =
true;
625 if(centralStrip_new==centralStrip_old ||
626 centralStrip_new==centralStrip_old+1 || centralStrip_new==centralStrip_old-1 ||
627 centralStrip_new==centralStrip_old+2 || centralStrip_new==centralStrip_old-2){
628 stripRequirementOK =
true;
631 if(centralWire_new==centralWire_old ||
632 centralWire_new==centralWire_old+1 || centralWire_new==centralWire_old-1 ||
633 centralWire_new==centralWire_old+2 || centralWire_new==centralWire_old-2){
634 wireRequirementOK =
true;
638 if(centralStrip_new==centralStrip_old+1-allStrips || centralStrip_new==centralStrip_old-1-allStrips ||
639 centralStrip_new==centralStrip_old+2-allStrips || centralStrip_new==centralStrip_old-2-allStrips ||
640 centralStrip_new==centralStrip_old+1+allStrips || centralStrip_new==centralStrip_old-1+allStrips ||
641 centralStrip_new==centralStrip_old+2+allStrips || centralStrip_new==centralStrip_old-2+allStrips){
642 stripRequirementOK =
true;
645 if(layerRequirementOK && stripRequirementOK && wireRequirementOK){
657 double CSCSegAlgoST::theWeight(
double coordinate_1,
double coordinate_2,
double coordinate_3,
float layer_1,
float layer_2,
float layer_3) {
658 double sub_weight = 0;
660 ( (coordinate_2 - coordinate_3) / (layer_2 - layer_3) ) -
661 ( (coordinate_1 - coordinate_2) / (layer_1 - layer_2) )
673 std::vector<CSCSegment> segmentInChamber;
674 segmentInChamber.clear();
677 unsigned int thering = 999;
678 unsigned int thestation = 999;
681 std::vector<int> hits_onLayerNumber(6);
686 for(
int iarray = 0; iarray <6; ++iarray) {
688 hits_onLayerNumber[iarray] = 0;
731 int midlayer_pointer[6] = {0,0,2,3,3,4};
734 int n_layers_occupied_tot = 0;
735 int n_layers_processed = 0;
737 float min_weight_A = 99999.9;
738 float min_weight_noLx_A = 99999.9;
747 int best_noLx_pseg = -1;
748 int best_Layer_noLx = -1;
761 for(
size_t M = 0; M < rechits.size(); ++M) {
763 hits_onLayerNumber[ rechits[M]->cscDetId().layer()-1 ] += 1;
764 if(hits_onLayerNumber[ rechits[M]->cscDetId().layer()-1 ] == 1 ) n_layers_occupied_tot += 1;
766 PAhits_onLayer[rechits[M]->cscDetId().layer()-1] .push_back(rechits[M]);
777 for(
size_t i = 0;
i< hits_onLayerNumber.size(); ++
i){
779 tothits += hits_onLayerNumber[
i];
780 if (hits_onLayerNumber[
i] > maxhits) {
781 nextlayer = maxlayer;
784 maxhits = hits_onLayerNumber[
i];
786 else if (hits_onLayerNumber[
i] > nexthits) {
788 nexthits = hits_onLayerNumber[
i];
793 if (tothits > (
int)UpperLimit) {
794 if (n_layers_occupied_tot > 4) {
795 tothits = tothits - hits_onLayerNumber[maxlayer];
796 n_layers_occupied_tot = n_layers_occupied_tot - 1;
798 hits_onLayerNumber[maxlayer] = 0;
802 if (tothits > (
int)UpperLimit) {
803 if (n_layers_occupied_tot > 4) {
804 tothits = tothits - hits_onLayerNumber[nextlayer];
805 n_layers_occupied_tot = n_layers_occupied_tot - 1;
807 hits_onLayerNumber[nextlayer] = 0;
811 if (tothits > (
int)UpperLimit){
820 if ( segShower.
nRecHits() < 3 )
return segmentInChamber;
821 if ( segShower.
chi2() == -1 )
return segmentInChamber;
823 segmentInChamber.push_back(segShower);
824 return segmentInChamber;
827 LogDebug(
"CSCSegment|CSC") <<
"Number of rechits in the cluster/chamber > "<< UpperLimit<<
828 " ... Segment finding in the cluster/chamber canceled!";
831 return segmentInChamber;
838 if( rechits.size() > 0 ) {
839 thering = rechits[0]->cscDetId().ring();
840 thestation = rechits[0]->cscDetId().station();
848 return segmentInChamber;
855 for(
int layer = 0; layer < 6; ++layer) {
865 n_layers_processed += 1;
869 int orig_number_of_psegs =
Psegments.size();
881 if( orig_number_of_psegs == 0 ) {
919 if( orig_number_of_noL1_psegs == 0 ) {
940 for(
int pseg = 0; pseg < orig_number_of_psegs; ++pseg ) {
942 int pseg_pos = (pseg)+((
hit)*orig_number_of_psegs);
943 int pseg_noL1_pos = (pseg)+((
hit)*orig_number_of_noL1_psegs);
944 int pseg_noL2_pos = (pseg)+((
hit)*orig_number_of_noL2_psegs);
945 int pseg_noL3_pos = (pseg)+((
hit)*orig_number_of_noL3_psegs);
946 int pseg_noL4_pos = (pseg)+((
hit)*orig_number_of_noL4_psegs);
947 int pseg_noL5_pos = (pseg)+((
hit)*orig_number_of_noL5_psegs);
948 int pseg_noL6_pos = (pseg)+((
hit)*orig_number_of_noL6_psegs);
974 if (n_layers_processed != 2 && pseg < orig_number_of_noL1_psegs)
curv_noL1_A.push_back(
curv_noL1_A[ pseg_noL1_pos ]);
975 if (n_layers_processed != 2 && pseg < orig_number_of_noL2_psegs)
curv_noL2_A.push_back(
curv_noL2_A[ pseg_noL2_pos ]);
976 if (n_layers_processed != 3 && pseg < orig_number_of_noL3_psegs)
curv_noL3_A.push_back(
curv_noL3_A[ pseg_noL3_pos ]);
977 if (n_layers_processed != 4 && pseg < orig_number_of_noL4_psegs)
curv_noL4_A.push_back(
curv_noL4_A[ pseg_noL4_pos ]);
978 if (n_layers_processed != 5 && pseg < orig_number_of_noL5_psegs)
curv_noL5_A.push_back(
curv_noL5_A[ pseg_noL5_pos ]);
979 if (n_layers_processed != 6 && pseg < orig_number_of_noL6_psegs)
curv_noL6_A.push_back(
curv_noL6_A[ pseg_noL6_pos ]);
991 if (n_layers_processed != 2 && pseg < orig_number_of_noL1_psegs)
Psegments_noL1[ pseg_noL1_pos ].push_back(
PAhits_onLayer[ layer ][ hit ]);
992 if (n_layers_processed != 2 && pseg < orig_number_of_noL2_psegs)
Psegments_noL2[ pseg_noL2_pos ].push_back(
PAhits_onLayer[ layer ][ hit ]);
993 if (n_layers_processed != 3 && pseg < orig_number_of_noL3_psegs)
Psegments_noL3[ pseg_noL3_pos ].push_back(
PAhits_onLayer[ layer ][ hit ]);
994 if (n_layers_processed != 4 && pseg < orig_number_of_noL4_psegs)
Psegments_noL4[ pseg_noL4_pos ].push_back(
PAhits_onLayer[ layer ][ hit ]);
995 if (n_layers_processed != 5 && pseg < orig_number_of_noL5_psegs)
Psegments_noL5[ pseg_noL5_pos ].push_back(
PAhits_onLayer[ layer ][ hit ]);
996 if (n_layers_processed != 6 && pseg < orig_number_of_noL6_psegs)
Psegments_noL6[ pseg_noL6_pos ].push_back(
PAhits_onLayer[ layer ][ hit ]);
1009 float((*(
Psegments[ pseg_pos ].
end()-1))->cscDetId().layer()),
1010 float((*(
Psegments[ pseg_pos ].
end()-2))->cscDetId().layer()),
1011 float((*(
Psegments[ pseg_pos ].
end()-3))->cscDetId().layer())
1018 float((*(
Psegments[ pseg_pos ].
end()-1))->cscDetId().layer()),
1019 float((*(
Psegments[ pseg_pos ].
end()-2))->cscDetId().layer()),
1020 float((*(
Psegments[ pseg_pos ].
end()-3))->cscDetId().layer())
1025 if(
int(
Psegments[ pseg_pos ].
size()) == n_layers_occupied_tot) {
1029 (*(
Psegments[ pseg_pos ].
end()-midlayer_pointer[n_layers_occupied_tot-1] ))->localPosition().
x(),
1030 (*(
Psegments[ pseg_pos ].
end()-n_layers_occupied_tot ))->localPosition().
x(),
1031 float((*(
Psegments[ pseg_pos ].
end()-1))->cscDetId().layer()),
1032 float((*(
Psegments[ pseg_pos ].
end()-midlayer_pointer[n_layers_occupied_tot-1] ))->cscDetId().layer()),
1033 float((*(
Psegments[ pseg_pos ].
end()-n_layers_occupied_tot ))->cscDetId().layer())
1040 if (
weight_A[ pseg_pos ] < min_weight_A ) {
1041 min_weight_A =
weight_A[ pseg_pos ];
1044 best_pseg = pseg_pos ;
1054 if ( n_layers_occupied_tot > 3 ) {
1055 if (pseg < orig_number_of_noL1_psegs && (n_layers_processed != 2)) {
1085 (*(
Psegments_noL1[ pseg_noL1_pos ].
end()-midlayer_pointer[n_layers_occupied_tot-2] ))->localPosition().
x(),
1086 (*(
Psegments_noL1[ pseg_noL1_pos ].
end()-(n_layers_occupied_tot-1) ))->localPosition().
x(),
1088 float((*(
Psegments_noL1[ pseg_noL1_pos ].
end()-midlayer_pointer[n_layers_occupied_tot-2] ))->cscDetId().layer()),
1089 float((*(
Psegments_noL1[ pseg_noL1_pos ].
end()-(n_layers_occupied_tot-1) ))->cscDetId().layer())
1101 best_noLx_pseg = pseg_noL1_pos;
1102 best_Layer_noLx = 1;
1114 if ( n_layers_occupied_tot > 3 ) {
1115 if (pseg < orig_number_of_noL2_psegs && ( n_layers_processed != 2 )) {
1145 (*(
Psegments_noL2[ pseg_noL2_pos ].
end()-midlayer_pointer[n_layers_occupied_tot-2] ))->localPosition().
x(),
1146 (*(
Psegments_noL2[ pseg_noL2_pos ].
end()-(n_layers_occupied_tot-1) ))->localPosition().
x(),
1148 float((*(
Psegments_noL2[ pseg_noL2_pos ].
end()-midlayer_pointer[n_layers_occupied_tot-2] ))->cscDetId().layer()),
1149 float((*(
Psegments_noL2[ pseg_noL2_pos ].
end()-(n_layers_occupied_tot-1) ))->cscDetId().layer())
1161 best_noLx_pseg = pseg_noL2_pos;
1162 best_Layer_noLx = 2;
1174 if ( n_layers_occupied_tot > 3 ) {
1175 if (pseg < orig_number_of_noL3_psegs && ( n_layers_processed != 3 )) {
1205 (*(
Psegments_noL3[ pseg_noL3_pos ].
end()-midlayer_pointer[n_layers_occupied_tot-2] ))->localPosition().
x(),
1206 (*(
Psegments_noL3[ pseg_noL3_pos ].
end()-(n_layers_occupied_tot-1) ))->localPosition().
x(),
1208 float((*(
Psegments_noL3[ pseg_noL3_pos ].
end()-midlayer_pointer[n_layers_occupied_tot-2] ))->cscDetId().layer()),
1209 float((*(
Psegments_noL3[ pseg_noL3_pos ].
end()-(n_layers_occupied_tot-1) ))->cscDetId().layer())
1221 best_noLx_pseg = pseg_noL3_pos;
1222 best_Layer_noLx = 3;
1234 if ( n_layers_occupied_tot > 3 ) {
1235 if (pseg < orig_number_of_noL4_psegs && ( n_layers_processed != 4 )) {
1265 (*(
Psegments_noL4[ pseg_noL4_pos ].
end()-midlayer_pointer[n_layers_occupied_tot-2] ))->localPosition().
x(),
1266 (*(
Psegments_noL4[ pseg_noL4_pos ].
end()-(n_layers_occupied_tot-1) ))->localPosition().
x(),
1268 float((*(
Psegments_noL4[ pseg_noL4_pos ].
end()-midlayer_pointer[n_layers_occupied_tot-2] ))->cscDetId().layer()),
1269 float((*(
Psegments_noL4[ pseg_noL4_pos ].
end()-(n_layers_occupied_tot-1) ))->cscDetId().layer())
1281 best_noLx_pseg = pseg_noL4_pos;
1282 best_Layer_noLx = 4;
1294 if ( n_layers_occupied_tot > 4 ) {
1295 if (pseg < orig_number_of_noL5_psegs && ( n_layers_processed != 5 )) {
1325 (*(
Psegments_noL5[ pseg_noL5_pos ].
end()-midlayer_pointer[n_layers_occupied_tot-2] ))->localPosition().
x(),
1326 (*(
Psegments_noL5[ pseg_noL5_pos ].
end()-(n_layers_occupied_tot-1) ))->localPosition().
x(),
1328 float((*(
Psegments_noL5[ pseg_noL5_pos ].
end()-midlayer_pointer[n_layers_occupied_tot-2] ))->cscDetId().layer()),
1329 float((*(
Psegments_noL5[ pseg_noL5_pos ].
end()-(n_layers_occupied_tot-1) ))->cscDetId().layer())
1341 best_noLx_pseg = pseg_noL5_pos;
1342 best_Layer_noLx = 5;
1354 if ( n_layers_occupied_tot > 5 ) {
1355 if (pseg < orig_number_of_noL6_psegs && ( n_layers_processed != 6 )) {
1385 (*(
Psegments_noL6[ pseg_noL6_pos ].
end()-midlayer_pointer[n_layers_occupied_tot-2] ))->localPosition().
x(),
1386 (*(
Psegments_noL6[ pseg_noL6_pos ].
end()-(n_layers_occupied_tot-1) ))->localPosition().
x(),
1388 float((*(
Psegments_noL6[ pseg_noL6_pos ].
end()-midlayer_pointer[n_layers_occupied_tot-2] ))->cscDetId().layer()),
1389 float((*(
Psegments_noL6[ pseg_noL6_pos ].
end()-(n_layers_occupied_tot-1) ))->cscDetId().layer())
1401 best_noLx_pseg = pseg_noL6_pos;
1402 best_Layer_noLx = 6;
1438 int chosen_pseg = best_pseg;
1440 return segmentInChamber;
1445 float hit_drop_limit = -999999.999;
1448 switch ( n_layers_processed ) {
1460 if ((best_Layer_noLx < 1) || (best_Layer_noLx > 4)) {
1463 if ((best_Layer_noLx == 2) || (best_Layer_noLx == 3)) hit_drop_limit = hit_drop_limit * (1./2.);
1467 if ((best_Layer_noLx < 1) || (best_Layer_noLx > 5)) {
1470 if ((best_Layer_noLx == 2) || (best_Layer_noLx == 4)) hit_drop_limit = hit_drop_limit * (1./2.);
1471 if (best_Layer_noLx == 3) hit_drop_limit = hit_drop_limit * (1./3.);
1475 if ((best_Layer_noLx < 1) || (best_Layer_noLx > 6)) {
1478 if ((best_Layer_noLx == 2) || (best_Layer_noLx == 5)) hit_drop_limit = hit_drop_limit * (1./2.);
1479 if ((best_Layer_noLx == 3) || (best_Layer_noLx == 4)) hit_drop_limit = hit_drop_limit * (1./3.);
1484 LogDebug(
"CSCSegment|CSC") <<
"CSCSegAlgoST: Unexpected number of layers with hits - please inform developers.";
1486 hit_drop_limit = 0.1;
1490 switch ( best_Layer_noLx ) {
1534 if( min_weight_A > 0. ) {
1535 if ( min_weight_noLx_A/min_weight_A < hit_drop_limit ) {
1540 chosen_pseg = best_noLx_pseg;
1555 for(
unsigned int iSegment=0; iSegment<
GoodSegments.size();++iSegment){
1576 LogDebug(
"CSCSegment|segmWierd") <<
"Wierd segment, ErrXX scaled, refit " <<std::endl;
1583 LogDebug(
"CSCSegment|segmWierd") <<
"Wierd segment, ErrXY changed to match cond. number, refit " << std::endl;
1595 LogDebug(
"CSCSegment|segmWierd") <<
"Scale factor protoChiUCorrection too big, pre-Prune, refit " << std::endl;
1611 LogTrace(
"CSCSegAlgoST") <<
"[CSCSegAlgoST::buildSegments] protosegment\n " <<
temp;
1613 segmentInChamber.push_back(temp);
1615 return segmentInChamber;
1626 int SumCommonHits = 0;
1628 int nr_remaining_candidates;
1629 unsigned int nr_of_segment_candidates;
1631 nr_remaining_candidates = nr_of_segment_candidates = chosen_segments.size();
1634 GoodSegments.push_back( chosen_segments[ chosen_seg ] );
1636 float chosen_weight_temp = 999999.;
1637 int chosen_seg_temp = -1;
1640 while( nr_remaining_candidates > 0 ) {
1642 for(
unsigned int iCand=0; iCand < nr_of_segment_candidates; ++iCand) {
1644 if( chosen_weight[iCand] < 0. )
continue;
1647 for(
int ihits = 0; ihits < int(chosen_segments[iCand].
size()); ++ihits ) {
1648 if( chosen_segments[iCand][ihits] == chosen_segments[chosen_seg][ihits]) {
1654 if(SumCommonHits>1) {
1655 chosen_weight[iCand] = -1.;
1656 nr_remaining_candidates -= 1;
1660 if( chosen_weight[ iCand ] < chosen_weight_temp ) {
1661 chosen_weight_temp = chosen_weight[ iCand ];
1662 chosen_seg_temp = iCand ;
1667 if( chosen_seg_temp > -1 )
GoodSegments.push_back( chosen_segments[ chosen_seg_temp ] );
1669 chosen_seg = chosen_seg_temp;
1671 chosen_weight_temp = 999999;
1672 chosen_seg_temp = -1;
1678 std::vector <unsigned int> BadCandidate;
1679 int SumCommonHits =0;
1681 BadCandidate.clear();
1682 for(
unsigned int iCand=0;iCand<
Psegments.size();++iCand) {
1684 for(
unsigned int iiCand=iCand+1;iiCand<
Psegments.size();++iiCand){
1688 LogDebug(
"CSCSegment|CSC") <<
"CSCSegmentST::ChooseSegments2: ALARM!! THIS should not happen!!";
1692 for(
int ihits = 0; ihits < int(
Psegments[iCand].
size()); ++ihits ) {
1698 if(SumCommonHits>1) {
1700 BadCandidate.push_back(iCand);
1704 BadCandidate.push_back(iiCand);
1711 for(
unsigned int isegm=0;isegm<
Psegments.size();++isegm) {
1715 for(
unsigned int ibad=0;ibad<BadCandidate.size();++ibad) {
1717 if(isegm == BadCandidate[ibad]) {
1744 LogDebug(
"CSCSegment|segmWierd") <<
"e_Cxx.size()!=protoSegment.size() IT IS A SERIOUS PROBLEM!!! " <<std::endl;
1747 CLHEP::HepMatrix M(4,4,0);
1748 CLHEP::HepVector
B(4,0);
1749 ChamberHitContainer::const_iterator ih =
protoSegment.begin();
1760 CLHEP::HepMatrix IC(2,2);
1779 LogDebug(
"CSCSegment|CSC") <<
"CSCSegment::fitSlopes: failed to invert covariance matrix=\n" << IC;
1785 M(1,3) += IC(1,1) *
z;
1786 M(1,4) += IC(1,2) *
z;
1787 B(1) += u * IC(1,1) + v * IC(1,2);
1791 M(2,3) += IC(2,1) *
z;
1792 M(2,4) += IC(2,2) *
z;
1793 B(2) += u * IC(2,1) + v * IC(2,2);
1795 M(3,1) += IC(1,1) *
z;
1796 M(3,2) += IC(1,2) *
z;
1797 M(3,3) += IC(1,1) * z *
z;
1798 M(3,4) += IC(1,2) * z *
z;
1799 B(3) += ( u * IC(1,1) + v * IC(1,2) ) * z;
1801 M(4,1) += IC(2,1) *
z;
1802 M(4,2) += IC(2,2) *
z;
1803 M(4,3) += IC(2,1) * z *
z;
1804 M(4,4) += IC(2,2) * z *
z;
1805 B(4) += ( u * IC(2,1) + v * IC(2,2) ) * z;
1807 CLHEP::HepVector
p = solve(M, B);
1824 ChamberHitContainer::const_iterator ih;
1839 CLHEP::HepMatrix IC(2,2);
1859 LogDebug(
"CSCSegment|CSC") <<
"CSCSegment::fillChiSquared: failed to invert covariance matrix=\n" << IC;
1864 chsq += du*du*IC(1,1) + 2.*du*dv*IC(1,2) + dv*dv*IC(2,2);
1879 double dz = 1./
sqrt(1. + dxdz*dxdz + dydz*dydz);
1880 double dx = dz*dxdz;
1881 double dy = dz*dydz;
1890 double directionSign = globalZpos * globalZdir;
1898 std::vector<const CSCRecHit2D*>::const_iterator it;
1914 matrix.invert(ierr);
1924 ChamberHitContainer::const_iterator it;
1926 CLHEP::HepMatrix
matrix(2*nhits, 4);
1959 result.invert(ierr);
1993 std::vector<double> uu, vv, zz;
1996 double sum_U_err=0.0;
1997 double sum_Z_U_err=0.0;
1998 double sum_Z2_U_err=0.0;
1999 double sum_U_U_err=0.0;
2000 double sum_UZ_U_err=0.0;
2001 std::vector<double> chiUZind;
2002 std::vector<double>::iterator chiContribution;
2004 ChamberHitContainer::const_iterator ih =
protoSegment.begin();
2020 sum_U_err += 1./
e_Cxx.back();
2021 sum_Z_U_err += z/
e_Cxx.back();
2022 sum_Z2_U_err += (z*
z)/
e_Cxx.back();
2023 sum_U_U_err += u/
e_Cxx.back();
2024 sum_UZ_U_err += (u*
z)/
e_Cxx.back();
2030 double denom=sum_U_err*sum_Z2_U_err-
pow(sum_Z_U_err,2);
2031 double U0=(sum_Z2_U_err*sum_U_U_err-sum_Z_U_err*sum_UZ_U_err)/denom;
2032 double UZ=(sum_U_err*sum_UZ_U_err-sum_Z_U_err*sum_U_U_err)/denom;
2037 for(
unsigned i=0;
i<uu.size(); ++
i){
2038 double uMean = U0+UZ*zz[
i];
2039 chiUZind.push_back((
pow((uMean-uu[
i]),2))/
e_Cxx[i]);
2040 chiUZ += (
pow((uMean-uu[i]),2))/
e_Cxx[i];
2042 chiUZ = chiUZ/(uu.size()-2);
2046 for(
unsigned i=0;
i<uu.size(); ++
i)
2053 chiContribution=max_element(chiUZind.begin(),chiUZind.end());
2069 double condNumberCorr2=0.0;
2073 double IC_12_corr=0.0;
2074 double IC_11_corr=0.0;
2078 diag1=IC(1,1)*IC(2,2);
2079 diag2=IC(1,2)*IC(1,2);
2080 detCov=fabs(diag1-diag2);
2081 if((diag1<condNumberCorr2)&&(diag2<condNumberCorr2)){
2090 if(((detCov<condNumberCorr2)&&(diag1>condNumberCorr2))||
2091 ((diag2>condNumberCorr2)&&(detCov<condNumberCorr2)
2096 IC_12_corr=
sqrt(fabs(diag1-condNumberCorr2));
2098 IC(1,2)=(-1)*IC_12_corr;
2115 for(std::vector<CSCSegment>::iterator it=segments.begin(); it != segments.end(); ++it) {
2116 std::vector<CSCSegment*> duplicateSegments;
2117 for(std::vector<CSCSegment>::iterator it2=segments.begin(); it2 != segments.end(); ++it2) {
2119 bool allShared =
true;
2121 allShared = it->sharesRecHits(*it2);
2128 duplicateSegments.push_back(&(*it2));
2131 it->setDuplicateSegments(duplicateSegments);
double yweightPenaltyThreshold
T getParameter(std::string const &) const
double protoChiUCorrection
Allow to correct the error matrix.
T getUntrackedParameter(std::string const &, T const &) const
bool preClustering_useChaining
CSCDetId cscDetId() const
bool passCondNumber
The number to fource the Covariance.
void doSlopesAndChi2(void)
std::vector< ChamberHitContainer > Psegments_noL5
std::vector< float > curv_noL2_A
void correctTheCovMatrix(CLHEP::HepMatrix &IC)
CSCDetId id() const
Get the (concrete) DetId.
CSCSegment showerSeg(const CSCChamber *aChamber, const ChamberHitContainer &rechits)
const CSCChamber * theChamber
std::vector< float > weight_noL4_A
void correctTheCovX(void)
std::vector< float > curv_noL6_A
GlobalPoint toGlobal(const Local2DPoint &lp) const
Conversion to the global R.F. from the R.F. of the GeomDet.
std::vector< CSCSegment > run(const CSCChamber *aChamber, const ChamberHitContainer &rechits)
void ChooseSegments2(int best_seg)
void ChooseSegments3(int best_seg)
std::vector< float > weight_noL3_B
LocalPoint toLocal(const GlobalPoint &gp) const
Conversion to the R.F. of the GeomDet.
std::vector< ChamberHitContainer > Psegments_noL1
CSCSegAlgoST(const edm::ParameterSet &ps)
Constructor.
bool isGoodToMerge(bool isME11a, ChamberHitContainer &newChain, ChamberHitContainer &oldChain)
std::vector< ChamberHitContainer > chosen_Psegments
std::vector< ChamberHitContainer > Psegments
ChamberHitContainer protoSegment
std::vector< std::vector< const CSCRecHit2D * > > clusterHits(const CSCChamber *aChamber, const ChamberHitContainer &rechits)
double condSeed1_
Correct the error matrix for the condition number.
LocalVector protoDirection
std::vector< float > weight_noL3_A
std::string chamberTypeName() const
CSCSegAlgoShowering * showering_
virtual ~CSCSegAlgoST()
Destructor.
const CSCChamberSpecs * specs() const
CLHEP::HepMatrix AlgebraicMatrix
LocalError localPositionError() const
double covAnyNumber_
Allow to use any number for covariance for all RecHits.
std::vector< ChamberHitContainer > Psegments_noLx
double curvePenaltyThreshold
std::vector< std::vector< const CSCRecHit2D * > > chainHits(const CSCChamber *aChamber, const ChamberHitContainer &rechits)
std::vector< ChamberHitContainer > Psegments_noL4
std::vector< float > weight_A
std::vector< float > weight_noL1_B
const CSCLayer * layer(CSCDetId id) const
Return the layer corresponding to the given id.
std::vector< CSCSegment > buildSegments(const ChamberHitContainer &rechits)
float ChiSquaredProbability(double chiSquared, double nrDOF)
std::vector< CSCSegment > prune_bad_hits(const CSCChamber *aChamber, std::vector< CSCSegment > &segments)
std::vector< float > curv_noL5_A
std::vector< ChamberHitContainer > Psegments_noL6
bool gangedStrips() const
unsigned maxContrIndex
Chi^2 normalization for the initial fit.
std::vector< const CSCRecHit2D * > ChamberHitContainer
Typedefs.
void flipErrors(AlgebraicSymMatrix &) const
std::vector< ChamberHitContainer > Psegments_noL2
std::vector< float > weight_noL5_A
bool passCondNumber_2
Passage the condition number calculations.
AlgebraicSymMatrix weightMatrix(void) const
std::vector< float > weight_noL1_A
std::vector< float > curv_noL4_A
std::vector< float > weight_noL2_A
std::vector< float > chosen_weight_A
bool correctCov_
Correct the Error Matrix.
ChamberHitContainer Psegments_hits
void findDuplicates(std::vector< CSCSegment > &segments)
std::vector< float > curv_noL1_A
void fillChiSquared(void)
AlgebraicSymMatrix calculateError(void) const
bool covToAnyNumberAll_
Allow to use any number for covariance (by hand)
double theWeight(double coordinate_1, double coordinate_2, double coordinate_3, float layer_1, float layer_2, float layer_3)
Utility functions.
std::vector< float > curv_A
bool prePrun_
The index of the worst x RecHit in Chi^2-X method.
double chi2() const
Chi2 of the segment fit.
CLHEP::HepSymMatrix AlgebraicSymMatrix
std::vector< float > weight_noL5_B
std::vector< float > weight_B
float a_yweightPenaltyThreshold[5][5]
void ChooseSegments2a(std::vector< ChamberHitContainer > &best_segments, int best_seg)
std::vector< double > e_Cxx
CLHEP::HepMatrix derivativeMatrix(void) const
void fillLocalDirection(void)
std::vector< float > weight_noL6_A
LocalPoint localPosition() const
std::vector< float > weight_noL2_B
bool covToAnyNumber_
The correction parameters.
std::vector< float > weight_noLx_A
std::vector< float > curv_noL3_A
std::vector< float > weight_noL6_B
tuple size
Write out results.
Power< A, B >::type pow(const A &a, const B &b)
ChamberHitContainer PAhits_onLayer[6]
LocalPoint protoIntercept
std::vector< float > weight_noL4_B
std::vector< ChamberHitContainer > Psegments_noL3
double chi2Norm_3D_
Chi^2 normalization for the corrected fit.