Hall-D Software  alpha
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
JEventProcessor_FCALpulsepeak.cc
Go to the documentation of this file.
1 // $Id$
2 //
3 // File: JEventProcessor_FCALpulsepeak.cc
4 // Created: Tue Sep 27 11:18:28 EDT 2016
5 // Creator: asubedi (on Linux stanley.physics.indiana.edu 2.6.32-573.18.1.el6.x86_64 x86_64)
6 //
7 
9 using namespace jana;
10 
11 
12 // Routine used to create our JEventProcessor
13 #include <JANA/JApplication.h>
14 #include <JANA/JFactory.h>
15 #include <stdint.h>
16 #include <vector>
17 #include <iostream>
18 #include "FCAL/DFCALHit.h"
19 #include "FCAL/DFCALDigiHit.h"
20 #include "FCAL/DFCALGeometry.h"
21 #include "FCAL/DFCALCluster.h"
22 #include "FCAL/DFCALShower.h"
23 #include "DAQ/Df250PulseIntegral.h"
24 #include "DAQ/Df250PulsePedestal.h"
25 #include "DAQ/Df250PulseData.h"
26 #include "units.h"
27 #include "DLorentzVector.h"
28 #include "DVector3.h"
29 #include "HDGEOMETRY/DGeometry.h"
30 #include "DANA/DApplication.h"
31 #include "TRIGGER/DTrigger.h"
32 
33 #include <iostream>
34 #include <algorithm>
35 #include <stdio.h>
36 #include <stdlib.h>
37 #include <TDirectory.h>
38 #include <TH1I.h>
39 #include <TH2F.h>
40 #include "HistogramTools.h"
41 
42 
43 const int nChan = 2800;
44 
45 // Define Histograms
46 static TH1I* pulsepeak[nChan];
47 
48 
49 extern "C"{
50 void InitPlugin(JApplication *app){
51  InitJANAPlugin(app);
52  app->AddProcessor(new JEventProcessor_FCALpulsepeak());
53 }
54 } // "C"
55 
56 
57 //------------------
58 // JEventProcessor_FCALpulsepeak (Constructor)
59 //------------------
61 {
62 
63 }
64 
65 //------------------
66 // ~JEventProcessor_FCALpulsepeak (Destructor)
67 //------------------
69 {
70 
71 }
72 
73 //------------------
74 // init
75 //------------------
77 {
78 
79  //This is called once at program startup.
80 TDirectory *main = gDirectory;
81  gDirectory->mkdir("FCAL_pulsepeak")->cd();
82 
83 
84  for (int i = 0; i < nChan; ++i) {
85  pulsepeak[i] = new TH1I(Form("peak_%i",i),Form("Pulsepeak for Channel %i",i),500,10,-10);
86  }
87 
88  main->cd();
89 
90  return NOERROR;
91 }
92 
93 //------------------
94 // brun
95 //------------------
96 jerror_t JEventProcessor_FCALpulsepeak::brun(JEventLoop *eventLoop, int32_t runnumber)
97 {
98  // This is called whenever the run number changes
99  return NOERROR;
100 }
101 //------------------
102 // evnt
103 //------------------
104 jerror_t JEventProcessor_FCALpulsepeak::evnt(JEventLoop *eventLoop, uint64_t eventnumber)
105 {
106 
107  // select events with physics events, i.e., not LED and other front panel triggers
108  const DTrigger* locTrigger = NULL;
109  eventLoop->GetSingle(locTrigger);
110  if(locTrigger->Get_L1FrontPanelTriggerBits() != 0)
111  return NOERROR;
112 
113  vector< const DFCALDigiHit* > digiHits;
114  eventLoop->Get( digiHits );
115  vector< const DFCALGeometry* > geomVec;
116  eventLoop->Get( geomVec );
117 
118  const DFCALGeometry& fcalGeom = *(geomVec[0]);
119 
120  japp->RootFillLock(this);
121 
122  for( vector< const DFCALDigiHit* >::const_iterator dHitItr = digiHits.begin();
123  dHitItr != digiHits.end(); ++dHitItr ){
124  const DFCALDigiHit& dHit = (**dHitItr);
125  int m_chan = fcalGeom.channel( dHit.row, dHit.column );
126  //uint32_t m_time = dHit.pulse_time;
127  uint32_t m_peak = dHit.pulse_peak;
128  uint32_t m_pedestal = dHit.pedestal;
129  //uint32_t m_integral = dHit.pulse_integral;
130 
131  if (m_peak > 0 && m_pedestal > 95){
132 
133  pulsepeak[m_chan]->Fill(m_peak);
134 
135  }
136  }
137 
138  japp->RootFillUnLock(this);
139 
140 
141 
142 /*
143  vector< const DFCALGeometry* > geomVec;
144  vector< const DFCALDigiHit* > digiHits;
145  vector< const DFCALHit* > hits;
146  eventLoop->Get( geomVec );
147  eventLoop->Get( digiHits );
148  eventLoop->Get( hits );
149 
150 
151  const DFCALGeometry& fcalGeom = *(geomVec[0]);
152 
153 
154 
155  for( vector< const DFCALDigiHit* >::const_iterator dHitItr = digiHits.begin();
156  dHitItr != digiHits.end(); ++dHitItr ){
157 
158  // fetch lower level FADC data
159  const Df250PulseData* pulseDat = NULL;
160 
161  const DFCALDigiHit& dHit = (**dHitItr);
162  dHit.GetSingle( pulseDat );
163  pd_cache[&dHit] = pulseDat;
164  }
165 
166  for( vector< const DFCALDigiHit* >::const_iterator dHitItr = digiHits.begin();
167  dHitItr != digiHits.end(); ++dHitItr ){
168 
169  const DFCALDigiHit& dHit = (**dHitItr);
170 
171  const Df250PulseData* pulseDat = pd_cache[&dHit];
172 
173 
174  if( pulseDat){
175 
176  // m_x = dHit.column - 29;
177  // m_y = dHit.row - 29;
178  m_chan = fcalGeom.channel( dHit.row, dHit.column );
179  //cout << "pedestal: " << pulseDat->pedestal << " peak: " << pulseDat->pulse_peak << endl;
180 
181  m_peak = pulseDat->pulse_peak;
182 
183  japp->RootFillLock(this);
184  if (m_peak > 0){
185  // cout << "Channel: " << m_chan << " peak: " << m_peak << endl;
186  pulsepeak[m_chan]->Fill(m_peak);
187  // Fill the only important histogram
188  //Fill2DHistogram("FCALpulsepeak", "", "FCAL Pulse Peak Vs. Channel Number",
189  //m_chan, m_peak,
190  //"Pulse Peak ;Channel Number; Pulse Peak",
191  //2800,-0.5,2799.5,4000,100, 4100); // Channels are numbered from zero...AGAINST CONVENTION
192  }
193 japp->RootFillUnLock(this);
194 
195 
196  }
197  }
198 */
199 
200 
201 
202 
203 
204 
205 
206  return NOERROR;
207 }
208 
209 //------------------
210 // erun
211 //------------------
213 {
214  // This is called whenever the run number changes, before it is
215  // changed to give you a chance to clean up before processing
216  // events from the next run number.
217  return NOERROR;
218 }
219 
220 //------------------
221 // fini
222 //------------------
224 {
225  // Called before program exit after event processing is finished.
226  return NOERROR;
227 }
228 
uint32_t pulse_peak
maximum sample in pulse
Definition: DFCALDigiHit.h:26
jerror_t evnt(jana::JEventLoop *eventLoop, uint64_t eventnumber)
Called every event.
jerror_t init(void)
Called once at program start.
uint32_t Get_L1FrontPanelTriggerBits(void) const
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.
jerror_t brun(jana::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.
int channel(int row, int column) const
static TH1I * pulsepeak[nChan]
int main(int argc, char *argv[])
Definition: gendoc.cc:6