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