// -*- C++/l -*- // // Description: // // Author: Nicholas Hastings // Created: Tuesday 23 October 11:35:51 JST 2012 // #include "TTree.h" #include "IFGDTriggerCheck.hxx" #include "IFgdAsumBank.hxx" IFGDTriggerCheck::IFGDTriggerCheck() : ftTriggerPattern(0), fFgdCosmic(false), fLow(0), fMid(0), fHigh(0), fNChan( fNIndex ), fGroup( new Int_t[fNChan]), fRate( new Double_t[fNChan]), fNMC( fNCrate ), fCrate ( new Int_t[fNMC]), fRateCMB( new Double_t[fNMC]), fTime(0) { } IFGDTriggerCheck::~IFGDTriggerCheck() { delete [] fGroup; delete [] fRate; delete [] fCrate; delete [] fRateCMB;; } void IFGDTriggerCheck::Initialize(void) { ftTriggerPattern = new TTree("trig", "FGD Trigger Pattern"); COMETVerbose("IFGDTriggerCheck::Initialize(void) TTree is " << ftTriggerPattern->GetName() ); ftTriggerPattern->Branch( "fgdcosmic", &fFgdCosmic, "fgdcosmic/O"); ftTriggerPattern->Branch( "low", &fLow, "low/L"); ftTriggerPattern->Branch( "mid", &fMid, "mid/L"); ftTriggerPattern->Branch( "high", &fHigh, "high/L"); ftTriggerPattern->Branch( "ngrp", &fNChan, "ngrp/i" ); ftTriggerPattern->Branch( "group",fGroup, "group[ngrp]/I" ); ftTriggerPattern->Branch( "rate", fRate, "rate[ngrp]/D" ); ftTriggerPattern->Branch( "nmc", &fNMC, "nmc/i" ); ftTriggerPattern->Branch( "crate", fCrate, "crate[nmc]/I" ); ftTriggerPattern->Branch( "ratecmb", fRateCMB, "ratecmb[nmc]/D" ); ftTriggerPattern->Branch("time", &fTime, "time/I"); } int IFGDTriggerCheck::Process( COMET::ICOMETEvent& event ) { COMET::IHandle raw_event = event.GetRaw(); if (!raw_event) return 0; for ( unsigned int i = 0; i < fNChan; i++ ) { fRate[i] = 0.0; fGroup[i] = i; } for ( unsigned int i = 0; i < fNMC; i++ ) { fRateCMB[i] = 0.0; fCrate[i] = i; } fFgdCosmic = event.CheckTrigger( COMET::Trigger::kFGDCosmic ); fTime = event.GetContext().GetTimeStamp(); /// Fill trigger bits information fLow = event.GetHeader().GetFGDCTMTriggerPattern(0); fMid = event.GetHeader().GetFGDCTMTriggerPattern(1); fHigh = event.GetHeader().GetFGDCTMTriggerPattern(2); /// Fill asum bank information const int grp_per_crate = fNGroup*fNFeb; COMET::IHandle fgdAsumBank; // if ( fgdAsumBank == 0) // return 0; while ( fgdAsumBank = raw_event->GetMidasBank("",fgdAsumBank) ) { const int crate = fgdAsumBank->GetCrate(); if ( crate < 0 || static_cast(fNCrate) <= crate ) continue; const double cmb_rate = fgdAsumBank->GetRateCMBTriggers(); fRateCMB[crate] = cmb_rate; for( int i = 0; i < grp_per_crate; i++){ const double asum_rate = fgdAsumBank->GetRateGroupTriggers(i); const Int_t ch = grp_per_crate*crate + i; if ( ch <0 || static_cast(fNChan) <= ch) continue; fRate[ch] = asum_rate; } } ftTriggerPattern->Fill(); return 0; } // Local Variables: // c-basic-offset: 8 // c-file-offsets: ((access-label . -2)(inclass . 4)(innamespace . 2)) // End: