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

AlgAtNuRecoMCTruth Class Reference

#include <AlgAtNuRecoMCTruth.h>

Inheritance diagram for AlgAtNuRecoMCTruth:

AlgBase List of all members.

Public Member Functions

 AlgAtNuRecoMCTruth ()
 ~AlgAtNuRecoMCTruth ()
void RunAlg (AlgConfig &ac, CandHandle &ch, CandContext &cx)
void Trace (const char *c) const

Private Attributes

TObjArray hitplnbnk [500]
TObjArray hitbnk
TObjArray trkbnk [2]
TObjArray shwbnk [2]
TObjArray trkcxt
TObjArray shwcxt

Constructor & Destructor Documentation

AlgAtNuRecoMCTruth::AlgAtNuRecoMCTruth  ) 
 

Definition at line 58 of file AlgAtNuRecoMCTruth.cxx.

00059 {
00060 
00061 }

AlgAtNuRecoMCTruth::~AlgAtNuRecoMCTruth  ) 
 

Definition at line 63 of file AlgAtNuRecoMCTruth.cxx.

00064 {
00065 
00066 }


Member Function Documentation

void AlgAtNuRecoMCTruth::RunAlg AlgConfig ac,
CandHandle ch,
CandContext cx
[virtual]
 

Implements AlgBase.

Definition at line 68 of file AlgAtNuRecoMCTruth.cxx.

References CandHandle::AddDaughterLink(), ShowerAtNu::AddHit(), TrackAtNu::AddHit(), CandAtNuRecoHandle::AddShower(), CandAtNuRecoHandle::AddTrack(), AlgFactory::GetAlgHandle(), CandContext::GetCandRecord(), HitAtNu::GetCharge(), Registry::GetCharString(), CandContext::GetDataIn(), CandHandle::GetDaughterIterator(), VldContext::GetDetector(), RerootExodus::GetFLSHitList(), AlgFactory::GetInstance(), CandContext::GetMom(), CandHandle::GetName(), RerootExodus::GetNeuKinList(), HitAtNu::GetPlane(), HitAtNu::GetPlaneView(), UgliPlnHandle::GetPlaneView(), UgliGeomHandle::GetScintPlnHandle(), HitAtNu::GetStrip(), RecMinos::GetVldContext(), hitbnk, hitplnbnk, REROOT_NeuKin::INu(), REROOT_FLSHit::IPackedPEC(), REROOT_FLSHit::IPDG(), CandShowerAtNuList::MakeCandidate(), CandTrackAtNuList::MakeCandidate(), MSG, CandRecord::SecureCandHandle(), CandShowerAtNuListHandle::SetCPUTime(), CandTrackAtNuListHandle::SetCPUTime(), CandHandle::SetName(), ObjShowerAtNu::SetPartner(), ObjTrackAtNu::SetPartner(), HitAtNu::SetShwFlag(), CandHandle::SetTitle(), HitAtNu::SetTrkFlag(), shwbnk, shwcxt, trkbnk, and trkcxt.

