CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch9/src/FastSimulation/CaloGeometryTools/interface/CaloGeometryHelper.h

Go to the documentation of this file.
00001 #ifndef FastSimulation_CaloGeometryTools_CaloGeometryHelper
00002 #define FastSimulation_CaloGeometryTools_CaloGeometryHelper
00003 
00004 #include "FastSimulation/CalorimeterProperties/interface/Calorimeter.h"
00005 #include "Geometry/CaloTopology/interface/CaloDirection.h"
00006 #include "FastSimulation/CaloGeometryTools/interface/BaseCrystal.h"
00007 
00008 #include <vector>
00009 
00010 class DetId;
00011 class Crystal;
00012 
00013 namespace edm { 
00014   class ParameterSet;
00015 }
00016 
00017 class CaloGeometryHelper:public Calorimeter
00018 {
00019 
00020  public:
00021 
00022   typedef math::XYZVector XYZVector;
00023   typedef math::XYZVector XYZPoint;
00024 
00025   CaloGeometryHelper();
00026   CaloGeometryHelper(const edm::ParameterSet& fastCalo);
00027   ~CaloGeometryHelper();
00028 
00029 
00030   // more user friendly getClosestCell  
00031   DetId getClosestCell(const XYZPoint& point, bool ecal, bool central) const;
00032 
00033   // more user friendly getWindow
00034   void getWindow(const DetId& pivot,int s1,int s2,std::vector<DetId> &) const;
00035   
00036   
00037   double preshowerZPosition(int layer) const
00038   {
00039     return (layer==1) ? psLayer1Z_: psLayer2Z_ ; 
00040   }
00041   
00042   // the Crystal constructor
00043   void buildCrystal(const DetId& id,Crystal&) const;
00044 
00045   void initialize(double bField);  
00046 
00047   // get the <=8 neighbours
00048   const std::vector<DetId> & getNeighbours(const DetId& det) const ;
00049 
00050   inline double magneticField() const {return bfield_;}
00051   
00052   // temporary. Requires a missing geometry tool 
00053   bool borderCrossing(const DetId&, const DetId&) const ;
00054 
00055   bool move(DetId& cell, const CaloDirection& dir,bool fast=true) const;
00056 
00057   inline bool preshowerPresent() const {return preshowerPresent_;};
00058 
00059  private:
00060   void buildNeighbourArray();
00061   void buildCrystalArray();
00062   bool simplemove(DetId& cell, const CaloDirection& dir) const;
00063   bool diagonalmove(DetId& cell, const CaloDirection& dir) const;
00064 
00065  private:
00066     // Preshower layer positions
00067   double psLayer1Z_,psLayer2Z_;
00068 
00069   // array of neighbours the hashed index is used for the first vector
00070   std::vector<std::vector<DetId> > barrelNeighbours_;
00071   std::vector<std::vector<DetId> > endcapNeighbours_;
00072 
00073   std::vector<BaseCrystal> barrelCrystals_;
00074   std::vector<BaseCrystal> endcapCrystals_;
00075 
00076   bool neighbourmapcalculated_;
00077   
00078   //mag field at 0,0,0
00079   double bfield_;
00080   bool preshowerPresent_;
00081 };
00082 #endif