#include <Alignment/CommonAlignment/interface/AlignableNavigator.h>
Public Types | |
typedef std::map< DetId, AlignableDetOrUnitPtr > | MapType |
typedef MapType::value_type | PairType |
Public Member Functions | |
AlignableDet * | alignableDetFromDetId (const DetId &detid) |
Deprecated method for backward compatibility: If DetId belongs to a GeomDetUnit/AlignableDetUnit, giving an error and returning the mother of the AlignableDetUnit which is an AlignableDet. | |
AlignableDet * | alignableDetFromGeomDet (const GeomDet *geomDet) |
Deprecated method for backward compatibility: If geomDet is a GeomDetUnit, giving an error and returning the mother of the corresponding AlignableDetUnit which is an AlignableDet. | |
std::vector< AlignableDet * > | alignableDetsFromHits (const std::vector< const TransientTrackingRecHit * > &hitvec) |
For backward compatibility, use alignablesFromHits (cf. alignableDetFromDetId). | |
std::vector< AlignableDet * > | alignableDetsFromHits (const TransientTrackingRecHit::ConstRecHitContainer &hitVec) |
For backward compatibility, use alignablesFromHits (cf. alignableDetFromDetId). | |
AlignableDetOrUnitPtr | alignableFromDetId (const DetId &detid) |
Returns AlignableDetOrUnitPtr corresponding to given DetId. | |
AlignableDetOrUnitPtr | alignableFromGeomDet (const GeomDet *geomDet) |
Returns AlignableDetOrUnitPtr corresponding to given GeomDet. | |
AlignableNavigator (std::vector< Alignable * > alignables) | |
Constructor from list of Alignbable. | |
AlignableNavigator (Alignable *tracker, Alignable *muon=0) | |
Constructor from one or two Alignables. | |
std::vector < AlignableDetOrUnitPtr > | alignablesFromHits (const TransientTrackingRecHit::ConstRecHitContainer &hitVec) |
Returns vector of AlignableDetOrUnitPtr for given vector of Hits. | |
std::vector < AlignableDetOrUnitPtr > | alignablesFromHits (const std::vector< const TransientTrackingRecHit * > &hitvec) |
Returns vector AlignableDetOrUnitPtr for given vector of Hits. | |
bool | detAndSubdetInMap (const DetId &detid) const |
Given a DetId, returns true if DetIds with this detector and subdetector id are in the map (not necessarily the exact DetId). | |
int | size (void) |
Returns number of elements in map. | |
Private Member Functions | |
unsigned int | recursiveGetId (Alignable *alignable) |
Add recursively DetId-AlignableDetOrUnitPtr pairs to map. | |
Private Attributes | |
std::vector< std::pair< int, int > > | theDetAndSubdet |
MapType | theMap |
A map is created at construction time from all sub-structures of the constructor's argument(s) that are AlignableDet or AlignableDetUnit.
Definition at line 24 of file AlignableNavigator.h.
typedef std::map<DetId, AlignableDetOrUnitPtr> AlignableNavigator::MapType |
Definition at line 35 of file AlignableNavigator.h.
typedef MapType::value_type AlignableNavigator::PairType |
Definition at line 36 of file AlignableNavigator.h.
Constructor from one or two Alignables.
Definition at line 16 of file AlignableNavigator.cc.
References recursiveGetId(), and theMap.
00017 { 00018 theMap.clear(); 00019 00020 const unsigned int numNonDets = this->recursiveGetId(tracker) + this->recursiveGetId(muon); 00021 if (numNonDets) { 00022 edm::LogWarning("Alignment") <<"@SUB=AlignableNavigator" << "Created with map of size " 00023 << theMap.size() << ", but found also " << numNonDets 00024 << " Alignables that have DetId!=0,\nbeing neither " 00025 << "AlignableDet nor AlignableDetUnit. This will " 00026 << "lead to an exception in case alignableFromDetId(..) " 00027 << "is called for one of these DetIds.\n" 00028 << "If there is no exception, you can ignore this message."; 00029 } else { 00030 edm::LogInfo("Alignment") <<"@SUB=AlignableNavigator" << "Created with map of size " 00031 << theMap.size() << "."; 00032 } 00033 }
AlignableNavigator::AlignableNavigator | ( | std::vector< Alignable * > | alignables | ) | [explicit] |
Constructor from list of Alignbable.
Definition at line 38 of file AlignableNavigator.cc.
References it, recursiveGetId(), and theMap.
00039 { 00040 theMap.clear(); 00041 00042 unsigned int numNonDets = 0; 00043 for ( std::vector<Alignable*>::iterator it = alignables.begin(); it != alignables.end(); ++it ) { 00044 numNonDets += this->recursiveGetId(*it); 00045 } 00046 if (numNonDets) { 00047 edm::LogWarning("Alignment") <<"@SUB=AlignableNavigator" << "Created with map of size " 00048 << theMap.size() << ", but found also " << numNonDets 00049 << " Alignables that have DetId!=0,\nbeing neither " 00050 << "AlignableDet nor AlignableDetUnit. This will " 00051 << "lead to an exception in case alignableFromDetId(..) " 00052 << "is called for one of these DetIds.\n" 00053 << "If there is no exception, you can ignore this message."; 00054 } else { 00055 edm::LogInfo("Alignment") <<"@SUB=AlignableNavigator" << "created with map of size " 00056 << theMap.size() << "."; 00057 } 00058 }
AlignableDet * AlignableNavigator::alignableDetFromDetId | ( | const DetId & | detid | ) |
Deprecated method for backward compatibility: If DetId belongs to a GeomDetUnit/AlignableDetUnit, giving an error and returning the mother of the AlignableDetUnit which is an AlignableDet.
This could lead to inconsistencies. Use alignableFromGeomDet instead.
Definition at line 85 of file AlignableNavigator.cc.
References AlignableDetOrUnitPtr::alignableDet(), AlignableDetOrUnitPtr::alignableDetUnit(), alignableFromDetId(), Exception, and Alignable::mother().
Referenced by alignableDetFromGeomDet().
00086 { 00087 AlignableDetOrUnitPtr ali = this->alignableFromDetId(detId); 00088 AlignableDet *aliDet = ali.alignableDet(); 00089 if (!aliDet) { 00090 AlignableDetUnit *aliDetUnit = ali.alignableDetUnit(); 00091 if (!aliDetUnit) { 00092 throw cms::Exception("BadAssociation") 00093 << "[AlignableNavigator::alignableDetFromDetId]" 00094 << " Neither AlignableDet nor AlignableDetUnit"; 00095 } 00096 aliDet = dynamic_cast<AlignableDet*>(aliDetUnit->mother()); 00097 if (!aliDet) { 00098 throw cms::Exception("BadLogic") 00099 << "[AlignableNavigator::alignableDetFromDetId]" << " AlignableDetUnit, but " 00100 << (aliDetUnit->mother() ? " mother not an AlignableDet." : "without mother."); 00101 } 00102 edm::LogWarning("Alignment") << "@SUB=AlignableNavigator::alignableDetFromDetId" 00103 << "Returning AlignableDet although DetId belongs" 00104 << " to AlignableDetUnit. Might become exception in future," 00105 << " use alignableFromDetId/GeomDet instead!"; 00106 } 00107 return aliDet; 00108 }
AlignableDet * AlignableNavigator::alignableDetFromGeomDet | ( | const GeomDet * | geomDet | ) |
Deprecated method for backward compatibility: If geomDet is a GeomDetUnit, giving an error and returning the mother of the corresponding AlignableDetUnit which is an AlignableDet.
This could lead to inconsistencies. Use alignableFromGeomDet instead.
Definition at line 79 of file AlignableNavigator.cc.
References alignableDetFromDetId(), and GeomDet::geographicalId().
Referenced by CurrentAlignmentKFUpdator::includeCurrentAlignmentEstimate().
00080 { 00081 return alignableDetFromDetId( geomDet->geographicalId() ); 00082 }
std::vector< AlignableDet * > AlignableNavigator::alignableDetsFromHits | ( | const std::vector< const TransientTrackingRecHit * > & | hitvec | ) |
For backward compatibility, use alignablesFromHits (cf. alignableDetFromDetId).
Definition at line 187 of file AlignableNavigator.cc.
References HLT_VtxMuL3::result.
00188 { 00189 std::vector<AlignableDet*> result; 00190 result.reserve(hitvec.size()); 00191 00192 for(std::vector<const TransientTrackingRecHit*>::const_iterator ih 00193 = hitvec.begin(), iEnd = hitvec.end(); ih != iEnd; ++ih) { 00194 result.push_back(this->alignableDetFromDetId((*ih)->geographicalId())); 00195 } 00196 00197 return result; 00198 }
std::vector< AlignableDet * > AlignableNavigator::alignableDetsFromHits | ( | const TransientTrackingRecHit::ConstRecHitContainer & | hitVec | ) |
For backward compatibility, use alignablesFromHits (cf. alignableDetFromDetId).
Definition at line 203 of file AlignableNavigator.cc.
References it, and HLT_VtxMuL3::result.
00204 { 00205 std::vector<AlignableDet*> result; 00206 result.reserve(hitVec.size()); 00207 00208 for (TransientTrackingRecHit::ConstRecHitContainer::const_iterator it 00209 = hitVec.begin(), iEnd = hitVec.end(); it != iEnd; ++it) { 00210 result.push_back(this->alignableDetFromDetId((*it)->geographicalId())); 00211 } 00212 00213 return result; 00214 }
AlignableDetOrUnitPtr AlignableNavigator::alignableFromDetId | ( | const DetId & | detid | ) |
Returns AlignableDetOrUnitPtr corresponding to given DetId.
Definition at line 67 of file AlignableNavigator.cc.
References DetId::rawId(), and theMap.
Referenced by alignableDetFromDetId(), alignableFromGeomDet(), SurveyInputCSCfromPins::beginJob(), AlignmentMonitorMuonHIP::event(), AlignmentMonitorTemplate::event(), AlignmentMonitorGeneric::event(), MuonAlignment::moveAlignableGlobalCoord(), MuonAlignment::moveAlignableLocalCoord(), and KalmanAlignmentTrackRefitter::refitTracks().
00068 { 00069 00070 MapType::iterator position = theMap.find( detid ); 00071 if ( position != theMap.end() ) return position->second; 00072 throw cms::Exception("BadLogic") 00073 << "[AlignableNavigator::alignableDetFromDetId] DetId " << detid.rawId() << " not found"; 00074 00075 return static_cast<AlignableDet*>(0); 00076 }
AlignableDetOrUnitPtr AlignableNavigator::alignableFromGeomDet | ( | const GeomDet * | geomDet | ) |
Returns AlignableDetOrUnitPtr corresponding to given GeomDet.
Definition at line 61 of file AlignableNavigator.cc.
References alignableFromDetId(), and GeomDet::geographicalId().
Referenced by MillePedeAlignmentAlgorithm::addMeasurementData(), and HIPAlignmentAlgorithm::run().
00062 { 00063 return alignableFromDetId( geomDet->geographicalId() ); 00064 }
std::vector< AlignableDetOrUnitPtr > AlignableNavigator::alignablesFromHits | ( | const TransientTrackingRecHit::ConstRecHitContainer & | hitVec | ) |
Returns vector of AlignableDetOrUnitPtr for given vector of Hits.
Definition at line 171 of file AlignableNavigator.cc.
References it, and HLT_VtxMuL3::result.
00172 { 00173 00174 std::vector<AlignableDetOrUnitPtr> result; 00175 result.reserve(hitVec.size()); 00176 00177 for (TransientTrackingRecHit::ConstRecHitContainer::const_iterator it 00178 = hitVec.begin(), iEnd = hitVec.end(); it != iEnd; ++it) { 00179 result.push_back(this->alignableFromDetId((*it)->geographicalId())); 00180 } 00181 00182 return result; 00183 }
std::vector< AlignableDetOrUnitPtr > AlignableNavigator::alignablesFromHits | ( | const std::vector< const TransientTrackingRecHit * > & | hitvec | ) |
Returns vector AlignableDetOrUnitPtr for given vector of Hits.
Definition at line 155 of file AlignableNavigator.cc.
References HLT_VtxMuL3::result.
Referenced by SingleTrajectoryUpdator::process(), and HIPAlignmentAlgorithm::run().
00156 { 00157 std::vector<AlignableDetOrUnitPtr> result; 00158 result.reserve(hitvec.size()); 00159 00160 for(std::vector<const TransientTrackingRecHit*>::const_iterator ih 00161 = hitvec.begin(), iEnd = hitvec.end(); ih != iEnd; ++ih) { 00162 result.push_back(this->alignableFromDetId((*ih)->geographicalId())); 00163 } 00164 00165 return result; 00166 }
Given a DetId, returns true if DetIds with this detector and subdetector id are in the map (not necessarily the exact DetId).
Definition at line 218 of file AlignableNavigator.cc.
References DetId::det(), i, DetId::subdetId(), and theDetAndSubdet.
Referenced by AlignmentMonitorMuonHIP::event(), AlignmentMonitorTemplate::event(), AlignmentMonitorMuonResiduals::event(), and HIPAlignmentAlgorithm::run().
00219 { 00220 int det = detid.det(); 00221 int subdet = detid.subdetId(); 00222 for (std::vector<std::pair<int, int> >::const_iterator i = theDetAndSubdet.begin(); i != theDetAndSubdet.end(); ++i) { 00223 if (det == i->first && subdet == i->second) return true; 00224 } 00225 return false; 00226 }
Add recursively DetId-AlignableDetOrUnitPtr pairs to map.
Returns number of Alignables with DetId!=0 which are (illegaly) neither AlignableDet nor AlignableDetUnit and are thus not added to the map.
Definition at line 112 of file AlignableNavigator.cc.
References align::AlignableDet, Alignable::alignableObjectId(), Alignable::components(), DetId::det(), detId, Alignable::geomDetId(), it, DetId::rawId(), DetId::subdetId(), theDetAndSubdet, and theMap.
Referenced by AlignableNavigator().
00113 { 00114 // Recursive method to get the detIds of an alignable and its childs 00115 // and add the to the map. 00116 // Returns number of Alignables with DetId which are neither AlignableDet 00117 // nor AlignableDetUnit and are thus not added to the map. 00118 00119 if (!alignable) return 0; 00120 00121 unsigned int nProblem = 0; 00122 const DetId detId(alignable->geomDetId()); 00123 if ( detId.rawId()) { 00124 AlignableDet *aliDet = dynamic_cast<AlignableDet*>(alignable); 00125 if (aliDet) { 00126 theMap.insert( PairType( detId, aliDet ) ); 00127 } else { 00128 AlignableDetUnit *aliDetUnit = dynamic_cast<AlignableDetUnit*>(alignable); 00129 if (aliDetUnit) { 00130 theMap.insert( PairType( detId, aliDetUnit ) ); 00131 } else { 00132 nProblem = 1; // equivalent to '++nProblem;' which could confuse to be ina loop... 00133 // Cannot be an exception since it happens (illegaly) in Muon DT hierarchy: 00134 // throw cms::Exception("BadLogic") 00135 // << "[AlignableNavigator::recursiveGetId] Alignable with DetId " << detId.rawId() 00136 // << " neither AlignableDet nor AlignableDetUnit"; 00137 } 00138 } 00139 if (!nProblem && !this->detAndSubdetInMap(detId)) { 00140 theDetAndSubdet.push_back(std::pair<int, int>( detId.det(), detId.subdetId() )); 00141 } 00142 } 00143 std::vector<Alignable*> comp = alignable->components(); 00144 if ( alignable->alignableObjectId() != align::AlignableDet 00145 || comp.size() > 1 ) { // Non-glued AlignableDets contain themselves 00146 for ( std::vector<Alignable*>::iterator it = comp.begin(); it != comp.end(); ++it ) { 00147 nProblem += this->recursiveGetId(*it); 00148 } 00149 } 00150 return nProblem; 00151 }
Returns number of elements in map.
Definition at line 72 of file AlignableNavigator.h.
References theMap.
00072 { return theMap.size(); }
std::vector<std::pair<int,int> > AlignableNavigator::theDetAndSubdet [private] |
Definition at line 84 of file AlignableNavigator.h.
Referenced by detAndSubdetInMap(), and recursiveGetId().
MapType AlignableNavigator::theMap [private] |
Definition at line 83 of file AlignableNavigator.h.
Referenced by alignableFromDetId(), AlignableNavigator(), recursiveGetId(), and size().