00001 #include "Alignment/TrackerAlignment/interface/AlignableTracker.h"
00002
00003 #include "FWCore/Utilities/interface/Exception.h"
00004
00005
00006 #include "Geometry/CommonDetUnit/interface/GeomDet.h"
00007 #include "Geometry/TrackerGeometryBuilder/interface/GluedGeomDet.h"
00008 #include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h"
00009 #include "DataFormats/SiStripDetId/interface/SiStripDetId.h"
00010 #include "DataFormats/SiPixelDetId/interface/PixelSubdetector.h"
00011
00012
00013 #include "Alignment/CommonAlignment/interface/AlignableBuilder.h"
00014 #include "Alignment/CommonAlignment/interface/AlignableObjectId.h"
00015 #include "Alignment/TrackerAlignment/interface/AlignableSiStripDet.h"
00016 #include "Alignment/CommonAlignment/interface/AlignableDetUnit.h"
00017
00018 #include "CondFormats/Alignment/interface/Alignments.h"
00019 #include "CondFormats/Alignment/interface/AlignmentErrors.h"
00020 #include "CondFormats/Alignment/interface/AlignmentSorter.h"
00021
00022
00023 AlignableTracker::AlignableTracker( const TrackerGeometry* tkGeom ):
00024 AlignableComposite( 0, align::Tracker, RotationType() )
00025 {
00026
00027
00028
00029 detsToAlignables(tkGeom->detsPXB(), "TPBModule");
00030 detsToAlignables(tkGeom->detsPXF(), "TPEModule");
00031 detsToAlignables(tkGeom->detsTIB(), "TIBModule");
00032 detsToAlignables(tkGeom->detsTID(), "TIDModule");
00033 detsToAlignables(tkGeom->detsTOB(), "TOBModule");
00034 detsToAlignables(tkGeom->detsTEC(), "TECModule");
00035
00036 buildTPB();
00037 buildTPE();
00038 buildTIB();
00039 buildTID();
00040 buildTOB();
00041 buildTEC();
00042 buildTRK();
00043
00044 theId = this->components()[0]->id();
00045 }
00046
00047
00048
00049 void AlignableTracker::detsToAlignables( const TrackingGeometry::DetContainer& dets,
00050 const std::string& moduleName )
00051 {
00052 unsigned int nDet = dets.size();
00053
00054 align::Alignables& alis = alignableLists_.get(moduleName);
00055 alis.reserve(nDet);
00056 align::Alignables *aliUnits = 0;
00057
00058 for (unsigned int i = 0; i < nDet; ++i) {
00059
00060 const unsigned int subdetId = dets[i]->geographicalId().subdetId();
00061 if (subdetId == PixelSubdetector::PixelBarrel || subdetId == PixelSubdetector::PixelEndcap) {
00062
00063 if (dets[i]->components().size()) {
00064 throw cms::Exception("LogicError")
00065 << "[AlignableTracker] Pixel GeomDet (subdetector " << subdetId << ") with "
00066 << dets[i]->components().size() << "components.\n";
00067 }
00068 alis.push_back(new AlignableDetUnit(dets[i]->geographicalId().rawId(), dets[i]->surface()));
00069 } else if (subdetId == SiStripDetId::TIB || subdetId == SiStripDetId::TID
00070 || subdetId == SiStripDetId::TOB || subdetId == SiStripDetId::TEC) {
00071
00072
00073
00074
00075
00076 const SiStripDetId detId(dets[i]->geographicalId());
00077 if (!detId.glued()) {
00078 if (dets[i]->components().size()) {
00079 const GluedGeomDet *gluedDet = dynamic_cast<GluedGeomDet*>(dets[i]);
00080 if (!gluedDet) {
00081 throw cms::Exception("LogicError")
00082 << "[AlignableTracker]" << "dynamic_cast<GluedGeomDet*> failed";
00083 }
00084 alis.push_back(new AlignableSiStripDet(gluedDet));
00085 const align::Alignables detUnits(alis.back()->components());
00086
00087 if (!aliUnits) {
00088 aliUnits = &alignableLists_.get(moduleName + "Unit");
00089 aliUnits->reserve(576);
00090 }
00091 aliUnits->insert(aliUnits->end(), detUnits.begin(), detUnits.end());
00092 } else {
00093 alis.push_back(new AlignableDetUnit(dets[i]->geographicalId().rawId(), dets[i]->surface()));
00094 }
00095 }
00096 } else {
00097 throw cms::Exception("LogicError")
00098 << "[AlignableTracker] GeomDet of unknown subdetector.";
00099 }
00100 }
00101
00102 LogDebug("Alignment") << "@SUB=AlignableTracker"
00103 << alis.size() << " AlignableDet(Unit)s for " << moduleName;
00104 if (aliUnits) {
00105 LogDebug("Alignment") << "@SUB=AlignableTracker"
00106 << aliUnits->size() << " AlignableDetUnits for "
00107 << moduleName + "Unit (capacity = " << aliUnits->capacity() << ").";
00108 }
00109
00110 }
00111
00112
00113
00114 void AlignableTracker::buildBarrel(const std::string& subDet)
00115 {
00116 AlignableObjectId objId;
00117
00118 align::Alignables& halfBarrels = alignableLists_.find(subDet + "HalfBarrel");
00119
00120 const std::string barrelName(subDet + "Barrel");
00121 align::Alignables &barrel = alignableLists_.get(barrelName);
00122 barrel.reserve(1);
00123 barrel.push_back(new AlignableComposite(halfBarrels[0]->id(), objId.nameToType(barrelName),
00124 RotationType()));
00125 barrel[0]->addComponent(halfBarrels[0]);
00126 barrel[0]->addComponent(halfBarrels[1]);
00127 }
00128
00129
00130 void AlignableTracker::buildTPB()
00131 {
00132 AlignableBuilder builder(align::TPBModule, tkCounters_ );
00133
00134 builder.addLevelInfo(align::TPBLadder , true, 22);
00135 builder.addLevelInfo(align::TPBLayer , false, 3);
00136 builder.addLevelInfo(align::TPBHalfBarrel, false, 2);
00137 builder.buildAll( alignableLists_ );
00138
00139 buildBarrel("TPB");
00140 }
00141
00142
00143 void AlignableTracker::buildTPE()
00144 {
00145 AlignableBuilder builder(align::TPEModule, tkCounters_);
00146
00147 builder.addLevelInfo(align::TPEPanel , true, 2);
00148 builder.addLevelInfo(align::TPEBlade , true, 12);
00149 builder.addLevelInfo(align::TPEHalfDisk , false, 3);
00150 builder.addLevelInfo(align::TPEHalfCylinder, false, 2);
00151 builder.addLevelInfo(align::TPEEndcap , false, 2);
00152 builder.buildAll( alignableLists_ );
00153 }
00154
00155
00156 void AlignableTracker::buildTIB()
00157 {
00158 AlignableBuilder builder(align::TIBModule, tkCounters_);
00159
00160 builder.addLevelInfo(align::TIBString , true, 28);
00161 builder.addLevelInfo(align::TIBSurface , false, 2);
00162 builder.addLevelInfo(align::TIBHalfShell , false, 2);
00163 builder.addLevelInfo(align::TIBLayer , false, 4);
00164 builder.addLevelInfo(align::TIBHalfBarrel, false, 2);
00165 builder.buildAll( alignableLists_ );
00166
00167 buildBarrel("TIB");
00168 }
00169
00170
00171 void AlignableTracker::buildTID()
00172 {
00173 AlignableBuilder builder(align::TIDModule, tkCounters_);
00174
00175 builder.addLevelInfo(align::TIDSide , false, 2);
00176 builder.addLevelInfo(align::TIDRing , false, 3);
00177 builder.addLevelInfo(align::TIDDisk , false, 3);
00178 builder.addLevelInfo(align::TIDEndcap, false, 2);
00179 builder.buildAll( alignableLists_ );
00180 }
00181
00182
00183 void AlignableTracker::buildTOB()
00184 {
00185 AlignableBuilder builder(align::TOBModule, tkCounters_);
00186
00187 builder.addLevelInfo(align::TOBRod , true, 74);
00188 builder.addLevelInfo(align::TOBLayer , false, 6);
00189 builder.addLevelInfo(align::TOBHalfBarrel, false, 2);
00190 builder.buildAll( alignableLists_ );
00191
00192 buildBarrel("TOB");
00193 }
00194
00195
00196 void AlignableTracker::buildTEC()
00197 {
00198 AlignableBuilder builder(align::TECModule, tkCounters_);
00199
00200 builder.addLevelInfo(align::TECRing , true, 7);
00201 builder.addLevelInfo(align::TECPetal , true, 8);
00202 builder.addLevelInfo(align::TECSide , false, 2);
00203 builder.addLevelInfo(align::TECDisk , false, 9);
00204 builder.addLevelInfo(align::TECEndcap, false, 2);
00205 builder.buildAll( alignableLists_ );
00206 }
00207
00208
00209 void AlignableTracker::buildTRK()
00210 {
00211
00212
00213
00214 const align::Alignables &pixelBarrel = alignableLists_.find("TPBBarrel");
00215 const align::Alignables &pixelEndcap = alignableLists_.find("TPEEndcap");
00216 align::Alignables &pixel = alignableLists_.get("Pixel");
00217 pixel.reserve(1);
00218 pixel.push_back(new AlignableComposite(pixelBarrel[0]->id(), align::Pixel, RotationType()));
00219 pixel[0]->addComponent(pixelBarrel[0]);
00220 pixel[0]->addComponent(pixelEndcap[0]);
00221 pixel[0]->addComponent(pixelEndcap[1]);
00222
00223
00224 const align::Alignables &innerBarrel = alignableLists_.find("TIBBarrel");
00225 const align::Alignables &outerBarrel = alignableLists_.find("TOBBarrel");
00226 const align::Alignables &innerEndcap = alignableLists_.find("TIDEndcap");
00227 const align::Alignables &outerEndcap = alignableLists_.find("TECEndcap");
00228 align::Alignables &strip = alignableLists_.get("Strip");
00229 strip.reserve(1);
00230 strip.push_back(new AlignableComposite(innerBarrel[0]->id(), align::Strip, RotationType()));
00231 strip[0]->addComponent(innerBarrel[0]);
00232 strip[0]->addComponent(innerEndcap[0]);
00233 strip[0]->addComponent(innerEndcap[1]);
00234 strip[0]->addComponent(outerBarrel[0]);
00235 strip[0]->addComponent(outerEndcap[0]);
00236 strip[0]->addComponent(outerEndcap[1]);
00237
00238
00239 align::Alignables &tracker = alignableLists_.get("Tracker");
00240 tracker.reserve(1);
00241 tracker.push_back(this);
00242 this->addComponent(pixel[0]);
00243 this->addComponent(strip[0]);
00244
00245 }
00246
00247
00248
00249 align::Alignables AlignableTracker::merge( const Alignables& list1,
00250 const Alignables& list2 ) const
00251 {
00252 Alignables all = list1;
00253
00254 all.insert( all.end(), list2.begin(), list2.end() );
00255
00256 return all;
00257 }
00258
00259
00260
00261 Alignments* AlignableTracker::alignments( void ) const
00262 {
00263
00264 align::Alignables comp = this->components();
00265 Alignments* m_alignments = new Alignments();
00266
00267 for ( align::Alignables::iterator i=comp.begin(); i!=comp.end(); i++ )
00268 {
00269 Alignments* tmpAlignments = (*i)->alignments();
00270 std::copy( tmpAlignments->m_align.begin(), tmpAlignments->m_align.end(),
00271 std::back_inserter(m_alignments->m_align) );
00272 delete tmpAlignments;
00273 }
00274
00275 std::sort( m_alignments->m_align.begin(), m_alignments->m_align.end(),
00276 lessAlignmentDetId<AlignTransform>() );
00277
00278 return m_alignments;
00279
00280 }
00281
00282
00283
00284 AlignmentErrors* AlignableTracker::alignmentErrors( void ) const
00285 {
00286
00287 align::Alignables comp = this->components();
00288 AlignmentErrors* m_alignmentErrors = new AlignmentErrors();
00289
00290
00291 for ( align::Alignables::iterator i=comp.begin(); i!=comp.end(); i++ )
00292 {
00293 AlignmentErrors* tmpAlignmentErrors = (*i)->alignmentErrors();
00294 std::copy( tmpAlignmentErrors->m_alignError.begin(), tmpAlignmentErrors->m_alignError.end(),
00295 std::back_inserter(m_alignmentErrors->m_alignError) );
00296 delete tmpAlignmentErrors;
00297 }
00298
00299 std::sort( m_alignmentErrors->m_alignError.begin(), m_alignmentErrors->m_alignError.end(),
00300 lessAlignmentDetId<AlignTransformError>() );
00301
00302 return m_alignmentErrors;
00303
00304 }