#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace CLHEP; namespace RAT { EventBuilderProc::EventBuilderProc() : Processor("EventBuilder"), fLdaq(0),fTriggerGateDB(0),fTriggerDelayDB(0),fFECDelay(0),fGTDelay(0),fCountPEs(false) { } EventBuilderProc::~EventBuilderProc() { } void EventBuilderProc::BeginOfRun(DS::Run &run) { fUnCal.BeginOfRun(run); fLdaq = DB::Get()->GetLink("DAQ"); // delay of channel info from FE elec fFECDelay = fLdaq->GetD("triggerfecdelay"); //delay of global trigger back to Front End fGTDelay = fLdaq->GetD("gtriggerdelay"); fStore = fLdaq->GetZ("store_all_hits"); fTriggerDelayDB = fFECDelay + fGTDelay; //width of trigger gate to collect hits fTriggerGateDB = fLdaq->GetD("triggergate"); detail << "EventBuilderProc: Trigger constants loaded" << newline; detail << dformat(" Trigger Delay: %5.2f + %5.2f = %5.2f ns \n",fFECDelay, fGTDelay, fTriggerDelayDB); detail << dformat(" Trigger Gate: %5.2f ns \n", fTriggerGateDB); } void EventBuilderProc::EndOfRun(DS::Run &run) { fUnCal.EndOfRun(run); } void EventBuilderProc::SetI( const string& param, const int value ) { if( param == string( "countpe" ) ) { fCountPEs = (value==1); } } EventBuilderProc::Result EventBuilderProc::DSEvent(DS::Run& run, DS::Entry& ds) { // -- First check that the MC branch does exist. In case of real data it won't exist // Of course, I have no idea why people would run this processor on real data, but // better safe than sorry if (!run.GetMCFlag()) { warn << "EventBuilderProc::DSEvent : There is no MC branch for this Run. Most likely this is real data. Aborting..." << newline; warn << "EventBuilderProc::DSEvent : Check the options in your macro, and your input file." << newline; return Processor::ABORT; } DS::MC& mc = ds.GetMC(); const DU::PMTInfo& pmtInfo = DU::Utility::Get()->GetPMTInfo(); if( fCountPEs) { // This section is intended to be executed only with the GenPMTEff event // generator, which generates events initiated with a photon at the face of // each PMT. It counts the number of PMTs with a photoelectron for which // the beginning of the track of the photon that produced the photoelectron // is within a small distance of the PMT position (the center of the PMT // face). I.e., the photon that generated the photoelectron was created at // the face of the PMT that had the PE. double rConc = RAT::DB::Get()->GetLink( "CONCENTRATOR", "cRAT" )-> GetDArray("rho_coord").back(); // Outer radius of concentrator Int_t nDirect = 0; // No. of PMTs with at least one photoelectron: Int_t nPEPMTs = mc.GetMCPMTCount(); for(Int_t i=0; i totalQs; for (size_t iev=0;iev15)cell=15; mchit.SetCellID(cell); totalQs[iev] += mchit.GetQHS(); //use QHS for this mcev.GetMCHits().AddPMT( mchit, type ); break; } } // If fStore is set to true, we store all the MCHits in the // 'mcUnbuiltHits'. This can be useful when trying to look // at the trigger information, where one wants to look at all // hits for events the triggered and did not trigger the detector. if (!triggered || fStore){ untriggeredMCHits.AddPMT( mchit, type ); } } for (size_t iev=0;iev