Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #include "TrackingTools/RoadSearchHitAccess/interface/RoadSearchHitSorting.h"
00017
00018 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00019
00020 #include "Utilities/General/interface/CMSexception.h"
00021 #include "DataFormats/SiStripDetId/interface/StripSubdetector.h"
00022 #include "DataFormats/SiPixelDetId/interface/PixelSubdetector.h"
00023
00024 bool SortHitsByGlobalPosition::insideOutLess( const TrackingRecHit& a, const TrackingRecHit& b) const{
00025
00026 DetId ida(a.geographicalId());
00027 DetId idb(b.geographicalId());
00028
00029 unsigned int idetA = static_cast<unsigned int>(ida.subdetId());
00030 unsigned int idetB = static_cast<unsigned int>(idb.subdetId());
00031
00032
00033 bool same_det = (
00034 (idetA == StripSubdetector::TIB && idetB == StripSubdetector::TIB) ||
00035 (idetA == StripSubdetector::TID && idetB == StripSubdetector::TID) ||
00036 (idetA == StripSubdetector::TIB && idetB == StripSubdetector::TID) ||
00037 (idetA == StripSubdetector::TID && idetB == StripSubdetector::TIB) ||
00038
00039 (idetA == StripSubdetector::TOB && idetB == StripSubdetector::TOB) ||
00040 (idetA == StripSubdetector::TEC && idetB == StripSubdetector::TEC) ||
00041 (idetA == StripSubdetector::TOB && idetB == StripSubdetector::TEC) ||
00042 (idetA == StripSubdetector::TEC && idetB == StripSubdetector::TOB) ||
00043
00044 (idetA == PixelSubdetector::PixelBarrel && idetB == PixelSubdetector::PixelBarrel) ||
00045 (idetA == PixelSubdetector::PixelEndcap && idetB == PixelSubdetector::PixelEndcap) ||
00046 (idetA == PixelSubdetector::PixelBarrel && idetB == PixelSubdetector::PixelEndcap) ||
00047 (idetA == PixelSubdetector::PixelEndcap && idetB == PixelSubdetector::PixelBarrel) );
00048
00049 if (!same_det) return (idetA < idetB);
00050
00051 if( (idetA == StripSubdetector::TIB || idetA == StripSubdetector::TOB || idetA == PixelSubdetector::PixelBarrel) &&
00052 (idetB == StripSubdetector::TIB || idetB == StripSubdetector::TOB || idetB == PixelSubdetector::PixelBarrel)) {
00053 return static_cast<unsigned int>(geometry->idToDet(ida)->surface().toGlobal(a.localPosition()).perp() * 1E7) < static_cast<unsigned int>(geometry->idToDet(idb)->surface().toGlobal(b.localPosition()).perp() * 1E7);
00054 }
00055
00056 if( (idetA == StripSubdetector::TEC || idetA == StripSubdetector::TID || idetA == PixelSubdetector::PixelEndcap) &&
00057 (idetB == StripSubdetector::TEC || idetB == StripSubdetector::TID || idetB == PixelSubdetector::PixelEndcap)) {
00058 return static_cast<unsigned int>(std::abs(geometry->idToDet(ida)->surface().toGlobal(a.localPosition()).z()) * 1E7) < static_cast<unsigned int>(std::abs(geometry->idToDet(idb)->surface().toGlobal(b.localPosition()).z()) * 1E7);
00059 }
00060
00061
00062
00063
00064
00065 if( (idetA == StripSubdetector::TIB || idetA == StripSubdetector::TOB || idetA == PixelSubdetector::PixelBarrel) &&
00066 (idetB == StripSubdetector::TEC || idetB == StripSubdetector::TID || idetB == PixelSubdetector::PixelEndcap)) {
00067 return barrelForwardLess( a, b);
00068 }else{
00069 return !barrelForwardLess( b, a);
00070 }
00071
00072 throw Genexception("SortHitsByGlobalPosition: arguments are not Ok");
00073 }
00074
00075 bool SortHitsByGlobalPosition::barrelForwardLess( const TrackingRecHit& a, const TrackingRecHit& b) const{
00076
00077
00078
00079
00080 DetId ida(a.geographicalId());
00081 DetId idb(b.geographicalId());
00082 return static_cast<unsigned int>(std::abs( geometry->idToDet(ida)->surface().toGlobal(a.localPosition()).z()) * 1E7) < static_cast<unsigned int>(std::abs( geometry->idToDet(idb)->surface().toGlobal(b.localPosition()).z()) * 1E7);
00083 }
00084
00085 bool SortHitPointersByGlobalPosition::insideOutLess( const TrackingRecHit* a, const TrackingRecHit* b) const{
00086
00087 DetId ida(a->geographicalId());
00088 DetId idb(b->geographicalId());
00089
00090 unsigned int idetA = static_cast<unsigned int>(ida.subdetId());
00091 unsigned int idetB = static_cast<unsigned int>(idb.subdetId());
00092
00093
00094 bool same_det = (
00095 (idetA == StripSubdetector::TIB && idetB == StripSubdetector::TIB) ||
00096 (idetA == StripSubdetector::TID && idetB == StripSubdetector::TID) ||
00097 (idetA == StripSubdetector::TIB && idetB == StripSubdetector::TID) ||
00098 (idetA == StripSubdetector::TID && idetB == StripSubdetector::TIB) ||
00099
00100 (idetA == StripSubdetector::TOB && idetB == StripSubdetector::TOB) ||
00101 (idetA == StripSubdetector::TEC && idetB == StripSubdetector::TEC) ||
00102 (idetA == StripSubdetector::TOB && idetB == StripSubdetector::TEC) ||
00103 (idetA == StripSubdetector::TEC && idetB == StripSubdetector::TOB) ||
00104
00105 (idetA == PixelSubdetector::PixelBarrel && idetB == PixelSubdetector::PixelBarrel) ||
00106 (idetA == PixelSubdetector::PixelEndcap && idetB == PixelSubdetector::PixelEndcap) ||
00107 (idetA == PixelSubdetector::PixelBarrel && idetB == PixelSubdetector::PixelEndcap) ||
00108 (idetA == PixelSubdetector::PixelEndcap && idetB == PixelSubdetector::PixelBarrel) );
00109
00110 if (!same_det) return (idetA < idetB);
00111
00112 if( (idetA == StripSubdetector::TIB || idetA == StripSubdetector::TOB || idetA == PixelSubdetector::PixelBarrel) &&
00113 (idetB == StripSubdetector::TIB || idetB == StripSubdetector::TOB || idetB == PixelSubdetector::PixelBarrel)) {
00114 return static_cast<unsigned int>(geometry->idToDet(ida)->surface().toGlobal(a->localPosition()).perp() * 1E7) < static_cast<unsigned int>(geometry->idToDet(idb)->surface().toGlobal(b->localPosition()).perp() * 1E7);
00115 }
00116
00117 if( (idetA == StripSubdetector::TEC || idetA == StripSubdetector::TID || idetA == PixelSubdetector::PixelEndcap) &&
00118 (idetB == StripSubdetector::TEC || idetB == StripSubdetector::TID || idetB == PixelSubdetector::PixelEndcap)) {
00119 return static_cast<unsigned int>(std::abs(geometry->idToDet(ida)->surface().toGlobal(a->localPosition()).z()) * 1E7) < static_cast<unsigned int>(std::abs(geometry->idToDet(idb)->surface().toGlobal(b->localPosition()).z()) * 1E7);
00120 }
00121
00122
00123
00124
00125
00126 if( (idetA == StripSubdetector::TIB || idetA == StripSubdetector::TOB || idetA == PixelSubdetector::PixelBarrel) &&
00127 (idetB == StripSubdetector::TEC || idetB == StripSubdetector::TID || idetB == PixelSubdetector::PixelEndcap)) {
00128 return barrelForwardLess( a, b);
00129 }else{
00130 return !barrelForwardLess( b, a);
00131 }
00132
00133 throw Genexception("SortHitPointersByGlobalPosition: arguments are not Ok");
00134 }
00135
00136 bool SortHitPointersByGlobalPosition::barrelForwardLess( const TrackingRecHit* a, const TrackingRecHit* b) const{
00137
00138
00139
00140
00141 DetId ida(a->geographicalId());
00142 DetId idb(b->geographicalId());
00143 return static_cast<unsigned int>(std::abs( geometry->idToDet(ida)->surface().toGlobal(a->localPosition()).z()) * 1E7) < static_cast<unsigned int>(std::abs( geometry->idToDet(idb)->surface().toGlobal(b->localPosition()).z()) * 1E7);
00144 }
00145
00146 bool SortHitTrajectoryPairsByGlobalPosition::InsideOutCompare(const std::pair<TransientTrackingRecHit::ConstRecHitPointer, TrajectoryMeasurement*>& HitTM1 ,
00147 const std::pair<TransientTrackingRecHit::ConstRecHitPointer, TrajectoryMeasurement*>& HitTM2 ) const
00148 {
00149
00150
00151 DetId ida(HitTM1.first->det()->geographicalId());
00152 DetId idb(HitTM2.first->det()->geographicalId());
00153
00154
00155 LogDebug("RoadSearch")<<" Comparing (r/phi/z) Hit 1 on DetID "
00156 << ida.rawId() << " : "
00157 << HitTM1.first->globalPosition().perp() << " / "
00158 << HitTM1.first->globalPosition().phi() << " / "
00159 << HitTM1.first->globalPosition().z()
00160 << " and Hit 2 on DetID "
00161 << idb.rawId() << " : "
00162 << HitTM2.first->globalPosition().perp() << " / "
00163 << HitTM2.first->globalPosition().phi() << " / "
00164 << HitTM2.first->globalPosition().z() ;
00165
00166
00167 if( ((unsigned int)ida.subdetId() == StripSubdetector::TIB || (unsigned int)ida.subdetId() == StripSubdetector::TOB || (unsigned int)ida.subdetId() == PixelSubdetector::PixelBarrel) &&
00168 ((unsigned int)idb.subdetId() == StripSubdetector::TIB || (unsigned int)idb.subdetId() == StripSubdetector::TOB || (unsigned int)idb.subdetId() == PixelSubdetector::PixelBarrel)) {
00169 return static_cast<unsigned int>(HitTM1.first->globalPosition().perp() * 1E7) < static_cast<unsigned int>(HitTM2.first->globalPosition().perp() * 1E7);
00170 }
00171
00172 if( ((unsigned int)ida.subdetId() == StripSubdetector::TEC || (unsigned int)ida.subdetId() == StripSubdetector::TID || (unsigned int)ida.subdetId() == PixelSubdetector::PixelEndcap) &&
00173 ((unsigned int)idb.subdetId() == StripSubdetector::TEC || (unsigned int)idb.subdetId() == StripSubdetector::TID || (unsigned int)idb.subdetId() == PixelSubdetector::PixelEndcap)) {
00174 return static_cast<unsigned int>(std::abs(HitTM1.first->globalPosition().z()) * 1E7) < static_cast<unsigned int>(std::abs(HitTM2.first->globalPosition().z()) * 1E7);
00175 }
00176
00177
00178
00179
00180
00181 if( ((unsigned int)ida.subdetId() == StripSubdetector::TIB || (unsigned int)ida.subdetId() == StripSubdetector::TOB || (unsigned int)ida.subdetId() == PixelSubdetector::PixelBarrel) &&
00182 ((unsigned int)idb.subdetId() == StripSubdetector::TEC || (unsigned int)idb.subdetId() == StripSubdetector::TID || (unsigned int)idb.subdetId() == PixelSubdetector::PixelEndcap)) {
00183 LogDebug("RoadSearch") <<"*** How did this happen ?!?!? ***" ;
00184 }else{
00185 LogDebug("RoadSearch") <<"*** How did this happen ?!?!? ***" ;
00186 }
00187
00188
00189 throw Genexception("SortHitTrajectoryPairsByGlobalPosition: arguments are not Ok");
00190
00191
00192 }
00193