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

AlgFarDetSlice Class Reference

#include <AlgFarDetSlice.h>

Inheritance diagram for AlgFarDetSlice:

AlgBase List of all members.

Public Member Functions

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

Private Attributes

TObjArray fStrpList [500]

Constructor & Destructor Documentation

AlgFarDetSlice::AlgFarDetSlice  ) 
 

Definition at line 22 of file AlgFarDetSlice.cxx.

00023 {
00024 
00025 }   

AlgFarDetSlice::~AlgFarDetSlice  )  [virtual]
 

Definition at line 27 of file AlgFarDetSlice.cxx.

00028 {
00029 
00030 }


Member Function Documentation

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

Implements AlgBase.

Definition at line 32 of file AlgFarDetSlice.cxx.

References CandHandle::AddDaughterLink(), fStrpList, CandContext::GetCandRecord(), CandStripHandle::GetCharge(), CandContext::GetDataIn(), CandHandle::GetDaughterIterator(), CandDeMuxDigitHandle::GetDeMuxDigitFlagWord(), Registry::GetDouble(), Registry::GetInt(), FabPlnInstallLookup::GetLastNormalPlane(), CandStripHandle::GetPlane(), PlexPlaneId::GetPlane(), CandStripHandle::GetPlaneView(), CandStripHandle::GetStrip(), CandStripHandle::GetTPos(), RecMinos::GetVldContext(), CandStripHandle::GetZPos(), PlexPlaneId::IsValid(), MSG, FarDetSliceHandle::SetEdges(), FarDetSliceHandle::SetEdgesSM1(), FarDetSliceHandle::SetEdgesSM2(), FarDetSliceHandle::SetEventId(), FarDetSliceHandle::SetEventIdSM1(), FarDetSliceHandle::SetEventIdSM2(), FarDetSliceHandle::SetEventIdX(), FarDetSliceHandle::SetGoodPlanes(), FarDetSliceHandle::SetGoodStrips(), FarDetSliceHandle::SetGoodUPlanes(), FarDetSliceHandle::SetGoodVPlanes(), FarDetSliceHandle::SetMaxPlaneCharge(), FarDetSliceHandle::SetSM1(), and FarDetSliceHandle::SetSM2().

