00001
00002
00003
00004
00005
00006
00007
00008
00009
00011
00012 #include "VtxCluster.h"
00013
00014 CVSID("$Id: VtxCluster.cxx,v 1.3 2006/12/01 20:30:53 rhatcher Exp $");
00015
00016
00017
00018
00019
00020 VtxCluster::VtxCluster()
00021 {
00022 fEdgeTrigger = 0;
00023 fNCTrigger = 0;
00024 fplanes.clear();
00025 fenergy.clear();
00026 }
00027
00028 VtxCluster::VtxCluster(Int_t plane, Float_t energy_in_pe)
00029 {
00030 fEdgeTrigger = 0;
00031 fNCTrigger = 0;
00032 fplanes.clear();
00033 fenergy.clear();
00034 AddPlane(plane, energy_in_pe);
00035 }
00036
00037 VtxCluster::VtxCluster(const VtxCluster& input)
00038 {
00039 fEdgeTrigger = input.fEdgeTrigger;
00040 fNCTrigger = input.fNCTrigger;
00041 fplanes.clear();
00042 fenergy.clear();
00043
00044 Int_t tempPlane;
00045 Float_t tempE;
00046
00047 for(int i = 0; i < input.Size(); i++)
00048 {
00049 tempPlane = input.GetPlane(i);
00050 tempE = input.GetEnergy(i);
00051
00052 AddPlane(tempPlane,tempE);
00053 }
00054
00055 }
00056
00057
00058
00059 VtxCluster::~VtxCluster()
00060 {
00061
00062 fplanes.clear();
00063 fenergy.clear();
00064 }
00065
00066 Float_t VtxCluster::GetEnergy(Int_t i) const
00067 {
00068 if(i < 0 || i >= Size()){ cerr<<"Array out of bounds"<<endl; return 1;}
00069 return fenergy[i];
00070 }
00071
00072 Int_t VtxCluster::GetPlane(Int_t i) const
00073 {
00074 if(i < 0 || i >= Size()){ cerr<<"Array out of bounds"<<endl; return 1;}
00075 return fplanes[i];
00076 }
00077
00078 Float_t VtxCluster::GetTotalEnergy() const
00079 {
00080 Float_t total = 0;
00081 for(Int_t i = 0; i < Size(); i++) total += fenergy[i];
00082
00083 return total;
00084 }
00085
00086 Int_t VtxCluster::GetFirstPlane() const
00087 {
00088 if(Size() == 0) return -1;
00089 return fplanes[0];
00090 }
00091
00092 Int_t VtxCluster::GetLastPlane() const
00093 {
00094 if(Size() == 0) return -1;
00095 return fplanes[Size()-1];
00096 }
00097
00098 void VtxCluster::AddPlane(Int_t plane, Float_t pes)
00099 {
00100 fplanes.push_back(plane);
00101 fenergy.push_back(pes);
00102 }
00103
00104 Int_t VtxCluster::Size() const
00105 {
00106 if(fplanes.size() != fenergy.size())
00107 cerr<<"Size: list length mismatch "<<fplanes.size()<<" "<<fenergy.size()<<endl;
00108 return fplanes.size();
00109 }
00110
00111 bool VtxCluster::HasRisingEdge()
00112 {
00113
00114
00115
00116 if(Size() < 2) return false;
00117
00118 bool done = false;
00119 bool rising = false;
00120 Int_t candidate = -1;
00121 Float_t subTotal = 0;
00122 Float_t runningTotal = 0;
00123 bool rescind = false;
00124
00125 Float_t energyCutOne = 4.0;
00126
00127
00128
00129 for(Int_t i = 0; i < Size()-1 && !done; i++)
00130 {
00131 rising = false;
00132 rescind = false;
00133 if(fenergy[i] > energyCutOne)
00134 {
00135 runningTotal += fenergy[i];
00136
00137 if(runningTotal > GetTotalEnergy()/3){
00138 MSG("VtxCluster",Msg::kDebug)<<"(HRE): More than 1/3 of energy "
00139 <<"passed, stopping"<<endl;
00140 i = Size();
00141 continue;
00142 }
00143
00144 if(fenergy[i+1] > TMath::Max(fenergy[i]*1.05, fenergy[i] + 2.0)
00145 && fplanes[i+1] == fplanes[i]+1){
00146
00147 rising = true;
00148
00149 if(i < Size()-3)
00150 if(fenergy[i]+fenergy[i+1]+fenergy[i+2] < 0.5*runningTotal)
00151 {
00152 rescind = true;
00153 }
00154
00155 if(Size() >= 12 && i > static_cast<Float_t>(Size())/2.2
00156 && runningTotal > GetTotalEnergy()/3){
00157 done = false;
00158 i = Size();
00159 continue;
00160 }
00161
00162 if(!rescind){
00163 if(candidate != -1){
00164 Float_t oldTotal = 0;
00165 for(Int_t j = candidate; j < TMath::Min(candidate+4, Size()-1); j++)
00166 oldTotal += fenergy[j];
00167 Float_t newTotal = 0;
00168 for(Int_t j = i; j < TMath::Min(i+4, Size()-1); j++)
00169 newTotal += fenergy[j];
00170 if(newTotal > oldTotal) candidate = i;
00171 }else
00172 candidate = i;
00173
00174 if(Size()-i > 4){
00175 subTotal = 0;
00176 for(Int_t j = i; j < i+4; j++) subTotal += fenergy[j];
00177 if(subTotal/4 > 1.5*GetTotalEnergy()/Size()){
00178
00179
00180 done = true;
00181 fEdgeTrigger = candidate = i;
00182 }
00183 }
00184 }
00185 }
00186 Int_t temp = i;
00187 if((rising))
00188 while(i < Size()-1 && fplanes[i+1] == fplanes[i]+1 && fenergy[i] > 10)
00189 { i++; runningTotal += fenergy[i]; }
00190 i = TMath::Max(temp, i--);
00191 if( i != temp) runningTotal -= fenergy[TMath::Min(i++, Size()-1)];
00192 }
00193 }
00194
00195 if(candidate != -1 && done == false) {
00196 fEdgeTrigger = candidate;
00197 done = true;
00198 }
00199
00200 fNCTrigger = DetermineNCTrigger();
00201
00202 return done;
00203 }
00204
00205 Int_t VtxCluster::DetermineNCTrigger()
00206 {
00207 Int_t i = 0;
00208 while(i < Size() && fenergy[i] < 5) i++;
00209 fNCTrigger = TMath::Min(i, Size()-1);
00210
00211 for(Int_t j = TMath::Max(i,1) ; j < Size() -1; j++){
00212 if(fplanes[j]-fplanes[j-1] != 1 && fenergy[j] > 4*fenergy[fNCTrigger])
00213 fNCTrigger = j;
00214 }
00215
00216 return fNCTrigger;
00217 }
00218
00219
00220