BOSS 6.6.4.p03
BESIII Offline Software System
Loading...
Searching...
No Matches
MixerAlg.h
Go to the documentation of this file.
1#ifndef MixerAlg_h
2#define MixerAlg_h
3
5#include "GaudiKernel/Algorithm.h"
6#include "GaudiKernel/SmartDataPtr.h"
12#include "EmcRawEvent/EmcDigi.h"
13#include "MdcRawEvent/MdcDigi.h"
14#include "TofRawEvent/TofDigi.h"
15#include "MucRawEvent/MucDigi.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< EmcDigi > EmcDigiCol
Definition: EmcDigi.h:43
ObjectVector< MdcDigi > MdcDigiCol
Definition: MdcDigi.h:39
void combineMdcDigits(SmartDataPtr< MdcDigiCol > &mcDigits, MdcDigiCol &bgDigits, int verbosity)
Definition: MixerAlg.cxx:923
void combineTofDigits(SmartDataPtr< TofDigiCol > &mcDigits, TofDigiCol &bgDigits, int verbosity)
Definition: MixerAlg.cxx:972
void combineDigits(SmartDataPtr< T1 > &mcDigits, T1 &bgDigits, int verbosity)
Definition: MixerAlg.cxx:875
ObjectVector< MucDigi > MucDigiCol
Definition: MucDigi.h:29
ObjectVector< TofDigi > TofDigiCol
Definition: TofDigi.h:41
manage multiple CLHEP random engines as named streams
std::string prepareDbQuery()
Definition: MixerAlg.cxx:84
bool file_sort(std::vector< std::string > &files, std::vector< int > &ranEvtNums)
Definition: MixerAlg.cxx:1153
void mixDigi(SmartDataPtr< MdcDigiCol > &mdcMcDigits, SmartDataPtr< EmcDigiCol > &emcMcDigits, SmartDataPtr< MucDigiCol > &mucMcDigits, SmartDataPtr< TofDigiCol > &tofMcDigits)
Definition: MixerAlg.cxx:987
void decodeMuc(MucDigiCol *digiCol)
Definition: MixerAlg.cxx:1068
void decodeEmc(EmcDigiCol *digiCol)
Definition: MixerAlg.cxx:1074
StatusCode finalize()
Definition: MixerAlg.cxx:700
bool nextEvent(int nskip=0, int evtbyte=0, int eventsToEnd=0)
Definition: MixerAlg.cxx:708
int getTiming()
Definition: MixerAlg.cxx:1099
StatusCode execute()
Definition: MixerAlg.cxx:266
StatusCode initialize()
Definition: MixerAlg.cxx:115
~MixerAlg()
Definition: MixerAlg.h:52
void decodeMdc(MdcDigiCol *digiCol)
Definition: MixerAlg.cxx:1062
void decodeTof(TofDigiCol *digiCol)
Definition: MixerAlg.cxx:1080
std::string eventType()
Definition: MixerAlg.cxx:1086