CMS 3D CMS Logo

AlignableTracker.cc

Go to the documentation of this file.
00001 #include "Alignment/TrackerAlignment/interface/AlignableTracker.h"
00002 
00003 #include "FWCore/Utilities/interface/Exception.h"
00004  
00005 // Geometry
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 // Alignment
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() ) // id not yet known
00025 {
00026 
00027   // Get levels from geometry
00028   // for strip we create also <TIB/TID/TOB/TEC>ModuleUnit list for 1D components of 2D layers
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(); // as all composites: id of first component
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;// If we need also units, they will be at moduleName + "Unit".
00057 
00058   for (unsigned int i = 0; i < nDet; ++i) {
00059    
00060     const unsigned int subdetId = dets[i]->geographicalId().subdetId();//don't check det()==Tracker
00061     if (subdetId == PixelSubdetector::PixelBarrel || subdetId == PixelSubdetector::PixelEndcap) {
00062       // Treat all pixel dets in same way with one AlignableDetUnit.
00063       if (dets[i]->components().size()) { // GeomDetUnit does not have any components!
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       // In strip we have:
00072       // 1) 'Pure' 1D-modules like TOB layers 3-6 (not glued): AlignableDetUnit
00073       // 2) Composite 2D-modules like TOB layers 1&2 (not glued): AlignableDet
00074       // 3) The two 1D-components of case 2 (glued): AlignableDetUnit that is constructed
00075       //      inside AlignableDet-constructor of 'mother', only need to add to alignableLists_
00076       const SiStripDetId detId(dets[i]->geographicalId());
00077       if (!detId.glued()) { // 2D- or 'pure' 1D-module
00078         if (dets[i]->components().size()) { // 2D-module
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)); // components constructed within
00085           const align::Alignables detUnits(alis.back()->components());
00086           // Ensure pointer existence and make list available via moduleName appended with "Unit"
00087           if (!aliUnits) {
00088             aliUnits = &alignableLists_.get(moduleName + "Unit");
00089             aliUnits->reserve(576); // ugly hardcode to save some memory due to vector doubling
00090           }
00091           aliUnits->insert(aliUnits->end(), detUnits.begin(), detUnits.end()); // only 2...
00092         } else { // no components: pure 1D-module
00093           alis.push_back(new AlignableDetUnit(dets[i]->geographicalId().rawId(), dets[i]->surface()));
00094         }
00095       } // no else: glued components of AlignableDet constructed within AlignableDet, see above
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); // max 22 ladders per layer
00135   builder.addLevelInfo(align::TPBLayer     , false, 3); // 3 layers per half barrel
00136   builder.addLevelInfo(align::TPBHalfBarrel, false, 2); // 2 half barrels in TPB
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); // 2 panels per blade
00148   builder.addLevelInfo(align::TPEBlade       , true, 12); // 12 blades per half disk
00149   builder.addLevelInfo(align::TPEHalfDisk    , false, 3); // max 3 disks per cylinder
00150   builder.addLevelInfo(align::TPEHalfCylinder, false, 2); // 2 HC per endcap
00151   builder.addLevelInfo(align::TPEEndcap      , false, 2); // 2 endcaps in TPE
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); // max 22 strings per surface
00161   builder.addLevelInfo(align::TIBSurface   , false, 2); // 2 surfaces per half shell
00162   builder.addLevelInfo(align::TIBHalfShell , false, 2); // 2 half shells per layer
00163   builder.addLevelInfo(align::TIBLayer     , false, 4); // 4 layers per half barrel
00164   builder.addLevelInfo(align::TIBHalfBarrel, false, 2); // 2 half barrels in TIB
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); // 2 sides per ring
00176   builder.addLevelInfo(align::TIDRing  , false, 3); // 3 rings per disk
00177   builder.addLevelInfo(align::TIDDisk  , false, 3); // 3 disks per endcap
00178   builder.addLevelInfo(align::TIDEndcap, false, 2); // 2 endcaps in TID
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); // max 74 rods per layer
00188   builder.addLevelInfo(align::TOBLayer     , false, 6); // 6 layers per half barrel
00189   builder.addLevelInfo(align::TOBHalfBarrel, false, 2); // 2 half barrels in TOB
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); // max 7 rings per petal
00201   builder.addLevelInfo(align::TECPetal , true,  8); // 8 petals per side
00202   builder.addLevelInfo(align::TECSide  , false, 2); // 2 sides per disk
00203   builder.addLevelInfo(align::TECDisk  , false, 9); // 9 disks per endcap
00204   builder.addLevelInfo(align::TECEndcap, false, 2); // 2 endcaps in TEC
00205   builder.buildAll( alignableLists_ );
00206 }
00207 
00208 //__________________________________________________________________________________________________
00209 void AlignableTracker::buildTRK()
00210 {
00211   // Build pixel, strip and full tracker 'by hand':
00212   
00213   // First create pixel:
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   // Now create strip:
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   // Finally add strip and pixel to tracker - that of course already exists:
00239   align::Alignables &tracker = alignableLists_.get("Tracker");
00240   tracker.reserve(1);
00241   tracker.push_back(this);
00242   this->addComponent(pixel[0]); // add to tracker
00243   this->addComponent(strip[0]); // add to tracker
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   // Add components recursively
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   // Add components recursively
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 }

Generated on Tue Jun 9 17:25:02 2009 for CMSSW by  doxygen 1.5.4