Changeset 1783 for trunk/MagicSoft/Mars
- Timestamp:
- 02/21/03 18:09:36 (22 years ago)
- Location:
- trunk/MagicSoft/Mars
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MagicSoft/Mars/Changelog
r1782 r1783 1 1 2 2 -*-*- END -*-*- 3 2003/02/21: Abelardo Moralejo 4 5 * mmontecarlo/MMcTriggerRateCalc.[h,cc] 6 - adapted to new camera files, added warnings. 7 - added ReInit procedure to read relevant info from from the run headers 8 9 * mhist/MHMcRate.[h,cc] 10 - adapted accordingly. Added Set functions for several members. 11 12 * mmc/MMcCorsikaRunHeader.h 13 - added Get functions for fELowLim, fEUppLim and fSlopeSpec. 14 15 * mmain/MMontecarlo.cc, macros/trigrate.C 16 - adapted to changes above, changed MReadTree to MReadMarsFile to 17 be able to read the run headers. 18 3 19 2003/02/21: Antonio Stamerra 4 20 -
trunk/MagicSoft/Mars/macros/trigrate.C
r1543 r1783 124 124 // analised trigger conditions should be set (BgR[]) 125 125 // 126 MReadTree reader("Events", filename); 126 127 MReadMarsFile reader("Events", filename); 127 128 tasklist.AddToList(&reader); 128 129 … … 141 142 cout << "Number of Trigger conditions: " << num << endl; 142 143 143 MMcTriggerRateCalc rate(dim, kPROTON, BgR, numnsbevents); 144 MMcTriggerRateCalc rate(dim, BgR, numnsbevents); 145 144 146 tasklist.AddToList(&rate); 145 147 -
trunk/MagicSoft/Mars/mhist/MHMcRate.cc
r1534 r1783 18 18 ! Author(s): Thomas Bretz 12/2000 <mailto:tbretz@uni-sw.gwdg.de> 19 19 ! Author(s): Harald Kornmayer 1/2001 20 ! Author(s): Abelardo Moralejo 2/2003 21 ! 22 ! Explanations on the rate calculation can be found in 23 ! chapter 7 of the following diploma thesis: 24 ! http://www.pd.infn.it/magic/tesi2.ps.gz (in Italian) 20 25 ! 21 26 ! Copyright: MAGIC Software Development, 2000-2001 … … 38 43 fPartId=0; // Type of particle 39 44 40 fEnergyMax=0.0; // Maximum Energy in GeV 41 fEnergyMin=1000000.0; // Minimum Energy in GeV 42 45 fEnergyMax=0.0; // Maximum Energy (TeV) 46 fEnergyMin=1000000.0; // Minimum Energy (TeV) 47 48 fSolidAngle = -1.; // Solid angle within which incident directions 49 // are distributed 43 50 fThetaMax=0.0; // Maximum theta angle of run 44 51 fThetaMin=370.0; // Minimum theta angle of run … … 119 126 // -------------------------------------------------------------------------- 120 127 // 121 // Set the information about trigger due only to the background conditions128 // Set the information about trigger due only to the Night Sky Background: 122 129 // 123 130 void MHMcRate::SetBackground (Float_t showers, Float_t triggers) … … 184 191 185 192 if (fShowerRate <= 0) 186 fShowerRate = fFlux0/specidx*(epowmin-epowmax); 193 fShowerRate = fFlux0/specidx*(epowmax-epowmin); 194 195 if (fSolidAngle < 0.) 196 fSolidAngle = (fPhiMax-fPhiMin)*(cos(fThetaMin)-cos(fThetaMax)); 187 197 188 198 if (fPartId!=1) 189 fShowerRate *= (fPhiMax-fPhiMin)*(cos(fThetaMax)-cos(fThetaMin)); 190 191 const Double_t impactdiff = fImpactMax-fImpactMin; 192 193 fShowerRate *= TMath::Pi()*(impactdiff/100.0*impactdiff/100.0); 199 fShowerRate *= fSolidAngle; 200 201 fShowerRate *= TMath::Pi()*(fImpactMax/100.0*fImpactMax/100.0 - 202 fImpactMin/100.0*fImpactMin/100.0); 194 203 195 204 fShowerRateError = sqrt(fShowerRate); -
trunk/MagicSoft/Mars/mhist/MHMcRate.h
r1663 r1783 12 12 UShort_t fPartId; // Type of particle 13 13 14 Float_t fEnergyMax; // Maximum Energy in GeV15 Float_t fEnergyMin; // Minimum Energy in GeV14 Float_t fEnergyMax; // Maximum Energy in TeV 15 Float_t fEnergyMin; // Minimum Energy in TeV 16 16 17 17 Float_t fThetaMax; // Maximum theta angle of run … … 20 20 Float_t fPhiMin; // Minimum phi angle of run 21 21 22 Float_t fImpactMax; // Maximum impact parameter 23 Float_t fImpactMin; // Minimum impact parameter 22 Float_t fSolidAngle; // Solid angle within which incident directions 23 // are distributed (sr) 24 25 Float_t fImpactMax; // Maximum impact parameter (cm) 26 Float_t fImpactMin; // Minimum impact parameter (cm) 24 27 25 28 Float_t fBackTrig; // Number of triggers from background … … 50 53 void SetIncidentRate(Float_t showerrate); 51 54 55 void SetImpactMax(Float_t Impact) {fImpactMax=Impact;} 56 void SetImpactMin(Float_t Impact) {fImpactMin=Impact;} 57 58 void SetThetaMax(Float_t Theta) {fThetaMax=Theta;} 59 void SetThetaMin(Float_t Theta) {fThetaMin=Theta;} 60 void SetPhiMax(Float_t Phi) {fPhiMax=Phi;} 61 void SetPhiMin(Float_t Phi) {fPhiMin=Phi;} 62 63 void SetSolidAngle(Float_t Solid) {fSolidAngle=Solid;} 64 void SetEnergyMax(Float_t Energy) {fEnergyMax=Energy;} 65 void SetEnergyMin(Float_t Energy) {fEnergyMin=Energy;} 66 52 67 void UpdateBoundaries(Float_t energy, Float_t theta, Float_t phi, Float_t impact); 53 68 -
trunk/MagicSoft/Mars/mmain/MMonteCarlo.cc
r1668 r1783 349 349 // analised trigger conditions should be set (BgR[]) 350 350 // 351 MRead Tree read("Events", fInputFile);351 MReadMarsFile read("Events", fInputFile); 352 352 tlist.AddToList(&read); 353 353 354 Float_t BgR[10]={660, 4, 0, 0, 0, 0, 0, 0, 0, 0}; 355 356 MMcTriggerRateCalc crate(dim, 14, BgR, 100000); 354 // We calculate only shower rate (not including NSB-only triggers) 355 Float_t* BgR = new Float_t[dim]; 356 memset(BgR, 0, num*sizeof(Float_t)); 357 358 MMcTriggerRateCalc crate(dim, BgR, 100000); 357 359 tlist.AddToList(&crate); 358 360 -
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 -
trunk/MagicSoft/Mars/mmontecarlo/MMcTriggerRateCalc.h
r1376 r1783 11 11 class MParList; 12 12 class MMcEvt; 13 class MMcRunHeader; 14 class MMcCorsikaRunHeader; 13 15 class MMcTrig; 14 16 class MHMcRate; … … 22 24 TObjArray *fMcTrig; 23 25 26 MMcRunHeader *fMcRunHeader; 27 MMcCorsikaRunHeader *fMcCorRunHeader; 28 24 29 UInt_t fNum; // decoded dimension 25 30 UInt_t fFirst; 26 31 UInt_t fLast; 27 32 28 Float_t* fTrigger; // Number of triggered showers 33 Float_t* fTrigNSB; // Number of triggers due to NSB alone 34 Float_t fSimNSB; // Number of simulated NSB-only events 29 35 36 Float_t* fTrigger; // Number of triggered showers 30 37 Float_t fShowers; // Number of simulated showers 31 38 Float_t fAnalShow; // Number of analysed showers … … 33 40 Int_t fPartId; // Incident particle that generates showers 34 41 35 void Init(int dim, int part,float *trigbg,42 void Init(int dim, float *trigbg, 36 43 float simbg, const char *name, const char *title); 37 44 … … 40 47 41 48 public: 42 MMcTriggerRateCalc(int dim=0, int part=14, float *trigbg=NULL, 43 float simbg=100000, 49 MMcTriggerRateCalc(int dim=0, float *trigbg=NULL, float simbg=100000, 44 50 const char *name=NULL, const char *title=NULL); 45 51 46 MMcTriggerRateCalc(float rate, int dim, int part, float *trigbg, 47 float simbg, 52 MMcTriggerRateCalc(float rate, int dim, float *trigbg, float simbg, 48 53 const char *name=NULL, const char *title=NULL); 49 54 50 55 ~MMcTriggerRateCalc(); 56 57 Bool_t ReInit(MParList *plist); 51 58 52 59 Bool_t PreProcess(MParList *pList);
Note:
See TracChangeset
for help on using the changeset viewer.