Changeset 1783 for trunk/MagicSoft/Mars/mmontecarlo/MMcTriggerRateCalc.cc
- Timestamp:
- 02/21/03 18:09:36 (22 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/mmontecarlo/MMcTriggerRateCalc.cc
r1376 r1783 38 38 #include "MMcEvt.hxx" 39 39 #include "MMcTrig.hxx" 40 #include "MMcRunHeader.hxx" 41 #include "MMcCorsikaRunHeader.h" 40 42 41 43 ClassImp(MMcTriggerRateCalc); 42 44 43 void MMcTriggerRateCalc::Init(int dim, int part, float *trigbg, 44 float simbg, 45 void MMcTriggerRateCalc::Init(int dim, float *trigbg, float simbg, 45 46 const char *name, const char *title) 46 47 { … … 51 52 fMcRate = NULL; 52 53 54 fTrigNSB = trigbg; 55 fSimNSB = simbg; 56 57 fPartId = -1; 58 53 59 fShowers = 0; 54 fAnalShow = simbg; 55 56 fPartId=part; 60 fAnalShow = 0; 57 61 58 62 fFirst = dim>0 ? 1 : -dim; … … 60 64 61 65 fNum = fLast-fFirst+1; 62 63 66 fTrigger = new float[fNum]; 64 67 65 68 for (UInt_t i=0;i<fNum;i++) 66 fTrigger[i] = dim&&trigbg ? trigbg[i] : 0; 67 69 fTrigger[i]=0; 70 71 AddToBranchList("MMcEvt.fPartId"); 68 72 AddToBranchList("MMcEvt.fImpact"); 69 73 AddToBranchList("MMcEvt.fEnergy"); … … 72 76 AddToBranchList("MMcEvt.fPhotElfromShower"); 73 77 AddToBranchList("MMcTrig", "fNumFirstLevel", fFirst, fLast); 78 79 } 80 81 // ReInit: read run header to get some info later: 82 83 Bool_t MMcTriggerRateCalc::ReInit(MParList *pList) 84 { 85 fMcRunHeader = (MMcRunHeader*) pList->FindObject("MMcRunHeader"); 86 if (!fMcRunHeader) 87 { 88 *fLog << err << dbginf << "Error - MMcRunHeader not found... exit." << endl; 89 return kFALSE; 90 } 91 92 fMcCorRunHeader = (MMcCorsikaRunHeader*) pList->FindObject("MMcCorsikaRunHeader"); 93 if (!fMcCorRunHeader) 94 { 95 *fLog << err << dbginf << "Error - MMcCorsikaRunHeader not found... exit." << endl; 96 return kFALSE; 97 } 98 99 if (fMcRunHeader->GetAllEvtsTriggered()) 100 fShowers += fMcRunHeader->GetNumSimulatedShowers(); 101 102 if (fMcRunHeader->GetAllEvtsTriggered()) 103 { 104 *fLog << endl << all << endl << 105 "WARNING: the input data file contains only the" << endl << 106 "events that triggered. I will assume the standard value" << endl << 107 "for maximum impact parameter (400 m)" <<endl; 108 109 110 if (fTrigNSB[0] > 0) 111 *fLog << endl << all << 112 "WARNING: NSB rate can be overestimated by up to 5%." << endl << 113 "For a precise estimate of the total rate including NSB" << endl << 114 "accidental triggers I need a file containing all event headers." 115 << endl; 116 else 117 *fLog << endl << all << 118 "WARNING: calculating only shower rate (no NSB accidental triggers)" << endl; 119 } 120 121 *fLog << endl << all << 122 "WARNING: I will assume the standard maximum off axis angle" << endl << 123 "(5 degrees) for the original showers" << endl; 124 125 for (UInt_t i=0; i<fNum; i++) 126 { 127 if (fMcRunHeader->GetAllEvtsTriggered()) 128 { 129 GetRate(i)->SetImpactMin(0.); 130 GetRate(i)->SetImpactMax(40000.); // in cm 131 } 132 GetRate(i)->SetSolidAngle(2.390941702e-2); // sr 133 134 // 135 // Set limits of energy range, coverting from GeV to TeV: 136 // 137 GetRate(i)->SetEnergyMin(fMcCorRunHeader->GetELowLim()/1000.); 138 GetRate(i)->SetEnergyMax(fMcCorRunHeader->GetEUppLim()/1000.); 139 140 } 141 142 return kTRUE; 74 143 } 75 144 … … 79 148 // 80 149 // dim: fDimension 81 // part: fPartId 82 // *trigbg: number of shower from bacground that triggers 150 // *trigbg: number of NSB triggers for 83 151 // a given trigger condition. 84 // simbg: Number of simulated showers for the background152 // simbg: Number of simulated events for the NSB 85 153 // rate: rate of incident showers 86 154 // 87 155 88 MMcTriggerRateCalc::MMcTriggerRateCalc(float rate, int dim, int part,156 MMcTriggerRateCalc::MMcTriggerRateCalc(float rate, int dim, 89 157 float *trigbg, float simbg, 90 158 const char *name, const char *title) 91 159 { 92 Init(dim, part,trigbg, simbg, name, title);160 Init(dim, trigbg, simbg, name, title); 93 161 } 94 162 … … 99 167 // 100 168 // dim: fDimension 101 // part: fPartId 102 // *trigbg: number of shower from bacground that triggers 169 // *trigbg: number of NSB triggers for 103 170 // a given trigger condition. 104 // simbg: Number of simulated showers for the background 105 // 106 MMcTriggerRateCalc::MMcTriggerRateCalc(int dim, int part, float *trigbg, 107 float simbg, 171 // simbg: Number of simulated events for the NSB 172 // 173 MMcTriggerRateCalc::MMcTriggerRateCalc(int dim, float *trigbg,float simbg, 108 174 const char *name, const char *title) 109 175 { 110 Init(dim, part,trigbg, simbg, name, title);176 Init(dim, trigbg, simbg, name, title); 111 177 } 112 178 … … 160 226 } 161 227 228 for (UInt_t i=0;i<fNum;i++) 229 { 230 MHMcRate &rate = *GetRate(i); 231 232 if (fTrigNSB) 233 rate.SetBackground(fTrigNSB[i], fSimNSB); 234 else 235 rate.SetBackground(0., fSimNSB); 236 } 237 238 return kTRUE; 239 } 240 241 // -------------------------------------------------------------------------- 242 // 243 // The Process-function counts the number of simulated showers, the 244 // number of analised showers and the number of triggers. It also updates 245 // the limits for theta, phi, energy and impact parameter in the 246 // MHMcRate container. 247 // 248 Bool_t MMcTriggerRateCalc::Process() 249 { 250 // 251 // Counting analysed showers (except in the case in which the file 252 // contains only events that triggered, since then we do not know 253 // how many showers were analysed). 254 // 255 256 if ( ! fMcRunHeader->GetAllEvtsTriggered() && 257 fMcEvt->GetPhotElfromShower() ) 258 fAnalShow++; 259 260 // 261 // Set PartId and check it is the same for all events 262 // 263 if (fPartId < 0) 264 fPartId = fMcEvt->GetPartId(); 265 else if (fPartId != fMcEvt->GetPartId()) 266 { 267 *fLog << err << dbginf << "Incident particle type seems to change"; 268 *fLog << "from " << fPartId << " to " << fMcEvt->GetPartId() << endl; 269 *fLog << "in input data files... aborting." << endl; 270 return kFALSE; 271 } 272 273 // 274 // Getting angles, energy and impact parameter to set boundaries 275 // 276 const Float_t theta = fMcEvt->GetTheta(); 277 const Float_t phi = fMcEvt->GetPhi(); 278 const Float_t param = fMcEvt->GetImpact(); 279 const Float_t ener = fMcEvt->GetEnergy()/1000.0; 280 281 // 282 // Counting number of triggers 283 // 284 for (UInt_t i=0; i<fNum; i++) 285 { 286 if (GetTrig(i)->GetFirstLevel()) 287 fTrigger[i] ++; 288 289 if ( ! fMcRunHeader->GetAllEvtsTriggered()) 290 GetRate(i)->UpdateBoundaries(ener, theta, phi, param); 291 } 292 293 return kTRUE; 294 } 295 296 // -------------------------------------------------------------------------- 297 // 298 // The PostProcess-function calculates and shows the trigger rate 299 // 300 Bool_t MMcTriggerRateCalc::PostProcess() 301 { 162 302 for (UInt_t i=0; i<fNum; i++) 163 303 { … … 168 308 { 169 309 case kPROTON: 170 rate.SetFlux(0.1091, 2.75); 171 break; 310 if (fMcCorRunHeader->GetSlopeSpec() != -2.75) 311 { 312 *fLog << err << dbginf << 313 "Spectrum slope as read from input file ("<< 314 fMcCorRunHeader->GetSlopeSpec() << ") does not match the expected one (-2.75) for protons" << endl << "... aborting." << endl; 315 return kFALSE; 316 } 317 rate.SetFlux(0.1091, 2.75); 318 break; 172 319 case kHELIUM: 173 rate.SetFlux(0.0660, 2.62); 174 break; 320 if (fMcCorRunHeader->GetSlopeSpec() != -2.62) 321 { 322 *fLog << err << dbginf << 323 "Spectrum slope as read from input file ("<< 324 fMcCorRunHeader->GetSlopeSpec() << ") does not match the expected one (-2.75) for Helium" << endl << "... aborting." << endl; 325 return kFALSE; 326 } 327 rate.SetFlux(0.0660, 2.62); 328 break; 175 329 default: 176 177 178 330 *fLog << err << dbginf << "Unknown incident flux parameters for "; 331 *fLog << fPartId<< " particle Id ... aborting." << endl; 332 return kFALSE; 179 333 } 180 rate.SetBackground(fTrigger[i], fAnalShow); 181 182 fTrigger[i]=0; 183 } 184 185 fAnalShow=0.0; 186 187 return kTRUE; 188 } 189 190 // -------------------------------------------------------------------------- 191 // 192 // The Process-function counts the number of simulated showers, the 193 // number of analised showers and the number of triggers. It also updates 194 // the limits for theta, phi, energy and impact parameter in the 195 // MHMcRate container. 196 // 197 Bool_t MMcTriggerRateCalc::Process() 198 { 199 // 200 // Counting analysed and simulated showers 201 // 202 fShowers++; 203 if (fMcEvt->GetPhotElfromShower()) 204 fAnalShow++; 205 206 // 207 // Getting angles, energy and impact parameter to set boundaries 208 // 209 const Float_t theta = fMcEvt->GetTheta(); 210 const Float_t phi = fMcEvt->GetPhi(); 211 const Float_t param = fMcEvt->GetImpact(); 212 const Float_t ener = fMcEvt->GetEnergy()/1000.0; 213 214 // 215 // Counting number of triggers 216 // 217 for (UInt_t i=0; i<fNum; i++) 218 { 219 if (GetTrig(i)->GetFirstLevel()) 220 fTrigger[i] ++; 221 222 GetRate(i)->UpdateBoundaries(ener, theta, phi, param); 223 } 224 225 return kTRUE; 226 } 227 228 // -------------------------------------------------------------------------- 229 // 230 // The PostProcess-function calculates and shows the trigger rate 231 // 232 Bool_t MMcTriggerRateCalc::PostProcess() 233 { 334 } 335 234 336 // 235 337 // Computing trigger rate
Note:
See TracChangeset
for help on using the changeset viewer.