Go to the documentation of this file.00001 #ifndef _EcalElectronicsMapper_HH_
00002 #define _EcalElectronicsMapper_HH_
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include <iostream>
00021 #include <fstream>
00022 #include <string>
00023 #include <map>
00024
00025
00026 #include "DCCRawDataDefinitions.h"
00027 #include <DataFormats/EcalDetId/interface/EcalTrigTowerDetId.h>
00028 #include <DataFormats/EcalDetId/interface/EcalElectronicsId.h>
00029 #include <DataFormats/EcalDetId/interface/EcalScDetId.h>
00030 #include <DataFormats/EcalDigi/interface/EcalDataFrame.h>
00031 #include <DataFormats/EcalDigi/interface/EcalTriggerPrimitiveDigi.h>
00032 #include <DataFormats/EcalDigi/interface/EcalPseudoStripInputDigi.h>
00033 #include <DataFormats/EcalDigi/interface/EcalSrFlag.h>
00034 #include <iostream>
00035 #include <sstream>
00036
00037 #include <DataFormats/EcalDetId/interface/EcalTriggerElectronicsId.h>
00038
00039 class EcalElectronicsMapping;
00040
00041 class EcalElectronicsMapper {
00042
00043 public:
00044
00048 EcalElectronicsMapper(unsigned int numbOfXtalTSamples, unsigned int numbOfTriggerTSamples);
00049
00050
00054 ~EcalElectronicsMapper();
00055
00056
00057 void setEcalElectronicsMapping(const EcalElectronicsMapping *);
00058
00059 void deletePointers();
00060 void resetPointers();
00061
00065 bool setActiveDCC(unsigned int dccId);
00066
00067
00071 bool setDCCMapFilePath(std::string );
00072
00073
00077 std::string getDCCMapFilePath() const { return pathToMapFile_; }
00078
00079
00084
00085
00086
00091 bool makeMapFromVectors(std::vector<int>&, std::vector<int>&);
00092
00096 const std::map<unsigned int ,unsigned int>& getDCCMap() const { return myDCCMap_; }
00097
00098 DetId * getDetIdPointer(unsigned int feChannel, unsigned int strip, unsigned int xtal){ return xtalDetIds_[smId_-1][feChannel-1][strip-1][xtal-1];}
00099
00100 EcalTrigTowerDetId * getTTDetIdPointer(unsigned int tccId, unsigned int tower){ return ttDetIds_[tccId-1][tower-1];}
00101
00102 EcalElectronicsId * getTTEleIdPointer(unsigned int tccId, unsigned int tower){ return ttEleIds_[tccId-1][tower-1];}
00103
00104 EcalTriggerPrimitiveDigi * getTPPointer(unsigned int tccId, unsigned int tower){ return ttTPIds_[tccId-1][tower-1];}
00105
00106 EcalScDetId * getSCDetIdPointer(unsigned int smId, unsigned int feChannel){ return scDetIds_[smId-1][feChannel-1];}
00107
00108 EcalElectronicsId * getSCElectronicsPointer(unsigned int smId, unsigned int feChannel){ return scEleIds_[smId-1][feChannel-1];}
00109
00110 EcalPseudoStripInputDigi * getPSInputDigiPointer(unsigned int tccId, unsigned int towerId, unsigned int psId){ return psInput_[tccId-1][towerId-1][psId-1];}
00111
00112 EcalPseudoStripInputDigi * getPSInputDigiPointer(unsigned int tccId, unsigned int psCounter){
00113 return getPSInputDigiPointer(tccId, tTandPs_[tccId-1][psCounter-1][0],tTandPs_[tccId-1][psCounter-1][1]);}
00114
00115
00116
00117
00118
00119
00120 std::vector<EcalSrFlag*> getSrFlagPointer(unsigned int feChannel){ return srFlags_[smId_-1][feChannel-1]; }
00121
00122 std::vector<unsigned int> * getTccs(unsigned int smId){ return mapSmIdToTccIds_[smId];}
00123
00124 unsigned int getActiveDCC() { return dccId_; }
00125
00126 unsigned int getActiveSM() { return smId_; }
00127
00128 unsigned int numbXtalTSamples() { return numbXtalTSamples_; }
00129
00130 unsigned int numbTriggerTSamples() { return numbTriggerTSamples_; }
00131
00132 unsigned int getUnfilteredTowerBlockLength(){ return unfilteredFEBlockLength_; }
00133
00134 unsigned int getEBTCCBlockLength() { return ebTccBlockLength_; }
00135
00136 unsigned int getEETCCBlockLength() { return eeTccBlockLength_; }
00137
00138 unsigned int getSRPBlockLength() { return srpBlockLength_; }
00139
00140 unsigned int getDCCId(unsigned int aSMId) const;
00141
00142 unsigned int getSMId(unsigned int aDCCId) const;
00143
00144 unsigned int getNumChannelsInDcc(unsigned int aDCCId){return numChannelsInDcc_[aDCCId-1];}
00145
00146 const EcalElectronicsMapping * mapping(){return mappingBuilder_;}
00147
00148 bool isTCCExternal(unsigned int TCCId);
00149
00153 friend std::ostream& operator<< (std::ostream &o, const EcalElectronicsMapper& aEcalElectronicsMapper);
00154
00155
00156
00157 enum SMGeom_t {
00158 kModules = 4,
00159 kTriggerTowers = 68,
00160 kTowersInPhi = 4,
00161 kTowersInEta = 17,
00162 kCrystals = 1700,
00163 kPns = 10,
00164 kCrystalsInPhi = 20,
00165 kCrystalsInEta = 85,
00166 kCrystalsPerTower = 25,
00167 kCardsPerTower = 5,
00168 kChannelsPerCard = 5,
00169 TTMAPMASK = 100
00170 };
00171
00172
00173 private:
00174
00175 void fillMaps();
00176 unsigned int computeUnfilteredFEBlockLength();
00177 unsigned int computeEBTCCBlockLength();
00178 unsigned int computeEETCCBlockLength();
00179
00180 std::string pathToMapFile_;
00181
00182 unsigned int numbXtalTSamples_;
00183
00184 unsigned int numbTriggerTSamples_;
00185
00186 std::map<unsigned int,unsigned int> myDCCMap_;
00187
00188 std::map< unsigned int, std::vector<unsigned int> * > mapSmIdToTccIds_;
00189
00190 unsigned int dccId_;
00191
00192 unsigned int smId_;
00193
00194 unsigned int unfilteredFEBlockLength_;
00195
00196 unsigned int srpBlockLength_;
00197
00198 unsigned int ebTccBlockLength_, eeTccBlockLength_;
00199
00200 static const unsigned int numChannelsInDcc_[NUMB_SM];
00201
00202
00203
00204 DetId * xtalDetIds_[NUMB_SM][NUMB_FE][NUMB_STRIP][NUMB_XTAL];
00205 EcalScDetId * scDetIds_[NUMB_SM][NUMB_FE];
00206 EcalElectronicsId * scEleIds_[NUMB_SM][NUMB_FE];
00207 EcalTrigTowerDetId * ttDetIds_[NUMB_TCC][NUMB_FE];
00208 EcalElectronicsId * ttEleIds_[NUMB_TCC][NUMB_FE];
00209 EcalTriggerPrimitiveDigi * ttTPIds_[NUMB_TCC][NUMB_FE];
00210 std::vector<EcalSrFlag*> srFlags_[NUMB_SM][NUMB_FE];
00211 EcalPseudoStripInputDigi * psInput_[NUMB_TCC][TCC_EB_NUMBTTS][NUMB_STRIP];
00212
00213 short tTandPs_[NUMB_TCC][5*EcalTrigTowerDetId::kEBTowersPerSM][2];
00214
00215 const EcalElectronicsMapping * mappingBuilder_;
00216
00217
00218
00219 public:
00220
00221
00222 bool isGhost(const int FED, const int CCU, const int VFE);
00223
00224 private:
00225 void setupGhostMap();
00226 std::map<int, std::map<int, std::map<int, bool> > > ghost_;
00227 };
00228
00229 #endif