// $Id$ // // File: JEventProcessor_CDC_Cosmics.cc // Created: Mon Jul 6 13:00:51 EDT 2015 // Creator: mstaib (on Linux egbert 2.6.32-504.16.2.el6.x86_64 x86_64) // #include "JEventProcessor_CDC_Cosmics.h" #include "TRACKING/DTrackCandidate.h" #include "HistogramTools.h" using namespace jana; // Routine used to create our JEventProcessor #include #include extern "C"{ void InitPlugin(JApplication *app){ InitJANAPlugin(app); app->AddProcessor(new JEventProcessor_CDC_Cosmics()); } } // "C" //------------------ // JEventProcessor_CDC_Cosmics (Constructor) //------------------ JEventProcessor_CDC_Cosmics::JEventProcessor_CDC_Cosmics() { } //------------------ // ~JEventProcessor_CDC_Cosmics (Destructor) //------------------ JEventProcessor_CDC_Cosmics::~JEventProcessor_CDC_Cosmics() { } //------------------ // init //------------------ jerror_t JEventProcessor_CDC_Cosmics::init(void) { EXCLUDERING=0; if (gPARMS){ gPARMS->SetDefaultParameter("CDCCOSMIC:EXCLUDERING", EXCLUDERING, "Ring Excluded from the fit"); } if(EXCLUDERING == 0 ){ jerr << "Did not set CDCCOSMIC:EXCLUDERING on the command line -- Aborting!!!" << endl; japp->Quit(); } return NOERROR; } //------------------ // brun //------------------ jerror_t JEventProcessor_CDC_Cosmics::brun(JEventLoop *eventLoop, int runnumber) { // This is called whenever the run number changes return NOERROR; } //------------------ // evnt //------------------ jerror_t JEventProcessor_CDC_Cosmics::evnt(JEventLoop *loop, int eventnumber) { // Get the DTrackCandidates vector trackCandidateVector; loop->Get(trackCandidateVector, "CDCCOSMIC"); // Require Single track events if (trackCandidateVector.size() != 1) return NOERROR; const DTrackCandidate* thisTrackCandidate = trackCandidateVector[0]; // Cut loosely on the track quality if (thisTrackCandidate->chisq / thisTrackCandidate->Ndof > 5) return NOERROR; vector pulls = thisTrackCandidate->pulls; // Loop over the pulls to get the appropriate information for our ring for (unsigned int i = 0; i < pulls.size(); i++){ DTrackFitter::pull_t thisPull = pulls[i]; double residual = thisPull.resi; //double error = thisPull.err; double time = thisPull.tdrift; double distance = thisPull.d; // This is the distance from the lookup table double predictedDistance = distance - residual; // This is the distance predicted by the fit const DCDCTrackHit* thisCDCHit = thisPull.cdc_hit; int ring = thisCDCHit->wire->ring; if (ring != EXCLUDERING) continue; // Now we have just the unbiased information for the ring we have chosen // Now just make a bunch of histograms to display all of the information char folder[100]; sprintf(folder, "Ring %.2i", ring); Fill1DHistogram("CDC_Cosmic", folder, "Residuals", residual, "Residuals; Residual [cm]; Entries", 100, -0.05, 0.05); Fill1DHistogram("CDC_Cosmic", folder, "Drift Time", time, "Drift Time; Drift Time [ns]; Entries", 500, -10, 990); Fill1DHistogram("CDC_Cosmic", folder, "Drift Distance", distance, "Drift Distance; Drift Distance [cm]; Entries", 50, 0.0, 1.0); Fill1DHistogram("CDC_Cosmic", folder, "Predicted Drift Distance", predictedDistance, "Predicted Drift Distance; Drift Distance [cm]; Entries", 50, 0.0, 1.0); Fill2DHistogram("CDC_Cosmic", folder, "Residual Vs. Drift Time", time, residual, "Residual Vs. Drift Time; Drift Time [ns]; Residual [cm]", 500, -10, 990, 100, -0.05, 0.05); Fill2DHistogram("CDC_Cosmic", folder, "Residual Vs. Drift Distance", distance, residual, "Residual Vs. Drift Distance; Drift Distance [cm]; Residual [cm]", 50, 0.0, 1.0, 100, -0.05, 0.05); Fill2DHistogram("CDC_Cosmic", folder, "Residual Vs. Predicted Drift Distance", predictedDistance, residual, "Residual Vs. Predicted Drift Distance; Predicted Drift Distance [cm]; Residual [cm]", 50, 0.0, 1.0, 100, -0.05, 0.05); Fill2DHistogram("CDC_Cosmic", folder, "Predicted Drift Distance Vs. Drift Time", time, predictedDistance, "Predicted Drift Distance Vs. Drift Time; Drift Time [ns]; Predicted Drift Distance [cm]", 500, -10, 990, 50, 0.0, 1.0); } return NOERROR; } //------------------ // erun //------------------ jerror_t JEventProcessor_CDC_Cosmics::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_CDC_Cosmics::fini(void) { // Called before program exit after event processing is finished. return NOERROR; }