/search.css" rel="stylesheet" type="text/css"/> /search.js">
| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

In This Package:

ROsFeeTdcTool.cc
Go to the documentation of this file.
00001 #include "ROsFeeTdcTool.h"
00002 
00003 #include "Conventions/Detectors.h"
00004 #include "Conventions/Electronics.h"
00005 #include "Conventions/Trigger.h"
00006 #include "Conventions/Site.h"
00007 
00008 #include "Event/SimReadoutHeader.h"
00009 #include "Event/ReadoutPmtCrate.h"
00010 
00011 #include "Event/ElecCrateHeader.h"
00012 #include "Event/ElecFeeCrate.h"
00013 #include "Event/ElecFeeChannel.h"
00014 
00015 #include "Event/SimTrigCommand.h"
00016 #include "Event/SimTrigCommandHeader.h"
00017 #include "Event/SimTrigCommandCollection.h"
00018 
00019 #include <set>
00020 #include <vector>
00021 
00022 #include "TF1.h"
00023 
00024 ROsFeeTdcTool::ROsFeeTdcTool(const std::string& type,
00025              const std::string& name, 
00026              const IInterface* parent)
00027   : GaudiTool(type,name,parent)
00028 {
00029   declareInterface< IROsFeeTdcTool >(this) ;
00030 
00031   declareProperty("UseMultiHitTdc",m_multiHitTdc=true,
00032                   "Allow multi-hit TDC functionality?");
00033   declareProperty("MultiLimit",m_multiLimit=5,
00034                   "Number of allowed TDC's in one readout");
00035   declareProperty("TdcResetCycles",m_tdcResetCycles=32,
00036                   "Reset Time on the TDC, in TDC counts (640 MHz)");
00037 }
00038 
00039 ROsFeeTdcTool::~ROsFeeTdcTool(){}
00040 
00041 StatusCode ROsFeeTdcTool::initialize()
00042 {
00043   m_fun = new TF1("f","-4845.33-337.431*x+13.1919*x*x-0.0950649*x*x*x",52,78);
00044   return StatusCode::SUCCESS;
00045 }
00046 
00047 StatusCode ROsFeeTdcTool::finalize()
00048 {
00049   return StatusCode::SUCCESS;
00050 }
00051 
00052 StatusCode ROsFeeTdcTool::readoutTdc(const std::vector<int>& tdc_in,
00053              unsigned int first_cycle,
00054              unsigned int last_cycle,
00055              std::vector<int>& tdc_out)
00056 {
00057     verbose() << "reading out tdc window ["
00058               << first_cycle << "," << last_cycle << ")" << endreq;
00059 
00060     if(tdc_out.size()>0) tdc_out.clear();
00061     
00062     // Select TDC values for readout
00063     std::vector<int>::const_iterator tdcIt;
00064     int prevTdcCycle = -2;
00065     int prevReadoutTdcCycle = -1000;
00066     for(tdcIt = tdc_in.begin(); tdcIt != tdc_in.end(); ++tdcIt){
00067       int tdcCycle= *tdcIt;
00068       // Skip TDC value if the signal has not dropped below threshold since last crossing
00069       if(tdcIt != tdc_in.begin())
00070         if( tdcCycle-*(tdcIt-1) == 1 ) {prevTdcCycle = tdcCycle; continue;} 
00071       // Skip TDC value if it is too close to previous threshold crossing
00072       double tdcReset = m_fun->GetRandom()/1.5625;
00073       if( (tdcCycle-prevReadoutTdcCycle)< (int)tdcReset ) {prevTdcCycle = tdcCycle; continue;}
00074       //if( (tdcCycle-prevReadoutTdcCycle)<m_tdcResetCycles ) {prevTdcCycle = tdcCycle; continue;}
00075       prevReadoutTdcCycle = tdcCycle;
00076       // Check if current TDC is in the readout window
00077       if( tdcCycle >= (int)first_cycle && tdcCycle < (int)last_cycle ){ 
00078         tdc_out.push_back(tdcCycle);
00079         // If multi-hit TDC is disabled, don't consider any more tdc values
00080         if( !m_multiHitTdc ) break;
00081         // If it reaches the number of tdc's limit, leave this.
00082         if( tdc_out.size() >= m_multiLimit ) break;
00083       }
00084       prevTdcCycle = tdcCycle;
00085     }
00086 
00087     verbose() << "      NTDC = " << tdc_out.size() << endreq; 
00088     
00089     return StatusCode::SUCCESS;
00090 }
| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

Generated on Fri May 16 2014 10:17:05 for ReadoutSim by doxygen 1.7.4