CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_9_patch3/src/Geometry/EcalMapping/interface/EcalElectronicsMapping.h

Go to the documentation of this file.
00001 #ifndef ECALELECTRONICSMAPPING_H
00002 #define ECALELECTRONICSMAPPING_H 1
00003 
00004 #include <memory>
00005 #include <iostream>
00006 #include <string>
00007 
00008 #include "DataFormats/EcalDetId/interface/EcalDetIdCollections.h"
00009 #include "DataFormats/EcalDetId/interface/EcalSubdetector.h"
00010 
00011 
00012 #include <boost/multi_index_container.hpp>
00013 #include <boost/multi_index/member.hpp>
00014 #include <boost/multi_index/ordered_index.hpp>
00015 #include <boost/tuple/tuple.hpp>
00016 #include <boost/multi_index/mem_fun.hpp>
00017 #include <boost/multi_index/composite_key.hpp>
00018 
00019 #include "RecoEcal/EgammaCoreTools/interface/EcalEtaPhiRegion.h"
00020 
00021 
00022 #include <vector>
00023 #include <map>
00024 
00025 
00032 class EcalElectronicsMapping {
00033 
00034   
00035  public:
00036   
00037   EcalElectronicsMapping();
00038   
00040   EcalElectronicsId getElectronicsId(const DetId& id) const;
00041   
00043   EcalTriggerElectronicsId getTriggerElectronicsId(const DetId& id) const;
00044 
00046   DetId getDetId(const EcalElectronicsId& id) const;
00047 
00049   EcalTriggerElectronicsId getTriggerElectronicsId(const EcalElectronicsId& id) const;
00050 
00052   DetId getDetId(const EcalTriggerElectronicsId& id) const;
00053 
00055   EcalElectronicsId getElectronicsId(const EcalTriggerElectronicsId& id) const;
00056 
00058   std::vector<DetId> dccConstituents(int dccId) const;
00059 
00061   std::vector<DetId> dccTowerConstituents(int dccId, int tower) const;
00062 
00064   std::vector<DetId> stripConstituents(int dccId, int tower, int strip) const;
00065 
00067   std::vector<DetId> tccConstituents(int tccId) const;
00068 
00070   std::vector<DetId> ttConstituents(int tccId, int tt) const;
00071 
00073   std::vector<DetId> pseudoStripConstituents(int tccId, int tt, int pseudostrip) const;
00074 
00076   void assign(const DetId& cell, const EcalElectronicsId&, const EcalTriggerElectronicsId& tower);
00077 
00090   std::pair<int, int> getDCCandSC(EcalScDetId id) const;
00091 
00107   std::vector<EcalScDetId> getEcalScDetId(int DCCid, int DCC_Channel,
00108                                           bool ignoreSingleCrystal = true) const;
00109 
00111   int DCCid(const EBDetId& id) const;
00112 
00114   int TCCid(const EBDetId& id) const;
00115 
00117   int iTT(const EcalTrigTowerDetId& id) const;
00118 
00120   int TCCid(const EcalTrigTowerDetId& id) const;
00121 
00123   int DCCid(const EcalTrigTowerDetId& id) const;
00124 
00126   EcalTrigTowerDetId getTrigTowerDetId(int TCCid, int iTT) const;
00127 
00128   EcalSubdetector subdet(int dccid, int mode) const;
00129   int zside(int dcctcc, int mode) const;
00130 
00131   bool rightTower(int tower) const;
00132 
00133   // methods used for regional unpacking :
00134   std::vector<int> GetListofFEDs(const EcalEtaPhiRegion region) const ;
00135   void GetListofFEDs(const EcalEtaPhiRegion region, std::vector<int> & FEDs) const ;
00136   int GetFED(double eta, double phi) const ;
00137   int DCCBoundary(int FED) const;
00138 
00139   // methods for retrieving the Laser Monitoring readout number
00140 
00141   int getLMNumber(const DetId& id) const;
00142 
00143 
00144  // Geometry of SM in EB :
00145   static const int kCrystalsInPhi = EBDetId::kCrystalsInPhi ; // per SM
00146   static const int kTowersInPhi = EBDetId::kTowersInPhi ;  // per SM
00147 
00148  // Geometry of the Trigger Towers :
00149 
00150   static const int kEBTowersInPhi = EcalTrigTowerDetId::kEBTowersInPhi ; // per SM (in the Barrel)
00151   static const int kEBTowersPerSM = EcalTrigTowerDetId::kEBTowersPerSM ; // per SM (in the Barrel)
00152   static const int kEBTowersInEta = EcalTrigTowerDetId::kEBTowersInEta; // per SM (in the Barrel)
00153   static const int kEETowersInEta = EcalTrigTowerDetId::kEETowersInEta; // Endcap
00154   static const int kEETowersInPhiPerQuadrant = EcalTrigTowerDetId::kEETowersInPhiPerQuadrant; // per Quadrant (EE)
00155                                                                                                                                                     
00156   static const int kEETowersInPhiPerTCC = 4;    // each TCC contains 4 towers in phi
00157   static const int kEETowersInEtaPerInnerTCC = 7;   // each inner TCC contains 7 towers in eta
00158   static const int kEETowersInEtaPerOuterTCC = 4;   // each outer TCC contains 4 towers in eta
00159   static const int iEEEtaMinOuter = 18;         // outer TCC : ieta = 18 -> 21
00160   static const int iEEEtaMinInner = 22;         // inner TCC : ieta = 22 -> 28
00161 
00162 
00163  // DCC values :
00164   static const int MAX_DCCID = EcalElectronicsId::MAX_DCCID ; //To be updated with correct and final number
00165   static const int MIN_DCCID = EcalElectronicsId::MIN_DCCID;
00166   static const int MIN_DCCID_EEM = EcalElectronicsId::MIN_DCCID_EEM ;
00167   static const int MAX_DCCID_EEM = EcalElectronicsId::MAX_DCCID_EEM ;
00168   static const int MIN_DCCID_EBM = EcalElectronicsId::MIN_DCCID_EBM ;
00169   static const int MAX_DCCID_EBM = EcalElectronicsId::MAX_DCCID_EBM ;
00170   static const int MIN_DCCID_EBP = EcalElectronicsId::MIN_DCCID_EBP ;
00171   static const int MAX_DCCID_EBP = EcalElectronicsId::MAX_DCCID_EBP ;
00172   static const int MIN_DCCID_EEP = EcalElectronicsId::MIN_DCCID_EEP ;
00173   static const int MAX_DCCID_EEP = EcalElectronicsId::MAX_DCCID_EEP ;
00174 
00175   static const int DCCID_PHI0_EBM = EcalElectronicsId::DCCID_PHI0_EBM ;   // contains phi = 0 deg.
00176   static const int DCCID_PHI0_EBP = EcalElectronicsId::DCCID_PHI0_EBP ;
00177 
00178  // TCC values :
00179   static const int MAX_TCCID = EcalTriggerElectronicsId::MAX_TCCID ; //To be updated with correct and final number
00180   static const int MIN_TCCID = EcalTriggerElectronicsId::MIN_TCCID ;
00181   static const int MIN_TCCID_EEM = EcalTriggerElectronicsId::MIN_TCCID_EEM ;
00182   static const int MAX_TCCID_EEM = EcalTriggerElectronicsId::MAX_TCCID_EEM ;
00183   static const int MIN_TCCID_EBM = EcalTriggerElectronicsId::MIN_TCCID_EBM ;
00184   static const int MAX_TCCID_EBM = EcalTriggerElectronicsId::MAX_TCCID_EBM ;
00185   static const int MIN_TCCID_EBP = EcalTriggerElectronicsId::MIN_TCCID_EBP ;
00186   static const int MAX_TCCID_EBP = EcalTriggerElectronicsId::MAX_TCCID_EBP ;
00187   static const int MIN_TCCID_EEP = EcalTriggerElectronicsId::MIN_TCCID_EEP ;
00188   static const int MAX_TCCID_EEP = EcalTriggerElectronicsId::MAX_TCCID_EEP ;
00189 
00190   static const int TCCID_PHI0_EBM = EcalTriggerElectronicsId::TCCID_PHI0_EBM ;
00191   static const int TCCID_PHI0_EBP = EcalTriggerElectronicsId::TCCID_PHI0_EBP ;
00192 
00193   static const int TCCID_PHI0_EEM_IN = EcalTriggerElectronicsId::TCCID_PHI0_EEM_IN ;
00194   static const int TCCID_PHI0_EEM_OUT = EcalTriggerElectronicsId::TCCID_PHI0_EEM_OUT ;
00195   static const int TCCID_PHI0_EEP_IN = EcalTriggerElectronicsId::TCCID_PHI0_EEP_IN ;
00196   static const int TCCID_PHI0_EEP_OUT = EcalTriggerElectronicsId::TCCID_PHI0_EEP_OUT ;
00197 
00198   static const int kTCCinPhi = 18;      // Number of TCC "sectors" in phi
00199 
00200  // LaserMonitoring readout numbers :
00201   static const int MIN_LM_EEM = 73;     // corresponds to MIN_DCCID_EEM
00202   static const int MIN_LM_EBM = 1;      // corresponds to MIN_DCCID_EBM
00203   static const int MIN_LM_EBP = 37;     // corresponds to MIN_DCCID_EBP
00204   static const int MIN_LM_EEP = 83;     // corresponds to MIN_DCCID_EEP
00205   static const int MAX_LM =     92;     // Total number of LaserModules
00206 
00207 
00208  private:
00209 
00210   static const int DCCMODE = 0;
00211   static const int TCCMODE = 1;
00212 
00215   //  DetId wrapEEDetId(const DetId& id) const;
00217   //DetId wrapEcalTrigTowerDetId(const DetId& id) const;
00218   //DetId changeEEDetIdQuadrantAndZ(const DetId& fromid, const int& toQuadrant,const int& tozside) const;
00219   //  int changeTowerQuadrant(int phiTower, int fromQuadrant, int toQuadrant) const;
00220 
00221   struct MapItem {
00222     MapItem(const DetId& acell, const EcalElectronicsId& aelid, const EcalTriggerElectronicsId& atrelid) : cell(acell),elid(aelid),trelid(atrelid) { }
00223     DetId cell;
00224     EcalElectronicsId elid;
00225     EcalTriggerElectronicsId trelid;
00226     int dccId() const { return elid.dccId(); }
00227     int towerId() const {return elid.towerId(); }
00228     int stripId() const {return elid.stripId(); }
00229     int tccId() const { return trelid.tccId(); }
00230     int ttId() const { return trelid.ttId(); }
00231     int pseudoStripId() const { return trelid.pseudoStripId(); }
00232   };
00233 
00234 
00235   //hashed indexes to be preferred to ordered (faster for lookup, here we are not interested in ordering...)
00236   typedef boost::multi_index::multi_index_container<
00237     MapItem,
00238     boost::multi_index::indexed_by<
00239     // hashed_unique< member < MapItem,DetId,&MapItem::cell > >,
00240     // hashed_unique< member < MapItem,EcalElectronicsId,&MapItem::elid > >,
00241     // hashed_unique< member < MapItem,EcalTriggerElectronicsId,&MapItem::trelid > >
00242      boost::multi_index::ordered_unique< boost::multi_index::member < MapItem,DetId,&MapItem::cell > >,
00243      boost::multi_index::ordered_unique< boost::multi_index::member < MapItem,EcalElectronicsId,&MapItem::elid > >,
00244      boost::multi_index::ordered_unique< boost::multi_index::member < MapItem,EcalTriggerElectronicsId,&MapItem::trelid > >,
00245      boost::multi_index::ordered_non_unique< boost::multi_index::const_mem_fun < MapItem, int, &MapItem::dccId > >,
00246      boost::multi_index::ordered_non_unique<
00247         boost::multi_index::composite_key<
00248                 MapItem,
00249                 boost::multi_index::const_mem_fun < MapItem, int, &MapItem::dccId > ,
00250                 boost::multi_index::const_mem_fun < MapItem, int, &MapItem::towerId  >  
00251         > >,
00252      boost::multi_index::ordered_non_unique<
00253         boost::multi_index::composite_key<
00254                 MapItem,
00255                 boost::multi_index::const_mem_fun < MapItem, int, &MapItem::dccId > ,
00256                 boost::multi_index::const_mem_fun < MapItem, int, &MapItem::towerId  >,
00257                 boost::multi_index::const_mem_fun < MapItem, int, &MapItem::stripId >
00258         > >,
00259      boost::multi_index::ordered_non_unique< boost::multi_index::const_mem_fun < MapItem, int, &MapItem::tccId > >,
00260      boost::multi_index::ordered_non_unique<
00261         boost::multi_index::composite_key<
00262                 MapItem,
00263                 boost::multi_index::const_mem_fun < MapItem, int, &MapItem::tccId > ,
00264                 boost::multi_index::const_mem_fun < MapItem, int, &MapItem::ttId  >
00265         > >,
00266      boost::multi_index::ordered_non_unique<
00267         boost::multi_index::composite_key<
00268                 MapItem,
00269                 boost::multi_index::const_mem_fun < MapItem, int, &MapItem::tccId > ,
00270                 boost::multi_index::const_mem_fun < MapItem, int, &MapItem::ttId  >,
00271                 boost::multi_index::const_mem_fun < MapItem, int, &MapItem::pseudoStripId >
00272         > >
00273     >
00274     > EcalElectronicsMap;
00275   
00276    typedef EcalElectronicsMap::nth_index<0>::type EcalElectronicsMap_by_DetId;
00277    typedef EcalElectronicsMap::nth_index<1>::type EcalElectronicsMap_by_ElectronicsId;
00278    typedef EcalElectronicsMap::nth_index<2>::type EcalElectronicsMap_by_TriggerElectronicsId;
00279 
00280    typedef EcalElectronicsMap::nth_index<3>::type EcalElectronicsMap_by_DccId;
00281    typedef EcalElectronicsMap::nth_index<4>::type EcalElectronicsMap_by_DccId_and_TowerId;
00282    typedef EcalElectronicsMap::nth_index<5>::type EcalElectronicsMap_by_DccId_TowerId_and_StripId;
00283   
00284    typedef EcalElectronicsMap::nth_index<6>::type EcalElectronicsMap_by_TccId;
00285    typedef EcalElectronicsMap::nth_index<7>::type EcalElectronicsMap_by_TccId_and_TtId;
00286    typedef EcalElectronicsMap::nth_index<8>::type EcalElectronicsMap_by_TccId_TtId_and_PseudostripId;
00287 
00288 
00289   //Needed only in the EE (contains only first quadrant object) 
00290   EcalElectronicsMap m_items;
00291 
00292 
00293   // Maps between DCC and LaserMonitoring readout numbers (take care that EB DCCs and two EE DCCs
00294   // actually correspond to two LMs. The map contain only the first one).
00295   // The maps are filled in the constructor of EcalElectronicsMapping.
00296 
00297   std::map<int, int> LaserMonitoringMap_EB;
00298   std::map<int, int> LaserMonitoringMap_EE;
00299 
00300 };
00301 
00302 #endif