00001 00056 #ifndef ELECSIMPROC_H 00057 #define ELECSIMPROC_H 00058 00059 #include "Stage/StageProcessor.h" 00060 #include "Event/SimHeader.h" 00061 #include "Event/SimHit.h" 00062 #include "Event/ElecHeader.h" 00063 00064 #include "ElecSim/IEsPulseTool.h" 00065 #include "ElecSim/IEsFrontEndTool.h" 00066 00068 #include "Stage/IStage.h" 00069 #include "Stage/FFTimeStamp.h" 00070 #include "Stage/HeaderStageData.h" 00071 00072 #include <vector> 00073 00074 class ElecSimProc : public StageProcessor<DayaBay::ElecHeader> 00075 { 00076 public: 00077 ElecSimProc(const std::string& name, ISvcLocator* pSvcLocator); 00078 virtual ~ElecSimProc(); 00079 00080 virtual StatusCode initialize(); 00081 virtual StatusCode execute(); 00082 00083 00084 private: 00085 00086 // properties/tools 00087 00088 // Property Detectors - List of detector names to include in simulation 00089 std::vector<std::string> m_detectorNames; 00090 // Property PmtTool - Name of the PMT simulation tool 00091 std::string m_pmtToolName; 00092 // Property RpcTool - Name of the RPC simulation tool 00093 std::string m_rpcToolName; 00094 // Property FeeTool - Name of the PMT Front-end electronics simulation tool 00095 std::string m_feeToolName; 00096 // Property FecTool - Name of the RPC Front-end electronics simulation tool 00097 std::string m_fecToolName; 00098 00099 // List of simulated detector IDs 00100 std::vector<DayaBay::Detector> m_detectors; 00101 // Tool for adding PMT effects to simulated hits 00102 IEsPulseTool* m_pmtTool; 00103 // Tool for adding RPC effects to simulated hits 00104 IEsPulseTool* m_rpcTool; 00105 // Tool for generating PMT Front-end electronics signals 00106 IEsFrontEndTool* m_feeTool; 00107 // Tool for generating RPC Front-end card signals 00108 IEsFrontEndTool* m_fecTool; 00109 00111 FFTimeStamp m_currentTime; 00112 00113 private: 00114 // implementation details 00115 00116 typedef HeaderStageData<DayaBay::HeaderObject> HeaderData; 00117 typedef HeaderStageData<DayaBay::SimHeader> SimData; 00118 typedef HeaderStageData<DayaBay::ElecHeader> ElecData; 00119 00120 // Get the next SimHeader 00121 StatusCode getSimData(DayaBay::SimHeader*& output); 00122 00123 // Fill hit pipeline and our SimHitHeader with given SimHeader's 00124 // worth of hits 00125 StatusCode fillPipeLine(DayaBay::SimHeader* shead); 00126 00127 // Gets more new data fills pipeline 00128 StatusCode moar(); 00129 00130 // Search pipeline for a gap 00131 // Nnoble particle with respect to Geant4 (i.e. muon from MuonProphet) 00132 // is treated as a giant hit 00133 StatusCode findGap(); 00134 00135 // Fills the fake SimHitHeader with hits that occured before gapStart time. 00136 StatusCode fillHitHeader(); 00137 00138 // Get all geant4-noble particles in time window 00139 StatusCode findGiantHitInTime(); 00140 00141 // Run the ElecSim tools and new data is push to its stage. 00142 // It should be close to EsFrontEndAlg.cc 00143 StatusCode ES_execute(); 00144 00145 // Fast electronic simulation, produce empty ElecHeader for MuonProphet muon 00146 StatusCode fastElecSim(); 00147 00148 // Process the data up to the gap and purge pipeline and current 00149 // headers of no longer needed objects. 00150 StatusCode blowChunks(); 00151 00152 // important data members 00153 // A fake SimHitHeader to hold current amalgamated hit 00154 // collections. 00155 DayaBay::SimHitHeader m_amalSimHitHeader; 00156 int m_count; // count for how many hits add to the fake SimHitHeader 00157 00158 // SimHeaders contributing the SimHits in current HitPipeline 00159 std::vector<const DayaBay::SimHeader*> m_currentHeaders; 00160 00161 // counting how many hits in a SimHeader is in use for 00162 // current fake SimHitHeader. Just for bookkeeping 00163 std::map<const DayaBay::SimHeader*,int> m_simHeaderCount; 00164 00165 // Too many bookkeeping to do 00166 // Need to keep track the real latest time of all header objects. 00167 // extremely long delay, >1e12 second, cause time go backwards. 00168 // Then latest can be early be earliest. 00169 std::map<const DayaBay::SimHeader*, TimeStamp /* latest */ > m_realLatest; 00170 00171 // The pipeline of hits. Used to find TimeGap 00172 // The time in this pipiline is absolute time. 00173 typedef std::multimap<TimeStamp,DayaBay::SimHit*, std::less<TimeStamp> > HitPipeline; 00174 HitPipeline m_hitPipeline; 00175 00176 // Minimum width of time gap that determines a chunk. 00177 double m_minTimeGap; 00178 00179 // Chunk Start and Stop time 00180 // The hits are within this [m_chunkStart,m_chunkStop] 00181 TimeStamp m_chunkStart; 00182 TimeStamp m_chunkStop; 00183 // Fake hits are also in pipeline. This is the earliest and latest for real hits. 00184 TimeStamp m_realHitEarliest; 00185 TimeStamp m_realHitLatest; 00186 00188 HitPipeline m_giantHits; 00190 std::map<const DayaBay::SimHit*, const DayaBay::SimHeader*> m_giantHitSheader; 00192 HitPipeline m_giantHitsInTime; 00193 00195 TimeStamp m_realElecHeaderTime; 00196 TimeStamp m_emptyElecHeaderTime; 00197 00199 double m_longest; 00200 }; 00201 00202 #endif // ELECSIMPROC_H