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

Public Member Functions | |
| AlgCalDetSI () | |
| virtual | ~AlgCalDetSI () |
| virtual void | RunAlg (AlgConfig &ac, CandHandle &ch, CandContext &cx) |
Private Member Functions | |
| void | SetDataPointers (CandContext &cx) |
| void | FillVarcErrs () |
| Bool_t | IsCosmic (const RawChannelId &) const |
Private Attributes | |
| Int_t | fRunNumber |
| RawDigitDataBlock * | fRawDDB |
| RawDeadChipBlock * | fRawDCB |
| RawOvershootBlock * | fRawOSB |
| RawTOFBlock * | fRawTOFB |
| RawSnarlHeaderBlock * | fRawSDB |
| const RawDaqSnarlHeader * | fRawDSH |
| RawVarcErrorInTfBlock * | fRawVErrB |
Static Private Attributes | |
| Int_t | fLastSnarlTick = 0 |
| Int_t | fLastSnarlSec = 0 |
| Int_t | fTimeFrame = 0 |
| RawChannelId | kCerenkovChannel1 |
| RawChannelId | kCerenkovChannel2 |
| RawChannelId | kCerenkovChannel3 |
| RawChannelId | kTriggerPMTChannel |
| RawChannelId | kTofADCChannel0 |
| RawChannelId | kTofADCChannel1 |
| RawChannelId | kTofADCChannel2 |
| RawChannelId | kTofTimeStampChannel |
| std::vector< RawChannelId > | kTriggerORs |
| UInt_t | kGoodTriggerORBits = 0 |
| const Int_t | kNTIMEBLOCKS = 40 |
| std::set< Int_t > | fVarcErrSet |
|
|
Definition at line 60 of file AlgCalDetSI.cxx. 00060 : 00061 fRunNumber(0), 00062 fRawDDB(0), 00063 fRawDCB(0), 00064 fRawOSB(0), 00065 fRawTOFB(0), 00066 fRawSDB(0), 00067 fRawDSH(0), 00068 fRawVErrB(0) 00069 00070 00071 {} //end constructor
|
|
|
Definition at line 75 of file AlgCalDetSI.cxx. 00075 {} //destructor
|
|
|
Definition at line 747 of file AlgCalDetSI.cxx. References fRawVErrB, fTimeFrame, fVarcErrSet, RawVarcErrorInTfBlock::GetNumberOfSparsErrors(), RawVarcErrorInTfBlock::GetTimeFrame(), and MSG. Referenced by SetDataPointers(). 00748 {
00749
00750 MSG("AlgCalDetSI", Msg::kDebug)<<"In FillVarcErrs"<<endl;
00751 Int_t thisTF = fRawVErrB->GetTimeFrame();
00752 if(thisTF!=fTimeFrame){ //if we've moved on to a new time frame, clear fVarcErrSet
00753 MSG("AlgCalDetSI", Msg::kDebug)<<"New time frame, clearing VErrs. Old TimeFrame="
00754 <<fTimeFrame<<" New TF="<<thisTF<<endl;
00755 fVarcErrSet.clear();
00756 fTimeFrame = thisTF; //change fTimeFrame to the current TimeFrame;
00757 }
00758
00759 const Int_t NSErrs = fRawVErrB->GetNumberOfSparsErrors();
00760 if(NSErrs>0){
00761 fVarcErrSet.insert(thisTF); //insert the timeframe into fVarcErrSet
00762 }
00763
00764 /* If the varc errors were correct, the following code would
00765 determine the time block of the error and put that into a vector,
00766 but since they are not correct, we just put the time frame into the vector
00767 (as done above)
00768 MSG("AlgCalDetSI",Msg::kInfo)<<NSErrs<<" Sparse Errors follow:"<<endl
00769 <<"********************************"<<endl;
00770 for(UInt_t i=0;i<NSErrs;i++){ //loop over elements of error array
00771 UShort_t ctb; //variable to hold the current time block
00772 UShort_t varc; //variable to hold the varc
00773 UShort_t errcode; //variable to hold the errorcode
00774 // MSG("AlgCalDetSI", Msg::kDebug)<<"Raw Error Block:"<<endl
00775 // <<"_____________________________"<<endl;
00776 // fRawVErrB->Print();
00777 // MSG("AlgCalDetSI", Msg::kDebug)<<endl<<"____________________________"<<endl;
00778 if(fRawVErrB->UnpackSparsError(i, ctb, varc, errcode)){
00779 fVarcErrSet.insert(ctb); //insert the timeblock into fVarcErrSet
00780 }
00781
00782 MSG("AlgCalDetSI",Msg::kInfo)<<"Timeframe "<<fTimeFrame<<" timeblock "<<ctb
00783 <<" varc "<<varc<<" error code "
00784 <<hex<<errcode<<dec<<endl;
00785 }//end loop over error array
00786 */
00787
00788 // MSG("AlgCalDetSI",Msg::kInfo)<<"********************************"<<endl;
00789 return;
00790 }//end FillVarcErrs
|
|
|
Definition at line 94 of file AlgCalDetSI.h. Referenced by RunAlg(). 00095 {
00096 // returns kTRUE if the channel corresponds to a cosmic counter
00097 // returns kFALSE otherwise
00098
00099 Bool_t rvalue = kFALSE;
00100 Int_t varc = id.GetVarcId();
00101 Int_t vmm = id.GetVmm();
00102 Int_t vaadc = id.GetVaAdcSel();
00103 //if we find a Cosmic Counter hit, event fails cut, return false
00104 if((varc==0||varc==1)&&vmm==5&&vaadc==0){
00105 rvalue = kTRUE;
00106 }
00107 return rvalue;
00108 }
|
|
||||||||||||||||
|
Implements AlgBase. Definition at line 79 of file AlgCalDetSI.cxx. References CandCalDetSIHandle::AddDeadChips(), CandCalDetSIHandle::AddUnderShootChips(), RawTOFBlock::At(), RawDigitDataBlock::At(), CandCalDetSIHandle::ComputeTORBits(), det, digit(), fLastSnarlSec, fLastSnarlTick, fRawDCB, fRawDDB, fRawDSH, fRawOSB, fRawSDB, fRawTOFB, fRawVErrB, fRunNumber, fVarcErrSet, RawDigit::GetADC(), RawDataBlock::GetBlockId(), CandRecord::GetCandHeader(), RawDigit::GetChannel(), CandCalDetSIHandle::GetCosmicCnt(), RawDataBlock::GetData(), CandCalDetSIHandle::GetDeadChips(), RawBlockId::GetDetector(), RawChannelId::GetElecType(), RawDigit::GetErrorCode(), CandCalDetSIHandle::GetFafErr(), MomNavigator::GetFragment(), CandCalDetSIHandle::GetIsSnarlRecord(), CandCalDetSIHandle::GetKovADC1(), CandCalDetSIHandle::GetKovADC2(), CandCalDetSIHandle::GetKovADC3(), CandCalDetSIHandle::GetKovTimeStamp1(), CandCalDetSIHandle::GetKovTimeStamp2(), CandCalDetSIHandle::GetKovTimeStamp3(), CandContext::GetMom(), RawDigitDataBlock::GetNumberOfDigits(), CandHeader::GetRun(), RawDataBlock::GetSize(), CandCalDetSIHandle::GetSnarl(), RawDaqSnarlHeader::GetSnarl(), RawSnarlHeaderBlock::GetSnarl(), CandCalDetSIHandle::GetSparseErr(), PlexHandle::GetSpecialChannelContains(), PlexHandle::GetSpecialDescriptMap(), RawDigit::GetTDC(), RawTOFDigit::GetTdcChannel(), RawTOFDigit::GetTdcValue(), CandCalDetSIHandle::GetTickSinceLast(), RawSnarlHeaderBlock::GetTimeFrameNo(), RawDaqHeader::GetTimeFrameNum(), VldContext::GetTimeStamp(), CandCalDetSIHandle::GetTofADC0(), CandCalDetSIHandle::GetTofADC1(), CandCalDetSIHandle::GetTofADC2(), CandCalDetSIHandle::GetTofTDC0(), CandCalDetSIHandle::GetTofTDC1(), CandCalDetSIHandle::GetTofTDC2(), CandCalDetSIHandle::GetTriggerORBits(), CandCalDetSIHandle::GetTriggerPMT(), RawSnarlHeaderBlock::GetTriggerSource(), CandCalDetSIHandle::GetTrigSource(), RawDaqSnarlHeader::GetTrigSrc(), RecMinos::GetVldContext(), IsCosmic(), RawChannelId::IsSameChannel(), RawChannelId::IsSameVAChip(), RawTOFDigit::IsStructureOk(), kCerenkovChannel1, kCerenkovChannel2, kCerenkovChannel3, kGoodTriggerORBits, kTofADCChannel0, kTofADCChannel1, kTofADCChannel2, kTofTimeStampChannel, kTriggerORs, kTriggerPMTChannel, MSG, CandCalDetSIHandle::SetCerenkovChannel1(), CandCalDetSIHandle::SetCerenkovChannel2(), CandCalDetSIHandle::SetCerenkovChannel3(), CandCalDetSIHandle::SetCosmicCnt(), SetDataPointers(), CandCalDetSIHandle::SetFafErr(), CandCalDetSIHandle::SetIsSnarlRecord(), CandCalDetSIHandle::SetKovADC1(), CandCalDetSIHandle::SetKovADC2(), CandCalDetSIHandle::SetKovADC3(), CandCalDetSIHandle::SetKovTimeStamp1(), CandCalDetSIHandle::SetKovTimeStamp2(), CandCalDetSIHandle::SetKovTimeStamp3(), CandCalDetSIHandle::SetSnarl(), CandCalDetSIHandle::SetSnarlMaxTimeStamp(), CandCalDetSIHandle::SetSnarlMinTimeStamp(), CandCalDetSIHandle::SetSnarlTimeFrame(), CandCalDetSIHandle::SetSparseErr(), CandCalDetSIHandle::SetTickSinceLast(), CandCalDetSIHandle::SetTofADC0(), CandCalDetSIHandle::SetTofADC1(), CandCalDetSIHandle::SetTofADC2(), CandCalDetSIHandle::SetTofADCTimeStamp0(), CandCalDetSIHandle::SetTofADCTimeStamp1(), CandCalDetSIHandle::SetTofADCTimeStamp2(), CandCalDetSIHandle::SetTofTDC0(), CandCalDetSIHandle::SetTofTDC1(), CandCalDetSIHandle::SetTofTDC2(), CandCalDetSIHandle::SetTofTimeStamp(), CandCalDetSIHandle::SetTriggerORBits(), CandCalDetSIHandle::SetTriggerOROK(), CandCalDetSIHandle::SetTriggerPMT(), and CandCalDetSIHandle::SetTrigSource(). 00080 {
00081
00082 //get the special channel RawChannelId's from the database
00083 //but first get the run number, so we only get the channel id's once per run
00084 CandRecord *cr = dynamic_cast<CandRecord *>
00085 (cx.GetMom()->GetFragment("CandRecord"));
00086 // CandRecord *cr = cx.GetCandRecord();
00087 const CandHeader *chead = cr->GetCandHeader();
00088 if(chead->GetRun()!=fRunNumber){
00089 const VldContext *vc = cr->GetVldContext();
00090 MSG("AlgCalDetSI",Msg::kDebug)<<" Validity context "<<*vc<<endl;
00091 VldTimeStamp sanity(1990,0,0,0,0,0);
00092 if(vc->GetTimeStamp()<sanity){
00093 MSG("AlgCalDetSI",Msg::kWarning)<<" Skipping silly record with "
00094 <<"silly timestamp <1990 "<<endl
00095 <<" vc is "<<*vc<<endl;
00096 return;
00097 }
00098 PlexHandle ph(*vc,kTRUE);
00099 kCerenkovChannel1=ph.GetSpecialChannelContains("DSCER");
00100 kCerenkovChannel2=ph.GetSpecialChannelContains("MIDCER");
00101 kCerenkovChannel3=ph.GetSpecialChannelContains("USCER");
00102 kTriggerPMTChannel=ph.GetSpecialChannelContains("FlashTrigPMT");
00103 kTofADCChannel0=ph.GetSpecialChannelContains("TADC0");
00104 kTofADCChannel1=ph.GetSpecialChannelContains("TTAG");
00105 if(kTofADCChannel1==0){
00106 kTofADCChannel1=ph.GetSpecialChannelContains("TADC1");
00107 }
00108 kTofADCChannel2=ph.GetSpecialChannelContains("TimingFid");
00109 if(kTofADCChannel2==0){
00110 kTofADCChannel2=ph.GetSpecialChannelContains("TADC2");
00111 }
00112 kTofTimeStampChannel=ph.GetSpecialChannelContains("TTIME");
00113
00114 // MAK: 15 Feb, 2005
00115 // multiple channels labeled TriggerOR in the DB
00116 // all refer to lemo inputs on the varcs
00117 // a good trigger should have hits on all these channels
00118 // ... we might want to check that!
00119 //
00120 const std::map<RawChannelId, std::string>& spec_chan_map
00121 = ph.GetSpecialDescriptMap();
00122 std::map<RawChannelId, std::string>::const_iterator it =
00123 spec_chan_map.begin();
00124 for( ; it!=spec_chan_map.end(); it++){
00125 const std::string& chan_description = it->second;
00126 if(chan_description.find("TriggerOR")!=std::string::npos){
00127 kTriggerORs.push_back(it->first);
00128 }
00129 }
00130 //
00131 fRunNumber = chead->GetRun();
00132 MSG("AlgCalDetSI",Msg::kDebug)<<"The special channels:"<<endl;
00133 MSG("AlgCalDetSI",Msg::kDebug)<<"tof 0 "<<kTofADCChannel0<<endl;
00134 MSG("AlgCalDetSI",Msg::kDebug)<<"tof 1 "<<kTofADCChannel1<<endl;
00135 MSG("AlgCalDetSI",Msg::kDebug)<<"tof 2 "<<kTofADCChannel2<<endl;
00136 MSG("AlgCalDetSI",Msg::kDebug)<<"cer 1 "<<kCerenkovChannel1<<endl;
00137 MSG("AlgCalDetSI",Msg::kDebug)<<"cer 2 "<<kCerenkovChannel2<<endl;
00138 MSG("AlgCalDetSI",Msg::kDebug)<<"cer 3 "<<kCerenkovChannel3<<endl;
00139 MSG("AlgCalDetSI",Msg::kDebug)<<"trig pmt "<<kTriggerPMTChannel<<endl;
00140 MSG("AlgCalDetSI",Msg::kDebug)<<"TriggerOR channels: "<<endl;
00141 kGoodTriggerORBits=0;
00142 std::vector<RawChannelId>::iterator torit = kTriggerORs.begin();
00143 for(; torit!=kTriggerORs.end(); torit++){
00144 MSG("AlgCalDetSI",Msg::kDebug)<<(*torit)<<endl;
00145 kGoodTriggerORBits|=CandCalDetSIHandle::ComputeTORBits(torit->GetCrate(), torit->GetVarcId());
00146 }
00147 MSG("AlgCalDetSI",Msg::kDebug)<<"GoodTORBits: "<<kGoodTriggerORBits<<std::endl;
00148
00149 }
00150
00151
00152 //get data and use CandCalDetSIHandle methods
00153 //to set CandCalDetSI member variables
00154
00155 if(!ch.InheritsFrom("CandCalDetSIHandle")){
00156 MSG("AlgCalDetSI",Msg::kError)<<"Bad parameter in RunAlg"<<endl;
00157 return;
00158 }
00159
00160 CandCalDetSIHandle *ccdhp = dynamic_cast<CandCalDetSIHandle *>(&ch);
00161 if(ccdhp==0){
00162 MSG("AlgCalDetSI", Msg::kError)<<"Could not make a CandCalDetSIHandle"<<endl;
00163 return;
00164 }
00165 CandCalDetSIHandle &ccdh = *ccdhp;
00166
00167
00168 MSG("AlgCalDetSI",Msg::kDebug)<<"Datapointers before setting: "<<endl
00169 <<"fRawDDB "<<fRawDDB<<endl
00170 <<"fRawDCB "<<fRawDCB<<endl
00171 <<"fRawOSB "<<fRawOSB<<endl
00172 <<"fRawTOFB "<<fRawTOFB<<endl
00173 <<"fRawSDB "<<fRawSDB<<endl
00174 <<"fRawVErrB "<<fRawVErrB<<endl
00175 <<endl;
00176
00177 SetDataPointers(cx);
00178
00179 MSG("AlgCalDetSI",Msg::kDebug)<<"Datapointers after setting: "<<endl
00180 <<"fRawDDB "<<fRawDDB<<endl
00181 <<"fRawDCB "<<fRawDCB<<endl
00182 <<"fRawOSB "<<fRawOSB<<endl
00183 <<"fRawTOFB "<<fRawTOFB<<endl
00184 <<"fRawSDB "<<fRawSDB<<endl
00185 <<"fRawVErrB "<<fRawVErrB<<endl
00186 <<endl;
00187
00188 Int_t timestamp; //timestamp of first digit in the list
00189 Int_t earliestts = 640000000; //earliest timestamp (640000000 is largest tick can be)
00190 Int_t latestts = 0; //latest timestamp
00191 Int_t timeframe = -1; //timeframe
00192
00193 ccdh.SetCerenkovChannel1(kCerenkovChannel1);
00194 ccdh.SetCerenkovChannel2(kCerenkovChannel2);
00195 ccdh.SetCerenkovChannel3(kCerenkovChannel3);
00196
00197 if(fRawDDB!=0){
00198 MSG("AlgCalDetSI",Msg::kDebug)<<"Found RawDataBlock"<<endl;
00199 //fRawDDB->Print();
00200 int size = fRawDDB->GetSize();
00201 const Int_t *ptr = fRawDDB->GetData();
00202 for (int i=0;i<size;i++) {
00203 MSG("AlgCalDetSI",Msg::kDebug)<<i<<" "<<hex<<ptr[i]<<dec<<endl;
00204 }
00205 MSG("AlgCalDetSI",Msg::kDebug)<<endl;
00206 int NDigits = fRawDDB->GetNumberOfDigits();
00207 for(int i=0;i<NDigits;i++){ //loop over digits
00208 const RawDigit *digit = fRawDDB->At(i);
00209 MSG("AlgCalDetSI",Msg::kDebug)<<"******RawDigit info ****************"<<endl;
00210 //digit->Print();
00211 MSG("AlgCalDetSI",Msg::kDebug)<<endl<<"*********************"<<endl;
00212 Int_t ts = digit->GetTDC();
00213 const RawChannelId cid = digit->GetChannel();
00214 if(i==0){//get timestamp of first digit, used later when reading errors
00215 timestamp = ts;
00216 }
00217
00218 //find max and min timestamps of detector hits
00219 Bool_t dtorhit = kTRUE;
00220 if(IsCosmic(cid)) dtorhit = kFALSE;
00221 if(cid.GetElecType()==ElecType::kVA){
00222 if(kCerenkovChannel1.GetElecType()==ElecType::kVA){
00223 if(cid.IsSameVAChip(kCerenkovChannel1)) dtorhit = kFALSE;
00224 }
00225 if(kCerenkovChannel2.GetElecType()==ElecType::kVA){
00226 if(cid.IsSameVAChip(kCerenkovChannel2)) dtorhit = kFALSE;
00227 }
00228 if(kCerenkovChannel3.GetElecType()==ElecType::kVA){
00229 if(cid.IsSameVAChip(kCerenkovChannel3)) dtorhit = kFALSE;
00230 }
00231 if(kTriggerPMTChannel.GetElecType()==ElecType::kVA){
00232 if(cid.IsSameVAChip(kTriggerPMTChannel)) dtorhit = kFALSE;
00233 }
00234 if(kTofTimeStampChannel.GetElecType()==ElecType::kVA){
00235 if(cid.IsSameVAChip(kTofTimeStampChannel)) dtorhit = kFALSE;
00236 }
00237 if(kTofADCChannel0.GetElecType()==ElecType::kVA){
00238 if(cid.IsSameVAChip(kTofADCChannel0)) dtorhit = kFALSE;
00239 }
00240 if(kTofADCChannel1.GetElecType()==ElecType::kVA){
00241 if(cid.IsSameVAChip(kTofADCChannel1)) dtorhit = kFALSE;
00242 }
00243 if(kTofADCChannel2.GetElecType()==ElecType::kVA){
00244 if(cid.IsSameVAChip(kTofADCChannel2)) dtorhit = kFALSE;
00245 }
00246 }
00247 else if(cid.GetElecType()==ElecType::kQIE){
00248 if(kCerenkovChannel1.GetElecType()==ElecType::kQIE){
00249 if(cid.IsSameChannel(kCerenkovChannel1)) dtorhit = kFALSE;
00250 }
00251 if(kCerenkovChannel2.GetElecType()==ElecType::kQIE){
00252 if(cid.IsSameChannel(kCerenkovChannel2)) dtorhit = kFALSE;
00253 }
00254 if(kCerenkovChannel3.GetElecType()==ElecType::kQIE){
00255 if(cid.IsSameChannel(kCerenkovChannel3)) dtorhit = kFALSE;
00256 }
00257 if(kTriggerPMTChannel.GetElecType()==ElecType::kQIE){
00258 if(cid.IsSameChannel(kTriggerPMTChannel)) dtorhit = kFALSE;
00259 }
00260 if(kTofTimeStampChannel.GetElecType()==ElecType::kQIE){
00261 if(cid.IsSameChannel(kTofTimeStampChannel)) dtorhit = kFALSE;
00262 }
00263 if(kTofADCChannel0.GetElecType()==ElecType::kQIE){
00264 if(cid.IsSameChannel(kTofADCChannel0)) dtorhit = kFALSE;
00265 }
00266 if(kTofADCChannel1.GetElecType()==ElecType::kQIE){
00267 if(cid.IsSameChannel(kTofADCChannel1)) dtorhit = kFALSE;
00268 }
00269 if(kTofADCChannel2.GetElecType()==ElecType::kQIE){
00270 if(cid.IsSameChannel(kTofADCChannel2)) dtorhit = kFALSE;
00271 }
00272 }
00273 if(dtorhit){
00274 if(earliestts>ts){
00275 //find tick of earliest hit
00276 earliestts =ts;
00277 ccdh.SetSnarlMinTimeStamp(ts);
00278 }
00279 if(latestts<ts){
00280 latestts = ts;
00281 ccdh.SetSnarlMaxTimeStamp(ts);
00282 }
00283 }
00284
00285 if(digit->GetErrorCode()&RawVaDigit::kWarningState){ //check for faf
00286 ccdh.SetFafErr(kTRUE);
00287 }
00288 if(cid.IsSameChannel(kCerenkovChannel1)){ //check for Kov hit
00289 ccdh.SetKovADC1(digit->GetADC());
00290 ccdh.SetKovTimeStamp1(digit->GetTDC());
00291 MSG("AlgCalDetSI",Msg::kDebug)<<"Found a Kov hit : ADC1="<<ccdh.GetKovADC1()
00292 <<" at time "<<ccdh.GetKovTimeStamp1()<<endl;
00293 }
00294 if(cid.IsSameChannel(kCerenkovChannel2)){ //check for Kov hit
00295 ccdh.SetKovADC2(digit->GetADC());
00296 ccdh.SetKovTimeStamp2(digit->GetTDC());
00297 MSG("AlgCalDetSI",Msg::kDebug)<<"Found a Kov hit : ADC2="<<ccdh.GetKovADC2()
00298 <<" at time "<<ccdh.GetKovTimeStamp2()<<endl;
00299 }
00300 if(cid.IsSameChannel(kCerenkovChannel3)){ //check for Kov hit
00301 ccdh.SetKovADC3(digit->GetADC());
00302 ccdh.SetKovTimeStamp3(digit->GetTDC());
00303 MSG("AlgCalDetSI",Msg::kDebug)<<"Found a Kov hit : ADC3="<<ccdh.GetKovADC3()
00304 <<" at time "<<ccdh.GetKovTimeStamp3()<<endl;
00305 }
00306 // TofADC added by MAK -- July 5, 2002
00307 if(cid.IsSameChannel(kTofADCChannel0)){ //check for Kov hit
00308 ccdh.SetTofADC0(digit->GetADC());
00309 ccdh.SetTofADCTimeStamp0(digit->GetTDC());
00310 MSG("AlgCalDetSI",Msg::kDebug)<<"Found a Tof ADC hit : ADC0="<<ccdh.GetTofADC0()
00311 <<endl;
00312 }
00313 if(cid.IsSameChannel(kTofADCChannel1)){ //check for Kov hit
00314 ccdh.SetTofADC1(digit->GetADC());
00315 ccdh.SetTofADCTimeStamp1(digit->GetTDC());
00316 MSG("AlgCalDetSI",Msg::kDebug)<<"Found a Tof ADC hit : ADC1="
00317 <<ccdh.GetTofADC1()
00318 <<endl;
00319 }
00320 if(cid.IsSameChannel(kTofADCChannel2)){ //check for Kov hit
00321 ccdh.SetTofADC2(digit->GetADC());
00322 ccdh.SetTofADCTimeStamp2(digit->GetTDC());
00323 MSG("AlgCalDetSI",Msg::kDebug)<<"Found a Tof ADC hit : ADC1="
00324 <<ccdh.GetTofADC2()
00325 <<endl;
00326 }
00327 if(cid.IsSameChannel(kTofTimeStampChannel)){
00328 ccdh.SetTofTimeStamp(digit->GetTDC());
00329 }
00330
00331 // modified by MAK -- July 5, 2002
00332 // if(cid==kTriggerPMTChannel){ //check for TriggerPMT hit
00333 if(cid.IsSameChannel(kTriggerPMTChannel)){ //check for TriggerPMT hit
00334 ccdh.SetTriggerPMT(kTRUE);
00335 }
00336 if(IsCosmic(cid)){ //check for Cosmic Counter hit
00337 ccdh.SetCosmicCnt(kTRUE);
00338 }
00339
00340 // check to see if this is a triggerOR channel (e.g. varc lemo)
00341 // if so, set a bit
00342 std::vector<RawChannelId>::iterator torit=kTriggerORs.begin();
00343 for(; torit!=kTriggerORs.end(); torit++){
00344 if(cid.IsSameChannel(*torit)){
00345 UShort_t crate = torit->GetCrate();
00346 UShort_t varc = torit->GetVarcId();
00347 ccdh.SetTriggerORBits(crate,varc);
00348 }
00349 }
00350 }//end loop over digits
00351 // after all digits have been looked at compare the triggerOR bits
00352 // to kGoodTORBits (e.g. the case where all bits are true)
00353 MSG("AlgCalDetSI",Msg::kDebug)<<"TriggerORBits = "
00354 <<ccdh.GetTriggerORBits()
00355 <<" (all set = "<<kGoodTriggerORBits
00356 <<" )"<<endl;
00357
00358 if(ccdh.GetTriggerORBits() == kGoodTriggerORBits){
00359 ccdh.SetTriggerOROK(kTRUE);
00360 }
00361 else{
00362 ccdh.SetTriggerOROK(kFALSE);
00363 }
00364
00365
00366 }//end if fRawDDB!=0
00367 else{//if fRawDDB==0, there is no data and something is wrong with this event
00368 ccdh.SetFafErr(kTRUE);
00369 ccdh.SetKovADC1(-999);
00370 ccdh.SetKovADC2(-999);
00371 ccdh.SetKovADC3(-999);
00372 ccdh.SetTriggerPMT(kTRUE);
00373 ccdh.SetCosmicCnt(kTRUE);
00374 ccdh.SetIsSnarlRecord(kFALSE);
00375 }
00376
00377 MSG("AlgCalDetSI",Msg::kDebug)<<endl<<"Faf err "<<(int)ccdh.GetFafErr()<<endl
00378 <<"KovADC "<<ccdh.GetKovADC1()<<endl
00379 <<"Kov Time Stamp "<<ccdh.GetKovTimeStamp1()<<endl
00380 <<"KovADC "<<ccdh.GetKovADC2()<<endl
00381 <<"Kov Time Stamp "<<ccdh.GetKovTimeStamp2()<<endl
00382 <<"KovADC "<<ccdh.GetKovADC3()<<endl
00383 <<"Kov Time Stamp "<<ccdh.GetKovTimeStamp3()<<endl
00384 <<"Trigger PMT "<<(int)ccdh.GetTriggerPMT()<<endl
00385 <<"Cosmic Cnt "<<(int)ccdh.GetCosmicCnt()<<endl;
00386
00387
00388 if(fRawDCB!=0){
00389 MSG("AlgCalDetSI",Msg::kDebug)<<"Found DeadChipBlock"<<endl;
00390 //Stolen code from RawDataBlock::Print
00391 Detector::Detector_t det = fRawDCB->GetBlockId().GetDetector();
00392 // assume this block is only sensible for VA electronics
00393 ElecType::Elec_t elec = ElecType::kVA;
00394 Int_t crate = -1;
00395 const Int_t* realdata = fRawDCB->GetData();
00396 // const Int_t* ptr = (int*)realdata+3; //zzzz_last in roberts code
00397 const Int_t* ptr = realdata+3; //zzzz_last in roberts code
00398 //need to clear deadchip vector before filling for next event
00399 //ccdh.ClearDeadChips();
00400 // while (ptr < (int *)realdata+(fRawDCB->GetSize())) {
00401 while (ptr < realdata+(fRawDCB->GetSize())) {
00402 // start of new crate
00403 crate++;
00404 int ndead = *ptr; ptr++;
00405 for (int i=0; i<ndead; i++,ptr++) {
00406 /*
00407 Int_t chad = *ptr; ptr++;
00408
00409 RawChannelId rcid(det,elec,crate,chad);
00410 ccdh.AddDeadChips(rcid); //add rawchannelid to deadchip vector
00411 */
00412 ccdh.AddDeadChips(RawChannelId(det,elec,crate,*ptr));
00413 }//end for
00414 }//end while
00415 //End Stolen Code
00416 }//end if
00417
00418 MSG("AlgCalDetSI",Msg::kDebug)<<"DCvector: "<<ccdh.GetDeadChips().size()<<endl;
00419 /*Prints out dead chips, for debugging
00420 for(UShort_t i=0;i<ccdh.GetDeadChips().size();i++){
00421 int varc = ccdh.GetDeadChips()[i].GetVarcId();
00422 int vmm = ccdh.GetDeadChips()[i].GetVmm();
00423 int vaadc = ccdh.GetDeadChips()[i].GetVaAdcSel();
00424 int chip = ccdh.GetDeadChips()[i].GetVaChip();
00425 int channel = ccdh.GetDeadChips()[i].GetVaChannel();
00426
00427 MSG("AlgCalDetSI", Msg::kDebug)<<"Dead chips: "<<varc<<","<<vmm<<","<<vaadc
00428 <<","<<chip<<","<<channel<<endl;
00429 }
00430 */
00431
00432 if(fRawOSB!=0){
00433 MSG("AlgCalDetSI",Msg::kDebug)<<"Found UnderShootBlock"<<endl;
00434 //More Stolen Code (from RawOvershootBlock::Print
00435 Detector::Detector_t det = fRawOSB->GetBlockId().GetDetector();
00436 // assume this block is only sensible for VA electronics
00437 ElecType::Elec_t elec = ElecType::kVA;
00438 Int_t crate = -1;
00439 const Int_t* ptr = fRawOSB->GetData()+3;
00440 //need to clear the overshoot map before filling again
00441 // ccdh.ClearUnderShoots();
00442 while (ptr < fRawOSB->GetData()+(fRawOSB->GetSize())) {
00443 // start of new crate
00444 crate++;
00445 int ndead = *ptr; ptr++;
00446 for (int i=0; i<ndead; i++,ptr++) {
00447 /*
00448 Int_t tmp = *ptr; ptr++;
00449 Int_t chad = tmp & 0x1fff;
00450 Int_t ticks = tmp>>13;
00451 RawChannelId rcid(det,elec,crate,chad);
00452 ccdh.AddUnderShootChips(rcid, ticks); //add undershoot channels to map
00453 */
00454 ccdh.AddUnderShootChips(RawChannelId(det,elec,crate,(*ptr)&0x1fff),
00455 (*ptr)>>13);
00456
00457 }//end for
00458 }//end while
00459 //End of stolen code
00460 }//end if
00461
00462 /*Prints out the UnderShoot chips, for debugging
00463 map<RawChannelId, Int_t>::const_iterator it
00464 = (ccdh.GetUnderShootChips()).begin();
00465 while(it!=(ccdh.GetUnderShootChips()).end()){
00466 int varc = (it->first).GetVarcId();
00467 int vmm = (it->first).GetVmm();
00468 int vaadc = (it->first).GetVaAdcSel();
00469 int chip = (it->first).GetVaChip();
00470 int channel = (it->first).GetVaChannel();
00471
00472 MSG("AlgCalDetSI", Msg::kDebug)<<"UnderShoots: "<<varc<<","<<vmm<<","<<vaadc
00473 <<","<<chip<<","<<channel<<","
00474 <<it->second<<endl;
00475 it++;
00476 }
00477 */
00478
00479 /* Removing this block of code until the TOF blocks are fixed
00480 if(fRawTOFB!=0){
00481 MSG("AlgCalDetSI",Msg::kDebug)<<"Found TOFBlock"<<endl;
00482 Int_t NDigits = fRawTOFB->GetNumberOfDigits();
00483 MSG("AlgCalDetSI",Msg::kError)<<"Number of TOF digits "<<NDigits<<endl;
00484 MSG("AlgCalDetSI", Msg::kError)<<"__________________________"<<endl
00485 <<*fRawTOFB<<endl
00486 <<"__________________________"<<endl;
00487 for(int i=0;i<NDigits;i++){ //loop over tof digits
00488 MSG("AlgCalDetSI", Msg::kDebug)<<"In tof digit loop "<<i<<endl;
00489 const RawTOFDigit *tofdigit = fRawTOFB->At(i);
00490 MSG("AlgCalDetSI", Msg::kDebug)<<"Got RawTOF Digit "<<tofdigit<<endl;
00491 //If tof info is not valid, continue
00492 if(!tofdigit->IsTdcValid(i)||
00493 tofdigit->IsTdcUnderThreshold(i)||tofdigit->IsTdcOverflow(i)){
00494 MSG("AlgCalDetSI", Msg::kError)<<*tofdigit<<endl;
00495 MSG("AlgCalDetSI", Msg::kError)<<"Tof not valid"<<endl;
00496 continue;
00497 }
00498 if(!tofdigit->IsStructureOk()){
00499 MSG("AlgCalDetSI", Msg::kError)<<"Bad TOF structure"<<endl;
00500 continue;
00501 }
00502 Short_t chan = tofdigit->GetTdcChannel(i);
00503 MSG("AlgCalDetSI",Msg::kDebug)<<"Tof channel "<<chan<<endl;
00504 switch (chan){
00505 case 0:
00506 ccdh.SetTofTDC0(tofdigit->GetTdcValue(i));
00507 break;
00508 case 1:
00509 ccdh.SetTofTDC1(tofdigit->GetTdcValue(i));
00510 break;
00511 case 2:
00512 ccdh.SetTofTDC2(tofdigit->GetTdcValue(i));
00513 break;
00514 default:
00515 break;
00516 }//end switch
00517 }//end for
00518 }//end if
00519
00520 MSG("AlgCalDetSI",Msg::kDebug)<<"TDC0 "<<ccdh.GetTofTDC0()
00521 <<" TDC1 "<<ccdh.GetTofTDC1()
00522 <<" TDC2 "<<ccdh.GetTofTDC2()<<endl;
00523
00524 */
00525 //Assuming just one digit in the TOF block, and that the data is valid
00526 if(fRawTOFB!=0){
00527 MSG("AlgCalDetSI",Msg::kDebug)<<"Found TOFBlock"<<endl;
00528 // Int_t NDigits = fRawTOFB->GetNumberOfDigits();
00529 MSG("AlgCalDetSI", Msg::kDebug)<<"__________________________"<<endl
00530 <<*fRawTOFB<<endl
00531 <<"__________________________"<<endl;
00532 const RawTOFDigit *tofdigit = fRawTOFB->At(0);
00533 MSG("AlgCalDetSI", Msg::kDebug)<<"Got RawTOF Digit "<<tofdigit<<endl;
00534 if(tofdigit!=0){
00535 if(!tofdigit->IsStructureOk()){
00536 MSG("AlgCalDetSI", Msg::kError)<<"Bad TOF structure"<<endl;
00537 }
00538 for(int i=0;i<3;i++){//loop over three tof channels
00539 Short_t chan = tofdigit->GetTdcChannel(i);
00540 MSG("AlgCalDetSI",Msg::kDebug)<<"Tof channel "<<chan<<endl;
00541 switch (chan){
00542 case 0:
00543 ccdh.SetTofTDC0(tofdigit->GetTdcValue(i));
00544 break;
00545 case 1:
00546 ccdh.SetTofTDC1(tofdigit->GetTdcValue(i));
00547 break;
00548 case 2:
00549 ccdh.SetTofTDC2(tofdigit->GetTdcValue(i));
00550 break;
00551 default:
00552 break;
00553 }//end switch
00554 }//end for
00555 }//end if(tofdigit!=0)
00556 }//end if(fRawTOFB!=0)
00557
00558 MSG("AlgCalDetSI",Msg::kDebug)<<"TDC0 "<<ccdh.GetTofTDC0()
00559 <<" TDC1 "<<ccdh.GetTofTDC1()
00560 <<" TDC2 "<<ccdh.GetTofTDC2()<<endl;
00561
00562
00563 if(fRawSDB!=0){
00564 MSG("AlgCalDetSI",Msg::kDebug)<<"Found SnarlHeaderBlock"<<endl;
00565 ccdh.SetTrigSource(fRawSDB->GetTriggerSource());
00566 ccdh.SetSnarl(fRawSDB->GetSnarl());
00567 timeframe = fRawSDB->GetTimeFrameNo();
00568 ccdh.SetSnarlTimeFrame(timeframe);
00569 }
00570 else if(fRawDSH!=0){ // MAK: 12 April, 2005: added as no snarlheaderblocks in mc for whatever reason... note, doesn't change behavior if there is one
00571 MSG("AlgCalDetSI",Msg::kDebug)<<"Found DaqSnarlHeader"<<endl;
00572 ccdh.SetTrigSource(fRawDSH->GetTrigSrc());
00573 ccdh.SetSnarl(fRawDSH->GetSnarl());
00574 timeframe = fRawDSH->GetTimeFrameNum();
00575 ccdh.SetSnarlTimeFrame(timeframe);
00576 }
00577
00578 MSG("AlgCalDetSI",Msg::kDebug)<<"Trigger Source "<<ccdh.GetTrigSource()
00579 <<" Snarl "<<ccdh.GetSnarl()<<endl;
00580
00581
00582 MSG("AlgCalDetSI", Msg::kDebug)<<"Timing: "<<endl
00583 <<"last snarl sec "<<fLastSnarlSec<<" last snarl ticks "
00584 <<fLastSnarlTick<<endl
00585 <<"this snarl sec "<<timeframe<<" this snarl tick "
00586 <<earliestts<<" end tick "<<latestts<<endl;
00587
00588 // Could we do this only for snarls ?
00589 //NOTE hardwired conversion from seconds to ticks
00590 ccdh.SetTickSinceLast((timeframe-fLastSnarlSec)*640000000+(earliestts-fLastSnarlTick));
00591 //640000000 ticks in a second
00592
00593
00594 if(ccdh.GetIsSnarlRecord()){ //if this was a snarl record,
00595 //change the LastSnarl timing varibles to this record
00596 fLastSnarlSec = timeframe;
00597 fLastSnarlTick = latestts;
00598 } //do nothing if it was not a snarl record
00599
00600 MSG("AlgCalDetSI",Msg::kDebug)<<"Ticks Since Last Snarl "<<ccdh.GetTickSinceLast()<<endl;
00601
00602
00603 //Check for SparseErrs, special case since there can be two
00604 //error blocks (one from each crate) per timeframe
00605 MSG("AlgCalDetSI",Msg::kDebug)<<"Checking fVarcErrSet"<<endl;
00606 ccdh.SetSparseErr(kFALSE);
00607
00608 Int_t tb = timeframe/kNTIMEBLOCKS;
00609
00610 if(fVarcErrSet.find(tb)!=fVarcErrSet.end()){//if tb is in fVarcErrSet
00611 ccdh.SetSparseErr(kTRUE); //then there is a SparseErr
00612 }
00613 MSG("AlgCalDetSI",Msg::kDebug)<<"Sparse Errors "<<(int)ccdh.GetSparseErr()<<endl;
00614
00615 /*
00616 since there is a problem with the varc error blocks, we can not just
00617 throw away a time block with an error, we must throw the entire time frame
00618 awaw!
00619 if there are any varc sparse errors in the time frame, the whole time
00620 frame is suspect
00621
00622 if(fVarcErrSet.find(timeframe)!=fVarcErrSet.end()){
00623 MSG("AlgCalDetSI",Msg::kDebug)<<"Number of sparse errors in this timeframe: "
00624 <<fVarcErrSet.size()
00625 <<" timeframe "<<timeframe<<endl;
00626
00627 ccdh.SetSparseErr(kTRUE);
00628 }
00629 */
00630
00631 return;
00632 }//end RunAlg
|
|
|
Definition at line 636 of file AlgCalDetSI.cxx. References FillVarcErrs(), fRawDCB, fRawDDB, fRawDSH, fRawOSB, fRawSDB, fRawTOFB, fRawVErrB, RawDataBlock::GetBlockId(), CandContext::GetDataIn(), RawBlockId::GetMajor(), RawRecord::GetRawHeader(), kMdBlockCrateReadout, kMdBlockSnarlHeader, kMdBlockTofReadout, kMdBlockVaDeadChips, kMdBlockVaOvershoot, kMdBlockVarcErrorInTf, and MSG. Referenced by RunAlg(). 00637 {
00638
00639 //We are assuming that cx contains a raw record
00640
00641 //zero pointers from previous event.
00642 fRawDDB = 0;
00643 fRawDCB = 0;
00644 fRawOSB = 0;
00645 fRawTOFB = 0;
00646 fRawSDB = 0;
00647 fRawVErrB = 0;
00648 fRawDSH = 0;
00649 const RawRecord *rr = dynamic_cast<const RawRecord *>(cx.GetDataIn());
00650 if(rr==0){
00651 return; //if cast fails, do nothing for the time being at least
00652 }
00653
00654 fRawDSH = dynamic_cast<const RawDaqSnarlHeader*>(rr->GetRawHeader());
00655
00656 MSG("AlgCalDetSI",Msg::kDebug)<<"Found a RawRecord in SetDataPointers"<<endl;
00657
00658 //Get a RawBlockIterator
00659 TIter rbi = const_cast<RawRecord*>(rr)->GetRawBlockIter();
00660
00661 //Iterate over RawBlocks
00662 while(TObject* obj = rbi.Next()){
00663 MSG("AlgCalDetSI",Msg::kDebug)<<"Iterating over RawBlocks"<<endl;
00664 //cast iterator object to a RawDataBlock
00665 RawDataBlock* rdb=static_cast<RawDataBlock *>(obj);
00666 if(rdb==0){ //if cast fails
00667 continue;
00668 }
00669
00670 //Get the RawBlockID
00671 /*
00672 RawBlockId bid=rdb->GetBlockId();
00673 int maj=bid.GetMajor();
00674 */
00675
00676 // June 20, 2003 -- Robert points out that the tests like fRawSDB==0
00677 // will never be true because we require rdb!=0 and then look at the block
00678 // id and then static cast to the correct block type.
00679 // I will comment out the offending code.
00680
00681 Int_t maj = rdb->GetBlockId().GetMajor();
00682 //Compare block ID to the various cases and set the appropriate pointer
00683 switch (maj){
00684 case kMdBlockSnarlHeader:
00685 fRawSDB = static_cast<RawSnarlHeaderBlock *> (rdb);
00686 // MSG("AlgCalDetSI",Msg::kDebug)<<"fRawSDB="<<fRawSDB<<endl;
00687 // if(fRawSDB==0){
00688 // MSG("AlgCalDetSI", Msg::kError)<<"Could not cast to"
00689 // <<"RawSnarlHeaderBlock"<<endl;
00690 // }
00691 break;
00692 case kMdBlockVarcErrorInTf: //not as simple as setting pointers
00693 //since the errors from the 2 crates are
00694 //written in separate blocks
00695 {
00696 fRawVErrB = static_cast<RawVarcErrorInTfBlock *> (rdb);
00697 // MSG("AlgCalDetSI",Msg::kDebug)<<"fRawVErrB="<<fRawVErrB<<endl;
00698 // if(fRawVErrB==0){
00699 // MSG("AlgCalDetSI", Msg::kError)<<"Could not cast to"
00700 // <<"RawVarcErrorInTfBlock"<<endl;
00701 // }
00702 FillVarcErrs();
00703 break;
00704 }
00705 case kMdBlockCrateReadout:
00706 fRawDDB = static_cast<RawDigitDataBlock *> (rdb);
00707 // MSG("AlgCalDetSI",Msg::kDebug)<<"fRawDDB="<<fRawDDB<<endl;
00708 // if(fRawSDB==0){
00709 // MSG("AlgCalDetSI", Msg::kError)<<"Could not cast to"
00710 // <<"RawDigitDataBlock"<<endl;
00711 // }
00712 break;
00713 case kMdBlockVaDeadChips:
00714 fRawDCB = static_cast<RawDeadChipBlock *> (rdb);
00715 // MSG("AlgCalDetSI",Msg::kDebug)<<"fRawDCB="<<fRawDCB<<endl;
00716 // if(fRawSDB==0){
00717 // MSG("AlgCalDetSI", Msg::kError)<<"Could not cast to"
00718 // <<"RawDeadChipBlock"<<endl;
00719 // }
00720 break;
00721 case kMdBlockVaOvershoot:
00722 fRawOSB = static_cast<RawOvershootBlock *> (rdb);
00723 MSG("AlgCalDetSI",Msg::kDebug)<<"fRawOSB="<<fRawOSB<<endl;
00724 // if(fRawSDB==0){
00725 // MSG("AlgCalDetSI", Msg::kError)<<"Could not cast to"
00726 // <<"RawOvershootBlock"<<endl;
00727 // }
00728 break;
00729 case kMdBlockTofReadout:
00730 fRawTOFB = static_cast<RawTOFBlock *> (rdb);
00731 // MSG("AlgCalDetSI",Msg::kDebug)<<"fRawTOFB="<<fRawTOFB<<","<<*fRawTOFB<<endl;
00732 // if(fRawSDB==0){
00733 // MSG("AlgCalDetSI", Msg::kError)<<"Could not cast to"
00734 // <<"RawTOFBlock"<<endl;
00735 // }
00736 break;
00737 default:
00738 MSG("AlgCalDetSI",Msg::kDebug)<<"ID did not match any options: "<<maj<<endl;
00739 break;
00740 }//end switch
00741 }//End loop over RawDataBlocks
00742 return;
00743 }//end SetDataPointers
|
|
|
Definition at line 42 of file AlgCalDetSI.cxx. Referenced by RunAlg(). |
|
|
Definition at line 41 of file AlgCalDetSI.cxx. Referenced by RunAlg(). |
|
|
Definition at line 66 of file AlgCalDetSI.h. Referenced by RunAlg(), and SetDataPointers(). |
|
|
Definition at line 65 of file AlgCalDetSI.h. Referenced by RunAlg(), and SetDataPointers(). |
|
|
Definition at line 70 of file AlgCalDetSI.h. Referenced by RunAlg(), and SetDataPointers(). |
|
|
Definition at line 67 of file AlgCalDetSI.h. Referenced by RunAlg(), and SetDataPointers(). |
|
|
Definition at line 69 of file AlgCalDetSI.h. Referenced by RunAlg(), and SetDataPointers(). |
|
|
Definition at line 68 of file AlgCalDetSI.h. Referenced by RunAlg(), and SetDataPointers(). |
|
|
Definition at line 71 of file AlgCalDetSI.h. Referenced by FillVarcErrs(), RunAlg(), and SetDataPointers(). |
|
|
Definition at line 61 of file AlgCalDetSI.h. Referenced by RunAlg(). |
|
|
Definition at line 43 of file AlgCalDetSI.cxx. Referenced by FillVarcErrs(). |
|
|
Definition at line 44 of file AlgCalDetSI.cxx. Referenced by FillVarcErrs(), and RunAlg(). |
|
|
Definition at line 48 of file AlgCalDetSI.cxx. Referenced by RunAlg(). |
|
|
Definition at line 49 of file AlgCalDetSI.cxx. Referenced by RunAlg(). |
|
|
Definition at line 50 of file AlgCalDetSI.cxx. Referenced by RunAlg(). |
|
|
Definition at line 57 of file AlgCalDetSI.cxx. Referenced by RunAlg(). |
|
|
Definition at line 58 of file AlgCalDetSI.cxx. |
|
|
Definition at line 52 of file AlgCalDetSI.cxx. Referenced by RunAlg(). |
|
|
Definition at line 53 of file AlgCalDetSI.cxx. Referenced by RunAlg(). |
|
|
Definition at line 54 of file AlgCalDetSI.cxx. Referenced by RunAlg(). |
|
|
Definition at line 55 of file AlgCalDetSI.cxx. Referenced by RunAlg(). |
|
|
Definition at line 56 of file AlgCalDetSI.cxx. Referenced by RunAlg(). |
|
|
Definition at line 51 of file AlgCalDetSI.cxx. Referenced by RunAlg(). |
1.3.9.1