00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #ifndef MUONIDHELPERS_CSCIDHELPER_H
00011 #define MUONIDHELPERS_CSCIDHELPER_H
00012
00013
00014
00015 #include "MuonIdHelpers/MuonIdHelper.h"
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055 class CscIdHelper : public MuonIdHelper
00056 {
00057 public:
00058
00059
00060
00061 CscIdHelper();
00062
00063
00064
00065 virtual ~CscIdHelper();
00066
00068
00070 virtual int initialize_from_dictionary(const IdDictMgr& dict_mgr);
00071 virtual int get_module_hash (const Identifier& id,
00072 IdentifierHash& hash_id ) const;
00073 virtual int get_detectorElement_hash (const Identifier& id,
00074 IdentifierHash& hash_id ) const;
00075
00076
00078
00079
00080
00081
00082 Identifier elementID(int stationName, int stationEta, int stationPhi, bool check=false, bool* isValid=0) const;
00083 Identifier elementID(std::string stationNameStr, int stationEta,
00084 int stationPhi, bool check=false, bool* isValid=0) const;
00085 Identifier elementID(const Identifier& channelID) const;
00086 Identifier channelID(int stationName, int stationEta,
00087 int stationPhi, int chamberLayer, int wireLayer,
00088 int measuresPhi, int strip, bool check=false, bool* isValid=0) const;
00089 Identifier channelID(std::string stationNameStr, int stationEta,
00090 int stationPhi, int chamberLayer, int wireLayer,
00091 int measuresPhi, int strip, bool check=false, bool* isValid=0) const;
00092 Identifier channelID(const Identifier& id, int chamberLayer, int wireLayer,
00093 int measurePhi, int strip, bool check=false, bool* isValid=0) const;
00094
00095 Identifier parentID (const Identifier& id) const;
00096
00097
00098 void idChannels (const Identifier& id, std::vector<Identifier>& vect) const;
00099
00100
00101
00102 int channel(const Identifier& id) const;
00103
00104 int chamberLayer(const Identifier& id) const;
00105 int wireLayer(const Identifier& id) const;
00106 bool measuresPhi(const Identifier& id) const;
00107 int strip(const Identifier& id) const;
00108 int gasGap(const Identifier& id) const;
00109
00110 int sector(const Identifier& id) const;
00111
00112
00113
00114 int stationEtaMin() const;
00115 int stationEtaMax() const;
00116 int stationPhiMin() const;
00117 int stationPhiMax() const;
00118 int chamberLayerMin() const;
00119 int chamberLayerMax() const;
00120 int wireLayerMin() const;
00121 int wireLayerMax() const;
00122 int measuresPhiMin() const;
00123 int measuresPhiMax() const;
00124 int stripMin() const;
00125 int stripMax() const;
00126
00127
00128
00129 int stationEtaMin (const Identifier& id) const;
00130 int stationEtaMax (const Identifier& id) const;
00131 int stationPhiMin (const Identifier& id) const;
00132 int stationPhiMax (const Identifier& id) const;
00133 int chamberLayerMin(const Identifier& id) const;
00134 int chamberLayerMax(const Identifier& id) const;
00135 int wireLayerMin (const Identifier& id) const;
00136 int wireLayerMax (const Identifier& id) const;
00137 int measuresPhiMin (const Identifier& id) const;
00138 int measuresPhiMax (const Identifier& id) const;
00139 int stripMin (const Identifier& id) const;
00140 int stripMax (const Identifier& id) const;
00141
00142
00143
00144 bool valid(const Identifier& id) const;
00145 bool validElement(const Identifier& id) const;
00146
00147 private:
00148
00149 int init_id_to_hashes();
00150 unsigned int m_module_hashes[60][3][8];
00151 unsigned int m_detectorElement_hashes[60][3][8][2];
00152
00153
00154 size_type m_CHAMBERLAYER_INDEX;
00155 size_type m_WIRELAYER_INDEX;
00156 size_type m_MEASURESPHI_INDEX;
00157
00158 IdDictFieldImplementation m_cla_impl;
00159 IdDictFieldImplementation m_lay_impl;
00160 IdDictFieldImplementation m_mea_impl;
00161 IdDictFieldImplementation m_str_impl;
00162
00163
00164 virtual int get_hash_calc (const Identifier& compact_id,
00165 IdentifierHash& hash_id,
00166 const IdContext* context) const;
00167
00168
00169
00170 bool validElement(const Identifier& id, int stationName, int stationEta,
00171 int stationPhi) const;
00172 bool validChannel(const Identifier& id, int stationName, int stationEta,
00173 int stationPhi,int chamberLayer, int wireLayer,
00174 int measuresPhi, int strip) const;
00175
00176
00177
00178 int cscTechnology() const;
00179
00180
00181 int strip_hash_offsets();
00182
00183
00184
00185 enum CscIndices
00186 {
00187 ChamberLayerIndex = 5,
00188 WireLayerIndex = 6,
00189 MeasuresPhiIndex = 7,
00190 StripIndex = 8
00191 };
00192
00193
00194
00195 enum CscRanges
00196 {
00197 StationEtaMin = -1,
00198 StationEtaMax = 1,
00199 StationPhiMin = 1,
00200 StationPhiMax = 8,
00201 ChamberLayerMin = 1,
00202 ChamberLayerMax = 2,
00203 WireLayerMin = 1,
00204 WireLayerMax = 4,
00205 MeasuresPhiMin = 0,
00206 MeasuresPhiMax = 1,
00207 StripMin = 1,
00208 StripMax = 216
00209 };
00210 int m_hashOffset[2][2];
00211
00212 mutable unsigned int m_etaStripMax;
00213 mutable unsigned int m_phiStripMax;
00214 inline virtual void create_mlog() const;
00215
00216 };
00217
00218
00219
00220 typedef CscIdHelper CSC_ID;
00221
00222 CLASS_DEF(CscIdHelper, 4171, 1)
00223
00224
00225
00226 inline Identifier CscIdHelper::elementID(int stationName,
00227 int stationEta, int stationPhi,
00228 bool check, bool* isValid) const
00229 {
00230
00231
00232 Identifier result((Identifier::value_type)0);
00233 bool val = false;
00234 m_muon_impl.pack(muon_field_value(),result);
00235 m_sta_impl.pack (stationName,result);
00236 m_eta_impl.pack (stationEta,result);
00237 m_phi_impl.pack (stationPhi,result);
00238 m_tec_impl.pack (csc_field_value(),result);
00239 if ( check ) {
00240 val = this->validElement(result,stationName,stationEta,stationPhi);
00241 if ( isValid ) *isValid = val;
00242 }
00243 return result;
00244 }
00245
00246 inline Identifier CscIdHelper::elementID(std::string stationNameStr,
00247 int stationEta, int stationPhi, bool check, bool* isValid) const
00248 {
00249 Identifier id;
00250 int stationName = stationNameIndex(stationNameStr);
00251 id = elementID(stationName, stationEta, stationPhi, check, isValid);
00252 return id;
00253 }
00254
00255 inline Identifier CscIdHelper::elementID(const Identifier& id) const
00256 {
00257 return parentID(id);
00258 }
00259
00260 inline Identifier CscIdHelper::channelID(int stationName, int stationEta, int stationPhi,
00261 int chamberLayer, int wireLayer, int measuresPhi,
00262 int strip, bool check, bool* isValid) const
00263 {
00264
00265 Identifier result((Identifier::value_type)0);
00266 bool val = false;
00267 m_muon_impl.pack(muon_field_value(),result);
00268 m_sta_impl.pack (stationName,result);
00269 m_eta_impl.pack (stationEta,result);
00270 m_phi_impl.pack (stationPhi,result);
00271 m_tec_impl.pack (csc_field_value(),result);
00272 m_cla_impl.pack (chamberLayer,result);
00273 m_lay_impl.pack (wireLayer,result);
00274 m_mea_impl.pack (measuresPhi,result);
00275 m_str_impl.pack (strip,result);
00276 if ( check ) {
00277 val = this->validChannel(result,stationName,stationEta,stationPhi,
00278 chamberLayer,wireLayer,measuresPhi,strip);
00279 if ( isValid ) *isValid = val;
00280 }
00281 return result;
00282 }
00283
00284 inline Identifier CscIdHelper::channelID(std::string stationNameStr, int stationEta,
00285 int stationPhi, int chamberLayer, int wireLayer,
00286 int measuresPhi, int strip, bool check, bool* isValid) const
00287 {
00288 Identifier id;
00289 int stationName = stationNameIndex(stationNameStr);
00290 id = channelID(stationName, stationEta, stationPhi, chamberLayer,
00291 wireLayer, measuresPhi, strip, check, isValid);
00292 return id;
00293 }
00294
00295 inline Identifier CscIdHelper::channelID(const Identifier& id, int chamberLayer,
00296 int wireLayer, int measuresPhi, int strip, bool check, bool* isValid) const
00297 {
00298 Identifier result(id);
00299 bool val = false;
00300 m_cla_impl.pack (chamberLayer,result);
00301 m_lay_impl.pack (wireLayer,result);
00302 m_mea_impl.pack (measuresPhi,result);
00303 m_str_impl.pack (strip,result);
00304 if ( check ) {
00305 val = this->valid(result);
00306 if ( isValid ) *isValid = val;
00307 }
00308 return result;
00309 }
00310
00312
00313 inline Identifier CscIdHelper::parentID(const Identifier& id) const
00314 {
00315 assert(is_csc(id));
00316 Identifier result(id);
00317 m_cla_impl.reset(result);
00318 m_lay_impl.reset(result);
00319 m_mea_impl.reset(result);
00320 m_str_impl.reset(result);
00321 return result;
00322 }
00323
00324
00325
00326 inline int CscIdHelper::chamberLayer(const Identifier& id) const
00327 {
00328
00329 return m_cla_impl.unpack(id);
00330
00331 }
00332
00333
00334 inline int CscIdHelper::wireLayer(const Identifier& id) const
00335 {
00336
00337 return m_lay_impl.unpack(id);
00338
00339 }
00340
00341 inline bool CscIdHelper::measuresPhi(const Identifier& id) const
00342 {
00343
00344 return m_mea_impl.unpack(id);
00345
00346 }
00347
00348 inline int CscIdHelper::strip(const Identifier& id) const
00349 {
00350
00351 return m_str_impl.unpack(id);
00352
00353 }
00354
00355 inline int CscIdHelper::channel(const Identifier& id) const
00356 {
00357
00358 return strip(id);
00359
00360 }
00361
00363
00364 inline int CscIdHelper::stationEtaMin() const
00365 {
00366 return StationEtaMin;
00367 }
00368
00369 inline int CscIdHelper::stationEtaMax() const
00370 {
00371 return StationEtaMax;
00372 }
00373
00374 inline int CscIdHelper::stationPhiMin() const
00375 {
00376 return StationPhiMin;
00377 }
00378
00379 inline int CscIdHelper::stationPhiMax() const
00380 {
00381 return StationPhiMax;
00382 }
00383
00384 inline int CscIdHelper::chamberLayerMin() const
00385 {
00386 return ChamberLayerMin;
00387 }
00388
00389 inline int CscIdHelper::chamberLayerMax() const
00390 {
00391 return ChamberLayerMax;
00392 }
00393
00394 inline int CscIdHelper::wireLayerMin() const
00395 {
00396 return WireLayerMin;
00397 }
00398
00399 inline int CscIdHelper::wireLayerMax() const
00400 {
00401 return WireLayerMax;
00402 }
00403
00404 inline int CscIdHelper::measuresPhiMin() const
00405 {
00406 return MeasuresPhiMin;
00407 }
00408
00409 inline int CscIdHelper::measuresPhiMax() const
00410 {
00411 return MeasuresPhiMax;
00412 }
00413
00414 inline int CscIdHelper::stripMin() const
00415 {
00416 return StripMin;
00417 }
00418
00419 inline int CscIdHelper::stripMax() const
00420 {
00421 return StripMax;
00422 }
00423
00425
00426 inline int CscIdHelper::cscTechnology() const
00427 {
00428 int cscField = technologyIndex("CSC");
00429 if (m_dict)
00430 {
00431 cscField = csc_field_value();
00432 }
00433 return cscField;
00434 }
00435
00436
00437 inline int CscIdHelper::sector(const Identifier& id) const {
00438 return stationEta(id) * ( 2*stationPhi(id) - (stationName(id)-49) + 1);
00439 }
00440
00441
00442 inline int CscIdHelper::gasGap(const Identifier& id) const
00443 {
00444
00445 return chamberLayer(id);
00446
00447 }
00448
00449
00450
00451 #endif // MUONIDHELPERS_CSCIDHELPER_H
00452