File indexing completed on 2024-11-16 09:02:05
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #ifndef INCLUDE_EICSMEAR_ERHIC_FORESTER_H_
0011 #define INCLUDE_EICSMEAR_ERHIC_FORESTER_H_
0012
0013
0014 #include <cmath>
0015 #include <ctime>
0016 #include <fstream>
0017 #include <iomanip>
0018 #include <iostream>
0019 #include <string>
0020
0021
0022 #include <Rtypes.h>
0023 #include <TFile.h>
0024 #include <TStopwatch.h>
0025 #include <TTree.h>
0026
0027
0028 #include "eicsmear/erhic/EventMC.h"
0029
0030 namespace erhic {
0031
0032 class FileType;
0033 class VirtualEventFactory;
0034
0035
0036
0037
0038
0039
0040 class Forester : public TObject {
0041 public:
0042
0043
0044
0045 Forester();
0046
0047
0048
0049
0050 virtual ~Forester();
0051
0052
0053
0054
0055
0056 Long64_t Plant();
0057
0058
0059
0060
0061 void SetInputFileName(const std::string&);
0062
0063
0064
0065
0066 void SetOutputFileName(const std::string&);
0067
0068
0069
0070
0071
0072 void SetTreeName(const std::string& = "EICTree");
0073
0074
0075
0076
0077
0078 void SetBranchName(const std::string& = "event");
0079
0080
0081
0082
0083 std::string GetInputFileName() const;
0084
0085
0086
0087
0088 std::string GetOutputFileName() const;
0089
0090
0091
0092
0093
0094 std::string GetTreeName() const;
0095
0096
0097
0098
0099 std::string GetBranchName() const;
0100
0101
0102
0103
0104
0105
0106
0107 void SetMaxNEvents(Long64_t = 0);
0108
0109
0110
0111
0112 Long64_t GetMaxNEvents() const;
0113
0114
0115
0116
0117
0118 void SetMessageInterval(Long64_t = 10000);
0119
0120
0121
0122
0123 void Print(std::ostream& stream) const;
0124
0125
0126
0127
0128
0129
0130 void Print(Option_t* = "not used") const;
0131
0132
0133
0134
0135
0136 void SetBeVerbose(bool = false);
0137
0138
0139
0140
0141 bool BeVerbose() const;
0142
0143
0144
0145
0146
0147
0148 const erhic::FileType* GetFileType() const;
0149
0150
0151
0152
0153
0154 class Status{
0155 public:
0156 Status();
0157 virtual ~Status();
0158 virtual std::ostream& Print(std::ostream& os = std::cout) const;
0159
0160 protected:
0161 virtual void StartTimer();
0162 virtual void StopTimer();
0163 virtual void ModifyEventCount(Long64_t count);
0164 virtual void ModifyParticleCount(Long64_t count);
0165
0166 time_t mStartTime;
0167 time_t mEndTime;
0168 Long64_t mNEvents;
0169 Long64_t mNParticles;
0170
0171
0172 mutable TStopwatch mTimer;
0173
0174 friend class Forester;
0175
0176 ClassDef(Status, 1);
0177 };
0178
0179 protected:
0180
0181
0182
0183
0184 const Status& GetGetStatus() const {
0185 return mStatus;
0186 }
0187
0188
0189
0190
0191
0192
0193
0194 bool OpenInput();
0195
0196
0197
0198
0199 bool SetupOutput();
0200
0201
0202
0203
0204 void Finish();
0205
0206
0207
0208
0209
0210
0211 bool AllocateEvent();
0212
0213
0214
0215
0216
0217
0218
0219 bool FindFirstEvent();
0220
0221
0222 void PrintStatus() const;
0223
0224
0225
0226
0227
0228
0229
0230 bool MustQuit() const;
0231
0232
0233 void SetMustQuit(bool quit);
0234
0235
0236
0237
0238
0239
0240 Bool_t mQuit;
0241 Bool_t mVerbose;
0242 TTree* mTree;
0243 VirtualEvent* mEvent;
0244 const erhic::FileType* mFile;
0245 TFile* mRootFile;
0246 Long64_t mMaxNEvents;
0247 Long64_t mInterval;
0248
0249 std::shared_ptr<std::istream> mTextFile;
0250 std::string mInputName;
0251 std::string mOutputName;
0252 std::string mTreeName;
0253 std::string mBranchName;
0254 std::string mLine;
0255 Status mStatus;
0256 VirtualEventFactory* mFactory;
0257
0258 ClassDef(Forester, 3)
0259 };
0260
0261 inline void Forester::SetInputFileName(const std::string& name) {
0262 mInputName = name;
0263 }
0264
0265 inline void Forester::SetOutputFileName(const std::string& name) {
0266 mOutputName = name;
0267 }
0268
0269 inline void Forester::SetTreeName(const std::string& name) {
0270 mTreeName = name;
0271 }
0272
0273 inline void Forester::SetBranchName(const std::string& name) {
0274 mBranchName = name;
0275 }
0276
0277 inline std::string Forester::GetInputFileName() const {
0278 return mInputName;
0279 }
0280
0281 inline std::string Forester::GetOutputFileName() const {
0282 return mOutputName;
0283 }
0284
0285 inline std::string Forester::GetTreeName() const {
0286 return mTreeName;
0287 }
0288
0289 inline std::string Forester::GetBranchName() const {
0290 return mBranchName;
0291 }
0292
0293 inline void Forester::SetMaxNEvents(Long64_t number) {
0294 mMaxNEvents = number;
0295 }
0296
0297 inline Long64_t Forester::GetMaxNEvents() const {
0298 return mMaxNEvents;
0299 }
0300
0301 inline void Forester::SetMessageInterval(Long64_t number) {
0302 mInterval = number;
0303 }
0304
0305 inline bool Forester::MustQuit() const {
0306 return mQuit;
0307 }
0308
0309 inline void Forester::SetMustQuit(bool flag) {
0310 mQuit = flag;
0311 }
0312
0313 inline void Forester::SetBeVerbose(bool flag) {
0314 mVerbose = flag;
0315 }
0316
0317 inline bool Forester::BeVerbose() const {
0318 return mVerbose;
0319 }
0320
0321 inline const FileType* Forester::GetFileType() const {
0322 return mFile;
0323 }
0324
0325 }
0326
0327 #endif