Hall A ROOT/C++ Analyzer (podd)
Loading...
Searching...
No Matches
THaQWEAKHelicityReader.cxx
Go to the documentation of this file.
1//*-- Author : Ole Hansen August 2006
2// Extracted from Bob Michaels' THaHelicity CVS 1.19
4//
5// THaQWEAKHelicityReader
6//
8
10#include "THaEvData.h"
11#include "TError.h"
12#include "THaAnalysisObject.h" // For LoadDB
13#include <iostream>
14#include "TH1F.h"
15
16using namespace std;
17
18//____________________________________________________________________
23
24//____________________________________________________________________
30 fQWEAKDebug(0), // Debug level
31 fHaveROCs(false), // Required ROCs are defined
32 fNegGate(false), // Invert polarity of gate, so that 0=active
33 fHistoR{}
34{
35 // Default constructor
36}
37
38//____________________________________________________________________
39//THaQWEAKHelicityReader::~THaQWEAKHelicityReader()
40//{
41// // Destructor
42//
43// // Histograms will be deleted by ROOT
44// // for( Int_t i = 0; i < NHISTR; ++i ) {
45// // delete fHistoR[i];
46// // }
47//}
48
49//____________________________________________________________________
51{
52 cout<<"================================================\n";
53 cout<<" THaQWEAKHelicityReader::Print() \n";
54 cout<<endl;
55 cout<<"fPatternTir, fHelicityTir, fTSettleTir="<< fPatternTir
56 <<" , "<<fHelicityTir<<" , "<<fTSettleTir<<endl;
57 cout<<"fTimeStampTir ="<<fTimeStampTir<<endl;
58 cout<<"fIRing="<<fIRing<<endl<<endl;
59 for (UInt_t j=0;j<fIRing;j++)
60 {
61 cout<<j<<"Pattern, helicity, time, T3, U3, T5, T10="
62 <<fHelicityRing[j]<<" , "
63 <<fPatternRing[j]<<" , "
64 <<fTimeStampRing[j]<<" , "
65 <<fT3Ring[j]<<" , "
66 <<fU3Ring[j]<<" , "
67 <<fT5Ring[j]<<" , "
68 <<fT10Ring[j]<<endl;
69 }
70 if(fIRing==0)
71 {
72 cout<<0<<"Pattern, helicity, time, T3, U3, T5, T10="
73 <<fHelicityRing[0]<<" , "
74 <<fPatternRing[0]<<" , "
75 <<fTimeStampRing[0]<<" , "
76 <<fT3Ring[0]<<" , "
77 <<fU3Ring[0]<<" , "
78 <<fT5Ring[0]<<" , "
79 <<fT10Ring[0]<<endl;
80 }
81 cout<<"================================================\n";
82}
83
84//____________________________________________________________________
86{
91 fIRing=0;
92 for(int i=0;i<kHelRingDepth;i++)
93 {
94 fHelicityRing[i]=3;
95 fPatternRing[i]=3;
96 fTimeStampRing[i]=0;
97 fT3Ring[i]=0;
98 fU3Ring[i]=0;
99 fT5Ring[i]=0;
100 fT10Ring[i]=0;
101 }
102}
103
104//____________________________________________________________________
106 const ROCinfo& info )
107// find the index of the word we are looking for given a header
108// or simply return the index already stored in ROC info (in that case
109// the header stored in ROC info needs to be 0
110{
111 UInt_t len = evdata.GetRocLength(info.roc);
112 if (len <= 4)
113 return -1;
114
115 UInt_t i = 0;
116 if( info.header == 0 )
117 i = info.index;
118 else {
119 for( ; i<len &&
120 (evdata.GetRawData(info.roc, i) & 0xffff000) != info.header;
121 ++i) {}
122 i += info.index;
123 }
124 return (i < len) ? i : kMaxUInt;
125}
126
127//_____________________________________________________________________________
128Int_t THaQWEAKHelicityReader::ReadDatabase( const char* /*dbfilename*/,
129 const char* /*prefix*/,
130 const TDatime& /*date*/,
131 int /*debug_flag*/ )
132{
133 // Read parameters from database: ROC info (detector map), QWEAK delay value
134 // TODO: for now I will bypass this call and just hardcode the data I need
135 // static const char* const here = "THaQWEAKHelicityReader::ReadDatabase";
136
137 // for now bypass the reading from the data base
138
139 SetROCinfo(kHel,11,0,3);
140 SetROCinfo(kTime,11,0,4);
141 SetROCinfo(kRing,11,0,0);
142
144}
145
146//_____________________________________________________________________________
148{
149 // static const char* const here = "THaQWEAKHelicityReader::Begin";
150 // cout<<here<<endl;
151
152 fHistoR[0]=new TH1F("hel.Pattern.TIR","hel.Pattern.TIR",5,-0.75, 1.75);
153 fHistoR[1]=new TH1F("hel.TSettle.TIR","hel.TSettle.TIR",5,-0.75, 1.75);
154 fHistoR[2]=new TH1F("hel.Reported.Helicity.TIR","hel.Reported.Helicity.TIR"
155 ,5,-0.75, 1.75);
156 fHistoR[3]=new TH1F("hel.dTimestamp.TIR","hel.dTimestamp.TIR",1000,-50,49950);
157 fHistoR[4]=new TH1F("hel.Pattern.Ring","hel.Pattern.Ring",5,-0.75, 1.75);
158 fHistoR[5]=new TH1F("hel.Reported.Helicity.Ring","hel.Reported.Helicity.Ring"
159 ,5,-0.75, 1.75);
160 fHistoR[6]=new TH1F("hel.Timestamp.Ring","hel.Timestamp.Ring",100,-10,490);
161 fHistoR[7]=new TH1F("hel.T3.Ring","hel.T3.Ring",53,-1.5, 50.5);
162 fHistoR[8]=new TH1F("hel.U3.Ring","hel.U3.Ring",100,-0.5, 99.5);
163 fHistoR[9]=new TH1F("hel.T5.Ring","hel.T5.Ring",53,-1.5, 50.5);
164 fHistoR[10]=new TH1F("hel.T10.Ring","hel.T10.Ring",53,-1.5, 50.5);
165 fHistoR[11]=new TH1F("hel.NRing","hel.NRing",503,-1.5, 501.5);
166}
167
168//____________________________________________________________________
170{
171 // static const char* const here = "THaQWEAKHelicityReader::End";
172 // cout<<here<<endl;
173
174 for(auto & i : fHistoR)
175 i->Write();
176}
177
178//____________________________________________________________________
180{
181 // Obtain the present data from the event for QWEAK helicity mode.
182
183 static const char* here = "THaQWEAKHelicityReader::ReadData";
184
185 // std::cout<<" kHel, kTime, kRing="<< kHel<<" "<<kTime<<" "<<kRing<<endl;
186 // for (int jk=0; jk<3; jk++)
187 // {
188 // std::cout<<" which="<<jk
189 // <<" roc="<<fROCinfo[jk].roc
190 // <<" header="<<fROCinfo[jk].header
191 // <<" index="<<fROCinfo[jk].index
192 // <<endl;
193 // }
194
195 // std::cout<<" fHaveROCs="<<fHaveROCs<<endl;
196 if( !fHaveROCs ) {
197 ::Error( here, "ROC data (detector map) not properly set up." );
198 return -1;
199 }
200 UInt_t hroc = fROCinfo[kHel].roc;
201 UInt_t len = evdata.GetRocLength(hroc);
202 if (len <= 4)
203 return -1;
204
205 UInt_t ihel = FindWord( evdata, fROCinfo[kHel] );
206 if (ihel == kMaxUInt) {
207 ::Error( here , "Cannot find helicity" );
208 return -1;
209 }
210 UInt_t data = evdata.GetRawData( hroc, ihel );
211 fPatternTir =(data & 0x20)>>5;
212 fHelicityTir=(data & 0x10)>>4;
213 fTSettleTir =(data & 0x40)>>6;
214
215 hroc=fROCinfo[kTime].roc;
216 len = evdata.GetRocLength(hroc);
217 if (len <= 4)
218 {
219 ::Error( here, "length of roc event not matching expectation ");
220 return -1;
221 }
222 UInt_t itime = FindWord (evdata, fROCinfo[kTime] );
223 if (itime == kMaxUInt) {
224 ::Error( here, "Cannot find timestamp" );
225 return -1;
226 }
227
228 fTimeStampTir = evdata.GetRawData(hroc, itime);
229
230 // Invert the gate polarity if requested
231 // if( fNegGate )
232 // fGate = !fGate;
233
234 hroc=fROCinfo[kRing].roc;
235 len = evdata.GetRocLength(hroc);
236 if (len <= 4)
237 {
238 ::Error( here, "length of roc event not matching expectation (message 2)");
239 // std::cout<<" len ="<<len<<endl;
240 // std::cout<<"kRING="<<kRing<<" hroc="<<hroc<<endl;
241 return -1;
242 }
243 UInt_t index = 0;
244 while( index < len && fIRing == 0 )
245 {
246 UInt_t header=evdata.GetRawData(hroc,index++);
247 if ((header & 0xffff0000) == 0xfb1b0000)
248 {
249 fIRing = header & 0x3ff;
250 }
251 }
252
253 // std::cout<<" fIRing ="<<fIRing<<" index="<<index<<endl;
254
255
257 {
258 ::Error( here, "Ring depth to large ");
259 return -1;
260 }
261 for(UInt_t i=0;i<fIRing; i++)
262 {
263 fTimeStampRing[i]=evdata.GetRawData(hroc,index++);
264 data=evdata.GetRawData(hroc,index++);
265 fHelicityRing[i]=(data & 0x1);
266 fPatternRing[i]= (data & 0x10)>>4;
267 fT3Ring[i]=evdata.GetRawData(hroc,index++);
268 fU3Ring[i]=evdata.GetRawData(hroc,index++);
269 fT5Ring[i]=evdata.GetRawData(hroc,index++);
270 fT10Ring[i]=evdata.GetRawData(hroc,index++);
271 }
272
273 // Print();
274
275 FillHisto();
276
277 return 0;
278}
279//____________________________________________________________________
281{
282 // static const char* here = "THaQWEAKHelicityReader::FillHisto";
283 // cout<<here<<endl;
284
290 for(UInt_t i=0;i<fIRing;i++)
291 {
292 fHistoR[4]->Fill(fPatternRing[i]);
293 fHistoR[5]->Fill(fHelicityRing[i]);
295 fHistoR[7]->Fill(fT3Ring[i]);
296 fHistoR[8]->Fill(fU3Ring[i]);
297 fHistoR[9]->Fill(fT5Ring[i]);
298 fHistoR[10]->Fill(fT10Ring[i]);
299 }
300 fHistoR[11]->Fill(fIRing);
301}
302
303
304//TODO: this should not be needed once LoadDB can fill fROCinfo directly
305//____________________________________________________________________
307 UInt_t header, UInt_t index )
308{
309
310 // Define source and offset of data. Normally called by ReadDatabase
311 // of the detector that is a THaQWEAKHelicityReader.
312 //
313 // "which" is one of { kHel, kTime, kROC2, kROC3 }.
314 // You must define at least the kHel and kTime ROCs.
315 // Returns <0 if parameter error, 0 if success
316
317 if( which<kHel || which>kROC3 )
318 return -1;
319 if( roc <= 0 || roc > 255 )
320 return -2;
321
322 fROCinfo[which].roc = roc;
323 fROCinfo[which].header = header;
324 fROCinfo[which].index = index;
325
326 fHaveROCs = ( fROCinfo[kHel].roc > 0 && fROCinfo[kTime].roc > 0 );
327
328 return 0;
329}
330
331//____________________________________________________________________
int Int_t
unsigned int UInt_t
bool Bool_t
const UInt_t kMaxUInt
const char Option_t
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void data
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
static const char *const here
Definition THaVar.cxx:64
virtual Int_t Fill(const char *name, Double_t w)
UInt_t GetRawData(UInt_t crate, UInt_t slot, UInt_t hit) const
Definition THaEvData.h:288
UInt_t GetRocLength(UInt_t crate) const
Definition THaEvData.h:259
UInt_t fTimeStampRing[kHelRingDepth]
static UInt_t FindWord(const THaEvData &evdata, const ROCinfo &info)
UInt_t fPatternRing[kHelRingDepth]
UInt_t fT3Ring[kHelRingDepth]
UInt_t fHelicityRing[kHelRingDepth]
UInt_t fT10Ring[kHelRingDepth]
virtual void Clear(Option_t *opt="")
UInt_t fU3Ring[kHelRingDepth]
virtual Int_t ReadData(const THaEvData &evdata)
UInt_t fT5Ring[kHelRingDepth]
Int_t SetROCinfo(EROC which, UInt_t roc, UInt_t header, UInt_t index)
Int_t ReadDatabase(const char *dbfilename, const char *prefix, const TDatime &date, int debug_flag=0)
static const UInt_t MAXROC
Definition Decoder.h:33
STL namespace.
ClassImp(TPyArg)