Changeset 2743 for trunk/MagicSoft/Mars
- Timestamp:
- 12/22/03 20:07:48 (21 years ago)
- Location:
- trunk/MagicSoft/Mars
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/Changelog
r2742 r2743 8 8 * manalysis/MCT1FindSupercuts.cc, manalysis/MFindSupercuts.cc: 9 9 - replaced MFRandomSplit by MFEventSelector 10 11 * mfilter/FilterLinkDef.h, mfilter/Makefile: 12 - removed MFRandomSplit (functionality already implemented 13 in MFEventSelector) 14 15 * mfilter/MFEventSelector.[h,cc]: 16 - did some cosmetics 17 - removed some obsolete data members 18 - added some comments 19 20 * mfilter/MFEventSelector2.[h,cc]: 21 - added some comments 10 22 11 23 … … 90 102 - added many small comment about future development 91 103 92 * manalysis/MExtractSignal. cc:104 * manalysis/MExtractSignal.[h,cc]: 93 105 - removed arguments from constructor 94 106 - added corresponding member functions … … 96 108 construtor and member functions to change the default 97 109 - removed obsolete PostProcess 110 ! PLEASE update you code accordingly. 98 111 99 112 * manalysis/MExtractedSignalCam.h, manalysis/MExtractedSignalPix.h: … … 141 154 moment 142 155 143 * mtools/MTMinui .[h,cc]:156 * mtools/MTMinuit.[h,cc]: 144 157 - added (will replace MMinuitInterface soon) 145 158 -
trunk/MagicSoft/Mars/mfilter/FilterLinkDef.h
r2704 r2743 28 28 29 29 #pragma link C++ class MFEnergySlope+; 30 #pragma link C++ class MFRandomSplit+;31 30 32 31 #endif -
trunk/MagicSoft/Mars/mfilter/MFEventSelector.cc
r2206 r2743 30 30 // present implementation you can only use a random selection. 31 31 // 32 // This filter can be used for a random split... 33 // 32 34 // If you want to fill only 50% of your events into a histogram please use: 33 35 // MFEventSelector sel; … … 60 62 // Remark: You can also use the filter together with MContinue 61 63 // 64 // 65 // FIXME: Merge MFEventSelector and MFEventSelector2 66 // 62 67 ///////////////////////////////////////////////////////////////////////////// 63 68 #include "MFEventSelector.h" … … 81 86 // -------------------------------------------------------------------------- 82 87 // 83 // Default Constructor. Don't use.84 //85 /*86 MFEventSelector::MFEventSelector()87 : fNumTotalEvts(-1), fNumSelectEvts(-1), fSelRatio(-1), fNumSelectedEvts(0)88 {89 fName = gsDefName.Data();90 fTitle = gsDefTitle.Data();91 }92 */93 // --------------------------------------------------------------------------94 //95 88 // Constructor. For the text describing the filter rule please see 96 89 // the class description above. … … 105 98 // -------------------------------------------------------------------------- 106 99 // 100 // Set a probability with which events are selected. Eg, f=0.5 101 // will select roughly half of all events. 102 // 103 void MFEventSelector::SetSelectionRatio(Float_t f) 104 { 105 if (f < 0) 106 { 107 *fLog << warn << "MFEventSelector::SetSelectionRatio: WARNING - Probability less than 0... set to 0." << endl; 108 f = 0; 109 } 110 111 if (f > 1) 112 { 113 *fLog << warn << "MFEventSelector::SetSelectionRatio: WARNING - Probability greater than 1... set to 1." << endl; 114 f = 1; 115 } 116 fSelRatio = f; 117 } 118 119 // -------------------------------------------------------------------------- 120 // 107 121 // PreProcess all filters. 108 122 // 109 123 Int_t MFEventSelector::PreProcess(MParList *plist) 110 124 { 111 memset(fErrors, 0, sizeof(fErrors));112 113 125 fNumSelectedEvts = 0; 126 127 // In the case a ratio was set by the user we are done. 114 128 if (fSelRatio>0) 115 129 return kTRUE; 116 130 131 // If the number of total events wasn't set try to get it 117 132 if (fNumTotalEvts<0) 118 133 { … … 120 135 if (!tlist) 121 136 { 122 *fLog << err << dbginf << "Sorry can't determin total number of events... no MTaskList." << endl;137 *fLog << err << "Can't determin total number of events... no MTaskList." << endl; 123 138 return kFALSE; 124 139 } … … 127 142 if (!read) 128 143 { 129 *fLog << err << dbginf << "Sorry can't determin total number of events from 'MRead'." << endl;144 *fLog << err << "Can't determin total number of events from 'MRead'." << endl; 130 145 return kFALSE; 131 146 } 132 147 fNumTotalEvts = read->GetEntries(); 133 148 134 *fLog << "MFEventSelector::PreProcess; fNumTotalEvts = "135 << fNumTotalEvts << endl;136 137 149 SetBit(kNumTotalFromFile); 138 150 } 139 151 152 // Calculate selection probability 153 fSelRatio = (Double_t)fNumSelectEvts/fNumTotalEvts; 154 155 *fLog << inf << "MFEventSelector: Selection probability = " << fNumSelectEvts; 156 *fLog << "/" << fNumTotalEvts << " = " << Form("%.2f", fSelRatio) << endl; 157 140 158 return kTRUE; 141 159 } … … 143 161 // -------------------------------------------------------------------------- 144 162 // 145 // Process all filters. 163 // Process all filters, FIXME: Make it fit the requested number of events 164 // exactly like it is done in MFEventSelector2. This can be done by merging 165 // both classes! 146 166 // 147 167 Int_t MFEventSelector::Process() 148 168 { 149 Int_t rc; 150 151 const Float_t evt = gRandom->Uniform(); 152 153 if (fNumSelectEvts>0) 154 fResult = evt*fNumTotalEvts < fNumSelectEvts; 155 else 156 fResult = evt < fSelRatio; 157 158 if (fResult) 159 { 160 fNumSelectedEvts++; 161 162 rc = 0; 163 fErrors[rc]++; 169 fResult = gRandom->Uniform() < fSelRatio; 170 171 if (!fResult) 164 172 return kTRUE; 165 } 166 167 rc = 1; 168 fErrors[rc]++; 169 173 174 fNumSelectedEvts++; 170 175 return kTRUE; 171 176 } … … 180 185 if (GetNumExecutions() != 0) 181 186 { 182 *fLog << inf << endl; 183 *fLog << GetDescriptor() << " execution statistics:" << endl; 184 *fLog << dec << setfill(' '); 185 *fLog << " " << setw(7) << fErrors[1] << " (" << setw(3) 186 << (int)(fErrors[1]*100/GetNumExecutions()) 187 << "%) Events not selected" << endl; 188 189 *fLog << " " << fErrors[0] << " (" 190 << (int)(fErrors[0]*100/GetNumExecutions()) 191 << "%) Events selected!" << endl; 192 *fLog << endl; 187 const Double_t sel = (Double_t)fNumSelectedEvts/GetNumExecutions(); 188 const UInt_t non = GetNumExecutions()-fNumSelectedEvts; 189 190 *fLog << inf << dec << setfill(' ') << endl; 191 *fLog << GetDescriptor() << " execution statistics:" << endl; 192 193 *fLog << " " << setw(7) << non << " (" << setw(3); 194 *fLog << (int)(100*(1-sel)) << "%) Events not selected" << endl; 195 196 *fLog << " " << setw(7) << fNumSelectedEvts << " ("; 197 *fLog << (int)(100*sel) << "%) Events selected!" << endl; 198 *fLog << endl; 193 199 } 194 200 … … 196 202 if (TestBit(kNumTotalFromFile)) 197 203 fNumTotalEvts = -1; 204 198 205 return kTRUE; 199 206 } … … 219 226 out << ");" << endl; 220 227 */ 221 222 } 228 } -
trunk/MagicSoft/Mars/mfilter/MFEventSelector.h
r2206 r2743 1 1 #ifndef MARS_MFEventSelector 2 2 #define MARS_MFEventSelector 3 4 /////////////////////////////////////////////////////////////////////////////5 // //6 // MFEventSelector //7 // //8 /////////////////////////////////////////////////////////////////////////////9 3 10 4 #ifndef MARS_MFilter … … 17 11 { 18 12 private: 19 Int_t fNumTotalEvts; 20 Int_t fNumSelectEvts; 21 Float_t fSelRatio; 13 Int_t fNumTotalEvts; // Number of total events from which are selected 14 Int_t fNumSelectEvts; // Number of events to be selected 15 Float_t fSelRatio; // Selection Probability 22 16 23 Int_t fNumSelectedEvts; //! 17 Int_t fNumSelectedEvts; //! Number of events which have been selected 24 18 25 Bool_t fResult; 19 Bool_t fResult; //! Reseult of a single selection 26 20 27 21 void StreamPrimitive(ofstream &out) const; … … 33 27 enum { kNumTotalFromFile = BIT(14) }; 34 28 35 Int_t fErrors[2];36 37 29 public: 38 30 MFEventSelector(const char *name=NULL, const char *title=NULL); … … 40 32 Bool_t IsExpressionTrue() const { return fResult; } 41 33 42 void SetNumTotalEvts(Int_t n) { fNumTotalEvts = n; ResetBit(kNumTotalFromFile); }34 void SetNumTotalEvts(Int_t n) { fNumTotalEvts = n; ResetBit(kNumTotalFromFile); } 43 35 void SetNumSelectEvts(Int_t n) { fNumSelectEvts = n; } 44 void SetSelectionRatio(Float_t f) { fSelRatio = f; }36 void SetSelectionRatio(Float_t f); 45 37 46 ClassDef(MFEventSelector, 0) // A Filter to select events from files38 ClassDef(MFEventSelector, 0) // A filter to do a random selection of events 47 39 }; 48 40 -
trunk/MagicSoft/Mars/mfilter/MFEventSelector2.cc
r2728 r2743 92 92 // Remark: You can also use the filter together with MContinue 93 93 // 94 // 95 // FIXME: Merge MFEventSelector and MFEventSelector2 96 // 94 97 ///////////////////////////////////////////////////////////////////////////// 95 98 #include "MFEventSelector2.h" … … 225 228 } 226 229 227 tlist.PrintStatistics( 0, kTRUE);230 tlist.PrintStatistics(); 228 231 229 232 *fLog << inf; -
trunk/MagicSoft/Mars/mfilter/MFEventSelector2.h
r2693 r2743 63 63 Bool_t IsExpressionTrue() const { return fResult; } 64 64 65 ClassDef(MFEventSelector2, 0) 65 ClassDef(MFEventSelector2, 0) // FIMXE! 66 66 }; 67 67 68 68 #endif 69 70 71 -
trunk/MagicSoft/Mars/mfilter/Makefile
r2736 r2743 52 52 MFSelFinal.cc \ 53 53 MFSoftwareTrigger.cc \ 54 MFEnergySlope.cc \ 55 MFRandomSplit.cc 54 MFEnergySlope.cc 56 55 57 56 SRCS = $(SRCFILES)
Note:
See TracChangeset
for help on using the changeset viewer.