CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_6_1_1/src/EventFilter/SiPixelRawToDigi/interface/PixelUnpackingRegions.h

Go to the documentation of this file.
00001 #ifndef PixelUnpackingRegions_H
00002 #define PixelUnpackingRegions_H
00003 
00004 #include "FWCore/Framework/interface/Event.h"
00005 #include "FWCore/Framework/interface/EventSetup.h"
00006 #include "FWCore/Framework/interface/ESWatcher.h"
00007 #include "DataFormats/Math/interface/Point3D.h"
00008 #include "DataFormats/Math/interface/Vector3D.h"
00009 
00010 #include "CondFormats/DataRecord/interface/SiPixelFedCablingMapRcd.h"
00011 #include "CondFormats/SiPixelObjects/interface/SiPixelFedCablingMap.h"
00012 
00013 #include <cmath>
00014 #include <vector>
00015 #include <set>
00016 #include <boost/scoped_ptr.hpp>
00017 
00018 
00027 class PixelUnpackingRegions
00028 {
00029 public:
00030 
00035   struct Region
00036   {
00037     Region(const math::XYZVector &dir, float dphi = 0.5f, float maxz = 24.f):
00038       v(dir), dPhi(dphi), maxZ(maxz)
00039     {
00040       cosphi = v.x()/v.rho();
00041       sinphi = v.y()/v.rho();
00042       atantheta = v.z()/v.rho();
00043     }
00044     math::XYZVector v;
00045     float dPhi, maxZ;
00046     float cosphi, sinphi, atantheta;
00047   };
00048 
00049 
00050   PixelUnpackingRegions(const edm::ParameterSet&);
00051 
00052   ~PixelUnpackingRegions() {}
00053 
00055   void run(const edm::Event& e, const edm::EventSetup& es);
00056 
00058   bool mayUnpackFED(unsigned int fed_n) const;
00059 
00061   bool mayUnpackModule(unsigned int id) const;
00062   
00064   const std::set<unsigned int> * modulesToUnpack() const {return &modules_;}
00065 
00067   unsigned int nFEDs() const { return feds_.size(); }
00068   unsigned int nBarrelFEDs() const;
00069   unsigned int nForwardFEDs() const;
00070   unsigned int nModules() const { return modules_.size(); }
00071   unsigned int nBarrelModules() const;
00072   unsigned int nForwardModules() const;
00073   unsigned int nRegions() const { return nreg_; }
00074 
00075   struct Module
00076   {
00077     float phi;
00078     float x, y, z;
00079     unsigned int id;
00080     unsigned int fed;
00081 
00082     Module() {}
00083     Module(float ph) : phi(ph), x(0.f), y(0.f), z(0.f), id(0), fed(0) {}
00084 
00085     bool operator < (const Module& m) const
00086     {
00087       if(phi < m.phi) return true;
00088       if(phi == m.phi && id < m.id) return true;
00089       return false;
00090     }
00091   };
00092 
00093 private:
00094 
00095   // input parameters
00096   std::vector<edm::InputTag> inputs_;
00097   std::vector<double> dPhi_;
00098   std::vector<double> maxZ_;
00099   edm::InputTag beamSpotTag_;
00100 
00101   std::set<unsigned int> feds_;
00102   std::set<unsigned int> modules_;
00103   unsigned int nreg_;
00104 
00106   void initialize(const edm::EventSetup& es);
00107 
00108   // add a new direction of a region of interest
00109   void addRegion(Region &r);
00110 
00111   // gather info into feds_ and modules_ from a range of a Module vector
00112   void gatherFromRange(Region &r, std::vector<Module>::const_iterator, std::vector<Module>::const_iterator);
00113 
00114   // addRegion for a local (BPIX or +-FPIX) container
00115   void addRegionLocal(Region &r, std::vector<Module> &container, Module lo, Module hi);
00116 
00117   // local containers of barrel and endcaps Modules sorted by phi
00118   std::vector<Module> phiBPIX_;
00119   std::vector<Module> phiFPIXp_;
00120   std::vector<Module> phiFPIXm_;
00121 
00122   boost::scoped_ptr<SiPixelFedCabling> cabling_;
00123   math::XYZPoint beamSpot_;
00124 
00125   edm::ESWatcher<SiPixelFedCablingMapRcd> watcherSiPixelFedCablingMap_;
00126 };
00127 
00128 #endif