|
// $Id: BrSelectGeantTracks.cxx,v 1.1.1.1 2001/06/21 14:55:07 hagel Exp $ // // $Log: BrSelectGeantTracks.cxx,v $ // Revision 1.1.1.1 2001/06/21 14:55:07 hagel // Initial revision of brat2 // // Revision 1.1 1998/09/27 17:28:52 alv // *** empty log message *** // // /////////////////////////////////////////////////////////////////////// // // // BrSelectGeantTracks // // // // BRAHMS Geant track selection class // // Selects the set of tracks that have hits in one of the // // specified sets of detector volumes. // // // /////////////////////////////////////////////////////////////////////// #include <string.h> #include <iostream.h> #include <iomanip.h> #include "BrSelectGeantTracks.h" #include "BrDataTable.h" #include "BrGeantInput.h" #include "BrGeantTrack.h" #include "BrEventNode.h" ClassImp(BrSelectGeantTracks) //______________________________________________________________________________ Bool_t BrSelectGeantTracks::AddConfig(const Text_t *config) { // Add a track configuration (bit mask) corresponding to the detectors // in the comma separated list of detector names in config if (!fModule) { Error("AddConfig", "No GEANT input module specified"); return kFALSE; } UInt_t bits = 0; char *list = new char [strlen(config)+1]; strcpy(list, config); for (const char *s = strtok(list,","); s; s = strtok(NULL,",")) bits |= fModule->GetDetectorBit(s); delete [] list; if (!bits) return kFALSE; if (fNumMasks >= kMAXMASKS) { Error("AddConfig", "Too many configurations specified."); return kFALSE; } fMask[fNumMasks++] = bits; return kTRUE; } //______________________________________________________________________________ void BrSelectGeantTracks::ListConfigs() { // List bit masks and detector names for the configurations cout << GetName() << " configuration bit masks:n"; for (Int_t i = 0; i < fNumMasks; i++) { cout << setw(3) << i << ": " << setw(8) << hex << fMask[i] << dec << " "; fModule->ListDetectors(fMask[i]); cout << endl; } } //______________________________________________________________________________ void BrSelectGeantTracks::Event(BrEventNode *inev, BrEventNode *outev) { // Search the GEANT tracks in the table "GeantTracks" for tracks that // have hits in one of the configurations specified and // copy those tracks to the table "GeantTracks" in the output event node BrDataTable* intracks = inev->GetDataTable("GeantTracks"); if(!intracks) return; BrDataTable* outtracks = outev->GetDataTable("GeantTracks"); if (!outtracks) outev->AddObject(outtracks = new BrDataTable("GeantTracks")); Int_t NumTracks = intracks->GetEntries(); for (Int_t itrack = 0; itrack < NumTracks; itrack++) { BrGeantTrack *track = (BrGeantTrack*)intracks->At(itrack); if (DebugLevel()>2) { if (itrack == 0) cout << GetName() << "::Event" << endl; cout << " track " << itrack << " hitbits " << hex << track->GetHitBits() << dec << endl; track->ListHits(); } for (Int_t i = 0; i < fNumMasks; i++) { if (DebugLevel()>2) cout << " mask " << i << " hitbits " << hex << fMask[i] << dec << endl; if (track->HasHitsIn(fMask[i])) { outtracks->Add(new BrGeantTrack(track)); break; } } } if (DebugLevel()) { Int_t NumSelectedTracks = outtracks->GetEntries(); cout << GetName() << "::Event selected " << NumSelectedTracks << " out of " << NumTracks << " tracksn"; if (DebugLevel()>1) for (Int_t itrack = 0; itrack < NumSelectedTracks; itrack++) { BrGeantTrack *track = (BrGeantTrack*)outtracks->At(itrack); cout << " Track " << itrack << ", ID " << track->Pid() << ", p (" << track->Px() << "," << track->Py() << "," << track->Pz() << "), HitBits " << hex << track->GetHitBits() << dec << endl; } } } |
||||||
This page automatically generated by script docBrat by Christian Holm |
Copyright ; 2002 BRAHMS Collaboration
<brahmlib@rcf.rhic.bnl.gov>
|