00069 {
00070 
00071   MSG("AlgAtNuRecoMCTruth", Msg::kDebug) << "AlgAtNuRecoMCTruth::RunAlg(...)" << endl;
00072 
00073   // Get CandAtNuRecoHandle
00074   CandAtNuRecoHandle& atnu_handle = dynamic_cast<CandAtNuRecoHandle&>(ch);
00075 
00076   // Unpack AlgConfig
00077   TString fListOutTrk,fListOutShw;
00078   fListOutTrk = ac.GetCharString("ListOutTrk");
00079   fListOutShw = ac.GetCharString("ListOutShw");
00080  
00081   // Unpack CandContext
00082   CandSliceListHandle* slice_list = (CandSliceListHandle*)(cx.GetDataIn()); 
00083 
00084   // clear timebanks
00085   Double_t dtime;
00086   Double_t fTime_TrackAtNu,fTime_ShowerAtNu;
00087 
00088   struct timeval tpbefore;
00089   gettimeofday(&tpbefore,0);
00090 
00091   Int_t i,j,k;
00092   Int_t pln,bpln,epln;
00093   Int_t trkplns,shwplns;
00094   TObjArray tmptrk,tmpshw,tmpmu;
00095   Int_t itr,idnu,ipdg,muflag,trkflag,shwflag;
00096   Int_t trueview,packedPEC,trueplane,truecell,trueext,truestrip;
00097 
00098   // Get Geometry
00099   CandRecord* candrectmp = (CandRecord*)(cx.GetCandRecord()); 
00100   VldContext *vldc = (VldContext*)(candrectmp->GetVldContext());
00101   UgliGeomHandle ugh(*vldc);
00102 
00103   Int_t StrpExtr[8]={ 0, 28, 56, 76, 96, 116, 136, 164 };
00104   Int_t StrpCell[28]={ 0, 1, 2, 3, 4, 5, 6, 
00105                        7, 8, 9, 10, 11, 12, 13, 
00106                        14, 15, 16, 17, 18, 19, 20, 
00107                        21, 22, 23, 24, 25, 26, 27 };
00108 
00109   // Get FLSHits
00110   const TClonesArray* FLShits = (TClonesArray*)(RerootExodus::GetFLSHitList());
00111   const TClonesArray* NeuKins = (TClonesArray*)(RerootExodus::GetNeuKinList());
00112   REROOT_NeuKin* neukin = (REROOT_NeuKin*)(NeuKins->At(0));
00113   idnu = neukin->INu();
00114   for(i=0;i<1+FLShits->GetLast();i++){
00115     REROOT_FLSHit* FLS_hit = (REROOT_FLSHit*)FLShits->At(i);
00116     ipdg = FLS_hit->IPDG();                   
00117     if( (idnu==0&&(ipdg==13||ipdg==-13))
00118       ||(idnu==14&&ipdg==13)||(idnu==-14&&ipdg==-13) ){
00119       tmpmu.Add(FLS_hit);
00120     }
00121   }
00122 
00123   // Iterate over slices
00124   TIter sliceitr(slice_list->GetDaughterIterator());
00125   while(CandSliceHandle* slice = dynamic_cast<CandSliceHandle*>(sliceitr())){
00126     atnu_handle.AddDaughterLink(*slice);
00127 
00128     TIter stripitr(slice->GetDaughterIterator());
00129     while(CandStripHandle* strip = (CandStripHandle*)(stripitr())){
00130       HitAtNu* hit = new HitAtNu(strip); pln=hit->GetPlane(); 
00131       hitplnbnk[pln].Add(hit); hitbnk.Add(hit);
00132     }
00133 
00134     trkplns=0; shwplns=0;
00135     for(i=0;i<500;i++){
00136       trkflag=0; shwflag=0;
00137       for(j=0;j<1+hitplnbnk[i].GetLast();j++){
00138         HitAtNu* hit = (HitAtNu*)(hitplnbnk[i].At(j));
00139         if(hit->GetCharge()>1.0){
00140           muflag=0;
00141           for(k=0;k<1+tmpmu.GetLast();k++){
00142             if(!muflag){
00143               REROOT_FLSHit* FLS_hit = (REROOT_FLSHit*)(tmpmu.At(k));
00144               packedPEC=FLS_hit->IPackedPEC();
00145               trueplane=(Int_t)(packedPEC/65536.0);
00146               if(trueplane==hit->GetPlane()){
00147                 trueext=(Int_t)((packedPEC-trueplane*65536)/256.0);
00148                 truecell=packedPEC-trueplane*65536-trueext*256;
00149                 truestrip=StrpExtr[trueext-1]+StrpCell[truecell-1];
00150                 PlexPlaneId trueplnid(vldc->GetDetector(),trueplane,0);
00151                 UgliScintPlnHandle trueplnhandle = ugh.GetScintPlnHandle(trueplnid);
00152                 if(trueplnhandle.GetPlaneView()==PlaneView::kU) trueview = 0;
00153                 if(trueplnhandle.GetPlaneView()==PlaneView::kV) trueview = 1;   
00154                 if(truestrip==hit->GetStrip()) muflag=1;
00155               }
00156             }
00157           }
00158           if(muflag){
00159             trkflag=1; tmptrk.Add(hit); hit->SetTrkFlag(2);
00160           }
00161           else{
00162             shwflag=1; tmpshw.Add(hit); hit->SetShwFlag(2);
00163           }
00164         }
00165       }
00166       if(trkflag) trkplns++; if(shwflag) shwplns++;
00167     }
00168 
00169 
00170     if(1+tmptrk.GetLast()>0){
00171       bpln=-1; epln=-1;
00172       for(j=0;j<1+tmptrk.GetLast();j++){
00173         HitAtNu* hit = (HitAtNu*)(tmptrk.At(j));
00174         if(bpln<0||hit->GetPlane()<bpln) bpln=hit->GetPlane();
00175         if(epln<0||hit->GetPlane()>epln) epln=hit->GetPlane();
00176       }
00177 
00178       if(trkplns>5 && 1+epln-bpln>5){
00179         TrackAtNu* trku = new TrackAtNu(slice);
00180         TrackAtNu* trkv = new TrackAtNu(slice);
00181         trkbnk[0].Add(trku); trkbnk[1].Add(trkv);
00182 
00183         for(j=0;j<1+tmptrk.GetLast();j++){
00184           HitAtNu* hit = (HitAtNu*)(tmptrk.At(j));
00185           if(hit->GetPlaneView()==0) trku->AddHit(hit);
00186           if(hit->GetPlaneView()==1) trkv->AddHit(hit);
00187         }
00188         
00189         trku->SetPartner(trkv); trkv->SetPartner(trku);
00190       }
00191 
00192     }
00193     
00194 
00195     if(1+tmpshw.GetLast()>0){
00196       bpln=-1; epln=-1;
00197       for(j=0;j<1+tmpshw.GetLast();j++){
00198         HitAtNu* hit = (HitAtNu*)(tmpshw.At(j));
00199         if(bpln<0||hit->GetPlane()<bpln) bpln=hit->GetPlane();
00200         if(epln<0||hit->GetPlane()>epln) epln=hit->GetPlane();
00201       }
00202 
00203       if(shwplns>1 && 1+epln-bpln>1){
00204         ShowerAtNu* shwu = new ShowerAtNu(slice);
00205         ShowerAtNu* shwv = new ShowerAtNu(slice);
00206         shwbnk[0].Add(shwu); shwbnk[1].Add(shwv);
00207 
00208         for(j=0;j<1+tmpshw.GetLast();j++){
00209           HitAtNu* hit = (HitAtNu*)(tmpshw.At(j));
00210           if(hit->GetPlaneView()==0) shwu->AddHit(hit);
00211           if(hit->GetPlaneView()==1) shwv->AddHit(hit);
00212         }
00213         
00214         shwu->SetPartner(shwv); shwv->SetPartner(shwu);
00215       }
00216 
00217     }
00218 
00219 
00220     for(i=0;i<500;i++){
00221       hitplnbnk[i].Clear();
00222     }
00223 
00224   }
00225 
00226   
00227   
00228   // *********************************************************
00229   // * F O R M A T I O N   O F   C A N D X X X H A N D L E S *
00230   // *********************************************************
00231   MSG("AlgAtNuRecoMCTruth", Msg::kDebug) << " Formation of CandXXXHandles " << endl;
00232 
00233   // create Singleton Instance of AlgFactory
00234   AlgFactory &af = AlgFactory::GetInstance();
00235 
00236   // create CandTrackAtNuListHandle
00237   TObjArray* objtrk = 0;
00238   for(itr=0;itr<1+trkbnk[0].GetLast();itr++){
00239     TrackAtNu* trku = (TrackAtNu*)(trkbnk[0].At(itr)); 
00240     TrackAtNu* trkv = (TrackAtNu*)(trkbnk[1].At(itr));
00241     objtrk = new TObjArray(); 
00242     objtrk->Add(trku);
00243     objtrk->Add(trkv); 
00244     trkcxt.Add(objtrk);
00245   }
00246 
00247   MSG("AlgAtNuRecoMCTruth", Msg::kDebug) << "*** CREATE CandTrackAtNuListHandle *** " << endl;
00248   AlgHandle ah_trk = af.GetAlgHandle("AlgTrackAtNuList", "default");
00249   CandContext cx_trk(this, cx.GetMom());
00250   cx_trk.SetCandRecord(cx.GetCandRecord());
00251   cx_trk.SetDataIn(&trkcxt);
00252   CandTrackAtNuListHandle trk_list = CandTrackAtNuList::MakeCandidate(ah_trk, cx_trk);
00253   trk_list.SetName(fListOutTrk.Data());
00254   trk_list.SetTitle(TString("Created by AtNuFindModule from ").Append(slice_list->GetName()));
00255   
00256   TIter trkitr(trk_list.GetDaughterIterator());
00257   while(CandTrackAtNuHandle* trk = dynamic_cast<CandTrackAtNuHandle*>(trkitr())){
00258     atnu_handle.AddTrack(trk);
00259   }
00260 
00261   //  create CandShowerAtNuListHandle
00262   TObjArray* objshw = 0;
00263   for(itr=0;itr<1+shwbnk[0].GetLast();itr++){
00264     ShowerAtNu* shwu = (ShowerAtNu*)(shwbnk[0].At(itr));
00265     ShowerAtNu* shwv = (ShowerAtNu*)(shwbnk[1].At(itr));
00266     objshw = new TObjArray();
00267     objshw->Add(shwu);
00268     objshw->Add(shwv);
00269     shwcxt.Add(objshw);
00270   }
00271 
00272   MSG("AlgAtNuRecoMCTruth", Msg::kDebug) << "*** CREATE CandShowerAtNuListHandle *** " << endl;
00273   AlgHandle ah_shw = af.GetAlgHandle("AlgShowerAtNuList", "default");
00274   CandContext cx_shw(this, cx.GetMom());
00275   cx_shw.SetCandRecord(cx.GetCandRecord());
00276   cx_shw.SetDataIn(&shwcxt);
00277   CandShowerAtNuListHandle shw_list = CandShowerAtNuList::MakeCandidate(ah_shw, cx_shw);
00278   shw_list.SetName(fListOutShw.Data());
00279   shw_list.SetTitle(TString("Created by AtNuFindModule from ").Append(slice_list->GetName())); 
00280   
00281   TIter shwitr(shw_list.GetDaughterIterator());
00282   while(CandShowerAtNuHandle* shw = dynamic_cast<CandShowerAtNuHandle*>(shwitr())){
00283     atnu_handle.AddShower(shw);
00284   }
00285 
00286 
00287   // ***************************************************
00288   // * D E L E T E   R E M A I N I N G   O B J E C T S *
00289   // ***************************************************
00290 
00291   hitbnk.Delete(); // hit bank
00292 
00293   for(itr=0;itr<2;itr++){ 
00294     trkbnk[itr].Delete(); // track bank
00295   }
00296   trkcxt.Delete();      // candcontext for tracks
00297 
00298   for(itr=0;itr<2;itr++){ 
00299     shwbnk[itr].Delete(); // shower bank
00300   }
00301   shwcxt.Delete();      // candcontext for showers
00302 
00303   // *********************************
00304   // * C A L C U L A T E   T I M E S *
00305   // *********************************
00306 
00307   struct timeval tpafter;
00308   gettimeofday(&tpafter,0);
00309   dtime=1000.0*(tpafter.tv_sec-tpbefore.tv_sec)+0.001*(tpafter.tv_usec-tpbefore.tv_usec);
00310   fTime_TrackAtNu=0.5*dtime; fTime_ShowerAtNu=0.5*dtime; 
00311 
00312   trk_list.SetCPUTime(fTime_TrackAtNu);
00313   MSG("AlgAtNuRecoMCTruth", Msg::kDebug) << " *** TRACK RECO TIME = " << fTime_TrackAtNu << endl; 
00314 
00315   shw_list.SetCPUTime(fTime_ShowerAtNu);
00316   MSG("AlgAtNuRecoMCTruth", Msg::kDebug) << " *** SHOWER RECO TIME = " << fTime_ShowerAtNu << endl;
00317 
00318   // ***************************************************************
00319   // * G I V E   C A N D H A N D L E S   T O   C A N D R E C O R D *
00320   // ***************************************************************
00321 
00322   CandRecord* candrec = (CandRecord*)(cx.GetCandRecord());
00323   candrec->SecureCandHandle(trk_list);
00324   candrec->SecureCandHandle(shw_list);
00325 
00326   return;
00327 
00328 }

