Changeset 4833 for trunk/MagicSoft/Mars/manalysis
- Timestamp:
- 09/02/04 15:18:09 (20 years ago)
- Location:
- trunk/MagicSoft/Mars/manalysis
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/manalysis/MEventRateCalc.cc
r2917 r4833 47 47 // 48 48 // 49 // In addition the difference between the event time of the current event 50 // and the last event is written into a MParameterD calles MTimeDiff. 51 // 52 // 49 53 // Input Containers: 50 54 // MTime … … 52 56 // Output Containers: 53 57 // MEventRate 58 // MTimeDiff [MParameterD] 54 59 // MTimeRate [MTime] (missing) 55 60 // … … 62 67 #include "MEventRateCalc.h" 63 68 64 #include "MParList.h"69 #include <fstream> 65 70 66 71 #include "MLog.h" 67 72 #include "MLogManip.h" 68 73 74 #include "MParList.h" 75 69 76 #include "MTime.h" 70 77 #include "MEventRate.h" 78 #include "MParameters.h" 71 79 72 80 ClassImp(MEventRateCalc); … … 74 82 using namespace std; 75 83 84 const TString MEventRateCalc::gsDefName = "MEventRateCalc"; 85 const TString MEventRateCalc::gsDefTitle = "Calculate event rate"; 86 87 const TString MEventRateCalc::gsNameTime = "MTime"; 88 const TString MEventRateCalc::gsNameEventRate = "MEventRate"; 89 const TString MEventRateCalc::gsNameTimeDiff = "MTimeDiff"; 90 91 const Int_t MEventRateCalc::gsNumEvents = 1000; 92 76 93 // -------------------------------------------------------------------------- 77 94 // … … 79 96 // 80 97 MEventRateCalc::MEventRateCalc(const char *name, const char *title) 81 : fTimes(1000) 82 { 83 fName = name ? name : "MEventRateCalc"; 84 fTitle = title ? title : "Calculate trigger rate"; 98 : fNameTime(gsNameTime), fNameEventRate(gsNameEventRate), 99 fNameTimeDiff(gsNameTimeDiff), fTimes(gsNumEvents) 100 { 101 fName = name ? name : gsDefName.Data(); 102 fTitle = title ? title : gsDefTitle.Data(); 85 103 } 86 104 … … 97 115 Int_t MEventRateCalc::PreProcess(MParList *pList) 98 116 { 99 fTime = (MTime*)pList->FindObject( "MTime");117 fTime = (MTime*)pList->FindObject(AddSerialNumber(fNameTime), "MTime"); 100 118 if (!fTime) 101 119 { … … 104 122 } 105 123 106 fRate = (MEventRate*)pList->FindCreateObj("MEventRate" );124 fRate = (MEventRate*)pList->FindCreateObj("MEventRate", AddSerialNumber(fNameEventRate)); 107 125 if (!fRate) 126 return kFALSE; 127 128 fTimeDiff = (MParameterD*)pList->FindCreateObj("MParameterD", AddSerialNumber(fNameTimeDiff)); 129 if (!fTimeDiff) 108 130 return kFALSE; 109 131 … … 137 159 fRate->SetReadyToSave(); 138 160 161 fTimeDiff->SetVal(exec==0 ? -1 : fTimes[n1%n] - fTimes[(n1+n-1)%n]); 162 fTimeDiff->SetReadyToSave(); 163 139 164 return kTRUE; 140 165 } 166 167 // -------------------------------------------------------------------------- 168 // 169 // Implementation of SavePrimitive. Used to write the call to a constructor 170 // to a macro. In the original root implementation it is used to write 171 // gui elements to a macro-file. 172 // 173 void MEventRateCalc::StreamPrimitive(ofstream &out) const 174 { 175 out << " MEventRateCalc " << GetUniqueName() << "("; 176 if (fName!=gsDefName || fTitle!=gsDefTitle) 177 { 178 out << "\"" <<fName << "\""; 179 if (fTitle!=gsDefTitle) 180 out << ", \"" << fTitle << "\""; 181 } 182 out << ");" << endl; 183 184 if (fTimes.GetSize()!=gsNumEvents) 185 out << " " << GetUniqueName() << ".SetNumEvents(" << fTimes.GetSize() << ");" << endl; 186 } 187 188 // -------------------------------------------------------------------------- 189 // 190 // Read the setup from a TEnv, eg: 191 // MEventRateCalc.NumEvents: 1000 192 // 193 Int_t MEventRateCalc::ReadEnv(const TEnv &env, TString prefix, Bool_t print) 194 { 195 Bool_t rc = kFALSE; 196 if (IsEnvDefined(env, prefix, "NumEvents", print)) 197 { 198 rc = kTRUE; 199 SetNumEvents(GetEnvValue(env, prefix, "NumEvents", fTimes.GetSize())); 200 } 201 202 return rc; 203 } -
trunk/MagicSoft/Mars/manalysis/MEventRateCalc.h
r2626 r4833 5 5 #include "MTask.h" 6 6 #endif 7 #ifndef MARS_MTime8 #include "MTime.h"9 #endif10 7 #ifndef ROOT_TArrayD 11 8 #include <TArrayD.h> 12 9 #endif 13 10 11 class MTime; 14 12 class MEventRate; 13 class MParameterD; 15 14 16 15 class MEventRateCalc : public MTask 17 16 { 18 MTime *fTime; //! 19 MEventRate *fRate; //! 17 private: 18 static const TString gsDefName; //! Default name of container 19 static const TString gsDefTitle; //! Default title of container 20 20 21 //ULong_t fEvtNumber; //! 22 //MTime fEvtTime; //! 21 static const TString gsNameTime; //! Default name of time container 22 static const TString gsNameEventRate; //! default name of rate container 23 static const TString gsNameTimeDiff; //! default name of time-diff container 23 24 24 //UInt_t fNumEvents;25 static const Int_t gsNumEvents; //! Default number of events 25 26 26 TArrayD fTimes; //!27 27 28 MTime *fTime; //! pointer to event time 29 MEventRate *fRate; //! pointer to rate storage container 30 MParameterD *fTimeDiff; //! Difference of time between two consecutive events 31 32 TString fNameTime; // name of time container 33 TString fNameEventRate; // name of event rate container 34 TString fNameTimeDiff; // name of time-diff container 35 36 TArrayD fTimes; //! internal array to store the last n event times 28 37 29 38 … … 31 40 Int_t Process(); 32 41 42 void StreamPrimitive(ofstream &out) const; 43 Int_t ReadEnv(const TEnv &env, TString prefix, Bool_t print); 44 33 45 public: 34 46 MEventRateCalc(const char *name=NULL, const char *title=NULL); 35 47 36 void SetNumEvents(ULong_t num) { /*fNumEvents = num;*/fTimes.Set(num); }48 void SetNumEvents(ULong_t num) { fTimes.Set(num); } 37 49 38 ClassDef(MEventRateCalc, 0)// Task to calculate event rates 50 void SetNameTime(const char *name) { fNameTime = name; } 51 void SetNameEventRate(const char *name) { fNameEventRate = name; } 52 void SetNameTimeDiff(const char *name) { fNameTimeDiff = name; } 53 54 ClassDef(MEventRateCalc, 1)// Task to calculate event rates 39 55 }; 40 56
Note:
See TracChangeset
for help on using the changeset viewer.