FairRoot/PandaRoot
Public Member Functions | Private Member Functions | Private Attributes | List of all members
ReadMainzProto60v4 Class Reference

#include <ReadMainzProto60v4.h>

Inheritance diagram for ReadMainzProto60v4:
ReadMainzProto60

Public Member Functions

void GetEnergies (Double_t *energies)
 
void GetTimes (Double_t *times)
 
void GetADCValues (Double_t *ADCs)
 
void GetTaggerTimes (Double_t *taggertimes)
 
void GetTaggerEnergies (Double_t *taggerEnergies)
 
void Reset ()
 
void PrintEvent ()
 
Long_t ReadNextEvent ()
 
Long_t GetNumberOfEvents ()
 
 ReadMainzProto60v4 ()
 
 ReadMainzProto60v4 (const char *datafilename, const char *calibrationfilename)
 
 ~ReadMainzProto60v4 ()
 

Private Member Functions

unsigned int read_one_event ()
 
void convert_60 (void)
 
void calibrate_60 (void)
 
void read_energy_factor (const char *filename)
 

Private Attributes

FILE * in
 
Bool_t ResetToFirstEvent
 
Long_t NumberOfEvents
 
double LG [60]
 
double TIME [60]
 
double TAGGER [16]
 
double TP
 
double MU
 
double VETO
 
double LG_CAL [60]
 
double TIME_CAL [60]
 
double TAGGER_CAL [16]
 
double TP_CAL
 
double MU_CAL
 
double VETO_CAL
 
unsigned int rawdata [32][16]
 
unsigned int noe_of_board [16]
 
int no_of_boards
 
int what [16]
 
int geos [16]
 
unsigned int geo_to_bnr [32]
 
char versionsstr [15]
 
int RANGE
 
int BINS
 
int CAL_RANGE
 
int CAL_BINS
 
int central
 
double lg_factor [60]
 
double lg_ped [60]
 
double ctime_factor
 
Bool_t IsInit
 

Detailed Description

Definition at line 15 of file ReadMainzProto60v4.h.

Constructor & Destructor Documentation

ReadMainzProto60v4::ReadMainzProto60v4 ( )

Definition at line 153 of file ReadMainzProto60v4.cxx.

References IsInit, and printf().

153  {
154  IsInit=kFALSE;
155  printf("do datafile given, nothing to do\n");
156 }
printf("RealTime=%f seconds, CpuTime=%f seconds\n", rtime, ctime)
ReadMainzProto60v4::ReadMainzProto60v4 ( const char *  datafilename,
const char *  calibrationfilename 
)

Definition at line 158 of file ReadMainzProto60v4.cxx.

References BINS, CAL_BINS, CAL_RANGE, central, ctime_factor, in, IsInit, NumberOfEvents, printf(), RANGE, read_energy_factor(), ResetToFirstEvent, and versionsstr.

158  {
159  IsInit=kFALSE;
160  ctime_factor=0.180;
161  RANGE=3860;
162  BINS=3860;
163  CAL_RANGE=1000;
164  CAL_BINS=4000;
165  central=34;
166  strcpy(versionsstr,"data_all_4.1.3");
167  NumberOfEvents=0;
168  ResetToFirstEvent=kFALSE;
169 
170  //unsigned int rv; //[R.K. 01/2017] unused variable?
171  //unsigned int noe=0; //[R.K. 01/2017] unused variable?
172  //int how_often=1000; //[R.K. 01/2017] unused variable?
173 
174  //int tagged_crystal=35; //[R.K. 01/2017] unused variable?
175  in = fopen(datafilename, "rb");
176  if(in==NULL){
177  printf("can't read datafile %s !!!\n", datafilename);
178  return;
179  }
180  read_energy_factor(calibrationfilename);
181 
182  IsInit=kTRUE;
183 }
printf("RealTime=%f seconds, CpuTime=%f seconds\n", rtime, ctime)
void read_energy_factor(const char *filename)
ReadMainzProto60v4::~ReadMainzProto60v4 ( )

Definition at line 185 of file ReadMainzProto60v4.cxx.

References in.

185  {
186  fclose(in);
187 }

Member Function Documentation

void ReadMainzProto60v4::calibrate_60 ( void  )
private

Definition at line 214 of file ReadMainzProto60v4.cxx.

