Hall-D Software  alpha
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
JEventProcessor_EventTagPi0.cc
Go to the documentation of this file.
1 // $Id$
2 //
3 // File: JEventProcessor_EventTagPi0.cc
4 // Created: Fri Feb 5 23:23:22 EST 2016
5 // Creator: davidl (on Darwin harriet 13.4.0 i386)
6 //
7 
9 using namespace jana;
10 
11 #include <DANA/DStatusBits.h>
12 #include <FCAL/DFCALHit.h>
13 
14 // Routine used to create our JEventProcessor
15 #include <JANA/JApplication.h>
16 #include <JANA/JFactory.h>
17 extern "C"{
18 void InitPlugin(JApplication *app){
19  InitJANAPlugin(app);
20  app->AddProcessor(new JEventProcessor_EventTagPi0());
21 }
22 } // "C"
23 
24 
25 //------------------
26 // JEventProcessor_EventTagPi0 (Constructor)
27 //------------------
29 {
30 
31 }
32 
33 //------------------
34 // ~JEventProcessor_EventTagPi0 (Destructor)
35 //------------------
37 {
38 
39 }
40 
41 //------------------
42 // init
43 //------------------
45 {
46  Emin_MeV = 200.0;
47  Rmin_cm = 30.0;
48 
49  gPARMS->SetDefaultParameter("PI0TAG:Emin_MeV", Emin_MeV , "Minimum energy in MeV of each single block hit to tag event as FCAL pi0");
50  gPARMS->SetDefaultParameter("PI0TAG:Rmin_cm" , Rmin_cm , "Minimum distance in cm between single blocks with energy > PI0TAG:Emin_MeV to tag event as FCAL pi0");
51 
52  Rmin_cm_2 = Rmin_cm*Rmin_cm;
53 
54  return NOERROR;
55 }
56 
57 //------------------
58 // brun
59 //------------------
60 jerror_t JEventProcessor_EventTagPi0::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_EventTagPi0::evnt(JEventLoop *loop, uint64_t eventnumber)
70 {
71  vector<const DFCALHit*> fcalhits;
72  loop->Get(fcalhits);
73 
74  if(fcalhits.size() < 2) return NOERROR;
75 
76  for(uint32_t i=0; i<(fcalhits.size()-1); i++){
77  const DFCALHit *hit1 = fcalhits[i];
78  if( hit1->E < Emin_MeV ) continue;
79 
80  for(uint32_t j=i+1; j<fcalhits.size(); j++){
81  const DFCALHit *hit2 = fcalhits[j];
82  if( hit2->E < Emin_MeV ) continue;
83 
84  double deltaX = hit1->x - hit2->x;
85  double deltaY = hit1->y - hit2->y;
86  double r2 = deltaX*deltaX + deltaY*deltaY;
87  if( r2 <= Rmin_cm_2 ){
88  JEvent &jevent = loop->GetJEvent();
89  jevent.SetStatusBit(kSTATUS_FCAL_PI0);
90  jevent.SetStatusBit(kSTATUS_PI0);
91  return NOERROR;
92  }
93  }
94  }
95 
96  return NOERROR;
97 }
98 
99 //------------------
100 // erun
101 //------------------
103 {
104  return NOERROR;
105 }
106 
107 //------------------
108 // fini
109 //------------------
111 {
112  // Called before program exit after event processing is finished.
113  return NOERROR;
114 }
115 
jerror_t brun(jana::JEventLoop *eventLoop, int32_t runnumber)
Called everytime a new run number is detected.
jerror_t evnt(jana::JEventLoop *eventLoop, uint64_t eventnumber)
Called every event.
jerror_t init(void)
Called once at program start.
InitPlugin_t InitPlugin
float y
Definition: DFCALHit.h:26
jerror_t fini(void)
Called after last event of last event source has been processed.
float x
Definition: DFCALHit.h:25
float E
Definition: DFCALHit.h:27
jerror_t erun(void)
Called everytime run number changes, provided brun has been called.