void AlgAtNuRecoMCTruth::Trace const char *  c  )  const [virtual]
 

Reimplemented from AlgBase.

Definition at line 330 of file AlgAtNuRecoMCTruth.cxx.

00331 {
00332 
00333 }


Member Data Documentation

TObjArray AlgAtNuRecoMCTruth::hitbnk [private]
 

Definition at line 21 of file AlgAtNuRecoMCTruth.h.

Referenced by RunAlg().

TObjArray AlgAtNuRecoMCTruth::hitplnbnk[500] [private]
 

Definition at line 19 of file AlgAtNuRecoMCTruth.h.

Referenced by RunAlg().

TObjArray AlgAtNuRecoMCTruth::shwbnk[2] [private]
 

Definition at line 23 of file AlgAtNuRecoMCTruth.h.

Referenced by RunAlg().

TObjArray AlgAtNuRecoMCTruth::shwcxt [private]
 

Definition at line 25 of file AlgAtNuRecoMCTruth.h.

Referenced by RunAlg().

TObjArray AlgAtNuRecoMCTruth::trkbnk[2] [private]
 

Definition at line 22 of file AlgAtNuRecoMCTruth.h.

Referenced by RunAlg().

TObjArray AlgAtNuRecoMCTruth::trkcxt [private]
 

Definition at line 24 of file AlgAtNuRecoMCTruth.h.

Referenced by RunAlg().


The documentation for this class was generated from the following files:
Generated on Thu Nov 1 15:55:21 2007 for loon by  doxygen 1.3.9.1