Hall A ROOT/C++ Analyzer (podd)
Loading...
Searching...
No Matches
Caen775Module.cxx
Go to the documentation of this file.
1
2//
3// Caen775Module
4// author Stephen Wood
5// author Vincent Sulkosky
6//
7// Decoder module to retrieve Caen 775 TDCs. Based on CAEN 792 decoding in
8// SkeletonModule.C in Podd 1.6. (Written by S. Wood, modified by V. Sulkosky)
9//
11
12
13#include "Caen775Module.h"
14#include "THaSlotData.h"
15#include "TString.h"
16#include <iostream>
17
18using namespace std;
19
20// #define DEBUG
21// #define WITH_DEBUG
22
23namespace Decoder {
24
26 DoRegister( ModuleType( "Decoder::Caen775Module" , 775 ));
27
29 VmeModule(crate, slot)
30{
31 fDebugFile=nullptr;
33}
34
37#ifdef DEBUG
38 cout << endl << "Initializing v" << MyModName() << "!" << endl << endl;
39#endif
41 fData.resize(fNumChan);
42#if defined DEBUG && defined WITH_DEBUG
43 // This will make a HUGE output
44 delete fDebugFile; fDebugFile = 0;
45 fDebugFile = new ofstream;
46 fDebugFile->open(string("v")+MyModName()+"debug.txt");
47#endif
48 Clear();
49 IsInit = true;
50 TString modtypeup(MyModType());
51 modtypeup.ToUpper();
52 fName = Form("Caen %s %s Module",modtypeup.Data(),MyModName());
53}
54
56 const UInt_t* pstop )
57{
58// This is a simple, default method for loading a slot
59 const UInt_t *p = evbuffer;
60 fWordsSeen = 0;
61// cout << "version like V792"<<endl;
62 ++p;
63 UInt_t nword = *p-2;
64 ++p;
65 for (UInt_t i=0;i<nword;i++) {
66 ++p;
67 if (p>pstop)
68 break;
69 UInt_t chan=((*p)&0x00ff0000)>>16;
70 UInt_t raw=((*p)&0x00000fff);
71 Int_t status = sldat->loadData(MyModType(),chan,raw,raw);
72 fWordsSeen++;
73 if (chan < fData.size()) fData[chan]=raw;
74// cout << "word "<<i<<" "<<chan<<" "<<raw<<endl;
75 if( status != SD_OK ) return -1;
76 }
77 return fWordsSeen;
78}
79
81 UInt_t pos, UInt_t len )
82{
83 // Fill data structures of this class
84 // Read until out of data or until decode says that the slot is finished
85 // len = ndata in event, pos = word number for block header in event
86 Clear();
87 UInt_t counter = 0;
88 Bool_t found_slot = kFALSE;
89 UInt_t nword = 0;
90 UInt_t slot_counter = 0;
91 const UInt_t *p = evbuffer;
92 fWordsSeen = 0;
93
94#ifdef WITH_DEBUG
95 //cout << "Number of words from 775: \t" << len << endl << endl;
96#endif
97 while (fWordsSeen < len) {
98 UInt_t index = pos + fWordsSeen;
99 // first word is the header
100 if( !found_slot ) {
101 nword = (p[index] & 0x00003f00) >> 8; // number of converted channels bits 8-13
102 auto slot_num = (p[index] & 0xf8000000) >> 27;
103 fWordsSeen++;
104 if (slot_num == fSlot) found_slot = kTRUE;
105 } else if (slot_counter < nword) { // excludes the End of Block (EOB) word
106 UInt_t chan = (p[index] & 0x00ff0000) >> 16; // number of channel which data are coming from bits 16-20
107 UInt_t raw = p[index] & 0x00000fff; // raw datum bits 0-11
108 Int_t status = sldat->loadData(MyModType(),chan,raw,raw);
109 fWordsSeen++;
110 counter++;
111 slot_counter++;
112 if( chan < fData.size() ) fData[chan] = raw;
113#ifdef WITH_DEBUG
114 //cout << "word\t"<<index<<"\t"<<chan<<"\t"<<raw<<endl;
115#endif
116 if( status != SD_OK ) return -1;
117 } else fWordsSeen++; // increment the counter for the EOB word
118
119#ifdef WITH_DEBUG
120 if( fDebugFile )
121 *fDebugFile << "\n" << "Caen775Module::LoadSlot >> evbuffer[" << index
122 << "] = " << hex << evbuffer[index] << dec << " >> crate = "
123 << fCrate << " >> slot = " << fSlot << " >> pos = "
124 << pos << " >> fWordsSeen = " << fWordsSeen
125 << " >> len = " << len << " >> index = " << index << "\n" << endl;
126#endif
127 }
128 if( counter != nword )
129 cout << Form("Warning in v%s Number of converted channels, %u, is not "
130 "equal to number of decoded words, %u!",
131 MyModName(), nword, counter) << endl << endl;
132 return fWordsSeen;
133}
134
135 /* Does anything use this method */
137 if (chan > fNumChan) return 0;
138 return fData[chan];
139}
140
142 VmeModule::Clear(opt);
143 fData.assign(fNumChan,0);
144}
145
146}
147
int Int_t
unsigned int UInt_t
uint32_t chan
bool Bool_t
const Bool_t kFALSE
const Bool_t kTRUE
const char Option_t
winID h TVirtualViewer3D TVirtualGLPainter p
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t index
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t UChar_t len
const int SD_OK
Definition THaSlotData.h:33
char * Form(const char *fmt,...)
virtual UInt_t GetData(UInt_t chan) const
static const size_t NTDCCHAN
virtual const char * MyModType()
virtual void Clear(Option_t *opt="")
static TypeIter_t fgThisType
virtual UInt_t LoadSlot(THaSlotData *sldat, const UInt_t *evbuffer, const UInt_t *pstop)
virtual const char * MyModName()
UInt_t fCrate
Definition Module.h:142
UInt_t fNumChan
Definition Module.h:148
virtual void Init()
Definition Module.cxx:51
std::ofstream * fDebugFile
Definition Module.h:156
UInt_t fSlot
Definition Module.h:142
UInt_t fWordsSeen
Definition Module.h:145
std::vector< UInt_t > fData
Definition Module.h:140
TypeSet_t::iterator TypeIter_t
Definition Module.h:40
Bool_t IsInit
Definition Module.h:151
Int_t loadData(const char *type, UInt_t chan, UInt_t dat, UInt_t raw)
TString fName
void Clear(Option_t *option="") override
const char * Data() const
void ToUpper()
STL namespace.
ClassImp(TPyArg)