00001
00002
00003
00004
00005
00006
00007
00008 #include <algorithm>
00009
00010 #include "TCanvas.h"
00011 #include "TAxis.h"
00012 #include "TText.h"
00013 #include "TFile.h"
00014
00015 #include "MinosObjectMap/MomNavigator.h"
00016 #include "JobControl/JobCResult.h"
00017 #include "JobControl/JobCModuleRegistry.h"
00018 #include "JobControl/JobCommand.h"
00019 #include "MessageService/MsgService.h"
00020 #include "RawData/RawRecord.h"
00021 #include "RawData/RawDigitDataBlock.h"
00022 #include "RawData/RawChannelId.h"
00023 #include "RawData/RawDigit.h"
00024 #include "RawData/RawDaqHeader.h"
00025 #include "Conventions/ElecType.h"
00026 #include <sstream>
00027 #include "Plex/PlexHandle.h"
00028 #include "OnlineUtil/mdBlockDefinitions.h"
00029 #include "CalDetSI/Cutter.h"
00030 #include "CalDetSI/Helpers.h"
00031
00032
00033 CVSID("$Id: Cutter.cxx,v 1.11 2007/11/11 09:13:18 rhatcher Exp $");
00034 JOBMODULE(Cutter,"Cutter","A module to apply basic cuts to CalDet data\n");
00035
00036 Cutter::Cutter():
00037 fSparseErrCut(true),
00038 fFafErrCut(true),
00039 fTrigCut(true),
00040 fTPMTCut(false),
00041 fCCCut(false),
00042 fDCCut(true),
00043 fOSCut(false),
00044 fKovCut(false),
00045 fTOFCut(false),
00046 fTOFTrigCut(false),
00047 fKov1TrigCut(false),
00048 fKov2TrigCut(false),
00049 fKov3TrigCut(false),
00050 fKovORTrigCut(false),
00051 fAllKovTrigCut(false),
00052 fLITrigCut(true),
00053 fPIDOrTrigCut(false),
00054 fDeadKovCut(true),
00055 fNDErrorCut(true),
00056 fDrawHist(false),
00057 fWriteHist(false),
00058 fWait(false),
00059 fCutsSet(false),
00060
00061 fKovADCCutLow1(1),
00062 fKovADCCutHigh1(60000),
00063 fKovADCCutLow2(1),
00064 fKovADCCutHigh2(60000),
00065 fKovADCCutLow3(1),
00066 fKovADCCutHigh3(60000),
00067 fDCPlaneCut(15),
00068 fMinOST(20000),
00069
00070 fFrequency(100),
00071 fCounter(0),
00072 fFileName("cuts.root"),
00073 fRunNumber(0),
00074 fRR(0),
00075 fCCDH(0),
00076 fCutHistogram("CutHistogram","CutHistogram",fNCuts+1,0,fNCuts+1),
00077 fCanvas("can","can"),
00078 fChipsToCut(),
00079 fFilledChipsToCut(false)
00080
00081
00082 {
00083 fCanvas.SetGridx(1);
00084 fCanvas.SetLogy(1);
00085 fCutHistogram.SetNdivisions(510);
00086
00087
00088 for(int i=0;i<fNCuts+1;i++){
00089 fBinLabel[i] = "";
00090 }
00091
00092
00093 MSG("Cutter",Msg::kDebug)<<"Creating Cutter"<<endl;
00094 }
00095
00096
00097
00098
00099 Cutter::~Cutter() {MSG("Cutter",Msg::kDebug)<<"Killing Cutter"<<endl;}
00100
00101
00102
00103 JobCResult Cutter::Get(MomNavigator *mom)
00104 {
00105
00106
00107
00108 fRR = dynamic_cast<RawRecord *>(mom->GetFragment("RawRecord"));
00109 if(fRR==0){
00110 MSG("Cutter", Msg::kError)<<"Could not retrieve a RawRecord from Mom"<<endl;
00111 return JobCResult(JobCResult::kFailed);
00112 }
00113 if(fRR->FindRawBlock("RawDigitDataBlock")==0){
00114 MSG("Cutter", Msg::kError)<<"Not a RawDigitDataBlock"<<endl;
00115 return JobCResult(JobCResult::kFailed);
00116 }
00117
00118
00119 CandRecord *cr = dynamic_cast<CandRecord *>(mom->GetFragment("CandRecord"));
00120 if(cr==0){
00121 return JobCResult(JobCResult::kFailed);
00122 }
00123
00124
00125 fCCDH = dynamic_cast<CandCalDetSIHandle *>(cr->FindCandHandle("CandCalDetSIHandle"));
00126 if(fCCDH==0){
00127 MSG("Cutter", Msg::kError)<<"Could not retrieve a CandCalDetSIHandle from Mom"<<endl;
00128 return JobCResult(JobCResult::kFailed);
00129 }
00130
00131 if(!fFilledChipsToCut){
00132 FillChipsToCut();
00133 fFilledChipsToCut=true;
00134 }
00135
00136 return JobCResult(JobCResult::kPassed);
00137 }
00138
00139
00140
00141 JobCResult Cutter::Ana(const MomNavigator* )
00142 {
00143
00144
00145
00146
00147 if(!fCutsSet){
00148 SetCuts();
00149 fCutsSet=true;
00150 }
00151
00152 if(fRunNumber==0){
00153 MSG("Cutter",Msg::kDebug)<<"Trying to get RunNumber"<<endl;
00154 const RawDaqHeader* daqhead =
00155 dynamic_cast <const RawDaqHeader *>(fRR->GetRawHeader());
00156 if(daqhead){
00157 fRunNumber = daqhead->GetRun();
00158 MSG("Cutter",Msg::kDebug)<<fRunNumber<<endl;
00159 }
00160 }
00161 fCounter++;
00162
00163 int CutNum = 1;
00164 int AllPassed = 0;
00165
00166 if(fDrawHist){
00167 if(fCounter%fFrequency==0){
00168 DrawCutHistogram();
00169 }
00170 }
00171
00172 if(fCounter%10000==0){
00173 MSG("Cutter",Msg::kInfo)<<"On Snarl "<<fCCDH->GetSnarl()<<endl;
00174 }
00175
00176 for(int i=0;i<fNCuts;i++){
00177 if(!(this->*fCutList[i])()){
00178 fCutHistogram.Fill(CutNum+.5);
00179 MSG("Cutter",Msg::kDebug)<<fBinLabel[i+1]<<" Fail"<<endl;
00180 return JobCResult::kFailed;
00181 }
00182 CutNum++;
00183 }
00184
00185
00186 fCutHistogram.Fill(AllPassed+.5);
00187 MSG("Cutter",Msg::kDebug)<<"Passed all cuts"<<endl;
00188 if(fWait){
00189 MSG("Cutter", Msg::kInfo)<<"After viewing, hit any key to continue"<<endl
00190 <<"--------------------------------------"<<endl;
00191
00192 char c;
00193 cin>>c;
00194 }
00195 return JobCResult(JobCResult::kPassed);
00196
00197 }
00198
00199
00200
00201
00202
00203 bool Cutter::DeadChipCutter() const
00204 {
00205 if(fCCDH->GetDeadChips().size()==0){
00206 return true;
00207 }
00208
00209
00210
00211
00212
00213
00214
00215
00216
00217
00218
00219
00220
00221
00222
00223
00224
00225
00226
00227
00228
00229
00230
00231
00232
00233
00234
00235
00236
00237
00238
00239
00240
00241
00242
00243
00244
00245
00246
00247 MSG("Cutter",Msg::kDebug)<<"Looking for DEAD CHIPS "<<endl;
00248
00249
00250
00251
00252
00253
00254
00255
00256
00257
00258
00259
00260
00261 MSG("Cutter",Msg::kDebug)<<"The dead chips are:"<<endl;;
00262 for(unsigned int i=0;i<fCCDH->GetDeadChips().size();i++){
00263 MSG("Cutter",Msg::kDebug)<<fCCDH->GetDeadChips()[i]<<endl;
00264 }
00265
00266 std::set<RawChannelId>::iterator ctci(fChipsToCut.begin());
00267 MSG("Cutter",Msg::kDebug)<<"The chips in the list of chips to cut are:"<<endl;
00268 while(ctci!=fChipsToCut.end()){
00269 MSG("Cutter",Msg::kDebug)<<*ctci<<endl;
00270 ctci++;
00271 }
00272
00273 if(find_first_of(fChipsToCut.begin(),
00274 fChipsToCut.end(),
00275 fCCDH->GetDeadChips().begin(),
00276 fCCDH->GetDeadChips().end())!= fChipsToCut.end())
00277 {
00278
00279 MSG("Cutter",Msg::kDebug)<<"FOUND DEAD CHIPS "<<endl
00280 <<"Size of DCVector "<<fCCDH->GetDeadChips().size()
00281 <<" first entry "<<(fCCDH->GetDeadChips())[0]
00282 <<endl;
00283 MSG("Cutter",Msg::kDebug)<<"Dead chips "
00284 <<*find_first_of(fChipsToCut.begin(),
00285 fChipsToCut.end(),
00286 fCCDH->GetDeadChips().begin(),
00287 fCCDH->GetDeadChips().end())
00288 <<endl;
00289 return false;
00290 }
00291
00292
00293
00294 return true;
00295 }
00296
00297
00298 bool Cutter::DeadKovCutter() const
00299 {
00300
00301 if(fCCDH->GetDeadChips().size()==0){
00302 return true;
00303 }
00304
00305 vector<RawChannelId>::const_iterator it(fCCDH->GetDeadChips().begin());
00306 while(it!=fCCDH->GetDeadChips().end()){
00307 if(it->GetElecType()==ElecType::kVA
00308 &&fCCDH->GetCerenkovChannel1()==ElecType::kVA){
00309 if(it->IsSameVAChip(fCCDH->GetCerenkovChannel1())){
00310 return false;
00311 }
00312 }
00313 else if(it->GetElecType()==ElecType::kQIE
00314 &&fCCDH->GetCerenkovChannel1()==ElecType::kQIE){
00315 if(it->IsSameChannel(fCCDH->GetCerenkovChannel1())){
00316 return false;
00317 }
00318 }
00319 if(it->GetElecType()==ElecType::kVA
00320 &&fCCDH->GetCerenkovChannel2()==ElecType::kVA){
00321 if(it->IsSameVAChip(fCCDH->GetCerenkovChannel2())){
00322 return false;
00323 }
00324 }
00325 else if(it->GetElecType()==ElecType::kQIE
00326 &&fCCDH->GetCerenkovChannel2()==ElecType::kQIE){
00327 if(it->IsSameChannel(fCCDH->GetCerenkovChannel2())){
00328 return false;
00329 }
00330 }
00331 if(it->GetElecType()==ElecType::kVA
00332 &&fCCDH->GetCerenkovChannel3()==ElecType::kVA){
00333 if(it->IsSameVAChip(fCCDH->GetCerenkovChannel3())){
00334 return false;
00335 }
00336 }
00337 else if(it->GetElecType()==ElecType::kQIE
00338 &&fCCDH->GetCerenkovChannel3()==ElecType::kQIE){
00339 if(it->IsSameChannel(fCCDH->GetCerenkovChannel3())){
00340 return false;
00341 }
00342 }
00343
00344 it++;
00345 }
00346
00347 return true;
00348
00349 }
00350
00351
00352
00353 bool Cutter::OverShootCutter() const
00354 {
00355 TIter rbi = fRR->GetRawBlockIter();
00356
00357 while(TObject* obj = rbi.Next()){
00358
00359 const RawDataBlock* rdb=dynamic_cast<RawDataBlock *>(obj);
00360 if(rdb==0){
00361 continue;
00362 }
00363
00364
00365
00366
00367
00368
00369 if(rdb->GetBlockId().GetMajor()==kMdBlockCrateReadout){
00370
00371 const RawDigitDataBlock* data = dynamic_cast<RawDigitDataBlock *>(obj);
00372 if(data==0){
00373 continue;
00374 }
00375 Int_t NDigits = data->GetNumberOfDigits();
00376 for(Int_t i=0;i<NDigits;i++){
00377
00378
00379
00380
00381
00382
00383
00384
00385
00386
00387
00388
00389
00390
00391
00392
00393
00394
00395
00396
00397
00398
00399
00400
00401
00402
00403
00404
00405
00406
00407 map<RawChannelId, Int_t>::const_iterator mit =
00408 fCCDH->GetUnderShootChips().find(data->At(i)->GetChannel());
00409 if(mit==fCCDH->GetUnderShootChips().end() || mit->second>fMinOST) {}
00410 else return false;
00411
00412
00413 }
00414 }
00415 }
00416
00417 return true;
00418
00419 }
00420
00421
00422
00423 void Cutter::DrawCutHistogram()
00424 {
00425 fCanvas.cd();
00426 fCutHistogram.Draw();
00427 TText t;
00428 t.SetTextAngle(90);
00429 t.SetTextSize(.035);
00430 t.SetTextAlign(33);
00431
00432 Float_t y = (fCanvas.GetUymax()+fCanvas.GetUymin())/2.;
00433 for(int i=0;i<fCutHistogram.GetNbinsX();i++){
00434 const char* temp = fBinLabel[i].c_str();
00435 char name[100];
00436 strcpy(name, temp);
00437 Float_t x = fCutHistogram.GetXaxis()->GetBinCenter(i+1);
00438 MSG("Cutter",Msg::kDebug)<<"*"<<name<<endl;
00439 t.DrawText(x,y,name);
00440 }
00441
00442
00443 }
00444
00445
00446
00447 void Cutter::WriteCutHistogram()
00448 {
00449
00450
00451
00452
00453
00454 const char* fname = fFileName.c_str();
00455 TFile f(fname, "RECREATE");
00456 if(!f.IsOpen()){
00457 MSG("Cutter",Msg::kError) << "Could not open " << fname
00458 << " for writing Cut Histogram" << endl;
00459 return;
00460 }
00461 MSG("Cutter",Msg::kInfo) <<"Writing cut hists to " << fname<<endl;
00462
00463
00464 fCanvas.Update();
00465 f.cd();
00466 fCutHistogram.Write();
00467 fCanvas.Write();
00468 f.Close();
00469
00470 return;
00471
00472
00473 }
00474
00475
00476
00477 void Cutter::HandleCommand(JobCommand *cmd)
00478 {
00479
00480 const char* c = cmd->PopCmd();
00481 if (c) {
00482 string sc(c);
00483
00484
00485
00486 if(sc == "Wait"){
00487 fWait = true;
00488 }
00489
00490 if(sc == "NoWait"){
00491 fWait = false;
00492 }
00493
00494 if (sc == "SetDrawFreq") {
00495 fDrawHist = true;
00496 fFrequency = atoi(cmd->PopOpt());
00497 }
00498
00499 if(sc == "SetFileName"){
00500 fFileName = cmd->PopOpt();
00501 }
00502
00503 if(sc == "WriteHistogram"){
00504 WriteCutHistogram();
00505 }
00506
00507 if(sc == "DrawHistogram"){
00508 DrawCutHistogram();
00509 }
00510
00511 if(sc == "CutON"){
00512 string cutname = cmd->PopOpt();
00513 if(cutname == "SparseErrCut"){
00514 fSparseErrCut=true;
00515 }
00516 if(cutname == "FafErrCut"){
00517 fFafErrCut=true;
00518 }
00519 if(cutname == "TrigCut"){
00520 fTrigCut=true;
00521 }
00522 if(cutname == "TriggerPMTCut"){
00523
00524 fTPMTCut=true;
00525 }
00526 if(cutname == "CosmicCntCut"){
00527 fCCCut=true;
00528 }
00529 if(cutname == "DeadChipCut"){
00530 fDCCut=true;
00531 }
00532 if(cutname == "UnderShootCut"){
00533 fOSCut=true;
00534 }
00535 if(cutname == "KovCut1"){
00536 fKovCut=true;
00537 fKovADCCutLow1 = atoi(cmd->PopOpt());
00538 fKovADCCutHigh1 = atoi(cmd->PopOpt());
00539 }
00540 if(cutname == "KovCut2"){
00541 fKovCut=true;
00542 fKovADCCutLow2 = atoi(cmd->PopOpt());
00543 fKovADCCutHigh2 = atoi(cmd->PopOpt());
00544 }
00545 if(cutname == "TOFCut"){
00546 fTOFCut=true;
00547 }
00548 if(cutname == "TOFTrigCut"){
00549 fTOFTrigCut=true;
00550 }
00551 if(cutname=="Kov1TrigCut"){
00552 fKov1TrigCut=true;
00553 }
00554 if(cutname=="Kov2TrigCut"){
00555 fKov2TrigCut=true;
00556 }
00557 if(cutname=="Kov3TrigCut"){
00558 fKov3TrigCut=true;
00559 }
00560 if(cutname=="KovORTrigCut"){
00561 fKovORTrigCut=true;
00562 }
00563 if(cutname=="AllKovTrigCut"){
00564 fAllKovTrigCut = true;
00565 }
00566 if(cutname=="PIDOrTrigCut"){
00567 fPIDOrTrigCut = true;
00568 }
00569 if(cutname=="LITrigCut"){
00570 fLITrigCut = true;
00571 }
00572 if(cutname == "NDErrorCut"){
00573 fNDErrorCut=true;
00574 }
00575 }
00576
00577 if(sc == "SetCutValue"){
00578 string cutname = cmd->PopOpt();
00579 if(cutname == "DeadChipCut"){
00580 fDCPlaneCut = atoi(cmd->PopOpt());
00581 }
00582 if(cutname == "UnderShootCut"){
00583 fMinOST = atoi(cmd->PopOpt());
00584 }
00585 }
00586
00587 if(sc == "CutOFF"){
00588 string cutname = cmd->PopOpt();
00589 if(cutname == "SparseErrCut"){
00590 fSparseErrCut=false;
00591 }
00592 if(cutname == "FafErrCut"){
00593 fFafErrCut=false;
00594 }
00595 if(cutname == "TrigCut"){
00596 fTrigCut=false;
00597 }
00598 if(cutname == "TriggerPMTCut"){
00599 fTPMTCut=false;
00600 }
00601 if(cutname == "CosmicCntCut"){
00602 fCCCut=false;
00603 }
00604 if(cutname == "DeadChipCut"){
00605 fDCCut=false;
00606 }
00607 if(cutname == "UnderShootCut"){
00608 fOSCut=false;
00609 }
00610 if(cutname == "KovCut"){
00611 fKovCut=false;
00612 }
00613 if(cutname == "TOFCut"){
00614 fTOFCut=false;
00615 }
00616 if(cutname == "TOFTrigCut"){
00617 fTOFTrigCut=false;
00618 }
00619 if(cutname=="Kov1TrigCut"){
00620 fKov1TrigCut=false;
00621 }
00622 if(cutname=="Kov2TrigCut"){
00623 fKov2TrigCut=false;
00624 }
00625 if(cutname=="Kov3TrigCut"){
00626 fKov2TrigCut=false;
00627 }
00628 if(cutname=="KovORTrigCut"){
00629 fKov2TrigCut=false;
00630 }
00631 if(cutname=="AllKovTrigCut"){
00632 fAllKovTrigCut = false;
00633 }
00634 if(cutname=="PIDOrTrigCut"){
00635 fPIDOrTrigCut = false;
00636 }
00637 if(cutname=="LITrigCut"){
00638 fLITrigCut = false;
00639 }
00640 if(cutname == "NDErrorCut"){
00641 fNDErrorCut=false;
00642 }
00643
00644
00645 }
00646
00647 }
00648 return;
00649 }
00650
00651
00652
00653 void Cutter::SetCuts()
00654 {
00655
00656 MSG("Cutter",Msg::kInfo)<<"THE CUTS ARE SET AS FOLLOWS:"<<endl
00657 <<"____________________________"<<endl
00658 <<"Dead Chip Cut "<<(int)fDCCut<<" Less than plane "<<fDCPlaneCut<<endl
00659 <<"UnderShoot Cut "<<(int)fOSCut<<" more than "<<fMinOST<<" ticks"<<endl
00660 <<"SparseErrCut "<<(int)fSparseErrCut<<endl
00661 <<"FafErrCut "<<(int)fFafErrCut<<endl
00662 <<"KovCut "<<(int)fKovCut<<endl
00663 <<"TOFCut "<<(int)fTOFCut<<endl
00664 <<"TrigCut "<<(int)fTrigCut<<endl
00665 <<"TOFTrigCut"<<(int)fTOFTrigCut<<endl
00666 <<"Kov1TrigCut"<<(int)fKov1TrigCut<<endl
00667 <<"Kov2TrigCut"<<(int)fKov2TrigCut<<endl
00668 <<"Kov3TrigCut"<<(int)fKov3TrigCut<<endl
00669 <<"KovORTrigCut"<<(int)fKovORTrigCut<<endl
00670 <<"AllKovTrigCut"<<(int)fAllKovTrigCut<<endl
00671 <<"CosmicCntCut "<<(int)fCCCut<<endl
00672 <<"TriggerPMTCut "<<(int)fTPMTCut<<endl
00673 <<"LITriggerCut "<<(int)fLITrigCut<<endl
00674 <<"PIDOrTrigCut "<<(int)fPIDOrTrigCut<<endl
00675 <<"DeadKovCut "<<(int)fDeadKovCut<<endl
00676 <<"NDErrorCut "<<(int)fNDErrorCut<<endl;
00677
00678 fBinLabel[0] = "PA";
00679 if(fTrigCut){
00680 fCutList[0] = &Cutter::TriggerCutter;
00681 fBinLabel[1] = "Trig";
00682 }
00683 else{
00684 fCutList[0] = &Cutter::DummyCutter;
00685 }
00686
00687 if(fTOFTrigCut){
00688 fCutList[1] = &Cutter::TOFTrigCutter;
00689 fBinLabel[2] = "TOFTrig";
00690 }
00691 else{
00692 fCutList[1] = &Cutter::DummyCutter;
00693 }
00694
00695 if(fKov1TrigCut){
00696 fCutList[2] = &Cutter::Kov1TrigCutter;
00697 fBinLabel[3] = "Kov1Trig";
00698 }
00699 else{
00700 fCutList[2] = &Cutter::DummyCutter;
00701 }
00702
00703 if(fKov2TrigCut){
00704 fCutList[3] = &Cutter::Kov2TrigCutter;
00705 fBinLabel[4] = "Kov2Trig";
00706 }
00707 else{
00708 fCutList[3] = &Cutter::DummyCutter;
00709 }
00710
00711 if(fKov3TrigCut){
00712 fCutList[4] = &Cutter::Kov3TrigCutter;
00713 fBinLabel[5] = "Kov3Trig";
00714 }
00715 else{
00716 fCutList[4] = &Cutter::DummyCutter;
00717 }
00718
00719 if(fKovORTrigCut){
00720 fCutList[5] = &Cutter::KovORTrigCutter;
00721 fBinLabel[6] = "KovORTrig";
00722 }
00723 else{
00724 fCutList[5] = &Cutter::DummyCutter;
00725 }
00726
00727 if(fAllKovTrigCut){
00728 fCutList[6] = &Cutter::AllKovTrigCutter;
00729 fBinLabel[7] = "AllKovTrig";
00730 }
00731 else{
00732 fCutList[6] = &Cutter::DummyCutter;
00733 }
00734
00735 if(fPIDOrTrigCut){
00736 fCutList[7] = &Cutter::PIDOrTrigCutter;
00737 fBinLabel[8] = "PIDTrig";
00738 }
00739 else{
00740 fCutList[7] = &Cutter::DummyCutter;
00741 }
00742
00743 if(fLITrigCut){
00744 fCutList[8] = &Cutter::LITrigCutter;
00745 fBinLabel[9] = "LITrig";
00746 }
00747 else{
00748 fCutList[8] = &Cutter::DummyCutter;
00749 }
00750
00751 if(fDCCut){
00752 fCutList[9] = &Cutter::DeadChipCutter;
00753 fBinLabel[10] = "DC";
00754 }
00755 else{
00756 fCutList[9] = &Cutter::DummyCutter;
00757 }
00758
00759 if(fKovCut){
00760 fCutList[10]=&Cutter::KovCutter;
00761 fBinLabel[11] = "Kov";
00762 }
00763 else{
00764 fCutList[10] = &Cutter::DummyCutter;
00765 }
00766
00767 if(fSparseErrCut){
00768 fCutList[11] = &Cutter::SparseErrorCutter;
00769 fBinLabel[12] = "SE";
00770 }
00771 else{
00772 fCutList[11] = &Cutter::DummyCutter;
00773 }
00774
00775 if(fFafErrCut){
00776 fCutList[12] = &Cutter::FafErrorCutter;
00777 fBinLabel[13] = "Faf";
00778 }
00779 else{
00780 fCutList[12] = &Cutter::DummyCutter;
00781 }
00782
00783 if(fOSCut){
00784 fCutList[13] = &Cutter::OverShootCutter;
00785 fBinLabel[14] = "OS";
00786 }
00787 else{
00788 fCutList[13] = &Cutter::DummyCutter;
00789 }
00790
00791 if(fTOFCut){
00792 fCutList[14]=&Cutter::TOFCutter;
00793 fBinLabel[15]="TOF";
00794 }
00795 else{
00796 fCutList[14]=&Cutter::DummyCutter;
00797 }
00798
00799 if(fCCCut){
00800 fCutList[15]=&Cutter::CosmicCounterCutter;
00801 fBinLabel[16] = "Cos";
00802 }
00803 else{
00804 fCutList[15] = &Cutter::DummyCutter;
00805 }
00806
00807 if(fTPMTCut){
00808 fCutList[16]=&Cutter::TrigPMTCutter;
00809 fBinLabel[17] = "PMT";
00810 }
00811 else{
00812 fCutList[16] = &Cutter::DummyCutter;
00813 }
00814
00815 if(fDeadKovCut){
00816 fCutList[17]=&Cutter::DeadKovCutter;
00817 fBinLabel[18] = "DK";
00818 }
00819 else{
00820 fCutList[17] = &Cutter::DummyCutter;
00821 }
00822
00823 if(fNDErrorCut){
00824 fCutList[18]=&Cutter::NDErrorCutter;
00825 fBinLabel[19] = "NDE";
00826 }
00827 else{
00828 fCutList[18] = &Cutter::DummyCutter;
00829 }
00830
00831 for(int i=0;i<fNCuts+1;i++){
00832 MSG("Cutter",Msg::kInfo)<<"THE CUTS ARE SET AS FOLLOWS:"<<endl
00833 <<fBinLabel[i]<<endl;
00834 }
00835
00836 return;
00837 }
00838
00839
00840 void Cutter::FillChipsToCut()
00841 {
00842
00843
00844
00845
00846
00847 const VldContext *vldc = fRR->GetVldContext();
00848 PlexHandle ph(*vldc);
00849 Detector::Detector_t detector = vldc->GetDetector();
00850 MSG("Cutter",Msg::kDebug)<<"The VldContext in Fill chips to cut is:"
00851 <<*vldc<<endl;
00852 for(Int_t plane=0; plane<fDCPlaneCut; plane++){
00853
00854
00855 Int_t nstrips = 0;
00856 switch(detector) {
00857 case Detector::kCalDet:
00858 nstrips=24;
00859 break;
00860 default:
00861 break;
00862 }
00863
00864
00865 for(Int_t strip=0; strip<nstrips; strip++) {
00866 PlexStripEndId pseid_pos(detector, plane,
00867 strip, StripEnd::kPositive);
00868 PlexStripEndId pseid_neg(detector, plane,
00869 strip, StripEnd::kNegative);
00870 RawChannelId chip_pos = ph.GetRawChannelId(pseid_pos);
00871 RawChannelId chip_neg = ph.GetRawChannelId(pseid_neg);
00872
00873 MSG("Cutter",Msg::kDebug)<<" The real rawchan id (before changing) "
00874 <<plane<<" strip "<<strip<<endl;
00875 MSG("Cutter",Msg::kDebug)<<"pos "<<chip_pos<<endl
00876 <<"neg "<<chip_neg<<endl;
00877
00878
00879
00880 if(chip_pos.GetElecType()==ElecType::kVA){
00881
00882 MSG("Cutter",Msg::kDebug)<<"positive va"<<endl;
00883 chip_pos.SetChAdd(
00884 chip_pos.CalcChAdd(chip_pos.GetVarcId(),chip_pos.GetVmm(),
00885 chip_pos.GetVaAdcSel(),
00886 chip_pos.GetVaChip(),0));
00887 }
00888 if(chip_pos.GetElecType()==ElecType::kQIE){
00889 MSG("Cutter",Msg::kDebug)<<"positive qie"<<endl;
00890
00891
00892
00893 chip_pos.SetChAdd(
00894 chip_pos.CalcChAdd(chip_pos.GetGeographicAddress(),
00895 ((int)(chip_pos.GetMasterChannel()/4))*4,
00896 0));
00897 }
00898 if(chip_neg.GetElecType()==ElecType::kVA){
00899 MSG("Cutter",Msg::kDebug)<<"neg va"<<endl;
00900 chip_neg.SetChAdd(
00901 chip_neg.CalcChAdd(chip_neg.GetVarcId(),chip_neg.GetVmm(),
00902 chip_neg.GetVaAdcSel(),
00903 chip_neg.GetVaChip(),0));
00904 }
00905 if(chip_neg.GetElecType()==ElecType::kQIE){
00906 MSG("Cutter",Msg::kDebug)<<"neg qie"<<endl;
00907 chip_neg.SetChAdd(
00908 chip_neg.CalcChAdd(chip_neg.GetGeographicAddress(),
00909 ((int)(chip_neg.GetMasterChannel()/4))*4,
00910 0));
00911
00912 }
00913
00914 MSG("Cutter",Msg::kDebug)<<" inserting chips for plane "
00915 <<plane<<" strip "<<strip<<endl;
00916 MSG("Cutter",Msg::kDebug)<<"pos "<<chip_pos<<endl
00917 <<"neg "<<chip_neg<<endl;
00918 fChipsToCut.insert(chip_pos);
00919 fChipsToCut.insert(chip_neg);
00920 }
00921 }
00922 return;
00923
00924 }
00925
00926
00927 bool Cutter::NDErrorCutter() const
00928 {
00929
00930
00931 if(!fRR) return true;
00932
00933
00934 const RawDigitDataBlock* r =
00935 dynamic_cast<const RawDigitDataBlock*>
00936 (fRR->FindRawBlock("RawDigitDataBlock"));
00937
00938
00939 if(!r) return true;
00940
00941
00942
00943
00944 bool error = false;
00945 const Int_t ndig=r->GetNumberOfDigits();
00946 for(int i=0; i<ndig; i++){
00947 const RawDigit* d = r->At(i);
00948 if( (d->GetChannel().GetElecType()==ElecType::kQIE)
00949 &&(d->GetErrorCode()!=0) ) { error=true; break;}
00950 }
00951
00952 return !(error);
00953 }
00954
00955
00956 void Cutter::Config(const Registry& r)
00957 {
00958
00959
00960
00961 const char* t;
00962 if (r.Get("FileName",t)) { fFileName = t; }
00963
00964 }
00965
00966
00967
00968 const Registry& Cutter::DefaultConfig() const
00969 {
00970
00971
00972
00973 static Registry r;
00974
00975
00976 std::string name = this->JobCModule::GetName();
00977 name += ".config.default";
00978 r.SetName(name.c_str());
00979
00980
00981 r.UnLockValues();
00982
00983 const char* s = "cuts.root";
00984 r.Set("FileName", s);
00985
00986 r.LockValues();
00987
00988 return r;
00989 }
00990
00991
00992
00993
00994
00995
00996
00997
00998
00999
01000
01001
01002
01003
01004
01005
01006
01007
01008
01009
01010
01011
01012
01013
01014
01015
01016
01017
01018
01019
01020
01021
01022
01023
01024
01025
01026
01027
01028
01029
01030
01031
01032
01033
01034
01035
01036
01037
01038
01039
01040
01041