100 LogTrace(
"CSCSegAlgoST") <<
"[CSCSegAlgoST::run] Start building segments in chamber " <<
theChamber->
id();
103 std::vector<CSCSegment> segments_temp;
104 std::vector<CSCSegment> segments;
105 std::vector<ChamberHitContainer> rechits_clusters;
110 for(
int a = 0;
a<5; ++
a) {
111 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 ) {
404 std::vector<ChamberHitContainer> rechits_clusters;
410 float dXclus_box = 0.0;
411 float dYclus_box = 0.0;
413 std::vector<const CSCRecHit2D*>
temp;
415 std::vector< ChamberHitContainer > seeds;
417 std::vector<float> running_meanX;
418 std::vector<float> running_meanY;
420 std::vector<float> seed_minX;
421 std::vector<float> seed_maxX;
422 std::vector<float> seed_minY;
423 std::vector<float> seed_maxY;
432 for(
unsigned int i = 0;
i < rechits.size(); ++
i) {
436 temp.push_back(rechits[
i]);
438 seeds.push_back(temp);
443 running_meanX.push_back( rechits[i]->localPosition().
x() );
444 running_meanY.push_back( rechits[i]->localPosition().
y() );
447 seed_minX.push_back( rechits[i]->localPosition().
x() );
448 seed_maxX.push_back( rechits[i]->localPosition().
x() );
449 seed_minY.push_back( rechits[i]->localPosition().
y() );
450 seed_maxY.push_back( rechits[i]->localPosition().
y() );
455 for(
size_t NNN = 0; NNN < seeds.size(); ++NNN) {
457 for(
size_t MMM = NNN+1; MMM < seeds.size(); ++MMM) {
458 if(running_meanX[MMM] == 999999. || running_meanX[NNN] == 999999. ) {
459 LogTrace(
"CSCSegment|CSC") <<
"[CSCSegAlgoST::clusterHits] ALARM! Skipping used seeds, this should not happen - inform CSC DPG";
469 if ( running_meanX[NNN] > running_meanX[MMM] ) dXclus_box = seed_minX[NNN] - seed_maxX[MMM];
470 else dXclus_box = seed_minX[MMM] - seed_maxX[NNN];
471 if ( running_meanY[NNN] > running_meanY[MMM] ) dYclus_box = seed_minY[NNN] - seed_maxY[MMM];
472 else dYclus_box = seed_minY[MMM] - seed_maxY[NNN];
480 running_meanX[MMM] = (running_meanX[NNN]*seeds[NNN].size() + running_meanX[MMM]*seeds[MMM].size()) / (seeds[NNN].
size()+seeds[MMM].size());
481 running_meanY[MMM] = (running_meanY[NNN]*seeds[NNN].size() + running_meanY[MMM]*seeds[MMM].size()) / (seeds[NNN].
size()+seeds[MMM].size());
484 if ( seed_minX[NNN] <= seed_minX[MMM] ) seed_minX[MMM] = seed_minX[NNN];
485 if ( seed_maxX[NNN] > seed_maxX[MMM] ) seed_maxX[MMM] = seed_maxX[NNN];
486 if ( seed_minY[NNN] <= seed_minY[MMM] ) seed_minY[MMM] = seed_minY[NNN];
487 if ( seed_maxY[NNN] > seed_maxY[MMM] ) seed_maxY[MMM] = seed_maxY[NNN];
490 seeds[MMM].insert(seeds[MMM].
end(),seeds[NNN].
begin(),seeds[NNN].
end());
493 running_meanX[NNN] = 999999.;
494 running_meanY[NNN] = 999999.;
506 for(
size_t NNN = 0; NNN < seeds.size(); ++NNN) {
507 if(running_meanX[NNN] == 999999.)
continue;
508 rechits_clusters.push_back(seeds[NNN]);
513 return rechits_clusters;
519 std::vector<ChamberHitContainer> rechits_chains;
522 std::vector<const CSCRecHit2D*>
temp;
524 std::vector< ChamberHitContainer > seeds;
526 std::vector <bool> usedCluster;
532 for(
unsigned int i = 0;
i < rechits.size(); ++
i) {
534 temp.push_back(rechits[
i]);
535 seeds.push_back(temp);
536 usedCluster.push_back(
false);
539 bool gangedME11a =
false;
545 for(
size_t NNN = 0; NNN < seeds.size(); ++NNN) {
546 for(
size_t MMM = NNN+1; MMM < seeds.size(); ++MMM) {
547 if(usedCluster[MMM] || usedCluster[NNN]){
561 bool goodToMerge =
isGoodToMerge(gangedME11a, seeds[NNN], seeds[MMM]);
567 seeds[MMM].insert(seeds[MMM].
end(),seeds[NNN].
begin(),seeds[NNN].
end());
570 usedCluster[NNN] =
true;
583 for(
size_t NNN = 0; NNN < seeds.size(); ++NNN) {
584 if(usedCluster[NNN])
continue;
585 rechits_chains.push_back(seeds[NNN]);
590 return rechits_chains;
594 for(
size_t iRH_new = 0;iRH_new<newChain.size();++iRH_new){
595 int layer_new = newChain[iRH_new]->cscDetId().layer()-1;
596 int middleStrip_new = newChain[iRH_new]->nStrips()/2;
597 int centralStrip_new = newChain[iRH_new]->channels(middleStrip_new);
598 int centralWire_new = newChain[iRH_new]->hitWire();
599 bool layerRequirementOK =
false;
600 bool stripRequirementOK =
false;
601 bool wireRequirementOK =
false;
602 bool goodToMerge =
false;
603 for(
size_t iRH_old = 0;iRH_old<oldChain.size();++iRH_old){
604 int layer_old = oldChain[iRH_old]->cscDetId().layer()-1;
605 int middleStrip_old = oldChain[iRH_old]->nStrips()/2;
606 int centralStrip_old = oldChain[iRH_old]->channels(middleStrip_old);
607 int centralWire_old = oldChain[iRH_old]->hitWire();
616 if(layer_new==layer_old+1 || layer_new==layer_old-1 ||
617 layer_new==layer_old+2 || layer_new==layer_old-2 ||
618 layer_new==layer_old+3 || layer_new==layer_old-3 ||
619 layer_new==layer_old+4 || layer_new==layer_old-4 ){
620 layerRequirementOK =
true;
626 if(centralStrip_new==centralStrip_old ||
627 centralStrip_new==centralStrip_old+1 || centralStrip_new==centralStrip_old-1 ||
628 centralStrip_new==centralStrip_old+2 || centralStrip_new==centralStrip_old-2){
629 stripRequirementOK =
true;
632 if(centralWire_new==centralWire_old ||
633 centralWire_new==centralWire_old+1 || centralWire_new==centralWire_old-1 ||
634 centralWire_new==centralWire_old+2 || centralWire_new==centralWire_old-2){
635 wireRequirementOK =
true;
639 if(centralStrip_new==centralStrip_old+1-allStrips || centralStrip_new==centralStrip_old-1-allStrips ||
640 centralStrip_new==centralStrip_old+2-allStrips || centralStrip_new==centralStrip_old-2-allStrips ||
641 centralStrip_new==centralStrip_old+1+allStrips || centralStrip_new==centralStrip_old-1+allStrips ||
642 centralStrip_new==centralStrip_old+2+allStrips || centralStrip_new==centralStrip_old-2+allStrips){
643 stripRequirementOK =
true;
646 if(layerRequirementOK && stripRequirementOK && wireRequirementOK){
658 double CSCSegAlgoST::theWeight(
double coordinate_1,
double coordinate_2,
double coordinate_3,
float layer_1,
float layer_2,
float layer_3) {
659 double sub_weight = 0;
661 ( (coordinate_2 - coordinate_3) / (layer_2 - layer_3) ) -
662 ( (coordinate_1 - coordinate_2) / (layer_1 - layer_2) )
674 std::vector<CSCSegment> segmentInChamber;
675 segmentInChamber.clear();
678 unsigned int thering = 999;
679 unsigned int thestation = 999;
682 std::vector<int> hits_onLayerNumber(6);
687 for(
int iarray = 0; iarray <6; ++iarray) {
689 hits_onLayerNumber[iarray] = 0;
732 int midlayer_pointer[6] = {0,0,2,3,3,4};
735 int n_layers_occupied_tot = 0;
736 int n_layers_processed = 0;
738 float min_weight_A = 99999.9;
739 float min_weight_noLx_A = 99999.9;
748 int best_noLx_pseg = -1;
749 int best_Layer_noLx = -1;
762 for(
size_t M = 0; M < rechits.size(); ++M) {
764 hits_onLayerNumber[ rechits[M]->cscDetId().layer()-1 ] += 1;
765 if(hits_onLayerNumber[ rechits[M]->cscDetId().layer()-1 ] == 1 ) n_layers_occupied_tot += 1;
767 PAhits_onLayer[rechits[M]->cscDetId().layer()-1] .push_back(rechits[M]);
778 for(
size_t i = 0;
i< hits_onLayerNumber.size(); ++
i){
780 tothits += hits_onLayerNumber[
i];
781 if (hits_onLayerNumber[
i] > maxhits) {
782 nextlayer = maxlayer;
785 maxhits = hits_onLayerNumber[
i];
787 else if (hits_onLayerNumber[
i] > nexthits) {
789 nexthits = hits_onLayerNumber[
i];
794 if (tothits > (
int)UpperLimit) {
795 if (n_layers_occupied_tot > 4) {
796 tothits = tothits - hits_onLayerNumber[maxlayer];
797 n_layers_occupied_tot = n_layers_occupied_tot - 1;
799 hits_onLayerNumber[maxlayer] = 0;
803 if (tothits > (
int)UpperLimit) {
804 if (n_layers_occupied_tot > 4) {
805 tothits = tothits - hits_onLayerNumber[nextlayer];
806 n_layers_occupied_tot = n_layers_occupied_tot - 1;
808 hits_onLayerNumber[nextlayer] = 0;
812 if (tothits > (
int)UpperLimit){
821 if ( segShower.
nRecHits() < 3 )
return segmentInChamber;
822 if ( segShower.
chi2() == -1 )
return segmentInChamber;
824 segmentInChamber.push_back(segShower);
825 return segmentInChamber;
828 LogTrace(
"CSCSegment|CSC") <<
"[CSCSegAlgoST::buildSegments] No. of rechits in the cluster/chamber > " << UpperLimit <<
829 " ... Segment finding in the cluster/chamber canceled!";
830 return segmentInChamber;
837 if( rechits.size() > 0 ) {
838 thering = rechits[0]->cscDetId().ring();
839 thestation = rechits[0]->cscDetId().station();
847 return segmentInChamber;
854 for(
int layer = 0; layer < 6; ++layer) {
864 n_layers_processed += 1;
868 int orig_number_of_psegs =
Psegments.size();
880 if( orig_number_of_psegs == 0 ) {
918 if( orig_number_of_noL1_psegs == 0 ) {
939 for(
int pseg = 0; pseg < orig_number_of_psegs; ++pseg ) {
941 int pseg_pos = (pseg)+((
hit)*orig_number_of_psegs);
942 int pseg_noL1_pos = (pseg)+((
hit)*orig_number_of_noL1_psegs);
943 int pseg_noL2_pos = (pseg)+((
hit)*orig_number_of_noL2_psegs);
944 int pseg_noL3_pos = (pseg)+((
hit)*orig_number_of_noL3_psegs);
945 int pseg_noL4_pos = (pseg)+((
hit)*orig_number_of_noL4_psegs);
946 int pseg_noL5_pos = (pseg)+((
hit)*orig_number_of_noL5_psegs);
947 int pseg_noL6_pos = (pseg)+((
hit)*orig_number_of_noL6_psegs);
973 if (n_layers_processed != 2 && pseg < orig_number_of_noL1_psegs)
curv_noL1_A.push_back(
curv_noL1_A[ pseg_noL1_pos ]);
974 if (n_layers_processed != 2 && pseg < orig_number_of_noL2_psegs)
curv_noL2_A.push_back(
curv_noL2_A[ pseg_noL2_pos ]);
975 if (n_layers_processed != 3 && pseg < orig_number_of_noL3_psegs)
curv_noL3_A.push_back(
curv_noL3_A[ pseg_noL3_pos ]);
976 if (n_layers_processed != 4 && pseg < orig_number_of_noL4_psegs)
curv_noL4_A.push_back(
curv_noL4_A[ pseg_noL4_pos ]);
977 if (n_layers_processed != 5 && pseg < orig_number_of_noL5_psegs)
curv_noL5_A.push_back(
curv_noL5_A[ pseg_noL5_pos ]);
978 if (n_layers_processed != 6 && pseg < orig_number_of_noL6_psegs)
curv_noL6_A.push_back(
curv_noL6_A[ pseg_noL6_pos ]);
990 if (n_layers_processed != 2 && pseg < orig_number_of_noL1_psegs)
Psegments_noL1[ pseg_noL1_pos ].push_back(
PAhits_onLayer[ layer ][ hit ]);
991 if (n_layers_processed != 2 && pseg < orig_number_of_noL2_psegs)
Psegments_noL2[ pseg_noL2_pos ].push_back(
PAhits_onLayer[ layer ][ hit ]);
992 if (n_layers_processed != 3 && pseg < orig_number_of_noL3_psegs)
Psegments_noL3[ pseg_noL3_pos ].push_back(
PAhits_onLayer[ layer ][ hit ]);
993 if (n_layers_processed != 4 && pseg < orig_number_of_noL4_psegs)
Psegments_noL4[ pseg_noL4_pos ].push_back(
PAhits_onLayer[ layer ][ hit ]);
994 if (n_layers_processed != 5 && pseg < orig_number_of_noL5_psegs)
Psegments_noL5[ pseg_noL5_pos ].push_back(
PAhits_onLayer[ layer ][ hit ]);
995 if (n_layers_processed != 6 && pseg < orig_number_of_noL6_psegs)
Psegments_noL6[ pseg_noL6_pos ].push_back(
PAhits_onLayer[ layer ][ hit ]);
1008 float((*(
Psegments[ pseg_pos ].
end()-1))->cscDetId().layer()),
1009 float((*(
Psegments[ pseg_pos ].
end()-2))->cscDetId().layer()),
1010 float((*(
Psegments[ pseg_pos ].
end()-3))->cscDetId().layer())
1017 float((*(
Psegments[ pseg_pos ].
end()-1))->cscDetId().layer()),
1018 float((*(
Psegments[ pseg_pos ].
end()-2))->cscDetId().layer()),
1019 float((*(
Psegments[ pseg_pos ].
end()-3))->cscDetId().layer())
1024 if(
int(
Psegments[ pseg_pos ].
size()) == n_layers_occupied_tot) {
1028 (*(
Psegments[ pseg_pos ].
end()-midlayer_pointer[n_layers_occupied_tot-1] ))->localPosition().
x(),
1029 (*(
Psegments[ pseg_pos ].
end()-n_layers_occupied_tot ))->localPosition().
x(),
1030 float((*(
Psegments[ pseg_pos ].
end()-1))->cscDetId().layer()),
1031 float((*(
Psegments[ pseg_pos ].
end()-midlayer_pointer[n_layers_occupied_tot-1] ))->cscDetId().layer()),
1032 float((*(
Psegments[ pseg_pos ].
end()-n_layers_occupied_tot ))->cscDetId().layer())
1039 if (
weight_A[ pseg_pos ] < min_weight_A ) {
1040 min_weight_A =
weight_A[ pseg_pos ];
1043 best_pseg = pseg_pos ;
1053 if ( n_layers_occupied_tot > 3 ) {
1054 if (pseg < orig_number_of_noL1_psegs && (n_layers_processed != 2)) {
1084 (*(
Psegments_noL1[ pseg_noL1_pos ].
end()-midlayer_pointer[n_layers_occupied_tot-2] ))->localPosition().
x(),
1085 (*(
Psegments_noL1[ pseg_noL1_pos ].
end()-(n_layers_occupied_tot-1) ))->localPosition().
x(),
1087 float((*(
Psegments_noL1[ pseg_noL1_pos ].
end()-midlayer_pointer[n_layers_occupied_tot-2] ))->cscDetId().layer()),
1088 float((*(
Psegments_noL1[ pseg_noL1_pos ].
end()-(n_layers_occupied_tot-1) ))->cscDetId().layer())
1100 best_noLx_pseg = pseg_noL1_pos;
1101 best_Layer_noLx = 1;
1113 if ( n_layers_occupied_tot > 3 ) {
1114 if (pseg < orig_number_of_noL2_psegs && ( n_layers_processed != 2 )) {
1144 (*(
Psegments_noL2[ pseg_noL2_pos ].
end()-midlayer_pointer[n_layers_occupied_tot-2] ))->localPosition().
x(),
1145 (*(
Psegments_noL2[ pseg_noL2_pos ].
end()-(n_layers_occupied_tot-1) ))->localPosition().
x(),
1147 float((*(
Psegments_noL2[ pseg_noL2_pos ].
end()-midlayer_pointer[n_layers_occupied_tot-2] ))->cscDetId().layer()),
1148 float((*(
Psegments_noL2[ pseg_noL2_pos ].
end()-(n_layers_occupied_tot-1) ))->cscDetId().layer())
1160 best_noLx_pseg = pseg_noL2_pos;
1161 best_Layer_noLx = 2;
1173 if ( n_layers_occupied_tot > 3 ) {
1174 if (pseg < orig_number_of_noL3_psegs && ( n_layers_processed != 3 )) {
1204 (*(
Psegments_noL3[ pseg_noL3_pos ].
end()-midlayer_pointer[n_layers_occupied_tot-2] ))->localPosition().
x(),
1205 (*(
Psegments_noL3[ pseg_noL3_pos ].
end()-(n_layers_occupied_tot-1) ))->localPosition().
x(),
1207 float((*(
Psegments_noL3[ pseg_noL3_pos ].
end()-midlayer_pointer[n_layers_occupied_tot-2] ))->cscDetId().layer()),
1208 float((*(
Psegments_noL3[ pseg_noL3_pos ].
end()-(n_layers_occupied_tot-1) ))->cscDetId().layer())
1220 best_noLx_pseg = pseg_noL3_pos;
1221 best_Layer_noLx = 3;
1233 if ( n_layers_occupied_tot > 3 ) {
1234 if (pseg < orig_number_of_noL4_psegs && ( n_layers_processed != 4 )) {
1264 (*(
Psegments_noL4[ pseg_noL4_pos ].
end()-midlayer_pointer[n_layers_occupied_tot-2] ))->localPosition().
x(),
1265 (*(
Psegments_noL4[ pseg_noL4_pos ].
end()-(n_layers_occupied_tot-1) ))->localPosition().
x(),
1267 float((*(
Psegments_noL4[ pseg_noL4_pos ].
end()-midlayer_pointer[n_layers_occupied_tot-2] ))->cscDetId().layer()),
1268 float((*(
Psegments_noL4[ pseg_noL4_pos ].
end()-(n_layers_occupied_tot-1) ))->cscDetId().layer())
1280 best_noLx_pseg = pseg_noL4_pos;
1281 best_Layer_noLx = 4;
1293 if ( n_layers_occupied_tot > 4 ) {
1294 if (pseg < orig_number_of_noL5_psegs && ( n_layers_processed != 5 )) {
1324 (*(
Psegments_noL5[ pseg_noL5_pos ].
end()-midlayer_pointer[n_layers_occupied_tot-2] ))->localPosition().
x(),
1325 (*(
Psegments_noL5[ pseg_noL5_pos ].
end()-(n_layers_occupied_tot-1) ))->localPosition().
x(),
1327 float((*(
Psegments_noL5[ pseg_noL5_pos ].
end()-midlayer_pointer[n_layers_occupied_tot-2] ))->cscDetId().layer()),
1328 float((*(
Psegments_noL5[ pseg_noL5_pos ].
end()-(n_layers_occupied_tot-1) ))->cscDetId().layer())
1340 best_noLx_pseg = pseg_noL5_pos;
1341 best_Layer_noLx = 5;
1353 if ( n_layers_occupied_tot > 5 ) {
1354 if (pseg < orig_number_of_noL6_psegs && ( n_layers_processed != 6 )) {
1384 (*(
Psegments_noL6[ pseg_noL6_pos ].
end()-midlayer_pointer[n_layers_occupied_tot-2] ))->localPosition().
x(),
1385 (*(
Psegments_noL6[ pseg_noL6_pos ].
end()-(n_layers_occupied_tot-1) ))->localPosition().
x(),
1387 float((*(
Psegments_noL6[ pseg_noL6_pos ].
end()-midlayer_pointer[n_layers_occupied_tot-2] ))->cscDetId().layer()),
1388 float((*(
Psegments_noL6[ pseg_noL6_pos ].
end()-(n_layers_occupied_tot-1) ))->cscDetId().layer())
1400 best_noLx_pseg = pseg_noL6_pos;
1401 best_Layer_noLx = 6;
1437 int chosen_pseg = best_pseg;
1439 return segmentInChamber;
1444 float hit_drop_limit = -999999.999;
1447 switch ( n_layers_processed ) {
1459 if ((best_Layer_noLx < 1) || (best_Layer_noLx > 4)) {
1462 if ((best_Layer_noLx == 2) || (best_Layer_noLx == 3)) hit_drop_limit = hit_drop_limit * (1./2.);
1466 if ((best_Layer_noLx < 1) || (best_Layer_noLx > 5)) {
1469 if ((best_Layer_noLx == 2) || (best_Layer_noLx == 4)) hit_drop_limit = hit_drop_limit * (1./2.);
1470 if (best_Layer_noLx == 3) hit_drop_limit = hit_drop_limit * (1./3.);
1474 if ((best_Layer_noLx < 1) || (best_Layer_noLx > 6)) {
1477 if ((best_Layer_noLx == 2) || (best_Layer_noLx == 5)) hit_drop_limit = hit_drop_limit * (1./2.);
1478 if ((best_Layer_noLx == 3) || (best_Layer_noLx == 4)) hit_drop_limit = hit_drop_limit * (1./3.);
1483 LogTrace(
"CSCSegment|CSC") <<
"[CSCSegAlgoST::buildSegments] Unexpected number of layers with hits - please inform CSC DPG.";
1484 hit_drop_limit = 0.1;
1488 switch ( best_Layer_noLx ) {
1532 if( min_weight_A > 0. ) {
1533 if ( min_weight_noLx_A/min_weight_A < hit_drop_limit ) {
1538 chosen_pseg = best_noLx_pseg;
1553 for(
unsigned int iSegment=0; iSegment<
GoodSegments.size();++iSegment){
1574 LogTrace(
"CSCWeirdSegment") <<
"[CSCSegAlgoST::buildSegments] Segment ErrXX scaled and refit " << std::endl;
1581 LogTrace(
"CSCWeirdSegment") <<
"[CSCSegAlgoST::buildSegments] Segment ErrXY changed to match cond. number and refit " << std::endl;
1593 LogTrace(
"CSCWeirdSegment") <<
"[CSCSegAlgoST::buildSegments] Scale factor protoChiUCorrection too big, pre-Prune and refit " << std::endl;
1612 segmentInChamber.push_back(temp);
1614 return segmentInChamber;
1625 int SumCommonHits = 0;
1627 int nr_remaining_candidates;
1628 unsigned int nr_of_segment_candidates;
1630 nr_remaining_candidates = nr_of_segment_candidates = chosen_segments.size();
1633 GoodSegments.push_back( chosen_segments[ chosen_seg ] );
1635 float chosen_weight_temp = 999999.;
1636 int chosen_seg_temp = -1;
1639 while( nr_remaining_candidates > 0 ) {
1641 for(
unsigned int iCand=0; iCand < nr_of_segment_candidates; ++iCand) {
1643 if( chosen_weight[iCand] < 0. )
continue;
1646 for(
int ihits = 0; ihits < int(chosen_segments[iCand].
size()); ++ihits ) {
1647 if( chosen_segments[iCand][ihits] == chosen_segments[chosen_seg][ihits]) {
1653 if(SumCommonHits>1) {
1654 chosen_weight[iCand] = -1.;
1655 nr_remaining_candidates -= 1;
1659 if( chosen_weight[ iCand ] < chosen_weight_temp ) {
1660 chosen_weight_temp = chosen_weight[ iCand ];
1661 chosen_seg_temp = iCand ;
1666 if( chosen_seg_temp > -1 )
GoodSegments.push_back( chosen_segments[ chosen_seg_temp ] );
1668 chosen_seg = chosen_seg_temp;
1670 chosen_weight_temp = 999999;
1671 chosen_seg_temp = -1;
1677 std::vector <unsigned int> BadCandidate;
1678 int SumCommonHits =0;
1680 BadCandidate.clear();
1681 for(
unsigned int iCand=0;iCand<
Psegments.size();++iCand) {
1683 for(
unsigned int iiCand=iCand+1;iiCand<
Psegments.size();++iiCand){
1687 LogTrace(
"CSCSegment|CSC") <<
"[CSCSegAlgoST::ChooseSegments2] ALARM!! Should not happen - please inform CSC DPG";
1690 for(
int ihits = 0; ihits < int(
Psegments[iCand].
size()); ++ihits ) {
1696 if(SumCommonHits>1) {
1698 BadCandidate.push_back(iCand);
1702 BadCandidate.push_back(iiCand);
1709 for(
unsigned int isegm=0;isegm<
Psegments.size();++isegm) {
1713 for(
unsigned int ibad=0;ibad<BadCandidate.size();++ibad) {
1715 if(isegm == BadCandidate[ibad]) {
1742 LogTrace(
"CSCSegment|CSC") <<
"[CSCSegAlgoST::fitSlopes] e_Cxx.size()!=protoSegment.size() ALARM! Please inform CSC DPG " << std::endl;
1749 ChamberHitContainer::const_iterator ih =
protoSegment.begin();
1776 bool ok = IC.Invert();
1778 LogTrace(
"CSCSegment|CSC") <<
"[CSCSegAlgoST::fitSlopes] Failed to invert covariance matrix: \n" << IC;
1784 M(0,2) += IC(0,0) *
z;
1785 M(0,3) += IC(0,1) *
z;
1786 B(0) += u * IC(0,0) + v * IC(0,1);
1790 M(1,2) += IC(1,0) *
z;
1791 M(1,3) += IC(1,1) *
z;
1792 B(1) += u * IC(1,0) + v * IC(1,1);
1794 M(2,0) += IC(0,0) *
z;
1795 M(2,1) += IC(0,1) *
z;
1796 M(2,2) += IC(0,0) * z *
z;
1797 M(2,3) += IC(0,1) * z *
z;
1798 B(2) += ( u * IC(0,0) + v * IC(0,1) ) * z;
1800 M(3,0) += IC(1,0) *
z;
1801 M(3,1) += IC(1,1) *
z;
1802 M(3,2) += IC(1,0) * z *
z;
1803 M(3,3) += IC(1,1) * z *
z;
1804 B(3) += ( u * IC(1,0) + v * IC(1,1) ) * z;
1809 bool ok = M.Invert();
1811 LogTrace(
"CSCSegment|CSC") <<
"[CSCSegAlgoST::fitSlopes[ Failed to invert matrix: \n" << M;
1838 ChamberHitContainer::const_iterator ih;
1876 bool ok = IC.Invert();
1878 LogTrace(
"CSCSegment|CSC") <<
"[CSCSegAlgoST::fillChiSquared] Failed to invert covariance matrix: \n" << IC;
1882 chsq += du*du*IC(0,0) + 2.*du*dv*IC(0,1) + dv*dv*IC(1,1);
1900 double dz = 1./
sqrt(1. + dxdz*dxdz + dydz*dydz);
1901 double dx = dz*dxdz;
1902 double dy = dz*dydz;
1911 double directionSign = globalZpos * globalZdir;
1921 std::vector<const CSCRecHit2D*>::const_iterator it;
1941 ok = matrix.Invert();
1943 LogTrace(
"CSCSegment|CSC") <<
"[CSCSegAlgoST::weightMatrix] Failed to invert matrix: \n" <<
matrix;
1956 ChamberHitContainer::const_iterator it;
1997 ok = result.Invert();
1999 LogTrace(
"CSCSegment|CSC") <<
"[CSCSegAlgoST::calculateError] Failed to invert matrix: \n" <<
result;
2017 for (
short j=0;
j!=4; ++
j) {
2018 for (
short i=0;
i!=4; ++
i) {
2019 hold(
i+1,
j+1) =
a(
i,
j);
2057 std::vector<double> uu, vv, zz;
2060 double sum_U_err=0.0;
2061 double sum_Z_U_err=0.0;
2062 double sum_Z2_U_err=0.0;
2063 double sum_U_U_err=0.0;
2064 double sum_UZ_U_err=0.0;
2065 std::vector<double> chiUZind;
2066 std::vector<double>::iterator chiContribution;
2068 ChamberHitContainer::const_iterator ih =
protoSegment.begin();
2084 sum_U_err += 1./
e_Cxx.back();
2085 sum_Z_U_err += z/
e_Cxx.back();
2086 sum_Z2_U_err += (z*
z)/
e_Cxx.back();
2087 sum_U_U_err += u/
e_Cxx.back();
2088 sum_UZ_U_err += (u*
z)/
e_Cxx.back();
2094 double denom=sum_U_err*sum_Z2_U_err-
pow(sum_Z_U_err,2);
2095 double U0=(sum_Z2_U_err*sum_U_U_err-sum_Z_U_err*sum_UZ_U_err)/denom;
2096 double UZ=(sum_U_err*sum_UZ_U_err-sum_Z_U_err*sum_U_U_err)/denom;
2101 for(
unsigned i=0;
i<uu.size(); ++
i){
2102 double uMean = U0+UZ*zz[
i];
2103 chiUZind.push_back((
pow((uMean-uu[
i]),2))/
e_Cxx[i]);
2104 chiUZ += (
pow((uMean-uu[i]),2))/
e_Cxx[i];
2106 chiUZ = chiUZ/(uu.size()-2);
2110 for(
unsigned i=0;
i<uu.size(); ++
i)
2117 chiContribution=max_element(chiUZind.begin(),chiUZind.end());
2133 double condNumberCorr2=0.0;
2137 double IC_01_corr=0.0;
2138 double IC_00_corr=0.0;
2142 diag1=IC(0,0)*IC(1,1);
2143 diag2=IC(0,1)*IC(0,1);
2144 detCov=fabs(diag1-diag2);
2145 if((diag1<condNumberCorr2)&&(diag2<condNumberCorr2)){
2154 if(((detCov<condNumberCorr2)&&(diag1>condNumberCorr2))||
2155 ((diag2>condNumberCorr2)&&(detCov<condNumberCorr2)
2160 IC_01_corr=
sqrt(fabs(diag1-condNumberCorr2));
2162 IC(0,1)=(-1)*IC_01_corr;
2180 for(std::vector<CSCSegment>::iterator it=segments.begin(); it != segments.end(); ++it) {
2181 std::vector<CSCSegment*> duplicateSegments;
2182 for(std::vector<CSCSegment>::iterator it2=segments.begin(); it2 != segments.end(); ++it2) {
2184 bool allShared =
true;
2186 allShared = it->sharesRecHits(*it2);
2193 duplicateSegments.push_back(&(*it2));
2196 it->setDuplicateSegments(duplicateSegments);
2207 <<
"\ncovariance matrix"
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 force the Covariance.
void doSlopesAndChi2(void)
std::vector< ChamberHitContainer > Psegments_noL5
std::vector< float > curv_noL2_A
const CSCChamber * chamber() const
CSCDetId id() const
Get the (concrete) DetId.
void dumpSegment(const CSCSegment &seg) const
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)
LocalError localPositionError() const
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)
void correctTheCovMatrix(SMatrixSym2 &IC)
std::vector< ChamberHitContainer > chosen_Psegments
std::vector< ChamberHitContainer > Psegments
ChamberHitContainer protoSegment
ROOT::Math::SVector< double, 4 > SVector4
std::vector< std::vector< const CSCRecHit2D * > > clusterHits(const CSCChamber *aChamber, const ChamberHitContainer &rechits)
double condSeed1_
The upper limit of protoChiUCorrection to apply prePrun.
LocalVector protoDirection
std::vector< float > weight_noL3_A
virtual int degreesOfFreedom() const
Degrees of freedom of the segment fit.
std::string chamberTypeName() const
LocalPoint localPosition() const
LocalVector localDirection() const
Local direction.
CSCSegAlgoShowering * showering_
virtual ~CSCSegAlgoST()
Destructor.
const CSCChamberSpecs * specs() const
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
SMatrix12by4 derivativeMatrix(void) const
bool gangedStrips() const
unsigned maxContrIndex
Chi^2 normalization for the initial fit.
std::vector< const CSCRecHit2D * > ChamberHitContainer
Typedefs.
const std::vector< CSCRecHit2D > & specificRecHits() const
std::vector< ChamberHitContainer > Psegments_noL2
ROOT::Math::SMatrix< double, 4 > SMatrix4
std::vector< float > weight_noL5_A
bool passCondNumber_2
Passage the condition number calculations.
ROOT::Math::SMatrix< double, 12, 12, ROOT::Math::MatRepSym< double, 12 > > SMatrixSym12
std::vector< float > weight_noL1_A
std::vector< float > curv_noL4_A
std::vector< float > weight_noL2_A
std::vector< float > chosen_weight_A
AlgebraicSymMatrix parametersError() const
Covariance matrix of parameters()
bool correctCov_
Correct the Error Matrix.
ChamberHitContainer Psegments_hits
void findDuplicates(std::vector< CSCSegment > &segments)
std::vector< float > curv_noL1_A
void fillChiSquared(void)
SMatrixSym4 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
ROOT::Math::SMatrix< double, 4, 4, ROOT::Math::MatRepSym< double, 4 > > SMatrixSym4
bool prePrun_
The index of the worst x RecHit in Chi^2-X method.
double chi2() const
Chi2 of the segment fit.
ROOT::Math::SMatrix< double, 12, 4 > SMatrix12by4
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
void fillLocalDirection(void)
ROOT::Math::SMatrix< double, 2, 2, ROOT::Math::MatRepSym< double, 2 > > SMatrixSym2
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
SMatrixSym12 weightMatrix(void) const
std::vector< float > weight_noL6_B
tuple size
Write out results.
AlgebraicSymMatrix flipErrors(const SMatrixSym4 &) const
Power< A, B >::type pow(const A &a, const B &b)
ChamberHitContainer PAhits_onLayer[6]
LocalError localDirectionError() const
Error on the local direction.
LocalPoint protoIntercept
std::vector< float > weight_noL4_B
std::vector< ChamberHitContainer > Psegments_noL3
double chi2Norm_3D_
Chi^2 normalization for the corrected fit.