Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:44:37

0001 #ifndef ALIGNMENTPARAMETERSELECTOR_H
0002 #define ALIGNMENTPARAMETERSELECTOR_H
0003 
0004 /** \class AlignmentParameterSelector
0005  *  \author Gero Flucke (selection by strings taken from AlignableParameterBuilder)
0006  *
0007  *  Selecting Alignable's of the tracker by predefined strings,
0008  *  additional constraints on eta, phi, r, x, y or z are possible.
0009  *  Furthermore stores the 'selection' of selected AlignmentParameters.
0010  *
0011  *  $Date: 2010/11/22 08:40:08 $
0012  *  $Revision: 1.10 $
0013  *  (last update by $Author: mussgill $)
0014  */
0015 
0016 #include "Alignment/CommonAlignment/interface/Utilities.h"
0017 
0018 class AlignableExtras;
0019 class AlignableTracker;
0020 class AlignableMuon;
0021 
0022 namespace edm {
0023   class ParameterSet;
0024 }
0025 
0026 class AlignmentParameterSelector {
0027 public:
0028   /// Constructor from tracker only or from tracker and muon
0029   explicit AlignmentParameterSelector(AlignableTracker *aliTracker,
0030                                       AlignableMuon *aliMuon = nullptr,
0031                                       AlignableExtras *aliExtras = nullptr);
0032 
0033   /// Destructor
0034   virtual ~AlignmentParameterSelector() {}
0035 
0036   /// vector of alignables selected so far
0037   const align::Alignables &selectedAlignables() const { return theSelectedAlignables; }
0038   /// vector of selection 'strings' for alignables, parallel to selectedAlignables()
0039   const std::vector<std::vector<char> > &selectedParameters() const { return theSelectedParameters; }
0040   /// remove all selected Alignables and geometrical restrictions
0041   void clear();
0042   /// remove all geometrical restrictions
0043   void clearGeometryCuts();
0044 
0045   /// Add several selections defined by the PSet which must contain a vstring like e.g.
0046   /// vstring alignParams = { "PixelHalfBarrelLadders,111000,pixelSelection",
0047   ///                         "BarrelDSRods,111ff0",
0048   ///                         "BarrelSSRods,101ff0"}
0049   /// The e.g. '111ff0' is decoded into vector<char> and stored.
0050   /// Returns number of added selections or -1 if problems (then also an error is logged)
0051   /// If a string contains a third, comma separated part (e.g. ',pixelSelection'),
0052   /// a further PSet of that name is expected to select eta/phi/r/x/y/z-ranges.
0053   unsigned int addSelections(const edm::ParameterSet &pSet);
0054   /// set geometrical restrictions to be applied on all following selections
0055   /// (slices defined by vdouble 'etaRanges', 'phiRanges', 'xRanges', 'yRanges', 'zRanges'
0056   /// and 'rRanges', empty array means no restriction)
0057   void setGeometryCuts(const edm::ParameterSet &pSet);
0058   /// add Alignables corresponding to predefined name, taking into account geometrical restrictions
0059   /// as defined in setSpecials, returns number of added alignables
0060   unsigned int addSelection(const std::string &name, const std::vector<char> &paramSel);
0061   /// as addSelection with one argument, but overwriting geometrical restrictions
0062   unsigned int addSelection(const std::string &name, const std::vector<char> &paramSel, const edm::ParameterSet &pSet);
0063   /// true if layer is deselected via "Layers<N><M>" or "DS/SS"
0064   bool layerDeselected(const Alignable *alignable) const;
0065   /// true if alignable is DetUnit deselected by Unit<Rphi/Stereo> selection
0066   bool detUnitDeselected(const Alignable *alignable) const;
0067   /// true if geometrical restrictions in eta, phi, r, x, y, z not satisfied
0068   bool outsideGeometricalRanges(const Alignable *alignable) const;
0069   /// true if DetId restrictions are not satisfied
0070   bool outsideDetIdRanges(const Alignable *alignable) const;
0071   /// true if ranges.size() is even and ranges[i] <= value < ranges[i+1] for any even i
0072   /// ( => false if ranges.empty() == true), if(isPhi==true) takes into account phi periodicity
0073   /// for the integer specialized method, true is returned for ranges[i] <= value <= ranges[i+1]
0074   /// and isPhi is ignored
0075   template <typename T>
0076   bool insideRanges(T value, const std::vector<T> &ranges, bool isPhi = false) const;
0077   /// true if value is member of vector of values
0078   bool isMemberOfVector(int value, const std::vector<int> &values) const;
0079   /// Decomposing input string 's' into parts separated by 'delimiter'
0080   std::vector<std::string> decompose(const std::string &s, std::string::value_type delimiter) const;
0081   /// Converting std::string into std::vector<char>
0082   std::vector<char> convertParamSel(const std::string &selString) const;
0083 
0084 protected:
0085   /// adding alignables which fulfil geometrical restrictions and special switches
0086   unsigned int add(const align::Alignables &alignables, const std::vector<char> &paramSel);
0087   /// some helper methods
0088   unsigned int addAllDets(const std::vector<char> &paramSel);
0089   unsigned int addAllRods(const std::vector<char> &paramSel);
0090   unsigned int addAllLayers(const std::vector<char> &paramSel);
0091   unsigned int addAllAlignables(const std::vector<char> &paramSel);
0092 
0093   void setPXBDetIdCuts(const edm::ParameterSet &pSet);
0094   void setPXFDetIdCuts(const edm::ParameterSet &pSet);
0095   void setTIBDetIdCuts(const edm::ParameterSet &pSet);
0096   void setTIDDetIdCuts(const edm::ParameterSet &pSet);
0097   void setTOBDetIdCuts(const edm::ParameterSet &pSet);
0098   void setTECDetIdCuts(const edm::ParameterSet &pSet);
0099 
0100   const AlignableTracker *alignableTracker() const;
0101 
0102 private:
0103   AlignableTracker *theTracker;
0104   AlignableMuon *theMuon;
0105   AlignableExtras *theExtras;
0106   align::Alignables theSelectedAlignables;
0107   std::vector<std::vector<char> > theSelectedParameters;
0108 
0109   /// geometrical restrictions in eta, phi, r, x, y, z to be applied for next addSelection
0110   std::vector<double> theRangesEta;
0111   std::vector<double> theRangesPhi;
0112   std::vector<double> theRangesR;
0113   std::vector<double> theRangesX;
0114   std::vector<double> theRangesY;
0115   std::vector<double> theRangesZ;
0116 
0117   /// DetId restrictions in eta, phi, r, x, y, z to be applied for next addSelection
0118   std::vector<int> theDetIds;
0119   std::vector<int> theDetIdRanges;
0120   std::vector<int> theExcludedDetIds;
0121   std::vector<int> theExcludedDetIdRanges;
0122   struct PXBDetIdRanges {
0123     std::vector<int> theLadderRanges;
0124     std::vector<int> theLayerRanges;
0125     std::vector<int> theModuleRanges;
0126     void clear() {
0127       theLadderRanges.clear();
0128       theLayerRanges.clear();
0129       theModuleRanges.clear();
0130     }
0131   } thePXBDetIdRanges;
0132   struct PXFDetIdRanges {
0133     std::vector<int> theBladeRanges;
0134     std::vector<int> theDiskRanges;
0135     std::vector<int> theModuleRanges;
0136     std::vector<int> thePanelRanges;
0137     std::vector<int> theSideRanges;
0138     void clear() {
0139       theBladeRanges.clear();
0140       theDiskRanges.clear();
0141       theModuleRanges.clear();
0142       thePanelRanges.clear();
0143       theSideRanges.clear();
0144     }
0145   } thePXFDetIdRanges;
0146   struct TIBDetIdRanges {
0147     std::vector<int> theLayerRanges;
0148     std::vector<int> theModuleRanges;
0149     std::vector<int> theStringRanges;
0150     std::vector<int> theSideRanges;
0151     void clear() {
0152       theLayerRanges.clear();
0153       theModuleRanges.clear();
0154       theSideRanges.clear();
0155       theStringRanges.clear();
0156     }
0157   } theTIBDetIdRanges;
0158   struct TIDDetIdRanges {
0159     std::vector<int> theDiskRanges;
0160     std::vector<int> theModuleRanges;
0161     std::vector<int> theRingRanges;
0162     std::vector<int> theSideRanges;
0163     void clear() {
0164       theDiskRanges.clear();
0165       theModuleRanges.clear();
0166       theRingRanges.clear();
0167       theSideRanges.clear();
0168     }
0169   } theTIDDetIdRanges;
0170   struct TOBDetIdRanges {
0171     std::vector<int> theLayerRanges;
0172     std::vector<int> theModuleRanges;
0173     std::vector<int> theRodRanges;
0174     std::vector<int> theSideRanges;
0175     void clear() {
0176       theLayerRanges.clear();
0177       theModuleRanges.clear();
0178       theRodRanges.clear();
0179       theSideRanges.clear();
0180     }
0181   } theTOBDetIdRanges;
0182   struct TECDetIdRanges {
0183     std::vector<int> theWheelRanges;
0184     std::vector<int> thePetalRanges;
0185     std::vector<int> theModuleRanges;
0186     std::vector<int> theRingRanges;
0187     std::vector<int> theSideRanges;
0188     void clear() {
0189       theWheelRanges.clear();
0190       thePetalRanges.clear();
0191       theModuleRanges.clear();
0192       theRingRanges.clear();
0193       theSideRanges.clear();
0194     }
0195   } theTECDetIdRanges;
0196 
0197   // further switches used in add(...)
0198   bool theOnlyDS;
0199   bool theOnlySS;
0200   bool theSelLayers;
0201   int theMinLayer;
0202   int theMaxLayer;
0203   enum RphiOrStereoDetUnit { Stereo, Both, Rphi };
0204   RphiOrStereoDetUnit theRphiOrStereoDetUnit;
0205   /// Setting the special switches and returning input string, but after removing the 'special
0206   /// indicators' from it. Known specials are:
0207   /// "SS" anywhere in name: in TIB/TOB restrict to single sided Dets/Rods/Layers
0208   /// "DS" anywhere in name: in TIB/TOB restrict to double sided Dets/Rods/Layers
0209   /// "Layers14" at end of name: in tracker restrict to layers/disks 1 to 4, similar for other digits
0210   /// "UnitStereo" and "UnitRphi" anywhere in name:
0211   ///      for a DetUnit in strip select only if stereo or rphi module (keep 'Unit' in name!)
0212   std::string setSpecials(const std::string &name);
0213 };
0214 
0215 template <>
0216 bool AlignmentParameterSelector::insideRanges<int>(int value, const std::vector<int> &ranges, bool isPhi) const;
0217 
0218 #endif