References ctime_factor, LG, LG_CAL, lg_factor, lg_ped, MU, MU_CAL, n, TAGGER, TAGGER_CAL, TIME, TIME_CAL, TP, TP_CAL, VETO, and VETO_CAL.

Referenced by ReadNextEvent().

214  {
215  for(int n=0; n<60; n++){
216  TIME_CAL[n] = ((TIME[n]) * ctime_factor);
217  LG_CAL[n] = (((LG[n])-lg_ped[n]) * lg_factor[n]);
218  }
219  for(int n=0; n<16; n++){
220  TAGGER_CAL[n] = ((TAGGER[n]) * ctime_factor);
221  }
222  TP_CAL = ((TP) * ctime_factor);
223  MU_CAL = ((MU) * ctime_factor);
224  VETO_CAL = ((VETO) * ctime_factor);
225 }
int n
void ReadMainzProto60v4::convert_60 ( void  )
private

Definition at line 227 of file ReadMainzProto60v4.cxx.

References central, LG, MU, n, rawdata, TAGGER, TIME, TP, and VETO.

Referenced by ReadNextEvent().

227  {
228  for(int n=0; n<32; n++){
229  TIME[n] = rawdata[n][0];
230  }
231  for(int n=32; n<60; n++){
232  TIME[n] = rawdata[n-32][1];
233  }
234  for(int n=0; n<16; n++){
235  LG[n] = rawdata[n][2];
236  }
237  for(int n=16; n<32; n++){
238  LG[n] = rawdata[n-16][3];
239  }
240  for(int n=32; n<48; n++){
241  LG[n] = rawdata[n-32][4];
242  }
243  for(int n=48; n<60; n++){
244  LG[n] = rawdata[n-48][5];
245  }
246  for(int n=0; n<16; n++){
247  TAGGER[n] = rawdata[n][6];
248  }
249 
250  TIME[ central ] = rawdata[28][1]; // correct position for Proto60 Mainz
251  LG[ central ] = rawdata[12][5]; // correct position for Proto60 Mainz
252  TP = rawdata[31][1];
253  MU = rawdata[30][1];
254  VETO = rawdata[29][1];
255 
256 }
int n
unsigned int rawdata[32][16]
void ReadMainzProto60v4::GetADCValues ( Double_t ADCs)
virtual

Implements ReadMainzProto60.

Definition at line 34 of file ReadMainzProto60v4.cxx.

References LG, and n.

34  {
35  for(int n=0; n<60;n++){
36  ADCs[n]=LG[n];
37  }
38 }
int n
void ReadMainzProto60v4::GetEnergies ( Double_t energies)
virtual

Implements ReadMainzProto60.

Definition at line 22 of file ReadMainzProto60v4.cxx.

References LG_CAL, and n.

22  {
23  for(int n=0;n<60;n++){
24  energies[n]=LG_CAL[n];
25  }
26 }
int n
Long_t ReadMainzProto60v4::GetNumberOfEvents ( )
virtual

Implements ReadMainzProto60.

Definition at line 200 of file ReadMainzProto60v4.cxx.

References NumberOfEvents, ReadNextEvent(), and Reset().

200  {
201  Long_t RetVal = 0;
202  Reset();
203  while(ReadNextEvent()!=-1);
204  RetVal = NumberOfEvents;
205  Reset();
206  return RetVal;
207 }
void ReadMainzProto60v4::GetTaggerEnergies ( Double_t taggerEnergies)
virtual

Implements ReadMainzProto60.

Definition at line 45 of file ReadMainzProto60v4.cxx.

Referenced by PrintEvent().

45  {
46  taggerEnergies[0]=1441.06;
47  taggerEnergies[1]=1356.89;
48  taggerEnergies[2]=1257.31;
49  taggerEnergies[3]=1156.56;
50  taggerEnergies[4]=1057.70;
51  taggerEnergies[5]=956.16;
52  taggerEnergies[6]=857.98;
53  taggerEnergies[7]=756.58;
54  taggerEnergies[8]=657.34;
55  taggerEnergies[9]=556.97;
56  taggerEnergies[10]=456.26;
57  taggerEnergies[11]=355.88;
58  taggerEnergies[12]=256.41;
59  taggerEnergies[13]=158.31;
60  taggerEnergies[14]=0.0;
61  taggerEnergies[15]=187.99;
62 
63 }
void ReadMainzProto60v4::GetTaggerTimes ( Double_t taggertimes)
virtual

