// Author: David Lawrence June 25, 2004 // // // MyProcessor.cc // #include #include using namespace std; #include #include #include "MyProcessor.h" #include "TRACKING/DTrack.h" #include "TRACKING/DTrackHit.h" #include "TRACKING/DTrackCandidate.h" #include "TRACKING/DTrackEfficiency.h" #include "TRACKING/DMCThrown.h" #include "FDC/DFDCPseudo.h" #include "GlueX.h" TFile *ROOTfile = NULL; TH1F *FDC_z, *FDC_r, *CDC_z, *CDC_r; TH3F *FDC_pseudo; extern const char* OUTPUTFILE; //------------------------------------------------------------------ // init -Open output file here (e.g. a ROOT file) //------------------------------------------------------------------ jerror_t MyProcessor::init(void) { // open ROOT file ROOTfile = new TFile(OUTPUTFILE,"RECREATE","Produced by hd_ana"); cout<<"Opened ROOT file \""<Branch("F",val,"p/F:px:py:pz:x:y:z:pcan:pcanx:pcany:pcanz:canz:Ro:x0:y0:phi:theta:p_thrn:px_thrn:py_thrn:pz_thrn:phi_thrn:theta_thrn:fittable:nhits:chisq"); gPARMS->GetParameter("TRKFIT:CANDIDATE_TAG", CANDIDATE_TAG); return NOERROR; } //------------------------------------------------------------------ // evnt -Fill histograms here //------------------------------------------------------------------ jerror_t MyProcessor::evnt(JEventLoop *loop, int eventnumber) { // Histograms are created and filled in DEventProcessor_TrackHists // Automatically since it was added to the app in mctrk_ana.cc // Histograms to determine angles from geometry vector trackhits; loop->Get(trackhits, "MC"); for(unsigned int i=0; isystem==SYS_CDC){ CDC_z->Fill(hit->z); CDC_r->Fill(hit->r); } if(hit->system==SYS_FDC){ FDC_z->Fill(hit->z); FDC_r->Fill(hit->r); } } vector tracks; vector trackeffs; vector mcthrowns; vector trackcandidates; JFactory *fac_track = loop->Get(tracks); loop->Get(trackeffs); loop->Get(mcthrowns); JFactory *fac_tc = loop->Get(trackcandidates, CANDIDATE_TAG.c_str()); // Loop over DMCThrown and DTrackEfficiency objects for(unsigned int i=0; iGetByIDT(trackeff->trackid); if(!track)continue; const DTrackCandidate *tc = fac_tc->GetByIDT(track->candidateid); if(!tc)continue; LockState(); val[ 0] = track->p; val[ 1] = track->p*sin(track->theta)*cos(track->phi); val[ 2] = track->p*sin(track->theta)*sin(track->phi); val[ 3] = track->p*cos(track->theta); val[ 4] = track->x; val[ 5] = track->y; val[ 6] = track->z; val[ 7] = tc->p; val[ 8] = tc->p_trans*cos(tc->phi); val[ 9] = tc->p_trans*sin(tc->phi); val[10] = tc->p*cos(tc->theta); val[11] = tc->z_vertex; val[12] = sqrt(tc->x0*tc->x0 + tc->y0*tc->y0); val[13] = tc->x0; val[14] = tc->y0; val[15] = track->phi; val[16] = track->theta; val[17] = thrown->p; val[18] = thrown->p*sin(thrown->theta)*cos(thrown->phi); val[19] = thrown->p*sin(thrown->theta)*sin(thrown->phi); val[20] = thrown->p*cos(thrown->theta); val[21] = thrown->phi; val[22] = thrown->theta; val[23] = (float)trackeff->fittable; val[24] = (float)trackeff->Nhits_thrown; val[25] = track->chisq; fit_parms->Fill(); UnlockState(); } vector fdcs; loop->Get(fdcs); for(unsigned int i=0; iwire)continue; TVector3 pos = hit->wire->origin + hit->s*hit->wire->udir; FDC_pseudo->Fill(pos.x(), pos.y(), pos.z()); } #if 0 for(unsigned int i=0; ix0*tc->x0 + tc->y0*tc->y0); R_vs_theta->Fill(tc->theta,R); R_over_sintheta_vs_theta->Fill(tc->theta,R/sin(tc->theta)); } #endif return NOERROR; } //------------------------------------------------------------------ // fini -Close output file here //------------------------------------------------------------------ jerror_t MyProcessor::fini(void) { ROOTfile->Write(); delete ROOTfile; cout<