本文整理汇总了C++中TBranch::UpdateAddress方法的典型用法代码示例。如果您正苦于以下问题:C++ TBranch::UpdateAddress方法的具体用法?C++ TBranch::UpdateAddress怎么用?C++ TBranch::UpdateAddress使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TBranch
的用法示例。
在下文中一共展示了TBranch::UpdateAddress方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GrowJoinedPhotonTree
TTree* GrowJoinedPhotonTree( RAT::DSReader& theDS )
{
//Now we build the fundamental blocks of our operation. The TrackedOpticalPhoton is static to avoid
//building many copies of the object on the stack, which is unnecessary. We reset the photon at the
//end of each track for this reason.
RAT::DS::Root* theDSEvent = NULL;
RAT::DS::MC* theDSMC = NULL;
static TrackedOpticalPhoton thePhoton;
TTree* theResultingTree = new TTree("T",
"Data From Tracked Optical Photons");
//For ROOT compatibility. For versions 5.22 and up, it's legal to omit the
//name of the class in this call. Before then, we need to call it by name.
#ifdef __ROOTVERLT522
TBranch* theBranch = theResultingTree->Branch("TrackedOpticalPhotons",
"TrackedOpticalPhoton",&thePhoton);
#else
TBranch* theBranch = theResultingTree->Branch("TrackedOpticalPhotons",
&thePhoton);
#endif
//This is just to keep the compiler from complaining about the use of the
//TBranch.
theBranch->UpdateAddress();
//All we are going to do, for starters, is get the tracks, print out the
//steps, join the tracks, and print them out again. Easy stuff. This will
//also give an easy way to track where the code is going wrong (or right).
for ( int eventIndex = 0; eventIndex < theDS.GetTotal(); eventIndex++ )
{
//Move to the next event.
theDSEvent = theDS.GetEvent(eventIndex);
theDSMC = theDSEvent->GetMC();
#ifndef CLUSTER_RUN
//Spit out Event Info...
std::cout << std::endl << "Analyzing event " << eventIndex << std::endl;
#endif
//The container will be a map, where the key is the trackID and the
//value is the track itself. This structure is _very_ useful for
//track reconstruction, where you want to be able to get a track by
//referring to its id.
IDtoTrackMap tracks;
//We also want to have a container that can tell us if a given track
//caused a hit in the simulation. We use a vector<bool>, where the
//index is equal to the trackID.
std::vector<bool> hit_list( theDSMC->GetMCTrackCount(), false );
//Now fill the map with the tracks.
for ( int track = 0; track < theDSMC->GetMCTrackCount(); track++ )
{
//Check if the track is an optical photon.
if ( theDSMC->GetMCTrack(track)->GetParticleName() == "opticalphoton" )
{
//Grab the track out of the monte carlo and push it into the map
//with its ID.
RAT::DS::MCTrack newTrack = *theDSMC->GetMCTrack(track);
tracks.insert( IDwithTrack(newTrack.GetTrackID(), newTrack) );
}
}
//And now for every hit in the monte carlo, flip the appropriate bit.
for ( int mc_pmt_hit = 0; mc_pmt_hit < theDSMC->GetMCPMTCount(); mc_pmt_hit++ )
{
//Iterate through all MCPhotons, flipping the TrackID'th bit in the vector<bool>
//to indicate a hit.
for ( int mc_phot = 0; mc_phot < theDSMC->GetMCPMT(mc_pmt_hit)->GetMCPhotonCount(); mc_phot++ )
{
hit_list[ theDSMC->GetMCPMT(mc_pmt_hit)->GetMCPhoton(mc_phot)->GetTrackID() - 1 ].flip();
}
}
#ifndef CLUSTER_RUN
#ifdef PRINT_TRACK_DEBUG
//Now that our map is full of tracks, let's iterate over them and
//print out their information. This is, of course, pre-joining.
IDtoTrackMap::iterator track_it = tracks.begin();
while ( track_it != tracks.end() )
{
std::cout << "Track ID " << track_it->first << "->Child of track ID " << track_it->second.GetParentID() << "\n";
for ( std::size_t stepcount = 0; stepcount < track_it->second.GetMCTrackStepCount(); stepcount++ )
{
std::cout << "\t Step " << stepcount << "->" << track_it->second.GetMCTrackStep(stepcount)->GetProcess() << "\n"
<< "\t\t X:" << track_it->second.GetMCTrackStep(stepcount)->GetEndpoint().X() << "\n"
<< "\t\t Y:" << track_it->second.GetMCTrackStep(stepcount)->GetEndpoint().Y() << "\n"
<< "\t\t Z:" << track_it->second.GetMCTrackStep(stepcount)->GetEndpoint().Z() << "\n"
<< "\t\t T:" << track_it->second.GetMCTrackStep(stepcount)->GetGlobalTime() << "\n"
<< "\t\t KE:" << track_it->second.GetMCTrackStep(stepcount)->GetKE() << std::endl;
}
//Remember to increment the iterator!
track_it++;
}
#endif
#endif
//OK, now the hard work. We need to join these damn tracks. Use a
//reverse iterator to move back through the tracks and look for child-
//parent relationships. This will simplify the logic of removing tracks
//from the map that 'belong' to some parent.
IDtoTrackMap::reverse_iterator track_rit = tracks.rbegin();
while ( track_rit != tracks.rend() )
{
//Search for the ID of the parent track in the map. If it is found,
//.........这里部分代码省略.........