#include <SimDetector.h>
Public Member Functions | |
SimDetector (VldContext context, TRandom *random=NULL) | |
virtual | ~SimDetector () |
virtual void | Config (Registry &configuration) |
virtual void | Reset (VldContext newContext) |
virtual void | Clean () |
virtual void | AddDigiPEList (const TObjArray *inList) |
virtual void | Simulate (void) |
virtual TRandom * | GetRandom (void) |
virtual int | GetNumberOfDigits (void) |
virtual SimDigit * | GetSimDigit (UInt_t ihit) |
virtual std::vector< SimSnarl > & | GetSnarlList () |
virtual UInt_t | GetNumberOfSnarls () |
virtual const SimSnarl & | GetSnarl (UInt_t i) |
virtual UInt_t | GetBiggestSnarl () |
virtual Int_t | GetTotalTriggerWord (void) const |
virtual Bool_t | IsTriggering (void) const |
virtual Bool_t | IsTriggered (void) const |
virtual void | Print (Option_t *option="") const |
virtual SimEventResult & | GetEventResult () |
virtual Double_t | GetTimeShift () const |
Static Public Member Functions | |
static Registry & | DefaultConfig (void) |
Protected Member Functions | |
virtual void | DistributePEs (void) |
virtual void | SortDigiPE (const DigiPE *digipe) |
virtual void | SimulatePmts (void) |
virtual void | SimulateElectronics (void) |
virtual void | SimulateTrigger (void) |
virtual void | CompileStats (void) |
virtual Int_t | IsWindowBurst (SimDigitList &digitList, UInt_t startdigit) |
virtual Int_t | IsGapBurst (SimDigitList &digitList, UInt_t startdigit) |
virtual UInt_t | GetTubeIndex (PlexPixelSpotId psid) |
void | AdjustTimeWithinSec (SimDigitList &digitList) |
ClassDef (SimDetector, 2) | |
Protected Attributes | |
VldContext | fContext |
PlexHandle | fPlex |
TRandom * | fRandom |
Int_t | fClearPmtList |
Int_t | fAddTimeWithinSec |
std::string | fM16Model |
std::string | fM64Model |
std::string | fFarElecModel |
std::string | fNearElecModel |
Int_t | fApplyTrigger |
Int_t | fDaqTrigTimingMethod |
Double_t | fDaqTrigTimeGap |
Double_t | fDaqTrigTimeWindow |
Double_t | fDaqTrigReadoutWindowStart |
Double_t | fDaqTrigReadoutWindowStop |
Int_t | fDaqTriggerMask |
SimDaqTrigger * | fDaqTriggers [kSimMaxTriggers] |
const TObjArray * | fPeList |
Double_t | fTimeShift |
SimElectronics * | fFarElectronics |
SimElectronics * | fNearElectronics |
SimPmtList | fPmts |
SimPmtList | fActivePmts |
SimDigitList | fDigits |
Int_t | fTotalTriggerWord |
UInt_t | fHitPlane [kSimMaxPlane] |
UInt_t | fSigHitPlane [kSimMaxPlane] |
Int_t | fAdcPlane [kSimMaxPlane] |
Int_t | fFirstPlane |
Int_t | fLastPlane |
std::vector< SimSnarl > | fSnarls |
UInt_t | fBiggestSnarl |
Int_t | fBiggestSnarlSize |
DigiList< DigiPE > | fDigiPeStorage |
SimEventResult | fResult |
Definition at line 45 of file SimDetector.h.
SimDetector::SimDetector | ( | VldContext | context, | |
TRandom * | random = NULL | |||
) |
Definition at line 24 of file SimDetector.cxx.
References SimElecMaker::Create(), Msg::kDebug, kSimMaxTriggers, and MSG.
00024 : 00025 fContext(context), 00026 fPlex(context), 00027 fRandom(random), 00028 fTimeShift(0), 00029 fFarElectronics(NULL), 00030 fNearElectronics(NULL), 00031 fFirstPlane(0), 00032 fLastPlane(0), 00033 fBiggestSnarl(0), 00034 fBiggestSnarlSize(0) 00035 { 00036 if(fRandom ==NULL) { 00037 fRandom = gRandom; 00038 } 00039 00040 // Hardwire the configuration defaults to the safest. 00041 fClearPmtList = 0; 00042 fM64Model = "SimPmtM64Full"; 00043 fM16Model = "SimPmtUTM16"; 00044 fFarElecModel = "SimVaElectronics"; 00045 fNearElecModel = "SimQieElectronics"; 00046 00047 // Electronics. 00048 fFarElectronics = SimElecMaker::Create(fFarElecModel,context,fRandom); 00049 fNearElectronics = SimElecMaker::Create(fNearElecModel,context,fRandom); 00050 00051 fDaqTriggerMask = 0xFF; 00052 for(int i=0;i<kSimMaxTriggers;i++) 00053 fDaqTriggers[i] = 0; 00054 00055 MSG("DetSim",Msg::kDebug) << "SimDetector::Constructor. Context: " << fContext.AsString() << endl; 00056 00057 gDetector = this; 00058 }
SimDetector::~SimDetector | ( | void | ) | [virtual] |
Definition at line 60 of file SimDetector.cxx.
References fActivePmts, fDigits, fFarElectronics, fNearElectronics, fPmts, and it.
00061 { 00062 if(fFarElectronics) delete fFarElectronics; 00063 if(fNearElectronics) delete fNearElectronics; 00064 00065 // Wipe digit list. 00066 fDigits.clear(); 00067 00068 // Wipe pmt list. 00069 SimPmtList::iterator it; 00070 for(it = fPmts.begin(); it!= fPmts.end(); it++) { 00071 if(it->second) delete it->second; 00072 fPmts.erase(it); 00073 } 00074 fPmts.clear(); 00075 fActivePmts.clear(); 00076 }
void SimDetector::AddDigiPEList | ( | const TObjArray * | inList | ) | [virtual] |
Adds a list of DigiPEs to the simulation. Shifts the DigiPEs by the proscribed amount.
Definition at line 350 of file SimDetector.cxx.
References fPeList, Msg::kWarning, and MAXMSG.
Referenced by DetSim::Get().
00351 { 00356 00357 fPeList = peListObj; 00358 if (!fPeList) { 00359 MAXMSG("DetSim",Msg::kWarning,10) 00360 << "Null PE list input into SimDetector.. might crash if not expected." 00361 << endl; 00362 } 00363 }
void SimDetector::AdjustTimeWithinSec | ( | SimDigitList & | digitList | ) | [protected] |
Definition at line 918 of file SimDetector.cxx.
References digit(), fContext, fTimeShift, VldTimeStamp::GetNanoSec(), SimDigit::GetRawChannelId(), SimDigit::GetTDC(), Calibrator::GetTDCFromTime(), VldContext::GetTimeStamp(), Calibrator::Instance(), Msg::kDebug, Msg::kWarning, MAXMSG, Munits::ns, SimDigit::SetTDC(), and SimDigitList::Size().
00919 { 00920 // Adjusting Digit TDCs for time within the VldContext second 00921 00922 if ( digitList.Size() == 0 ) return; // nothing to do 00923 00924 // use the first digit info to determine what to add to everyone 00925 SimDigit& digit0 = digitList[0]; 00926 RawChannelId rcid = digit0.GetRawChannelId(); 00927 00928 int ns = fContext.GetTimeStamp().GetNanoSec(); 00929 00930 MAXMSG("DetSim",Msg::kDebug,10) << "#slew fTimeShift " << fTimeShift 00931 << " from VldContext ns " << ns << std::endl; 00932 00933 double toffset = ns * Munits::ns; // convert to Munits 00934 toffset -= fTimeShift; // undo effect of trying to make all digits positive 00935 if ( toffset < 0 ) { 00936 MAXMSG("DetSim",Msg::kWarning,10) << "Failed to fully undo fTimeShift " 00937 << fTimeShift << " from VldContext ns " 00938 << ns << std::endl; 00939 toffset = 0; // well, we can't fully in some cases 00940 } 00941 00942 Int_t add2TDC = Calibrator::Instance().GetTDCFromTime(toffset,rcid); 00943 00944 for (size_t i=0; i<digitList.size(); ++i) { 00945 SimDigit& digit = digitList[i]; 00946 Int_t newTDC = digit.GetTDC() + add2TDC; 00947 digit.SetTDC(newTDC); 00948 } 00949 }
SimDetector::ClassDef | ( | SimDetector | , | |
2 | ||||
) | [protected] |
void SimDetector::Clean | ( | ) | [virtual] |
Definition at line 335 of file SimDetector.cxx.
void SimDetector::CompileStats | ( | void | ) | [protected, virtual] |
Definition at line 807 of file SimDetector.cxx.
References SimEventResult::adcsAfterDaqTrigger, SimEventResult::adcsAfterFETrigger, SimEventResult::adcsAfterSpars, SimEventResult::bigSnarl, SimEventResult::digitsAfterDaqTrigger, SimEventResult::digitsAfterFETrigger, SimEventResult::digitsAfterSpars, fActivePmts, fFarElectronics, fNearElectronics, fResult, fSnarls, fTimeShift, SimDigit::GetADC(), SimElectronics::GetAdcsAfterSpars(), GetBiggestSnarl(), SimElectronics::GetDigitsAfterFETrigger(), SimElectronics::GetDigitsAfterSpars(), GetNumberOfSnarls(), SimPmt::GetTotalCharge(), SimPmt::GetTotalHitPixels(), SimPmt::GetTotalPe(), SimEventResult::hitPixels, SimEventResult::hitPixelsWithXtalk, it, SimEventResult::Reset(), SimEventResult::snarl_adcs, SimEventResult::snarl_digits, SimEventResult::snarl_trigger, SimEventResult::snarls, SimEventResult::timeShift, SimEventResult::totalCharge, and SimEventResult::totalPe.
Referenced by Simulate().
00808 { 00809 fResult.Reset(); 00810 00811 // PMT statistics: 00812 SimPmtList::iterator it; 00813 for(it = fActivePmts.begin(); it!= fActivePmts.end(); it++) { 00814 SimPmt* pmt = it->second; 00815 if(pmt){ 00816 fResult.totalPe += pmt->GetTotalPe(); 00817 fResult.hitPixels += pmt->GetTotalHitPixels(false); 00818 fResult.hitPixelsWithXtalk += pmt->GetTotalHitPixels(true); 00819 fResult.totalCharge += pmt->GetTotalCharge(); 00820 } 00821 } 00822 00823 // Electronics: 00824 if(fFarElectronics) { 00825 fResult.digitsAfterFETrigger+=( fFarElectronics->GetDigitsAfterFETrigger() ); 00826 fResult.adcsAfterFETrigger+=( fFarElectronics-> GetAdcsAfterFETrigger() ); 00827 fResult.digitsAfterSpars+=( fFarElectronics->GetDigitsAfterSpars() ); 00828 fResult.adcsAfterSpars+=( fFarElectronics->GetAdcsAfterSpars() ); 00829 } 00830 00831 // Generic ND electronics: 00832 if(fNearElectronics) { 00833 fResult.digitsAfterFETrigger+=( fNearElectronics->GetDigitsAfterFETrigger() ); 00834 fResult.adcsAfterFETrigger+=( fNearElectronics-> GetAdcsAfterFETrigger() ); 00835 fResult.digitsAfterSpars+=( fNearElectronics->GetDigitsAfterSpars() ); 00836 fResult.adcsAfterSpars+=( fNearElectronics->GetAdcsAfterSpars() ); 00837 } 00838 00839 // Snarls. 00840 fResult.snarls = GetNumberOfSnarls(); 00841 00842 // Create arrays. 00843 fResult.snarl_digits = new Int_t[ fResult.snarls ]; 00844 fResult.snarl_trigger = new Int_t[ fResult.snarls ]; 00845 fResult.snarl_adcs = new Float_t[ fResult.snarls ]; 00846 00847 fResult.bigSnarl= GetBiggestSnarl(); 00848 00849 // Loop through snarls. Fill all the stats. 00850 for(UInt_t isnarl = 0; isnarl < fSnarls.size(); isnarl++) { 00851 Float_t adctot = 0; 00852 for(UInt_t i=0; i<fSnarls[isnarl].size(); i++) { 00853 SimDigit& simdigit = fSnarls[isnarl][i]; 00854 00855 adctot+= simdigit.GetADC() ; 00856 } 00857 00858 // totals. 00859 fResult.digitsAfterDaqTrigger+=( fSnarls[isnarl].Size() ); 00860 fResult.adcsAfterDaqTrigger+=( adctot ); 00861 00862 fResult.snarl_digits[isnarl] = fSnarls[isnarl].Size(); 00863 fResult.snarl_trigger[isnarl] = fSnarls[isnarl].GetTriggerSource(); 00864 fResult.snarl_adcs[isnarl] = adctot; 00865 } 00866 00867 fResult.timeShift = fTimeShift; 00868 00869 }
void SimDetector::Config | ( | Registry & | configuration | ) | [virtual] |
Definition at line 200 of file SimDetector.cxx.
References SimElectronics::Config(), SimPmt::Config(), SimDaqTrigger::Configure(), SimElecMaker::Create(), SimPmtMaker::Create(), SimDaqTrigMaker::Create(), fAddTimeWithinSec, fApplyTrigger, fClearPmtList, fContext, fDaqTriggerMask, fDaqTriggers, fDaqTrigReadoutWindowStart, fDaqTrigReadoutWindowStop, fDaqTrigTimeGap, fDaqTrigTimeWindow, fDaqTrigTimingMethod, fFarElecModel, fFarElectronics, fM16Model, fM64Model, fNearElecModel, fNearElectronics, Form(), fRandom, Registry::Get(), SimPmtMaker::HasRegisteredClass(), SimElecMaker::HasRegisteredClass(), Msg::kError, kSimMaxTriggers, and MSG.
Referenced by DetSim::Config(), and DetSim::Get().
00201 { 00202 // Modify the configuration. 00203 const char* s; 00204 00205 //-- Operational concerns. 00206 config.Get("clearPmtList",fClearPmtList); 00207 00208 //-- Determine should we be adding in offset within 1sec? 00209 config.Get("addTimeWithinSec",fAddTimeWithinSec); 00210 00211 //-- Pmt models. 00212 config.Get("M64Model",s); 00213 if(SimPmtMaker::HasRegisteredClass(s)) fM64Model = s; 00214 else 00215 MSG("DetSim",Msg::kError) << "M64 Pmt Model " << s 00216 << " is not known. Reverting to default." << endl; 00217 00218 config.Get("M16Model",s); fM16Model = s; 00219 if(SimPmtMaker::HasRegisteredClass(s)) fM16Model = s; 00220 else 00221 MSG("DetSim",Msg::kError) << "M16 Pmt Model " << s 00222 << " is not known. Reverting to default." << endl; 00223 00224 // Create dummy versions of the PMT to configure the model (with static functions) 00225 SimPmt* m16 = SimPmtMaker::Create(fM16Model,PlexPixelSpotId(), 00226 fContext,fRandom); 00227 m16->Config(config); 00228 delete m16; 00229 00230 SimPmt* m64 = SimPmtMaker::Create(fM64Model,PlexPixelSpotId(), 00231 fContext,fRandom); 00232 m64->Config(config); 00233 delete m64; 00234 00235 //-- Recreate and configure the electronics models. 00236 config.Get("farElecModel",s); 00237 if(SimElecMaker::HasRegisteredClass(s)) fFarElecModel = s; 00238 else 00239 MSG("DetSim",Msg::kError) << "Far Detector Electronics Model " << s 00240 << " is not known. Reverting to default." << endl; 00241 config.Get("nearElecModel",s); 00242 if(SimElecMaker::HasRegisteredClass(s)) fNearElecModel = s; 00243 else 00244 MSG("DetSim",Msg::kError) << "Near Detector Electronics Model " << s 00245 << " is not known. Reverting to default." << endl; 00246 00247 // Gentlemen, we can rebuild him.. 00248 if(fFarElectronics) delete fFarElectronics; 00249 if(fNearElectronics) delete fNearElectronics; 00250 fFarElectronics = SimElecMaker::Create(fFarElecModel, fContext,fRandom); 00251 fNearElectronics = SimElecMaker::Create(fNearElecModel,fContext,fRandom); 00252 // And boot them. 00253 fFarElectronics ->Config(config); 00254 fNearElectronics->Config(config); 00255 00256 //-- Triggers. 00257 config.Get("applyTrigger", fApplyTrigger); 00258 config.Get("daqTrigTimingMethod", fDaqTrigTimingMethod); 00259 config.Get("daqTrigTimeGap", fDaqTrigTimeGap); 00260 config.Get("daqTrigTimeWindow", fDaqTrigTimeWindow); 00261 config.Get("daqTrigReadoutWindowStart",fDaqTrigReadoutWindowStart); 00262 config.Get("daqTrigReadoutWindowStop", fDaqTrigReadoutWindowStop); 00263 config.Get("daqTriggerMask", fDaqTriggerMask); 00264 00265 // Rebuild trigger list. 00266 Registry trigConfig; 00267 for(int itrig = 0; itrig<kSimMaxTriggers; itrig++) { 00268 if(fDaqTriggers[itrig]) delete fDaqTriggers[itrig]; // Delete old ones. 00269 fDaqTriggers[itrig] = 0; 00270 00271 if( config.Get(Form("trigger%d",itrig),trigConfig) ) { 00272 const char* triggerType = 0; 00273 if( trigConfig.Get("type",triggerType) ) { 00274 fDaqTriggers[itrig] = SimDaqTrigMaker::Create(triggerType); 00275 if(fDaqTriggers[itrig]) { 00276 fDaqTriggers[itrig]->Configure(trigConfig); 00277 } else { 00278 MSG("DetSim",Msg::kError) << "Trigger " << itrig << ": type=" << triggerType << " not known!" << endl; 00279 } 00280 } 00281 } 00282 } 00283 00284 }
Registry & SimDetector::DefaultConfig | ( | void | ) | [static] |
Definition at line 78 of file SimDetector.cxx.
References Munits::fC, Form(), Registry::Get(), Munits::hertz, SimVarcTriggerMode::k2of36, SimTimeSmearingMode::kBreitWigner, SimDaqTrigger::kGap, kSimMaxTriggers, Munits::microsecond, Munits::ns, Registry::Set(), and Registry::UnLockValues().
Referenced by DetSim::DetSim().
00079 { 00080 // Supply default configuration. 00081 static Registry r; // Default configuration for module 00082 00083 // Set name of config 00084 std::string name = "SimDetector.config.default"; 00085 r.SetName(name.c_str()); 00086 00087 // Set values in configuration 00088 r.UnLockValues(); 00089 00090 r.Set("clearPmtList",0); 00091 r.Set("addTimeWithinSec",0); // by default: no (original behaviour) 00092 00093 // PMT model 00094 r.Set("M64Model","SimPmtM64Oxford"); 00095 r.Set("M16Model","SimPmtM16UTTimed"); 00096 r.Set("pmtM16DefaultGain",60); // Used by decalibrator 00097 r.Set("pmtM64DefaultGain",100); // ditto 00098 r.Set("pmtDoOpticalCrosstalk",1); 00099 r.Set("pmtDoChargeCrosstalk",1); 00100 r.Set("pmtDoNonlinearity",0); 00101 r.Set("pmtDoDarkNoise",1); 00102 r.Set("pmtApplyGainDrift",0); // 0 = Trust PMT gains. 00103 r.Set("pmtScaleOpticalCrosstalk",1.0); 00104 r.Set("pmtScaleChargeCrosstalk",1.0); 00105 //Added by G. Pawloski to scale Adjacent and Diagonal separately 00106 r.Set("pmtScaleAdjacentChargeCrosstalk",1.0); 00107 r.Set("pmtScaleDiagonalChargeCrosstalk",1.0); 00108 r.Set("pmtScaleAdjacentOpticalCrosstalk",1.0); 00109 r.Set("pmtScaleDiagonalOpticalCrosstalk",1.0); 00110 r.Set("pmtHamamatsuPixelNumbering",0); 00111 r.Set("pmtChargeSlop",1.6); 00112 r.Set("pmtDoChargeSmear",1); 00113 r.Set("pmtM64DynodeSkipRate",0.00); 00114 r.Set("pmtM64NLThreshold",3.0); 00115 r.Set("pmtM64NonlinearityScale",1.0); 00116 r.Set("pmtRebuildGainMap",0); 00117 00118 // Electronics. 00119 r.Set("farElecModel", "SimVaTimedElectronics"); 00120 r.Set("nearElecModel","SimQieElectronics"); 00121 r.Set("doLookupNonlinearity",1); 00122 00123 // FD front end 00124 r.Set("vaGain", 0.375/Munits::fC ); 00125 r.Set("vaPedWidth", 2.8); 00126 r.Set("vaTimeSmearingMode", SimTimeSmearingMode::kBreitWigner); 00127 r.Set("vaTimingWidth", 0.); 00128 r.Set("vaSparsifyThresh", 17); 00129 r.Set("vaDynodeThresh", 57); 00130 r.Set("vaNonlinearity",1); 00131 r.Set("vaLinearityP0",24.); 00132 r.Set("vaLinearityP1",16091.3); 00133 r.Set("vaLinearityP2",4.63); 00134 r.Set("vaLinearityP3",13267.); 00135 r.Set("vaLinearityP4",7085.12); 00136 00137 // FD back end 00138 r.Set("varcTriggerMode", SimVarcTriggerMode::k2of36); // 2 out of 36. 00139 r.Set("varcTriggerWindow", 400.*Munits::ns); 00140 r.Set("vaChipRandomDeadRate",700.*Munits::hertz); 00141 r.Set("vaChipDeadTime",5*Munits::microsecond); 00142 r.Set("vaShapingTime",500.*Munits::ns); 00143 00144 // ND front end. 00145 r.Set("qieDoLookukp",1); // Turn on lookup table. 00146 r.Set("qieDacCharge",1.4*Munits::fC); // Charge for one DAC count. Charge is in Munits (Coulombs) 00147 r.Set("qieDaqPerRangeZeroAac",1.6); // DAC counts per ADC in range 0 00148 r.Set("qieFlipLowAdc",30.); // Point at which the range flips 00149 r.Set("qieFlipHighAdc",180.); // Point at which the range flips 00150 r.Set("qiePedestalWidthAdc",1.5); // RMS of pedestal in ADC counts 00151 r.Set("qieAdcRms",0.0); // RMS of a large charge in ADC counts 00152 r.Set("qiePedestalDac",50); // Pedestal in DAC counts. 00153 r.Set("qieSparsifyThresh",70); // Sparsification threshold (should be larger than pedestal!) 00154 00155 // Daq trigger 00156 r.Set("applyTrigger",3); 00157 r.Set("daqTrigTimingMethod",SimDaqTrigger::kGap); 00158 r.Set("daqTrigTimeGap",156.0*Munits::ns); 00159 r.Set("daqTrigTimeWindow",117.0*Munits::ns); 00160 r.Set("daqTrigReadoutWindowStart",5500.*Munits::ns); // Pretrigger window, ns 00161 r.Set("daqTrigReadoutWindowStop",187*Munits::ns); // Posttrigger window, ns 00162 r.Set("daqTriggerMask",0xFF); 00163 00164 // Bit 2 (hex 0x04) 00165 // Standard 4 out of 5 trigger 00166 Registry trigger2; 00167 trigger2.SetName("trigger2"); 00168 trigger2.Set("type","PlaneTrigger"); 00169 trigger2.Set("thresh",0.0); 00170 trigger2.Set("N",4); 00171 trigger2.Set("M",5); 00172 r.Set("trigger2",trigger2); 00173 00174 // Bit 5 (hex 0x20) 00175 // Standard energy trigger: 00176 // In a 4-plane window, demand 00177 // >=1500 ADCs, planes hit >= 2, N_hits >= 6 00178 Registry trigger5; 00179 trigger5.SetName("trigger5"); 00180 trigger5.Set("type","EnergyTrigger"); 00181 trigger5.Set("thresh",1500.); 00182 trigger5.Set("Nhits",6); 00183 trigger5.Set("N",2); 00184 trigger5.Set("M",4); 00185 r.Set("trigger5",trigger5); 00186 00187 // Add a whole bunch more triggers to be filled by the user. 00188 // This adds empty registries that can easily be modified. 00189 for(int i=0;i<kSimMaxTriggers;i++) { 00190 Registry triggerN; 00191 if(!(r.Get(Form("trigger%d",i),triggerN))) { 00192 triggerN.SetName(Form("trigger%d",i)); 00193 r.Set(Form("trigger%d",i),triggerN); 00194 } 00195 } 00196 00197 return r; 00198 }
void SimDetector::DistributePEs | ( | void | ) | [protected, virtual] |
Definition at line 466 of file SimDetector.cxx.
References fPeList, fTimeShift, DigiPE::GetTime(), Msg::kWarning, MAXMSG, Munits::ns, and SortDigiPE().
Referenced by Simulate().
00467 { 00468 // nothing to do, if no input ... but allow for creation of empty event 00469 if ( ! fPeList ) return; 00470 00471 TObjArrayIter itr(fPeList); 00472 const DigiPE* digipe = NULL; 00473 double earlyTime = 1e10; 00474 while( (digipe = dynamic_cast<DigiPE*>(itr.Next()))!=0 ) { 00475 if(digipe->GetTime()<earlyTime) earlyTime = digipe->GetTime(); 00476 } 00477 00478 // find the timeshift. 00479 fTimeShift = 0; 00480 if(earlyTime<0) { 00481 while((earlyTime+fTimeShift)<0) fTimeShift+=100.*Munits::ns; 00482 MAXMSG("DetSim",Msg::kWarning,10) 00483 << "Negative times in PE list. Shifting all times forward by " 00484 << fTimeShift/Munits::ns << " ns" << endl; 00485 } 00486 00487 // 00488 // Shift all the times. 00489 // 00490 itr.Reset(); 00491 while( (digipe = dynamic_cast<DigiPE*>(itr.Next()))!=0 ) { 00492 if(fTimeShift>0) { 00493 // Hack to get times all positive. 00494 const_cast<DigiPE*>(digipe)->SetTime(digipe->GetTime() + fTimeShift); 00495 } 00496 00497 // Add the hit in. 00498 this->SortDigiPE( digipe ); 00499 } 00500 00501 }
virtual UInt_t SimDetector::GetBiggestSnarl | ( | ) | [inline, virtual] |
Definition at line 66 of file SimDetector.h.
References fBiggestSnarl.
Referenced by CompileStats(), and DetSim::Get().
00066 { return fBiggestSnarl; };
virtual SimEventResult& SimDetector::GetEventResult | ( | ) | [inline, virtual] |
Definition at line 74 of file SimDetector.h.
References fResult.
Referenced by DetSim::Ana(), and DetSim::Get().
00074 { return fResult; };
int SimDetector::GetNumberOfDigits | ( | void | ) | [virtual] |
Definition at line 375 of file SimDetector.cxx.
References fDigits.
Referenced by DetSim::Get().
00376 { 00377 return fDigits.size(); 00378 }
virtual UInt_t SimDetector::GetNumberOfSnarls | ( | ) | [inline, virtual] |
Definition at line 64 of file SimDetector.h.
References fSnarls.
Referenced by CompileStats(), and DetSim::Get().
00064 { return fSnarls.size(); };
virtual TRandom* SimDetector::GetRandom | ( | void | ) | [inline, virtual] |
Definition at line 58 of file SimDetector.h.
References fRandom.
Referenced by DetSim::Get().
00058 { return fRandom; };
SimDigit * SimDetector::GetSimDigit | ( | UInt_t | ihit | ) | [virtual] |
virtual const SimSnarl& SimDetector::GetSnarl | ( | UInt_t | i | ) | [inline, virtual] |
Definition at line 65 of file SimDetector.h.
References fSnarls.
Referenced by DetSim::Get().
00065 { return fSnarls[i]; };
virtual std::vector<SimSnarl>& SimDetector::GetSnarlList | ( | ) | [inline, virtual] |
Definition at line 63 of file SimDetector.h.
References fSnarls.
Referenced by DetSim::Get().
00063 { return fSnarls; };
virtual Double_t SimDetector::GetTimeShift | ( | ) | const [inline, virtual] |
Definition at line 76 of file SimDetector.h.
References fTimeShift.
Referenced by DetSim::CalculateAddTDC().
00076 { return fTimeShift; }
virtual Int_t SimDetector::GetTotalTriggerWord | ( | void | ) | const [inline, virtual] |
Definition at line 68 of file SimDetector.h.
References fTotalTriggerWord.
00068 { return fTotalTriggerWord; };
virtual UInt_t SimDetector::GetTubeIndex | ( | PlexPixelSpotId | psid | ) | [inline, protected, virtual] |
Definition at line 92 of file SimDetector.h.
References PlexPixelSpotId::GetUniquePmtEncodedValue().
Referenced by SortDigiPE().
00093 { return psid.GetUniquePmtEncodedValue(); };
Int_t SimDetector::IsGapBurst | ( | SimDigitList & | digitList, | |
UInt_t | startdigit | |||
) | [protected, virtual] |
Definition at line 892 of file SimDetector.cxx.
References fDaqTrigTimeGap, fDigits, and SimDigitList::GoodSize().
Referenced by SimulateTrigger().
00894 { 00895 // See if startdigit is the start of a gap trigger. 00896 00897 // The first digit is always at a gap. Further digits are not at a gap start 00898 // if they are too far separated from the previous one. 00899 if(startdigit!=0) { 00900 Double_t t1 = fDigits[startdigit-1].GetTime(); 00901 Double_t t2 = fDigits[startdigit].GetTime(); 00902 if (t2-t1 < fDaqTrigTimeGap) 00903 return 0; // Not the start of a gap. 00904 } 00905 00906 // Look for gap end. 00907 Int_t ndigs = 1; 00908 while(startdigit+ndigs < digitList.GoodSize()) { 00909 Double_t t1 = fDigits[startdigit+ndigs-1].GetTime(); 00910 Double_t t2 = fDigits[startdigit+ndigs].GetTime(); 00911 if(t2-t1 >= fDaqTrigTimeGap) return ndigs; 00912 ndigs++; 00913 } 00914 return ndigs; 00915 00916 }
Bool_t SimDetector::IsTriggered | ( | void | ) | const [inline, virtual] |
Definition at line 175 of file SimDetector.h.
References fDaqTriggerMask, fTotalTriggerWord, and IsTriggering().
00176 { 00177 return (! IsTriggering() )||(fTotalTriggerWord & fDaqTriggerMask); 00178 }
Bool_t SimDetector::IsTriggering | ( | void | ) | const [inline, virtual] |
Definition at line 165 of file SimDetector.h.
References fApplyTrigger, fContext, VldContext::GetDetector(), and Detector::kFar.
Referenced by IsTriggered().
00166 { 00167 if(fApplyTrigger==0) return false; 00168 if(fApplyTrigger==3) { 00169 if(fContext.GetDetector()==Detector::kFar) return true; 00170 return false; 00171 } 00172 return true; 00173 }
Int_t SimDetector::IsWindowBurst | ( | SimDigitList & | digitList, | |
UInt_t | startdigit | |||
) | [protected, virtual] |
Definition at line 872 of file SimDetector.cxx.
References fDaqTrigTimeWindow, fDigits, and SimDigitList::GoodSize().
Referenced by SimulateTrigger().
00874 { 00875 // Assign a winow at startdigit. 00876 00877 // Note: assumes fDaqTrigTimeWindow in TDC units 00878 // Assumes all electronics identitcal. 00879 Double_t t_start = digitList[startdigit].GetTime(); 00880 Double_t t_stop = t_start + fDaqTrigTimeWindow; 00881 00882 Int_t ndigs = 1; 00883 while(startdigit+ndigs < digitList.GoodSize()) { 00884 Double_t t = fDigits[startdigit+ndigs-1].GetTime(); 00885 if(t>t_stop) break; 00886 ndigs++; 00887 } 00888 return ndigs; 00889 }
void SimDetector::Print | ( | Option_t * | option = "" |
) | const [virtual] |
Definition at line 388 of file SimDetector.cxx.
References bfld::AsString(), VldContext::AsString(), fActivePmts, fContext, fDaqTriggerMask, fDaqTriggers, fDaqTrigReadoutWindowStart, fDaqTrigReadoutWindowStop, fDaqTrigTimeGap, fDaqTrigTimeWindow, fDaqTrigTimingMethod, fDigits, fFarElectronics, fM16Model, fM64Model, fNearElectronics, fPmts, fResult, fSnarls, fTotalTriggerWord, it, SimDaqTrigger::kGap, kSimMaxTriggers, Munits::ns, SimElectronics::Print(), SimDaqTrigger::Print(), SimPmt::Print(), SimEventResult::Print(), SimPmt::PrintConfig(), and size.
Referenced by DetSim::Get(), and DetSim::Report().
00389 { 00390 std::string opt = option; 00391 Bool_t verbose = (opt.find("v") != std::string::npos);; 00392 Bool_t showpmts = (opt.find("p") != std::string::npos);; 00393 Bool_t showdigits = (opt.find("d") != std::string::npos);; 00394 Bool_t showsnarldigits = (opt.find("s") != std::string::npos);; 00395 00396 if(verbose) { 00397 showpmts = showdigits = showsnarldigits = true; 00398 } 00399 00400 printf("SimDetector:"); 00401 printf("Current context: %s\n",fContext.AsString()); 00402 printf("---------Config------------------------------\n"); 00403 printf("PMT sim: M16Model %s\n",fM16Model.c_str()); 00404 printf(" M64Model %s\n",fM64Model.c_str()); 00405 SimPmt::PrintConfig(); 00406 if(fFarElectronics) fFarElectronics->Print(); 00407 if(fNearElectronics) fNearElectronics->Print(); 00408 printf("Triggers: fDaqTriggerMask 0x%x\n",fDaqTriggerMask); 00409 printf(" fDaqTrigTimingMethod %s\n", 00410 (fDaqTrigTimingMethod==SimDaqTrigger::kGap)?"Gap":"Window"); 00411 printf(" fDaqTrigTimeGap %f ns\n",fDaqTrigTimeGap/Munits::ns); 00412 printf(" fDaqTrigTimeWindow %f ns\n",fDaqTrigTimeWindow/Munits::ns); 00413 printf(" fDaqTrigReadoutWindowStart %f ns\n",fDaqTrigReadoutWindowStart/Munits::ns); 00414 printf(" fDaqTrigReadoutWindowStop %f ns\n",fDaqTrigReadoutWindowStop/Munits::ns); 00415 00416 for(int itrig=0;itrig<kSimMaxTriggers;itrig++) { 00417 if(fDaqTriggers[itrig]) { 00418 printf(" -- Trigger %2d: --\n",itrig); 00419 fDaqTriggers[itrig]->Print(option); 00420 } 00421 } 00422 printf("---------PMTS------------------------------------\n"); 00423 printf(" Total PMTS in memory: %d Active PMTs: %d\n", (int)fPmts.size(),(int)fActivePmts.size()); 00424 SimPmtList::iterator it; 00425 if(showpmts) 00426 for(it = fActivePmts.begin(); it!= fActivePmts.end(); it++) { 00427 SimPmt* pmt = it->second; 00428 if(pmt){ 00429 pmt->Print(option); 00430 } 00431 } 00432 00433 printf("---------Digits----------------------------------\n"); 00434 printf(" Total digits: %d\n",(int)fDigits.size()); 00435 if(showdigits) 00436 for(UInt_t i = 0; i<fDigits.size(); i++) { 00437 printf(" Digit %3d: %s\n",i,fDigits[i].AsString()); 00438 } 00439 for(UInt_t j=0; j < fSnarls.size(); j++ ) { 00440 printf("---------Snarl %d\n",j); 00441 printf(" Digits: %d\n",(int)fSnarls[j].size()); 00442 printf(" Trigger time: %f ns\n",fSnarls[j].GetTriggerTime()/Munits::ns); 00443 printf(" Trigger Source: 0x%08X\n",fSnarls[j].GetTriggerSource()); 00444 if(fSnarls[j].Size()>0) { 00445 printf(" Start time: %f ns\n",fSnarls[j].GetDigit(0)->GetTime()/Munits::ns); 00446 printf(" Stop time: %f ns\n",fSnarls[j].GetDigit(fSnarls[j].Size()-1)->GetTime()/Munits::ns); 00447 } 00448 if(showsnarldigits) 00449 for(UInt_t i = 0; i<fSnarls[j].size(); i++) { 00450 printf(" Digit: %s\n",fSnarls[j][i].AsString()); 00451 } 00452 } 00453 00454 printf("---------DAQ-------------------------------------\n"); 00455 printf(" TriggerWord: 0x%08X\n",fTotalTriggerWord); 00456 printf(" TriggerMask: 0x%08X\n",fDaqTriggerMask); 00457 printf("--------SimEventResult---------------------------\n"); 00458 fResult.Print(); 00459 printf("-------------------------------------------------\n"); 00460 00461 00462 }
void SimDetector::Reset | ( | VldContext | newContext | ) | [virtual] |
Definition at line 287 of file SimDetector.cxx.
References VldContext::AsString(), fActivePmts, fClearPmtList, fContext, fDigiPeStorage, fDigits, fFarElectronics, fNearElectronics, fPlex, fPmts, fSnarls, SimPixelTimeBucket::GetGlobalPixelBuckets(), it, Msg::kDebug, Msg::kError, MSG, SimPmt::Reset(), and SimElectronics::Reset().
Referenced by DetSim::Get().
00288 { 00289 MSG("DetSim",Msg::kDebug) << "SimDetector::Reset. Context: " << fContext.AsString() << endl; 00290 00291 // Wipe digit list. 00292 fDigits.clear(); 00293 fSnarls.clear(); 00294 00295 // Reset the context. 00296 fContext = context; 00297 fPlex = PlexHandle(context); 00298 00299 00300 // Delete all PMTs in list: this means that 'duds' won't eat random numbers. 00301 if(fClearPmtList) { 00302 // The nasty way: delete every PMT every event. 00303 // This is slower, but safer for event-reproducability and heisenbug close encounters 00304 SimPmtList::iterator it; 00305 for(it = fPmts.begin(); it!= fPmts.end(); it++) { 00306 if(it->second) delete it->second; 00307 fPmts.erase(it); 00308 } 00309 fPmts.clear(); 00310 } else { 00311 // Reset all pmts in list. 00312 // Much more efficient and aesthetically pleasing. 00313 SimPmtList::iterator it; 00314 for(it = fPmts.begin(); it!= fPmts.end(); it++) { 00315 SimPmt* pmt = it->second; 00316 pmt->Reset(context); 00317 } 00318 } 00319 00320 fActivePmts.clear(); // Wipe list of active pmts. 00321 00322 if(SimPixelTimeBucket::GetGlobalPixelBuckets()>0) { 00323 MSG("DetSim",Msg::kError) << "Error: Memory leak detected: total SimPixelTimeBuckets after reset is " 00324 << SimPixelTimeBucket::GetGlobalPixelBuckets() << endl; 00325 } 00326 00327 // Reset the Electronics. 00328 if(fNearElectronics) fNearElectronics->Reset(fContext); 00329 if(fFarElectronics) fFarElectronics->Reset(fContext); 00330 00331 // Reset temporary lists. 00332 fDigiPeStorage.clear(); 00333 }
void SimDetector::Simulate | ( | void | ) | [virtual] |
Definition at line 366 of file SimDetector.cxx.
References CompileStats(), DistributePEs(), SimulateElectronics(), SimulatePmts(), and SimulateTrigger().
Referenced by DetSim::Get().
00367 { 00368 DistributePEs(); 00369 SimulatePmts(); 00370 SimulateElectronics(); 00371 SimulateTrigger(); 00372 CompileStats(); 00373 }
void SimDetector::SimulateElectronics | ( | void | ) | [protected, virtual] |
Apply gains, nonlinearity, pedestal width, roundoff as well as varc 2/6 or 2/36 triggers.
Definition at line 605 of file SimDetector.cxx.
References SimDigitList::AddList(), fActivePmts, fDigits, fFarElectronics, fNearElectronics, SimElectronics::GetDigits(), Msg::kVerbose, MSG, and SimElectronics::ReadoutDetector().
Referenced by Simulate().
00606 { 00611 fDigits.clear(); 00612 00613 // Generic FD electronics: 00614 if(fFarElectronics) 00615 fFarElectronics->ReadoutDetector(fActivePmts); 00616 00617 // Now, read them out. 00618 fDigits.AddList(fFarElectronics->GetDigits()); 00619 00620 // Generic ND electronics: 00621 if(fNearElectronics) 00622 fNearElectronics->ReadoutDetector(fActivePmts); 00623 00624 // Now, read them out. 00625 fDigits.AddList(fNearElectronics->GetDigits()); 00626 00627 for(UInt_t i = 0; i<fDigits.size(); i++) { 00628 MSG("DetSim",Msg::kVerbose) 00629 << "SimDetector read out digit: " 00630 << fDigits[i].AsString() << std::endl;; 00631 } 00632 00633 }
void SimDetector::SimulatePmts | ( | void | ) | [protected, virtual] |
Run all simulated PMTs through their routine
Applies: 1pe width, nonlinearity, gains, xtalk
Definition at line 583 of file SimDetector.cxx.
References PlexPixelSpotId::AsString(), fActivePmts, SimPmt::GetTubeId(), it, Msg::kDebug, MSG, and SimPmt::SimulatePmt().
Referenced by Simulate().
00584 { 00590 SimPmtList::iterator it; 00591 // Only simulate PMTs that have light. This helps to ensure 00592 // random-numbers are OK. 00593 for(it = fActivePmts.begin(); it!= fActivePmts.end(); it++) { 00594 SimPmt* pmt = it->second; 00595 if(pmt){ 00596 00597 MSG("DetSim",Msg::kDebug) << "Simulating PMT " 00598 << pmt->GetTubeId().AsString() 00599 << endl; 00600 pmt->SimulatePmt();} 00601 } 00602 }
void SimDetector::SimulateTrigger | ( | void | ) | [protected, virtual] |
this routine calculated alse the triggers, which active in the online trigger farm
Definition at line 635 of file SimDetector.cxx.
References SimDigitList::AddList(), SimDaqTrigger::ApplyTriggerAt(), fApplyTrigger, fBiggestSnarl, fBiggestSnarlSize, fContext, fDaqTriggers, fDaqTrigReadoutWindowStart, fDaqTrigReadoutWindowStop, fDaqTrigTimingMethod, fDigits, fPlex, fSnarls, fTotalTriggerWord, VldContext::GetDetector(), SimSnarl::GetTriggerTime(), IsGapBurst(), IsWindowBurst(), Detector::kCalDet, Msg::kDebug, Msg::kError, Detector::kFar, SimDaqTrigger::kGap, Detector::kNear, SimDaqTrigger::kNone, kSimMaxTriggers, Msg::kWarning, SimDaqTrigger::kWindow, MSG, SimDigitList::Size(), and SimDigitList::Sort().
Referenced by Simulate().
00636 { 00641 00642 00643 fTotalTriggerWord = 0; 00644 fBiggestSnarl = 0; 00645 fBiggestSnarlSize = -1; 00646 00647 // Sort the digit list in time for ease in doing the trigger computation. 00648 fDigits.Sort(); 00649 00650 bool dotrigger = (fApplyTrigger>0); 00651 static bool donemessage = false; 00652 if(fApplyTrigger==3) { 00653 // Choose an 'intelligent' trigger mode. 00654 if(fContext.GetDetector()==Detector::kFar) { 00655 if(!donemessage) MSG("DetSim",Msg::kWarning) 00656 << "This is the far detector, so I'm assuming you want DAQ triggers on. Use applytrigger=0 to turn them off." << endl; 00657 dotrigger = true; 00658 } 00659 else if(fContext.GetDetector()==Detector::kNear) { 00660 if(!donemessage) MSG("DetSim",Msg::kWarning) 00661 << "This is the near detector, so I'm assuming you want DAQ triggers off. Use applytrigger=1 to turn them on." << endl; 00662 dotrigger = false; 00663 } 00664 else if(fContext.GetDetector()==Detector::kCalDet) { 00665 if(!donemessage) MSG("DetSim",Msg::kWarning) 00666 << "This is the caldet detector, so I'm assuming you want DAQ triggers off. Use applytrigger=1 to turn them on." << endl; 00667 dotrigger = false; 00668 } 00669 donemessage = true; 00670 }; 00671 00672 if(!dotrigger) { 00673 // Look to see if the all digits pass any triggers, just for 00674 // the sake of completeness. 00675 Int_t triggerWord = 0; 00676 00677 for(int itrig=0;itrig<kSimMaxTriggers;itrig++) { 00678 int triggerbit = (1<<itrig); 00679 00680 if(fDaqTriggers[itrig]) { 00681 bool result = fDaqTriggers[itrig]->ApplyTriggerAt(fPlex, 00682 fDigits, 00683 0, 00684 fDigits.size() 00685 ); 00686 if(result) triggerWord |= triggerbit; 00687 } 00688 } 00689 00690 // Add trigger bit for SpillTrigger 00691 if(fContext.GetDetector() == Detector::kFar) { 00692 triggerWord |= 0x20000; // TRIGGER_BIT_SPILL_IP from mdTriggerCodes.h 00693 } else 00694 if(fContext.GetDetector() == Detector::kNear) { 00695 triggerWord |= 0x10000; // TRIGGER_BIT_SPILL from mdTriggerCodes.h 00696 } 00697 00698 // Don't bother triggering.. just dump everything into one big snarl. 00699 double snarltime = 0; 00700 if(fDigits.size()>0) snarltime = fDigits[0].GetTime(); 00701 MSG("DetSim",Msg::kDebug) << "#slew SimDetector@1 create SimSnarl " 00702 << snarltime << endl; 00703 SimSnarl snarl(triggerWord,snarltime); 00704 fTotalTriggerWord = triggerWord; 00705 00706 00707 snarl.AddList(fDigits); 00708 00709 // Add the snarl. 00710 MSG("DetSim",Msg::kDebug) << "#slew SimDetector@2 push_back " 00711 << snarl.GetTriggerTime() << endl; 00712 fSnarls.push_back(snarl); 00713 fBiggestSnarlSize = snarl.Size(); 00714 return; 00715 } 00716 00717 00718 // We now have a sorted list of digits. 00719 // Go through the list, looking for a burst or a 00720 // gap, as befits our trigger type. 00721 00722 UInt_t startdigit = 0; 00723 00724 while(startdigit<fDigits.size()) { 00725 int digitsInBurst = 0; 00726 switch(fDaqTrigTimingMethod) { 00727 case SimDaqTrigger::kNone: 00728 digitsInBurst=fDigits.size(); // Always trigger. 00729 MSG("DetSim",Msg::kDebug) << "Trigger: NULL trigger, triggering all digits." << endl; 00730 break; 00731 case SimDaqTrigger::kWindow: // Window trigger. 00732 digitsInBurst = IsWindowBurst(fDigits,startdigit); 00733 if(digitsInBurst) MSG("DetSim",Msg::kDebug) << "Trigger: Window trigger fired with " << digitsInBurst << " digits." << endl; 00734 break; 00735 case SimDaqTrigger::kGap: // Gap trigger. 00736 digitsInBurst = IsGapBurst(fDigits,startdigit); 00737 if(digitsInBurst) MSG("DetSim",Msg::kDebug) << "Trigger: Gap trigger fired with " << digitsInBurst << " digits." << endl; break; 00738 default: 00739 MSG("DetSim",Msg::kError) << "Unknown DAQ trigger window method " << fDaqTrigTimingMethod << endl; 00740 break; 00741 } 00742 00743 if(digitsInBurst>0) { // A burst is starting here. 00744 00745 // See if this passes any trigger condition: 00746 Int_t triggerWord = 0; 00747 00748 for(int itrig=0;itrig<kSimMaxTriggers;itrig++) { 00749 int triggerbit = (1<<itrig); 00750 00751 if(fDaqTriggers[itrig]) { 00752 bool result = fDaqTriggers[itrig]->ApplyTriggerAt(fPlex, 00753 fDigits, 00754 startdigit, 00755 startdigit+digitsInBurst 00756 ); 00757 if(result) triggerWord |= triggerbit; 00758 } 00759 } 00760 MSG("DetSim",Msg::kDebug) << "Burst digits " << startdigit 00761 << " to " << startdigit+digitsInBurst - 1 00762 << " fired triggers: " << triggerWord << endl; 00763 00764 if(triggerWord != 0){ 00765 // Something triggered. 00766 00767 fTotalTriggerWord |= triggerWord; // Add to toal. 00768 00769 // Make a snarl. 00770 MSG("DetSim",Msg::kDebug) << "#slew SimDetector@3 create SimSnarl " 00771 << fDigits[startdigit].GetTime() << endl; 00772 SimSnarl snarl(triggerWord,fDigits[startdigit].GetTime()); 00773 00774 // Collect hits for the trigger. 00775 Double_t burst_start = fDigits[startdigit].GetTime(); 00776 Double_t burst_stop = fDigits[startdigit+digitsInBurst-1].GetTime(); 00777 Double_t window_open = burst_start - fDaqTrigReadoutWindowStart; 00778 Double_t window_close = burst_stop + fDaqTrigReadoutWindowStop; 00779 00780 UInt_t lastdigit = 0; 00781 for(UInt_t i=0; i<fDigits.size(); i++) { 00782 if(( fDigits[i].GetTime()>=window_open ) && 00783 ( fDigits[i].GetTime()<=window_close ) ) { 00784 snarl.push_back(fDigits[i]); 00785 if(i>lastdigit) lastdigit=i; 00786 } 00787 } 00788 00789 // Add the snarl. 00790 00791 MSG("DetSim",Msg::kDebug) << "#slew SimDetector@4 push_back " 00792 << snarl.GetTriggerTime() << endl; 00793 fSnarls.push_back(snarl); 00794 if((Int_t)snarl.Size() > fBiggestSnarlSize) { 00795 fBiggestSnarlSize = snarl.size();; 00796 fBiggestSnarl = fSnarls.size() -1; 00797 } 00798 00799 // Advance the pointer to the end of the burst. 00800 startdigit += lastdigit; 00801 } 00802 } 00803 startdigit++; // Increment counter by one and look again. 00804 } 00805 }
void SimDetector::SortDigiPE | ( | const DigiPE * | digipe | ) | [protected, virtual] |
Definition at line 505 of file SimDetector.cxx.
References DigiScintHit::AsString(), PlexPixelSpotId::AsString(), SimPmtMaker::Create(), fActivePmts, fContext, fM16Model, fM64Model, fPmts, fRandom, PlexMuxBoxId::GetDetector(), PlexMuxBoxId::GetElecType(), DigiPE::GetHitPointer(), DigiPE::GetPixelSpotId(), DigiPE::GetTime(), SimPmt::GetTubeId(), GetTubeIndex(), SimPmt::GetType(), DigiPE::IsDarkNoise(), DigiPE::IsFibreLight(), PlexPixelSpotId::IsValid(), it, Msg::kDebug, Msg::kError, SimPmt::kM16, SimPmt::kM64, ElecType::kQIE, Detector::kUnknown, Msg::kVerbose, Msg::kWarning, MSG, SimPmt::Reset(), and DigiScintHit::StripEndId().
Referenced by DistributePEs().
00506 { 00507 if(digipe==0) return; 00508 PlexPixelSpotId psid; 00509 PlexStripEndId seid; 00510 00511 const DigiScintHit* hit = digipe->GetHitPointer(); 00512 psid = digipe->GetPixelSpotId(); 00513 if(hit) seid = hit->StripEndId(); // Truth info: convert from DigiScintHit into SEID. 00514 Double_t time = digipe->GetTime(); 00515 00516 if(!psid.IsValid()) { 00517 MSG("DetSim",Msg::kWarning) << "Invalid pixel spot on a DigiPE. Omitting. " << psid.AsString() << "\n"; 00518 MSG("DetSim",Msg::kWarning) << "Time: " << time 00519 << " DarkNoise: " << ((digipe->IsDarkNoise())?"true":"false") 00520 << " FibreLight: " << ((digipe->IsFibreLight())?"true":"false") 00521 << " ScintHit: \n"; 00522 if(hit) 00523 MSG("DetSim",Msg::kWarning) << hit->AsString() << endl; 00524 00525 return; 00526 } 00527 if (psid.GetDetector()==Detector::kUnknown) { 00528 MSG("DetSim",Msg::kWarning) << "Bad pixel spot on a DigiPE (unknown detector). Omitting.\n"; 00529 return; 00530 } 00531 00532 // Find the tube. 00533 SimPmt* pmt = 0; 00534 int tube = GetTubeIndex(psid); 00535 SimPmtList::iterator it = fPmts.find(tube); 00536 pmt = it->second; 00537 00538 // Create the tube if neccessary. 00539 if(it == fPmts.end()) { 00540 SimPmt::Pmt_t type = SimPmt::kM16; 00541 // Determine type of tube (M16 or M64) from the psid. 00542 if(psid.GetElecType() == ElecType::kQIE) type = SimPmt::kM64; 00543 00544 std::string modelName; 00545 if( type == SimPmt::kM16 ) modelName = fM16Model; 00546 else modelName = fM64Model; 00547 00548 pmt = SimPmtMaker::Create(modelName,psid,fContext,fRandom); 00549 00550 if(!pmt) { 00551 MSG("DetSim",Msg::kError) << "SimDetector: Failed to create new " 00552 << "pmt of type " << modelName << endl; 00553 return; 00554 } 00555 00556 // Call Reset() on the tube to get it up-to-date 00557 pmt->Reset(fContext); 00558 00559 MSG("DetSim",Msg::kDebug) << "SimDetector: Adding new PMT " 00560 << pmt->GetTubeId().AsString() 00561 << " type: " << pmt->GetType() 00562 << " at: " << tube 00563 << endl; 00564 fPmts[tube] = pmt; 00565 } 00566 00567 // Add the hit. 00568 MSG("DetSim",Msg::kVerbose) << "SimDetector::AddDigiPE " 00569 << psid.AsString() << " " 00570 << 1.0 << "pe " 00571 << time << "ns" 00572 << endl; 00573 00574 00575 fPmts[tube]->AddDigiPE(digipe); 00576 00577 // Add the tube to the 'active' list. 00578 fActivePmts[tube] = fPmts[tube]; 00579 }
SimPmtList SimDetector::fActivePmts [mutable, protected] |
Definition at line 138 of file SimDetector.h.
Referenced by CompileStats(), Print(), Reset(), SimulateElectronics(), SimulatePmts(), SortDigiPE(), and ~SimDetector().
Int_t SimDetector::fAdcPlane[kSimMaxPlane] [protected] |
Definition at line 145 of file SimDetector.h.
Int_t SimDetector::fAddTimeWithinSec [protected] |
Definition at line 110 of file SimDetector.h.
Referenced by Config().
Int_t SimDetector::fApplyTrigger [protected] |
Definition at line 119 of file SimDetector.h.
Referenced by Config(), IsTriggering(), and SimulateTrigger().
UInt_t SimDetector::fBiggestSnarl [protected] |
Definition at line 152 of file SimDetector.h.
Referenced by GetBiggestSnarl(), and SimulateTrigger().
Int_t SimDetector::fBiggestSnarlSize [protected] |
Definition at line 153 of file SimDetector.h.
Referenced by SimulateTrigger().
Int_t SimDetector::fClearPmtList [protected] |
Definition at line 108 of file SimDetector.h.
VldContext SimDetector::fContext [protected] |
Definition at line 99 of file SimDetector.h.
Referenced by AdjustTimeWithinSec(), Config(), IsTriggering(), Print(), Reset(), SimulateTrigger(), and SortDigiPE().
Int_t SimDetector::fDaqTriggerMask [protected] |
Definition at line 125 of file SimDetector.h.
Referenced by Config(), IsTriggered(), and Print().
SimDaqTrigger* SimDetector::fDaqTriggers[kSimMaxTriggers] [protected] |
Definition at line 126 of file SimDetector.h.
Referenced by Config(), Print(), and SimulateTrigger().
Double_t SimDetector::fDaqTrigReadoutWindowStart [protected] |
Definition at line 123 of file SimDetector.h.
Referenced by Config(), Print(), and SimulateTrigger().
Double_t SimDetector::fDaqTrigReadoutWindowStop [protected] |
Definition at line 124 of file SimDetector.h.
Referenced by Config(), Print(), and SimulateTrigger().
Double_t SimDetector::fDaqTrigTimeGap [protected] |
Definition at line 121 of file SimDetector.h.
Referenced by Config(), IsGapBurst(), and Print().
Double_t SimDetector::fDaqTrigTimeWindow [protected] |
Definition at line 122 of file SimDetector.h.
Referenced by Config(), IsWindowBurst(), and Print().
Int_t SimDetector::fDaqTrigTimingMethod [protected] |
Definition at line 120 of file SimDetector.h.
Referenced by Config(), Print(), and SimulateTrigger().
DigiList<DigiPE> SimDetector::fDigiPeStorage [protected] |
Definition at line 157 of file SimDetector.h.
Referenced by Reset().
SimDigitList SimDetector::fDigits [protected] |
Definition at line 139 of file SimDetector.h.
Referenced by Clean(), GetNumberOfDigits(), GetSimDigit(), IsGapBurst(), IsWindowBurst(), Print(), Reset(), SimulateElectronics(), SimulateTrigger(), and ~SimDetector().
std::string SimDetector::fFarElecModel [protected] |
Definition at line 115 of file SimDetector.h.
Referenced by Config().
SimElectronics* SimDetector::fFarElectronics [protected] |
Definition at line 135 of file SimDetector.h.
Referenced by CompileStats(), Config(), Print(), Reset(), SimulateElectronics(), and ~SimDetector().
Int_t SimDetector::fFirstPlane [protected] |
Definition at line 146 of file SimDetector.h.
UInt_t SimDetector::fHitPlane[kSimMaxPlane] [protected] |
Definition at line 143 of file SimDetector.h.
Int_t SimDetector::fLastPlane [protected] |
Definition at line 147 of file SimDetector.h.
std::string SimDetector::fM16Model [protected] |
Definition at line 113 of file SimDetector.h.
Referenced by Config(), Print(), and SortDigiPE().
std::string SimDetector::fM64Model [protected] |
Definition at line 114 of file SimDetector.h.
Referenced by Config(), Print(), and SortDigiPE().
std::string SimDetector::fNearElecModel [protected] |
Definition at line 116 of file SimDetector.h.
Referenced by Config().
SimElectronics* SimDetector::fNearElectronics [protected] |
Definition at line 136 of file SimDetector.h.
Referenced by CompileStats(), Config(), Print(), Reset(), SimulateElectronics(), and ~SimDetector().
const TObjArray* SimDetector::fPeList [protected] |
Definition at line 130 of file SimDetector.h.
Referenced by AddDigiPEList(), and DistributePEs().
PlexHandle SimDetector::fPlex [protected] |
Definition at line 102 of file SimDetector.h.
Referenced by Reset(), and SimulateTrigger().
SimPmtList SimDetector::fPmts [mutable, protected] |
Definition at line 137 of file SimDetector.h.
Referenced by Clean(), Print(), Reset(), SortDigiPE(), and ~SimDetector().
TRandom* SimDetector::fRandom [protected] |
Definition at line 103 of file SimDetector.h.
Referenced by Config(), GetRandom(), and SortDigiPE().
SimEventResult SimDetector::fResult [protected] |
Definition at line 160 of file SimDetector.h.
Referenced by CompileStats(), GetEventResult(), and Print().
UInt_t SimDetector::fSigHitPlane[kSimMaxPlane] [protected] |
Definition at line 144 of file SimDetector.h.
std::vector<SimSnarl> SimDetector::fSnarls [protected] |
Definition at line 151 of file SimDetector.h.
Referenced by CompileStats(), GetNumberOfSnarls(), GetSnarl(), GetSnarlList(), Print(), Reset(), and SimulateTrigger().
Double_t SimDetector::fTimeShift [protected] |
Definition at line 131 of file SimDetector.h.
Referenced by AdjustTimeWithinSec(), CompileStats(), DistributePEs(), and GetTimeShift().
Int_t SimDetector::fTotalTriggerWord [protected] |
Definition at line 140 of file SimDetector.h.
Referenced by GetTotalTriggerWord(), IsTriggered(), Print(), and SimulateTrigger().