// $Id$ // // File: JEventProcessor_diphoton.cc // Created: Sun Nov 23 11:01:46 EST 2014 // Creator: hdcdcops (on Linux gluon47.jlab.org 2.6.32-358.23.2.el6.x86_64 x86_64) // #include "JEventProcessor_diphoton.h" using namespace jana; // Routine used to create our JEventProcessor #include #include extern "C"{ void InitPlugin(JApplication *app){ InitJANAPlugin(app); app->AddProcessor(new JEventProcessor_diphoton()); } } // "C" //------------------ // JEventProcessor_diphoton (Constructor) //------------------ JEventProcessor_diphoton::JEventProcessor_diphoton() { } //------------------ // ~JEventProcessor_diphoton (Destructor) //------------------ JEventProcessor_diphoton::~JEventProcessor_diphoton() { } //------------------ // init //------------------ jerror_t JEventProcessor_diphoton::init(void) { // This is called once at program startup. If you are creating // and filling historgrams in this plugin, you should lock the // ROOT mutex like this: // // japp->RootWriteLock(); // ... fill historgrams or trees ... // japp->RootUnLock(); // if(gDirectory->Get("InvMass") == NULL) hInvMass = new TH2I("InvMassVsnumTrackCand","Invariant Mass vs track cand; track candidates; diphoton inv mass",11,-0.5,10.5, 2000, 0, 1); if(gDirectory->Get("hInvMassVsNNeutral") == NULL) hInvMassVsNNeutral = new TH2I("InvMassVsnumNeutral","Invariant Mass vs N_Neutral; Number Of NeutralParticles; diphoton inv mass",11,-0.5,10.5, 2000, 0, 1); return NOERROR; } //------------------ // brun //------------------ jerror_t JEventProcessor_diphoton::brun(JEventLoop *eventLoop, int runnumber) { // This is called whenever the run number changes return NOERROR; } //------------------ // evnt //------------------ jerror_t JEventProcessor_diphoton::evnt(JEventLoop *loop, int eventnumber) { // This is called for every event. Use of common resources like writing // to a file or filling a histogram should be mutex protected. Using // loop->Get(...) to get reconstructed objects (and thereby activating the // reconstruction algorithm) should be done outside of any mutex lock // since multiple threads may call this method at the same time. // Here's an example: // // vector mydataclasses; // loop->Get(mydataclasses); // // japp->RootWriteLock(); // ... fill historgrams or trees ... // japp->RootUnLock(); vector neutralParticleVector; vector trackCandidates; loop->Get(neutralParticleVector); loop->Get(trackCandidates); int nBCAL = 0; for(unsigned int i = 0 ; i < neutralParticleVector.size(); i++){ if (neutralParticleVector[i]->dNeutralShower->dEnergy < 0.75) continue; if (neutralParticleVector[i]->dNeutralShower->dDetectorSystem == SYS_FCAL) nBCAL++; } for(unsigned int i = 0 ; i < neutralParticleVector.size(); i++){ if (neutralParticleVector[i]->dNeutralShower->dDetectorSystem != SYS_FCAL) continue; if (neutralParticleVector[i]->dNeutralShower->dEnergy < 0.75) continue; const DNeutralParticleHypothesis * gamma1 = neutralParticleVector[i]->Get_Hypothesis(Gamma); for(unsigned int j = i+1 ; j < neutralParticleVector.size(); j++){ if (neutralParticleVector[j]->dNeutralShower->dDetectorSystem != SYS_FCAL) continue; if (neutralParticleVector[j]->dNeutralShower->dEnergy < 0.75) continue; if (fabs((neutralParticleVector[i]->dNeutralShower->dSpacetimeVertex).T() - (neutralParticleVector[j]->dNeutralShower->dSpacetimeVertex).T()) > 5) continue; const DNeutralParticleHypothesis * gamma2 = neutralParticleVector[j]->Get_Hypothesis(Gamma); const DLorentzVector g1p4 = gamma1->lorentzMomentum(); const DLorentzVector g2p4 = gamma2->lorentzMomentum(); japp->RootWriteLock(); hInvMass->Fill( trackCandidates.size(), (g1p4 + g2p4).M() ); hInvMassVsNNeutral->Fill( nBCAL, (g1p4 + g2p4).M() ); japp->RootUnLock(); } } return NOERROR; } //------------------ // erun //------------------ jerror_t JEventProcessor_diphoton::erun(void) { // This is called whenever the run number changes, before it is // changed to give you a chance to clean up before processing // events from the next run number. return NOERROR; } //------------------ // fini //------------------ jerror_t JEventProcessor_diphoton::fini(void) { // Called before program exit after event processing is finished. return NOERROR; }