Changeset 5073 for trunk/MagicSoft
- Timestamp:
- 09/16/04 16:17:29 (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/mmontecarlo/MMcCollectionAreaCalc.cc
r2252 r5073 78 78 if (!fMcEvt) 79 79 { 80 *fLog << err << dbginf << "MMcEvt not found... exit." << endl;80 *fLog << err << "MMcEvt not found... abort." << endl; 81 81 return kFALSE; 82 82 } … … 87 87 Bool_t MMcCollectionAreaCalc::ReInit(MParList *plist) 88 88 { 89 fCollArea=0; 90 89 91 MMcRunHeader *runheader = (MMcRunHeader*)plist->FindObject("MMcRunHeader"); 90 92 if (!runheader) 91 93 { 92 *fLog << err << dbginf << "Error - MMcRunHeader not found... exit." << endl; 93 return kFALSE; 94 *fLog << err << "Error - MMcRunHeader not found... abort." << endl; 95 return kFALSE; 96 } 97 98 fTotalNumSimulatedShowers += runheader->GetNumSimulatedShowers(); 99 *fLog << inf << "Total Number of Simulated showers: " << fTotalNumSimulatedShowers << endl; 100 101 102 if (fTheta>=0 && fTheta!=runheader->GetTelesTheta()) 103 { 104 *fLog << warn << "Warning - Read files have different TelesTheta ("; 105 *fLog << fTheta << ", " << runheader->GetTelesTheta() << ")..." << endl; 106 } 107 fTheta = runheader->GetTelesTheta(); 108 109 110 if (fCorsikaVersion!=0 && fCorsikaVersion!=runheader->GetCorsikaVersion()) 111 *fLog << warn << "Warning - Read files have different Corsika versions..." << endl; 112 fCorsikaVersion = runheader->GetCorsikaVersion(); 113 114 115 fAllEvtsTriggered |= runheader->GetAllEvtsTriggered(); 116 *fLog << inf << "Only triggered events avail: " << (fAllEvtsTriggered?"yes":"no") << endl; 117 118 119 fCollArea = (MHMcCollectionArea*)plist->FindCreateObj("MHMcCollectionArea"); 120 if (!fCollArea) 121 return kFALSE; 122 123 if (!fAllEvtsTriggered) 124 { 125 fMcTrig = (MMcTrig*)plist->FindObject(fObjName); 126 if (!fMcTrig) 127 { 128 *fLog << err << fObjName << " [MMcTrig] not found... anort." << endl; 129 return kFALSE; 130 } 131 return kTRUE; 94 132 } 95 133 … … 97 135 if (!corrunheader) 98 136 { 99 *fLog << err << dbginf << "Error - MMcCorsikaRunHeader not found... exit." << endl; 100 return kFALSE; 101 } 102 103 fTotalNumSimulatedShowers += runheader->GetNumSimulatedShowers(); 104 *fLog << inf << "Total Number of Simulated showers: " << fTotalNumSimulatedShowers << endl; 105 106 107 if (fTheta>=0 && fTheta!=runheader->GetTelesTheta()) 108 { 109 *fLog << warn << dbginf << "Warning - Read files have different TelesTheta ("; 110 *fLog << fTheta << ", " << runheader->GetTelesTheta() << ")..." << endl; 111 } 112 fTheta = runheader->GetTelesTheta(); 113 114 115 if (fCorsikaVersion!=0 && fCorsikaVersion!=runheader->GetCorsikaVersion()) 116 *fLog << warn << dbginf << "Warning - Read files have different Corsika versions..." << endl; 117 fCorsikaVersion = runheader->GetCorsikaVersion(); 118 119 120 fAllEvtsTriggered |= runheader->GetAllEvtsTriggered(); 121 *fLog << inf << "Only triggered events avail: " << (fAllEvtsTriggered?"yes":"no") << endl; 122 123 124 fCollArea = (MHMcCollectionArea*)plist->FindCreateObj("MHMcCollectionArea"); 125 if (!fCollArea) 126 return kFALSE; 127 128 if (fAllEvtsTriggered) 129 { 130 // 131 // Calculate approximately the original number of events in each 132 // energy bin: 133 // 134 135 const Float_t emin = corrunheader->GetELowLim(); 136 const Float_t emax = corrunheader->GetEUppLim(); 137 const Float_t expo = 1 + corrunheader->GetSlopeSpec(); 138 const Float_t k = runheader->GetNumSimulatedShowers() / 139 (pow(emax,expo) - pow(emin,expo)) ; 140 141 TH2 &hall = *fCollArea->GetHistAll(); 142 143 const Int_t nbinx = hall.GetNbinsX(); 144 145 TAxis &axe = *hall.GetXaxis(); 146 for (Int_t i = 1; i <= nbinx; i++) 147 { 148 const Float_t e1 = axe.GetBinLowEdge(i); 149 const Float_t e2 = axe.GetBinLowEdge(i+1); 150 151 if (e1 < emin || e2 > emax) 152 continue; 153 154 const Float_t events = k * (pow(e2, expo) - pow(e1, expo)); 155 // 156 // We fill the i-th energy bin, with the total number of events 157 // Second argument of Fill would be impact parameter of each 158 // event, but we don't really need it for the collection area, 159 // so we just put a dummy value (1.) 160 // 161 162 const Float_t energy = (e1+e2)/2.; 163 hall.Fill(energy, 1., events); 164 } 165 166 return kTRUE; 167 } 168 169 fMcTrig = (MMcTrig*)plist->FindObject(fObjName); 170 if (!fMcTrig) 171 { 172 *fLog << err << dbginf << fObjName << " [MMcTrig] not found... exit." << endl; 173 return kFALSE; 137 *fLog << err << "MMcCorsikaRunHeader not found... abort." << endl; 138 return kFALSE; 139 } 140 141 // 142 // Calculate approximately the original number of events in each 143 // energy bin: 144 // 145 146 const Float_t emin = corrunheader->GetELowLim(); 147 const Float_t emax = corrunheader->GetEUppLim(); 148 const Float_t expo = 1 + corrunheader->GetSlopeSpec(); 149 const Float_t k = runheader->GetNumSimulatedShowers() / 150 (pow(emax,expo) - pow(emin,expo)) ; 151 152 TH2 &hall = *fCollArea->GetHistAll(); 153 154 const Int_t nbinx = hall.GetNbinsX(); 155 156 TAxis &axe = *hall.GetXaxis(); 157 for (Int_t i = 1; i <= nbinx; i++) 158 { 159 const Float_t e1 = axe.GetBinLowEdge(i); 160 const Float_t e2 = axe.GetBinLowEdge(i+1); 161 162 if (e1 < emin || e2 > emax) 163 continue; 164 165 const Float_t events = k * (pow(e2, expo) - pow(e1, expo)); 166 // 167 // We fill the i-th energy bin, with the total number of events 168 // Second argument of Fill would be impact parameter of each 169 // event, but we don't really need it for the collection area, 170 // so we just put a dummy value (1.) 171 // 172 173 const Float_t energy = (e1+e2)/2.; 174 hall.Fill(energy, 1., events); 174 175 } 175 176 … … 205 206 206 207 Int_t MMcCollectionAreaCalc::PostProcess() 207 { 208 { 209 if (!fCollArea) 210 return kTRUE; 211 208 212 // 209 213 // do the calculation of the effectiv area
Note:
See TracChangeset
for help on using the changeset viewer.