00001 #include "ClusterAtNu.h"
00002
00003 ClassImp(ClusterAtNu)
00004
00005
00006
00007 ClusterAtNu::ClusterAtNu() :
00008 fPlane(-1),fBegStrip(-1), fEndStrip(-1),
00009 fBegTime(0.0), fEndTime(0.0),
00010 fZPos(0.0), fTPos(0.0), fCharge(0.0),
00011 fTrkFlag(0), fShwFlag(0),
00012 fTrkPlnFlag(0), fShwPlnFlag(0), fClrPlnFlag(0)
00013 {
00014
00015 }
00016
00017 ClusterAtNu::ClusterAtNu(HitAtNu* hit) :
00018 fPlane(-1),fBegStrip(-1), fEndStrip(-1),
00019 fBegTime(0.0), fEndTime(0.0),
00020 fZPos(0.0), fTPos(0.0), fCharge(0.0),
00021 fTrkFlag(0), fShwFlag(0),
00022 fTrkPlnFlag(0), fShwPlnFlag(0), fClrPlnFlag(0)
00023 {
00024 this->AddHit(hit);
00025 }
00026
00027 ClusterAtNu::ClusterAtNu(const ClusterAtNu& rhs) :
00028 ObjAtNu(rhs),
00029 fPlane(rhs.fPlane),
00030 fBegStrip(rhs.fBegStrip),
00031 fEndStrip(rhs.fEndStrip),
00032 fBegTime(rhs.fBegTime),
00033 fEndTime(rhs.fEndTime),
00034 fZPos(rhs.fZPos),
00035 fTPos(rhs.fTPos),
00036 fCharge(rhs.fCharge),
00037 fTrkFlag(rhs.fTrkFlag),
00038 fShwFlag(rhs.fShwFlag),
00039 fTrkPlnFlag(rhs.fTrkPlnFlag),
00040 fShwPlnFlag(rhs.fShwPlnFlag),
00041 fClrPlnFlag(rhs.fClrPlnFlag)
00042 {
00043
00044 }
00045
00046 ClusterAtNu::~ClusterAtNu()
00047 {
00048
00049 }
00050
00051 Int_t ClusterAtNu::IsTrkAssoc(ClusterAtNu* clrm, ClusterAtNu* clrp) const
00052 {
00053 Double_t win=99.9;
00054 Int_t assoc=0;
00055 Double_t min=0.20,max=0.80;
00056 if( (fEndTime-clrm->GetBegTime()>-win && clrm->GetEndTime()-fBegTime>-win)
00057 && (fEndTime-clrp->GetBegTime()>-win && clrp->GetEndTime()-fBegTime>-win) ){
00058
00059 Double_t clrmGetBegStrip=clrm->GetBegStrip();
00060 Double_t clrmGetEndStrip=clrm->GetEndStrip();
00061 if(fPlane-clrm->GetPlane()>2){
00062 Double_t km=2.0/(fPlane-clrm->GetPlane());
00063 clrmGetBegStrip=fBegStrip+km*(clrmGetBegStrip-fBegStrip);
00064 clrmGetEndStrip=fEndStrip+km*(clrmGetEndStrip-fEndStrip);
00065 }
00066
00067 Double_t clrpGetBegStrip=clrp->GetBegStrip();
00068 Double_t clrpGetEndStrip=clrp->GetEndStrip();
00069 if(clrp->GetPlane()-fPlane>2){
00070 Double_t kp=2.0/(clrp->GetPlane()-fPlane);
00071 clrpGetBegStrip=fBegStrip+kp*(clrpGetBegStrip-fBegStrip);
00072 clrpGetEndStrip=fEndStrip+kp*(clrpGetEndStrip-fEndStrip);
00073 }
00074
00075 Double_t k0 = 0.5*(clrp->GetPlane()-clrm->GetPlane()-4.0);
00076 min = min + 0.1*k0; max = max - 0.1*k0;
00077
00078 if(fEndStrip-clrm->GetBegStrip()>-1.1 && clrp->GetEndStrip()-fBegStrip>-1.1){
00079 if(fBegStrip-clrm->GetEndStrip()>-0.1 || clrp->GetBegStrip()-fEndStrip>-0.1){
00080 if( ( (clrp->GetBegStrip()-fEndStrip)-(fBegStrip-clrm->GetEndStrip())<2.1
00081 && (clrp->GetBegStrip()-fEndStrip)-(fBegStrip-clrm->GetEndStrip())>-2.1 )
00082 || ( min*clrmGetEndStrip+max*clrpGetEndStrip>fBegStrip-0.5
00083 && max*clrmGetBegStrip+min*clrpGetBegStrip<fEndStrip+0.5 ) )
00084 if(assoc<2) assoc=2;
00085 }
00086 if(clrm->GetEndStrip()-fBegStrip>-1.1 && fEndStrip-clrp->GetBegStrip()>-1.1){
00087 if(assoc<1) assoc=1;
00088 }
00089 }
00090 if(fBegStrip-clrm->GetEndStrip()<1.1 && clrp->GetBegStrip()-fEndStrip<1.1){
00091 if(fEndStrip-clrm->GetBegStrip()<0.1 || clrp->GetEndStrip()-fBegStrip<0.1){
00092 if( ( (clrp->GetEndStrip()-fBegStrip)-(fEndStrip-clrm->GetBegStrip())>-2.1
00093 && (clrp->GetEndStrip()-fBegStrip)-(fEndStrip-clrm->GetBegStrip())<2.1 )
00094 || ( min*clrpGetEndStrip+max*clrmGetEndStrip>fBegStrip-0.5
00095 && max*clrpGetBegStrip+min*clrmGetBegStrip<fEndStrip+0.5 ) )
00096 if(assoc<2) assoc=2;
00097 }
00098 if(clrm->GetBegStrip()-fEndStrip<1.1 && fBegStrip-clrp->GetEndStrip()<1.1){
00099 if(assoc<1) assoc=1;
00100 }
00101 }
00102
00103 }
00104 return assoc;
00105 }
00106
00107 Int_t ClusterAtNu::IsShwAssoc(ClusterAtNu* clr) const
00108 {
00109 Double_t win = 99.9;
00110 Int_t assoc = 0;
00111 if(fEndTime-clr->GetBegTime()>-win || clr->GetEndTime()-fBegTime>-win){
00112 if( clr->GetPlane()-fPlane<5 && clr->GetPlane()-fPlane>-5
00113 && clr->GetEndStrip()-fBegStrip>-6 && fEndStrip-clr->GetBegStrip()>-6 ){
00114 if( ( clr->GetPlane()-fPlane<3 && clr->GetPlane()-fPlane>-3
00115 && clr->GetEndStrip()-fBegStrip>-1 && fEndStrip-clr->GetBegStrip()>-1 )
00116 || ( clr->GetPlane()-fPlane==0
00117 && clr->GetEndStrip()-fBegStrip>-3 && fEndStrip-clr->GetBegStrip()>-3 ) )
00118 assoc=2; else assoc=1;
00119 }
00120 }
00121 return assoc;
00122 }
00123
00124 Int_t ClusterAtNu::IsDiffuseShwAssoc(ClusterAtNu* clr) const
00125 {
00126 Double_t win = 99.9;
00127 Int_t assoc = 0;
00128 if(fEndTime-clr->GetBegTime()>-win || clr->GetEndTime()-fBegTime>-win){
00129 if( clr->GetPlane()-fPlane<9 && clr->GetPlane()-fPlane>-9
00130 && clr->GetEndStrip()-fBegStrip>-21 && fEndStrip-clr->GetBegStrip()>-21 ){
00131 if( ( clr->GetPlane()-fPlane<5 && clr->GetPlane()-fPlane>-5
00132 && clr->GetEndStrip()-fBegStrip>-11 && fEndStrip-clr->GetBegStrip()>-11 ) )
00133 assoc=2; else assoc=1;
00134 }
00135 }
00136 return assoc;
00137 }
00138
00139 Int_t ClusterAtNu::IsHitAssoc(HitAtNu* hit) const
00140 {
00141 Double_t win = 9999.9;
00142 if( hit->GetPlane()==fPlane
00143 && hit->GetStrip()>fBegStrip-2 && hit->GetStrip()<fEndStrip+2
00144 && hit->GetTime()>fBegTime-win && hit->GetTime()<fEndTime+win )
00145 return 1; else return 0;
00146 }
00147
00148 Int_t ClusterAtNu::GetPlane() const
00149 {
00150 return fPlane;
00151 }
00152
00153 Int_t ClusterAtNu::GetBegStrip() const
00154 {
00155 return fBegStrip;
00156 }
00157
00158 Int_t ClusterAtNu::GetEndStrip() const
00159 {
00160 return fEndStrip;
00161 }
00162
00163 Double_t ClusterAtNu::GetZPos()
00164 {
00165 return fZPos;
00166 }
00167
00168 Double_t ClusterAtNu::GetTPos()
00169 {
00170 return fTPos;
00171 }
00172
00173 Double_t ClusterAtNu::GetCharge()
00174 {
00175 return fCharge;
00176 }
00177
00178 Int_t ClusterAtNu::GetDigits()
00179 {
00180 Int_t i,digits=0;
00181 for(i=0;i<1+this->GetHitLast();i++){
00182 HitAtNu* hit = (HitAtNu*)(this->GetHitAt(i));
00183 digits+=hit->GetDigits();
00184 }
00185 return digits;
00186 }
00187
00188 Double_t ClusterAtNu::GetBegTime() const
00189 {
00190 return fBegTime;
00191 }
00192
00193 Double_t ClusterAtNu::GetEndTime() const
00194 {
00195 return fEndTime;
00196 }
00197
00198
00199 Int_t ClusterAtNu::GetTrkFlag() const
00200 {
00201 return fTrkFlag;
00202 }
00203
00204 Int_t ClusterAtNu::GetShwFlag() const
00205 {
00206 return fShwFlag;
00207 }
00208
00209 Int_t ClusterAtNu::GetTrkPlnFlag() const
00210 {
00211 return fTrkPlnFlag;
00212 }
00213
00214 Int_t ClusterAtNu::GetShwPlnFlag() const
00215 {
00216 return fShwPlnFlag;
00217 }
00218
00219 Int_t ClusterAtNu::GetClrPlnFlag() const
00220 {
00221 return fClrPlnFlag;
00222 }
00223
00224 void ClusterAtNu::SetTrkFlag(Int_t flag)
00225 {
00226 fTrkFlag=flag;
00227 }
00228
00229 void ClusterAtNu::SetShwFlag(Int_t flag)
00230 {
00231 fShwFlag=flag;
00232 }
00233
00234 void ClusterAtNu::SetTrkPlnFlag(Int_t flag)
00235 {
00236 fTrkPlnFlag=flag;
00237 }
00238
00239 void ClusterAtNu::SetShwPlnFlag(Int_t flag)
00240 {
00241 fShwPlnFlag=flag;
00242 }
00243
00244 void ClusterAtNu::SetClrPlnFlag(Int_t flag)
00245 {
00246 fClrPlnFlag=flag;
00247 }
00248
00249 void ClusterAtNu::AddHit(HitAtNu* hit)
00250 {
00251 if(this->AddHitToList(hit)){
00252 if(this->GetHitLast()==0){
00253 fPlane=hit->GetPlane();
00254 fBegStrip=hit->GetStrip();
00255 fEndStrip=hit->GetStrip();
00256 fBegTime=hit->GetTime();
00257 fEndTime=hit->GetTime();
00258 fZPos=hit->GetZPos();
00259 }
00260 else{
00261 if(hit->GetStrip()<fBegStrip) fBegStrip=hit->GetStrip();
00262 if(hit->GetStrip()>fEndStrip) fEndStrip=hit->GetStrip();
00263 if(hit->GetTime()<fBegTime) fBegTime=hit->GetTime();
00264 if(hit->GetTime()>fEndTime) fEndTime=hit->GetTime();
00265 }
00266 fTPos = (fTPos*fCharge+hit->GetTPos()*hit->GetCharge())/(fCharge+hit->GetCharge());
00267 fCharge += hit->GetCharge();
00268 return;
00269 }
00270 else return;
00271 }
00272