Implements ReadMainzProto60.

Definition at line 39 of file ReadMainzProto60v4.cxx.

References n, and TAGGER_CAL.

39  {
40  for(int n = 0; n<16;n++){
41  taggertimes[n]=TAGGER_CAL[n];
42  }
43 }
int n
void ReadMainzProto60v4::GetTimes ( Double_t times)
virtual

Implements ReadMainzProto60.

Definition at line 28 of file ReadMainzProto60v4.cxx.

References n, and TIME.

28  {
29  for(int n=0;n<60;n++){
30  times[n]=TIME[n];
31  }
32 }
int n
void ReadMainzProto60v4::PrintEvent ( )
virtual

Implements ReadMainzProto60.

Definition at line 108 of file ReadMainzProto60v4.cxx.

References col, Double_t, GetTaggerEnergies(), LG, LG_CAL, NumberOfEvents, printf(), row, TAGGER_CAL, and TIME_CAL.

108  {
109  printf("Printing Event Number %li\n",NumberOfEvents);
110  printf("ADCValues:\n");
111  for(Int_t row=0;row<6;row++){
112  for(Int_t col=0;col<10;col++){
113  printf("% 8.3f ",LG[row*10+col]);
114  }
115  printf("\n");
116  }
117 
118  printf("Energies:\n");
119  for(Int_t row=0;row<6;row++){
120  for(Int_t col=0;col<10;col++){
121  printf("% 8.3f ",LG_CAL[row*10+col]);
122  }
123  printf("\n");
124  }
125  printf("Times:\n");
126  for(Int_t row=0;row<6;row++){
127  for(Int_t col=0;col<10;col++){
128  printf("% 8.3f ",TIME_CAL[row*10+col]);
129  }
130  printf("\n");
131  }
132 
133  printf("TaggerTimes:\n");
134  for(Int_t row=0;row<2;row++){
135  for(Int_t col=0;col<8;col++){
136  printf("% 8.3f ",TAGGER_CAL[row*8+col]);
137  }
138  printf("\n");
139  }
140  printf("TaggerEnergies:\n");
141  Double_t tagger_energies[16];
142  GetTaggerEnergies(tagger_energies);
143  for(Int_t row=0;row<2;row++){
144  for(Int_t col=0;col<8;col++){
145  printf("% 8.3f ",tagger_energies[row*8+col]);
146  }
147  printf("\n");
148  }
149 
150 }
int row
Definition: anaLmdDigi.C:67
printf("RealTime=%f seconds, CpuTime=%f seconds\n", rtime, ctime)
int col
Definition: anaLmdDigi.C:67
Double_t
void GetTaggerEnergies(Double_t *taggerEnergies)
void ReadMainzProto60v4::read_energy_factor ( const char *  filename)
private

Definition at line 65 of file ReadMainzProto60v4.cxx.

References exit(), i, lg_factor, lg_ped, n, and printf().

Referenced by ReadMainzProto60v4().

65  {
66  FILE * fin;
67 // char infilename[100];
68  char instr[100];
69  int ch;
70  double ped, sigped, thr, mu, gmev, fr_mev, thr_mev;
71 
72 // sprintf(infilename, "%s.thr_mev", filename);
73  printf("filename read in: %s\n", filename);
74 
75  fin = fopen(filename, "rt");
76  if(fin==NULL){
77  printf("No file \"%s\" found!\n", filename);
78  for(int n=0; n<60; n++){
79  lg_factor[n]=lg_ped[n]=0;
80  }
81  }
82  else{
83  fgets(instr, 100, fin); // root filename
84  printf("filename read in: %s\n", instr);
85  fgets(instr, 100, fin); // Ch Ped Sigped Thr Mu GMeV FR_MeV Thr_MeV
86  printf("header read in: %s\n", instr);
87  for(int i = 0; i < 60; i++){
88  fgets(instr, 100, fin); // values
89  if(strlen(instr)<2) fgets(instr, 100, fin); // empty line
90 
91  sscanf(instr, "%i%lf%lf%lf%lf%lf%lf%lf",
92  &ch, &ped, &sigped, &thr, &mu, &gmev, &fr_mev, &thr_mev);
93  printf("line %i: %s -> ch: %i, factor: %f, ped: %f\n",
94  i, instr, ch, gmev, ped);
95  if(i+1==ch){
96  lg_factor[i]=gmev;
97  lg_ped[i]=ped;
98  }
99  else{
100  printf("Wrong channel in %s detected!\n", filename);
101  exit(0);
102  }
103  }
104  }
105 }
printf("RealTime=%f seconds, CpuTime=%f seconds\n", rtime, ctime)
Int_t i
Definition: run_full.C:25
exit(0)
int n
const string filename
unsigned int ReadMainzProto60v4::read_one_event ( )
private

