/home/bes3soft/bes3soft/Boss/7.0.2/dist/7.0.2/Simulation/BesEventMixer/BesEventMixer-00-00-35/BesEventMixer/MixerAlg.h

Go to the documentation of this file.
00001 #ifndef MixerAlg_h
00002 #define MixerAlg_h
00003 
00004 #include "RawDataCnv/EventManagement/RAWEVENT.h"
00005 #include "GaudiKernel/Algorithm.h"
00006 #include "GaudiKernel/SmartDataPtr.h"
00007 #include "RawFile/RawFileReader.h"
00008 #include "RawDataCnv/EventManagement/EmcBuilder.h"
00009 #include "RawDataCnv/EventManagement/MdcBuilder.h"
00010 #include "RawDataCnv/EventManagement/MucBuilder.h"
00011 #include "RawDataCnv/EventManagement/TofBuilder.h"
00012 #include "EmcRawEvent/EmcDigi.h"
00013 #include "MdcRawEvent/MdcDigi.h"
00014 #include "TofRawEvent/TofDigi.h"
00015 #include "MucRawEvent/MucDigi.h"
00016 #include "RawEvent/RawDataUtil.h"
00017 #include "RealizationSvc/RealizationSvc.h"
00018 #include "RealizationSvc/IRealizationSvc.h"
00019 #include "DataInfoSvc/DataInfoSvc.h"
00020 #include "DataInfoSvc/IDataInfoSvc.h"
00021 #include "BesTimerSvc/IBesTimerSvc.h"
00022 #include "BesTimerSvc/BesTimerSvc.h"
00023 #include "GaudiKernel/NTuple.h"
00024 //
00025 // An algorithm to combine MC signal and background from raw data file at digi level
00026 //
00027 // A.Zhemchugov (zhemchugov@jinr.ru), 09/08/2006
00028 // A.Zhemchugov: modified to new data format, 29.07.08
00029 
00030 #define MAX_LOOP_TIMES 1000000
00031 
00032 class MsgStream;
00033 //class IDatabaseSvc;
00034 class IBesRndmGenSvc;
00035 
00036 class MdcConverter;
00037 class MucConverter;
00038 class EmcConverter;
00039 class TofConverter;
00040 
00041 template <class T1, class T2> 
00042 void combineDigits (SmartDataPtr<T1>& mcDigits, T1& bgDigits, int verbosity);
00043 void combineMdcDigits (SmartDataPtr<MdcDigiCol>& mcDigits, MdcDigiCol& bgDigits, int verbosity);
00044 void combineTofDigits (SmartDataPtr<TofDigiCol>& mcDigits, TofDigiCol& bgDigits, int verbosity);
00045 
00046 class MixerAlg:public Algorithm {
00047 public:
00048   MixerAlg (const std::string& name, ISvcLocator* pSvcLocator);
00049   StatusCode initialize();
00050   StatusCode execute();
00051   StatusCode finalize();
00052   ~MixerAlg() {}
00053 
00054  protected:
00055   bool nextEvent(int nskip = 0, int evtbyte = 0, int eventsToEnd = 0);
00056   
00057   void mixDigi(SmartDataPtr<MdcDigiCol>& mdcMcDigits, 
00058                SmartDataPtr<EmcDigiCol>& emcMcDigits, 
00059                SmartDataPtr<MucDigiCol>& mucMcDigits, 
00060                SmartDataPtr<TofDigiCol>& tofMcDigits);
00061 
00062   void decodeMdc(MdcDigiCol* digiCol);
00063   void decodeMuc(MucDigiCol* digiCol);
00064   void decodeEmc(EmcDigiCol* digiCol);
00065   void decodeTof(TofDigiCol* digiCol);
00066 
00067   int getTiming();
00068   std::string eventType();
00069 
00070   std::string prepareDbQuery();
00071 
00072   bool file_sort(std::vector<std::string>& files, std::vector<int>& ranEvtNums);
00073 
00074  private:
00075   MsgStream* log;
00076 
00077   RAWEVENT*                m_raw_event;
00078   RawFileReader*  m_fr;
00079  
00080   //IDatabaseSvc* m_db;
00081 
00082   // Converters to create Digi objects
00083   MdcConverter* m_mdcCnv;
00084   MucConverter* m_mucCnv;
00085   EmcConverter* m_emcCnv;
00086   TofConverter* m_tofCnv;
00087 
00088   // Algorithm properties to be set in data card
00089   std::string m_run;
00090   std::vector<std::string> m_runs;
00091   std::vector<std::string> m_dates;
00092 
00093   // Flags to choose subdetectors for which background should be mixed in
00094   bool b_mdc;
00095   bool b_emc;
00096   bool b_muc;
00097   bool b_tof;
00098   
00099   // Number of background events to be mixed in one signal event
00100   // bool b_loop;
00101   bool m_skip;
00102   bool m_dbUserRequest;
00103   int m_NSkip;
00104   int m_skipCount;
00105   int nskipped;
00106   int m_mixingMethod;
00107 
00108   int m_nevent;
00109   int m_runNo;
00110   int m_totRanEvtNum;
00111   int m_totalEvent;
00112   int m_totEvtNumInCurFile;
00113   int m_nEventsToEnd;
00114 
00115   std::vector<int> m_ranTrgEvents;
00116   std::vector<int> m_numSets; //No. of sets of each bg file, for example: run_**_RandomTrg_file001_SF0-1.raw, 001 is set No.
00117   std::vector<int> m_vRanEvtNumInSubSet;
00118   std::vector<int> m_vStreamNumInSubSet;
00119   std::vector<int> m_vStepLength;
00120   std::vector<int> m_ranStepLenInCurrentFile;
00121 
00122   std::map<int,std::vector<int> > map_stepLength;
00123   
00124   int m_exRunFrom;
00125   int m_exRunTo;
00126 
00127   int m_maxLoop;
00128   bool m_ifSmearT0;
00129 
00130   int m_readBGMethod;
00131 
00132   bool m_usingFilter;
00133 
00134   // Current bg file
00135   std::string currentBGFile;
00136 
00137   // Current MC file
00138   std::string currentMCFile;
00139 
00140   // Input file name of background data (raw data format)
00141   std::vector<std::string> m_bgfiles;
00142   std::vector<std::string> m_bgfilesIndex;
00143   //std::vector<std::string>::iterator m_bgfile;
00144 
00145   // Replace  /besfs/offline/data/randomtrg in the file name from the database to the user defined value
00146   std::string m_pattern;
00147   // Use the user defined value of directory which contains random trigger files
00148   std::string m_newdatadir;
00149 
00150   // Reference to RealizationSvc
00151   RealizationSvc* m_RealizationSvc;
00152   DataInfoSvc* m_jobInfoSvc;
00153  
00154   NTuple::Tuple*        m_tuple1;
00155   NTuple::Item<float> m_time1;
00156   NTuple::Item<float> m_time2;
00157   NTuple::Item<float> m_time3;
00158   NTuple::Item<float> m_time4;
00159   NTuple::Item<float> m_time5;
00160 
00161   NTuple::Tuple*        m_tuple2;
00162   NTuple::Tuple*        m_tuple3;
00163   NTuple::Item<long> m_tdc;
00164 
00165   IBesTimerSvc* m_timersvc;
00166   BesTimer* m_timer; 
00167   BesTimer* m_timer1; 
00168   bool m_ifOutPut;
00169 
00170   //caogf for random seed
00171   IBesRndmGenSvc* p_BesRndmGenSvc;
00172 };
00173 
00174 #endif

Generated on Tue Nov 29 23:14:22 2016 for BOSS_7.0.2 by  doxygen 1.4.7