Changeset 5869 for trunk/MagicSoft/Mars/manalysis
- Timestamp:
- 01/17/05 11:54:30 (20 years ago)
- Location:
- trunk/MagicSoft/Mars/manalysis
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/manalysis/MEnergyEstimate.cc
r2206 r5869 25 25 26 26 ///////////////////////////////////////////////////////////////////////////// 27 // // 28 // MEnergyEstimate // 29 // // 30 // Task to estimate the energy // 31 // // 32 // // 27 // 28 // MEnergyEstimate 29 // 30 // Task to estimate the energy by a rule, eg: 31 // 32 // MEnergyEstimate est; 33 // est.SetRule("0.5 + (1.1*MHillas.fLength) + (2.2*MHillasSrc.fDist) + (3.3*MHillas.fSize) +" 34 // "(4.4*MHillas.fSize*MHillas.fLength) + (5.5*MHillasSrc.fDist*MHillas.fLength)"); 35 // 36 // For description of rules, see MDataChain. 37 // 38 // The default rule is "MMcEvt.fEnergy" 39 // 40 // Output: 41 // MEnergyEst 42 // 33 43 ///////////////////////////////////////////////////////////////////////////// 34 44 #include "MEnergyEstimate.h" … … 36 46 #include "MParList.h" 37 47 38 #include "MMcEvt.hxx" 39 #include "MHillas.h" 48 #include "MDataChain.h" 40 49 #include "MEnergyEst.h" 41 50 … … 47 56 using namespace std; 48 57 58 // -------------------------------------------------------------------------- 59 // 60 // Default constructor. Initialize fData with default rule "MMcEvt.fEnergy" 61 // 62 MEnergyEstimate::MEnergyEstimate(const char *name, const char *title) 63 : fData(0), fEnergy(0) 64 { 65 fName = name ? name : "MEnergyEstimate"; 66 fTitle = title ? title : "Task to estimate the energy by a rule"; 67 68 fData = new MDataChain("MMcEvt.fEnergy"); 69 } 49 70 50 71 // -------------------------------------------------------------------------- 51 72 // 52 // Default constructor.73 // delete fData 53 74 // 54 MEnergyEstimate:: MEnergyEstimate(const char *name, const char *title)75 MEnergyEstimate::~MEnergyEstimate() 55 76 { 56 fName = name ? name : "MEnergyEstimate"; 57 fTitle = title ? title : "Task to estimate the energy"; 58 59 AddToBranchList("MMcEvt.fEnergy"); 77 delete fData; 60 78 } 61 79 80 // -------------------------------------------------------------------------- 81 // 82 // Delete fData. Initialize a new MDataChain with rule. 83 // Returns if fData->IsValid() 84 // 85 Bool_t MEnergyEstimate::SetRule(const char *rule) 86 { 87 delete fData; 88 fData = new MDataChain(rule); 89 90 return fData->IsValid(); 91 } 92 93 // -------------------------------------------------------------------------- 94 // 95 // Forwards SetVariables to fData to allow optimizations. 96 // 97 void MEnergyEstimate::SetVariables(const TArrayD &arr) 98 { 99 fData->SetVariables(arr); 100 } 101 102 // -------------------------------------------------------------------------- 103 // 104 // FindCreate "MEnergyEst" 105 // PreProcess fData. 106 // 62 107 Int_t MEnergyEstimate::PreProcess(MParList *plist) 63 108 { 64 fHillas = (MHillas*)plist->FindObject("MHillas"); 65 if (!fHillas) 66 { 67 *fLog << err << dbginf << "MHillas not found... aborting." << endl; 68 return kFALSE; 69 } 109 fEnergy = (MEnergyEst*)plist->FindCreateObj("MEnergyEst"); 110 if (!fEnergy) 111 return kFALSE; 70 112 71 fMcEvt = (MMcEvt*)plist->FindObject("MMcEvt"); 72 if (!fMcEvt) 73 { 74 *fLog << err << dbginf << "MMcEvt not found... aborting." << endl; 75 return kFALSE; 76 } 113 if (!fData->PreProcess(plist)) 114 return kFALSE; 77 115 78 fEnergy = (MEnergyEst*)plist->FindCreateObj("MEnergyEst"); 79 if (!fEnergy) 80 return kFALSE; 116 *fLog << inf << "Rule for energy estimation: " << fData->GetRule() << endl; 81 117 82 return kTRUE;118 return kTRUE; 83 119 } 84 120 121 // -------------------------------------------------------------------------- 122 // 123 // Get value from fData and set it to fEnergy. SetReadyToSave for fEnergy. 124 // Return kCONTINUE if value is NaN (Not a Number) 125 // 85 126 Int_t MEnergyEstimate::Process() 86 127 { 87 //fEnergy->SetEnergy(fHillas->GetSize()); 88 fEnergy->SetEnergy(fMcEvt->GetEnergy()); 89 return kTRUE; 128 const Double_t val = fData->GetValue(); 129 if (TMath::IsNaN(val)) 130 return kCONTINUE; 131 132 fEnergy->SetEnergy(val); 133 fEnergy->SetReadyToSave(); 134 return kTRUE; 90 135 } -
trunk/MagicSoft/Mars/manalysis/MEnergyEstimate.h
r2206 r5869 6 6 #endif 7 7 8 class MMcEvt; 9 class MHillas; 8 class MData; 10 9 class MEnergyEst; 11 10 … … 13 12 { 14 13 private: 15 MMcEvt *fMcEvt; 16 MHillas *fHillas; 14 MData *fData; //-> 17 15 MEnergyEst *fEnergy; 18 16 19 17 public: 20 18 MEnergyEstimate(const char *name=NULL, const char *title=NULL); 19 ~MEnergyEstimate(); 20 21 Bool_t SetRule(const char *rule); 21 22 22 23 Int_t PreProcess(MParList *plist); 23 24 Int_t Process(); 24 25 25 ClassDef(MEnergyEstimate, 0) // Task to copy the MC energy (preliminary) 26 void SetVariables(const TArrayD &); 27 28 ClassDef(MEnergyEstimate, 0) // Task to estimate the energy by a rule 26 29 }; 27 30
Note:
See TracChangeset
for help on using the changeset viewer.