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

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 24 of file AlgFarDetSlice.cxx.

00025 {
00026 
00027 }   

AlgFarDetSlice::~AlgFarDetSlice  )  [virtual]
 

Definition at line 29 of file AlgFarDetSlice.cxx.

00030 {
00031 
00032 }


Member Function Documentation

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

Implements AlgBase.

Definition at line 34 of file AlgFarDetSlice.cxx.

References CandHandle::AddDaughterLink(), digit(), fStrpList, CandContext::GetCandRecord(), CandStripHandle::GetCharge(), CandContext::GetDataIn(), CandHandle::GetDaughterIterator(), CandDeMuxDigitHandle::GetDeMuxDigitFlagWord(), Registry::GetDouble(), Registry::GetInt(), FabPlnInstallLookup::GetLastNormalPlane(), CandStripHandle::GetNDigit(), 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().

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

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

Reimplemented from AlgBase.

Definition at line 418 of file AlgFarDetSlice.cxx.

00419 {
00420 
00421 }


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 11:56:24 2007 for loon by  doxygen 1.3.9.1