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

AlgFarDetShieldPlankList.cxx

Go to the documentation of this file.
00001 #include "AlgFarDetShieldPlankList.h"
00002 #include "FarDetShieldPlankListHandle.h"
00003 #include "FarDetShieldPlankHandle.h"
00004 
00005 #include "MessageService/MsgService.h"
00006 #include "MinosObjectMap/MomNavigator.h"
00007 
00008 #include "Algorithm/AlgFactory.h"
00009 #include "Algorithm/AlgHandle.h"
00010 #include "Algorithm/AlgConfig.h"
00011 
00012 #include "CandData/CandRecord.h"
00013 #include "Candidate/CandContext.h"
00014 #include "CandDigit/CandDigitHandle.h"
00015 #include "CandDigit/CandDigitListHandle.h"
00016 
00017 ClassImp(AlgFarDetShieldPlankList)
00018  
00019 CVSID("$Id: AlgFarDetShieldPlankList.cxx,v 1.5 2007/12/19 21:53:23 bspeak Exp $");
00020 
00021 AlgFarDetShieldPlankList::AlgFarDetShieldPlankList() :
00022   fPairList(0)
00023 {
00024   fPairList = new TObjArray();
00025 }
00026 
00027 AlgFarDetShieldPlankList::~AlgFarDetShieldPlankList()
00028 {
00029   if(fPairList) delete fPairList;
00030 }
00031 
00032 void AlgFarDetShieldPlankList::RunAlg(AlgConfig& /* ac */, 
00033                                       CandHandle& ch, CandContext& cx)
00034 {
00035   MSG("FarDetShieldPlankList",Msg::kDebug) << " *** AlgFarDetShieldPlankList::RunAlg(...) *** "<<endl;
00036 
00037   FarDetShieldPlankListHandle& myplanklist = dynamic_cast<FarDetShieldPlankListHandle&>(ch);
00038 
00039   Int_t DigitsBefore=0,DigitsAfter=0;
00040 
00041   Int_t i,j,kn,kp;
00042   Int_t veto,pln,match;
00043   TObjArray northlist,southlist;
00044   TObjArray tmpn,tmpp,tmp1;
00045 
00046   // Unpack CandContext
00047   CandRecord* candrec = (CandRecord*)(cx.GetCandRecord());
00048   const TObjArray* inputarray = dynamic_cast<const TObjArray*>(cx.GetDataIn());
00049   const CandDigitListHandle *cdlh = dynamic_cast<const CandDigitListHandle*>(inputarray->At(0));
00050 
00051   TIter digitr(cdlh->GetDaughterIterator());
00052   while(CandDigitHandle* cdh = dynamic_cast<CandDigitHandle*>(digitr())){
00053     if(cdh){
00054       veto = cdh->GetPlexSEIdAltL().IsVetoShield();
00055 
00056       //Find the lowest Plane value in the AltList to set as the key
00057       pln = cdh->GetPlexSEIdAltL().GetPlane();
00058       cdh->GetPlexSEIdAltL().SetFirst();
00059       while ( cdh->GetPlexSEIdAltL().IsValid() ) {
00060         if( cdh->GetPlexSEIdAltL().GetCurrentSEId().GetPlane() < pln )
00061           pln = cdh->GetPlexSEIdAltL().GetCurrentSEId().GetPlane();
00062         cdh->GetPlexSEIdAltL().Next();
00063       }
00064       cdh->GetPlexSEIdAltL().SetFirst();
00065       pln -= 500;
00066 
00067       if( veto && pln>0 && pln<500 ){
00068         fDigiList[pln].Add(cdh);
00069         MSG("FarDetShieldPlank",Msg::kVerbose) << " digit : " 
00070                                                << " " << cdh->GetPlexSEIdAltL().GetPlane() 
00071                                                << " " << cdh->GetPlexSEIdAltL().GetEnd()
00072                                                << " " << cdh->GetCharge(CalDigitType::kNone) 
00073                                                << " " << 1.0e9*cdh->GetSubtractedTime(CalTimeType::kNone) << endl;
00074         DigitsBefore++;
00075       }
00076     }
00077   }
00078     
00079   // Pair up CandDigits
00080   for(i=0;i<500;i++){
00081     if(1+fDigiList[i].GetLast()>0){
00082     
00083       for(j=0;j<1+fDigiList[i].GetLast();j++){
00084         CandDigitHandle* digit = (CandDigitHandle*)(fDigiList[i].At(j));
00085         const PlexSEIdAltL& pSEIdAltL = digit->GetPlexSEIdAltL();
00086         if(pSEIdAltL.GetEnd()==StripEnd::kNegative) northlist.Add(digit);
00087         if(pSEIdAltL.GetEnd()==StripEnd::kPositive) southlist.Add(digit);
00088       }
00089 
00090       for(kn=0;kn<1+northlist.GetLast();kn++){
00091         CandDigitHandle* dign = (CandDigitHandle*)(northlist.At(kn));
00092         const PlexSEIdAltL& nSEIdAltL = dign->GetPlexSEIdAltL();
00093         match=0;
00094         for(kp=0;kp<1+southlist.GetLast();kp++){
00095           CandDigitHandle* digp = (CandDigitHandle*)(southlist.At(kp));
00096           const PlexSEIdAltL& pSEIdAltL = digp->GetPlexSEIdAltL();
00097           if( 1.0e9*(dign->GetTime(CalTimeType::kNone)-digp->GetTime(CalTimeType::kNone))>-500.0  
00098            && 1.0e9*(dign->GetTime(CalTimeType::kNone)-digp->GetTime(CalTimeType::kNone))<500.0 ){
00099             for(PlexSEIdAltL::const_iterator itern = nSEIdAltL.begin();itern!=nSEIdAltL.end(); ++itern){
00100               for(PlexSEIdAltL::const_iterator iterp = pSEIdAltL.begin();iterp!=pSEIdAltL.end(); ++iterp){
00101                 if((*itern).GetSEId().IsSameStrip((*iterp).GetSEId())) match=1;
00102               }
00103             }
00104           }
00105         }
00106         if(match) tmpn.Add(dign); else tmp1.Add(dign);
00107       }
00108 
00109       for(kp=0;kp<1+southlist.GetLast();kp++){
00110         CandDigitHandle* digp = (CandDigitHandle*)(southlist.At(kp));
00111         const PlexSEIdAltL& pSEIdAltL = digp->GetPlexSEIdAltL();
00112         match=0;
00113         for(kn=0;kn<1+northlist.GetLast();kn++){
00114           CandDigitHandle* dign = (CandDigitHandle*)(northlist.At(kn));
00115           const PlexSEIdAltL& nSEIdAltL = dign->GetPlexSEIdAltL();
00116           if( 1.0e9*(dign->GetTime(CalTimeType::kNone)-digp->GetTime(CalTimeType::kNone))>-500.0  
00117            && 1.0e9*(dign->GetTime(CalTimeType::kNone)-digp->GetTime(CalTimeType::kNone))<500.0 ){
00118             for(PlexSEIdAltL::const_iterator iterp = pSEIdAltL.begin();iterp!=pSEIdAltL.end(); ++iterp){
00119               for(PlexSEIdAltL::const_iterator itern = nSEIdAltL.begin();itern!=nSEIdAltL.end(); ++itern){
00120                 if((*iterp).GetSEId().IsSameStrip((*itern).GetSEId())) match=1;
00121               }
00122             }
00123           }
00124         }
00125         if(match) tmpp.Add(digp); else tmp1.Add(digp);
00126       }
00127 
00128       if( 1+tmpn.GetLast()>0 && 1+tmpp.GetLast()>0 ){
00129         for(kn=0;kn<1+tmpn.GetLast();kn++){
00130           CandDigitHandle* dign = (CandDigitHandle*)(tmpn.At(kn));
00131           const PlexSEIdAltL& nSEIdAltL = dign->GetPlexSEIdAltL();   
00132           for(kp=0;kp<1+tmpp.GetLast();kp++){
00133             CandDigitHandle* digp = (CandDigitHandle*)(tmpp.At(kp));
00134             const PlexSEIdAltL& pSEIdAltL = digp->GetPlexSEIdAltL();
00135             if( 1.0e9*(dign->GetTime(CalTimeType::kNone)-digp->GetTime(CalTimeType::kNone))>-500.0  
00136              && 1.0e9*(dign->GetTime(CalTimeType::kNone)-digp->GetTime(CalTimeType::kNone))<500.0 ){
00137               match=0;
00138               for(PlexSEIdAltL::const_iterator itern = nSEIdAltL.begin();itern!=nSEIdAltL.end(); ++itern){
00139                 for(PlexSEIdAltL::const_iterator iterp = pSEIdAltL.begin();iterp!=pSEIdAltL.end(); ++iterp){
00140                   if((*itern).GetSEId().IsSameStrip((*iterp).GetSEId())) match=1;
00141                 }
00142               }
00143               if(match){
00144                 TObjArray* myarray = new TObjArray();
00145                 myarray->Add(dign); DigitsAfter++; 
00146                 myarray->Add(digp); DigitsAfter++;
00147                 fPairList->Add(myarray);
00148               }
00149             }
00150           }
00151         }
00152       }
00153 
00154       for(j=0;j<1+tmp1.GetLast();j++){
00155         CandDigitHandle* dig = (CandDigitHandle*)(tmp1.At(j));
00156         TObjArray* myarray = new TObjArray();
00157         myarray->Add(dig); DigitsAfter++; 
00158         fPairList->Add(myarray);
00159       }
00160       
00161       tmpn.Clear(); tmpp.Clear(); tmp1.Clear(); 
00162       northlist.Clear(); southlist.Clear();
00163     }
00164   }
00165 
00166   // Print out list digit pairs
00167   for(Int_t i=0; i<1+fPairList->GetLast();i++){
00168     TObjArray* temparray = (TObjArray*)(fPairList->At(i));
00169     MSG("FarDetShieldPlank",Msg::kVerbose) << " " << i << ":" << endl;
00170 
00171     CandDigitHandle* dig1 = (CandDigitHandle*)(temparray->At(0));
00172     if( dig1 ){
00173       MSG("FarDetShieldPlank",Msg::kVerbose) << "  (1) " <<  dig1->GetPlexSEIdAltL().GetPlane() << " " << dig1->GetPlexSEIdAltL().GetEnd() << " " << dig1->GetCharge(CalDigitType::kNone) << " " << 1.0e9*dig1->GetSubtractedTime(CalTimeType::kNone) << " " << "(" << dig1->GetChannelId().GetCrate() << "-" << dig1->GetChannelId().GetVarcId() << "-" << dig1->GetChannelId().GetVmm() << "-" << dig1->GetChannelId().GetVaAdcSel() << "-" << dig1->GetChannelId().GetVaChip() << "-" << dig1->GetChannelId().GetVaChannel() << ")" << endl;
00174     }
00175 
00176     CandDigitHandle* dig2 = (CandDigitHandle*)(temparray->At(1));
00177     if( dig2 ){
00178       MSG("FarDetShieldPlank",Msg::kVerbose) << "  (2) " <<  dig2->GetPlexSEIdAltL().GetPlane() << " " << dig2->GetPlexSEIdAltL().GetEnd() << " " << dig2->GetCharge(CalDigitType::kNone) << " " << 1.0e9*dig2->GetSubtractedTime(CalTimeType::kNone) << " " << "(" << dig2->GetChannelId().GetCrate() << "-" << dig2->GetChannelId().GetVarcId() << "-" << dig2->GetChannelId().GetVmm() << "-" << dig2->GetChannelId().GetVaAdcSel() << "-" << dig2->GetChannelId().GetVaChip() << "-" << dig2->GetChannelId().GetVaChannel() << ")" << endl;
00179     }
00180   }
00181 
00182   // Check on number digits
00183   MSG("FarDetShieldPlank",Msg::kDebug) << "  DIGITS BEFORE = " << DigitsBefore << "  DIGITS AFTER = " << DigitsAfter << endl;
00184 
00185   // Make ShieldPlanks
00186   AlgFactory &af = AlgFactory::GetInstance();
00187   AlgHandle ahh = af.GetAlgHandle("AlgFarDetShieldPlank","default");
00188   CandContext cxx(this,cx.GetMom());
00189   cxx.SetCandRecord(candrec);
00190 
00191   for(i=0;i<1+fPairList->GetLast();i++){
00192     TObjArray* mypair = (TObjArray*)(fPairList->At(i));
00193     cxx.SetDataIn(mypair);
00194     FarDetShieldPlankHandle myplank = FarDetShieldPlank::MakeCandidate(ahh,cxx);
00195     myplank.SetName("FarDetShieldPlank");
00196     myplank.SetTitle(TString("Created by FarDetShieldPlankList"));
00197     myplanklist.AddDaughterLink(myplank);
00198   }
00199 
00200   for(i=0;i<500;i++){
00201     fDigiList[i].Clear();
00202   }
00203 
00204   fPairList->Delete();
00205 
00206   return;
00207 }
00208 
00209 
00210 void AlgFarDetShieldPlankList::Trace(const char* /*c*/) const
00211 {
00212 
00213 }
00214 
00215 
00216 
00217 
00218 

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