00001 #include <TMath.h>
00002 #include <TStyle.h>
00003 #include <TLegend.h>
00004 #include <TPad.h>
00005 #include <TROOT.h>
00006 #include <TError.h>
00007 #include <TSystem.h>
00008
00009 #include <math.h>
00010
00011 #include <SexyPedAna.h>
00012
00013 using namespace std;
00014
00015 SexyPedAna* SexyPedAna::mySexyPedAna = 0;
00016
00017 CVSID("$Id: SexyPedAna.cxx,v 1.8 2005/05/20 18:49:19 anatael Exp $");
00018
00019
00020
00021 SexyPedAna* SexyPedAna::InstantiateMe() {
00022 if(!mySexyPedAna) {
00023 mySexyPedAna = new SexyPedAna();
00024 }
00025 return mySexyPedAna;
00026 }
00027
00028
00029
00030 SexyPedAna::~SexyPedAna() {
00031
00032 mySP.clear();
00033
00034 fReportFile.close();
00035
00036 delete mySexyPedAna;
00037 }
00038
00039
00040
00041 SexyPedAna::SexyPedAna() {
00042
00043
00044
00045 gTruncType = 2;
00046 gSparsFactor = 5;
00047 gTruncLimit = 5;
00048
00049 gPlotEachPage = false;
00050 gPlots = true;
00051 gQuickPlots = false;
00052
00053 gOutputPedestalTable = false;
00054 gOutputSparsTable = false;
00055 gDebugTable = false;
00056
00057 gCheckError2 = true;
00058
00059 gDoOutliersAnalysis = true;
00060
00061 gComparePedTable = true;
00062 gCompareSparTable = true;
00063 gTolerancePedTable = 1;
00064 gToleranceSparTable = 10;
00065
00066 fFile = 0;
00067 gErrorIgnoreLevel = 1;
00068 gStyle->SetOptStat(111111);
00069 gStyle->SetPalette(1);
00070
00071
00072 ferrorNot2 = 0;
00073 }
00074
00075
00076
00077 void SexyPedAna::DoOnlineAnalysis() {
00078
00079
00080
00081
00082
00083 this->gOutputSparsTable = true;
00084 this->gOutputPedestalTable = false;
00085 this->gComparePedTable = false;
00086 this->gCompareSparTable = false;
00087 this->gCheckError2 = false;
00088 this->gDoOutliersAnalysis = false;
00089 this->gPlots = true;
00090 this->gQuickPlots = true;
00091
00092
00093 this->gTruncType = 2;
00094 this->gTruncLimit = 5;
00095 this->gSparsFactor = 5;
00096
00097
00098 MSG("SexyPedAna",Msg::kInfo) << "\tInitialising analysis variables..." << endl;
00099 this->InitAnaVariables();
00100
00101
00102 MSG("SexyPedAna",Msg::kInfo) << "\tAnalysis starts here...\n\n\tGetting MEANs and RMSs..." << endl;
00103 this->ProcessSexyPedestals();
00104
00105 if(gOutputPedestalTable || gOutputSparsTable) {
00106 MSG("SexyPedAna",Msg::kInfo) << "\tOutputing SexyPedestal Tables (a la online)..." << endl;
00107 this->OutputTables();
00108 }
00109
00110 MSG("SexyPedAna",Msg::kInfo) << "\tEt voila! Plotting at last...\n" << endl;
00111 if(this->gPlots) this->GetPlots();
00112
00113 return;
00114 }
00115
00116
00117
00118 void SexyPedAna::DoOfflineAnalysis(const Int_t entriesMax) {
00119
00120
00121 SexyPedestal::SetTruncFlag(gTruncType);
00122 SexyPedestal::SetTruncFactor(gTruncLimit);
00123 SexyPedestal::SetSparsFactor(gSparsFactor);
00124
00125 this->gQuickPlots = false;
00126
00127 MSG("SexyPedAna",Msg::kInfo) << "\tGetting SexyPedestal TTrees..." << endl;
00128 Int_t success = this->LoadPedTree();
00129 if(!success) {
00130 MSG("SexyPedAna",Msg::kError) << "ERROR: Input TTree could not be loaded." << endl;
00131 return;
00132 }
00133
00134 MSG("SexyPedAna",Msg::kInfo) << "\tGetting data from SexyPedestal TTrees..." << endl;
00135 Int_t SPcounter = this->GetSPData(entriesMax);
00136 MSG("SexyPedAna",Msg::kInfo) << "\t\tGot "<< SPcounter << " SexyPedestals! " << endl;
00137
00138 MSG("SexyPedAna",Msg::kInfo) << "\tInitialising analysis variables..." << endl;
00139 this->InitAnaVariables();
00140
00141 MSG("SexyPedAna",Msg::kInfo) << "\tAnalysis starts...\n\n\tGetting MEANs and RMSs..." << endl;
00142 this->ProcessSexyPedestals();
00143
00144 delete fPedRawTree;
00145
00146 if(gCompareSparTable || gComparePedTable) {
00147 MSG("SexyPedAna",Msg::kInfo) << "\tComparing SexyPedestals and previous DAQ Tables..." << endl;
00148 this->LoadDAQTrees();
00149 this->CompareDAQTables();
00150 }
00151
00152 delete fPedDAQTree;
00153 delete fSparDAQTree;
00154
00155
00156 if(gOutputPedestalTable || gOutputSparsTable) {
00157 MSG("SexyPedAna",Msg::kInfo) << "\tOutputting a la online Tables..." << endl;
00158 this->OutputTables();
00159 }
00160
00161
00162
00163
00164 MSG("SexyPedAna",Msg::kInfo) << "\tEt voila! Plotting at last...\n" << endl;
00165 if(gPlots) this->GetPlots();
00166 }
00167
00168
00169
00170 Bool_t SexyPedAna::LoadPedTree() {
00171
00172 fFile = TFile::Open(gFileName.c_str());
00173 fPedRawTree = (TTree*) fFile->Get("sexyPedTree");
00174
00175 fPedRawTree->SetBranchAddress("run", &frun);
00176 fPedRawTree->SetBranchAddress("error",&ferror);
00177 fPedRawTree->SetBranchAddress("crate",&fcrate);
00178 fPedRawTree->SetBranchAddress("varc", &fvarc);
00179 fPedRawTree->SetBranchAddress("vmm", &fvmm);
00180 fPedRawTree->SetBranchAddress("vfb", &fvfb);
00181 fPedRawTree->SetBranchAddress("va", &fva);
00182 fPedRawTree->SetBranchAddress("vach", &fvach);
00183 fPedRawTree->SetBranchAddress("adc", &fadc);
00184
00185 fPedRawTree->SetBranchAddress("plane",&fplane);
00186 fPedRawTree->SetBranchAddress("tUTC", &ftUTC);
00187
00188 return true;
00189 }
00190
00191
00192
00193
00194 void SexyPedAna::CreateReportFile() {
00195
00196 string fileName = "SexyPedestalReport_";
00197 fileName += Form("%i",frun);
00198
00199 fReportFile.open(fileName.c_str(),ofstream::out | ofstream::app);
00200
00201 return;
00202 }
00203
00204
00205
00206 Bool_t SexyPedAna::LoadDAQTrees() {
00207
00208 TFile* fFile = TFile::Open(gFileName.c_str());
00209 fPedDAQTree = (TTree*) fFile->Get("pedTableTree");
00210
00211 fPedDAQTree->SetBranchAddress("crate",&pedcrate);
00212 fPedDAQTree->SetBranchAddress("varc", &pedvarc);
00213 fPedDAQTree->SetBranchAddress("vmm", &pedvmm);
00214 fPedDAQTree->SetBranchAddress("vfb", &pedvfb);
00215 fPedDAQTree->SetBranchAddress("va", &pedva);
00216 fPedDAQTree->SetBranchAddress("vach", &pedvach);
00217 fPedDAQTree->SetBranchAddress("adc", &pedadc);
00218
00219
00220 fSparDAQTree = (TTree*) fFile->Get("sparTableTree");
00221
00222 fSparDAQTree->SetBranchAddress("crate",&sparcrate);
00223 fSparDAQTree->SetBranchAddress("varc", &sparvarc);
00224 fSparDAQTree->SetBranchAddress("vmm", &sparvmm);
00225 fSparDAQTree->SetBranchAddress("vfb", &sparvfb);
00226 fSparDAQTree->SetBranchAddress("va", &sparva);
00227 fSparDAQTree->SetBranchAddress("vach", &sparvach);
00228 fSparDAQTree->SetBranchAddress("adc", &sparadc);
00229
00230
00231 return true;
00232 }
00233
00234
00235
00236 void SexyPedAna::ReportThisGuy() {
00237
00238
00239 fReportFile << "\t@: " << fvarc << "-" << fvmm << "-"
00240 << fvfb << "-" << fva << "-" << fvach
00241 << "\t"
00242 << "(Error: " << ferror << " ADC: " << fadc
00243 << " Time: " << ftdc << ")"
00244 << endl << endl;
00245
00246 return;
00247 }
00248
00249
00250
00251 void SexyPedAna::CheckDataQuality() {
00252
00253
00254 if(gCheckError2 && ferror!=2) {
00255 fReportFile << "\tFound entry with errro!=2.(" << "Exception #: " << ferrorNot2 << ")." << endl;
00256 this->ReportThisGuy();
00257 ferrorNot2++;
00258 }
00259
00260
00261 if(fadc < ADCMIN || fadc > ADCMAX) {
00262 fReportFile << "\tFound pedestal with ADC too high/low" << endl;
00263 this->ReportThisGuy();
00264 }
00265
00266 return;
00267 }
00268
00269
00270
00271 Int_t SexyPedAna::GetSPData(const Int_t entriesMax) {
00272
00273 Int_t nentries = 0;
00274
00275
00276 if (entriesMax == -1) nentries = Int_t(fPedRawTree->GetEntries());
00277 else nentries = entriesMax;
00278
00279 for (Int_t jentry=0; jentry<nentries;jentry++) {
00280 fPedRawTree->GetEvent(jentry);
00281
00282 this->CheckDataQuality();
00283
00284 Int_t key = SexyPedestal::EncriptMeAKey(fcrate,fvarc,fvmm,fvfb,fva,fvach);
00285
00286
00287 if( mySP.find(key) == mySP.end() ) mySP[key] = new SexyPedestal();
00288
00289 mySP[key]->AddressMe(fcrate,fvarc,fvmm,fvfb,fva,fvach);
00290
00291 mySP[key]->SetPlane(fplane);
00292 mySP[key]->SetError(ferror);
00293 mySP[key]->InputSPEntry(fadc);
00294 }
00295
00296 return mySP.size();
00297
00298 }
00299
00300
00301
00302 void SexyPedAna::ProcessSexyPedestals() {
00303
00304
00305 map<Int_t,SexyPedestal*>::iterator iterSP = mySP.begin();
00306
00307 while(iterSP != mySP.end()) {
00308
00309
00310
00311 iterSP->second->GetSTAT();
00312
00313
00314 iterSP->second->FlushSexyPedestals();
00315
00316 if( (iterSP->second->SparsifiedChannel()) ) {
00317 iterSP++;
00318 continue;
00319 }
00320
00321 MSG("SexyPedAna", Msg::kDebug) << iterSP->second->GetCrate()
00322 << "-"
00323 << iterSP->second->GetVarc()
00324 << "-"
00325 << iterSP->second->GetVmm()
00326 << "-"
00327 << iterSP->second->GetVfb()
00328 << "-"
00329 << iterSP->second->GetVA()
00330 << "-"
00331 << iterSP->second->GetVAch()
00332 << endl
00333 << iterSP->second->GetRawMean()
00334 << endl
00335 << iterSP->second->GetRawRms()
00336 << endl
00337 << iterSP->second->GetEntries()
00338 << endl
00339 << iterSP->second->GetRmsT2()
00340 << endl
00341 << iterSP->second->GetEntriesT2()
00342 << endl;
00343
00344
00345 fMeanRaw_h->Fill((iterSP->second->GetRawMean()));
00346
00347 switch(gTruncType) {
00348 case 1:
00349 fMeanT1_h->Fill((iterSP->second->GetMeanT1()));
00350 break;
00351 case 2:
00352 fMeanT2_h->Fill( (iterSP->second->GetMeanT2()) );
00353 break;
00354 }
00355
00356
00357 fRmsRaw_h->Fill((iterSP->second->GetRawRms()));
00358
00359
00360 fSparcRaw_h->Fill( (iterSP->second->GetRawSparsLevel()) );
00361
00362 switch(gTruncType) {
00363 case 1:
00364 fRmsT1_h->Fill((iterSP->second->GetRmsT1()));
00365 break;
00366 case 2:
00367 fRmsT2_h->Fill((iterSP->second->GetRmsT2()));
00368 break;
00369 }
00370
00371
00372 if( (iterSP->second->IsLGPIN()) ) {
00373
00374 fRmsRawPINLG_h->Fill((iterSP->second->GetRawRms()));
00375 switch(gTruncType) {
00376 case 1:
00377
00378 fRmsPINLG_h->Fill((iterSP->second->GetRmsT1()));
00379
00380 fSparcLGPIN_h->Fill((iterSP->second->GetSparsLevelT1()));
00381 break;
00382 case 2:
00383
00384 fRmsPINLG_h->Fill((iterSP->second->GetRmsT2()));
00385
00386 fSparcLGPIN_h->Fill((iterSP->second->GetSparsLevelT2()));
00387 break;
00388 }
00389 }
00390 else if( (iterSP->second->IsHGPIN()) ) {
00391
00392 fRmsRawPINHG_h->Fill((iterSP->second->GetRawRms()));
00393 switch(gTruncType) {
00394 case 1:
00395
00396 fRmsPINHG_h->Fill((iterSP->second->GetRmsT1()));
00397
00398 fSparcHGPIN_h->Fill((iterSP->second->GetSparsLevelT1()));
00399 break;
00400 case 2:
00401
00402 fRmsPINHG_h->Fill((iterSP->second->GetRmsT2()));
00403
00404 fSparcHGPIN_h->Fill((iterSP->second->GetSparsLevelT2()));
00405 break;
00406 }
00407 }
00408 else if( (iterSP->second->IsCMchannel()) ) {
00409
00410 fRmsRawCM_h->Fill( (iterSP->second->GetRawRms()) );
00411 switch(gTruncType) {
00412 case 1:
00413 fRmsCM_h->Fill((iterSP->second->GetRmsT1()));
00414 break;
00415 case 2:
00416 fRmsCM_h->Fill((iterSP->second->GetRmsT2()));
00417 break;
00418 }
00419 }
00420 else {
00421
00422
00423 fRmsRawPMT_h->Fill( (iterSP->second->GetRawRms()) );
00424
00425 switch(gTruncType) {
00426 case 1:
00427 fRmsPMT_h->Fill( (iterSP->second->GetRmsT1()) );
00428
00429 fSparc_h->Fill( (iterSP->second->GetSparsLevelT1()) );
00430 break;
00431 case 2:
00432 fRmsPMT_h->Fill( (iterSP->second->GetRmsT2()) );
00433
00434 fSparc_h->Fill( (iterSP->second->GetSparsLevelT2()) );
00435 break;
00436 }
00437 }
00438
00439 const Int_t icrate = iterSP->second->GetCrate();
00440 const Int_t ivarc = iterSP->second->GetVarc();
00441 const Int_t ivmm = iterSP->second->GetVmm();
00442 const Int_t ivfb = iterSP->second->GetVfb();
00443 const Int_t iva = iterSP->second->GetVA();
00444 const Int_t ivach = iterSP->second->GetVAch();
00445
00446
00447 fMeanMap_h->Fill(6*3*2*icrate+6*2*ivarc+2*ivmm+ivfb,
00448 30*iva+ivach,
00449 (iterSP->second->GetRawMean()) );
00450 fRmsMap_h->Fill(6*3*2*icrate+6*2*ivarc+2*ivmm+ivfb,
00451 30*iva+ivach,
00452 (iterSP->second->GetRawRms()) );
00453
00454 fEntriesMap_h->Fill(6*3*2*icrate+6*2*ivarc+2*ivmm+ivfb,
00455 30*iva+ivach,
00456 (iterSP->second->GetEntries()) );
00457
00458
00459 switch(gTruncType) {
00460 case 1:
00461 fRmsMapT_h->Fill(6*3*2*icrate+6*2*ivarc+2*ivmm+ivfb,
00462 30*iva+ivach,
00463 (iterSP->second->GetRmsT1()) );
00464
00465 fDeltaMeanMapT_h->Fill(6*3*2*icrate+6*2*ivarc+2*ivmm+ivfb,
00466 30*iva+ivach,
00467 TMath::Abs(iterSP->second->GetRawMean()-iterSP->second->GetMeanT1()) );
00468 fDeltaRmsMapT_h->Fill(6*3*2*icrate+6*2*ivarc+2*ivmm+ivfb,
00469 30*iva+ivach,
00470 (iterSP->second->GetRawRms())-(iterSP->second->GetRmsT1()));
00471
00472 fSparcMap_h->Fill(6*3*2*icrate+6*2*ivarc+2*ivmm+ivfb,
00473 30*iva+ivach,
00474 (iterSP->second->GetSparsLevelT1()) );
00475 break;
00476 case 2:
00477 fRmsMapT_h->Fill(6*3*2*icrate+6*2*ivarc+2*ivmm+ivfb,
00478 30*iva+ivach,
00479 (iterSP->second->GetRmsT2()) );
00480
00481 fDeltaMeanMapT_h->Fill(6*3*2*icrate+6*2*ivarc+2*ivmm+ivfb,
00482 30*iva+ivach,
00483 TMath::Abs(iterSP->second->GetRawMean()-iterSP->second->GetMeanT2()) );
00484 fDeltaRmsMapT_h->Fill(6*3*2*icrate+6*2*ivarc+2*ivmm+ivfb,
00485 30*iva+ivach,
00486 (iterSP->second->GetRawRms())-(iterSP->second->GetRmsT2()) );
00487
00488 fSparcMap_h->Fill(6*3*2*icrate+6*2*ivarc+2*ivmm+ivfb,
00489 30*iva+ivach,
00490 (iterSP->second->GetSparsLevelT2()));
00491 break;
00492 }
00493
00494
00495 fErrorMap_h->Fill(6*3*2*icrate+6*2*ivarc+2*ivmm+ivfb,
00496 30*iva+ivach,
00497 iterSP->second->GetError());
00498
00499
00500 if(gDoOutliersAnalysis) {
00501
00502 const Int_t iplane = iterSP->second->GetPlane();
00503
00504 Int_t outliersNum = 0;
00505
00506 switch(gTruncType) {
00507 case 1:
00508 outliersNum = iterSP->second->GetEntries()-iterSP->second->GetEntriesT1();
00509 break;
00510 case 2:
00511 outliersNum = iterSP->second->GetEntries()-iterSP->second->GetEntriesT2();
00512 break;
00513 }
00514
00515
00516 fPerTrunc_h->Fill(outliersNum);
00517
00518
00519
00520 fOutMap_h->Fill(6*3*2*icrate+6*2*ivarc+2*ivmm+ivfb,
00521 30*iva+ivach,
00522 outliersNum);
00523
00524
00525 fOutDetMap_h->Fill(iplane,outliersNum);
00526
00527
00528 fTruncOccVA_h->Fill(ivach,outliersNum);
00529
00530
00531 fTruncOccCM_h->Fill(icrate,outliersNum);
00532
00533
00534 }
00535 iterSP++;
00536 }
00537 return;
00538 }
00539
00540
00541
00542 void SexyPedAna::OutputTables() {
00543
00544
00545 for(Int_t icrate = 0; icrate < SexyPedestal::CRATEMAX; icrate++) {
00546
00547 ofstream sparFile;
00548 ofstream pedFile;
00549
00550 if(gOutputSparsTable) {
00551 string sparFileName = "recentSparsifierTable_rop";
00552 sparFileName += Form("%i",icrate);
00553
00554
00555 sparFile.open(sparFileName.c_str(),ofstream::out );
00556 }
00557
00558
00559 if(gOutputPedestalTable) {
00560 string pedFileName = "recentPedTable_rop";
00561 pedFileName += Form("%i",icrate);
00562
00563
00564 pedFile.open(pedFileName.c_str(),ofstream::out );
00565 }
00566
00567 Int_t sparThreshold = -1;
00568 Int_t pedThreshold = -1;
00569
00570 for(Int_t ivarc = 0; ivarc < SexyPedestal::VARCMAX; ivarc++) {
00571 for(Int_t ivmm = 0; ivmm < SexyPedestal::VMMMAX; ivmm++) {
00572 for(Int_t ivfb = 0; ivfb < SexyPedestal::VFBMAX; ivfb++) {
00573 for(Int_t iva = 0; iva < SexyPedestal::VAMAX; iva++) {
00574 for(Int_t ivach = 0; ivach < SexyPedestal::VACHMAX; ivach++) {
00575
00576
00577 Int_t key = SexyPedestal::EncriptMeAKey(icrate,
00578 ivarc,
00579 ivmm,
00580 ivfb,
00581 iva,
00582 ivach);
00583
00584
00585 if( mySP.find(key) == mySP.end() ) {
00586
00587 MSG("SexyPedAna",Msg::kDebug) << "Empty Entry at:"
00588 << icrate
00589 << "-"
00590 << ivarc
00591 << "-"
00592 << ivmm
00593 << "-"
00594 << ivfb
00595 << "-"
00596 << iva
00597 << "-"
00598 << ivach
00599 << endl;
00600
00601
00602 sparThreshold = 16383;
00603 pedThreshold = 1;
00604 }
00605 else {
00606 switch(gTruncType) {
00607 case 1:
00608 sparThreshold = (Int_t) mySP[key]->GetSparsLevelT1();
00609 break;
00610 case 2:
00611 sparThreshold = (Int_t) mySP[key]->GetSparsLevelT2();
00612 break;
00613 }
00614
00615 if(mySP[key]->IsTPMTchannel()) sparThreshold = this->GetTPMTsparTh();
00616
00617
00618 if(mySP[key]->SparsifiedChannel()
00619 ||
00620 mySP[key]->IsCMchannel()) {
00621
00622 sparThreshold = 16383;
00623 pedThreshold = (Int_t) mySP[key]->GetRawMean();
00624 }
00625 }
00626
00627
00628 if(gOutputSparsTable) {
00629 if(gDebugTable && ivach==0) sparFile << icrate << "_"
00630 << ivarc <<"_"
00631 << ivmm <<"_"
00632 << ivfb <<"_"
00633 << iva <<">> ";
00634
00635
00636 sparFile << (Int_t) (sparThreshold) << " ";
00637 if(ivach == 21) sparFile << endl;
00638 }
00639
00640
00641 if(gOutputPedestalTable) {
00642 if(gDebugTable && ivach==0) pedFile << icrate << "_"
00643 << ivarc <<"_"
00644 << ivmm <<"_"
00645 << ivfb <<"_"
00646 << iva <<">> ";
00647
00648 pedFile << pedThreshold << " " ;
00649 if(ivach == 21) pedFile << endl;
00650 }
00651 }
00652 }
00653 }
00654 }
00655 }
00656
00657 if(gOutputSparsTable) sparFile.close();
00658 if(gOutputPedestalTable) pedFile.close();
00659 }
00660 return;
00661 }
00662
00663
00664
00665 void SexyPedAna::CompareDAQTables() {
00666
00667 if(gComparePedTable) {
00668 for(Int_t ientry = 0; ientry < fPedDAQTree->GetEntries(); ientry++) {
00669 Int_t suc = fPedDAQTree->GetEvent(ientry);
00670 if(suc<0) {
00671 MSG("SexyPedAna",Msg::kInfo) << "Failed: " << suc << "\t" << ientry << endl;
00672 continue;
00673 }
00674
00675 Int_t key = SexyPedestal::EncriptMeAKey(pedcrate,
00676 pedvarc,
00677 pedvmm,
00678 pedvfb,
00679 pedva,
00680 pedvach );
00681 Int_t pedSP = -1;
00682
00683 if(mySP[key]) pedSP = (Int_t)mySP[key]->GetRawMean();
00684 else pedSP = 1;
00685
00686 MSG("SexyPedAna",Msg::kInfo) << "PedComp: "
00687 << pedSP
00688 << "-"
00689 << pedadc
00690 << "-"
00691 << pedSP - pedadc
00692 << endl;
00693
00694 fDeltaMean_h->Fill(Int_t(pedSP - pedadc));
00695
00696 fDeltaCompMean_h->Fill(6*3*2*pedcrate+6*2*pedvarc+2*pedvmm+pedvfb,
00697 30*pedva+pedvach,
00698 Int_t(pedSP - pedadc));
00699
00700
00701 if(pedadc>1
00702 &&
00703
00704
00705 TMath::Abs(pedSP-pedadc)>gTolerancePedTable) {
00706
00707 fReportFile << "\tDiscrepacy between pedestal values > "
00708 << gTolerancePedTable
00709 << " ADCs." << endl
00710 << "\t\tmyPed-tablePed ("
00711 << pedSP << "-" << pedadc <<") =\t"
00712 << pedSP - pedadc
00713 << " @ "
00714 << pedcrate <<"_"
00715 << pedvarc <<"_"
00716 << pedvmm <<"_"
00717 << pedvfb <<"_"
00718 << pedva <<"_"
00719 << pedvach << endl;
00720 }
00721 }
00722 }
00723
00724 if(gCompareSparTable) {
00725 for(Int_t ientry = 0; ientry < fSparDAQTree->GetEntries(); ientry++) {
00726 Int_t suc = fSparDAQTree->GetEvent(ientry);
00727 if(suc<0) {
00728 MSG("SexyPedAna",Msg::kInfo) << "Failed: " << suc << "\t" << ientry << endl;
00729 continue;
00730 }
00731
00732 Int_t key = SexyPedestal::EncriptMeAKey(sparcrate,
00733 sparvarc,
00734 sparvmm,
00735 sparvfb,
00736 sparva,
00737 sparvach );
00738 Int_t sparThreshold = -1;
00739 Float_t rms = -1;
00740 if( mySP.find(key) == mySP.end() ) {
00741
00742 sparThreshold = 16383;
00743 rms = 0.5;
00744 }
00745 else {
00746
00747 if(mySP[key]->IsTPMTchannel()) {
00748 sparThreshold = this->GetTPMTsparTh();
00749 rms = 0.5;
00750 }
00751
00752 else if(mySP[key]->SparsifiedChannel()
00753 ||
00754 mySP[key]->IsCMchannel()) {
00755 sparThreshold = 16383;
00756 rms = 0.5;
00757 }
00758
00759 else {
00760 switch(gTruncType) {
00761 case 1:
00762 sparThreshold = (Int_t) mySP[key]->GetSparsLevelT1();
00763 rms = mySP[key]->GetRawRms();
00764 break;
00765 case 2:
00766 sparThreshold = (Int_t) mySP[key]->GetSparsLevelT2();
00767 rms = mySP[key]->GetRawRms();
00768 break;
00769 }
00770 }
00771 }
00772
00773 MSG("SexyPedAna",Msg::kInfo) << "SparComp: "
00774 << sparThreshold
00775 << "-"
00776 << sparadc
00777 << "-"
00778 << sparThreshold - sparadc
00779 << endl;
00780
00781 if(TMath::Abs(sparThreshold - sparadc) < 15000) {
00782
00783 fDeltaSparc_h->Fill(Int_t(sparThreshold-sparadc));
00784
00785 fDeltaSparcMap_h->Fill(6*3*2*sparcrate+6*2*sparvarc+2*sparvmm+sparvfb,
00786 30*sparva+sparvach,
00787 Int_t(sparThreshold-sparadc));
00788
00789 if( rms >0 && TMath::Abs(sparThreshold - sparadc) > gToleranceSparTable) {
00790
00791 fReportFile << "\tDiscrepacy between sparsification thresholds values > "
00792 << gToleranceSparTable
00793 << " ADCs." << endl
00794 << "\t\tmySparTh-tableSparTh ("
00795 << sparThreshold << "-" << sparadc <<") =\t"
00796 << sparThreshold - sparadc
00797 << " @ "
00798 << sparcrate <<"_"
00799 << sparvarc <<"_"
00800 << sparvmm <<"_"
00801 << sparvfb <<"_"
00802 << sparva <<"_"
00803 << sparvach << endl;
00804 }
00805 }
00806
00807 }
00808 }
00809 return;
00810 }
00811
00812
00813
00814
00815 void SexyPedAna::Report() {
00816
00817 fReportFile << endl
00818 << "Sparsification Thresholds Summaries: "
00819 << endl
00820 << endl
00821 << "\tFor PMTs truncated: " << fSparc_h->GetMean()
00822 << "+/_" << fSparc_h->GetRMS() << endl
00823
00824 << "\tFor PMTs non-truncated: " << fSparcRaw_h->GetMean()
00825 << "+/_" << fSparcRaw_h->GetRMS() << endl
00826
00827 << "\tFor LG PIN truncated: " << fSparcLGPIN_h->GetMean()
00828 << "+/_" << fSparcLGPIN_h->GetRMS() << endl
00829
00830 << "\tFor HG PIN truncated: " << fSparcHGPIN_h->GetMean()
00831 << "+/_" << fSparcHGPIN_h->GetRMS() << endl
00832 << endl;
00833
00834 return;
00835 }
00836
00837
00838
00839 void SexyPedAna::GetPlots() {
00840
00841
00842 fplotFile_c = new TCanvas("plotFile_c","",1200,800);
00843 TLegend* leg = new TLegend(0.4,0.6,0.89,0.89);
00844
00845 Int_t plotCounter = 1;
00846
00847 string bookName = "SexyPedPlots_";
00848 bookName += Form("t%i_s%i_%i.ps",gTruncType,gSparsFactor,frun);
00849
00850 string bookNameStart = bookName + "(";
00851 string bookNameEnd = bookName + ")";
00852
00853 string plotNameEps;
00854 string plotNameGif;
00855
00856
00857 if(gPlotEachPage) {
00858 plotNameGif = gSystem->pwd();
00859 plotNameGif += "SexyPedestalPlotsAll_";
00860 plotNameGif += Form("%i/",frun);
00861
00862 MSG("SexyPedAna",Msg::kInfo) << "Plots will be @ " << plotNameGif.c_str() << endl;
00863
00864 plotNameEps = plotNameGif;
00865
00866 Int_t suc = gSystem->MakeDirectory( plotNameGif.c_str() );
00867
00868 if(suc==-1) {
00869 MSG("SexyPedAna",Msg::kError) << endl << "ERROR: Directory could not be created" << endl << endl;
00870 gPlotEachPage = false;
00871 }
00872 }
00873
00874
00875
00876 fplotFile_c->cd();
00877 gPad->SetLogy(0);
00878 fMeanRaw_h->SetXTitle("Pedestal Means [ADC]");
00879 fMeanRaw_h->Draw();
00880 fplotFile_c->Update();
00881 fplotFile_c->Print(bookNameStart.c_str());
00882 if(gPlotEachPage) {
00883 plotNameGif += Form("SPplotAtPage%i.gif",plotCounter);
00884 plotNameEps += Form("SPplotAtPage%i.eps",plotCounter);
00885
00886 fplotFile_c->Print(plotNameGif.c_str());
00887 fplotFile_c->Print(plotNameEps.c_str());
00888 }
00889 MSG("SexyPedAna",Msg::kInfo) << "Included Page " << plotCounter << endl;
00890 plotCounter++;
00891 fplotFile_c->Clear();
00892
00893
00894 if(!gQuickPlots) {
00895
00896 fplotFile_c->cd();
00897 gPad->SetLogy(1);
00898 fRmsRaw_h->SetXTitle("Pedestal RMSs [ADC]");
00899 fRmsRaw_h->Draw();
00900 switch(gTruncType) {
00901 case 1:
00902 fRmsT1_h->SetLineColor(4);
00903 fRmsT1_h->Draw("same");
00904 break;
00905 case 2:
00906 fRmsT2_h->SetLineColor(4);
00907 fRmsT2_h->Draw("same");
00908 break;
00909 }
00910 fplotFile_c->Update();
00911 fplotFile_c->Print(bookName.c_str());
00912 if(gPlotEachPage) {
00913 plotNameGif += Form("SPplotAtPage%i.gif",plotCounter);
00914 plotNameEps += Form("SPplotAtPage%i.eps",plotCounter);
00915
00916 fplotFile_c->Print(plotNameGif.c_str());
00917 fplotFile_c->Print(plotNameEps.c_str());
00918 }
00919 MSG("SexyPedAna",Msg::kInfo) << "Included Page " << plotCounter << endl;
00920 plotCounter++;
00921 fplotFile_c->Clear();
00922 }
00923
00924
00925
00926 fplotFile_c->cd();
00927 gPad->SetLogy(1);
00928 fRmsRaw_h->SetStats(0);
00929 fRmsRaw_h->SetXTitle("Non-truncated Pedestal RMSs [ADC]");
00930 fRmsRaw_h->SetLineColor(1);
00931 fRmsRaw_h->Draw();
00932 fRmsRawPMT_h->SetLineColor(4);
00933 fRmsRawPMT_h->Draw("same");
00934 fRmsRawCM_h->SetLineColor(3);
00935 fRmsRawCM_h->Draw("same");
00936 fRmsRawPINLG_h->SetLineColor(6);
00937 fRmsRawPINLG_h->Draw("same");
00938 fRmsRawPINHG_h->SetLineColor(15);
00939 fRmsRawPINHG_h->Draw("same");
00940 leg->AddEntry(fRmsRaw_h,"All Channels","l");
00941 leg->AddEntry(fRmsRawPMT_h,"PMT Channels","l");
00942 leg->AddEntry(fRmsRawPINHG_h,"HIGH GAIN PINs","l");
00943 leg->AddEntry(fRmsRawPINLG_h,"LOW GAIN PINs","l");
00944 leg->AddEntry(fRmsRawCM_h,"CM Channels","l");
00945
00946 leg->Draw("same");
00947 fplotFile_c->Update();
00948 fplotFile_c->Print(bookName.c_str());
00949 if(gPlotEachPage) {
00950 plotNameGif += Form("SPplotAtPage%i.gif",plotCounter);
00951 plotNameEps += Form("SPplotAtPage%i.eps",plotCounter);
00952
00953 fplotFile_c->Print(plotNameGif.c_str());
00954 fplotFile_c->Print(plotNameEps.c_str());
00955 }
00956 MSG("SexyPedAna",Msg::kInfo) << "Included Page " << plotCounter << endl;
00957 plotCounter++;
00958 fplotFile_c->Clear();
00959
00960
00961
00962
00963 fplotFile_c->cd();
00964 gPad->SetLogy(1);
00965 switch (gTruncType) {
00966 case 1:
00967 fRmsT1_h->SetXTitle("Truncated Pedestal RMSs [ADC]");
00968 fRmsT1_h->SetLineColor(1);
00969 fRmsT1_h->SetStats(0);
00970 fRmsT1_h->Draw();
00971 break;
00972 case 2:
00973 fRmsT2_h->SetXTitle("Truncated Pedestal RMSs [ADC]");
00974 fRmsT2_h->SetLineColor(1);
00975 fRmsT2_h->SetStats(0);
00976 fRmsT2_h->Draw();
00977 break;
00978 }
00979 fRmsPMT_h->SetLineColor(4);
00980 fRmsPMT_h->Draw("same");
00981 fRmsCM_h->SetLineColor(3);
00982 fRmsCM_h->Draw("same");
00983 fRmsPINLG_h->SetLineColor(6);
00984 fRmsPINLG_h->Draw("same");
00985 fRmsPINHG_h->SetLineColor(15);
00986 fRmsPINHG_h->Draw("same");
00987 leg->Clear();
00988 switch (gTruncType) {
00989 case 1:
00990 leg->AddEntry(fRmsT1_h,"All Channels","l");
00991 break;
00992 case 2:
00993 leg->AddEntry(fRmsT2_h,"All Channels","l");
00994 break;
00995 }
00996 leg->AddEntry(fRmsPMT_h,"PMT Channels","l");
00997 leg->AddEntry(fRmsPINHG_h,"HIGH GAIN PINs","l");
00998 leg->AddEntry(fRmsPINLG_h,"LOW GAIN PINs","l");
00999 leg->AddEntry(fRmsCM_h,"CM Channels","l");
01000
01001 leg->Draw("same");
01002 fplotFile_c->Update();
01003 fplotFile_c->Print(bookName.c_str());
01004 if(gPlotEachPage) {
01005 plotNameGif += Form("SPplotAtPage%i.gif",plotCounter);
01006 plotNameEps += Form("SPplotAtPage%i.eps",plotCounter);
01007
01008 fplotFile_c->Print(plotNameGif.c_str());
01009 fplotFile_c->Print(plotNameEps.c_str());
01010
01011 }
01012 MSG("SexyPedAna",Msg::kInfo) << "Included Page " << plotCounter << endl;
01013 plotCounter++;
01014 fplotFile_c->Clear();
01015
01016
01017 if(!gQuickPlots) {
01018
01019 fplotFile_c->cd();
01020 gPad->SetLogy(1);
01021 fRmsRawPMT_h->SetXTitle("Truncated Pedestal RMSs [ADC]");
01022 fRmsRawPMT_h->SetLineColor(1);
01023 fRmsRawPMT_h->Draw();
01024 fRmsPMT_h->SetLineColor(4);
01025 fRmsPMT_h->Draw("sames");
01026 fplotFile_c->Update();
01027 fplotFile_c->Print(bookName.c_str());
01028 if(gPlotEachPage) {
01029 plotNameGif += Form("SPplotAtPage%i.gif",plotCounter);
01030 plotNameEps += Form("SPplotAtPage%i.eps",plotCounter);
01031
01032 fplotFile_c->Print(plotNameGif.c_str());
01033 fplotFile_c->Print(plotNameEps.c_str());
01034 }
01035 MSG("SexyPedAna",Msg::kInfo) << "Included Page " << plotCounter << endl;
01036 plotCounter++;
01037 fplotFile_c->Clear();
01038
01039
01040
01041 fplotFile_c->cd();
01042 gPad->SetLogy(0);
01043 fRmsRawPINLG_h->SetXTitle("Truncated Pedestal RMSs [ADC]");
01044 fRmsRawPINLG_h->SetLineColor(1);
01045 fRmsRawPINLG_h->Draw();
01046 fRmsPINLG_h->SetLineColor(4);
01047 fRmsPINLG_h->Draw("sames");
01048 fplotFile_c->Update();
01049 fplotFile_c->Print(bookName.c_str());
01050 if(gPlotEachPage) {
01051 plotNameGif += Form("SPplotAtPage%i.gif",plotCounter);
01052 plotNameEps += Form("SPplotAtPage%i.eps",plotCounter);
01053
01054 fplotFile_c->Print(plotNameGif.c_str());
01055 fplotFile_c->Print(plotNameEps.c_str());
01056 }
01057 MSG("SexyPedAna",Msg::kInfo) << "Included Page " << plotCounter << endl;
01058 plotCounter++;
01059 fplotFile_c->Clear();
01060
01061
01062 fplotFile_c->cd();
01063 gPad->SetLogy(0);
01064 fRmsRawPINHG_h->SetXTitle("Truncated Pedestal RMSs [ADC]");
01065 fRmsRawPINHG_h->SetLineColor(1);
01066 fRmsRawPINHG_h->Draw();
01067 fRmsPINHG_h->SetLineColor(4);
01068 fRmsPINHG_h->Draw("sames");
01069 fplotFile_c->Update();
01070 fplotFile_c->Print(bookName.c_str());
01071 if(gPlotEachPage) {
01072 plotNameGif += Form("SPplotAtPage%i.gif",plotCounter);
01073 plotNameEps += Form("SPplotAtPage%i.eps",plotCounter);
01074
01075 fplotFile_c->Print(plotNameGif.c_str());
01076 fplotFile_c->Print(plotNameEps.c_str());
01077 }
01078 MSG("SexyPedAna",Msg::kInfo) << "Included Page " << plotCounter << endl;
01079 plotCounter++;
01080 fplotFile_c->Clear();
01081
01082
01083 fplotFile_c->cd();
01084 gPad->SetLogy(1);
01085 fRmsRawCM_h->SetXTitle("Truncated Pedestal RMSs [ADC]");
01086 fRmsRawCM_h->SetLineColor(1);
01087 fRmsRawCM_h->SetMinimum(.5);
01088 fRmsRawCM_h->Draw();
01089 fRmsCM_h->SetLineColor(4);
01090 fRmsCM_h->Draw("sames");
01091 fplotFile_c->Update();
01092 fplotFile_c->Print(bookName.c_str());
01093 if(gPlotEachPage) {
01094 plotNameGif += Form("SPplotAtPage%i.gif",plotCounter);
01095 plotNameEps += Form("SPplotAtPage%i.eps",plotCounter);
01096
01097 fplotFile_c->Print(plotNameGif.c_str());
01098 fplotFile_c->Print(plotNameEps.c_str());
01099 }
01100 MSG("SexyPedAna",Msg::kInfo) << "Included Page " << plotCounter << endl;
01101 plotCounter++;
01102 fplotFile_c->Clear();
01103
01104
01105
01106
01107
01108
01109
01110
01111 fplotFile_c->Clear();
01112 gPad->SetLogz(1);
01113 gPad->SetLogy(0);
01114 gPad->SetLogx(0);
01115
01116 fMeanMap_h->SetStats(0);
01117 fMeanMap_h->Draw("colz");
01118 for(Int_t icrate = 0; icrate < SexyPedestal::CRATEMAX; icrate++)
01119 for(Int_t ivarc = 0; ivarc < SexyPedestal::VARCMAX; ivarc++)
01120 fLines[icrate][ivarc]->Draw("same");
01121 fplotFile_c->Update();
01122 fplotFile_c->Print(bookName.c_str());
01123 if(gPlotEachPage) {
01124 plotNameGif += Form("SPplotAtPage%i.gif",plotCounter);
01125 plotNameEps += Form("SPplotAtPage%i.eps",plotCounter);
01126
01127 fplotFile_c->Print(plotNameGif.c_str());
01128 fplotFile_c->Print(plotNameEps.c_str());
01129 }
01130 MSG("SexyPedAna",Msg::kInfo) << "Included Page " << plotCounter << endl;
01131 plotCounter++;
01132 fplotFile_c->Clear();
01133 }
01134
01135
01136
01137 fplotFile_c->Clear();
01138 gPad->SetLogy(0);
01139 gPad->SetLogx(0);
01140 gPad->SetLogz(0);
01141 fDeltaMeanMapT_h->SetStats(0);
01142 fDeltaMeanMapT_h->SetMinimum(0.1);
01143 fDeltaMeanMapT_h->Draw("colz");
01144 for(Int_t icrate = 0; icrate < SexyPedestal::CRATEMAX; icrate++)
01145 for(Int_t ivarc = 0; ivarc < SexyPedestal::VARCMAX; ivarc++)
01146 fLines[icrate][ivarc]->Draw("same");
01147 fplotFile_c->Update();
01148 fplotFile_c->Print(bookName.c_str());
01149 if(gPlotEachPage) {
01150 plotNameGif += Form("SPplotAtPage%i.gif",plotCounter);
01151 plotNameEps += Form("SPplotAtPage%i.eps",plotCounter);
01152
01153 fplotFile_c->Print(plotNameGif.c_str());
01154 fplotFile_c->Print(plotNameEps.c_str());
01155 }
01156 MSG("SexyPedAna",Msg::kInfo) << "Included Page " << plotCounter << endl;
01157 plotCounter++;
01158 fplotFile_c->Clear();
01159
01160
01161 if(!gQuickPlots) {
01162
01163 fplotFile_c->Clear();
01164 gPad->SetLogy(0);
01165 gPad->SetLogx(0);
01166 gPad->SetLogz(0);
01167
01168 fRmsMap_h->SetMaximum(25);
01169 fRmsMap_h->SetStats(0);
01170 fRmsMap_h->Draw("colz");
01171 for(Int_t icrate = 0; icrate < SexyPedestal::CRATEMAX; icrate++)
01172 for(Int_t ivarc = 0; ivarc < SexyPedestal::VARCMAX; ivarc++)
01173 fLines[icrate][ivarc]->Draw("same");
01174 fplotFile_c->Update();
01175 fplotFile_c->Print(bookName.c_str());
01176 if(gPlotEachPage) {
01177 plotNameGif += Form("SPplotAtPage%i.gif",plotCounter);
01178 plotNameEps += Form("SPplotAtPage%i.eps",plotCounter);
01179
01180 fplotFile_c->Print(plotNameGif.c_str());
01181 fplotFile_c->Print(plotNameEps.c_str());
01182 }
01183 MSG("SexyPedAna",Msg::kInfo) << "Included Page " << plotCounter << endl;
01184 plotCounter++;
01185 fplotFile_c->Clear();
01186 }
01187
01188
01189
01190 fplotFile_c->Clear();
01191 gPad->SetLogy(0);
01192 gPad->SetLogx(0);
01193 gPad->SetLogz(0);
01194
01195
01196 fRmsMapT_h->SetStats(0);
01197 fRmsMapT_h->Draw("colz");
01198 for(Int_t icrate = 0; icrate < SexyPedestal::CRATEMAX; icrate++)
01199 for(Int_t ivarc = 0; ivarc < SexyPedestal::VARCMAX; ivarc++)
01200 fLines[icrate][ivarc]->Draw("same");
01201 fplotFile_c->Update();
01202 fplotFile_c->Print(bookName.c_str());
01203 if(gPlotEachPage) {
01204 plotNameGif += Form("SPplotAtPage%i.gif",plotCounter);
01205 plotNameEps += Form("SPplotAtPage%i.eps",plotCounter);
01206
01207 fplotFile_c->Print(plotNameGif.c_str());
01208 fplotFile_c->Print(plotNameEps.c_str());
01209 }
01210 MSG("SexyPedAna",Msg::kInfo) << "Included Page " << plotCounter << endl;
01211 plotCounter++;
01212 fplotFile_c->Clear();
01213
01214
01215
01216 fplotFile_c->Clear();
01217 gPad->SetLogy(0);
01218 gPad->SetLogx(0);
01219 gPad->SetLogz(0);
01220 fDeltaRmsMapT_h->SetStats(0);
01221 fDeltaRmsMapT_h->Draw("colz");
01222 for(Int_t icrate = 0; icrate < SexyPedestal::CRATEMAX; icrate++)
01223 for(Int_t ivarc = 0; ivarc < SexyPedestal::VARCMAX; ivarc++)
01224 fLines[icrate][ivarc]->Draw("same");
01225 fplotFile_c->Update();
01226 fplotFile_c->Print(bookName.c_str());
01227 if(gPlotEachPage) {
01228 plotNameGif += Form("SPplotAtPage%i.gif",plotCounter);
01229 plotNameEps += Form("SPplotAtPage%i.eps",plotCounter);
01230
01231 fplotFile_c->Print(plotNameGif.c_str());
01232 fplotFile_c->Print(plotNameEps.c_str());
01233 }
01234 MSG("SexyPedAna",Msg::kInfo) << "Included Page " << plotCounter << endl;
01235 plotCounter++;
01236 fplotFile_c->Clear();
01237
01238
01239 if(!gQuickPlots) {
01240
01241 fplotFile_c->Clear();
01242 gPad->SetLogy(0);
01243 gPad->SetLogx(0);
01244 gPad->SetLogz(0);
01245 fEntriesMap_h->SetStats(0);
01246 fEntriesMap_h->Draw("colz");
01247 for(Int_t icrate = 0; icrate < SexyPedestal::CRATEMAX; icrate++)
01248 for(Int_t ivarc = 0; ivarc < SexyPedestal::VARCMAX; ivarc++)
01249 fLines[icrate][ivarc]->Draw("same");
01250 fplotFile_c->Update();
01251 fplotFile_c->Print(bookName.c_str());
01252 if(gPlotEachPage) {
01253 plotNameGif += Form("SPplotAtPage%i.gif",plotCounter);
01254 plotNameEps += Form("SPplotAtPage%i.eps",plotCounter);
01255
01256 fplotFile_c->Print(plotNameGif.c_str());
01257 fplotFile_c->Print(plotNameEps.c_str());
01258 }
01259 MSG("SexyPedAna",Msg::kInfo) << "Included Page " << plotCounter << endl;
01260 plotCounter++;
01261
01262
01263
01264 fplotFile_c->Clear();
01265 fplotFile_c->Clear();
01266 gPad->SetLogy(0);
01267 gPad->SetLogx(0);
01268 gPad->SetLogz(0);
01269 fErrorMap_h->SetStats(0);
01270 fErrorMap_h->Draw("colz");
01271 for(Int_t icrate = 0; icrate < SexyPedestal::CRATEMAX; icrate++)
01272 for(Int_t ivarc = 0; ivarc < SexyPedestal::VARCMAX; ivarc++)
01273 fLines[icrate][ivarc]->Draw("same");
01274 fplotFile_c->Update();
01275 fplotFile_c->Print(bookName.c_str());
01276 if(gPlotEachPage) {
01277 plotNameGif += Form("SPplotAtPage%i.gif",plotCounter);
01278 plotNameEps += Form("SPplotAtPage%i.eps",plotCounter);
01279
01280 fplotFile_c->Print(plotNameGif.c_str());
01281 fplotFile_c->Print(plotNameEps.c_str());
01282 }
01283 MSG("SexyPedAna",Msg::kInfo) << "Included Page " << plotCounter << endl;
01284 plotCounter++;
01285 fplotFile_c->Clear();
01286 }
01287
01288
01289
01290 string histName;
01291 histName = "Sparsification Thresholds Histograms";
01292 histName += Form(" (%i Sigmas)",SexyPedestal::GetSparsFactor());
01293 histName += Form(" - Run %i",frun);
01294
01295 fplotFile_c->cd();
01296 gPad->SetLogy(1);
01297 fSparcRaw_h->SetXTitle("ADC Counts");
01298 fSparcRaw_h->SetTitle(histName.c_str());
01299 fSparcRaw_h->SetStats(0);
01300 fSparcRaw_h->SetLineStyle(3);
01301 fSparcRaw_h->Draw();
01302 fSparc_h->SetLineColor(4);
01303 fSparc_h->Draw("same");
01304 fSparcLGPIN_h->SetLineColor(6);
01305 fSparcLGPIN_h->Draw("same");
01306 fSparcHGPIN_h->SetLineColor(15);
01307 fSparcHGPIN_h->Draw("same");
01308 leg->Clear();
01309 leg->AddEntry(fSparcRaw_h,"No Truncation","l");
01310 leg->AddEntry(fSparc_h,"PMT Channels","l");
01311 leg->AddEntry(fSparcHGPIN_h,"HIGH GAIN PINs","l");
01312 leg->AddEntry(fSparcLGPIN_h,"LOW GAIN PINs","l");
01313
01314 leg->Draw("same");
01315 fplotFile_c->Update();
01316
01317 if(!gQuickPlots) fplotFile_c->Print(bookName.c_str());
01318 else fplotFile_c->Print("LastSparsificationTable.eps");
01319
01320 if(gPlotEachPage) {
01321 plotNameGif += Form("SPplotAtPage%i.gif",plotCounter);
01322 plotNameEps += Form("SPplotAtPage%i.eps",plotCounter);
01323
01324 fplotFile_c->Print(plotNameGif.c_str());
01325 fplotFile_c->Print(plotNameEps.c_str());
01326 }
01327 MSG("SexyPedAna",Msg::kInfo) << "Included Page " << plotCounter << endl;
01328 plotCounter++;
01329 fplotFile_c->Clear();
01330
01331
01332 if(!gQuickPlots) {
01333
01334 fplotFile_c->Clear();
01335 gPad->SetLogy(0);
01336 gPad->SetLogx(0);
01337 gPad->SetLogz(0);
01338 fSparcMap_h->SetStats(0);
01339
01340 fSparcMap_h->Draw("colz");
01341 for(Int_t icrate = 0; icrate < SexyPedestal::CRATEMAX; icrate++)
01342 for(Int_t ivarc = 0; ivarc < SexyPedestal::VARCMAX; ivarc++)
01343 fLines[icrate][ivarc]->Draw("same");
01344 fplotFile_c->Update();
01345 fplotFile_c->Print(bookName.c_str());
01346 if(gPlotEachPage) {
01347 plotNameGif += Form("SPplotAtPage%i.gif",plotCounter);
01348 plotNameEps += Form("SPplotAtPage%i.eps",plotCounter);
01349
01350 fplotFile_c->Print(plotNameGif.c_str());
01351 fplotFile_c->Print(plotNameEps.c_str());
01352 }
01353 MSG("SexyPedAna",Msg::kInfo) << "Included Page " << plotCounter << endl;
01354 plotCounter++;
01355 fplotFile_c->Clear();
01356 }
01357
01358
01359
01360
01361
01362
01363 if(!gQuickPlots) {
01364
01365
01366 fplotFile_c->cd();
01367 gPad->SetLogy(1);
01368 fPerTrunc_h->SetXTitle("# of Outliers Per Channel");
01369 fPerTrunc_h->SetMinimum(0.5);
01370 fPerTrunc_h->Draw();
01371 fplotFile_c->Update();
01372 fplotFile_c->Print(bookName.c_str());
01373 if(gPlotEachPage) {
01374 plotNameGif += Form("SPplotAtPage%i.gif",plotCounter);
01375 plotNameEps += Form("SPplotAtPage%i.eps",plotCounter);
01376
01377 fplotFile_c->Print(plotNameGif.c_str());
01378 fplotFile_c->Print(plotNameEps.c_str());
01379 }
01380 MSG("SexyPedAna",Msg::kInfo) << "Included Page " << plotCounter << endl;
01381 plotCounter++;
01382 fplotFile_c->Clear();
01383
01384
01385
01386 fplotFile_c->cd();
01387 gPad->SetLogy(0);
01388 fTruncOccCM_h->SetXTitle("Crate#");
01389 fTruncOccCM_h->Draw();
01390 fplotFile_c->Update();
01391 fplotFile_c->Print(bookName.c_str());
01392 if(gPlotEachPage) {
01393
01394 plotNameGif += Form("SPplotAtPage%i.gif",plotCounter);
01395 plotNameEps += Form("SPplotAtPage%i.eps",plotCounter);
01396
01397 fplotFile_c->Print(plotNameGif.c_str());
01398 fplotFile_c->Print(plotNameEps.c_str());
01399 }
01400 MSG("SexyPedAna",Msg::kInfo) << "Included Page " << plotCounter << endl;
01401 plotCounter++;
01402 fplotFile_c->Clear();
01403
01404
01405
01406 fplotFile_c->cd();
01407 gPad->SetLogy(0);
01408 fTruncOccVA_h->SetXTitle("VA Chip Channels");
01409 fTruncOccVA_h->Draw();
01410 fplotFile_c->Update();
01411 fplotFile_c->Print(bookName.c_str());
01412 if(gPlotEachPage) {
01413 plotNameGif += Form("SPplotAtPage%i.gif",plotCounter);
01414 plotNameEps += Form("SPplotAtPage%i.eps",plotCounter);
01415
01416 fplotFile_c->Print(plotNameGif.c_str());
01417 fplotFile_c->Print(plotNameEps.c_str());
01418 }
01419 MSG("SexyPedAna",Msg::kInfo) << "Included Page " << plotCounter << endl;
01420 plotCounter++;
01421 fplotFile_c->Clear();
01422
01423
01424
01425 fplotFile_c->cd();
01426 gPad->SetLogy(0);
01427 fOutDetMap_h->SetXTitle("Plane#");
01428 fOutDetMap_h->SetTitle("Plane Occupancy of Outliers");
01429 fOutDetMap_h->Draw();
01430 fplotFile_c->Update();
01431 fplotFile_c->Print(bookName.c_str());
01432 if(gPlotEachPage) {
01433 plotNameGif += Form("SPplotAtPage%i.gif",plotCounter);
01434 plotNameEps += Form("SPplotAtPage%i.eps",plotCounter);
01435
01436 fplotFile_c->Print(plotNameGif.c_str());
01437 fplotFile_c->Print(plotNameEps.c_str());
01438 }
01439 MSG("SexyPedAna",Msg::kInfo) << "Included Page " << plotCounter << endl;
01440 plotCounter++;
01441 fplotFile_c->Clear();
01442
01443
01444
01445 fplotFile_c->cd();
01446 gPad->SetLogy(0);
01447 gPad->SetLogx(0);
01448 gPad->SetLogz(0);
01449 fOutMap_h->SetMaximum(15);
01450 fOutMap_h->SetStats(0);
01451 fOutMap_h->Draw("colz");
01452 for(Int_t icrate = 0; icrate < SexyPedestal::CRATEMAX; icrate++)
01453 for(Int_t ivarc = 0; ivarc < SexyPedestal::VARCMAX; ivarc++)
01454 fLines[icrate][ivarc]->Draw("same");
01455 fplotFile_c->Update();
01456 fplotFile_c->Print(bookName.c_str());
01457 if(gPlotEachPage) {
01458 plotNameGif += Form("SPplotAtPage%i.gif",plotCounter);
01459 plotNameEps += Form("SPplotAtPage%i.eps",plotCounter);
01460
01461 fplotFile_c->Print(plotNameGif.c_str());
01462 fplotFile_c->Print(plotNameEps.c_str());
01463 }
01464 MSG("SexyPedAna",Msg::kInfo) << "Included Page " << plotCounter << endl;
01465 plotCounter++;
01466 fplotFile_c->Clear();
01467 }
01468
01469
01470
01471
01472
01473
01474
01475 if(!gQuickPlots) {
01476 if(gCompareSparTable) {
01477
01478
01479 fplotFile_c->Clear();
01480 gPad->SetLogx(0);
01481 gPad->SetLogy(0);
01482 fDeltaMean_h->SetStats(1);
01483 fDeltaMean_h->Draw();
01484 fplotFile_c->Update();
01485 fplotFile_c->Print(bookName.c_str());
01486 if(gPlotEachPage) {
01487 plotNameGif += Form("SPplotAtPage%i.gif",plotCounter);
01488 plotNameEps += Form("SPplotAtPage%i.eps",plotCounter);
01489
01490 fplotFile_c->Print(plotNameGif.c_str());
01491 fplotFile_c->Print(plotNameEps.c_str());
01492 }
01493 MSG("SexyPedAna",Msg::kInfo) << "Included Page " << plotCounter << endl;
01494 plotCounter++;
01495 fplotFile_c->Clear();
01496
01497
01498 fplotFile_c->Clear();
01499 gPad->SetLogz(0);
01500 gPad->SetLogx(0);
01501 gPad->SetLogy(0);
01502 fDeltaCompMean_h->SetStats(0);
01503 fDeltaCompMean_h->Draw("colz");
01504 for(Int_t icrate = 0; icrate < SexyPedestal::CRATEMAX; icrate++)
01505 for(Int_t ivarc = 0; ivarc < SexyPedestal::VARCMAX; ivarc++)
01506 fLines[icrate][ivarc]->Draw("same");
01507 fplotFile_c->Update();
01508 fplotFile_c->Print(bookName.c_str());
01509 if(gPlotEachPage) {
01510 plotNameGif += Form("SPplotAtPage%i.gif",plotCounter);
01511 plotNameEps += Form("SPplotAtPage%i.eps",plotCounter);
01512
01513 fplotFile_c->Print(plotNameGif.c_str());
01514 fplotFile_c->Print(plotNameEps.c_str());
01515 }
01516 MSG("SexyPedAna",Msg::kInfo) << "Included Page " << plotCounter << endl;
01517 plotCounter++;
01518 fplotFile_c->Clear();
01519
01520
01521 fplotFile_c->Clear();
01522 gPad->SetLogy(1);
01523 fDeltaSparc_h->SetStats(1);
01524 fDeltaSparc_h->Draw();
01525 fplotFile_c->Update();
01526 fplotFile_c->Print(bookName.c_str());
01527 if(gPlotEachPage) {
01528 plotNameGif += Form("SPplotAtPage%i.gif",plotCounter);
01529 plotNameEps += Form("SPplotAtPage%i.eps",plotCounter);
01530
01531 fplotFile_c->Print(plotNameGif.c_str());
01532 fplotFile_c->Print(plotNameEps.c_str());
01533 }
01534 MSG("SexyPedAna",Msg::kInfo) << "Included Page " << plotCounter << endl;
01535 plotCounter++;
01536 fplotFile_c->Clear();
01537
01538
01539 fplotFile_c->Clear();
01540 gPad->SetLogz(0);
01541 gPad->SetLogx(0);
01542 gPad->SetLogy(0);
01543 fDeltaSparcMap_h->SetStats(0);
01544
01545
01546 fDeltaSparcMap_h->Draw("colz");
01547 for(Int_t icrate = 0; icrate < SexyPedestal::CRATEMAX; icrate++)
01548 for(Int_t ivarc = 0; ivarc < SexyPedestal::VARCMAX; ivarc++)
01549 fLines[icrate][ivarc]->Draw("same");
01550 fplotFile_c->Update();
01551 fplotFile_c->Print(bookName.c_str());
01552 if(gPlotEachPage) {
01553 plotNameGif += Form("SPplotAtPage%i.gif",plotCounter);
01554 plotNameEps += Form("SPplotAtPage%i.eps",plotCounter);
01555
01556 fplotFile_c->Print(plotNameGif.c_str());
01557 fplotFile_c->Print(plotNameEps.c_str());
01558 }
01559 MSG("SexyPedAna",Msg::kInfo) << "Included Page " << plotCounter << endl;
01560 plotCounter++;
01561 fplotFile_c->Clear();
01562 }
01563 }
01564
01565
01566 fplotFile_c->Clear();
01567 fplotFile_c->Update();
01568 fplotFile_c->Print(bookNameEnd.c_str());
01569 fplotFile_c->Clear();
01570
01571 MSG("SexyPedAna",Msg::kInfo) << "All Plots are done!" << endl;
01572
01573 delete fplotFile_c;
01574 }
01575
01576
01577
01578
01579
01580
01581
01582
01583
01584 Float_t SexyPedAna::FindFirstBin( const TH1* histogram ) {
01585
01586 Int_t lowestBin = 0;
01587 Int_t allBin = histogram->GetNbinsX();
01588
01589 for (Int_t iBin = 1; iBin <= allBin; iBin++) {
01590 if ( histogram->GetBinContent( iBin ) > 0 ) {
01591 lowestBin = iBin;
01592 break;
01593 }
01594 }
01595 return histogram->GetBinCenter( lowestBin );
01596 }
01597
01598
01599
01600
01601
01602 Float_t SexyPedAna::FindLastBin( const TH1* histogram ) {
01603
01604 Int_t allBin = histogram->GetNbinsX();
01605 Int_t highestBin = allBin;
01606
01607 for (Int_t iBin = allBin; iBin >= 1; iBin--) {
01608 if( histogram->GetBinContent( iBin ) > 0 ) {
01609 highestBin = iBin;
01610 break;
01611 }
01612 }
01613 return histogram->GetBinCenter( highestBin );
01614 }
01615
01616
01617
01618 void SexyPedAna::InitAnaVariables() {
01619
01620
01621 fMeanT1_h = new TH1F("fMeanT1_h","Distribution of the Pedestals's Means",600,0,1200);
01622 fRmsT1_h = new TH1F("fRmsT1_h", "Distribution of the Pedestals's RMSs (ALL channels)", 31,-0.5,30.5);
01623
01624 fMeanT2_h = new TH1F("fMeanT2_h","Distribution of the Pedestals's Means",600,0,1200);
01625 fRmsT2_h = new TH1F("fRmsT2_h", "Distribution of the Pedestals's RMSs (ALL channels)", 31,-0.5,30.5);
01626
01627 fMeanRaw_h = new TH1F("fMeanRaw_h","Distribution of the Pedestals's Means",600,0,1200);
01628 fRmsRaw_h = new TH1F("fRmsRaw_h", "Distribution of the Pedestals's RMSs (ALL channels)", 51,-0.5,50.5);
01629
01630 fRmsPMT_h = new TH1F("fRmsPMT_h", "Distribution of the Pedestals's RMSs (PMT channels)", 31,-0.5,30.5);
01631 fRmsCM_h = new TH1F("fRmsCM_h", "Distribution of the Pedestals's RMSs (CM channels)", 31,-0.5,30.5);
01632 fRmsPINLG_h = new TH1F("fRmsPINLG_h", "Distribution of the Pedestals's RMSs (LG PIN)", 31,-0.5,30.5);
01633 fRmsPINHG_h = new TH1F("fRmsPINHG_h", "Distribution of the Pedestals's RMSs (HG PIN)", 31,-0.5,30.5);
01634
01635 fRmsRawPMT_h = new TH1F("fRmsRawPMT_h", "Distribution of the Pedestals's RMSs (PMT channels)", 51,-0.5,50.5);
01636 fRmsRawCM_h = new TH1F("fRmsRawCM_h", "Distribution of the Pedestals's RMSs (CM channels)", 31,-0.5,30.5);
01637 fRmsRawPINLG_h = new TH1F("fRmsRawPINLG_h", "Distribution of the Pedestals's RMSs (LG PIN)", 31,-0.5,30.5);
01638 fRmsRawPINHG_h = new TH1F("fRmsRawPINHG_h", "Distribution of the Pedestals's RMSs (HG PIN)", 31,-0.5,30.5);
01639
01640
01641 fTruncOcc_h = new TH1F("fTruncOcc_h", "Pedestal Occupancy",15,0,15);
01642 fTruncOccCM_h = new TH1F("fTruncOccCM1_h","Truncated Outliers Occupancy wrt Crate#",16,0,16);
01643 fTruncOccVA_h = new TH1F("fTruncOccVA1_h","Truncated Outliers Occupancy wrt VA-channel#",22,0,22);
01644 fPerTrunc_h = new TH1F("fPerTrunc_h", "Truncated Outliers Multiplicity Per Channel", 15,0,15);
01645 fOutDetMap_h = new TH1F("fOutDetMap_h", "Truncated Outliers Occupancy wrt Plane#", 125,0,500);
01646
01647
01648 fMeanMap_h = new TH2S("fMeanMap_h","Mapping of the MEAN per Channels without Truncation",576,0,576,90,0,90);
01649 fMeanMap_h->SetXTitle("3x6x2xCrate# + 6x2xVARC# + 2xVMM# + VFB#");
01650 fMeanMap_h->SetYTitle("22xVA-chip# + VA-chip-Channel#");
01651
01652 fRmsMap_h = new TH2S("fRmsMap_h", "Mapping of the RMS (no Truncation) {if RMS < 25}",576,0,576,90,0,90);
01653 fRmsMap_h->SetXTitle("3x6x2xCrate# + 6x2xVARC# + 2xVMM# + VFB#");
01654 fRmsMap_h->SetYTitle("22xVA-chip# + VA-chip-Channel#");
01655
01656 fRmsMapT_h = new TH2S("fRmsMapT_h", "Mapping of the RMS (truncated)",576,0,576,90,0,90);
01657 fRmsMapT_h->SetXTitle("3x6x2xCrate# + 6x2xVARC# + 2xVMM# + VFB#");
01658 fRmsMapT_h->SetYTitle("22xVA-chip# + VA-chip-Channel#");
01659
01660 fOutMap_h = new TH2S("fOutMap_h","Map of Outliers Occupancy",576,0,576,90,0,90);
01661 fOutMap_h->SetXTitle("3x6x2xCrate# + 6x2xVARC# + 2xVMM# + VFB#");
01662 fOutMap_h->SetYTitle("22xVA-chip# + VA-chip-Channel#");
01663
01664 fEntriesMap_h = new TH2S("fEntriesMap_h",
01665 "Mapping of the number of triggers per Channels (no truncation)",
01666 576,0,576,90,0,90);
01667 fEntriesMap_h->SetXTitle("3x6x2xCrate# + 6x2xVARC# + 2xVMM# + VFB#");
01668 fEntriesMap_h->SetYTitle("22xVA-chip# + VA-chip-Channel#");
01669
01670 fSparcMap_h = new TH2S("fSparcMap_h",
01671 "Mapping of the Sparsification Threshold per Channels with Truncation",
01672 576,0,576,90,0,90);
01673 fSparcMap_h->SetXTitle("3x6x2xCrate# + 6x2xVARC# + 2xVMM# + VFB#");
01674 fSparcMap_h->SetYTitle("22xVA-chip# + VA-chip-Channel#");
01675
01676 fDeltaSparcMap_h= new TH2S("fDeltaSparcMap_h",
01677 "Mapping of the Sparsification Threshold Variation ('MyValues'-'TableValues')",
01678 576,0,576,90,0,90);
01679 fDeltaSparcMap_h->SetXTitle("3x6x2xCrate# + 6x2xVARC# + 2xVMM# + VFB#");
01680 fDeltaSparcMap_h->SetYTitle("22xVA-chip# + VA-chip-Channel#");
01681
01682 fDeltaMeanMapT_h = new TH2S("fDeltaMeanMapT_h",
01683 "Effect of truncation on the MEAN {Mean(non-truncated) - MEAN(truncated)}",
01684 576,0,576,90,0,90);
01685 fDeltaMeanMapT_h->SetXTitle("3x6x2xCrate# + 6x2xVARC# + 2xVMM# + VFB#");
01686 fDeltaMeanMapT_h->SetYTitle("22xVA-chip# + VA-chip-Channel#");
01687
01688
01689 fSparc_h = new TH1F("fSparc_h","",95,0,95);
01690 fSparcRaw_h = new TH1F("fSparcRaw_h","",95,0,95);
01691 fSparcLGPIN_h = new TH1F("fSparcLGPIN_h","",95,0,95);
01692 fSparcHGPIN_h = new TH1F("fSparcHGPIN_h","",95,0,95);
01693
01694
01695 for(Int_t icrate = 0; icrate < SexyPedestal::CRATEMAX; icrate++) {
01696 for(Int_t ivarc = 0; ivarc < SexyPedestal::VARCMAX; ivarc++) {
01697
01698 fLines[icrate][ivarc] = new TLine(3*6*2*icrate+6*2*ivarc,0,
01699 3*6*2*icrate+6*2*ivarc,90);
01700
01701 fLines[icrate][ivarc]->SetLineColor(6);
01702 fLines[icrate][ivarc]->SetLineWidth(2);
01703 fLines[icrate][ivarc]->SetLineStyle(3);
01704 }
01705 }
01706
01707
01708
01709
01710
01711
01712 fDeltaMean_h = new TH1F("fDeltaMean_h",
01713 "Difference between SexyPedestal Table and online Tables MEANs",10,-5,5);
01714 fDeltaMean_h->SetXTitle("#Delta MEAN('SexyPedestalValues'-'OnlineTablesValues')");
01715
01716 fDeltaCompMean_h = new TH2S("fDeltaCompMean_h",
01717 "Difference between SexyPedestal Table and online Table MEANs",
01718 576,0,576,90,0,90);
01719 fDeltaCompMean_h->SetXTitle("3x6x2xCrate# + 6x2xVARC# + 2xVMM# + VFB#");
01720 fDeltaCompMean_h->SetYTitle("22xVA-chip# + VA-chip-Channel#");
01721
01722
01723
01724
01725 fDeltaSparc_h = new TH1F("fDeltaSparc_h",
01726 "Difference between SexyPedestal Table and online Tables RMSs",50,-25,25);
01727
01728
01729
01730 fDeltaSparc_h->SetXTitle("#Delta RMS('SexyPedestalValues'-'OnlineTablesValues')");
01731
01732 fDeltaRmsMapT_h = new TH2S("fDeltaRmsMapT_h",
01733 "Effect of Truncation on pedestals width {RMS(non-truncated) - RMS(truncated)}",
01734 576,0,576,90,0,90);
01735 fDeltaRmsMapT_h->SetXTitle("3x6x2xCrate# + 6x2xVARC# + 2xVMM# + VFB#");
01736 fDeltaRmsMapT_h->SetYTitle("22xVA-chip# + VA-chip-Channel#");
01737
01738 fErrorMap_h = new TH2S("fErrorMap_h",
01739 "Error Code Map",
01740 576,0,576,90,0,90);
01741 fErrorMap_h->SetXTitle("3x6x2xCrate# + 6x2xVARC# + 2xVMM# + VFB#");
01742 fErrorMap_h->SetYTitle("22xVA-chip# + VA-chip-Channel#");
01743
01744 }
01745
01746
01747
01748