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

Public Member Functions | |
| BeamTOF (const char *version) | |
| ~BeamTOF () | |
| JobCResult | Reco () |
| JobCResult | Ana (const EDMEventHandle &evt) |
| void | Update (const CfgConfig &c) |
Private Attributes | |
| int | fDebug |
| int | fNEvent |
| TH1F * | beamtof |
| CMapTOF * | cmaptof |
| std::vector< const TOFDigit * > | tofdigits |
| std::vector< const TOFDigit * > | t0digits |
Definition at line 15 of file BeamTOF.h.
| BeamTOF::BeamTOF | ( | const char * | version | ) |
Definition at line 29 of file BeamTOF.cxx.
References beamtof, cmaptof, fDebug, CMapTOF::Instance(), name, and JobCModule::SetCfgVersion().
00029 : 00030 JobCModule("BeamTOF") 00031 { 00032 // Do this first to load default configuration 00033 this->SetCfgVersion(version); 00034 00035 if (fDebug) { 00036 std::cout <<"Debug value is: " << fDebug << std::endl; 00037 } 00038 00039 // Initialize the histograms 00040 char name[80], title[256]; 00041 sprintf(title, "Time of Flight for Beam Tracks"); 00042 sprintf(name, "beamtof"); 00043 // Histos here 00044 beamtof = new TH1F(name, title, 100, 0, 30); //20 50 00045 00046 // Init the connection map 00047 cmaptof = &CMapTOF::Instance(); 00048 }
| BeamTOF::~BeamTOF | ( | ) |
| JobCResult BeamTOF::Ana | ( | const EDMEventHandle & | evt | ) | [virtual] |
Reimplemented from JobCModule.
Definition at line 61 of file BeamTOF.cxx.
References TOFDigit::ADC(), beamtof, EDMTriggerId::BeamTrig(), CENTERCHAN, TOFDigit::Channel(), EDMEventHeader::Event(), fDebug, fNEvent, EDMDataBucket::Get(), EDMEventHandle::Header(), JobCModule::kFailed, JobCModule::kPassed, EDMEventHandle::Raw(), TOFBarHit::SetChannel(), TOFBarHit::SetLowerADC(), TOFBarHit::SetLowerTime(), TOFBarHit::SetUpperADC(), TOFBarHit::SetUpperTime(), t0digits, TOFDigit::TDC(), tofdigits, and EDMEventHeader::TriggerId().
00062 { 00063 // Just to make sure... 00064 fNEvent=evt.Header().Event(); 00065 if(!evt.Header().TriggerId().BeamTrig()) { 00066 if(fDebug) std::cout << "Not a beam trigger" << std::endl; 00067 return JobCModule::kFailed; 00068 } 00069 00070 // Clear the list and fill it 00071 tofdigits.clear(); 00072 t0digits.clear(); 00073 00074 // Some useful information 00075 std::cout << "***********************************" << std::endl; 00076 std::cout << "Starting event " << fNEvent <<std::endl; 00077 // Read in tof digits 00078 try { 00079 evt.Raw().Get("./tof", tofdigits); 00080 } catch(EDMException e) { 00081 std::cerr << "Failed to get TOF Digits for event " 00082 << fNEvent << std::endl; 00083 return JobCModule::kFailed; 00084 } 00085 if(fDebug) { 00086 std::cout << "read in tof digits " << tofdigits.size() << std::endl; 00087 } 00088 00089 // Read in t0 digits 00090 try { 00091 evt.Raw().Get("./t0", t0digits); 00092 } catch(EDMException e) { 00093 std::cerr << "Failed to get t0 digits for event " 00094 << fNEvent << std::endl; 00095 return JobCModule::kFailed; 00096 } 00097 if(fDebug) { 00098 std::cout << "read in t0 digits " << t0digits.size() << std::endl; 00099 } 00100 00101 // I'm assuming all four pmts fire. 00102 // T00 = 500*, T01 = 501*, TBD = 503* 00103 double t0sum = 0; 00104 for(unsigned int j=0; j<t0digits.size(); j++) { 00105 if(t0digits[j]->Channel() < 5015 && t0digits[j]->Channel() > 5010) { 00106 switch(t0digits[j]->Channel()) { 00107 case 5011: //5011: 300 150 5031: 700 300 00108 if(t0digits[j]->ADC() > 300 || t0digits[j]->ADC() < 150) 00109 return JobCModule::kFailed; 00110 break; 00111 case 5012: //5012: 275 125 5032: 600 250 00112 if(t0digits[j]->ADC() > 275 || t0digits[j]->ADC() < 125) 00113 return JobCModule::kFailed; 00114 break; 00115 case 5013: //5013: 350 180 5033: 800 300 00116 if(t0digits[j]->ADC() > 350 || t0digits[j]->ADC() < 180) 00117 return JobCModule::kFailed; 00118 break; 00119 case 5014: //5014: 360 150 5034: 800 300 00120 if(t0digits[j]->ADC() > 360 || t0digits[j]->ADC() < 150) 00121 return JobCModule::kFailed; 00122 break; 00123 default: 00124 break; 00125 } 00126 t0sum+=t0digits[j]->TDC(); 00127 std::cout << "t0 fired " << j-4 << " times" << std::endl; 00128 } 00129 } 00130 00131 // Divide sum by 4 00132 double t0time = t0sum/4; 00133 00134 // Convert to ns using that damned connection map 00135 t0time = t0time / (1000/30); //T01: 30 TBD: 60 00136 //cmaptof->TDCBinSize(); 00137 //if(fDebug) 00138 std::cout << "T0 time: " << t0time << std::endl; 00139 // Put the tofdigits in a map so they can be indexed by channel 00140 std::map<int, const TOFDigit*> tofmap; 00141 for(unsigned int j=0; j<tofdigits.size(); j++) { 00142 tofmap[tofdigits[j]->Channel()] = tofdigits[j]; 00143 } 00144 00145 for(unsigned int upper=0;upper<tofdigits.size();upper++) { 00146 // Check to see if the upper PMT has a hit 00147 // Skip over lower hits and add those in 00148 // When doing upper hits, also do calibration bars. 00149 if(tofdigits[upper]->Channel() != 2501 00150 && tofdigits[upper]->Channel() != 2502) 00151 if(tofdigits[upper]->Channel()>1000) continue; 00152 00153 // Use the loop to make sure we account for all the hits in the wall 00154 // Setup upper and lower pmt pointers. 00155 int upperchan=tofdigits[upper]->Channel(); 00156 int lowerchan=upperchan+1000; 00157 00158 if(fDebug>1) std::cout << "Upper TDC: " 00159 << tofdigits[upper]->TDC() << std::endl; 00160 00161 const TOFDigit* upperpmt=tofmap[upperchan]; 00162 const TOFDigit* lowerpmt=tofmap[lowerchan]; 00163 00164 if(fDebug>1) std::cout << "Upper channel: " << upperchan 00165 << " Lower channel: " << lowerchan << std::endl; 00166 00167 // See if Upper or Lower Tube was hit: 00168 // If both upper and lower have no hit--continue to next bar 00169 if (upperpmt->TDC() > 2047 && lowerpmt->TDC() > 2047) continue; 00170 if(upperpmt->TDC() == 0 && lowerpmt->TDC() == 0) { 00171 if(fDebug) std::cout << "Both TDCs == 0!" << std::endl; 00172 break; 00173 } 00174 00175 // Create a bar hit and use that 00176 TOFBarHit bar; 00177 bar.SetChannel(upperchan); 00178 // Don't care about ADC's so this'll be commented 00179 // until it happens that we do 00180 bar.SetUpperADC(upperpmt->ADC()); 00181 bar.SetLowerADC(lowerpmt->ADC()); 00182 00183 // Check for TDC overflow 00184 if(upperpmt->TDC() > 2047) { // overflow 00185 bar.SetUpperTime(-10000.); 00186 } else { 00187 // Assertively do nothing. 00188 } 00189 00190 if(lowerpmt->TDC() > 2047) { // overflow 00191 bar.SetLowerTime(-10000.); 00192 } // else { also do nothing } 00193 00194 // Could probably use bar to hold times... but since I don't care about 00195 // cleanliness in this module, I won't! ;) 00196 00197 if(lowerpmt->TDC() > 2047 or upperpmt->TDC() > 2047) { 00198 if(fDebug) std::cout << "TDC value too large!" << std::endl; 00199 return JobCModule::kFailed; 00200 } else { 00201 // A few useful numbers 00202 //double diff = upperpmt->TDC() - lowerpmt->TDC(); 00203 double sum = lowerpmt->TDC() + upperpmt->TDC(); 00204 double toftime = sum/2 / (1000/50); // tof time in ns 00205 std::cout << "tof time: " << toftime << std::endl; 00206 double tof = 0; 00207 00208 // Do things for the center channel 00209 std::cout << upperpmt->Channel() << std::endl; 00210 if(upperpmt->Channel() == CENTERCHAN) { 00211 if(CENTERCHAN == 320) { 00212 if(upperpmt->ADC() > 600 || upperpmt->ADC() < 400) { 00213 std::cout << "failing on upper: " << upperpmt->ADC() << std::endl; 00214 return JobCModule::kFailed; 00215 } 00216 if(lowerpmt->ADC() > 120 || lowerpmt->ADC() < 85) { 00217 std::cout << "failing on lower: " << lowerpmt->ADC() << std::endl; 00218 return JobCModule::kFailed; 00219 } 00220 } 00221 else if(CENTERCHAN == 326) { 00222 // 310 230 00223 if(upperpmt->ADC() > 380 || upperpmt->ADC() < 180) { 00224 std::cout << "failing on upper: " << upperpmt->ADC() << std::endl; 00225 return JobCModule::kFailed; 00226 } 00227 if(lowerpmt->ADC() > 145 || lowerpmt->ADC() < 90) { 00228 std::cout << "failing on lower: " << lowerpmt->ADC() << std::endl; 00229 return JobCModule::kFailed; 00230 } 00231 } 00232 tof = toftime - t0time; 00233 //if(fDebug) 00234 std::cout << "Time of flight: " << tof << std::endl; 00235 beamtof->Fill(tof); 00236 } 00237 } 00238 } 00239 00240 return JobCModule::kPassed; 00241 }
| JobCResult BeamTOF::Reco | ( | ) |
Definition at line 245 of file BeamTOF.cxx.
References JobCModule::kPassed.
00245 { 00246 return JobCModule::kPassed; 00247 }
| void BeamTOF::Update | ( | const CfgConfig & | c | ) | [virtual] |
Implements CfgObserver.
Definition at line 252 of file BeamTOF.cxx.
References fDebug.
00253 { 00254 c("Debug").Get(fDebug); 00255 }
TH1F* BeamTOF::beamtof [private] |
CMapTOF* BeamTOF::cmaptof [private] |
int BeamTOF::fDebug [private] |
int BeamTOF::fNEvent [private] |
std::vector<const TOFDigit*> BeamTOF::t0digits [private] |
std::vector<const TOFDigit*> BeamTOF::tofdigits [private] |
1.4.7