Definition at line 258 of file ReadMainzProto60v4.cxx.

References geo_to_bnr, geos, in, n, no_of_boards, noe_of_board, printf(), rawdata, ResetToFirstEvent, versionsstr, and what.

Referenced by ReadNextEvent().

258  {
259  static unsigned int dataword=0xffffffff; // current data word
260  static unsigned int events=0; // event counter
261  static unsigned int no_of_ev=0; // number of words in file
262  static char ververgl[100];
263 
264  // unsigned int rv; // return value
265  int wie_oft=200000; // how often status report
266  unsigned int dec_geo, dec_tow, dec_noch, dec_data, dec_ch; // decoded event informations
267  int n; // counting variables
268  int board_no;
269 
270  memset(noe_of_board, 0, sizeof(noe_of_board)); //
271  memset(rawdata, 0, sizeof(rawdata)); //
272 
273 
274  if(dataword==0xffffffff || ResetToFirstEvent){ // init readout
275  ResetToFirstEvent=kFALSE;
276  events=0;
277  fseek(in, 0, 2); //setze Zeiger auf Ende der Datei
278  no_of_ev=ftell(in)/4; // Dateilaenge/4 pro header, data word, trail
279  fseek(in, 0, 0); //setze Zeiger auf Anfang der Datei
280 
281  n=0;
282  do{
283  fread(&ververgl[n], 1, 1, in);
284  n++;
285  }while(ververgl[n-1]!=0);
286 
287  printf("The version of the readout was: %s (expected: %s)\n\n",
288  ververgl, versionsstr);
289  fread(&no_of_boards, sizeof(no_of_boards), 1, in);
290  printf("%i boards were read out.\n", no_of_boards);
291  fread(what, sizeof(what), 1, in);
292  fread(geos, sizeof(geos), 1, in);
293  for(n=0; n<no_of_boards; n++){
294  printf("Board no %i is a %i\n", n, what[n]);
295  geo_to_bnr[ geos[n] ]=n;
296  }
297 
298  }
299  for(board_no=0; board_no< no_of_boards; board_no++){
300  if(what[board_no]<80){
301  /* Header **********************/
302  if(0==fread((char*) &dataword, sizeof(dataword), 1, in)) return(0);
303  events++; if(events%wie_oft==0) printf("%i of %i read in (%3.0f%%)\n", events, no_of_ev, ((double) events)*100/ ((double)no_of_ev));
304  dec_tow=((dataword>>24) & 0x7); // decode type of dataword
305  if(dec_tow!=2){ // not a header
306  // do{
307  printf("H");
308  // fread((char*) &dataword, sizeof(dataword), 1, in);
309  // events++; if(events%wie_oft==0) printf("%i von %i read in (%3.0f%%)\n", events, no_of_[1]ev, ((double) events)*100/ ((double)no_of_ev));
310  // dec_tow=((dataword>>24) & 0x7);
311  // }while(dec_tow!=2); // repeat until first header
312  }
313  dec_geo = (dataword>>27); // decode board number
314  dec_noch = ((dataword>>8) & 0x3f); // decode no of events in board
315  /* Header **********************/
316 
317  /* Data Words **********************/
318  for(n=0; n< (int) dec_noch; n++){
319  if(0==fread((char*) &dataword, sizeof(dataword), 1, in)) return(0);
320  events++; if(events%wie_oft==0) printf("%i von %i read in (%3.0f%%)\n", events, no_of_ev, ((double) events)*100/ ((double)no_of_ev));
321  dec_tow=((dataword>>24) & 0x7); // decode type of dataword
322  dec_data = (dataword & 0xfff); // decode actual data
323  if((what[board_no]%10)==1){ // ch on board max 32
324  dec_ch =((dataword>>16) & 0x3f); // decode channel number
325  }
326  else if((what[board_no]%10)==0){ //ch on board max 16, N version of board
327  dec_ch =((dataword>>17) & 0x1f); // decode dataword
328  }
329  else printf("ERROR in WHAT!!!\n\n\n");
330  if(dec_tow==0 && (dec_geo==(dataword>>27))){ // tow and geo is ok
331  // rawdata[dec_ch][ geo_to_bnr[dec_geo] ] = dec_data;
332  if(what[board_no]==30 || what[board_no]==31) // tdc
333  if(((dataword>>14)&0x1)==0) dec_data=0; // valid data?
334  rawdata[dec_ch][ board_no ] = dec_data;
335  }
336  else printf("D");
337  }
338  /* Data Words **********************/
339 
340  /* Trail **********************/
341  if(0==fread((char*) &dataword, sizeof(dataword), 1, in)) return(0);
342  events++; if(events%wie_oft==0) printf("%i of %i read in (%3.0f%%)\n", events, no_of_ev, ((double) events)*100/ ((double)no_of_ev));
343  dec_tow=((dataword>>24) & 0x7); // decode type of word
344  if(dec_tow!=4) printf("T"); //if it wasn't trail
345  noe_of_board[geo_to_bnr[dec_geo] ] =((dataword) & 0xffffff); //
346 
347  /* Trail **********************/
348 
349  }
350  else if(what[board_no]==90){
351  for(n=0;n<7; n++){ // header, counter 1-4, direct data in, trail
352  if(0==fread((char*) &dataword, sizeof(dataword), 1, in)) return(0);
353  events++; if(events%wie_oft==0) printf("%i of %i read in (%3.0f%%)\n", events, no_of_ev, ((double) events)*100/ ((double)no_of_ev));
354  rawdata[n][ board_no ] = dec_data;
355  }
356  }
357  }
358  // rv=events; // of there is more data, return number of read in events
359  return 1;
360 } //read_one_event
printf("RealTime=%f seconds, CpuTime=%f seconds\n", rtime, ctime)
int n
unsigned int noe_of_board[16]
unsigned int geo_to_bnr[32]
unsigned int rawdata[32][16]
Long_t ReadMainzProto60v4::ReadNextEvent ( )
virtual

