// $Id$ // // File: JEventProcessor_DAQTreeFCAL.cc // Created: Mon Dec 8 11:12:16 EST 2014 // Creator: manlara (on Linux gluon03.jlab.org 2.6.32-358.18.1.el6.x86_64 x86_64) // // Purpose // ____________________________________________ // To output a .root of just pedestal related information #include "JEventProcessor_DAQTreeFCAL.h" using namespace jana; #include // https://halldsvn.jlab.org/repos/branches/sim-recon-commissioning/src/programs/Utilities/plugins/DAQ #include #include #include #include #include #include // FCAL Hit Objects // https://halldsvn.jlab.org/repos/branches/sim-recon-commissioning/src/libraries/FCAL/ // Other peoples plugins // https://halldsvn.jlab.org/repos/branches/sim-recon-commissioning/src/programs/Analysis/plugins/ bool Df250WindowRawData_cmp(const Df250WindowRawData *a,const Df250WindowRawData *b){ // sort by crate, then by slot, then by channel, then by trigger number if (a->rocid != b->rocid) return a->rocid < b->rocid; if (a->slot != b->slot ) return a->slot < b->slot; if (a->channel != b->channel) return a->channel < b->channel; return a->itrigger < b->itrigger; } bool Df250PulseRawData_cmp(const Df250PulseRawData *a,const Df250PulseRawData *b){ // sort by crate, then by slot, then by channel, then by trigger number if (a->rocid != b->rocid) return a->rocid < b->rocid; if (a->slot != b->slot ) return a->slot < b->slot; if (a->channel != b->channel) return a->channel < b->channel; return a->itrigger < b->itrigger; } bool Df250PulseIntegral_cmp(const Df250PulseIntegral *a,const Df250PulseIntegral *b){ // sort by crate, then by slot, then by channel, then by trigger number if (a->rocid != b->rocid) return a->rocid < b->rocid; if (a->slot != b->slot ) return a->slot < b->slot; if (a->channel != b->channel) return a->channel < b->channel; return a->itrigger < b->itrigger; } bool Df250PulseTime_cmp(const Df250PulseTime *a,const Df250PulseTime *b){ // sort by crate, then by slot, then by channel, then by trigger number if (a->rocid != b->rocid) return a->rocid < b->rocid; if (a->slot != b->slot ) return a->slot < b->slot; if (a->channel != b->channel) return a->channel < b->channel; return a->itrigger < b->itrigger; } bool Df250PulsePedestal_cmp(const Df250PulsePedestal *a,const Df250PulsePedestal *b){ // sort by crate, then by slot, then by channel, then by trigger number if (a->rocid != b->rocid) return a->rocid < b->rocid; if (a->slot != b->slot ) return a->slot < b->slot; if (a->channel != b->channel) return a->channel < b->channel; return a->itrigger < b->itrigger; } bool Df250TriggerTime_cmp(const Df250TriggerTime *a,const Df250TriggerTime *b){ // sort by crate, then by slot, then by channel, then by trigger number if (a->rocid != b->rocid) return a->rocid < b->rocid; if (a->slot != b->slot ) return a->slot < b->slot; return a->itrigger < b->itrigger; } // Routine used to create our JEventProcessor #include #include extern "C"{ void InitPlugin(JApplication *app){ InitJANAPlugin(app); app->AddProcessor(new JEventProcessor_DAQTreeFCAL()); } } // "C" //------------------ // JEventProcessor_DAQTreeFCAL (Constructor) //------------------ JEventProcessor_DAQTreeFCAL::JEventProcessor_DAQTreeFCAL() { } //------------------ // ~JEventProcessor_DAQTreeFCAL (Destructor) //------------------ JEventProcessor_DAQTreeFCAL::~JEventProcessor_DAQTreeFCAL() { } //------------------ // init //------------------ jerror_t JEventProcessor_DAQTreeFCAL::init(void) { // This is called once at program startup. If you are creating // and filling historgrams in this plugin, you should lock the // ROOT mutex like this: // // japp->RootWriteLock(); // ... fill historgrams or trees ... // japp->RootUnLock(); // FCAL_Df250PulseIntegral = new TTree("Df250PulseIntegral","Pedestal information from Pulse Integral Object"); FCAL_Df250PulseIntegral->Branch("rocid", &rocid , "rocid/i"); FCAL_Df250PulseIntegral->Branch("slot", &slot , "slot/i"); FCAL_Df250PulseIntegral->Branch("channel", &channel , "channel/i"); FCAL_Df250PulseIntegral->Branch("eventnum", &eventnum, "eventnum/i"); FCAL_Df250PulseIntegral->Branch("pedestal", &pedestal, "pedestal/i"); FCAL_Df250WindowRawData = new TTree("Df250WindowRawData","Pedestal information from Pulse Integral Object"); FCAL_Df250WindowRawData->Branch("rocid", &rocid , "rocid/i"); FCAL_Df250WindowRawData->Branch("slot", &slot , "slot/i"); FCAL_Df250WindowRawData->Branch("channel", &channel , "channel/i"); FCAL_Df250WindowRawData->Branch("eventnum", &eventnum, "eventnum/i"); FCAL_Df250WindowRawData->Branch("w_ped", &w_ped, "w_ped/f"); FCAL_SpecialWaveforms = new TTree("SpecialWaveforms","Waveforms for special channels"); FCAL_Df250WindowRawData->Branch("rocid", &rocid , "rocid/i"); FCAL_Df250WindowRawData->Branch("slot", &slot , "slot/i"); FCAL_Df250WindowRawData->Branch("channel", &channel , "channel/i"); FCAL_Df250WindowRawData->Branch("eventnum", &eventnum, "eventnum/i"); FCAL_Df250WindowRawData->Branch("w_ped", &w_ped, "w_ped/f"); FCAL_Df250WindowRawData->Branch("nsamples", &nsamples, "nsamples/i"); FCAL_Df250WindowRawData->Branch("waveform", &waveform); return NOERROR; } //------------------ // brun //------------------ jerror_t JEventProcessor_DAQTreeFCAL::brun(JEventLoop *eventLoop, int runnumber) { // This is called whenever the run number changes return NOERROR; } //------------------ // evnt //------------------ jerror_t JEventProcessor_DAQTreeFCAL::evnt(JEventLoop *loop, int eventnumber) { // This is called for every event. Use of common resources like writing // to a file or filling a histogram should be mutex protected. Using // loop->Get(...) to get reconstructed objects (and thereby activating the // reconstruction algorithm) should be done outside of any mutex lock // since multiple threads may call this method at the same time. // Here's an example: // loop->GetJCalibration() vector f250WindowRawData_vec; loop->Get(f250WindowRawData_vec); sort(f250WindowRawData_vec.begin(), f250WindowRawData_vec.end(), Df250WindowRawData_cmp); vector f250PulseRawData_vec; loop->Get(f250PulseRawData_vec); sort(f250PulseRawData_vec.begin(), f250PulseRawData_vec.end(), Df250PulseRawData_cmp); vector f250PulseIntegral_vec; loop->Get(f250PulseIntegral_vec); sort(f250PulseIntegral_vec.begin(), f250PulseIntegral_vec.end(), Df250PulseIntegral_cmp); vector f250PulseTime_vec; loop->Get(f250PulseTime_vec); sort(f250PulseTime_vec.begin(), f250PulseTime_vec.end(), Df250PulseTime_cmp); vector f250PulsePedestal_vec; loop->Get(f250PulsePedestal_vec); sort(f250PulsePedestal_vec.begin(), f250PulsePedestal_vec.end(), Df250PulsePedestal_cmp); vector f250TriggerTime_vec; loop->Get(f250TriggerTime_vec); sort(f250TriggerTime_vec.begin(), f250TriggerTime_vec.end(), Df250TriggerTime_cmp); japp->RootWriteLock(); for (vector::const_iterator iter = f250PulseIntegral_vec.begin(); iter != f250PulseIntegral_vec.end(); ++iter){ rocid=(*iter)->rocid; slot=(*iter)->slot; channel=(*iter)->channel; eventnum=eventnumber; pedestal=(*iter)->pedestal; if (rocid>=11 && rocid<=23) { FCAL_Df250PulseIntegral->Fill(); } } for (vector::const_iterator iter = f250WindowRawData_vec.begin(); iter != f250WindowRawData_vec.end(); ++iter){ rocid=(*iter)->rocid; slot=(*iter)->slot; channel=(*iter)->channel; eventnum=eventnumber; waveform.clear(); const vector &samplesvector = (*iter)->samples; nsamples = samplesvector.size(); w_ped = samplesvector[0]; for (int i=1; i=11 && rocid<=23) { FCAL_Df250WindowRawData->Fill(); if (w_ped>3000){ std::cout << "Pedestal > 3000 !!\n" << rocid << "/" << slot << "/" << channel << "\t" << eventnumber << std::endl; FCAL_SpecialWaveforms->Fill(); } } } japp->RootUnLock(); return NOERROR; } //------------------ // erun //------------------ jerror_t JEventProcessor_DAQTreeFCAL::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_DAQTreeFCAL::fini(void) { // Called before program exit after event processing is finished. return NOERROR; }