StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StEmcDecoder.h
1 
25 #include <Stiostream.h>
26 #include "Stiostream.h"
27 
28 #ifndef StEmcDecoder_HH
29 #define StEmcDecoder_HH
30 
31 #include "TObject.h"
32 #include "TDatime.h"
33 
34 class StEmcMappingDb;
35 
36 class StEmcDecoder : public TObject
37 {
38 public:
39  StEmcDecoder(unsigned int date=20330101,unsigned int time=000000, bool TowerMapBug = false);
40  virtual ~StEmcDecoder();
41 
42  void SetDateTime(const TDatime& dt) { SetDateTime(dt.GetDate(), dt.GetTime()); }
43  void SetDateTime(unsigned int date, unsigned int time);
44  bool GetFixTowerMapBug(void) const;
45  void SetFixTowerMapBug(bool fix);
46 
47  int GetTowerBugCorrectionShift(int id_original, int &shift) const;
48  int GetPreshowerBugCorrectionShift(int id_original, int &shift) const;
49  int GetSmdBugCorrectionShift(int id_original, int &shift) const;
50 
51  //methods to get another basis from softId
52  int GetTowerBin(int softId,int &m,int &e,int &s) const;
53  int GetDaqIdFromTowerId(int softId,int &RDO) const;
54  int GetCrateFromTowerId(int softId, int &crate, int &sequence) const;
55  int GetTDCFromTowerId(int softId, int &TDC) const;
56  int GetTriggerPatchFromTowerId(int softId, int &patchId) const;
57  int GetJetPatchFromTowerId(int softId, int &jetPatch) const;
58 
59  //methods to get softId from another basis
60  int GetTowerIdFromBin(int m, int e, int s, int &softId) const;
61  int GetTowerIdFromDaqId(int RDO, int &softId) const;
62  int GetTowerIdFromCrate(int crate, int sequence, int &softId) const;
63  int GetTowerIdFromTDC(int TDC, int sequence, int &softId) const;
64 
65  //additional RDO <-> TDC <-> crate translations
66  int GetTowerCrateFromDaqId(int RDO,int &crate, int &sequence) const;
67  int GetTowerCrateFromTDC(int TDC, int &crate) const;
68  int GetTowerTDCFromCrate(int crate, int &TDC) const;
69  int GetTowerTDCFromDaqId(int RDO, int &TDC) const;
70 
71  //additional trigger patch <-> jet patch <-> crate translations
72  int GetTriggerPatchFromCrate(int crate, int sequence, int &patchId) const;
73  int GetCrateAndSequenceFromTriggerPatch(int patchId, int &crate, int &sequence) const;
74  int GetTriggerPatchFromJetPatch(int jetPatch, int sequence, int &patchId) const;
75  int GetJetPatchAndSequenceFromTriggerPatch(int patchId, int &jetPatch, int &sequence) const;
76 
78  int GetDSMFromTriggerPatch(int patchId, int &dsmModule) const;
79 
81  int GetTriggerPatchesFromDSM(int dsmModule, int *triggerPatches) const;
82 
83  //smd methods
84  int GetSmdCoord(int RDO, int posInFiber, int &det, int &m, int &e, int &s, bool print=false) const;
85  int GetSmdCoord(int RDO, int posInFiber, int &det, int &m, int &e, int &s, int &wire, int &A_value, bool print=false) const;
86  int GetSmdRDO(int detector, int m, int e, int s, int &RDO, int &posInFiber) const;
87 
88  //psd methods
89  int GetPsdId(int RDO, int posInFiber, int &softId,bool print=false) const;
90  int GetPsdId(int RDO, int posInFiber, int &softId, int &PMTbox, int &wire, int &A_value, bool print=false) const;
91  int GetPsdRDO(int softId, int &RDO, int &posInFiber) const;
92 
93  void PrintTowerMap(ofstream *out) const;
94  void PrintSmdMap(ofstream *out) const;
95  void PrintPsdMap(ofstream *out) const;
96 
97 private:
98  bool mTowerMapBug;
99  int TowerBugFixIndex[4800];
100  int PreshowerBugFixIndex[4800];
101  int SmdBugFixIndex[18000];
102  StEmcMappingDb* mapping;
103 
104  ClassDef(StEmcDecoder,1)
105 };
106 #endif
107 
108 // $Id: StEmcDecoder.h,v 1.3 2010/12/22 22:57:21 stevens4 Exp $
109 //
110 // $Log: StEmcDecoder.h,v $
111 // Revision 1.3 2010/12/22 22:57:21 stevens4
112 // Patch for BSMDE mapping problem in P10ih and P10ij productions (RT #2043)
113 //
114 // Revision 1.2 2009/02/01 17:34:52 kocolosk
115 // more caching and optimization.
116 //
117 // Last StEmcMapping commit was bad and left header, implementation
118 // inconsistent. This commit fixes the AutoBuild.
119 //
120 // Revision 1.1 2009/01/08 02:16:18 kocolosk
121 // move StEmcMappingDb/StEmcDecoder to StEmcUtil/database
122 //
123 // Revision 2.21 2009/01/02 03:52:46 kocolosk
124 // allow setting timestamp using a TDatime directly
125 //
126 // Revision 2.20 2009/01/02 03:34:33 kocolosk
127 // use default date==20330101 like St_db_Maker to suppress spurious error msgs
128 //
129 // Revision 2.19 2008/12/05 19:05:32 kocolosk
130 // new DB-backed implementation of StEmcDecoder
131 //
132 // Revision 2.18 2008/11/14 23:25:36 mattheww
133 // Fixed a lot of BPRS swaps
134 //
135 // Revision 2.17 2007/10/09 18:02:24 kocolosk
136 // two extra support functions for TP <=> DSM module mapping
137 //
138 // Revision 2.16 2007/09/11 02:41:37 kocolosk
139 // added code to fix preshower swaps in 2006 and beyond
140 //
141 // Revision 2.15 2007/04/04 17:35:12 kocolosk
142 // Added methods GetCrateFromTowerId, GetTDCFromTowerId, GetTDCFromTowerId, GetTriggerPatchFromTowerId, GetJetPatchFromTowerId, and GetTowerIdFromBin. Also implemented const-correctness and used meaningful argument names in method declarations to improve readability.
143 //
int GetSmdBugCorrectionShift(int id_original, int &shift) const
Returns the index shift for the SMD in original map.
int GetTriggerPatchFromCrate(int crate, int sequence, int &patchId) const
returns the trigger patch from crate and sequence in the crate
virtual ~StEmcDecoder()
StEmcDecoder destructor.
int GetJetPatchFromTowerId(int softId, int &jetPatch) const
Get jet patch that contains software Id.
int GetTowerBin(int softId, int &m, int &e, int &s) const
Convert from softId to m,e,s for towers only.
int GetTowerCrateFromTDC(int TDC, int &crate) const
Get crate number from TDC channel for towers.
void PrintPsdMap(ofstream *out) const
Print SMD MAP.
int GetTowerIdFromBin(int m, int e, int s, int &softId) const
Get Software Id from (m,e,s) space.
void PrintTowerMap(ofstream *out) const
Print Tower MAP.
void PrintSmdMap(ofstream *out) const
Print SMD MAP.
bool GetFixTowerMapBug(void) const
Shows if the tower map bug is being fixed on the fly.
int GetTriggerPatchFromJetPatch(int jetPatch, int sequence, int &patchId) const
returns the trigger patch from big jet patch and the sequence in it
int GetSmdCoord(int RDO, int posInFiber, int &det, int &m, int &e, int &s, bool print=false) const
Get SMD detector (3==SMDE, 4==SMDP), m, e, s from RDO and position for SMD.
int GetTowerTDCFromDaqId(int RDO, int &TDC) const
Get TDC channel from Daq Id for towers.
int GetTowerCrateFromDaqId(int RDO, int &crate, int &sequence) const
Get crate number from Daq Id for towers.
int GetTowerIdFromCrate(int crate, int sequence, int &softId) const
Get Software Id from Crate number and position in crate for towers.
int GetPreshowerBugCorrectionShift(int id_original, int &shift) const
Returns the index shift for the preshower in original map.
int GetTowerIdFromDaqId(int RDO, int &softId) const
Get Sofwtare Id from Daq Id for towers.
int GetCrateAndSequenceFromTriggerPatch(int patchId, int &crate, int &sequence) const
returns the crate number and start point for a given trigger patch
int GetPsdRDO(int softId, int &RDO, int &posInFiber) const
Get PSD fiber and position from id.
StEmcDecoder(unsigned int date=20330101, unsigned int time=000000, bool TowerMapBug=false)
StEmcDecoder constructor.
int GetCrateFromTowerId(int softId, int &crate, int &sequence) const
Get crate number and position in crate for Software Id.
int GetTowerIdFromTDC(int TDC, int sequence, int &softId) const
Get Software Id from TDC channel number and position in TDC for towers.
int GetJetPatchAndSequenceFromTriggerPatch(int patchId, int &jetPatch, int &sequence) const
return the big jet patch and sequence number within it from the
int GetTriggerPatchFromTowerId(int softId, int &patchId) const
Get trigger patch that contains software Id.
int GetTowerBugCorrectionShift(int id_original, int &shift) const
Returns the index shift for the tower in original map.
int GetPsdId(int RDO, int posInFiber, int &softId, bool print=false) const
Get PSD id.
int GetTowerTDCFromCrate(int crate, int &TDC) const
Get TDC channel from crate number for towers.
int GetSmdRDO(int detector, int m, int e, int s, int &RDO, int &posInFiber) const
Get SMD fiber and position from detector number (3==SMDE, 4==SMDP), m, e, s.
int GetDaqIdFromTowerId(int softId, int &RDO) const
Get Daq Id from Software Id for towers.
int GetTDCFromTowerId(int softId, int &TDC) const
Get TDC channel from Software Id.
void SetFixTowerMapBug(bool fix)
Sets the tower map bug fix.
int GetDSMFromTriggerPatch(int patchId, int &dsmModule) const
dsmModule is set to the DSM module containing this trigger patch (0-299)
int GetTriggerPatchesFromDSM(int dsmModule, int *triggerPatches) const
triggerPatches is an int[10]; contents will be set to the TPs of the supplied DSM # ...