#include <AlgChopListSharp.h>
Inheritance diagram for AlgChopListSharp:

Public Member Functions | |
| AlgChopListSharp () | |
| virtual | ~AlgChopListSharp () |
| virtual void | RunAlg (AlgConfig &ac, CandHandle &ch, CandContext &cx) |
| virtual void | Trace (const char *c) const |
Private Member Functions | |
| bool | ShouldSplit (float this_ph, float next_ph, float d_tmax) |
Definition at line 13 of file AlgChopListSharp.h.
| AlgChopListSharp::AlgChopListSharp | ( | ) |
| AlgChopListSharp::~AlgChopListSharp | ( | ) | [virtual] |
| void AlgChopListSharp::RunAlg | ( | AlgConfig & | ac, | |
| CandHandle & | ch, | |||
| CandContext & | cx | |||
| ) | [virtual] |
Implements AlgBase.
Definition at line 84 of file AlgChopListSharp.cxx.
References digits(), done(), Form(), AlgFactory::GetAlgHandle(), CandContext::GetCandRecord(), CandContext::GetDataIn(), AlgFactory::GetInstance(), CandContext::GetMom(), Calibrator::GetTDCFromTime(), RecMinos::GetVldContext(), Calibrator::Instance(), Msg::kDebug, Msg::kError, Detector::kNear, CalTimeType::kNone, kQieRcid, CalDigitType::kSigCorr, Msg::kWarning, PlexPlaneId::LastPlaneNearCalor(), CandDigitList::MakeCandidate(), MSG, CandHandle::SetName(), and ShouldSplit().
00087 { 00091 00092 assert(candHandle.InheritsFrom("CandChopListHandle")); 00093 CandChopListHandle &chopList = dynamic_cast<CandChopListHandle &>(candHandle); 00094 00095 assert(candContext.GetDataIn()); 00096 // Check for CandDigitListHandle input 00097 if (!(candContext.GetDataIn()->InheritsFrom("CandDigitListHandle"))) { 00098 MSG("Chop",Msg::kWarning ) << "Data into AlgChopListSharp is not a digit list." << std::endl; 00099 } 00100 00101 const CandDigitListHandle *cdlh_ptr = 00102 dynamic_cast<const CandDigitListHandle*>(candContext.GetDataIn()); 00103 00104 const MomNavigator *mom = candContext.GetMom(); 00105 const RawDigitDataBlock* rddb = DataUtil::GetRawBlock<RawDigitDataBlock>(mom); 00106 if (!rddb) { 00107 MSG("Chop", Msg::kWarning) << "No RawDigitDataBlock in RawRecord." << endl; 00108 return; 00109 } 00110 00111 // Get setup for the DigitList maker algorithm 00112 AlgFactory &af = AlgFactory::GetInstance(); 00113 AlgHandle ah = af.GetAlgHandle("AlgChop","default"); 00114 CandContext cxx(this,candContext.GetMom()); 00115 00116 const VldContext &context = *(candContext.GetCandRecord()->GetVldContext()); 00117 if(context.GetDetector() != Detector::kNear) 00118 MSG("Chop",Msg::kError) << "Running the Sharp algorithm on FD data is a no-no!" << endl; 00119 00120 Calibrator& cal = Calibrator::Instance(); 00121 UgliGeomHandle ugli(context); 00122 00123 // Now do the actual slicing. 00124 00125 // First, make a nice stl vector of the digits. 00126 DigitVector digits(cdlh_ptr); 00127 00128 UInt_t ndigits = digits.size(); 00129 UInt_t nchop = 0; 00130 00131 // Sort the list by time. 00132 // Not neccessary for this algorithm. 00133 // std::sort(digits.begin(), digits.end(), compareDigitTimes()); 00134 00135 00136 // Also, I want some other pieces of info: 00137 std::vector<int> digit_tdc(ndigits); 00138 std::vector<UInt_t> digit_plane(ndigits); 00139 //std::vector<float> digit_tpos(ndigits); 00140 for(UInt_t i=0;i<ndigits;i++) { 00141 digit_tdc[i] = (cal.GetTDCFromTime(digits[i].GetTime(CalTimeType::kNone), kQieRcid)); 00142 digit_plane[i] = digits[i].GetPlexSEIdAltL().GetPlane(); 00143 //if(digit_plane[i]<=PlexPlaneId::LastPlaneNearCalor()) 00144 // digit_tpos[i] = ugli.GetStripHandle(digits[i].GetPlexSEIdAltL().GetBestSEId()).GetTPos(); 00145 //else 00146 // digit_tpos[i] = -999; 00147 } 00148 00149 // Find first and last times. Add some padding so sertain operations are easier to code. 00150 Int_t tfirst = digit_tdc[0]; 00151 Int_t tlast = digit_tdc[0]; 00152 for(UInt_t i=0;i<ndigits;i++) { 00153 if(digit_tdc[i] < tfirst) tfirst = digit_tdc[i]; 00154 if(digit_tdc[i] > tlast ) tlast = digit_tdc[i]; 00155 } 00156 tfirst-=5; 00157 tlast +=5; 00158 00159 00160 // Make the energy histogram. 00161 MSG("Chop",Msg::kDebug) << "Running Chop_Sharp" << endl; 00162 00163 UInt_t numBins = tlast-tfirst; 00164 00165 // Create the energy-time profile. 00166 std::vector<float> energyVsTime(numBins,0.); 00167 00168 for(UInt_t idig = 0; idig < ndigits; idig++ ) { 00169 float sigcor = digits[idig].GetCharge(CalDigitType::kSigCorr); 00170 int tdcbin = digit_tdc[idig]-tfirst; 00171 if((tdcbin<0) || ((int)numBins<=tdcbin)) MSG("Chop",Msg::kDebug) << "Whups!" << endl; 00172 else if(digit_plane[idig]<=PlexPlaneId::LastPlaneNearCalor()) { 00173 energyVsTime[digit_tdc[idig]-tfirst] += sigcor; 00174 } 00175 } 00176 00177 // Used bins: 00178 std::vector<char> binsUsed(numBins,0); 00179 00180 do { 00181 // Look for biggest peak. 00182 UInt_t biggest_bin = 99999; 00183 float biggest_size = 0; 00184 for(UInt_t i=0;i<numBins;i++) { 00185 if(binsUsed[i]==0) 00186 if(energyVsTime[i]>biggest_size) { 00187 biggest_size = energyVsTime[i]; 00188 biggest_bin = i; 00189 } 00190 } 00191 00192 if(biggest_bin==99999) break; // We've gone through all of them. 00193 if(biggest_size<100.) break; // We've hit 1 pe, rock bottom. 00194 00195 // Collect the start and stop time for this chop. 00196 // Start 1 bin before the peak, and at least 1 bin after the peak. 00197 UInt_t bin_start = biggest_bin; 00198 UInt_t bin_stop = biggest_bin; 00199 00200 //for(Int_t i=-3;i<5;i++) { 00201 // MSG("Chop",Msg::kDebug) << i << "\t" << energyVsTime[biggest_bin+i] << endl; 00202 // } 00203 00204 if(binsUsed[bin_start-1]==0) bin_start--; 00205 if(binsUsed[bin_stop +1]==0) bin_stop++; 00206 00207 bool done = false; 00208 while(!done) { 00209 // Stop at start of spill. 00210 if(bin_start==0) { 00211 //MSG("Chop",Msg::kDebug) << "Hit start of spill" << endl; 00212 done=true; 00213 } 00214 00215 if(ShouldSplit(energyVsTime[bin_start], 00216 energyVsTime[bin_start-1], 00217 bin_start-1 - biggest_bin ) ) { 00218 //MSG("Chop",Msg::kDebug) << "Didn't move back. dE = " << energyVsTime[bin_start-1] << "-" << energyVsTime[bin_start] << " maxdE = " << max << endl; 00219 done = true; 00220 } 00221 00222 // Stop if we've hit another chop. 00223 if(binsUsed[bin_start-1]) { 00224 //MSG("Chop",Msg::kDebug) << "Hit another chop." << endl; 00225 done = true; 00226 } 00227 00228 if(!done) { 00229 //MSG("Chop",Msg::kDebug) << "Moving start back 1 notch. dE = " << climb << " maxdE = " << max << endl; 00230 bin_start--; 00231 } 00232 }; 00233 00234 // Expand forwards until the energy starts climbing. 00235 // But, allow small pulses in for the first 5 buckets. 00236 done = false; 00237 while(!done) { 00238 // Stop at end of spill 00239 if(bin_stop >= numBins-1) { 00240 //MSG("Chop",Msg::kDebug) << "Hit end of spill" << endl; 00241 done = true; 00242 } 00243 00244 // Allow 5 buckets worth of small stuff: 00245 if((energyVsTime[bin_stop+1] < 500.) && (bin_stop+1 < biggest_bin+7)) { 00246 // keep going 00247 } else { 00248 if(ShouldSplit(energyVsTime[bin_stop], 00249 energyVsTime[bin_stop+1], 00250 bin_stop+1 - biggest_bin) ) { 00251 //MSG("Chop",Msg::kDebug) << "Didn't move forward. dE = " << energyVsTime[bin_stop+1] << "-" << energyVsTime[bin_stop] << " maxdE = " << max << endl; 00252 done = true; 00253 } 00254 } 00255 00256 // Stop if we hit another chop. 00257 if(binsUsed[bin_stop+1]) { 00258 //MSG("Chop",Msg::kDebug) << "Didn't move forward; hit another chop." << endl; 00259 done = true; 00260 } 00261 00262 // If we're ok, increment and continue. 00263 if(!done) bin_stop++; 00264 } 00265 00266 int tdc_start = bin_start+tfirst; 00267 int tdc_stop = bin_stop+tfirst; 00268 00269 // We have a chop candidate. Create it. 00270 DigitVector slc; 00271 00272 for(UInt_t idig = 0; idig < ndigits; idig++ ) { 00273 int tdc = digit_tdc[idig]; 00274 if((tdc>=(int)tdc_start)&&(tdc<=(int)tdc_stop)) 00275 slc.push_back(digits[idig]); 00276 } 00277 cxx.SetDataIn(&(slc)); 00278 CandDigitListHandle chopHandle = CandDigitList::MakeCandidate(ah,cxx); 00279 chopHandle.SetName(Form("Chop %d",nchop++)); 00280 chopList.AddDaughterLink(chopHandle); 00281 00282 MSG("Chop",Msg::kDebug) << "Creating chop. Big: " << biggest_bin 00283 << " Start: " << bin_start << " Stop: " << bin_stop 00284 << " Digits: " << slc.size() 00285 << endl; 00286 00287 00288 00289 // Zero out these buckets so they won't be caught again. 00290 for(UInt_t i=bin_start; i<=bin_stop; i++) { 00291 binsUsed[i] = 1; 00292 } 00293 00294 } while(true); 00295 00296 }
| bool AlgChopListSharp::ShouldSplit | ( | float | this_ph, | |
| float | next_ph, | |||
| float | d_tmax | |||
| ) | [private] |
Definition at line 60 of file AlgChopListSharp.cxx.
References k1pe.
Referenced by RunAlg().
00064 { 00065 float climb = next_ph - this_ph; 00066 00067 // the maximum delta that the algorithm will climb before making a new chop 00068 float max_climb = 2.5*sqrt(fabs(this_ph)/k1pe)*k1pe; 00069 if(max_climb < (6 * k1pe)) max_climb=max_climb*2; 00070 00071 // the maximum pulse height in this bin if we're making a new chop. 00072 //const float size_limit = 20 * k1pe; 00073 //const float min_time = 2; 00074 00075 //if(d_tmax < min_time) return false; 00076 //if(this_ph < size_limit) return false; 00077 00078 if( climb >= max_climb ) return true; 00079 else return false; 00080 }
| void AlgChopListSharp::Trace | ( | const char * | c | ) | const [virtual] |
1.4.7