Implements ReadMainzProto60.

Definition at line 189 of file ReadMainzProto60v4.cxx.

References calibrate_60(), convert_60(), NumberOfEvents, and read_one_event().

Referenced by GetNumberOfEvents().

189  {
190  if(read_one_event()!=0){
191  NumberOfEvents++;
192  convert_60();
193  calibrate_60();
194  return NumberOfEvents;
195  } else {
196  return -1;
197  }
198 }
unsigned int read_one_event()
void ReadMainzProto60v4::Reset ( )
virtual

Implements ReadMainzProto60.

Definition at line 209 of file ReadMainzProto60v4.cxx.

References NumberOfEvents, and ResetToFirstEvent.

Referenced by GetNumberOfEvents().

209  {
210  NumberOfEvents = 0;
211  ResetToFirstEvent = kTRUE;
212 }

Member Data Documentation

int ReadMainzProto60v4::BINS
private

Definition at line 62 of file ReadMainzProto60v4.h.

Referenced by ReadMainzProto60v4().

int ReadMainzProto60v4::CAL_BINS
private

Definition at line 63 of file ReadMainzProto60v4.h.

Referenced by ReadMainzProto60v4().

int ReadMainzProto60v4::CAL_RANGE
private

Definition at line 63 of file ReadMainzProto60v4.h.

Referenced by ReadMainzProto60v4().

int ReadMainzProto60v4::central
private

Definition at line 64 of file ReadMainzProto60v4.h.

Referenced by convert_60(), and ReadMainzProto60v4().

double ReadMainzProto60v4::ctime_factor
private

Definition at line 68 of file ReadMainzProto60v4.h.

Referenced by calibrate_60(), and ReadMainzProto60v4().

unsigned int ReadMainzProto60v4::geo_to_bnr[32]
private

Definition at line 59 of file ReadMainzProto60v4.h.

Referenced by read_one_event().

