#include <PTSimValidate.h>
Public Member Functions | |
| PTSimValidate () | |
| virtual | ~PTSimValidate () |
| bool | RunAllTests () |
Private Member Functions | |
| bool | TestPTSim () |
| bool | TestClearStdHepSecondaries () |
| bool | TestParticle () |
| bool | TestStack () |
| bool | TestStackSaveSecondaryConfiguration () |
| bool | TestParticleIsSelected () |
| bool | TestInitSnarl () |
Private Attributes | |
| TClonesArray * | fStdHepArray |
| TClonesArray * | fHitArray |
| PTSimApplication | fPTSimApplication |
|
|
Definition at line 42 of file PTSimValidate.cxx. 00042 : fStdHepArray(0),fHitArray(0), 00043 fPTSimApplication("test","test") { 00044 // Default constructor 00045 00046 }
|
|
|
Definition at line 49 of file PTSimValidate.cxx. References fStdHepArray. 00049 {
00050 // Destructor
00051
00052 if ( fStdHepArray ) delete fStdHepArray; fStdHepArray = 0;
00053
00054 }
|
|
|
Definition at line 57 of file PTSimValidate.cxx. References TestInitSnarl(), TestParticle(), and TestStack(). Referenced by main(). 00057 {
00058 //
00059 // Purpose: Run sequence of ParticleTransportSim package validity tests.
00060 //
00061 // Arguments: none.
00062 //
00063 // Return: pass (if all tests successful) or fail
00064 //
00065 // Contact: S. Kasahara
00066 //
00067
00068 cout << "*** PTSimValidate::RunAllTests ***\n" << endl;
00069
00070 bool allpassed = true; // assume the best
00071
00072 allpassed |= TestParticle();
00073 allpassed |= TestStack();
00074 allpassed |= TestInitSnarl();
00075
00076 cout << "\n*** Finished all tests: ***" << endl;
00077
00078 return allpassed;
00079 }
|
|
|
|
|
|
Definition at line 1010 of file PTSimValidate.cxx. References fPTSimApplication, fStdHepArray, PTSimApplication::GetEvtStdHepMap(), PTSimApplication::InitSnarl(), and Lit::Print(). Referenced by RunAllTests(). 01010 {
01011
01012 bool pass = true;
01013
01014 // Take the existing fStdHepArray, filled with the first 10 events
01015 // in PTSimStack, and use it as input
01016
01017 // args: number of snarls, array, number of events
01018 fPTSimApplication.InitSnarl(0,fStdHepArray,10);
01019
01020 const PTSimApplication::EvtStdHepMap& evtstdhepmap
01021 = fPTSimApplication.GetEvtStdHepMap();
01022
01023 for ( unsigned int ievt = 0; ievt < evtstdhepmap.size(); ievt++ ) {
01024 cout << "****** Event " << ievt << " ******" << endl;
01025 PTSimModule::EvtStdHepMap::const_iterator idItr = evtstdhepmap.find(ievt);
01026 if ( idItr != evtstdhepmap.end() ) {
01027 const std::vector<TParticle*>& stdheplist = idItr->second;
01028 for ( unsigned int is = 0; is < stdheplist.size(); is++ ) {
01029 TParticle* prim = stdheplist[is];
01030 prim -> Print();
01031 }
01032 }
01033
01034 }
01035
01036 return pass;
01037
01038 }
|
|
|
Definition at line 82 of file PTSimValidate.cxx. References UtilIstHEP::AsString(), and Particle::Mass(). Referenced by RunAllTests(). 00082 {
00083 // Test PTSimParticle class
00084
00085 bool pass = true;
00086 cout << "*** TestParticle ***" << endl;
00087
00088 // Create a particle and test that it's attributes match expected.
00089 // Print particle.
00090
00091 Int_t particleId = 0;
00092 Int_t pdgcode = 13; // muon
00093 const TDatabasePDG& dbpdg = *(TDatabasePDG::Instance());
00094 Double_t mass = dbpdg.GetParticle(pdgcode) -> Mass();
00095 Double_t charge = dbpdg.GetParticle(pdgcode) -> Charge();
00096
00097 Int_t statuscode = UtilIstHEP::kNFinal;
00098 TLorentzVector pmom(1.,2.,3.,4.);
00099 TLorentzVector pos(5.,6.,7.,8.);
00100 Double_t pol[3] = {1.,0.,0.};
00101 Double_t weight = 1.;
00102 TMCProcess process = kPPrimary;
00103
00104 PTSimParticle particle(particleId,pdgcode,statuscode,
00105 pmom.Px(),pmom.Py(),pmom.Pz(),pmom.E(),
00106 pos.X(),pos.Y(),pos.Z(),pos.T(),process);
00107
00108 particle.SetPolarisation(pol[0],pol[1],pol[2]);
00109 particle.SetWeight(weight);
00110
00111 Int_t childId = particleId + 1;
00112 PTSimParticle childparticle(childId,const_cast<TParticle*>
00113 (particle.GetTParticle()),process);
00114 particle.AddChild(&childparticle);
00115 childparticle.AddParent(&particle);
00116
00117 Int_t siblingId = childId + 1;
00118 PTSimParticle siblingparticle(siblingId,const_cast<TParticle*>
00119 (childparticle.GetTParticle()),
00120 process);
00121 childparticle.AddSibling(&siblingparticle);
00122
00123 particle.Print();
00124 particle.GetTParticle()->Print();
00125 childparticle.Print();
00126 siblingparticle.Print();
00127
00128 // **** Tests of base class MCAppParticle methods ****
00129 if ( particle.GetID() != particleId ) {
00130 cout << "particle.GetID() " << particle.GetID() << " != particleId "
00131 << particleId << endl;
00132 pass = false;
00133 }
00134
00135 if ( particle.GetNChildren() != 1 ) {
00136 cout << "particle.GetNChildren() " << particle.GetNChildren()
00137 << " != 1" << endl;
00138 pass = false;
00139 }
00140 if ( particle.GetChild(0)->GetID() != 1 ) {
00141 cout << "particle.GetChild(0)->GetID() "
00142 << particle.GetChild(0)->GetID()
00143 << " != 1 " << endl;
00144 pass = false;
00145 }
00146 if ( particle.GetChildID(0) != 1 ) {
00147 cout << "particle.GetChildID(0) "
00148 << particle.GetChildID(0)
00149 << " != 1 " << endl;
00150 pass = false;
00151 }
00152
00153 if ( particle.GetNParents() != 0 ) {
00154 cout << "particle.GetNParents() " << particle.GetNParents()
00155 << " != 0" << endl;
00156 pass = false;
00157 }
00158
00159 if ( particle.GetNSiblings() != 0 ) {
00160 cout << "particle.GetNSiblings() " << particle.GetNSiblings()
00161 << " != 0" << endl;
00162 pass = false;
00163 }
00164
00165 if ( childparticle.GetNParents() != 1 ) {
00166 cout << "childparticle.GetNParents() " << childparticle.GetNParents()
00167 << " != 1" << endl;
00168 pass = false;
00169 }
00170 if ( childparticle.GetParent(0)->GetID() != 0 ) {
00171 cout << "childparticle.GetParent(0)->GetID() "
00172 << childparticle.GetParent(0)->GetID()
00173 << " != 0 " << endl;
00174 pass = false;
00175 }
00176 if ( childparticle.GetParentID(0) != 0 ) {
00177 cout << "childparticle.GetParentID(0) "
00178 << childparticle.GetParentID(0)
00179 << " != 0 " << endl;
00180 pass = false;
00181 }
00182
00183 if ( childparticle.GetNChildren() != 0 ) {
00184 cout << "childparticle.GetNChildren() " << childparticle.GetNChildren()
00185 << " != 0" << endl;
00186 pass = false;
00187 }
00188
00189 if ( childparticle.GetNSiblings() != 1 ) {
00190 cout << "childparticle.GetNSiblings() " << childparticle.GetNSiblings()
00191 << " != 1" << endl;
00192 pass = false;
00193 }
00194 if ( childparticle.GetSibling(0)->GetID() != 2 ) {
00195 cout << "childparticle.GetSibling(0)->GetID() "
00196 << childparticle.GetSibling(0)->GetID()
00197 << " != 2 " << endl;
00198 pass = false;
00199 }
00200 if ( childparticle.GetSiblingID(0) != 2 ) {
00201 cout << "childparticle.GetSiblingID(0) "
00202 << childparticle.GetSiblingID(0)
00203 << " != 2 " << endl;
00204 pass = false;
00205 }
00206
00207
00208 if ( particle.GetProcess() != process ) {
00209 cout << "particle.GetProcess() " << particle.GetProcess()
00210 << " != process " << endl;
00211 pass = false;
00212 }
00213
00214 if ( particle.GetPdgCode() != pdgcode ) {
00215 cout << "particle.GetPdgCode() " << particle.GetPdgCode()
00216 << " != pdgcode " << pdgcode << endl;
00217 pass = false;
00218 }
00219
00220 if ( particle.GetEnergy() != pmom.E() ) {
00221 cout << "particle.GetEnergy() " << particle.GetEnergy()
00222 << " != pmom.E() " << pmom.E() << endl;
00223 pass = false;
00224 }
00225
00226 if ( particle.GetMass() != mass ) {
00227 cout << "particle.GetMass() " << particle.GetMass() << " != mass "
00228 << mass << endl;
00229 pass = false;
00230 }
00231
00232 if ( particle.GetStatusCode() != statuscode ) {
00233 cout << "particle.GetStatusCode() " << particle.GetStatusCode()
00234 << " != statuscode " << statuscode << endl;
00235 pass = false;
00236 }
00237
00238 if ( particle.GetStatusCodeName() !=
00239 std::string(UtilIstHEP::AsString(statuscode))) {
00240 cout << "particle.GetStatusCodeName() "
00241 << (particle.GetStatusCodeName()).c_str()
00242 << " != UtilIstHEP::AsString(statuscode) "
00243 << UtilIstHEP::AsString(statuscode) << endl;
00244 pass = false;
00245 }
00246
00247 if ( particle.GetCharge() != charge ) {
00248 cout << "particle.GetCharge() " << particle.GetCharge() << " != charge "
00249 << charge << endl;
00250 pass = false;
00251 }
00252
00253 if ( particle.GetWeight() != weight ) {
00254 cout << "particle.GetWeight() " << particle.GetWeight()
00255 << " != weight "
00256 << weight << endl;
00257 pass = false;
00258 }
00259
00260 TVector3 polvec;
00261 particle.GetPolarisation(polvec);
00262
00263 if ( polvec.X() != pol[0] ) {
00264 cout << "polvec.X() " << polvec.X() << " != pol[0] "
00265 << pol[0] << endl;
00266 pass = false;
00267 }
00268 if ( polvec.Y() != pol[1] ) {
00269 cout << "polvec.Y() " << polvec.Y() << " != pol[1] "
00270 << pol[1] << endl;
00271 pass = false;
00272 }
00273 if ( TMath::Abs(polvec.Z() - pol[2]) >= 1.e-6 ) {
00274 cout << "polvec.Z() " << polvec.Z() << " != pol[2] "
00275 << pol[2] << endl;
00276 pass = false;
00277 }
00278
00279
00280 TLorentzVector particlepmom;
00281 particle.ProductionMomentum(particlepmom);
00282
00283 if ( particlepmom.Px() != pmom.Px() ) {
00284 cout << "particlepmom.Px() " << particlepmom.Px() << " != pmom.Px() "
00285 << pmom.Px() << endl;
00286 pass = false;
00287 }
00288 if ( particlepmom.Py() != pmom.Py() ) {
00289 cout << "particlepmom.Py() " << particlepmom.Py() << " != pmom.Py() "
00290 << pmom.Py() << endl;
00291 pass = false;
00292 }
00293 if ( particlepmom.Pz() != pmom.Pz() ) {
00294 cout << "particlepmom.Pz() " << particlepmom.Pz() << " != pmom.Pz() "
00295 << pmom.Pz() << endl;
00296 pass = false;
00297 }
00298 if ( particlepmom.E() != pmom.E() ) {
00299 cout << "particlepmom.E() " << particlepmom.E() << " != pmom.E() "
00300 << pmom.E() << endl;
00301 pass = false;
00302 }
00303
00304 TLorentzVector particlevtx;
00305 particle.ProductionVertex(particlevtx);
00306
00307 if ( particlevtx.X() != pos.X() ) {
00308 cout << "particlevtx.X() " << particlevtx.X() << " != pos.X() "
00309 << pos.X() << endl;
00310 pass = false;
00311 }
00312 if ( particlevtx.Y() != pos.Y() ) {
00313 cout << "particlevtx.Y() " << particlevtx.Y() << " != pos.Y() "
00314 << pos.Y() << endl;
00315 pass = false;
00316 }
00317 if ( particlevtx.Z() != pos.Z() ) {
00318 cout << "particlevtx.Z() " << particlevtx.Z() << " != pos.Z() "
00319 << pos.Pz() << endl;
00320 pass = false;
00321 }
00322 if ( particlevtx.T() != pos.T() ) {
00323 cout << "particlevtx.T() " << particlevtx.T() << " != pos.T() "
00324 << pos.T() << endl;
00325 pass = false;
00326 }
00327
00328 // **** Tests of class PTSimParticle methods ****
00329 if ( particle.HasHitAboveThresh() ) {
00330 cout << "particle.HasHitAboveThresh() true, expect false" << endl;
00331 pass = false;
00332 }
00333
00334 particle.SetHasHitAboveThresh(true);
00335 if ( !particle.HasHitAboveThresh() ) {
00336 cout << "particle.HasHitAboveThresh() false, expect true" << endl;
00337 pass = false;
00338 }
00339
00340 if ( particle.IsSetToSave() ) {
00341 cout << "particle.IsSetToSave() true, expect false" << endl;
00342 pass = false;
00343 }
00344
00345 // SetToSave arguments: save,ancestor,sibling all true by default
00346 Int_t nset = particle.SetToSave(true,false,false);
00347 if ( nset != 1 ) {
00348 cout << "particle.SetToSave(true,false,false) returned nset " << nset
00349 << " expected 1" << endl;
00350 pass = false;
00351 }
00352 if ( !particle.IsSetToSave() ) {
00353 cout << "particle.IsSetToSave() false, expect true" << endl;
00354 pass = false;
00355 }
00356
00357 nset = particle.SetToSave(false,true,true);
00358 if ( nset != 1 ) {
00359 cout << "particle.SetToSave(false,false,false) returned nset " << nset
00360 << " expected 1" << endl;
00361 pass = false;
00362 }
00363
00364 nset = childparticle.SetToSave(true,true,false);
00365 if ( nset != 2 ) {
00366 cout << "childparticle.SetToSave(true,true,false) returned nset " << nset
00367 << " expected 2" << endl;
00368 pass = false;
00369 }
00370
00371 if ( !particle.IsSetToSave() ) {
00372 cout << "particle.IsSetToSave() false, expect true" << endl;
00373 pass = false;
00374 }
00375
00376 if ( !childparticle.IsSetToSave() ) {
00377 cout << "childparticle.IsSetToSave() false, expect true" << endl;
00378 pass = false;
00379 }
00380
00381 if ( siblingparticle.IsSetToSave() ) {
00382 cout << "siblingparticle.IsSetToSave() true, expect false" << endl;
00383 pass = false;
00384 }
00385
00386 nset = childparticle.SetToSave(false,true,true);
00387 if ( nset != 2 ) {
00388 cout << "childparticle.SetToSave(false,false,false) returned nset " << nset
00389 << " expected 2" << endl;
00390 pass = false;
00391 }
00392
00393 nset = childparticle.SetToSave(true,true,true);
00394 if ( nset != 3 ) {
00395 cout << "childparticle.SetToSave(true,true,true) returned nset " << nset
00396 << " expected 3" << endl;
00397 pass = false;
00398 }
00399
00400 if ( !particle.IsSetToSave() ) {
00401 cout << "particle.IsSetToSave() false, expect true" << endl;
00402 pass = false;
00403 }
00404
00405 if ( !childparticle.IsSetToSave() ) {
00406 cout << "childparticle.IsSetToSave() false, expect true" << endl;
00407 pass = false;
00408 }
00409
00410 if ( !siblingparticle.IsSetToSave() ) {
00411 cout << "siblingparticle.IsSetToSave() false, expect true" << endl;
00412 pass = false;
00413 }
00414
00415 if ( pass ) cout << "*** All TestParticle tests Passed ***" << endl;
00416 else cout << "*** At least one TestParticle test FAILED ***" << endl;
00417
00418 return pass;
00419
00420 }
|
|
|
Definition at line 602 of file PTSimValidate.cxx. References PTSimStack::ParticleIsSelected(), PTSimStack::SetStdHepSelectMask(), and PTSimStack::SetStdHepThrByType(). Referenced by TestStack(). 00602 {
00603 // Test PTSimStack::ParticleIsSelected(const PTSimParticle*) method
00604
00605 bool pass = true;
00606 cout << " *** TestParticleIsSelected ***" << endl;
00607
00608 PTSimStack ptsimstack;
00609
00610 Int_t particleId = 0;
00611 Int_t pdgcode = 13; // muon
00612 Int_t statuscode = UtilIstHEP::kNFinal;
00613 TLorentzVector pmom(0.,0.,0.,0.);
00614 TLorentzVector pos(5.,6.,7.,8.);
00615 Double_t pol[3] = {1.,0.,0.};
00616 Double_t weight = 1.;
00617 TMCProcess process = kPPrimary;
00618
00619 PTSimParticle particle(particleId,pdgcode,statuscode,
00620 pmom.Px(),pmom.Py(),pmom.Pz(),pmom.E(),
00621 pos.X(),pos.Y(),pos.Z(),pos.T(),process);
00622
00623 particle.SetPolarisation(pol[0],pol[1],pol[2]);
00624 particle.SetWeight(weight);
00625
00626 if ( !ptsimstack.ParticleIsSelected(&particle) ) {
00627 cout << "ptsimstack.ParticleIsSelected() false when"
00628 << " particle is PPrimary, expect true." << endl;
00629 pass = false;
00630 }
00631
00632 particle.SetProcess(kPPair);
00633 if ( ptsimstack.ParticleIsSelected(&particle) ) {
00634 cout << "ptsimstack.ParticleIsSelected() true when"
00635 << " particle not primary and P=0, expect false." << endl;
00636 pass = false;
00637 }
00638
00639 pmom.SetPxPyPzE(0.,0.,0.20,0.20);
00640 particle.SetProductionMomentum(pmom);
00641 if ( !ptsimstack.ParticleIsSelected(&particle) ) {
00642 cout << "ptsimstack.ParticleIsSelected() false when"
00643 << " particle not primary and P=0.2, expect true." << endl;
00644 pass = false;
00645 }
00646
00647 ptsimstack.SetStdHepSelectMask(0);
00648 if ( ptsimstack.ParticleIsSelected(&particle) ) {
00649 cout << "ptsimstack.ParticleIsSelected() true when"
00650 << " P above threshold but PTSim::kMomentum not selected." << endl;
00651 pass = false;
00652 }
00653
00654 ptsimstack.SetStdHepSelectMask(PTSim::kHit);
00655 if ( ptsimstack.ParticleIsSelected(&particle) ) {
00656 cout << "ptsimstack.ParticleIsSelected() true when"
00657 << " particle does not have hit above threshold, expect false."
00658 << endl;
00659 pass = false;
00660 }
00661
00662 particle.SetHasHitAboveThresh(true);
00663 if ( !ptsimstack.ParticleIsSelected(&particle) ) {
00664 cout << "ptsimstack.ParticleIsSelected() false when"
00665 << " particle has hit above threshold, expect true." << endl;
00666 pass = false;
00667 }
00668
00669 ptsimstack.SetStdHepSelectMask(PTSim::kHit | PTSim::kMomentum);
00670 if ( !ptsimstack.ParticleIsSelected(&particle) ) {
00671 cout << "ptsimstack.ParticleIsSelected() false when"
00672 << " particle does have hit above threshold"
00673 << " & P > threshold, expect true."
00674 << endl;
00675 pass = false;
00676 }
00677
00678 pmom.SetPxPyPzE(0.,0.,0.,0.);
00679 particle.SetProductionMomentum(pmom);
00680 if ( !ptsimstack.ParticleIsSelected(&particle) ) {
00681 cout << "ptsimstack.ParticleIsSelected() false when"
00682 << " particle does have hit above threshold"
00683 << ", expect true."
00684 << endl;
00685 pass = false;
00686 }
00687
00688 particle.SetHasHitAboveThresh(false);
00689 if ( ptsimstack.ParticleIsSelected(&particle) ) {
00690 cout << "ptsimstack.ParticleIsSelected() true when"
00691 << " particle does not have hit above threshold & P = 0"
00692 << ", expect false."
00693 << endl;
00694 pass = false;
00695 }
00696
00697 // Set momentum threshold by type
00698 Int_t pdgId = 13;
00699 process = kPPair;
00700 ptsimstack.SetStdHepThrByType(0.,process,pdgId);
00701 if ( !ptsimstack.ParticleIsSelected(&particle) ) {
00702 cout << "ptsimstack.ParticleIsSelected() false when"
00703 << " particle threshold by type set to P = 0 for production kPPair"
00704 << ", expect true."
00705 << endl;
00706 pass = false;
00707 }
00708
00709 TMCProcess process2 = kPBrem;
00710 particle.SetProcess(process2);
00711 if ( ptsimstack.ParticleIsSelected(&particle) ) {
00712 cout << "ptsimstack.ParticleIsSelected() true when"
00713 << " particle threshold by type set to P = 0 for production kPPair"
00714 << " but particle proc kPBrem, expect false."
00715 << endl;
00716 pass = false;
00717 }
00718
00719 ptsimstack.SetStdHepThrByType(0.,kPNoProcess,pdgId);
00720 if ( !ptsimstack.ParticleIsSelected(&particle) ) {
00721 cout << "ptsimstack.ParticleIsSelected() false when"
00722 << " particle threshold by type set to P = 0 for all processes"
00723 << ", expect true."
00724 << endl;
00725 pass = false;
00726 }
00727
00728 if ( pass )
00729 cout << " *** All TestParticleIsSelected tests Passed ***" << endl;
00730 else
00731 cout << " *** At least one TestParticleIsSelected test FAILED ***"
00732 << endl;
00733
00734 return pass;
00735
00736 }
|
|
|
|
|
|
Definition at line 740 of file PTSimValidate.cxx. References fHitArray, PTSimStack::FillStdHepArray(), fStdHepArray, MCAppStack< T >::GetCurrentParentTrackNumber(), MCAppStack< T >::GetCurrentTrack(), MCAppStack< T >::GetCurrentTrackNumber(), MCAppParticle::GetID(), MCAppStack< T >::GetNprimary(), MCAppStack< T >::GetNtrack(), MCAppStack< T >::GetParticle(), MCAppStack< T >::PopNextTrack(), MCAppStack< T >::PopPrimaryForTracking(), Lit::Print(), MCAppStack< T >::Print(), PTSimStack::PushTrack(), PTSimStack::Reset(), MCAppStack< T >::SetCurrentTrack(), PTSimStack::SetStdHepSave(), PTSimStack::SetStdHepSelectMask(), PTSimStack::SetStdHepThr(), TestParticleIsSelected(), and TestStackSaveSecondaryConfiguration(). Referenced by RunAllTests(). 00740 {
00741 // Test PTSimStack methods
00742
00743 bool pass = true;
00744 cout << "*** TestStack ***" << endl;
00745
00746 // Test stack methods to set secondary save configurations
00747 pass |= TestStackSaveSecondaryConfiguration();
00748 pass |= TestParticleIsSelected();
00749
00750 PTSimStack ptsimstack;
00751 Int_t snarl = 0;
00752 std::vector<Int_t> snarllist;
00753 snarllist.push_back(0);
00754 snarllist.push_back(999999);
00755 ptsimstack.SetStdHepSave(snarllist,true);
00756 ptsimstack.SetStdHepSelectMask(PTSim::kMomentum);
00757 ptsimstack.SetStdHepThr(0.15);
00758
00759 if ( fStdHepArray ) delete fStdHepArray;
00760 fStdHepArray = new TClonesArray("TParticle");
00761 if ( fHitArray ) delete fHitArray;
00762 fHitArray = new TClonesArray("DigiScintHit");
00763
00764 const Int_t nevent = 1000000;
00765 for ( int ievt = 0; ievt < nevent; ievt++ ) {
00766 // Create a set of particles and push to stack.
00767 // Do this nevent times, each time resetting stack, to look for
00768 // memory leaks and test performance.
00769
00770 TLorentzVector pmom(1.,2.,3.,4.);
00771 TLorentzVector pos(5.,6.,7.,8.);
00772 Double_t pol[3] = {1.,0.,0.};
00773 Double_t weight = 1.;
00774
00775 Int_t nprimary = 0;
00776 Int_t ntr = -1;
00777 const Int_t ntrack = 7;
00778 Int_t pdg[ntrack] = {0};
00779 Int_t parentId[ntrack] = {0};
00780
00781 // track 0, primary initial state, not to be done
00782 pdg[ntr+1] = 12; // nu_e
00783 Int_t toBeDone = 0;
00784 parentId[ntr+1] = -1;
00785 Int_t statuscode = UtilIstHEP::kNInitial;
00786 ptsimstack.PushTrack(toBeDone,parentId[ntr+1],pdg[ntr+1],
00787 pmom.Px(),pmom.Py(),pmom.Pz(),
00788 pmom.E(),pos.X(),pos.Y(),pos.Z(),pos.T(),
00789 pol[0],pol[1],pol[2],kPPrimary,
00790 ntr,weight,statuscode);
00791
00792 // track 1, primary final state, to be done
00793 pdg[ntr+1] = 2112; // neutron
00794 toBeDone = 1;
00795 parentId[ntr+1] = -1;
00796 nprimary++;
00797 statuscode = UtilIstHEP::kNFinal;
00798 ptsimstack.PushTrack(toBeDone,parentId[ntr+1],pdg[ntr+1],
00799 pmom.Px(),pmom.Py(),pmom.Pz(),
00800 pmom.E(),pos.X(),pos.Y(),pos.Z(),pos.T(),
00801 pol[0],pol[1],pol[2],kPPrimary,
00802 ntr,weight,statuscode);
00803
00804 // track 2, intermediate daughter state of track 0, not to be done
00805 pdg[ntr+1] = 14; // nu_mu
00806 toBeDone = 0;
00807 parentId[ntr+1] = 0;
00808 statuscode = UtilIstHEP::kNIntermediate;
00809 ptsimstack.PushTrack(toBeDone,parentId[ntr+1],pdg[ntr+1],
00810 pmom.Px(),pmom.Py(),pmom.Pz(),
00811 pmom.E(),pos.X(),pos.Y(),pos.Z(),pos.T(),
00812 pol[0],pol[1],pol[2],kPPrimary,
00813 ntr,weight,statuscode);
00814
00815 // track 3, final daughter state of track 2, to be done
00816 pdg[ntr+1] = 13; // muon
00817 toBeDone = 1;
00818 parentId[ntr+1] = 2;
00819 nprimary++;
00820 statuscode = UtilIstHEP::kNFinal;
00821 ptsimstack.PushTrack(toBeDone,parentId[ntr+1],pdg[ntr+1],
00822 pmom.Px(),pmom.Py(),pmom.Pz(),
00823 pmom.E(),pos.X(),pos.Y(),pos.Z(),pos.T(),
00824 pol[0],pol[1],pol[2],kPPrimary,
00825 ntr,weight,statuscode);
00826
00827 // track 4, rootino, not to be done
00828 pdg[ntr+1] = 0; // rootino
00829 toBeDone = 0;
00830 parentId[ntr+1] = 0;
00831 statuscode = 999;
00832 ptsimstack.PushTrack(toBeDone,parentId[ntr+1],pdg[ntr+1],
00833 pmom.Px(),pmom.Py(),pmom.Pz(),
00834 pmom.E(),pos.X(),pos.Y(),pos.Z(),pos.T(),
00835 pol[0],pol[1],pol[2],kPPrimary,
00836 ntr,weight,statuscode);
00837
00838 // track 5, secondary of track 3, to be done
00839 pdg[ntr+1] = 22; // gamma
00840 toBeDone = 1;
00841 parentId[ntr+1] = 3;
00842 statuscode = 0;
00843 ptsimstack.PushTrack(toBeDone,parentId[ntr+1],pdg[ntr+1],pmom.Px(),
00844 pmom.Py(),pmom.Pz(),
00845 pmom.E(),pos.X(),pos.Y(),pos.Z(),pos.T(),
00846 pol[0],pol[1],pol[2],kPBrem,
00847 ntr,weight,statuscode);
00848
00849 // track 6, secondary of track 1, to be done
00850 pdg[ntr+1] = 111; // pi0
00851 toBeDone = 1;
00852 parentId[ntr+1] = 1;
00853 statuscode = 0;
00854 ptsimstack.PushTrack(toBeDone,parentId[ntr+1],pdg[ntr+1],
00855 pmom.Px(),pmom.Py(),pmom.Pz(),
00856 pmom.E(),pos.X(),pos.Y(),pos.Z(),pos.T(),
00857 pol[0],pol[1],pol[2],kPHadronic,
00858 ntr,weight,statuscode);
00859
00860 if ( ievt < 2 ) ptsimstack.Print();
00861
00862 if ( ptsimstack.GetNtrack() != ntr+1 ) {
00863 cout << "ptsimstack.GetNtrack() " << ptsimstack.GetNtrack()
00864 << " != ntr+1 " << ntr+1 << endl;
00865 pass = false;
00866 }
00867
00868 if ( ptsimstack.GetNprimary() != nprimary ) {
00869 cout << "ptsimstack.GetNprimary() " << ptsimstack.GetNprimary()
00870 << " != nprimary " << nprimary << endl;
00871 pass = false;
00872 }
00873
00874 if ( ptsimstack.GetCurrentTrack() != 0 ) {
00875 cout << "ptsimstack.GetCurrentTrack() != 0 " << endl;
00876 pass = false;
00877 }
00878 Int_t track = -1;
00879 TParticle* particle = 0;
00880 const Int_t nstack = 4;
00881 Int_t stackorder[nstack] = {6,5,3,1};
00882 Int_t pdgorder[nstack] = {0};
00883 Int_t parentorder[nstack] = {0};
00884 for ( int ist = 0; ist < nstack; ist++ ) {
00885 pdgorder[ist] = pdg[stackorder[ist]];
00886 parentorder[ist] = parentId[stackorder[ist]];
00887 }
00888
00889
00890 Int_t istack = 0;
00891 while ( (particle = ptsimstack.PopNextTrack(track)) ) {
00892 if ( istack < nstack ) {
00893 if ( track != stackorder[istack] ) {
00894 cout << "ptsimstack.PopNextTrack popped " << istack << "th track "
00895 << "with id " << track
00896 << " expected id " << stackorder[istack] << endl;
00897 pass = false;
00898 }
00899 if ( ptsimstack.GetCurrentTrackNumber() != stackorder[istack] ) {
00900 cout << "ptsimstack.GetCurrentTrackNumber() "
00901 << ptsimstack.GetCurrentTrackNumber()
00902 << " not equal to " << stackorder[istack] << endl;
00903 pass = false;
00904 }
00905 if ( ptsimstack.GetCurrentParentTrackNumber() != parentorder[istack] ){
00906 cout << "ptsimstack.GetCurrentParentTrackNumber() "
00907 << ptsimstack.GetCurrentParentTrackNumber()
00908 << " not equal to " << parentorder[istack] << endl;
00909 pass = false;
00910 }
00911 if ((ptsimstack.GetCurrentTrack())->GetPdgCode() != pdgorder[istack]) {
00912 cout << "(ptsimstack.GetCurrentTrack())->GetPdgCode() "
00913 << (ptsimstack.GetCurrentTrack())->GetPdgCode()
00914 << " not equal to " << pdgorder[istack] << endl;
00915 pass = false;
00916 }
00917 }
00918 else {
00919 cout << "ptsimstack.PopNextTrack popped " << istack << "th track "
00920 << " expected only " << nstack << " tracks " << endl;
00921 pass = false;
00922 }
00923 istack++;
00924 }
00925
00926 const Int_t nprim = 2;
00927 Int_t primaryorder[nprim] = {1,3};
00928 Int_t primarypdgorder[nprim] = {0};
00929 Int_t primaryparentorder[nprim] = {0};
00930
00931 for ( Int_t iprim = 0; iprim < nprim; iprim++ ) {
00932 primarypdgorder[iprim] = pdg[primaryorder[iprim]];
00933 primaryparentorder[iprim] = parentId[primaryorder[iprim]];
00934 }
00935
00936 for ( Int_t iprim = 0; iprim < ptsimstack.GetNprimary(); iprim++ ) {
00937 TParticle* primary = ptsimstack.PopPrimaryForTracking(iprim);
00938 if ( primary->GetPdgCode() != primarypdgorder[iprim] ) {
00939 cout << "ptsimstack.PopPrimaryForTracking(iprim)->GetPdgCode() "
00940 << primary->GetPdgCode() << " not equal to "
00941 << primarypdgorder[iprim] << endl;
00942 pass = false;
00943 }
00944 if ( ptsimstack.GetCurrentTrackNumber() != primaryorder[iprim] ) {
00945 cout << "ptsimstack.GetCurrentTrackNumber() "
00946 << ptsimstack.GetCurrentTrackNumber()
00947 << " for primary " << iprim
00948 << " not equal to " << primaryorder[iprim] << endl;
00949 pass = false;
00950 }
00951 if ( ptsimstack.GetCurrentParentTrackNumber()
00952 != primaryparentorder[iprim] ) {
00953 cout << "ptsimstack.GetCurrentParentTrackNumber() "
00954 << ptsimstack.GetCurrentParentTrackNumber()
00955 << " for primary " << iprim
00956 << " not equal to " << primaryparentorder[iprim] << endl;
00957 pass = false;
00958 }
00959 if ( (ptsimstack.GetCurrentTrack())->GetPdgCode()
00960 != primarypdgorder[iprim] ) {
00961 cout << "(ptsimstack.GetCurrentTrack())->GetPdgCode() "
00962 << (ptsimstack.GetCurrentTrack())->GetPdgCode()
00963 << " for primary " << iprim
00964 << " not equal to " << primarypdgorder[iprim] << endl;
00965 pass = false;
00966 }
00967 }
00968
00969 ptsimstack.SetCurrentTrack(5);
00970 if ( ptsimstack.GetCurrentTrackNumber() != 5 ) {
00971 cout << "ptsimstack.GetCurrentTrackNumber() "
00972 << ptsimstack.GetCurrentTrackNumber()
00973 << " not equal to 5 after SetCurrentTrack " << endl;
00974 pass = false;
00975 }
00976
00977 const Int_t nparticle = 7;
00978 Int_t particleorder[nparticle] = {0,1,2,3,4,5,6};
00979
00980 for ( int ip = 0; ip < nparticle; ip++ ) {
00981 const PTSimParticle* particle = ptsimstack.GetParticle(ip);
00982 if ( particle->GetID() != particleorder[ip] ) {
00983 cout << "ptsimstack.GetParticle(ip)->GetID() with ip " << ip
00984 << " not equal to " << particleorder[ip] << endl;
00985 pass = false;
00986 }
00987 if ( ievt < 2 ) particle -> Print();
00988 }
00989
00990
00991 if ( ievt < 10 ) {
00992 ptsimstack.FillStdHepArray(fStdHepArray,snarl,
00993 fHitArray,0);
00994 }
00995
00996 ptsimstack.Reset();
00997
00998 }
00999
01000 fStdHepArray -> Print();
01001
01002 if ( pass ) cout << "*** All TestStack tests Passed ***" << endl;
01003 else cout << "*** At least one TestStack test FAILED ***" << endl;
01004
01005 return pass;
01006
01007 }
|
|
|
Definition at line 423 of file PTSimValidate.cxx. References PTSimStack::GetStdHepHitThr(), PTSimStack::GetStdHepSaveByRange(), PTSimStack::GetStdHepSaveSibling(), PTSimStack::GetStdHepSelectMask(), PTSimStack::GetStdHepThr(), PTSimStack::GetStdHepThrByType(), PTSimStack::SaveSecondariesForSnarl(), PTSimStack::SetStdHepHitThr(), PTSimStack::SetStdHepSave(), PTSimStack::SetStdHepSaveSibling(), PTSimStack::SetStdHepSelectMask(), PTSimStack::SetStdHepThr(), and PTSimStack::SetStdHepThrByType(). Referenced by TestStack(). 00423 {
00424 // Test PTSimStack methods to set secondary save configurations
00425
00426 bool pass = true;
00427 cout << " *** TestStackSaveSecondaryConfiguration ***" << endl;
00428
00429 PTSimStack ptsimstack;
00430
00431 // Check settings of snarls for which secondaries will be saved.
00432 if ( ptsimstack.GetStdHepSaveByRange() ) {
00433 cout << "ptsimstack.GetStdHepSaveByRange() true, expect false" << endl;
00434 pass = false;
00435 }
00436 std::vector<Int_t> snarllist;
00437 // Check by range
00438 snarllist.push_back(0);
00439 snarllist.push_back(999999);
00440 ptsimstack.SetStdHepSave(snarllist,true);
00441 if ( !ptsimstack.GetStdHepSaveByRange() ) {
00442 cout << "ptsimstack.GetStdHepSaveByRange() false, expect true" << endl;
00443 pass = false;
00444 }
00445 if ( !ptsimstack.SaveSecondariesForSnarl(5) ) {
00446 cout << "ptsimstack.SaveSecondariesForSnarl(5) false, expect true"
00447 << endl;
00448 pass = false;
00449 }
00450 if ( !ptsimstack.SaveSecondariesForSnarl(0) ) {
00451 cout << "ptsimstack.SaveSecondariesForSnarl(0) false, expect true"
00452 << endl;
00453 pass = false;
00454 }
00455
00456 // Check by snarl list
00457 snarllist.clear();
00458 snarllist.push_back(0);
00459 snarllist.push_back(15);
00460 ptsimstack.SetStdHepSave(snarllist,false);
00461 if ( ptsimstack.GetStdHepSaveByRange() ) {
00462 cout << "ptsimstack.GetStdHepSaveByRange() true, expect false" << endl;
00463 pass = true;
00464 }
00465 if ( !ptsimstack.SaveSecondariesForSnarl(0) ) {
00466 cout << "ptsimstack.SaveSecondariesForSnarl(0) false, expect true"
00467 << endl;
00468 pass = false;
00469 }
00470 if ( ptsimstack.SaveSecondariesForSnarl(5) ) {
00471 cout << "ptsimstack.SaveSecondariesForSnarl(5) true, expect false"
00472 << endl;
00473 pass = false;
00474 }
00475 if ( !ptsimstack.SaveSecondariesForSnarl(15) ) {
00476 cout << "ptsimstack.SaveSecondariesForSnarl(15) false, expect true"
00477 << endl;
00478 pass = false;
00479 }
00480
00481
00482 // Save sibling
00483 if ( !ptsimstack.GetStdHepSaveSibling() ) {
00484 cout << "ptsimstack.GetStdHepSaveSibling() false, expect true"
00485 << endl;
00486 pass = false;
00487 }
00488 ptsimstack.SetStdHepSaveSibling(0);
00489 if ( ptsimstack.GetStdHepSaveSibling() ) {
00490 cout << "ptsimstack.GetStdHepSaveSibling() true, expect false"
00491 << endl;
00492 pass = false;
00493 }
00494
00495 // Selection mask
00496 if ( ptsimstack.GetStdHepSelectMask() != PTSim::kMomentum ) {
00497 cout << "ptsimstack.GetStdHepSelectMask() "
00498 << ptsimstack.GetStdHepSelectMask()
00499 << ", expect PTSim::kMomentum" << endl;
00500 pass = false;
00501 }
00502 Int_t mask = PTSim::kMomentum | PTSim::kHit;
00503 ptsimstack.SetStdHepSelectMask(mask);
00504 if ( ptsimstack.GetStdHepSelectMask() != mask ) {
00505 cout << "ptsimstack.GetStdHepSelectMask() "
00506 << ptsimstack.GetStdHepSelectMask()
00507 << ", expect " << mask << endl;
00508 pass = false;
00509 }
00510
00511 // Hit threshold
00512 if ( ptsimstack.GetStdHepHitThr() != 0.001 ) {
00513 cout << "ptsimstack.GetStdHepHitThr() " << ptsimstack.GetStdHepHitThr()
00514 << ", expect 0.001" << endl;
00515 pass = false;
00516 }
00517 ptsimstack.SetStdHepHitThr(0.0001);
00518 if ( ptsimstack.GetStdHepHitThr() != 0.0001 ) {
00519 cout << "ptsimstack.GetStdHepHitThr() " << ptsimstack.GetStdHepHitThr()
00520 << ", expect 0.0001" << endl;
00521 pass = false;
00522 }
00523
00524 // Momentum threshold
00525 if ( ptsimstack.GetStdHepThr() != 0.15 ) {
00526 cout << "ptsimstack.GetStdHepThr() " << ptsimstack.GetStdHepThr()
00527 << ", expect 0.15" << endl;
00528 pass = false;
00529 }
00530
00531 ptsimstack.SetStdHepThr(0.10);
00532 if ( ptsimstack.GetStdHepThr() != 0.10 ) {
00533 cout << "ptsimstack.GetStdHepThr() " << ptsimstack.GetStdHepThr()
00534 << ", expect 0.10" << endl;
00535 pass = false;
00536 }
00537
00538 // Momentum threshold by type
00539 Int_t pdgId = 11;
00540 TMCProcess process = kPPair;
00541 if ( ptsimstack.GetStdHepThrByType(process,pdgId) != -1 ) {
00542 cout << "ptsimstack.GetStdHepThrByType() for process,pdgId "
00543 << process << "," << pdgId << " is "
00544 << ptsimstack.GetStdHepThrByType(process,pdgId)
00545 << ", expect 0.10" << endl;
00546 pass = false;
00547 }
00548 ptsimstack.SetStdHepThrByType(0.001,process,pdgId);
00549 if ( ptsimstack.GetStdHepThrByType(process,pdgId) != 0.001 ) {
00550 cout << "ptsimstack.GetStdHepThrByType() for process,pdgId "
00551 << process << "," << pdgId << " is "
00552 << ptsimstack.GetStdHepThrByType(process,pdgId)
00553 << ", expect 0.001" << endl;
00554 pass = false;
00555 }
00556 TMCProcess process2 = kPBrem;
00557 if ( ptsimstack.GetStdHepThrByType(process2,pdgId) != -1 ) {
00558 cout << "ptsimstack.GetStdHepThrByType() for process2,pdgId "
00559 << process2 << "," << pdgId << " is "
00560 << ptsimstack.GetStdHepThrByType(process2,pdgId)
00561 << ", expect 0.10" << endl;
00562 pass = false;
00563 }
00564 ptsimstack.SetStdHepThrByType(0.002,process2,kRootino);
00565 if ( ptsimstack.GetStdHepThrByType(process2,pdgId) != 0.002 ) {
00566 cout << "ptsimstack.GetStdHepThrByType() for process2,pdgId "
00567 << process2 << "," << pdgId << " is "
00568 << ptsimstack.GetStdHepThrByType(process2,pdgId)
00569 << ", expect 0.002" << endl;
00570 pass = false;
00571 }
00572 ptsimstack.SetStdHepThrByType(0.0015,kPNoProcess,pdgId);
00573 if ( ptsimstack.GetStdHepThrByType(process2,pdgId) != 0.0015 ) {
00574 cout << "ptsimstack.GetStdHepThrByType() for process2,pdgId "
00575 << process2 << "," << pdgId << " is "
00576 << ptsimstack.GetStdHepThrByType(process2,pdgId)
00577 << ", expect 0.0015" << endl;
00578 pass = false;
00579 }
00580 ptsimstack.SetStdHepThrByType(0.003,kPNoProcess,pdgId);
00581 if ( ptsimstack.GetStdHepThrByType(process2,pdgId) != 0.002 ) {
00582 cout << "ptsimstack.GetStdHepThrByType() for process2,pdgId "
00583 << process2 << "," << pdgId << " is "
00584 << ptsimstack.GetStdHepThrByType(process2,pdgId)
00585 << ", expect 0.003" << endl;
00586 pass = false;
00587 }
00588
00589 if ( pass )
00590 cout << " *** All TestStackSaveSecondaryConfiguration tests Passed ***"
00591 << endl;
00592 else
00593 cout <<
00594 " *** At least one TestStackSaveSecondaryConfiguration test FAILED ***"
00595 << endl;
00596
00597 return pass;
00598
00599 }
|
|
|
Definition at line 44 of file PTSimValidate.h. Referenced by TestStack(). |
|
|
Definition at line 45 of file PTSimValidate.h. Referenced by TestInitSnarl(). |
|
|
Definition at line 43 of file PTSimValidate.h. Referenced by TestInitSnarl(), TestStack(), and ~PTSimValidate(). |
1.3.9.1