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

586 Answers

Hire Me
expert
Muhammad Ali HaiderFinance

817 Answers

Hire Me
expert
Husnain SaeedComputer science

974 Answers

Hire Me
expert
Atharva PatilComputer science

632 Answers

Hire Me
June
January
February
March
April
May
June
July
August
September
October
November
December
2025
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
SunMonTueWedThuFriSat
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
1
2
3
4
5
00:00
00:30
01:00
01:30
02:00
02:30
03:00
03:30
04:00
04:30
05:00
05:30
06:00
06:30
07:00
07:30
08:00
08:30
09:00
09:30
10:00
10:30
11:00
11:30
12:00
12:30
13:00
13:30
14:00
14:30
15:00
15:30
16:00
16:30
17:00
17:30
18:00
18:30
19:00
19:30
20:00
20:30
21:00
21:30
22:00
22:30
23:00
23:30