logo Use CA10RAM to get 10%* Discount.
Order Nowlogo
(5/5)

I just need help fixing the code under the example histogram so it can run

INSTRUCTIONS TO CANDIDATES
ANSWER ALL QUESTIONS

I just need help fixing the code under the example histogram so it can run

 

 // $Id$

//

//    File: DEventProcessor_search.cc

// Created: Mon Apr  3 11:38:03 EDT 2006

// Creator: davidl (on Darwin swire-b241.jlab.org 8.4.0 powerpc)

//

 

#include <map>

using namespace std;

 

#include "DEventProcessor_search.h"

 

// Routine used to create our DEventProcessor

extern "C"{

void InitPlugin(JApplication *app){

 

 

  InitJANAPlugin(app);

 

  app->AddProcessor(new DEventProcessor_search());

 

}

} // "C"

 

//------------------

// init

//------------------

jerror_t DEventProcessor_search::init(void)

{

  return NOERROR;

}

 

//------------------

// brun

//------------------

jerror_t DEventProcessor_search::brun(JEventLoop *eventLoop, int32_t runnumber)

{

  // Called for every run

  // Get the calibration for the run and extract the beam spot position

 

  DGeometry* dgeom = NULL;

 

  DApplication* dapp = dynamic_cast<DApplication*> (eventLoop->GetJApplication());

 

  if(dapp)

    dgeom = dapp->GetDGeometry(runnumber);

  if(dgeom){

    dgeom->GetTargetZ(m_targetZ);

    dgeom->GetFCALPosition( m_fcalX, m_fcalY, m_fcalZ );

    dgeom->GetCCALPosition( m_ccalX, m_ccalY, m_ccalZ );

  }else{

    cerr << "No geometry accessible." << endl;

    return RESOURCE_UNAVAILABLE;

  }

 

  //-----

  jana::JCalibration *jcalib = japp->GetJCalibration(runnumber);

 

  std::map<string, float> beam_spot;

 

  jcalib->Get("PHOTON_BEAM/beam_spot", beam_spot);

  m_beamSpotX = beam_spot.at("x");

  m_beamSpotY = beam_spot.at("y");

 

  cout << "Target Z: " << m_targetZ << endl;

  cout << "FCal Z: " << m_fcalZ << endl;

  cout << "CCal Z: " << m_ccalZ << endl;

  return NOERROR;

}

//------------------

// evnt

//------------------

jerror_t DEventProcessor_search::evnt(JEventLoop *loop, uint64_t eventnumber){

  //Called for every event

 

  //Use vectors of data type to get them for each event

  vector<const DFCALShower*> fcal;   //Vector of DFCalShower pointers

  TVector3 fP;

 

  //Event loop will get objects that match the type of the vector

  loop->Get(fcal);

 

 //Example of a histogram

 Fill1DWeightedHistogram("pi0_search", "example", "nFCalShowers", fcal.size(), 1, "Number of FCAL Showers in an event; Number of FCal Showers; Count", 10, 0, 10);

 

 for(int i=0;i<fcal.size(); i++){

    fcal[i]->getEnergy();

    fcal[i]->getPosition().X();

    fcal[i]->getPosition().Y();

    fcal[i]->getPosition().Z();

   DVector3 v1 = fcal[i]->getPosition();

                v1.SetX(v1.X()- m_beamSpotX);

                v1.SetY(v1.Y() - m_beamSpotY);

                v1.SetZ(v1.Z() - m_targetZ);

                v1.Phi();

                v1.Theta();

                double p1 = e1;

                double px = p1 * sin(v1.Theta()) * cos(v1.Phi());

                double py = p1 * sin(v1.Theta()) * cos(v1.Phi());

                double pz = p1 * sin(v1.Theta());

                v2.SetX(v2.X()-m_beamSpotX);

                v2.SetY(v2.Y()-m_beamSpotY):

                v2.SetZ(v2.Z()-m_targetZ);

                v2.Phi();

                v2.Theta();

                double p2 = e2;

                double px2 = p2 * sin(v2.Theta()) * cos(v2.Phi());

                double py2 = p2 * sin(v2.Theta()) * cos(v2.Phi());

                double pz2 = p2 * sin(v2.Theta());

                v3.SetX(v3.X()-m_beamSpotX);

                v3.SetY(v3.Y()-m_beamSpotY):

                v3.SetZ(v3.Z()-m_targetZ);

                v3.Phi();

                v3.Theta();

           double p3 = e3;

                double px3 = p3 * sin(v3.Theta()) * cos(v3.Phi());

                double py3 = p3 * sin(v3.Theta()) * cos(v3.Phi());

                double pz3 = p3 * sin(v3.Theta());

 

                DVector3 v4 = fcal[i]->getEnergy();

                v4.Sete();

 for(int i=0;i<fcal.size();i++){

                        TLorentzVector sh(px,py,pz,E1);

                }

 if(sh.E()>0.5){

                continue;

                }

                else{

                for(int j=i+2;j<fcal.size(); j++);{

                   TLorentzVector sh1(px2,py2,pz2,E2);

                 if(sh1.E()>0.5){

                    continue;

                   }

                    else{

                     for(int k=i+2;k<fcal.size(); k++);{

                     TLorentzVector sh2(px3,py3,pz3,E3);

                      if(sh2.E()>0.5){

                         continue;

                         }

                        else{

                         TLorentzVector w = sh + sh1 + sh2;

                          Double_t pho = w.M();

                      Fill1DWeightedHistogram("pi0_search2","shower2","nFCalShowers2",fcal.size(), 1, "Number of FCal Showers in an event; Number of FCal Showers; Count", 10, 0, 10);

       }

      }

     }

    }

   }

  }

}

 

  return NOERROR;

 }

}

//------------------

// erun

//------------------

jerror_t DEventProcessor_search::erun(void)

{

 // Any final calculations on histogram (like dividing them)

 // should be done here. This may get called more than once.

 return NOERROR;

}

 

//------------------

// fini

//------------------

jerror_t DEventProcessor_search::fini(void)

{

  return NOERROR;

}

(5/5)
Attachments:

Related Questions

. Introgramming & Unix Fall 2018, CRN 44882, Oakland University Homework Assignment 6 - Using Arrays and Functions in C

DescriptionIn this final assignment, the students will demonstrate their ability to apply two ma

. The standard path finding involves finding the (shortest) path from an origin to a destination, typically on a map. This is an

Path finding involves finding a path from A to B. Typically we want the path to have certain properties,such as being the shortest or to avoid going t

. Develop a program to emulate a purchase transaction at a retail store. This program will have two classes, a LineItem class and a Transaction class. The LineItem class will represent an individual

Develop a program to emulate a purchase transaction at a retail store. Thisprogram will have two classes, a LineItem class and a Transaction class. Th

. SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of Sea Ports. Here are the classes and their instance variables we wish to define:

1 Project 1 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of

. Project 2 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of Sea Ports. Here are the classes and their instance variables we wish to define:

1 Project 2 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of

Ask This Question To Be Solved By Our ExpertsGet A+ Grade Solution Guaranteed

expert
Um e HaniScience

997 Answers

Hire Me
expert
Muhammad Ali HaiderFinance

852 Answers

Hire Me
expert
Husnain SaeedComputer science

968 Answers

Hire Me
expert
Atharva PatilComputer science

825 Answers

Hire Me