Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

ANtpEventManipulator.cxx

Go to the documentation of this file.
00001 
00002 //$Id: ANtpEventManipulator.cxx,v 1.6 2007/03/21 21:50:15 brebel Exp $
00003 //
00004 //ANtpEventManipulator.cxx
00005 //
00006 //B. Rebel 10/2004
00008 
00009 #include "AnalysisNtuples/Module/ANtpEventManipulator.h"
00010 #include "MessageService/MsgService.h"
00011 
00012 #include <cassert>
00013 #include <algorithm>
00014 
00015 ClassImp(ANtpEventManipulator)
00016 
00017 CVSID("$Id: ANtpEventManipulator.cxx,v 1.6 2007/03/21 21:50:15 brebel Exp $");
00018 
00019 //-------------------------------------------------------------------
00020 ANtpEventManipulator::ANtpEventManipulator() :
00021   fNtpSREvent(0),
00022   fEventArray(0),
00023   fTrackArray(0),
00024   fShowerArray(0),
00025   fStripArray(0),
00026   fUseLengthTrack(0),
00027   fUsePHShower(0),
00028   fUseNPlanesShower(0),
00029   fUsePHTrack(0),
00030   fUseNPlanesTrack(0)
00031 {
00032     
00033   MSG("ANtpEventManipulator", Msg::kDebug) << "ANtpEventManipulator::Constructor" << endl;
00034   
00035 }
00036 
00037 //-------------------------------------------------------------------
00038 void ANtpEventManipulator::Initialize(TClonesArray  *eventArray, TClonesArray *trackArray, 
00039                                       TClonesArray *showerArray, TClonesArray *stripArray)
00040 {
00041   fNtpSREvent = 0;
00042   fEventArray = eventArray;
00043   fTrackArray = trackArray;
00044   fShowerArray = showerArray;
00045   fStripArray =stripArray;
00046   MSG("ANtpEventManipulator", Msg::kDebug) << "ANtpEventManipulator::Constructor" << endl;    
00047 }
00048 
00049 
00050 //----------------------------------------------------------------------
00051 ANtpEventManipulator::~ANtpEventManipulator()
00052 { 
00053   MSG("ANtpEventManipulator", Msg::kDebug) << "ANtpEventManipulator::Destructor" << endl; 
00054 }
00055 
00056 //------------------------------------------------------------------------
00057 NtpSREvent *ANtpEventManipulator::GetEvent()
00058 {
00059   return fNtpSREvent;
00060 }
00061 
00062 //------------------------------------------------------------------------
00063 //get the track corresponding to entry index in the NtpSREvent trk array
00064 NtpSRTrack *ANtpEventManipulator::GetTrack(Int_t index) 
00065 {
00066   NtpSRTrack *ntpTrack = 0;
00067   
00068   if(!fNtpSREvent){
00069     MSG("ANtpEventManipulator", Msg::kWarning) << "No NtpSREvent to get a NtpSRTrack from"
00070                                                << " - returning empty pointer" << endl;
00071     return ntpTrack;
00072   } 
00073     
00074   if(index < fNtpSREvent->ntrack)
00075     ntpTrack = dynamic_cast<NtpSRTrack *>(fTrackArray->At(fNtpSREvent->trk[index]));
00076   
00077   return ntpTrack;
00078 }
00079 
00080 //------------------------------------------------------------------------
00081 //get the shower corresponding to entry index in the NtpSREvent shw array
00082 NtpSRShower *ANtpEventManipulator::GetShower(Int_t index) 
00083 {
00084   NtpSRShower *ntpShower = 0;
00085 
00086   if(!fNtpSREvent){
00087     MSG("ANtpEventManipulator", Msg::kWarning) << "No NtpSREvent to get a NtpSRShower from"
00088                                                << " - returning empty pointer" << endl;
00089     return ntpShower;
00090   }
00091   
00092   if(index < fNtpSREvent->nshower)
00093     ntpShower = dynamic_cast<NtpSRShower *>(fShowerArray->At(fNtpSREvent->shw[index]));
00094   
00095   return ntpShower;
00096 }
00097 
00098 //-------------------------------------------------------------------------
00099 NtpSRTrack *ANtpEventManipulator::GetPrimaryTrack() 
00100 {
00101   NtpSRTrack *primaryTrack = 0;
00102   NtpSRTrack *ntpTrack = 0;
00103 
00104   Int_t index = 0;
00105   
00106   if(!fNtpSREvent){
00107     MSG("ANtpEventManipulator", Msg::kWarning) << "No NtpSREvent to get a NtpSRTrack from"
00108                                                << " - returning empty pointer" << endl;
00109     return primaryTrack;
00110   } 
00111   
00112   for(Int_t i = 0; i < fNtpSREvent->ntrack; ++i){
00113     
00114     MSG("ANtpEventManipulator", Msg::kDebug) << "current track = " << i 
00115                                              << "/" << fNtpSREvent->ntrack << endl;
00116     
00117     index = fNtpSREvent->trk[i];
00118     
00119     MSG("ANtpEventManipulator", Msg::kDebug) << "current track index = " << index 
00120                                              << "/" << fNtpSREvent->ntrack << endl;
00121     
00122     ntpTrack = dynamic_cast<NtpSRTrack *>(fTrackArray->At(index));
00123     
00124     //if you dont already have a candidate, make this track it
00125     if(!primaryTrack) primaryTrack = ntpTrack;
00126     
00127     //check to see if this track is better than the best so far.  the fUseXXX
00128     //variables are set to 1. or 0. depending on if they should be used to 
00129     //determine which is the primary track
00130     if(ntpTrack->ds > primaryTrack->ds*fUseLengthTrack
00131        && ntpTrack->plane.n > primaryTrack->plane.n*fUseNPlanesTrack
00132        && ntpTrack->ph.sigmap > primaryTrack->ph.sigmap*fUsePHTrack)
00133       primaryTrack = ntpTrack;
00134     
00135   }//end loop over tracks in the event
00136   
00137   return primaryTrack;
00138   
00139 }
00140 
00141 //------------------------------------------------------------------------------------------------------
00142 
00143 NtpSRTrack *ANtpEventManipulator::GetPrimaryTrackNS() 
00144 {
00145   NtpSRTrack *primaryTrack = 0;
00146   NtpSRTrack *ntpTrack = 0;
00147 
00148   Int_t    index  = 0;
00149   Double_t lenmax =-999;
00150   
00151   if(!fNtpSREvent){
00152     MSG("ANtpEventManipulator", Msg::kWarning) << "No NtpSREvent to get a NtpSRTrack from"
00153                                                << " - returning empty pointer" << endl;
00154     return primaryTrack;
00155   } 
00156   
00157   for(Int_t i = 0; i < fNtpSREvent->ntrack; ++i){
00158     
00159 //     MSG("ANtpEventManipulator", Msg::kInfo) << "current track = " << i 
00160 //                                           << "/" << fNtpSREvent->ntrack << endl;
00161     
00162     index = fNtpSREvent->trk[i];
00163     
00164 //     MSG("ANtpEventManipulator", Msg::kInfo) << "current track index = " << index 
00165 //                                           << "/" << fNtpSREvent->ntrack << endl;
00166     
00167     ntpTrack = dynamic_cast<NtpSRTrack *>(fTrackArray->At(index));
00168     Double_t len = ntpTrack->plane.end-ntpTrack->plane.beg+1;
00169         
00170     if(len>=lenmax) {
00171      lenmax=len;
00172      primaryTrack = ntpTrack;
00173     }
00174        
00175   }//end loop over tracks in the event
00176   
00177   return primaryTrack;
00178   
00179 }
00180 
00181 //--------------------------------------------------------------------------------------------------------
00182 NtpSRShower *ANtpEventManipulator::GetPrimaryShower() 
00183 {
00184   
00185   NtpSRShower *ntpShower = 0;
00186   NtpSRShower *primaryShower = 0;
00187   
00188   if(!fNtpSREvent){
00189     MSG("ANtpEventManipulator", Msg::kWarning) << "No NtpSREvent to get a NtpSRShower from"
00190                                                << " - returning empty pointer" << endl;
00191     return ntpShower;
00192   } 
00193   
00194   for(Int_t i = 0; i < fNtpSREvent->nshower; ++i){
00195     
00196     ntpShower = dynamic_cast<NtpSRShower *>(fShowerArray->At(fNtpSREvent->shw[i]));
00197     
00198     //if you dont already have a candidate, make this Shower it
00199     if(!primaryShower) primaryShower = ntpShower;
00200     
00201     //check to see if this Shower is better than the best so far.  the fUseXXX
00202     //variables are set to 1. or 0. depending on if they should be used to 
00203     //determine which is the primary Shower
00204 //     if(ntpShower->plane.n > primaryShower->plane.n*fUseNPlanesShower
00205 //        && ntpShower->ph.sigmap > primaryShower->ph.sigmap*fUsePHShower)
00206 //       primaryShower = ntpShower;
00207     
00208   }//end loop over Showers in the event
00209   
00210   return primaryShower;
00211   
00212 }
00213 
00214 //------------------------------------------------------------------------
00215 //get the strip corresponding to entry index in the NtpSREvent stp array
00216 NtpSRStrip *ANtpEventManipulator::GetStrip(Int_t index) 
00217 {
00218   NtpSRStrip *ntpStrip = 0;
00219 
00220   if(!fNtpSREvent){
00221     MSG("ANtpEventManipulator", Msg::kWarning) << "No NtpSREvent to get a NtpSRStrip from"
00222                                                << " - returning empty pointer" << endl;
00223     return ntpStrip;
00224   }
00225   
00226   if(index < fNtpSREvent->nstrip)
00227     ntpStrip = dynamic_cast<NtpSRStrip *>(fStripArray->At(fNtpSREvent->stp[index]));
00228   
00229   return ntpStrip;
00230 }
00231 
00232 //--------------------------------------------------------------------------
00233 
00234 
00235 
00236 
00237 void ANtpEventManipulator::SetPrimaryTrackCriteria(Int_t useNPlanes, Int_t useLength,
00238                                                    Int_t usePH)
00239 {
00240   fUseLengthTrack = useLength;
00241   fUseNPlanesTrack = useNPlanes;
00242   fUsePHTrack = usePH;
00243   
00244   return;
00245 }
00246 
00247 //--------------------------------------------------------------------------
00248 void ANtpEventManipulator::SetPrimaryShowerCriteria(Int_t useNPlanes, Int_t usePH)
00249 {
00250   fUseNPlanesShower = useNPlanes;
00251   fUsePHShower = usePH;
00252   
00253   return;
00254 }
00255 
00256 //--------------------------------------------------------------------------
00257 void ANtpEventManipulator::SetEventInSnarl(Int_t eventIndex)
00258 {
00259   //check that such an event exists
00260   if(eventIndex < fEventArray->GetLast()+1) 
00261     fNtpSREvent = dynamic_cast<NtpSREvent *>(fEventArray->At(eventIndex));
00262   else{
00263     MSG("ANtpEventManipulator", Msg::kWarning) << "invalid event index, "
00264                                                << eventIndex << "/" 
00265                                                << fEventArray->GetLast()+1 
00266                                                << " set to first event in array" 
00267                                                << endl;
00268     fNtpSREvent = dynamic_cast<NtpSREvent *>(fEventArray->At(0));
00269   }
00270 
00271   return;
00272 }

Generated on Mon Feb 15 11:06:22 2010 for loon by  doxygen 1.3.9.1