diff --git a/FCALbadchannels.cc b/FCALbadchannels.cc new file mode 100644 index 0000000..e958c89 --- /dev/null +++ b/FCALbadchannels.cc @@ -0,0 +1,316 @@ +// $Id$ +// +// File: FCALbadchannels.cc +// Created: Wed Sep 11 13:39:58 EDT 2019 +// Creator: cakondi (on Linux ifarm1802 3.10.0-327.el7.x86_64 x86_64) +// +#include +#include +#include +#include "FCALbadchannels.hh" +using namespace jana; +#include +#include +#include +//// DFCAL Hit factory.cc included the following header files +#include +#include "FCAL/DFCALDigiHit.h" +#include "FCAL/DFCALGeometry.h" +#include "FCAL/DFCALHit_factory.h" +#include "DAQ/Df250PulseIntegral.h" +#include "DAQ/Df250PulsePedestal.h" +#include "DAQ/Df250Config.h" +#include "TTAB/DTTabUtilities.h" +#include +#include +#include +#include "DVector2.h" +#include "units.h" +#include +#include "FCAL/DFCALCluster.h" +#include "FCAL/DFCALCluster_factory.h" +#include "HDGEOMETRY/DGeometry.h" +#include +#include +#include +#include "TApplication.h" +#include "TH3.h" + + + + + + +// Routine used to create our JEventProcessor +#include +#include +extern "C"{ +void InitPlugin(JApplication *app){ + InitJANAPlugin(app); + app->AddProcessor(new FCALbadchannels()); +} +} // "C" + + +//------------------ +// FCALbadchannels (Constructor) +//------------------ +FCALbadchannels::FCALbadchannels() +{ + +} + +//------------------ +// ~FCALbadchannels (Destructor) +//------------------ +FCALbadchannels::~FCALbadchannels() +{ + +} + +//------------------ +// init +//------------------ +jerror_t FCALbadchannels::init(void) +{ + char hname[100]; + const int max_blocks = 2800, max_rows = 59 , max_cols = 59; + static const int nranges = 5; + + htrigfp = new TH1F("htrigfp", "", 32,0,31); + hrawtrigbit = new TH1F("hrawtrigbit", "", 32,0,31); + + hAllInte = new TH1F("hAllInte", "", 2000,0,200000); + + hTotalInte = new TH1F("hTotalInte", "", 20000,0.,200000000.); + hTotalInteCut = new TH1F("hTotalInteCut", "", 20000,0.,200000000.); + hRanges = new TH1F("hRanges", "", 20000,0.,200000000.); + + hhitcnter = new TH1F("hhitcnter", "", 11,0,10); + hTotalInteHits = new TH2F("hTotalInteHits", "",20000,0.,200000000., 11,0,10); + + hNhits = new TH1F("hNhits", "", max_blocks,-0.5,max_blocks-0.5); + hEff = new TH1F("hEff", "", max_blocks,-0.5,max_blocks-0.5); + + hRowColOcc = new TH2F("hRowColOcc", "", max_cols,-0.5,max_cols-0.5, max_rows,-0.5,max_rows-0.5); + hRowColEff = new TH2F("hRowColEff", "", max_cols,-0.5,max_cols-0.5, max_rows,-0.5,max_rows-0.5); + + for(int ira=0; ira fcalGeomVect; + loop->Get( fcalGeomVect ); + if (fcalGeomVect.size() < 1) + return OBJECT_NOT_AVAILABLE; + const DFCALGeometry& fcalGeom = *(fcalGeomVect[0]); + + + ///////////////Trigger and Front Panel Trigger ///////////////////////// + + vector l1trig; + loop->Get(l1trig); + + japp->RootFillLock(this); + + int rawtrignumber,trigfpnumber; + if( l1trig.size() > 0) { + for(unsigned int trigcounter = 0; trigcounter < 32; trigcounter++){ + trig_bit[trigcounter+1] = (l1trig[0]->trig_mask & (1 << trigcounter)) ? 1 : 0; + if (trig_bit[trigcounter+1] == 1) { + trigbit=trigcounter+1; + rawtrignumber=trigbit; + //hrawtrigbit->Fill(trigbit); + } + } + hrawtrigbit->Fill(trigbit); + + for(unsigned int trigfpcounter = 0; trigfpcounter < 32; trigfpcounter++){ + trig_bit_fp[trigfpcounter+1] = (l1trig[0]->fp_trig_mask & (1 << trigfpcounter)) ? 1 : 0; + if (trig_bit_fp[trigfpcounter+1] == 1) { + trigfpbit=trigfpcounter+1; + trigfpnumber=trigfpbit; + //htrigfp->Fill(trigfpbit); + } + } + htrigfp->Fill(trigfpbit); + } + + //----------------- + if(trigfpnumber!=3) return NOERROR; // trigfpnumber!=3 for FCAL FP trigger + // if(rawtrignumber!=1) return NOERROR; // trignumber!=1 for rawdata // trignumber !4 for PS + + vector digihits; + loop->Get(digihits); + + Double_t RegLo[5] = { 5e+6, 10e+6, 15e+6, 28e+6, 33e+6}; + // Double_t RegHi[5] = {10e+6, 15e+6, 20e+6, 33e+6, 38e+6}; + Double_t RegHi[5] = {10e+6, 15e+6, 20e+6, 33e+6, 45e+6};// RunPeriod-2019-11 -- not great + + for(int ira=0; iraFill(RegLo[ira]); + hRanges->Fill(RegHi[ira]); + } + + float TotalInte=0; + int Row[max_blocks], Column[max_blocks]; + int hitcnter[max_blocks]; + for(int ibl=0; iblpulse_time == 0 || digihit->pedestal == 0 || digihit->pulse_peak == 0) continue; + int ibl = fcalGeom.channel(digihit->row,digihit->column); + Row[ibl] = digihit->row; + Column[ibl] = digihit->column; + hitcnter[ibl]++; + + hNhits->Fill(ibl); + hRowColOcc->Fill(Column[ibl],Row[ibl]); + + double inte = (digihit->pulse_integral) -(((double)digihit->pedestal/digihit->nsamples_pedestal)*digihit->nsamples_integral); + + hAllInte->Fill(inte); + + TotalInte += inte; + } + hTotalInte->Fill(TotalInte); + + if (TotalInte > RegLo[0] && TotalInte <= RegHi[4]){ + hTotalInteCut->Fill(TotalInte); + + for(int ibl=0; ibl 0) { + + hEff->Fill(ibl); + hRowColEff->Fill(Column[ibl],Row[ibl]); + + for(int ira=0; ira RegLo[ira] && TotalInte <= RegHi[ira]){ + hEffReg_[ira]->Fill(ibl); + hRowColReg_[ira]->Fill(Column[ibl],Row[ibl]); + } + } + + int yval; + if (hitcnter[ibl] <= 10) yval = hitcnter[ibl]; + if (hitcnter[ibl] > 10) yval = 10; + hhitcnter->Fill(yval); + hTotalInteHits->Fill(TotalInte, yval); + + } // hitcnter + } // ibl + } // TotalInte threshold + + + //----------------- + //--- for LED time: + // + vector fcalhits; + loop->Get(fcalhits); + + // RunPeriod-2019-11 + Double_t RegLoE[5] = {2000, 3200, 4700, 6500, 8000}; + Double_t RegHiE[5] = {3200, 4700, 6500, 8000, 10000}; + + for(int ira=0; iraFill(RegLoE[ira]); + hRangesE->Fill(RegHiE[ira]); + } + + float TotalInteE=0; + for (unsigned int i = 0; i < fcalhits.size(); i++){ + const DFCALHit *fcalhit = fcalhits[i]; + int ibl = fcalGeom.channel(fcalhit->row, fcalhit->column); + if(trigfpnumber==3){ + TotalInteE += fcalhit->E; + if (ibl == 2121) hHitTime2121->Fill(fcalhit->t); + } + } + + hTotalInteE->Fill(TotalInteE); + for(int ira=0; ira RegLoE[ira] && TotalInteE <= RegHiE[ira]){ + hTotalInteE_Cut->Fill(TotalInteE); + for (unsigned int i = 0; i < fcalhits.size(); i++){ + const DFCALHit *fcalhit = fcalhits[i]; + int ibl = fcalGeom.channel(fcalhit->row, fcalhit->column); + if (ira == 0) hHitTimeRange0_[ibl]->Fill(fcalhit->t); + if (ira == 1) hHitTimeRange1_[ibl]->Fill(fcalhit->t); + if (ira == 2) hHitTimeRange2_[ibl]->Fill(fcalhit->t); + if (ira == 3) hHitTimeRange3_[ibl]->Fill(fcalhit->t); + if (ira == 4) hHitTimeRange4_[ibl]->Fill(fcalhit->t); + } + } + } + + + + japp->RootFillUnLock(this); + + return NOERROR; +} + +//------------------ +// erun +//------------------ +jerror_t FCALbadchannels::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 FCALbadchannels::fini(void) +{ + // Called before program exit after event processing is finished. + return NOERROR; +} + diff --git a/FCALbadchannels.hh b/FCALbadchannels.hh new file mode 100644 index 0000000..df48910 --- /dev/null +++ b/FCALbadchannels.hh @@ -0,0 +1,97 @@ +// $Id$ +// +// File: FCALbadchannels.hh +// Created: Wed Sep 11 13:39:58 EDT 2019 +// Creator: cakondi (on Linux ifarm1802 3.10.0-327.el7.x86_64 x86_64) +// + +#ifndef _FCALbadchannels_ +#define _FCALbadchannels_ + +#include +#include +#include +using namespace jana; +#include +#include +#include +#include +#include +#include +#include + +#include "TApplication.h" +#include +#include +#include +#include +#include "TProfile.h" +#include "TCanvas.h" +#include + + +class FCALbadchannels:public jana::JEventProcessor{ +public: + FCALbadchannels(); + ~FCALbadchannels(); + const char* className(void){return "FCALbadchannels";} + +private: + jerror_t init(void); ///< Called once at program start. + jerror_t brun(jana::JEventLoop *eventLoop, int32_t runnumber); ///< Called everytime a new run number is detected. + jerror_t evnt(jana::JEventLoop *eventLoop, uint64_t eventnumber); ///< Called every event. + jerror_t erun(void); ///< Called everytime run number changes, provided brun has been called. + jerror_t fini(void); ///< Called after last event of last event source has been processed. + + + + + + ////// trigger bit section variables + + static const Int_t max_bit = 32; + Int_t trig_bit[max_bit]; + Int_t trig_bit_fp[max_bit]; + + Int_t trigbit; + Int_t trigfpbit; + + static const Int_t kBlocksWidth = 59 ; + static const Int_t kBlocksHeight = 59 ; + static const Int_t max_blocks = kBlocksWidth*kBlocksHeight; /// 59 x59 = # blocks width x # blocks height + static const Int_t nranges = 5; + + TH1F *htrigfp; + TH1F *hrawtrigbit; + + TH1F *hAllInte; + TH1F *hTotalInte; + TH1F *hTotalInteCut; + TH1F *hRanges; + + TH1F *hhitcnter; + TH2F *hTotalInteHits; + TH2F *hhitt; + + TH1F *hNhits; + TH2F *hRowColOcc; + TH1F *hEff; + TH2F *hRowColEff; + + TH1F *hEffReg_[nranges]; + TH2F *hRowColReg_[nranges]; + + TH1F *hRangesE; + TH1F *hTotalInteE; + TH1F *hHitTime2121; + TH1F *hTotalInteE_Cut; + TH1F *hHitTimeRange0_[max_blocks]; + TH1F *hHitTimeRange1_[max_blocks]; + TH1F *hHitTimeRange2_[max_blocks]; + TH1F *hHitTimeRange3_[max_blocks]; + TH1F *hHitTimeRange4_[max_blocks]; + +}; + +#endif // _FCALbadchannels_ +