// $Id$ // // File: MyProcessor.cc // Created: Mon Aug 28 EDT 2006 // Creator: davidl (on Darwin swire-b241.jlab.org 8.7.0 powerpc) // #include #include "TAGGER/DTAGGER_EHit.h" #include "MyProcessor.h" // This is an example program that shows how to access the BCAL06 // beam test data and create a ROOT file with histograms from it. // It uses ROOT's built-in mutex for serializing access to the // ROOT memory so this should be thread safe. To running it with // multiple processing threads, run the program with the // --nthreads=XXX option where XXX is the number of threads. //------------------ // init //------------------ jerror_t MyProcessor::init(void) { // ROOT file is opened in brun so we can use runnumber // in the filename. If you want one file for several // runs (e.g. multiple files from different runs are // specified on the command line) then open the file // here. file = NULL; return NOERROR; } //------------------ // brun //------------------ jerror_t MyProcessor::brun(JEventLoop *eventLoop, int runnumber) { // Special events (like prestart and go) will not have run number // info in them. Ignore these. if(runnumber==0)return NOERROR; // Lock access to ROOT TThread::Lock(); // Create ROOT file char fname[256]; sprintf(fname,"bcal_root%05d.root", runnumber); file = new TFile(fname, "RECREATE"); // Create Histograms Eid_vs_t = new TH2F("Eid_vs_t","E-counter ID vs. time", 1000, 0.0, 1000.0, 384, 0.5, 384.5); Eid_in_time = new TH1F("Eid_in_time","E-counter occupancy for in-time hits",384, 0.5, 384.5); // Unlock ROOT mutex TThread::UnLock(); return NOERROR; } //------------------ // evnt //------------------ jerror_t MyProcessor::evnt(JEventLoop *loop, int eventnumber) { // If ROOT file is not open, then do nothing if(!file)return NOERROR; // Get data vector ehits; loop->Get(ehits); // Loop over hits for(unsigned int i=0; itime/2.0; Eid_vs_t->Fill(t, ehit->E_id); if(t>=585.0 && t<=600.0)Eid_in_time->Fill(ehit->E_id); } return NOERROR; } //------------------ // erun //------------------ jerror_t MyProcessor::erun(void) { TThread::Lock(); // Close file if(file){ file->Write(); file->Close(); delete file; } file = NULL; TThread::UnLock(); return NOERROR; } //------------------ // fini //------------------ jerror_t MyProcessor::fini(void) { return NOERROR; }