Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 14:26:12

0001 /** \class MuonNavigationPrinter
0002  *
0003  * Description:
0004  *  class to print the MuonNavigationSchool
0005  *
0006  *
0007  * \author : Stefano Lacaprara - INFN Padova <stefano.lacaprara@pd.infn.it>
0008  *
0009  * Modification:
0010  *
0011  * Chang Liu:
0012  * add compatibleLayers
0013  * add constructor for MuonTkNavigation
0014  *
0015  * Cesare Calabria:
0016  * GEMs implementation.
0017  * David Nash:
0018  * ME0s implementation.
0019  */
0020 
0021 #include "RecoMuon/Navigation/interface/MuonNavigationPrinter.h"
0022 
0023 #include "TrackingTools/DetLayers/interface/BarrelDetLayer.h"
0024 #include "TrackingTools/DetLayers/interface/ForwardDetLayer.h"
0025 #include "DataFormats/GeometrySurface/interface/BoundCylinder.h"
0026 #include "DataFormats/GeometrySurface/interface/BoundDisk.h"
0027 #include "RecoMuon/DetLayers/interface/MuonDetLayerGeometry.h"
0028 #include "RecoTracker/TkDetLayers/interface/GeometricSearchTracker.h"
0029 #include "RecoMuon/Navigation/interface/MuonNavigationSchool.h"
0030 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0031 
0032 #include <iostream>
0033 #include <iomanip>
0034 using namespace std;
0035 
0036 // #define VI_DEBUG
0037 
0038 #ifdef VI_DEBUG
0039 #define PRINT(x) std::cout << x << ' '
0040 #else
0041 #define PRINT(x) edm::LogInfo(x)
0042 #endif
0043 
0044 MuonNavigationPrinter::MuonNavigationPrinter(const MuonDetLayerGeometry* muonLayout,
0045                                              MuonNavigationSchool const& sh,
0046                                              bool enableCSC,
0047                                              bool enableRPC,
0048                                              bool enableGEM,
0049                                              bool enableME0)
0050     : school(&sh) {
0051   PRINT("MuonNavigationPrinter") << "MuonNavigationPrinter::MuonNavigationPrinter" << std::endl;
0052   PRINT("MuonNavigationPrinter") << "================================" << std::endl;
0053   PRINT("MuonNavigationPrinter") << "BARREL:" << std::endl;
0054   vector<const DetLayer*> barrel;
0055   if (enableRPC)
0056     barrel = muonLayout->allBarrelLayers();
0057   else
0058     barrel = muonLayout->allDTLayers();
0059 
0060   PRINT("MuonNavigationPrinter") << "There are " << barrel.size() << " Barrel DetLayers";
0061   for (auto i : barrel)
0062     printLayer(i);
0063   PRINT("MuonNavigationPrinter") << "================================" << std::endl;
0064   PRINT("MuonNavigationPrinter") << "BACKWARD:" << std::endl;
0065 
0066   vector<const DetLayer*> backward;
0067 
0068   if (enableCSC & enableGEM & enableRPC & enableME0)
0069     backward = muonLayout->allBackwardLayers();
0070   else if (enableCSC & enableGEM & !enableRPC & !enableME0)
0071     backward = muonLayout->allCscGemBackwardLayers();  // CSC + GEM
0072   else if (!enableCSC & enableGEM & !enableRPC & !enableME0)
0073     backward = muonLayout->backwardGEMLayers();  //GEM only
0074   else if (enableCSC & !enableGEM & !enableRPC & !enableME0)
0075     backward = muonLayout->backwardCSCLayers();  //CSC only
0076   else if (enableCSC & !enableGEM & !enableRPC & enableME0)
0077     backward = muonLayout->allCscME0BackwardLayers();  //CSC + ME0
0078   else if (!enableCSC & !enableGEM & !enableRPC & enableME0)
0079     backward = muonLayout->backwardME0Layers();  //ME0 only
0080   else
0081     backward = muonLayout->allBackwardLayers();
0082 
0083   PRINT("MuonNavigationPrinter") << "There are " << backward.size() << " Backward DetLayers";
0084   for (auto i : backward)
0085     printLayer(i);
0086   PRINT("MuonNavigationPrinter") << "==============================" << std::endl;
0087   PRINT("MuonNavigationPrinter") << "FORWARD:" << std::endl;
0088   vector<const DetLayer*> forward;
0089 
0090   if (enableCSC & enableGEM & enableRPC & enableME0)
0091     forward = muonLayout->allForwardLayers();
0092   else if (enableCSC & enableGEM & !enableRPC & !enableME0)
0093     forward = muonLayout->allCscGemForwardLayers();  // CSC + GEM
0094   else if (!enableCSC & enableGEM & !enableRPC & !enableME0)
0095     forward = muonLayout->forwardGEMLayers();  //GEM only
0096   else if (enableCSC & !enableGEM & !enableRPC & !enableME0)
0097     forward = muonLayout->forwardCSCLayers();  //CSC only
0098   else if (enableCSC & !enableGEM & !enableRPC & enableME0)
0099     forward = muonLayout->allCscME0ForwardLayers();  //CSC + ME0
0100   else if (!enableCSC & !enableGEM & !enableRPC & enableME0)
0101     forward = muonLayout->forwardME0Layers();  //ME0 only
0102   else
0103     forward = muonLayout->allForwardLayers();
0104 
0105   PRINT("MuonNavigationPrinter") << "There are " << forward.size() << " Forward DetLayers" << std::endl;
0106   for (auto i : forward)
0107     printLayer(i);
0108 }
0109 
0110 MuonNavigationPrinter::MuonNavigationPrinter(const MuonDetLayerGeometry* muonLayout,
0111                                              MuonNavigationSchool const& sh,
0112                                              const GeometricSearchTracker* tracker)
0113     : school(&sh) {
0114   PRINT("MuonNavigationPrinter") << "MuonNavigationPrinter::MuonNavigationPrinter" << std::endl;
0115   //  vector<BarrelDetLayer*>::const_iterator tkiter;
0116   //  vector<ForwardDetLayer*>::const_iterator tkfiter;
0117   PRINT("MuonNavigationPrinter") << "================================" << std::endl;
0118   PRINT("MuonNavigationPrinter") << "BARREL:" << std::endl;
0119   const vector<const BarrelDetLayer*>& tkbarrel = tracker->barrelLayers();
0120   PRINT("MuonNavigationPrinter") << "There are " << tkbarrel.size() << " Tk Barrel DetLayers" << std::endl;
0121   //  for ( tkiter = tkbarrel.begin(); tkiter != tkbarrel.end(); tkiter++ ) printLayer(*tkiter);
0122   vector<const DetLayer*> barrel = muonLayout->allBarrelLayers();
0123   PRINT("MuonNavigationPrinter") << "There are " << barrel.size() << " Mu Barrel DetLayers";
0124   for (auto i : barrel)
0125     printLayer(i);
0126   PRINT("MuonNavigationPrinter") << "================================" << std::endl;
0127   PRINT("MuonNavigationPrinter") << "BACKWARD:" << std::endl;
0128   const vector<const ForwardDetLayer*>& tkbackward = tracker->negForwardLayers();
0129   PRINT("MuonNavigationPrinter") << "There are " << tkbackward.size() << " Tk Backward DetLayers" << std::endl;
0130   ///  for ( tkfiter = tkbackward.begin(); tkfiter != tkbackward.end(); tkfiter++ ) printLayer(*tkfiter);
0131   vector<const DetLayer*> backward = muonLayout->allBackwardLayers();
0132   PRINT("MuonNavigationPrinter") << "There are " << backward.size() << " Mu Backward DetLayers << std::endl";
0133   for (auto i : backward)
0134     printLayer(i);
0135   PRINT("MuonNavigationPrinter") << "==============================" << std::endl;
0136   PRINT("MuonNavigationPrinter") << "FORWARD:" << std::endl;
0137   const vector<const ForwardDetLayer*>& tkforward = tracker->posForwardLayers();
0138   PRINT("MuonNavigationPrinter") << "There are " << tkforward.size() << " Tk Forward DetLayers" << std::endl;
0139   //  for ( tkfiter = tkforward.begin(); tkfiter != tkforward.end(); tkfiter++ ) printLayer(*tkfiter);
0140 
0141   vector<const DetLayer*> forward = muonLayout->allForwardLayers();
0142   PRINT("MuonNavigationPrinter") << "There are " << forward.size() << " Mu Forward DetLayers";
0143   for (auto i : forward)
0144     printLayer(i);
0145 }
0146 
0147 /// print layer
0148 void MuonNavigationPrinter::printLayer(const DetLayer* layer) const {
0149   vector<const DetLayer*> nextLayers = school->nextLayers(*layer, insideOut);
0150   vector<const DetLayer*> compatibleLayers = school->compatibleLayers(*layer, insideOut);
0151   if (const BarrelDetLayer* bdl = dynamic_cast<const BarrelDetLayer*>(layer)) {
0152     PRINT("MuonNavigationPrinter") << layer->location() << " " << layer->subDetector()
0153                                    << " layer at R: " << setiosflags(ios::showpoint | ios::fixed) << setw(8)
0154                                    << setprecision(2) << bdl->specificSurface().radius() << "  length: " << setw(6)
0155                                    << setprecision(2) << layer->surface().bounds().length() << std::endl;
0156 
0157   } else if (const ForwardDetLayer* fdl = dynamic_cast<const ForwardDetLayer*>(layer)) {
0158     PRINT("MuonNavigationPrinter") << endl
0159                                    << layer->location() << " " << layer->subDetector()
0160                                    << "layer at z: " << setiosflags(ios::showpoint | ios::fixed) << setw(8)
0161                                    << setprecision(2) << layer->surface().position().z() << "  inner r: " << setw(6)
0162                                    << setprecision(2) << fdl->specificSurface().innerRadius()
0163                                    << "  outer r: " << setw(6) << setprecision(2)
0164                                    << fdl->specificSurface().outerRadius() << std::endl;
0165   }
0166   PRINT("MuonNavigationPrinter") << " has " << nextLayers.size()
0167                                  << " next layers in the direction inside-out: " << std::endl;
0168   printLayers(nextLayers);
0169 
0170   nextLayers.clear();
0171   nextLayers = school->nextLayers(*layer, outsideIn);
0172 
0173   PRINT("MuonNavigationPrinter") << " has " << nextLayers.size()
0174                                  << " next layers in the direction outside-in: " << std::endl;
0175   printLayers(nextLayers);
0176 
0177   PRINT("MuonNavigationPrinter") << " has " << compatibleLayers.size()
0178                                  << " compatible layers in the direction inside-out:: " << std::endl;
0179   printLayers(compatibleLayers);
0180   compatibleLayers.clear();
0181   compatibleLayers = school->compatibleLayers(*layer, outsideIn);
0182 
0183   PRINT("MuonNavigationPrinter") << " has " << compatibleLayers.size()
0184                                  << " compatible layers in the direction outside-in: " << std::endl;
0185   printLayers(compatibleLayers);
0186 }
0187 
0188 /// print next layers
0189 void MuonNavigationPrinter::printLayers(const vector<const DetLayer*>& nextLayers) const {
0190   for (vector<const DetLayer*>::const_iterator inext = nextLayers.begin(); inext != nextLayers.end(); inext++) {
0191     PRINT("MuonNavigationPrinter") << " --> " << std::endl;
0192     if ((*inext)->location() == GeomDetEnumerators::barrel) {
0193       const BarrelDetLayer* l = dynamic_cast<const BarrelDetLayer*>(&(**inext));
0194       PRINT("MuonNavigationPrinter") << (*inext)->location() << " " << (*inext)->subDetector()
0195                                      << " layer at R: " << setiosflags(ios::showpoint | ios::fixed) << setw(8)
0196                                      << setprecision(2) << l->specificSurface().radius() << "   " << std::endl;
0197     } else {
0198       const ForwardDetLayer* l = dynamic_cast<const ForwardDetLayer*>(&(**inext));
0199       PRINT("MuonNavigationPrinter") << (*inext)->location() << " " << (*inext)->subDetector()
0200                                      << " layer at z: " << setiosflags(ios::showpoint | ios::fixed) << setw(8)
0201                                      << setprecision(2) << l->surface().position().z() << "   " << std::endl;
0202     }
0203     PRINT("MuonNavigationPrinter") << setiosflags(ios::showpoint | ios::fixed) << setprecision(1) << setw(6)
0204                                    << (*inext)->surface().bounds().length() << ", " << setw(6)
0205                                    << (*inext)->surface().bounds().width() << ", " << setw(4)
0206                                    << (*inext)->surface().bounds().thickness() << " : "
0207                                    << (*inext)->surface().position() << std::endl;
0208   }
0209 }
0210 
0211 /// These should not be useful anymore as SubDetector and Location enums now have << operators
0212 
0213 // /// determine whether the layer is forward or backward
0214 // string MuonNavigationPrinter::layerPart(const DetLayer* layer) const {
0215 
0216 //   string result = "unknown";
0217 
0218 //   if ( layer->part() == barrel ) return "barrel";
0219 //   if ( layer->part() == forward && layer->surface().position().z() < 0 ) {
0220 //     result = "backward";
0221 //   }
0222 //   if ( layer->part() == forward && layer->surface().position().z() >= 0 ) {
0223 //     result = "forward";
0224 //   }
0225 
0226 //   return result;
0227 
0228 // }
0229 
0230 // /// determine the module (pixel, sililcon, msgc, dt, csc, rpc)
0231 // string MuonNavigationPrinter::layerModule(const DetLayer* layer) const {
0232 
0233 //   string result = "unknown";
0234 
0235 //   GeomDetEnumerators::SubDetector det = layer->subDetector();
0236 
0237 //   if ( det == Pixel ) return "Pixel";
0238 //   if ( det == TIB || det == TOB
0239 //        || det == TID || det == TEC ) return "silicon";
0240 //   if ( det == DT ) return "DT";
0241 //   if ( det == CSC ) return "CSC";
0242 //   if ( det == RPC ) return "RPC";
0243 
0244 //   return result;
0245 
0246 // }