#include #include #include #include #include #include #include #include #include #include #include using namespace RAT; using namespace std; void FlasherCrossTalk::BeginOfRun() { DBLinkPtr flasherDB = DB::Get()->GetLink( "FLASHER" ); fXTalkFlag = flasherDB->GetI( "cross_talk_flag" ) == 1; if( fXTalkFlag ) warn << "FlasherCrossTalk::BeginOfRun: Flasher cross talk flag set to on. Will generate hits on unbuilt PMTs.\n"; DBLinkPtr daqDB = DB::Get()->GetLink("DAQ"); //factor that attenuates low gain charges fLowGainFactorDB = daqDB->GetD("lowgain_factor"); // Get tube status and noise rate fNumChannels = static_cast(DB::Get()->GetLink( "PMTINFO" )->GetIArray( "pmt_type" ).size()); } void FlasherCrossTalk::GenerateFlasherCrossTalk(DS::Run&, DS::Entry& ds) { if( !fXTalkFlag ) // Drop out, no cross talk to generate return; // Get the collection of Monte Carlo hits DS::MC& mc = ds.GetMC(); DS::MCHits& mcHits = mc.GetUnbuiltMCHits(); // Find maximum charge PMT Double_t maxQHL = 0; Int_t maxi = 0; for (size_t i=0; i maxQHL){ maxQHL = hitQHL; maxi = i; } } // Generate noise hits for adjacent channels if (maxQHL > 4000){ Int_t lcnID = mcHits.GetAllPMT(maxi).GetID(); if (lcnID < 0 || lcnID >= fNumChannels) return; Int_t hitTime = mcHits.GetAllPMT(maxi).GetTime()+20; // 20ns delay for (int i=1; i<=6; i++){ if (lcnID+i < fNumChannels) if (BitManip::GetChannel(lcnID+i) > BitManip::GetChannel(lcnID)) GenerateNoiseHit( mcHits, lcnID+i, hitTime ); } for (int i=1; i<=6; i++){ if (lcnID-i >= 0) if (BitManip::GetChannel(lcnID-i) < BitManip::GetChannel(lcnID)) GenerateNoiseHit( mcHits, lcnID-i, hitTime ); } } } void FlasherCrossTalk::GenerateNoiseHit( DS::MCHits& mcHits, const Int_t lcn, const Double_t time ) { const DU::ChanHWStatus& channelHardwareStatus = DU::Utility::Get()->GetChanHWStatus(); if( channelHardwareStatus.IsEnabled() && !channelHardwareStatus.IsTubeOnline( lcn ) ) return; // Do Not record the hit. // Add noise hit to unbuilt MC hits Int_t charge = channelHardwareStatus.GetThresholdZero( lcn ); DS::MCHit hit; hit.SetID( lcn ); hit.SetQHS(charge); hit.SetQHL(charge); hit.SetQLX(charge/fLowGainFactorDB); hit.SetTime(time); const DU::PMTInfo& pmtInfo = DU::Utility::Get()->GetPMTInfo(); mcHits.AddPMT( hit, pmtInfo.GetType( lcn ) ); }