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

Public Member Functions | |
| FarPlaneCheckout () | |
| JobCResult | Ana (const MomNavigator *mom) |
| void | EndJob () |
| void | HandleCommand (JobCommand *cmd) |
Private Attributes | |
| TFile * | fFile |
| Int_t | fRunType |
| map< RawChannelId, TH1F * > | frawid2th1adc |
| map< Int_t, TH1F * > | fstrip2th1adc |
| map< RawChannelId, TProfile * > | frawid2tprofCIraw |
| map< RawChannelId, TProfile * > | frawid2tprofCI |
| TObjArray * | fth1adcarray |
| TObjArray * | ftprofCIarray |
| int | CIbegframe [50][128] |
| int | CIendframe [50][128] |
| TH1F * | fth1record |
|
|
Definition at line 37 of file FarPlaneCheckout.cxx. References CIbegframe, CIendframe, fFile, and fRunType. 00038 {
00039 fFile = 0;
00040 fRunType = -1;
00041
00042 for (int icrate=0; icrate<50; icrate++) {
00043 for (int icharge=0; icharge<128; icharge++) {
00044 CIbegframe[icrate][icharge] = -1;
00045 CIendframe[icrate][icharge] = -1;
00046 }
00047 }
00048 }
|
|
|
Implement this for read only access to the MomNavigator Reimplemented from JobCModule. Definition at line 51 of file FarPlaneCheckout.cxx. References CIbegframe, CIendframe, fFile, RawRecord::FindRawBlock(), frawid2th1adc, frawid2tprofCIraw, fRunType, fstrip2th1adc, fth1adcarray, fth1record, ftprofCIarray, RawDigit::GetADC(), RawDataBlock::GetBlockId(), RawDigit::GetChannel(), RawChargeInjectInfoBlock::GetCharge(), RawChannelId::GetCrate(), RawChargeInjectInfoBlock::GetCrateId(), PlexSEIdAltL::GetCurrentSEId(), RawDigitDataBlock::GetDatumIter(), RawBlockId::GetDetector(), MomNavigator::GetFragment(), RawBlockId::GetMajor(), RawBlockId::GetMinor(), RawVarcErrorInTfBlock::GetNumberOfEtcErrors(), RawVarcErrorInTfBlock::GetNumberOfSparsErrors(), RawChargeInjectInfoBlock::GetNumberOfValues(), PlexPlaneId::GetPlane(), RawRecord::GetRawBlockIter(), RawRecord::GetRawBlockList(), RawRecord::GetRawHeader(), PlexHandle::GetReadoutType(), RawDaqHeader::GetRun(), RawDaqHeader::GetRunType(), PlexHandle::GetSEIdAltL(), RawDaqSnarlHeader::GetSnarl(), PlexStripEndId::GetStrip(), RawDigit::GetTDC(), RawDaqHeaderBlock::GetTimeFrameNo(), RawSnarlHeaderBlock::GetTimeFrameNo(), RawChargeInjectInfoBlock::GetTrigFrameEnd(), RawChargeInjectInfoBlock::GetTrigFrameStart(), RawDaqSnarlHeader::GetTrigSrc(), RawChannelId::GetVaAdcSel(), RawChannelId::GetVaChannel(), RawChannelId::GetVaChip(), RawChannelId::GetVarcId(), RecMinosHdr::GetVldContext(), RawChannelId::GetVmm(), RawBlockId::IsDCS(), PlexStripEndId::IsOppositeStripEnd(), PlexSEIdAltL::IsValid(), MSG, PlexSEIdAltL::Next(), RawDataBlock::Print(), and PlexSEIdAltL::SetFirst(). 00051 {
00052
00053
00054
00055 RawRecord *rawrec = dynamic_cast<RawRecord *>
00056 (mom->GetFragment("RawRecord"));
00057 if (!rawrec) {
00058 MSG("FarPlaneCheckout", Msg::kWarning) << "No RawRecord in MOM." << endl;
00059 return JobCResult::kFailed;
00060 }
00061
00062
00063 const RawDaqHeader* rhead =
00064 dynamic_cast<const RawDaqHeader*>(rawrec->GetRawHeader());
00065
00066 if (!rhead) {
00067 MSG("FarPlaneCheckout", Msg::kWarning) << "No RawDaqHeader in MOM." << endl;
00068 return JobCResult::kFailed;
00069 }
00070
00071 if (!fFile) {
00072 char filename[80];
00073 sprintf(filename,"planecheckout.%08d.root",rhead->GetRun());
00074 fFile = new TFile(filename,"RECREATE");
00075
00076 fth1record = new TH1F("record","record",10000,0.,10000.);
00077
00078 fFile->mkdir("ADC_bin1");
00079 fFile->mkdir("ADC_coincidence");
00080 TDirectory *dirCI = fFile->mkdir("CI");
00081 dirCI->mkdir("raw");
00082 fFile->cd();
00083 fth1adcarray = new TObjArray();
00084 ftprofCIarray = new TObjArray();
00085 }
00086
00087
00088 const TObjArray blocklist(rawrec->GetRawBlockList());
00089 for (int iblock=0; iblock<=blocklist.GetLast(); iblock++) {
00090 RawDataBlock *rawdatablock = dynamic_cast<RawDataBlock*>(blocklist.At(iblock));
00091 if (rawdatablock->GetBlockId().GetMajor()==kMdBlockChargeInjectInfo) {
00092 const RawChargeInjectInfoBlock *CIBlock =
00093 dynamic_cast<const RawChargeInjectInfoBlock*>(rawdatablock);
00094 if (CIBlock->GetCrateId()>=0 && CIBlock->GetCrateId()<50) {
00095 for (int icharge=0; icharge<CIBlock->GetNumberOfValues(); icharge++) {
00096 if (CIBlock->GetCharge(icharge)>=0 && CIBlock->GetCharge(icharge)<128) {
00097 CIbegframe[CIBlock->GetCrateId()][CIBlock->GetCharge(icharge)] = CIBlock->GetTrigFrameStart(icharge);
00098 CIendframe[CIBlock->GetCrateId()][CIBlock->GetCharge(icharge)] = CIBlock->GetTrigFrameEnd(icharge);
00099 }
00100 }
00101 }
00102 cout << "blockid " << CIBlock->GetBlockId().GetMajor() << " " << CIBlock->GetBlockId().GetMinor() << " " << CIBlock->GetBlockId().IsDCS() << " " << CIBlock->GetBlockId().GetDetector() << "\n";
00103 for (int icharge=0; icharge<CIBlock->GetNumberOfValues() && CIBlock->GetCharge(icharge)>=0; icharge++) {
00104 cout << "charge " << icharge << "/" << CIBlock->GetNumberOfValues() << " " << CIBlock->GetCrateId() << " " << CIBlock->GetTrigFrameStart(icharge) << " " << CIBlock->GetTrigFrameEnd(icharge) << " " << CIBlock->GetCharge(icharge) << "\n";
00105 }
00106
00107 }
00108 }
00109
00110
00111 int timeframeno=-1;
00112 const RawSnarlHeaderBlock* rawsnarlHdrBlock =
00113 dynamic_cast<const RawSnarlHeaderBlock*>
00114 (rawrec->FindRawBlock("RawSnarlHeaderBlock"));
00115 if (rawsnarlHdrBlock) {
00116 timeframeno = rawsnarlHdrBlock->GetTimeFrameNo();
00117 }
00118 const RawDaqSnarlHeader* snarlHdr =
00119 dynamic_cast<const RawDaqSnarlHeader*>(rawrec->GetRawHeader());
00120 if (snarlHdr) {
00121 fth1record->Fill((float)snarlHdr->GetSnarl());
00122 //nt_record = snarlHdr->GetSnarl();
00123 //nt_error = snarlHdr->GetErrorCode();
00124 }
00125 const RawDaqHeaderBlock* rawdaqHdrBlock =
00126 dynamic_cast<const RawDaqHeaderBlock*>
00127 (rawrec->FindRawBlock("RawDaqHeaderBlock"));
00128 if (rawdaqHdrBlock) {
00129 // nt_time = rawdaqHdrBlock->GetTimeStamp().GetSec();
00130 // nt_time = rawdaqHdrBlock->GetTimeFrameNo();
00131 timeframeno = rawdaqHdrBlock->GetTimeFrameNo();
00132 }
00133 const RawVarcErrorInTfBlock* rawVarcErrorBlock =
00134 dynamic_cast<const RawVarcErrorInTfBlock*>
00135 (rawrec->FindRawBlock("RawVarcErrorInTfBlock"));
00136 if (rawVarcErrorBlock) {
00137 //const Int_t *sparserr = rawVarcErrorBlock->GetSparsErrorValues();
00138 //const Int_t *etcerr = rawVarcErrorBlock->GetEtcErrorValues();
00139 //nt_varcerr_crate = rawVarcErrorBlock->GetCrateId();
00140 //nt_varcerr_tf = rawVarcErrorBlock->GetTimeFrame();
00141 //nt_varcerr_nspars = rawVarcErrorBlock->GetNumberOfSparsErrors();
00142 //nt_varcerr_netc = rawVarcErrorBlock->GetNumberOfEtcErrors();
00143 for (int i=0; i<rawVarcErrorBlock->GetNumberOfSparsErrors(); i++) {
00144 //nt_varcerr_word = sparserr[i];
00145 //fVarcErrorNt->Fill();
00146 }
00147 for (int i=0; i<rawVarcErrorBlock->GetNumberOfEtcErrors(); i++) {
00148 //nt_varcerr_word = etcerr[i];
00149 //fVarcErrorNt->Fill();
00150 }
00151 }
00152 RawRecord *rr = dynamic_cast<RawRecord *>
00153 (mom->GetFragment("RawRecord"));
00154 if (rr == 0) {
00155 MSG("FarPlaneCheckout", Msg::kWarning) << "No RawRecord in MOM." << endl;
00156 return JobCResult::kFailed;
00157 }
00158
00159
00160 PlexHandle *plexhandle = new PlexHandle(rhead->GetVldContext());
00161
00162
00163 fRunType = rhead->GetRunType();
00164
00165 if (snarlHdr) {
00166
00167 // pedestal and normal data
00168 if (rhead->GetRunType()==1 || rhead->GetRunType()==2) {
00169
00170 TIter rdbit = rr->GetRawBlockIter();
00171 TObject *tob;
00172 while ((tob = rdbit())) {
00173 if (tob->InheritsFrom("RawDigitDataBlock")) {
00174 RawDigitDataBlock *rdb = (RawDigitDataBlock *) tob;
00175 TIter rdit = rdb->GetDatumIter();
00176 RawDigit *rd;
00177 rd = (RawDigit *)rdit();
00178 while (rd) {
00179 if (rd) {
00180 RawChannelId rawch = rd->GetChannel();
00181 if (TH1F *th1adc = frawid2th1adc[rawch]) {
00182 th1adc->Fill((Float_t)rd->GetADC());
00183 }
00184 else {
00185 char histtitle[256];
00186 sprintf(histtitle,"ADC %02d %01d %01d %01d %01d %02d",rawch.GetCrate(),rawch.GetVarcId(),rawch.GetVmm(),rawch.GetVaAdcSel(),rawch.GetVaChip(),rawch.GetVaChannel());
00187 fFile->cd("/ADC_bin1");
00188 frawid2th1adc[rawch] = new TH1F(histtitle,histtitle,2000,-500.,1500.);
00189 fth1adcarray->Add(frawid2th1adc[rawch]);
00190 frawid2th1adc[rawch]->Fill((Float_t)rd->GetADC());
00191 }
00192 }
00193 rd = (RawDigit *)rdit();
00194 }
00195 }
00196 }
00197 }
00198
00199
00200 // normal data, null trigger
00201 if (rhead->GetRunType()==2 && (snarlHdr->GetTrigSrc())&(0x1)) {
00202
00203
00204 TIter rdbit = rr->GetRawBlockIter();
00205 TObject *tob;
00206 while ((tob = rdbit())) {
00207 if (tob->InheritsFrom("RawDigitDataBlock")) {
00208 RawDigitDataBlock *rdb = (RawDigitDataBlock *) tob;
00209 TIter rdit0 = rdb->GetDatumIter();
00210 TIter rdit1 = rdb->GetDatumIter();
00211 RawDigit *rd0;
00212 RawDigit *rd1;
00213 rd1 = (RawDigit *)rdit1();
00214 RawChannelId rawid1 = rd1->GetChannel();
00215 while (rd1 && rawid1.GetCrate()==0) {
00216 rd1 = (RawDigit *)rdit1();
00217 if (rd1) {
00218 rawid1 = rd1->GetChannel();
00219 }
00220 }
00221 rd0 = (RawDigit *)rdit0();
00222 RawChannelId rawid0 = rd0->GetChannel();
00223 TObjArray sortedlist;
00224 while (rd0 || rd1) {
00225 if (rd0 && !rd1) {
00226 sortedlist.Add(rd0);
00227 rd0 = (RawDigit *)rdit0();
00228 RawChannelId rawid0 = rd0->GetChannel();
00229 if (rawid0.GetCrate()==1) rd0=0;
00230 }
00231 else if (rd1 && !rd0) {
00232 sortedlist.Add(rd1);
00233 rd1 = (RawDigit *)rdit1();
00234 }
00235 else if (rd0 && rd1) {
00236 if (rd0->GetTDC()<rd1->GetTDC()) {
00237 sortedlist.Add(rd0);
00238 rd0 = (RawDigit *)rdit0();
00239 RawChannelId rawid0 = rd0->GetChannel();
00240 if (rawid0.GetCrate()==1) rd0=0;
00241 } else {
00242 sortedlist.Add(rd1);
00243 rd1 = (RawDigit *)rdit1();
00244 }
00245 }
00246 }
00247 RawDigit *rd;
00248 TObjArray timewindow;
00249 for (int isort=0; isort<=sortedlist.GetLast(); isort++) {
00250 rd = (RawDigit *)(sortedlist.At(isort));
00251 RawChannelId rawid = rd->GetChannel();
00252 if (plexhandle->GetReadoutType(rawid) == ReadoutType::kScintStrip) {
00253 PlexSEIdAltL altlist = plexhandle->GetSEIdAltL(rawid);
00254 for (int isort1=isort-1; isort1>=0; isort1--) {
00255 RawDigit *rd1 = (RawDigit *)(sortedlist.At(isort1));
00256 RawChannelId rawid1 = rd1->GetChannel();
00257 if (rd->GetTDC()-rd1->GetTDC()>100) {
00258 isort1 = -1;
00259 } else if (plexhandle->GetReadoutType(rawid1) == ReadoutType::kScintStrip){
00260 PlexSEIdAltL altlist1 = plexhandle->GetSEIdAltL(rawid1);
00261 altlist.SetFirst();
00262 while (altlist.IsValid()) {
00263 PlexStripEndId stripend = altlist.GetCurrentSEId();
00264 altlist1.SetFirst();
00265 while (altlist1.IsValid()) {
00266 PlexStripEndId stripend1 = altlist1.GetCurrentSEId();
00267 if (stripend.IsOppositeStripEnd(stripend1)) {
00268 Int_t stripindex = stripend.GetPlane()*192+stripend.GetStrip();
00269 if (TH1F *th1strip = fstrip2th1adc[stripindex]) {
00270 th1strip->Fill((Float_t)(rd->GetADC()+rd1->GetADC()));
00271 }
00272 else {
00273 char histtitle[256];
00274 sprintf(histtitle,"ADC Plane %03d Strip %03d",stripend.GetPlane(),stripend.GetStrip());
00275 fFile->cd("/ADC_coincidence");
00276 fstrip2th1adc[stripindex] = new TH1F(histtitle,histtitle,3000,0.,3000.);
00277 fstrip2th1adc[stripindex]->Fill((Float_t)(rd->GetADC()+rd1->GetADC()));
00278 }
00279 }
00280 altlist1.Next();
00281 }
00282 altlist.Next();
00283 }
00284 }
00285 }
00286 }
00287 }
00288 }
00289 }
00290
00291 }
00292
00293
00294 // charge injection
00295 if (rhead->GetRunType()==3) {
00296
00297 // this needs to be fixed once charge inject info blocks can be read in
00298 //unused: int chargein = (int)((snarlHdr->GetSnarl()-3)/2)*10;
00299
00300 TIter rdbit = rr->GetRawBlockIter();
00301 TObject *tob;
00302 while ((tob = rdbit())) {
00303 if (tob->InheritsFrom("RawDigitDataBlock")) {
00304 RawDigitDataBlock *rdb = (RawDigitDataBlock *) tob;
00305 TIter rdit = rdb->GetDatumIter();
00306 RawDigit *rd;
00307 rd = (RawDigit *)rdit();
00308 while (rd) {
00309 if (rd) {
00310 RawChannelId rawch = rd->GetChannel();
00311 if (TProfile *tprofCI = frawid2tprofCIraw[rawch]) {
00312 // tprofCI->Fill((Float_t)chargein,(Float_t)rd->GetADC());
00313 tprofCI->Fill((Float_t)timeframeno,(Float_t)rd->GetADC());
00314 }
00315 else {
00316 char histtitle[256];
00317 sprintf(histtitle,"%02d %01d %01d %01d %01d %02d",rawch.GetCrate(),rawch.GetVarcId(),rawch.GetVmm(),rawch.GetVaAdcSel(),rawch.GetVaChip(),rawch.GetVaChannel());
00318 fFile->cd("/CI/raw");
00319 // assume charge injection doesn't go for more than one hour
00320 frawid2tprofCIraw[rawch] = new TProfile(histtitle,histtitle,3600,0.,3600.);
00321 ftprofCIarray->Add(frawid2tprofCIraw[rawch]);
00322 // frawid2tprofCIraw[rawch]->Fill((Float_t)chargein,(Float_t)rd->GetADC());
00323 frawid2tprofCIraw[rawch]->Fill((Float_t)timeframeno,(Float_t)rd->GetADC());
00324 }
00325 }
00326 rd = (RawDigit *)rdit();
00327 }
00328 }
00329 }
00330
00331 }
00332
00333 // normal data, light injection trigger
00334 if (rhead->GetRunType()==2 && (snarlHdr->GetTrigSrc())&(0x2)) {
00335
00336
00337 TIter rdbit = rr->GetRawBlockIter();
00338 TObject *tob;
00339 while ((tob = rdbit())) {
00340 if (tob->InheritsFrom("RawDigitDataBlock")) {
00341 RawDigitDataBlock *rdb = (RawDigitDataBlock *) tob;
00342 TIter rdit = rdb->GetDatumIter();
00343 RawDigit *rd;
00344 rd = (RawDigit *)rdit();
00345 while (rd) {
00346 RawChannelId rawid = rd->GetChannel();
00347 rd = (RawDigit *)rdit();
00348 }
00349 }
00350 }
00351 }
00352
00353
00354 }
00355
00356
00357 const RawLIAdcSummaryBlock *rawLIadcblock =
00358 dynamic_cast<const RawLIAdcSummaryBlock*>
00359 (rawrec->FindRawBlock("RawLIAdcSummaryBlock"));
00360
00361 const RawLITimingSummaryBlock *rawLItimingblock =
00362 dynamic_cast<const RawLITimingSummaryBlock*>
00363 (rawrec->FindRawBlock("RawLITimingSummaryBlock"));
00364
00365 if (rawLIadcblock) {
00366 rawLIadcblock->Print();
00367 }
00368
00369 if (rawLItimingblock) {
00370 rawLItimingblock->Print();
00371 }
00372
00373 delete plexhandle;
00374
00375 return JobCResult::kPassed;
00376
00377 }
|
|
|
Implement for notification of end of job Reimplemented from JobCModule. Definition at line 396 of file FarPlaneCheckout.cxx. References CIbegframe, CIendframe, fFile, fRunType, fth1adcarray, and ftprofCIarray. 00397 {
00398 //======================================================================
00399 // At the end of the job print some stuff out and save the histogram
00400 // to a file
00401 //======================================================================
00402
00403 // fit gaussian if pedestal run
00404
00405 if (fRunType==1 && fth1adcarray) {
00406 for (Int_t ith1 = 0; ith1<=fth1adcarray->GetLast(); ith1++) {
00407 TH1F *th1 = dynamic_cast<TH1F*>(fth1adcarray->At(ith1));
00408 th1->Fit("gaus","q");
00409 }
00410 }
00411
00412 if (fRunType==3 && ftprofCIarray) {
00413 TF1 linfit("linfit","pol1",0.,60.);
00414 int ibinoff = {3}; // offset since bins start at zero
00415 for (Int_t itprof = 0; itprof<=ftprofCIarray->GetLast(); itprof++) {
00416 TProfile *tprofraw = dynamic_cast<TProfile*>(ftprofCIarray->At(itprof));
00417 fFile->cd("/CI");
00418 TProfile *tprof = new TProfile(tprofraw->GetName(),tprofraw->GetTitle(),128,0.,128.);
00419 int icrate,ivarc,ivmm,ivaadc,ivachip,ivachannel;
00420 sscanf(tprofraw->GetTitle(),"%02d %01d %01d %01d %01d %02d",&icrate,&ivarc,&ivmm,&ivaadc,&ivachip,&ivachannel);
00421
00422 if (icrate>=0 && icrate<50) {
00423 for (int icharge=0; icharge<128; icharge++) {
00424 if (CIbegframe[icrate][icharge]>=0 &&
00425 CIbegframe[icrate][icharge]<=CIendframe[icrate][icharge]) {
00426 double xavg=0.;
00427 double navg=0.;
00428 //unused: double xerr=0.;
00429 //unused: double xgerr=0.;
00430 for (int ibin=CIbegframe[icrate][icharge]+ibinoff; ibin<=CIendframe[icrate][icharge]+ibinoff; ibin++) {
00431 /*
00432 if (tprofraw->GetBinError(ibin)>1e-4) {
00433 xerr += 1./(tprofraw->GetBinError(ibin)*tprofraw->GetBinError(ibin));
00434 }
00435 */
00436 navg += tprofraw->GetBinEntries(ibin);
00437 xavg += tprofraw->GetBinEntries(ibin)*tprofraw->GetBinContent(ibin);
00438 }
00439 if (navg>0.) {
00440 xavg /= navg;
00441 }
00442 tprof->Fill((float)icharge,(float)xavg,1.);
00443 }
00444 }
00445 tprof->Fit("linfit","qr");
00446 }
00447 }
00448 }
00449
00450
00451 if (fFile) {
00452 fFile->Write();
00453 fFile->Close();
00454 }
00455
00456 }
|
|
|
Implement to handle a JobCommand Reimplemented from JobCModule. Definition at line 382 of file FarPlaneCheckout.cxx. References JobCommand::HaveCmd(), MSG, and JobCommand::PopCmd(). 00383 {
00384 //======================================================================
00385 // Handle a command send from the job controller
00386 //
00387 // Inputs: cmd - The parsed job command
00388 //======================================================================
00389 if (cmd->HaveCmd()) { // If we have a command...
00390 string sc = cmd->PopCmd(); // Get the command
00391 MSG("FarPlaneCheckout",Msg::kWarning) << "Don't understand '" << sc.c_str() << "'\n";
00392 }
00393 }
|
|
|
Definition at line 54 of file FarPlaneCheckout.h. Referenced by Ana(), EndJob(), and FarPlaneCheckout(). |
|
|
Definition at line 55 of file FarPlaneCheckout.h. Referenced by Ana(), EndJob(), and FarPlaneCheckout(). |
|
|
Definition at line 41 of file FarPlaneCheckout.h. Referenced by Ana(), EndJob(), and FarPlaneCheckout(). |
|
|
Definition at line 45 of file FarPlaneCheckout.h. Referenced by Ana(). |
|
|
Definition at line 48 of file FarPlaneCheckout.h. |
|
|
Definition at line 47 of file FarPlaneCheckout.h. Referenced by Ana(). |
|
|
Definition at line 43 of file FarPlaneCheckout.h. Referenced by Ana(), EndJob(), and FarPlaneCheckout(). |
|
|
Definition at line 46 of file FarPlaneCheckout.h. Referenced by Ana(). |
|
|
Definition at line 50 of file FarPlaneCheckout.h. |
|
|
Definition at line 57 of file FarPlaneCheckout.h. Referenced by Ana(). |
|
|
Definition at line 52 of file FarPlaneCheckout.h. |
1.3.9.1