QwAnalysis
QwMainDetector.h
Go to the documentation of this file.
1 /*------------------------------------------------------------------------*//*!
2 
3  \file QwMainDetector.h
4 
5  \author P. King
6  \author P. Wang
7 
8  \date 2007-05-08 15:40
9 
10  \brief This is the main executable for the tracking analysis.
11 
12 *//*-------------------------------------------------------------------------*/
13 
14 #ifndef __QWMAINDETECTOR__
15 #define __QWMAINDETECTOR__
16 
17 #include <vector>
18 #include "TTree.h"
19 
20 #include "VQwSubsystemTracking.h"
21 #include "QwColor.h"
22 
23 #include "QwHit.h"
24 #include "QwHitContainer.h"
25 
26 #include "QwTypes.h"
27 #include "QwDetectorInfo.h"
28 
29 #include "MQwV775TDC.h"
30 #include "QwPMT_Channel.h"
31 #include "QwScaler_Channel.h"
32 #include "QwF1TDContainer.h"
33 
34 #include "QwSoftwareMeantime.h"
35 #include "QwOptions.h"
36 ///
37 /// \ingroup QwTracking
38 class QwMainDetector: public VQwSubsystemTracking, public MQwSubsystemCloneable<QwMainDetector> {
39  /******************************************************************
40  * Class: QwMainDetector
41  *
42  *
43  ******************************************************************/
44  private:
45  /// Private default constructor (not implemented, will throw linker error on use)
47 
48  public:
49  /// Constructor with name
50  QwMainDetector(const TString& name);
51  /// Virtual destructor
52  virtual ~QwMainDetector();
53 
54  /* Member functions derived from VQwSubsystem. */
55  Int_t LoadChannelMap(TString mapfile);
56  Int_t LoadInputParameters(TString mapfile){return 0;};
57 
59  void ConstructHistograms(TDirectory *folder, TString &prefix);
60  void FillHistograms();
61 
63  void ConstructBranchAndVector(TTree *tree, TString& prefix, std::vector<Double_t> &values);
64  void FillTreeVector(std::vector<Double_t> &values) const;
65 
66  Int_t ProcessConfigurationBuffer(const UInt_t roc_id, const UInt_t bank_id, UInt_t* buffer, UInt_t num_words);
67  void ReportConfiguration(Bool_t verbose);
68  Int_t ProcessEvBuffer(const UInt_t roc_id, const UInt_t bank_id, UInt_t* buffer, UInt_t num_words);
69 
70  void ProcessEvent();
71 
72  void FillRawTDCWord(Int_t bank_index, Int_t slot_num, Int_t chan, UInt_t data);
74 
75  void ClearEventData();
76 
77 
78  static void DefineOptions(QwOptions& options);
79  void ProcessOptions(QwOptions& options);
80 
81  void GetHitList(QwHitContainer & grandHitContainer) {
82  grandHitContainer.Append(fTDCHits);
83  };
84 
86 
87 
88  protected:
90 
91  Bool_t fDEBUG;
94 
95  TString fRegion; /// Name of this subsystem (the region).
97  Int_t fCurrentSlot;
99 
100  UInt_t fBankID[3];
101  //bank ID's of 3 different modules for trigger scintillator
102  //fBankID[0] for V792/V775 QDC_Bank
103  //fBankID[1] for SIS3801 SCA_Bank
104  //fBankID[2] for F1TDC F1TDC_Bank
105 
106 
107  static const UInt_t kMaxNumberOfModulesPerROC;
108  static const Int_t kF1ReferenceChannelNumber;
109 
112 
113  static const Int_t kMaxNumberOfQwHitPlane; //JAM 2012-03-12
114 
115 
121 
122  void FillRawWord(Int_t bank_index, Int_t slot_num, Int_t chan, UInt_t data);
123 
125  Int_t RegisterROCNumber (const UInt_t roc_id);
126  Int_t RegisterSubbank (const UInt_t bank_id);
127  Int_t RegisterSlotNumber (const UInt_t slot_id); // Tells this object that it will decode data from the current bank
128 
129  Int_t GetModuleIndex(size_t bank_index, size_t slot_num) const;
130 
131  Bool_t IsSlotRegistered(Int_t bank_index, Int_t slot_num) const {
132  return (GetModuleIndex(bank_index,slot_num) != -1);
133  };
134 
135  EQwModuleType RegisterModuleType(TString moduletype);
136  Int_t LinkChannelToSignal(const UInt_t chan, const TString &name);
137  Int_t FindSignalIndex(const EQwModuleType modtype, const TString &name) const;
138 
139 
140  void SubtractReferenceTimes(); // be executed in ProcessEvent()
141  void UpdateHits(); // be executed in ProcessEvent()
142 
143  void AddSoftwareMeantimeToHits(Bool_t option);
144 
145  std::vector< QwHit > fTDCHits;
146 
147  std::vector< std::vector< QwDetectorID > > fDetectorIDs;
148  // Indexed by module_index and Channel; and so on....
149  std::vector< std::pair<Int_t, Int_t> > fReferenceChannels;
150  // reference chans number <first:tdc_index, second:channel_number>
151  // fReferenceChannels[tdc_index,channel_number][ num of [tdc,chan] set]
152  std::vector< std::vector<Double_t> > fReferenceData;
153  // fReferenceData[bank_index][channel_number]
154 
155 
156 
157  std::vector< std::vector<Int_t> > fModuleIndex; // Module index, indexed by bank_index and slot_number
158  std::vector< EQwModuleType > fModuleTypes;
159  std::vector< std::vector< std::pair< EQwModuleType, Int_t> > > fModulePtrs; // Indexed by Module_index and Channel; gives the plane and wire assignment.
160 
161  // We need a mapping of module,channel into PMT index, ADC/TDC
162  std::vector< std::vector<QwPMT_Channel> > fPMTs;
163  std::vector<QwSIS3801D24_Channel> fSCAs;
164  std::map<TString,size_t> fSCAs_map;
165  std::vector<Int_t> fSCAs_offset;
166 
167  // For reference time subtraction
170  Double_t fRefTime;
171 
172  Bool_t IsF1ReferenceChannel (Int_t slot, Int_t chan) {
173  return ( slot == fRefTime_SlotNum && chan == fRefTime_ChanNum) ;
174  };
175 
176 };
177 
178 #endif
QwMainDetector & operator=(const QwMainDetector &value)
Int_t ProcessConfigurationBuffer(const UInt_t roc_id, const UInt_t bank_id, UInt_t *buffer, UInt_t num_words)
std::vector< EQwModuleType > fModuleTypes
void FillHistograms()
Fill the histograms for this subsystem.
std::vector< std::vector< Int_t > > fModuleIndex
MeanTimeContainer * fSoftwareMeantimeContainer[8]
F1TDCs configuration and reference siganls container.
std::vector< std::vector< Double_t > > fReferenceData
void FillRawWord(Int_t bank_index, Int_t slot_num, Int_t chan, UInt_t data)
Bool_t IsSlotRegistered(Int_t bank_index, Int_t slot_num) const
void SubtractReferenceTimes()
void FillTreeVector(std::vector< Double_t > &values) const
Fill the tree vector.
std::vector< std::vector< std::pair< EQwModuleType, Int_t > > > fModulePtrs
An options class.
Definition: QwOptions.h:133
void ReportConfiguration(Bool_t verbose)
Int_t RegisterSlotNumber(const UInt_t slot_id)
std::vector< QwHit > fTDCHits
virtual ~QwMainDetector()
Virtual destructor.
Int_t LoadInputParameters(TString mapfile)
Mandatory parameter file definition.
Software Meantime container.
void AddSoftwareMeantimeToHits(Bool_t option)
Int_t fCurrentBankIndex
Name of this subsystem (the region).
virtual void ConstructHistograms()
Construct the histograms for this subsystem.
Definition: VQwSubsystem.h:209
void FillRawTDCWord(Int_t bank_index, Int_t slot_num, Int_t chan, UInt_t data)
Int_t ProcessEvBuffer(const UInt_t roc_id, const UInt_t bank_id, UInt_t *buffer, UInt_t num_words)
TODO: The non-event-type-aware ProcessEvBuffer routine should be replaced with the event-type-aware v...
Int_t FindSignalIndex(const EQwModuleType modtype, const TString &name) const
Int_t LoadChannelMap(TString mapfile)
Mandatory map file definition.
static void DefineOptions()
Define options function (note: no virtual static functions in C++)
Definition: VQwSubsystem.h:88
Draft skeleton for the decoding-to-QTR interface class.
MQwV775TDC fQDCTDC
QwMainDetector()
Private default constructor (not implemented, will throw linker error on use)
static const Int_t kF1ReferenceChannelNumber
Bool_t fSoftwareMeantimeOption
static const UInt_t kMaxNumberOfModulesPerROC
Int_t GetModuleIndex(size_t bank_index, size_t slot_num) const
static const Int_t kMaxNumberOfQwHitPlane
EQwModuleType
Definition: QwTypes.h:148
Int_t LinkChannelToSignal(const UInt_t chan, const TString &name)
Int_t RegisterSubbank(const UInt_t bank_id)
MQwF1TDC fF1TDCDecoder
virtual void ConstructBranchAndVector(TTree *tree, TString &prefix, std::vector< Double_t > &values)=0
Construct the branch and tree vector.
EQwModuleType fCurrentType
Int_t fCurrentModuleIndex
std::vector< QwSIS3801D24_Channel > fSCAs
void ClearAllBankRegistrations()
An options class which parses command line, config file and environment.
Int_t RegisterROCNumber(const UInt_t roc_id)
std::vector< std::pair< Int_t, Int_t > > fReferenceChannels
EQwModuleType RegisterModuleType(TString moduletype)
QwF1TDContainer * fF1TDContainer
void ProcessOptions(QwOptions &options)
Process the command line options.
std::vector< Int_t > fSCAs_offset
void GetHitList(QwHitContainer &grandHitContainer)
Get the hit list.
void Append(const QwHitContainer &mylist)
Double_t fSoftwareMeantimeTimeWindowNs
UInt_t fBankID[3]
std::map< TString, size_t > fSCAs_map
std::vector< std::vector< QwDetectorID > > fDetectorIDs
F1TDCReferenceContainer * fF1RefContainer
std::vector< std::vector< QwPMT_Channel > > fPMTs
void FillHardwareErrorSummary()
Hardware error summary.
void ConstructBranchAndVector(TTree *tree, TString &prefix, std::vector< Double_t > &values)
Construct the branch and tree vector.
UInt_t kMaxNumberOfChannelsPerF1TDC
Bool_t IsF1ReferenceChannel(Int_t slot, Int_t chan)