Hall-D Software  alpha
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
JEventProcessor_TAGGER_online.cc
Go to the documentation of this file.
1 // $Id$
2 //
3 // File: JEventProcessor_TAGGER_online.cc
4 // Created: Thu Feb 18 07:45:18 EST 2016
5 // Creator: jrsteven (on Linux gluon110.jlab.org 2.6.32-358.23.2.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 extern "C"{
16 void InitPlugin(JApplication *app){
17  InitJANAPlugin(app);
18  app->AddProcessor(new JEventProcessor_TAGGER_online());
19 }
20 } // "C"
21 
22 
23 //------------------
24 // JEventProcessor_TAGGER_online (Constructor)
25 //------------------
27 {
28 
29 }
30 
31 //------------------
32 // ~JEventProcessor_TAGGER_online (Destructor)
33 //------------------
35 {
36 
37 }
38 
39 //------------------
40 // init
41 //------------------
43 {
44  gDirectory->Cd("/");
45  new TDirectoryFile("TAGGER", "TAGGER");
46  gDirectory->cd("TAGGER");
47 
48  dTAGMPulsePeak_Column = new TH2D("TAGMPulsePeak_Column", "TAGM pulse peak vs column", 102, 0., 102., 200, 0., 2000.);
49  dTAGMIntegral_Column = new TH2D("TAGMIntegral_Column", "TAGM pulse integral vs column", 102, 0., 102., 100, 0., 4000.);
50  dTaggerEnergy_DeltaTSC = new TH2D("TaggerEnergy_DeltaTSC", "Tagger Energy vs. #Delta t (TAG-SC); #Delta t (TAG-SC); Tagger Energy", 200, -100, 100, 240, 0., 12.);
51 
52  gDirectory->cd("..");
53 
54  return NOERROR;
55 }
56 
57 //------------------
58 // brun
59 //------------------
60 jerror_t JEventProcessor_TAGGER_online::brun(JEventLoop *eventLoop, int32_t runnumber)
61 {
62  // This is called whenever the run number changes
63  return NOERROR;
64 }
65 
66 //------------------
67 // evnt
68 //------------------
69 jerror_t JEventProcessor_TAGGER_online::evnt(JEventLoop *loop, uint64_t eventnumber)
70 {
71  vector<const DBeamPhoton*> locBeamPhotons;
72  loop->Get(locBeamPhotons);
73 
74  vector<const DSCHit*> locSCHits;
75  loop->Get(locSCHits);
76 
77  for(size_t loc_i = 0; loc_i < locBeamPhotons.size(); loc_i++) {
78  const DTAGMHit* locTAGMHit;
79  locBeamPhotons[loc_i]->GetSingle(locTAGMHit);
80  if(locTAGMHit != NULL) {
81  // FILL HISTOGRAMS
82  // Since we are filling histograms local to this plugin, it will not interfere with other ROOT operations: can use plugin-wide ROOT fill lock
83  japp->RootFillLock(this); //ACQUIRE ROOT FILL LOCK
84  dTAGMPulsePeak_Column->Fill(locTAGMHit->column, locTAGMHit->pulse_peak);
85  dTAGMIntegral_Column->Fill(locTAGMHit->column, locTAGMHit->integral);
86  japp->RootFillUnLock(this); //RELEASE ROOT FILL LOCK
87 
88  // add threshold on TAGM hits
89  if(locTAGMHit->integral < 500.) continue;
90  }
91 
92  for(size_t loc_j = 0; loc_j < locSCHits.size(); loc_j++) {
93  Double_t locDeltaT = locBeamPhotons[loc_i]->time() - locSCHits[loc_j]->t;
94  // FILL HISTOGRAMS
95  // Since we are filling histograms local to this plugin, it will not interfere with other ROOT operations: can use plugin-wide ROOT fill lock
96  japp->RootFillLock(this); //ACQUIRE ROOT FILL LOCK
97  dTaggerEnergy_DeltaTSC->Fill(locDeltaT, locBeamPhotons[loc_i]->momentum().Mag());
98  japp->RootFillUnLock(this); //RELEASE ROOT FILL LOCK
99 
100  }
101  }
102 
103  return NOERROR;
104 }
105 
106 //------------------
107 // erun
108 //------------------
110 {
111  // This is called whenever the run number changes, before it is
112  // changed to give you a chance to clean up before processing
113  // events from the next run number.
114  return NOERROR;
115 }
116 
117 //------------------
118 // fini
119 //------------------
121 {
122  // Called before program exit after event processing is finished.
123  return NOERROR;
124 }
125 
JApplication * japp
InitPlugin_t InitPlugin
jerror_t evnt(jana::JEventLoop *eventLoop, uint64_t eventnumber)
Called every event.
double pulse_peak
Definition: DTAGMHit.h:23
double integral
Definition: DTAGMHit.h:22
jerror_t fini(void)
Called after last event of last event source has been processed.
jerror_t brun(jana::JEventLoop *eventLoop, int32_t runnumber)
Called everytime a new run number is detected.
jerror_t erun(void)
Called everytime run number changes, provided brun has been called.
jerror_t init(void)
Called once at program start.
int column
Definition: DTAGMHit.h:21