Hall-D Software  alpha
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DEventProcessor_fcal_led.cc
Go to the documentation of this file.
1 // $Id$
2 // File: DEventProcessor_fcal_led.cc
3 
4 
5 #include <map>
6 using namespace std;
7 
9 
10 #include <DANA/DApplication.h>
11 #include <FCAL/DFCALDigiHit.h>
12 
13 #include <DAQ/Df250PulseIntegral.h>
14 #include <DAQ/Df250PulseData.h>
15 #include <DAQ/Df250WindowRawData.h>
16 #include <DAQ/Df250PulsePedestal.h>
17 
18 
19 
20 
21 // Routine used to create our DEventProcessor
22 extern "C"{
23 void InitPlugin(JApplication *app){
24  InitJANAPlugin(app);
25  app->AddProcessor(new DEventProcessor_fcal_led());
26 }
27 } // "C"
28 
29 
30 //------------------
31 // init
32 //------------------
34 {
35 
36  TDirectory *dir = new TDirectoryFile("FCAL","FCAL");
37  dir->cd();
38 
39  tree1 = new TTree( "digihit", "digihit" );
40 
41  cout << " SASCHA I AM HERE " << endl;
42 
43 
44  tree1->Branch("nhit", &nhit, "nhit/I");
45  tree1->Branch("column", &column, "column[nhit]/I");
46  tree1->Branch("row", &row, "row[nhit]/I");
47  tree1->Branch("peak", &peak, "peak[nhit]/I");
48  tree1->Branch("integral", &integral, "integral[nhit]/I");
49  tree1->Branch("pedestal", &pedestal, "pedestal[nhit]/I");
50  tree1->Branch("time", &time, "time[nhit]/I");
51  tree1->Branch("qf", &qf, "qf[nhit]/I");
52 
53  tree1->Branch("waveform", &waveform, "waveform[nhit][100]/I");
54 
55  tree1->Branch("nsamples_integral", &nsamples_integral, "nsamples_integral/I");
56  tree1->Branch("nsamples_pedestal", &nsamples_pedestal, "nsamples_pedestal/I");
57 
58 
59 
60  for(Int_t ii = 0; ii < 59; ii++){
61  for(Int_t jj = 0; jj < 59; jj++){
62 
63  char title[30];
64  char title1[30];
65 
66  sprintf(title,"Waveform_%d_%d",ii, jj);
67  fcal_wave[ii][jj] = new TProfile(title,title,100,-0.5,99.5,-10.,4096);
68 
69  sprintf(title1,"Peak_%d_%d", ii, jj);
70  fcal_peak[ii][jj] = new TH1F(title1, title1, 4096, -0.5, 4095.5);
71 
72  // sprintf(title,"Int_%d_%d", ii, jj);
73  // fcal_int[ii][jj] = new TH1F(title, title, 500, 0., 20000.5);
74 
75  }
76  }
77 
78 
79  // Go back up to the parent directory
80  dir->cd("../");
81 
82 
83  return NOERROR;
84 }
85 
86 //------------------
87 // brun
88 //------------------
89 jerror_t DEventProcessor_fcal_led::brun(JEventLoop *eventLoop, int32_t runnumber)
90 {
91 
92  return NOERROR;
93 }
94 
95 //------------------
96 // evnt
97 //------------------
98 jerror_t DEventProcessor_fcal_led::evnt(JEventLoop *loop, uint64_t eventnumber)
99 {
100 
101 
102 
103  vector<const DFCALDigiHit*> fcal_digihits;
104 
105  loop->Get(fcal_digihits);
106 
107  cout << " Event number = " << eventnumber << endl;
108  cout << " Number of hits = " << fcal_digihits.size() << endl;
109 
110  nhit = 0;
111  memset(column,0,sizeof(column));
112  memset(row,0,sizeof(row));
113  memset(peak,0,sizeof(peak));
114  memset(integral,0,sizeof(integral));
115  memset(pedestal,0,sizeof(pedestal));
116  memset(time,0,sizeof(time));
117  memset(qf,0,sizeof(qf));
118  memset(waveform,0,sizeof(waveform));
119  nsamples_integral = 0;
120  nsamples_pedestal = 0;
121 
122 
123  japp->RootWriteLock();
124 
125 
126  for(unsigned int ii = 0; ii < fcal_digihits.size(); ii++){
127  const DFCALDigiHit *fcal_hit = fcal_digihits[ii];
128 
129  if(ii == 0){
130  nsamples_integral = fcal_hit->nsamples_integral;
131  nsamples_pedestal = fcal_hit->nsamples_pedestal;
132  }
133 
134  row[nhit] = fcal_hit->row;
135  column[nhit] = fcal_hit->column;
136 
137  peak[nhit] = fcal_hit->pulse_peak;
138  integral[nhit] = fcal_hit->pulse_integral;
139 
140  pedestal[nhit] = fcal_hit->pedestal;
141  time[nhit] = (fcal_hit->pulse_time & 0x7FC0) >> 6;
142  qf[nhit] = fcal_hit->QF;
143 
144 
145  // Index for histograms
146 
147 
148  // Assume that baseline is at fadc count 100
149  fcal_peak[column[nhit]][row[nhit]]->Fill(float(fcal_hit->pulse_peak) - 100.);
150  // fcal_int[column[nhit]][row[nhit]]->Fill(float(fcal_hit->pulse_integral) - 100*nsamples_integral);
151 
152 
153  const Df250WindowRawData *windorawdata;
154  const Df250PulseData *pulsedata;
155 
156  fcal_hit->GetSingle(pulsedata);
157 
158  if(pulsedata){;
159 
160  pulsedata->GetSingle(windorawdata);
161 
162  if(windorawdata){
163 
164  const vector<uint16_t> &samplesvector = windorawdata->samples;
165 
166  unsigned int nsamples = samplesvector.size();
167 
168  for(uint16_t samp = 0; samp < nsamples; samp++){
169  waveform[nhit][samp] = samplesvector[samp];
170 
171  fcal_wave[column[nhit]][row[nhit]]->Fill(float(samp),float(samplesvector[samp]));
172 
173  }
174 
175  }
176 
177  }
178 
179  if(nhit < 4000)
180  nhit++;
181  else cout << "Too many hits " << endl;
182 
183  }
184 
185 
186  if(nhit > 0){
187  tree1->Fill();
188  }
189 
190  japp->RootUnLock();
191 
192  return NOERROR;
193 }
194 
195 //------------------
196 // erun
197 //------------------
199 {
200  // Any final calculations on histograms (like dividing them)
201  // should be done here. This may get called more than once.
202  return NOERROR;
203 }
204 
205 //------------------
206 // fini
207 //------------------
209 {
210  return NOERROR;
211 }
212 
uint32_t QF
Quality Factor from FPGA algorithms.
Definition: DFCALDigiHit.h:23
uint32_t pulse_peak
maximum sample in pulse
Definition: DFCALDigiHit.h:26
uint32_t nsamples_integral
number of samples used in integral
Definition: DFCALDigiHit.h:24
sprintf(text,"Post KinFit Cut")
vector< uint16_t > samples
uint32_t pulse_time
identified pulse time as returned by FPGA algorithm
Definition: DFCALDigiHit.h:21
jerror_t evnt(JEventLoop *eventLoop, uint64_t eventnumber)
Called every event.
jerror_t init(void)
Called once at program start.
JApplication * japp
uint32_t pedestal
pedestal info used by FPGA (if any)
Definition: DFCALDigiHit.h:22
InitPlugin_t InitPlugin
jerror_t erun(void)
Called everytime run number changes, provided brun has been called.
uint32_t pulse_integral
identified pulse integral as returned by FPGA algorithm
Definition: DFCALDigiHit.h:20
uint32_t nsamples_pedestal
number of samples used in pedestal
Definition: DFCALDigiHit.h:25
jerror_t brun(JEventLoop *eventLoop, int32_t runnumber)
Called everytime a new run number is detected.
jerror_t fini(void)
Called after last event of last event source has been processed.
static TH1I * pedestal[nChan]
TDirectory * dir
Definition: bcal_hist_eff.C:31