BOSS 7.0.4
BESIII Offline Software System
Loading...
Searching...
No Matches
Simulation/BesEventMixer/BesEventMixer-00-00-35/BesEventMixer/MixerAlg.h
Go to the documentation of this file.
1#ifndef MixerAlg_h
2#define MixerAlg_h
3
4#include "RawDataCnv/EventManagement/RAWEVENT.h"
5#include "GaudiKernel/Algorithm.h"
6#include "GaudiKernel/SmartDataPtr.h"
7#include "RawFile/RawFileReader.h"
8#include "RawDataCnv/EventManagement/EmcBuilder.h"
9#include "RawDataCnv/EventManagement/MdcBuilder.h"
10#include "RawDataCnv/EventManagement/MucBuilder.h"
11#include "RawDataCnv/EventManagement/TofBuilder.h"
12#include "EmcRawEvent/EmcDigi.h"
13#include "MdcRawEvent/MdcDigi.h"
14#include "TofRawEvent/TofDigi.h"
15#include "MucRawEvent/MucDigi.h"
16#include "RawEvent/RawDataUtil.h"
17#include "RealizationSvc/RealizationSvc.h"
18#include "RealizationSvc/IRealizationSvc.h"
19#include "DataInfoSvc/DataInfoSvc.h"
20#include "DataInfoSvc/IDataInfoSvc.h"
21#include "BesTimerSvc/IBesTimerSvc.h"
22#include "BesTimerSvc/BesTimerSvc.h"
23#include "GaudiKernel/NTuple.h"
24//
25// An algorithm to combine MC signal and background from raw data file at digi level
26//
27// A.Zhemchugov ([email protected]), 09/08/2006
28// A.Zhemchugov: modified to new data format, 29.07.08
29
30#define MAX_LOOP_TIMES 1000000
31
32class MsgStream;
33//class IDatabaseSvc;
34class IBesRndmGenSvc;
35
36class MdcConverter;
37class MucConverter;
38class EmcConverter;
39class TofConverter;
40
41template <class T1, class T2>
42void combineDigits (SmartDataPtr<T1>& mcDigits, T1& bgDigits, int verbosity);
43void combineMdcDigits (SmartDataPtr<MdcDigiCol>& mcDigits, MdcDigiCol& bgDigits, int verbosity);
44void combineTofDigits (SmartDataPtr<TofDigiCol>& mcDigits, TofDigiCol& bgDigits, int verbosity);
45
46class MixerAlg:public Algorithm {
47public:
48 MixerAlg (const std::string& name, ISvcLocator* pSvcLocator);
49 StatusCode initialize();
50 StatusCode execute();
51 StatusCode finalize();
53
54 protected:
55 bool nextEvent(int nskip = 0, int evtbyte = 0, int eventsToEnd = 0);
56
57 void mixDigi(SmartDataPtr<MdcDigiCol>& mdcMcDigits,
58 SmartDataPtr<EmcDigiCol>& emcMcDigits,
59 SmartDataPtr<MucDigiCol>& mucMcDigits,
60 SmartDataPtr<TofDigiCol>& tofMcDigits);
61
62 void decodeMdc(MdcDigiCol* digiCol);
63 void decodeMuc(MucDigiCol* digiCol);
64 void decodeEmc(EmcDigiCol* digiCol);
65 void decodeTof(TofDigiCol* digiCol);
66
67 int getTiming();
68 std::string eventType();
69
70 std::string prepareDbQuery();
71
72 bool file_sort(std::vector<std::string>& files, std::vector<int>& ranEvtNums);
73
74 private:
75 MsgStream* log;
76
77 RAWEVENT* m_raw_event;
78 RawFileReader* m_fr;
79
80 //IDatabaseSvc* m_db;
81
82 // Converters to create Digi objects
83 MdcConverter* m_mdcCnv;
84 MucConverter* m_mucCnv;
85 EmcConverter* m_emcCnv;
86 TofConverter* m_tofCnv;
87
88 // Algorithm properties to be set in data card
89 std::string m_run;
90 std::vector<std::string> m_runs;
91 std::vector<std::string> m_dates;
92
93 // Flags to choose subdetectors for which background should be mixed in
94 bool b_mdc;
95 bool b_emc;
96 bool b_muc;
97 bool b_tof;
98
99 // Number of background events to be mixed in one signal event
100 // bool b_loop;
101 bool m_skip;
102 bool m_dbUserRequest;
103 int m_NSkip;
104 int m_skipCount;
105 int nskipped;
106 int m_mixingMethod;
107
108 int m_nevent;
109 int m_runNo;
110 int m_totRanEvtNum;
111 int m_totalEvent;
112 int m_totEvtNumInCurFile;
113 int m_nEventsToEnd;
114
115 std::vector<int> m_ranTrgEvents;
116 std::vector<int> m_numSets; //No. of sets of each bg file, for example: run_**_RandomTrg_file001_SF0-1.raw, 001 is set No.
117 std::vector<int> m_vRanEvtNumInSubSet;
118 std::vector<int> m_vStreamNumInSubSet;
119 std::vector<int> m_vStepLength;
120 std::vector<int> m_ranStepLenInCurrentFile;
121
122 std::map<int,std::vector<int> > map_stepLength;
123
124 int m_exRunFrom;
125 int m_exRunTo;
126
127 int m_maxLoop;
128 bool m_ifSmearT0;
129
130 int m_readBGMethod;
131
132 bool m_usingFilter;
133
134 // Current bg file
135 std::string currentBGFile;
136
137 // Current MC file
138 std::string currentMCFile;
139
140 // Input file name of background data (raw data format)
141 std::vector<std::string> m_bgfiles;
142 std::vector<std::string> m_bgfilesIndex;
143 //std::vector<std::string>::iterator m_bgfile;
144
145 // Replace /besfs/offline/data/randomtrg in the file name from the database to the user defined value
146 std::string m_pattern;
147 // Use the user defined value of directory which contains random trigger files
148 std::string m_newdatadir;
149
150 // Reference to RealizationSvc
151 RealizationSvc* m_RealizationSvc;
152 DataInfoSvc* m_jobInfoSvc;
153
154 NTuple::Tuple* m_tuple1;
155 NTuple::Item<float> m_time1;
156 NTuple::Item<float> m_time2;
157 NTuple::Item<float> m_time3;
158 NTuple::Item<float> m_time4;
159 NTuple::Item<float> m_time5;
160
161 NTuple::Tuple* m_tuple2;
162 NTuple::Tuple* m_tuple3;
163 NTuple::Item<long> m_tdc;
164
165 IBesTimerSvc* m_timersvc;
166 BesTimer* m_timer;
167 BesTimer* m_timer1;
168 bool m_ifOutPut;
169
170 //caogf for random seed
171 IBesRndmGenSvc* p_BesRndmGenSvc;
172};
173
174#endif
ObjectVector< MdcDigi > MdcDigiCol
ObjectVector< MucDigi > MucDigiCol
ObjectVector< TofDigi > TofDigiCol
void combineMdcDigits(SmartDataPtr< MdcDigiCol > &mcDigits, MdcDigiCol &bgDigits, int verbosity)
Definition: MixerAlg.cxx:930
void combineTofDigits(SmartDataPtr< TofDigiCol > &mcDigits, TofDigiCol &bgDigits, int verbosity)
Definition: MixerAlg.cxx:979
void combineDigits(SmartDataPtr< T1 > &mcDigits, T1 &bgDigits, int verbosity)
Definition: MixerAlg.cxx:882
manage multiple CLHEP random engines as named streams
std::string prepareDbQuery()
bool file_sort(std::vector< std::string > &files, std::vector< int > &ranEvtNums)
void mixDigi(SmartDataPtr< MdcDigiCol > &mdcMcDigits, SmartDataPtr< EmcDigiCol > &emcMcDigits, SmartDataPtr< MucDigiCol > &mucMcDigits, SmartDataPtr< TofDigiCol > &tofMcDigits)
void decodeMuc(MucDigiCol *digiCol)
void decodeEmc(EmcDigiCol *digiCol)
StatusCode finalize()
bool nextEvent(int nskip=0, int evtbyte=0, int eventsToEnd=0)
MixerAlg(const std::string &name, ISvcLocator *pSvcLocator)
int getTiming()
StatusCode execute()
StatusCode initialize()
void decodeMdc(MdcDigiCol *digiCol)
void decodeTof(TofDigiCol *digiCol)
std::string eventType()