Cat
StorageFifoAcquisition.cpp
Go to the documentation of this file.
1 // $Id: $
2 
3 // include files
4 
5 // local
6 #include "Proto40MHz_v1.h"
7 #include "A3PE.h"
8 #include "RAM.h"
10 
11 //-----------------------------------------------------------------------------
12 // Implementation file for class : StorageFifoAcquisition
13 //
14 // 2006-10-23 :²
15 //-----------------------------------------------------------------------------
16 
17 //=============================================================================
18 // Standard constructor, initializes variables
19 //=============================================================================
21  m_channels(0xFF),
22  m_nbins(100),
23  m_minRange(0.),
24  m_maxRange(4095),
25  m_depth(5)
26 {
27  setName ( "StorageFifoAcquisition" );
28  setType ( "Proto40MHz_v1" );
29  setTitle( "Proto40MHz_v1 Storage Fifo" );
30 }
31 //=============================================================================
32 // Destructor
33 //=============================================================================
35 
36 //=============================================================================
37 
38 //=========================================================================
39 //
40 //=========================================================================
42  debug("StorageFifoAcquisition" , "initialize");
43 
44  info("" );
45  info("____________________________");
46  info("Proto 40 MHZ - Storage FIFO Acquisition");
47  info(" =>" + element()->path() + " " +
48  element()->name() + " " + element()->type() );
49 
50  m_board=dynamic_cast<Proto40MHz_v1*>( element() );
51 
52  if (!m_board){
53  warning("StorageFifoAcquisition","No Proto40MHz_v1 board found. Interrupt." );
54  return false;
55  }
56 
57  for (int i=0; i<8; ++i){
58  for (unsigned int d=0; d<m_depthmax; ++d){
59  m_h[m_depthmax*i+d]=0;
60  }
61  }
62 
63  m_pga=m_board->a3pe();
67  m_fifo = m_pga->storageRam();
68 
69  for (int i=0; i<8; ++i) m_pga->setEnableADC(i,true);
70 
71  int channel=m_channels;
72  char name[100], title[100];
73  for (int i=0; i<8; ++i){
74  if ((channel>>i)&1==1){
75  for (unsigned int d=0; d<m_depth; ++d){
76  sprintf(name,"Ch_%i_%i",i,d);
77  sprintf(title,"Ch %i - %i",i,d);
78  m_h[m_depth*i+d]=new TH1D(name, title , m_nbins , m_minRange, m_maxRange);
79  addHisto1d(m_h[m_depth*i+d]);
80  }
81  sprintf(name,"Ch_%i_sigma",i);
82  sprintf(title,"Ch %i Sigma",i);
83  m_sh[i]=new TH1D(name, title, m_depth , 0., m_depth);
84  addHisto1d(m_sh[i]);
85  sprintf(name,"Ch_%i_average",i);
86  sprintf(title,"Ch %i Average",i);
87  m_ah[i]=new TH1D(name, title, m_depth , 0., m_depth);
88  addHisto1d(m_ah[i]);
89  }
90  }
91  return StatusCode::SUCCESS;
92 }
93 
94 
95 //=========================================================================
96 //
97 //=========================================================================
99  debug("StorageFifoAcquisition" , "execute");
100 
101  m_pga->acquisition();
102  m_fifo->read();
103 
104  int channel=m_channels;
105 
106  int val[12], data[12];
107  for (unsigned int d=0; d<m_depth; ++d){
108  // d+=0.5;
109  val[0] =m_fifo->io()->dataU8( 0+12*d);
110  val[1] =m_fifo->io()->dataU8( 1+12*d);
111  val[2] =m_fifo->io()->dataU8( 2+12*d);
112  val[3] =m_fifo->io()->dataU8( 3+12*d);
113  val[4] =m_fifo->io()->dataU8( 4+12*d);
114  val[5] =m_fifo->io()->dataU8( 5+12*d);
115  val[6] =m_fifo->io()->dataU8( 6+12*d);
116  val[7] =m_fifo->io()->dataU8( 7+12*d);
117  val[8] =m_fifo->io()->dataU8( 8+12*d);
118  val[9] =m_fifo->io()->dataU8( 9+12*d);
119  val[10]=m_fifo->io()->dataU8(10+12*d);
120  val[11]=m_fifo->io()->dataU8(11+12*d);
121  data[0]=val[0]+((val[1]&0xf)<<8);
122  data[1]=(val[1]>>4)+(val[2]<<4);
123  data[2]=val[3]+((val[4]&0xf)<<8);
124  data[3]=(val[4]>>4)+(val[5]<<4);
125  data[4]=val[6]+((val[7]&0xf)<<8);
126  data[5]=(val[7]>>4)+(val[8]<<4);
127  data[6]=val[9]+((val[10]&0xf)<<8);
128  data[7]=(val[10]>>4)+(val[11]<<4);
129  for (int i=0; i<8; ++i){
130  if ((channel>>i)&1==1){
131  m_h[m_depth*i+d]->Fill(data[i]);
132  }
133  }
134  }
135  return StatusCode::SUCCESS;
136 }
137 
138 //=========================================================================
139 //
140 //=========================================================================
142  int channel=m_channels;
143  for (int i=0; i<8; ++i){
144  if ((channel>>i)&1==1){
145  for (unsigned int d=0; d<m_depth; ++d){
146  m_ah[i]->Fill(i,m_h[m_depth*i+d]->GetMean());
147  m_sh[i]->Fill(i,m_h[m_depth*i+d]->GetRMS());
148  }
149  }
150  }
151  return StatusCode::SUCCESS;
152 }
153 
154 //=========================================================================
155 //
156 //=========================================================================
158  if (depth>512){
159  warning("Cannot acquire more than 512 consecutive events. Interrupt.");
160  return StatusCode::FAILURE;
161  }
162  m_depth=depth;
163  return StatusCode::SUCCESS;
164 }
165 
166 //=========================================================================
167 //
168 //=========================================================================
170  if (channels>0xFF){
171  channels=(channels&0xFF);
172  warning("Channels coding not appropriate. Truncated at 0xFF.");
173  }
175  return StatusCode::SUCCESS;
176 }
void info(std::string mymsg)
Definition: Object.h:38
virtual StatusCode execute()
static const unsigned int m_depthmax
StatusCode setSoftwareTrigger(bool)
Definition: A3PE.cpp:368
std::string title()
Definition: Object.h:31
void setName(std::string name)
Definition: Object.h:51
StatusCode setFifoDepth(unsigned int)
Definition: A3PE.cpp:612
StatusCode setDepth(unsigned int)
A3PE * a3pe()
Definition: Proto40MHz_v1.h:74
RAM * storageRam()
Definition: A3PE.h:536
virtual StatusCode read()
Definition: IOobject.h:73
void setType(std::string type)
Definition: Object.h:52
TH1D * m_h[8 *m_depthmax]
void debug(std::string mymsg)
Definition: Object.h:37
void setTitle(std::string title)
Definition: Object.h:54
virtual StatusCode initialize()
U8 * dataU8()
Definition: IOdata.h:214
std::string name() const
Definition: Object.h:28
StorageFifoAcquisition()
Standard constructor.
void addHisto1d(TH1D *h)
Definition: Processus.h:160
virtual ~StorageFifoAcquisition()
Destructor.
Element * element()
Definition: Processus.h:231
StatusCode setWriteStorageFifoUsb(bool)
Definition: A3PE.cpp:99
StatusCode acquisition()
Definition: A3PE.cpp:417
std::string type()
Definition: Object.h:29
void warning(std::string mymsg)
Definition: Object.h:39
StatusCode setEnableADC(unsigned int, bool)
Definition: A3PE.cpp:87
StatusCode setChannels(unsigned int)
Data * data()
Definition: Processus.h:114
IOdata * io()
Definition: IOobject.h:66