00033 {
00034   MSG("FarDetSlice",Msg::kDebug) << " AlgFarDetSlice::RunAlg(...) " << endl;
00035 
00036   FarDetSliceHandle& myslice = dynamic_cast<FarDetSliceHandle&>(ch);
00037 
00038   // Unpack AlgConfig
00039   Int_t fMinPlane,fMaxPlane,fEdgePlnCut;
00040   Double_t fEdgeRadCut,fEdgeWidthCut;
00041   Double_t fEdgeChargeCut,fFidChargeCut;
00042   fMinPlane = ac.GetInt("MinPlane");
00043   fMaxPlane = ac.GetInt("MaxPlane");
00044   fEdgePlnCut = ac.GetInt("EdgePlnCut");
00045   fEdgeRadCut = ac.GetDouble("EdgeRadCut");
00046   fEdgeWidthCut = ac.GetDouble("EdgeWidthCut");
00047   fEdgeChargeCut = ac.GetDouble("EdgeChargeCut");
00048   fFidChargeCut = ac.GetDouble("FidChargeCut");
00049 
00050   MSG("FarDetSlice",Msg::kDebug) << endl
00051                                  << " AlgFarDetSlice Config: " << endl
00052                                  << "  MinPlane=" << fMinPlane 
00053                                  << "  MaxPlane=" << fMaxPlane << endl
00054                                  << "  EdgePlnCut=" << fEdgePlnCut 
00055                                  << "  EdgeRadCut=" << fEdgeRadCut 
00056                                  << "  EdgeWidthCut=" << fEdgeWidthCut
00057                                  << "  EdgeChargeCut=" << fEdgeChargeCut 
00058                                  << "  FidChargeCut=" << fFidChargeCut << endl;
00059 
00060   // Find Max Installed Plane
00061   Int_t fTmpInstallPlane=485,fMaxInstallPlane=485;
00062   CandRecord* candrec = (CandRecord*)(cx.GetCandRecord());
00063   VldContext *vldc = (VldContext*)(candrec->GetVldContext());
00064   FabPlnInstallLookup fMaxPlaneLookup(*vldc);
00065   PlexPlaneId fMaxPlaneId = fMaxPlaneLookup.GetLastNormalPlane();
00066   if(fMaxPlaneId.IsValid()) fTmpInstallPlane = fMaxPlaneId.GetPlane();
00067   if(fTmpInstallPlane<fMaxInstallPlane) fMaxInstallPlane=fTmpInstallPlane;
00068   MSG("FarDetSlice",Msg::kDebug) << "  MaxInstallPlane=" << fMaxInstallPlane << endl;
00069 
00070   if(fMaxInstallPlane<fMaxPlane){
00071     MSG("FarDetSlice",Msg::kDebug) << "   ... resetting MaxPlane to: " << fMaxInstallPlane << endl;
00072     fMaxPlane=fMaxInstallPlane;
00073   }
00074 
00075   if(fMaxInstallPlane<fMinPlane){
00076     MSG("FarDetSlice",Msg::kDebug) << "   ... resetting MinPlane to: " << fMaxInstallPlane << endl;
00077     fMinPlane=fMaxInstallPlane;
00078   }
00079 
00080   // Unpack CandContext
00081   const TObjArray* myarray = dynamic_cast<const TObjArray*>(cx.GetDataIn());
00082 
00083   Int_t i,j;
00084   Int_t pln,vuw,sm;
00085   Int_t xtalk;
00086   Double_t q;
00087   
00088   for(i=0;i<1+myarray->GetLast();i++){
00089     CandStripHandle* mystrip = (CandStripHandle*)(myarray->At(i));
00090     myslice.AddDaughterLink(*mystrip);
00091     pln=mystrip->GetPlane();
00092 
00093     xtalk=0;
00094     TIter digitr(mystrip->GetDaughterIterator());
00095     while(CandDeMuxDigitHandle* digit = dynamic_cast<CandDeMuxDigitHandle*>(digitr())){
00096       if(  (digit->GetDeMuxDigitFlagWord()<8)
00097         && ( (digit->GetDeMuxDigitFlagWord() & CandDeMuxDigit::kXTalk)==(CandDeMuxDigit::kXTalk) ) ){
00098         xtalk=1; 
00099       }
00100     }
00101 
00102     q=mystrip->GetCharge();
00103     if( pln>0 && pln<500
00104      && pln>=fMinPlane && pln<=fMaxPlane
00105      && !xtalk && q>2.0 ){
00106       fStrpList[pln].Add(mystrip);
00107     }
00108   }
00109 
00110   // Good Planes
00111   Int_t flag=0,uflag=0,vflag=0;
00112   Int_t nplanes=0,uplanes=0,vplanes=0;
00113   Int_t nstrips=0;
00114 
00115   for(pln=0;pln<500;pln++){
00116     flag=0;
00117     uflag=0; vflag=0;
00118     if(1+fStrpList[pln].GetLast()>0){
00119       flag=1; nstrips+=1+fStrpList[pln].GetLast();
00120       CandStripHandle* firststrip = (CandStripHandle*)(fStrpList[pln].First());
00121       if(firststrip->GetPlaneView()==PlaneView::kU) uflag=1;
00122       if(firststrip->GetPlaneView()==PlaneView::kV) vflag=1;
00123     }
00124     if(flag){
00125       if(uflag) uplanes+=1; if(vflag) vplanes+=1;
00126       nplanes+=1;
00127     }
00128   }
00129 
00130   MSG("FarDetSlice",Msg::kDebug) << " nplanes=" << nplanes << " nstrips=" << nstrips << endl; 
00131 
00132   // Max Plane Charge
00133   Double_t thisplncharge=0.0;
00134   Double_t maxplncharge=0.0;
00135   for(pln=0;pln<500;pln++){
00136     if(1+fStrpList[pln].GetLast()>0){
00137       thisplncharge=0.0;
00138       for(j=0;j<1+fStrpList[pln].GetLast();j++){
00139         CandStripHandle* mystrip = (CandStripHandle*)(fStrpList[pln].At(j));
00140         thisplncharge+=mystrip->GetCharge();
00141       }
00142       if(thisplncharge>maxplncharge){
00143         maxplncharge=thisplncharge;
00144       }
00145     }
00146   }
00147 
00148   MSG("FarDetSlice",Msg::kDebug) << " maxplncharge=" << maxplncharge << endl;
00149 
00150   // Containment 
00151   Double_t qSM1[11],qSM2[11]; // 0=contained, 1-8=edges, 9-10=beg/end
00152   Double_t xSM1[11],xSM2[11];
00153   Double_t ySM1[11],ySM2[11];
00154   Double_t zSM1[11],zSM2[11]; 
00155   Int_t eventidSM1,eventidSM2,eventidX;
00156   Int_t edgesSM1,edgesSM2,edges;
00157   Int_t Tctr,Zctr;
00158   Double_t upos,vpos,tpos,opos,xpos,ypos,zpos;
00159   Double_t totqo,totq;
00160   Double_t xm,xp,ym,yp,um,up,vm,vp;
00161   Double_t dx,dy,dz,dr;
00162   Double_t rmin;
00163   Int_t id,cont;
00164   Int_t eventid;
00165 
00166   for(i=0;i<11;i++){
00167     qSM1[i]=0.0; qSM2[i]=0.0; 
00168     xSM1[i]=0.0; xSM2[i]=0.0;
00169     ySM1[i]=0.0; ySM2[i]=0.0;
00170     zSM1[i]=0.0; zSM2[i]=0.0;
00171   }
00172   
00173   for(pln=0;pln<500;pln++){
00174     for(i=0;i<1+fStrpList[pln].GetLast();i++){
00175       CandStripHandle* mystrip = (CandStripHandle*)(fStrpList[pln].At(i));
00176       cont=0; id=-1;   
00177       MSG("FarDetSlice",Msg::kVerbose) << "  STRIP : " 
00178                                        << " " << mystrip->GetPlane() 
00179                                        << " " << mystrip->GetStrip() 
00180                                        << " " << mystrip->GetCharge() << endl; 
00181 
00182       vuw=-1; sm=-1; 
00183       if(mystrip->GetPlaneView()==PlaneView::kU) vuw=0;
00184       if(mystrip->GetPlaneView()==PlaneView::kV) vuw=1;
00185       if(pln>0 && pln<249) sm=1; if(pln>249 && pln<498) sm=2;
00186       tpos=mystrip->GetTPos(); opos=0.0; 
00187       
00188       totqo=0.0; totq=0.0;
00189       if((pln>1&&pln<249)||(pln>250&&pln<498)){
00190         for(j=0;j<1+fStrpList[pln-1].GetLast();j++){
00191           CandStripHandle* tmpstrip = (CandStripHandle*)(fStrpList[pln-1].At(j));  
00192           totqo+=tmpstrip->GetCharge()*tmpstrip->GetTPos();
00193           totq+=tmpstrip->GetCharge();
00194         } 
00195       }        
00196       if((pln>0&&pln<248)||(pln>249&&pln<497)){
00197         for(j=0;j<1+fStrpList[pln+1].GetLast();j++){
00198           CandStripHandle* tmpstrip = (CandStripHandle*)(fStrpList[pln+1].At(j));  
00199           totqo+=tmpstrip->GetCharge()*tmpstrip->GetTPos();
00200           totq+=tmpstrip->GetCharge();
00201         }
00202       }
00203       if(totq>0.0){ opos=totqo/totq; } else{ opos=0.0; }
00204 
00205       upos=0.0; vpos=0.0;
00206       if(vuw==0){ upos=tpos; vpos=opos; } 
00207       if(vuw==1){ upos=opos; vpos=tpos; }
00208       xpos=0.7071*(upos-vpos); ypos=0.7071*(upos+vpos); 
00209       zpos=mystrip->GetZPos();
00210 
00211       MSG("FarDetSlice",Msg::kVerbose) << "  "
00212                                        << " u=" << upos << " v=" << vpos 
00213                                        << " x=" << xpos << " y=" << ypos 
00214                                        << " z=" << zpos << endl;
00215 
00216       if(sm>-1 && vuw>-1) cont=1;
00217 
00218       if(cont){
00219         if(sm==1){
00220           if( (pln<1+fEdgePlnCut)||(fMinPlane<249&&pln<fMinPlane+fEdgePlnCut) ) id=9;
00221           if( (pln>248-fEdgePlnCut)||(fMaxPlane<249&&pln>fMaxPlane-fEdgePlnCut) ) id=10; }
00222         if(sm==2){
00223           if( (pln<250+fEdgePlnCut)||(fMinPlane>249&&pln<fMinPlane+fEdgePlnCut) ) id=9;
00224           if( (pln>485-fEdgePlnCut)||(fMaxPlane>249&&pln>fMaxPlane-fEdgePlnCut) ) id=10; }
00225         
00226         if(id>0) cont=0;
00227         if(id>0) MSG("FarDetSlice",Msg::kVerbose) << "    ... id=" << id << endl;
00228       }
00229 
00230       if(cont){  
00231         rmin=4.0; 
00232         up=4.0-upos; if(up<rmin){ rmin=up; if(rmin<fEdgeRadCut) id=2; }
00233         um=4.0+upos; if(um<rmin){ rmin=um; if(rmin<fEdgeRadCut) id=6; }
00234         vp=4.0-vpos; if(vp<rmin){ rmin=vp; if(rmin<fEdgeRadCut) id=8; }
00235         vm=4.0+vpos; if(vm<rmin){ rmin=vm; if(rmin<fEdgeRadCut) id=4; }
00236         xp=4.0-xpos; if(xp<rmin){ rmin=xp; if(rmin<fEdgeRadCut) id=3; }
00237         xm=4.0+xpos; if(xm<rmin){ rmin=xm; if(rmin<fEdgeRadCut) id=7; }
00238         yp=4.0-ypos; if(yp<rmin){ rmin=yp; if(rmin<fEdgeRadCut) id=1; }
00239         ym=4.0+ypos; if(ym<rmin){ rmin=ym; if(rmin<fEdgeRadCut) id=5; }
00240       
00241         if(id>0) cont=0;
00242         if(id>0) MSG("FarDetSlice",Msg::kVerbose) << "    ... id=" << id << endl;
00243       }
00244 
00245       if(cont){
00246         id=0;
00247         if(id==0) MSG("FarDetSlice",Msg::kVerbose) << "    ... contained" << endl;
00248       }
00249 
00250       if(1+id>0){
00251         if(sm==1){
00252           qSM1[id]+=mystrip->GetCharge(); 
00253           xSM1[id]+=mystrip->GetCharge()*xpos;
00254           ySM1[id]+=mystrip->GetCharge()*ypos;
00255           zSM1[id]+=mystrip->GetCharge()*zpos; }
00256 
00257         if(sm==2){ 
00258           qSM2[id]+=mystrip->GetCharge(); 
00259           xSM2[id]+=mystrip->GetCharge()*xpos;
00260           ySM2[id]+=mystrip->GetCharge()*ypos;
00261           zSM2[id]+=mystrip->GetCharge()*zpos; }
00262       }
00263  
00264     }
00265   }
00266 
00267   for(i=0;i<11;i++){
00268     if( qSM1[i]>0.0 ){
00269       xSM1[i]=xSM1[i]/qSM1[i]; ySM1[i]=ySM1[i]/qSM1[i]; zSM1[i]=zSM1[i]/qSM1[i]; }
00270     else{
00271       xSM1[i]=-999.9; ySM1[i]=-999.9; zSM1[i]=-999.9; }
00272 
00273     if( qSM2[i]>0.0 ){
00274       xSM2[i]=xSM2[i]/qSM2[i]; ySM2[i]=ySM2[i]/qSM2[i]; zSM2[i]=zSM2[i]/qSM2[i]; }
00275     else{
00276       xSM2[i]=-999.9; ySM2[i]=-999.9; zSM2[i]=-999.9; }
00277   }
00278 
00279   MSG("FarDetSlice",Msg::kDebug) << " *** RESULTS *** " << endl;
00280   MSG("FarDetSlice",Msg::kDebug) << "  *** SM1 *** " << endl;
00281   for(i=0;i<11;i++){
00282     MSG("FarDetSlice",Msg::kDebug) << "  " << i << "  "
00283                                    << qSM1[i] << "   ( "
00284                                    << xSM1[i] << " , "
00285                                    << ySM1[i] << " , "
00286                                    << zSM1[i] << " )   " << endl; 
00287   }
00288    
00289   MSG("FarDetSlice",Msg::kDebug) << "  *** SM2 *** " << endl;
00290   for(i=0;i<11;i++){
00291     MSG("FarDetSlice",Msg::kDebug) << "  " << i << "  "
00292                                    << qSM2[i] << "   ( "
00293                                    << xSM2[i] << " , "
00294                                    << ySM2[i] << " , "
00295                                    << zSM2[i] << " )   " << endl;
00296   }
00297 
00298 
00299   edgesSM1=0;
00300   eventidSM1=-1;
00301   Tctr=0; Zctr=0;
00302   for(i=1;i<9;i++){
00303     if( qSM1[i]>fEdgeChargeCut ){
00304       if(Tctr<1) Tctr=1;
00305       for(j=1;j<9;j++){
00306         if( qSM1[j]>fEdgeChargeCut ){ 
00307           dx = xSM1[j]-xSM1[i];
00308           dy = ySM1[j]-ySM1[i];
00309           dz = zSM1[j]-zSM1[i];
00310           dr = sqrt(dx*dx+dy*dy+dz*dz);
00311           if( ( (i-j>-7&&i-j<-1)||(i-j>1&&i-j<7) )
00312            || ( dr>fEdgeWidthCut && i!=j ) ){      
00313             if(Tctr<2) Tctr=2;
00314           }
00315         }
00316       }
00317       edgesSM1++;
00318     }
00319   }
00320   for(j=9;j<11;j++){
00321     if( qSM1[j]>fEdgeChargeCut ){
00322       Zctr++; edgesSM1++;
00323     }
00324   }
00325   if( qSM1[0]>fFidChargeCut ){
00326     eventidSM1=Tctr+Zctr; if(eventidSM1>1) eventidSM1=2;
00327   }
00328   
00329   edgesSM2=0;
00330   eventidSM2=-1;
00331   Tctr=0; Zctr=0;
00332   for(i=1;i<9;i++){
00333     if( qSM2[i]>fEdgeChargeCut ){
00334       if(Tctr<1) Tctr=1;
00335       for(j=1;j<9;j++){
00336         if( qSM2[j]>fEdgeChargeCut ){ 
00337           dx = xSM2[j]-xSM2[i];
00338           dy = ySM2[j]-ySM2[i];
00339           dz = zSM2[j]-zSM2[i];
00340           dr = sqrt(dx*dx+dy*dy+dz*dz);
00341           if( ( (i-j>-7&&i-j<-1)||(i-j>1&&i-j<7) )
00342            || ( dr>fEdgeWidthCut && i!=j ) ){      
00343             if(Tctr<2) Tctr=2;
00344           }
00345         }
00346       }
00347       edgesSM2++;
00348     }
00349   }
00350   for(j=9;j<11;j++){
00351     if( qSM2[j]>fEdgeChargeCut ){
00352       Zctr++; edgesSM2++;
00353     }
00354   }
00355   if( qSM2[0]>fFidChargeCut ){
00356     eventidSM2=Tctr+Zctr; if(eventidSM2>1) eventidSM2=2; 
00357   }
00358   
00359   eventidX=0;
00360   if( eventidSM1>-1 && eventidSM2>-1
00361    && qSM1[10]>fEdgeChargeCut && qSM2[9]>fEdgeChargeCut ) eventidX=1;
00362  
00363   edges=0;
00364   if( eventidSM1>-1 ) edges+=edgesSM1;
00365   if( eventidSM2>-1 ) edges+=edgesSM2; 
00366   if( eventidX ) edges=edges-2;
00367 
00368   MSG("FarDetSlice",Msg::kDebug) << " eventid : "
00369                                  << " SM1=" << eventidSM1
00370                                  << " SM2=" << eventidSM2
00371                                  << " X=" << eventidX << endl;
00372   MSG("FarDetSlice",Msg::kDebug) << " edges : "
00373                                  << " SM1=" << edgesSM1
00374                                  << " SM2=" << edgesSM2
00375                                  << " total=" << edges << endl;
00376 
00377   eventid=-1;
00378   if( (eventidSM1<0&&eventidSM2==0) 
00379    || (eventidSM1==0&&eventidSM2<0)
00380    || (eventidSM1==1&&eventidSM2==1&&eventidX>0) ) eventid=0;
00381   if( (eventidSM1<0&&eventidSM2==1) 
00382    || (eventidSM1==1&&eventidSM2<0)
00383    || (eventidSM1==1&&eventidSM2==2&&eventidX>0)
00384    || (eventidSM1==2&&eventidSM2==1&&eventidX>0) ) eventid=1;
00385   if( (eventidSM1<0&&eventidSM2==2) 
00386    || (eventidSM1==2&&eventidSM2<0)
00387    || (eventidSM1==2&&eventidSM2==2&&eventidX>0) ) eventid=2;
00388 
00389   MSG("FarDetSlice",Msg::kDebug) << " eventid : " << eventid << endl;
00390 
00391 
00392   // Set slice parameters
00393   myslice.SetSM1(qSM1,xSM1,ySM1,zSM1);
00394   myslice.SetSM2(qSM2,xSM2,ySM2,zSM2);
00395   myslice.SetMaxPlaneCharge(maxplncharge);
00396   myslice.SetEventId(eventid);
00397   myslice.SetEventIdSM1(eventidSM1);
00398   myslice.SetEventIdSM2(eventidSM2);
00399   myslice.SetEventIdX(eventidX);
00400   myslice.SetEdgesSM1(edgesSM1);
00401   myslice.SetEdgesSM2(edgesSM2);
00402   myslice.SetEdges(edges);
00403   myslice.SetGoodUPlanes(uplanes);
00404   myslice.SetGoodVPlanes(vplanes);
00405   myslice.SetGoodPlanes(nplanes);
00406   myslice.SetGoodStrips(nstrips);
00407 
00408 
00409   for(i=0;i<500;i++){
00410     fStrpList[i].Clear();
00411   }
00412 
00413 }

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

Reimplemented from AlgBase.

Definition at line 415 of file AlgFarDetSlice.cxx.

00416 {
00417 
00418 }


Member Data Documentation

TObjArray AlgFarDetSlice::fStrpList[500] [private]
 

Definition at line 18 of file AlgFarDetSlice.h.

Referenced by RunAlg().


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