BOSS 7.1.2
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_maxLoop;
125 bool m_ifSmearT0;
126
127 int m_readBGMethod;
128
129 bool m_usingFilter;
130
131 // Current bg file
132 std::string currentBGFile;
133
134 // Current MC file
135 std::string currentMCFile;
136
137 // Input file name of background data (raw data format)
138 std::vector<std::string> m_bgfiles;
139 std::vector<std::string> m_bgfilesIndex;
140 //std::vector<std::string>::iterator m_bgfile;
141
142 // Replace /besfs/offline/data/randomtrg in the file name from the database to the user defined value
143 std::string m_pattern;
144 // Use the user defined value of directory which contains random trigger files
145 std::string m_newdatadir;
146
147 // Reference to RealizationSvc
148 RealizationSvc* m_RealizationSvc;
149 DataInfoSvc* m_jobInfoSvc;
150
151 NTuple::Tuple* m_tuple1;
152 NTuple::Item<float> m_time1;
153 NTuple::Item<float> m_time2;
154 NTuple::Item<float> m_time3;
155 NTuple::Item<float> m_time4;
156 NTuple::Item<float> m_time5;
157
158 NTuple::Tuple* m_tuple2;
159 NTuple::Tuple* m_tuple3;
160 NTuple::Item<long> m_tdc;
161
162 IBesTimerSvc* m_timersvc;
163 BesTimer* m_timer;
164 BesTimer* m_timer1;
165 bool m_ifOutPut;
166 bool m_dump;
167
168 //caogf for random seed
169 IBesRndmGenSvc* p_BesRndmGenSvc;
170
171 //configuration file for raw data revise
172 std::string m_rawReviseConfig;
173};
174
175#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:935
void combineTofDigits(SmartDataPtr< TofDigiCol > &mcDigits, TofDigiCol &bgDigits, int verbosity)
Definition MixerAlg.cxx:984
void combineDigits(SmartDataPtr< T1 > &mcDigits, T1 &bgDigits, int verbosity)
Definition MixerAlg.cxx:887
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)
void mixDigi(SmartDataPtr< MdcDigiCol > &mdcMcDigits, SmartDataPtr< EmcDigiCol > &emcMcDigits, SmartDataPtr< MucDigiCol > &mucMcDigits, SmartDataPtr< TofDigiCol > &tofMcDigits)
Definition MixerAlg.cxx:999
void decodeMuc(MucDigiCol *digiCol)
void decodeEmc(EmcDigiCol *digiCol)
StatusCode finalize()
Definition MixerAlg.cxx:705
bool nextEvent(int nskip=0, int evtbyte=0, int eventsToEnd=0)
Definition MixerAlg.cxx:713
MixerAlg(const std::string &name, ISvcLocator *pSvcLocator)
Definition MixerAlg.cxx:38
int getTiming()
StatusCode execute()
Definition MixerAlg.cxx:267
StatusCode initialize()
Definition MixerAlg.cxx:115
~MixerAlg()
Definition MixerAlg.h:52
void decodeMdc(MdcDigiCol *digiCol)
void decodeTof(TofDigiCol *digiCol)
std::string eventType()