int ReadMainzProto60v4::geos[16]
private

Definition at line 58 of file ReadMainzProto60v4.h.

Referenced by read_one_event().

FILE* ReadMainzProto60v4::in
private

Definition at line 34 of file ReadMainzProto60v4.h.

Referenced by read_one_event(), ReadMainzProto60v4(), and ~ReadMainzProto60v4().

Bool_t ReadMainzProto60v4::IsInit
private

Definition at line 69 of file ReadMainzProto60v4.h.

Referenced by ReadMainzProto60v4().

double ReadMainzProto60v4::LG[60]
private

Definition at line 42 of file ReadMainzProto60v4.h.

Referenced by calibrate_60(), convert_60(), GetADCValues(), and PrintEvent().

double ReadMainzProto60v4::LG_CAL[60]
private

Definition at line 49 of file ReadMainzProto60v4.h.

Referenced by calibrate_60(), GetEnergies(), and PrintEvent().

double ReadMainzProto60v4::lg_factor[60]
private

Definition at line 66 of file ReadMainzProto60v4.h.

Referenced by calibrate_60(), and read_energy_factor().

double ReadMainzProto60v4::lg_ped[60]
private

Definition at line 67 of file ReadMainzProto60v4.h.

Referenced by calibrate_60(), and read_energy_factor().

double ReadMainzProto60v4::MU
private

Definition at line 46 of file ReadMainzProto60v4.h.

Referenced by calibrate_60(), and convert_60().

double ReadMainzProto60v4::MU_CAL
private

Definition at line 53 of file ReadMainzProto60v4.h.

Referenced by calibrate_60().

int ReadMainzProto60v4::no_of_boards
private

Definition at line 58 of file ReadMainzProto60v4.h.

Referenced by read_one_event().

unsigned int ReadMainzProto60v4::noe_of_board[16]
private

Definition at line 57 of file ReadMainzProto60v4.h.

Referenced by read_one_event().

Long_t ReadMainzProto60v4::NumberOfEvents
private
int ReadMainzProto60v4::RANGE
private

Definition at line 62 of file ReadMainzProto60v4.h.

Referenced by ReadMainzProto60v4().

unsigned int ReadMainzProto60v4::rawdata[32][16]
private

Definition at line 56 of file ReadMainzProto60v4.h.

Referenced by convert_60(), and read_one_event().

Bool_t ReadMainzProto60v4::ResetToFirstEvent
private

Definition at line 36 of file ReadMainzProto60v4.h.

Referenced by read_one_event(), ReadMainzProto60v4(), and Reset().

double ReadMainzProto60v4::TAGGER[16]
private

Definition at line 44 of file ReadMainzProto60v4.h.

Referenced by calibrate_60(), and convert_60().

double ReadMainzProto60v4::TAGGER_CAL[16]
private

Definition at line 51 of file ReadMainzProto60v4.h.

Referenced by calibrate_60(), GetTaggerTimes(), and PrintEvent().

double ReadMainzProto60v4::TIME[60]
private

Definition at line 43 of file ReadMainzProto60v4.h.

Referenced by calibrate_60(), convert_60(), and GetTimes().

double ReadMainzProto60v4::TIME_CAL[60]
private

Definition at line 50 of file ReadMainzProto60v4.h.

Referenced by calibrate_60(), and PrintEvent().

double ReadMainzProto60v4::TP
private

Definition at line 45 of file ReadMainzProto60v4.h.

Referenced by calibrate_60(), and convert_60().

double ReadMainzProto60v4::TP_CAL
private

Definition at line 52 of file ReadMainzProto60v4.h.

Referenced by calibrate_60().

char ReadMainzProto60v4::versionsstr[15]
private

Definition at line 60 of file ReadMainzProto60v4.h.

Referenced by read_one_event(), and ReadMainzProto60v4().

double ReadMainzProto60v4::VETO
private

Definition at line 47 of file ReadMainzProto60v4.h.

Referenced by calibrate_60(), and convert_60().

double ReadMainzProto60v4::VETO_CAL
private

Definition at line 54 of file ReadMainzProto60v4.h.

Referenced by calibrate_60().

int ReadMainzProto60v4::what[16]
private

Definition at line 58 of file ReadMainzProto60v4.h.

Referenced by read_one_event().


The documentation for this class was generated from the following files: