00001
00002
00003
00004
00005
00006
00007
00009 #include "AtNuReco/ClusterCam.h"
00010 #include "AtNuReco/HitCam.h"
00011
00012 ClassImp(ClusterCam)
00013
00014
00015
00016
00017 ClusterCam::ClusterCam(HitCam* hit) :
00018 fPlane(-1),fBegStrip(-1), fEndStrip(-1),
00019 fBegTime(0.), fEndTime(0.),
00020 fBegTPos(0.), fEndTPos(0.),
00021 fZPos(0.), fTPos(0.), fCharge(0.),
00022 fTrkFlag(0), fShwFlag(0),
00023 fTrkPlnFlag(0), fShwPlnFlag(0),
00024 fPlaneView(-1),fDigits(0),fNDFlag(1),
00025 StripWidth(4.108e-2)
00026 {
00027 this->AddHit(hit);
00028 }
00030
00031
00033 ClusterCam::~ClusterCam()
00034 {
00035 HitsInCluster.clear();
00036 }
00038
00039
00041 void ClusterCam::AddHit(HitCam* hit)
00042 {
00043 if(HitsInCluster.size()==0) {
00044 HitsInCluster.push_back(hit);
00045
00046 fPlane=hit->GetPlane();
00047 fBegStrip=hit->GetStrip();
00048 fEndStrip=hit->GetStrip();
00049 fBegTPos=hit->GetTPos();
00050 fEndTPos=hit->GetTPos();
00051 fBegTime=hit->GetTime();
00052 fEndTime=hit->GetTime();
00053 fZPos=hit->GetZPos();
00054 fPlaneView=hit->GetPlaneView();
00055 }
00056
00057 else {
00058 if(this->ContainsHit(hit)==true) {return;}
00059 HitsInCluster.push_back(hit);
00060
00061 if(hit->GetStrip()<fBegStrip) fBegStrip=hit->GetStrip();
00062 if(hit->GetStrip()>fEndStrip) fEndStrip=hit->GetStrip();
00063 if(hit->GetTPos()<fBegTPos) fBegTPos=hit->GetTPos();
00064 if(hit->GetTPos()>fEndTPos) fEndTPos=hit->GetTPos();
00065 if(hit->GetTime()<fBegTime) fBegTime=hit->GetTime();
00066 if(hit->GetTime()>fEndTime) fEndTime=hit->GetTime();
00067 }
00068 fDigits += hit->GetCandStripHandle()->GetNDaughters();
00069 fTPos = (fTPos*fCharge+hit->GetTPos()*hit->GetCharge())/(fCharge+hit->GetCharge());
00070 fCharge += hit->GetCharge();
00071
00072 return;
00073
00074 }
00076
00077
00079 bool ClusterCam::ContainsHit(HitCam* hit)
00080 {
00081 for(unsigned int i=0; i<HitsInCluster.size(); ++i) {
00082 if(hit==HitsInCluster[i]) {return true;}
00083 }
00084
00085 return false;
00086 }
00088
00089
00091 int ClusterCam::IsHitAssoc(HitCam* hit) const
00092 {
00093 double TimeWindow = 9999.9;
00094 if( hit->GetPlane()==fPlane
00095 && hit->GetTPos()>(fBegTPos-2*StripWidth) && hit->GetTPos()<(fEndTPos+2*StripWidth)
00096 && hit->GetTime()>(fBegTime-TimeWindow) && hit->GetTime()<(fEndTime+TimeWindow) ) {
00097 return 1;
00098 }
00099 else {return 0;}
00100 }
00102
00103
00105 int ClusterCam::IsShwAssoc(ClusterCam* clust) const
00106 {
00107 double TimeWindow = 99.9; int ShwAssocNum = 0;
00108
00109 if( (fEndTime-clust->GetBegTime())>-TimeWindow || (clust->GetEndTime()-fBegTime)>-TimeWindow ) {
00110
00111 if( abs(clust->GetPlane()-fPlane)<5
00112 && (clust->GetEndTPos()-fBegTPos)>-6*StripWidth && (fEndTPos-clust->GetBegTPos())>-6*StripWidth ) {
00113
00114 if( ( abs(clust->GetPlane()-fPlane)<3
00115 && (clust->GetEndTPos()-fBegTPos)>-StripWidth && (fEndTPos-clust->GetBegTPos())>-StripWidth )
00116
00117 || ( clust->GetPlane()==fPlane
00118 && (clust->GetEndTPos()-fBegTPos)>-3*StripWidth && (fEndTPos-clust->GetBegTPos())>-3*StripWidth ) )
00119
00120 {ShwAssocNum=2;}
00121
00122 else {ShwAssocNum=1;}
00123 }
00124
00125 }
00126
00127 if(ShwAssocNum==2 && this->GetEntries()<3 && clust->GetEntries()<2) {ShwAssocNum=1;}
00128
00129 return ShwAssocNum;
00130 }
00132
00133
00134
00136 int ClusterCam::IsTrkAssoc(ClusterCam* clustm, ClusterCam* clustp, int PlaneGap) const
00137 {
00138 double TimeWindow = 99.9; int TrkAssocNum = 0;
00139 double min=0.2; double max=0.8;
00140 double NDScale=1;
00141
00142
00143
00144 if(PlaneGap==0) {
00145 if(this->GetNDFlag()==2) {PlaneGap=10;}
00146 else {PlaneGap=2;}
00147 }
00148
00149 if(PlaneGap==10) {NDScale=2;}
00150
00151
00152
00153
00154 if(( (fEndTime-clustm->GetBegTime())>-TimeWindow && (clustm->GetEndTime()-fBegTime)>-TimeWindow)
00155 && ( (fEndTime-clustp->GetBegTime())>-TimeWindow && (clustp->GetEndTime()-fBegTime)>-TimeWindow) ) {
00156
00157
00158
00159
00161 double mBegTPos=clustm->GetBegTPos();
00162 double mEndTPos=clustm->GetEndTPos();
00163
00164 if((fPlane-clustm->GetPlane())>PlaneGap) {
00165 double mScale = double(PlaneGap)/double(fPlane-clustm->GetPlane());
00166
00167 mBegTPos=fBegTPos+mScale*(mBegTPos-fBegTPos);
00168 mEndTPos=fEndTPos+mScale*(mEndTPos-fEndTPos);
00169 }
00170
00171 double pBegTPos=clustp->GetBegTPos();
00172 double pEndTPos=clustp->GetEndTPos();
00173
00174 if((clustp->GetPlane()-fPlane)>PlaneGap) {
00175 double pScale = double(PlaneGap)/double(clustp->GetPlane()-fPlane);
00176
00177 pBegTPos=fBegTPos+pScale*(pBegTPos-fBegTPos);
00178 pEndTPos=fEndTPos+pScale*(pEndTPos-fEndTPos);
00179 }
00181
00182
00183
00184 double k0 = 0.5*(clustp->GetPlane()-clustm->GetPlane()-(2*PlaneGap));
00185
00186 if(PlaneGap==10) {k0/=5;}
00187
00188 min = min + 0.1*k0;
00189 max = max - 0.1*k0;
00190
00191
00192
00194
00195 if( (fEndTPos-clustm->GetBegTPos())>-(NDScale*1.1*StripWidth) && (clustp->GetEndTPos()-fBegTPos)>-(NDScale*1.1*StripWidth) ) {
00196
00197
00198 if( (fBegTPos-clustm->GetEndTPos())>-(NDScale*0.1*StripWidth) || (clustp->GetBegTPos()-fEndTPos)>-(NDScale*0.1*StripWidth) ) {
00199 if( TMath::Abs( (clustp->GetBegTPos()-fEndTPos)-(fBegTPos-clustm->GetEndTPos()) )<(NDScale*2.1*StripWidth)
00200 || ( ((min*mEndTPos)+(max*pEndTPos))>(fBegTPos-(NDScale*0.5*StripWidth)) && ((max*mBegTPos)+(min*pBegTPos))<(fEndTPos+(NDScale*0.5*StripWidth)) ) )
00201 {TrkAssocNum=2;}
00202 }
00203
00204
00205 if( (clustm->GetEndTPos()-fBegTPos)>-(NDScale*1.1*StripWidth) && (fEndTPos-clustp->GetBegTPos())>-(NDScale*1.1*StripWidth) ) {
00206 if(TrkAssocNum<1) TrkAssocNum=1;
00207 }
00208 }
00209
00210
00211
00212 if( (fBegTPos-clustm->GetEndTPos())<(NDScale*1.1*StripWidth) && (clustp->GetBegTPos()-fEndTPos)<(NDScale*1.1*StripWidth) ) {
00213
00214
00215 if( (fEndTPos-clustm->GetBegTPos())<(NDScale*0.1*StripWidth) || (clustp->GetEndTPos()-fBegTPos)<(NDScale*0.1*StripWidth) ) {
00216 if( TMath::Abs( (clustp->GetEndTPos()-fBegTPos)-(fEndTPos-clustm->GetBegTPos()) )<(NDScale*2.1*StripWidth)
00217 || ( ((min*pEndTPos)+(max*mEndTPos))>(fBegTPos-(NDScale*0.5*StripWidth)) && ((max*pBegTPos)+(min*mBegTPos))<(fEndTPos+(NDScale*0.5*StripWidth)) ) )
00218 {TrkAssocNum=2;}
00219 }
00220
00221
00222 if( (clustm->GetBegTPos()-fEndTPos)<(NDScale*1.1*StripWidth) && (fBegTPos-clustp->GetEndTPos())<(NDScale*1.1*StripWidth) ) {
00223 if(TrkAssocNum<1) TrkAssocNum=1;
00224 }
00225 }
00227
00228 }
00229
00230 return TrkAssocNum;
00231 }
00233
00234
00236 HitCam* ClusterCam::GetHit(unsigned int i) const
00237 {
00238 if(i<HitsInCluster.size()) {return HitsInCluster[i];}
00239 else {return 0;}
00240 }
00242
00243
00245 int ClusterCam::IsDiffuseShwAssoc(ClusterCam* clr) const
00246 {
00247 double win = 99.9;
00248 int assoc = 0;
00249 if(fEndTime-clr->GetBegTime()>-win || clr->GetEndTime()-fBegTime>-win){
00250 if( clr->GetPlane()-fPlane<9 && clr->GetPlane()-fPlane>-9 && clr->GetEndStrip()-fBegStrip>-21 && fEndStrip-clr->GetBegStrip()>-21 )
00251 {
00252 if( ( clr->GetPlane()-fPlane<5 && clr->GetPlane()-fPlane>-5 && clr->GetEndStrip()-fBegStrip>-11 && fEndStrip-clr->GetBegStrip()>-11 ) ) assoc=2;
00253 else assoc=1;
00254 }
00255 }
00256 return assoc;
00257 }
00259
00260
00262