00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124 #include "Stsstream.h"
00125
00126 #include "StPmdReadMaker.h"
00127 #include "St_DataSetIter.h"
00128
00129 #include "StDbLib/StDbManager.hh"
00130 #include "StDbLib/StDbTable.h"
00131 #include "StDbLib/StDbConfigNode.hh"
00132
00133 #include "StGlobals.hh"
00134 #include "StPmdUtil/StPmdCollection.h"
00135 #include "StPmdUtil/StPmdDetector.h"
00136 #include "StPmdUtil/StPmdHit.h"
00137 #include "StPmdUtil/StPmdModule.h"
00138 #include "StPmdUtil/StPmdGeom.h"
00139 #include "StPmdUtil/StPmdDBUtil.h"
00140 #include<StMessMgr.h>
00141 #include "StRtsTable.h"
00142 #include "RTS/src/DAQ_PMD/pmd.h"
00143
00144
00145
00146
00147
00148
00149 #include "StDaqLib/GENERIC/EventReader.hh"
00150 #include "StDaqLib/PMD/PMD_Reader.hh"
00151 #include "StDAQMaker/StDAQReader.h"
00152
00153 #include "TFile.h"
00154
00155 #include "StEvent/StEvent.h"
00156 #include "StEvent/StEventTypes.h"
00157
00158
00159 #include "StPmdCleanConstants.h"
00160 Int_t BadChainZero[25];
00161 Int_t * BadChain;
00162 Float_t SM_chain_factor[24][48];
00163
00164
00165
00166 ClassImp(StPmdReadMaker)
00167
00168
00169 StPmdReadMaker::StPmdReadMaker(const char *name) : StRTSBaseMaker("pmd",name)
00170 {
00171 mThePmdReader=NULL;
00172 mEvtPmdCollection=NULL;
00173 mPmdCollection=NULL;
00174 mTheDataReader=NULL;
00175 mThePmdData=NULL;
00176 mPmdEvent=NULL;
00177 mCpvEvent=NULL;
00178 mDb=NULL;
00179 m_PmdCalibConst=NULL;
00180 mPmdGeom = new StPmdGeom();
00181 mPmdDBUtil = new StPmdDBUtil();
00182 mChainTh=0;
00183
00184 mCalibFlag=kFALSE;
00185
00186
00187 mPmdPrint=kFALSE;
00188 mHotCells=NULL;
00189 }
00190
00191
00192
00193 StPmdReadMaker::~StPmdReadMaker() {
00194 delete mPmdGeom; mPmdGeom =0;
00195 delete mPmdDBUtil; mPmdDBUtil =0;
00196 mThePmdReader =0;
00197 mTheDataReader=0;
00198 mThePmdData =0;
00199 mPmdEvent =0;
00200 mCpvEvent =0;
00201 mPmdCollection=0;
00202 mDb=0;
00203 m_PmdCalibConst=0;
00204 mHotCells=0;
00205 }
00206
00207
00208
00209 Int_t StPmdReadMaker::Init() {
00210 if(mPmdPrint)gMessMgr->Info("StPmdReadMaker::Init()");
00211 mCalibFlag = !(IAttr("pmdRaw"));
00212
00213 bookHist();
00214
00215 return StMaker::Init();
00216 }
00217
00218
00219 Int_t StPmdReadMaker::InitRun(Int_t runnr) {
00220 if(mPmdPrint)gMessMgr->Info("StPmdReaderMaker::InitRun()");
00221
00222 mRunNumber = runnr;
00223 mPmdGeom->readBoardDetail(runnr);
00224
00225
00226 if(mRunNumber < 5034042) mVmeCond = 1;
00227 else if(mRunNumber >= 5034042 && mRunNumber < 5049020) mVmeCond = 2;
00228 else if(mRunNumber >= 5049020 && mRunNumber < 6000000) mVmeCond = 3;
00229 else if(mRunNumber >= 6000000 && mRunNumber < 7000000) mVmeCond = 4;
00230 else if(mRunNumber >= 8000000 && mRunNumber < 9000000) mVmeCond = 5;
00231 else if(mRunNumber >= 9000000) mVmeCond = 5;
00232
00233
00234
00235
00236
00237 for(Int_t i=0;i<25;i++) BadChainZero[i]=0;
00238
00239 ReadBadChains(runnr);
00240 ReadCalibrationsConst();
00241
00242
00243
00244
00245
00246
00247
00248
00249
00250
00251
00252
00253
00254
00255
00256 return StMaker::InitRun(runnr);
00257 }
00258
00259
00260
00261 void StPmdReadMaker::ReadBadChains(Int_t runNo){
00262
00263 Int_t rn,year;
00264 mPmdGeom->GetRunYear(runNo,rn,year);
00265 if(Debug())cout<<"runNo="<<runNo<<" year="<<year<<endl;
00266 cout<<"runNo="<<runNo<<" year="<<year<<endl;
00267
00268 if(year==12){
00269 if(runNo>12172000){
00270 BadChain = PmdClean::BadChain_y12d172;
00271 }else if(runNo>12114000){
00272 BadChain = PmdClean::BadChain_y12d114;
00273 }else{
00274 BadChain = PmdClean::BadChain_y12d0;
00275 }
00276
00277
00278 }
00279
00280 if(year==11){
00281 if(runNo>11148001){
00282 BadChain = PmdClean::BadChain_y10d148;
00283 }else if(runNo>11105000){
00284 BadChain = PmdClean::BadChain_y10d105;
00285 }else if(runNo>11100000){
00286 BadChain = PmdClean::BadChain_y10d100;
00287 }else if(runNo>11091000){
00288 BadChain = PmdClean::BadChain_y10d91;
00289 }else if(runNo>11001000){
00290 BadChain = PmdClean::BadChain_y10d0;
00291 }
00292 }
00293
00294
00295 if(year==8){
00296 if(runNo>8342000){
00297 BadChain = PmdClean::BadChain_y8d342;
00298 }else if(runNo>8143000){
00299 BadChain = PmdClean::BadChain_y8d143;
00300 }else if(runNo>8135000){
00301 BadChain = PmdClean::BadChain_y8d135;
00302 }else if(runNo>8131000){
00303 BadChain = PmdClean::BadChain_y8d131;
00304 }else if(runNo>8122000){
00305 BadChain = PmdClean::BadChain_y8d122;
00306 }else if(runNo>8116000){
00307 BadChain = PmdClean::BadChain_y8d116;
00308 }else if(runNo>8108000){
00309 BadChain = PmdClean::BadChain_y8d108;
00310 }else if(runNo>8102000){
00311 BadChain = PmdClean::BadChain_y8d102;
00312 }else if(runNo > 8095000){
00313 BadChain = PmdClean::BadChain_y8d95;
00314 }else if(runNo>8089001){
00315 BadChain = PmdClean::BadChain_y8d89;
00316 }else{
00317 BadChain = PmdClean::BadChain_y8d0;
00318 }
00319 } else {
00320 BadChain = BadChainZero;
00321 }
00322
00323 if (BadChain[0]>0 && Debug()){
00324
00325 cout<<"BadChains are ";
00326 for(Int_t i=0;i<25;i++){
00327 if (BadChain[i]>0) cout<<BadChain[i]<<" ";
00328 }
00329 cout<<endl;
00330 }
00331
00332 }
00333
00334
00335
00336
00337
00338
00339
00340
00341
00342
00343
00344
00345
00346
00347
00348
00349
00350
00351
00352
00353
00354
00355
00356
00357 Int_t StPmdReadMaker::Make() {
00358
00359 if(mPmdPrint)gMessMgr->Info("StPmdReadMaker::Make()");
00360 Int_t adc[2*PMD_CRAMS_MAX*2*(PMD_CRAMS_CH_MAX)];
00361 Int_t rn,year;
00362 mPmdGeom->GetRunYear(mRunNumber,rn,year);
00363 if(Debug())cout<<"runNo="<<mRunNumber<<" year="<<year<<endl;
00364
00365
00366
00367 Int_t adcChCount=0;
00368
00369
00370
00371
00372
00373
00374 for (int sector=1; sector<2;++sector) {
00375
00376 while ( GetNextLegacy(sector) ) {
00377
00378 pmd_t* fpmd = (pmd_t*)*DaqDta()->begin();
00379 Int_t nChain=0;
00380 for(Int_t crate=0;crate<2;crate++) {
00381
00382 for(Int_t c=0;c<12;c++) {
00383 for(Int_t s=0;s<2;s++) {
00384 Int_t chmax = 0;
00385 Int_t chain = 0;
00386 for(Int_t ch=0;ch<1728;ch++) {
00387 if(s==0){ nChain=c+12*crate;}
00388 if(s==1){ nChain=(c+24)+12*crate;}
00389 Double_t ped_mean= (double)fpmd->ped[crate][c][s][ch]/16.0;
00390 Double_t ped_rms= (double)fpmd->rms[crate][c][s][ch]/16.0;
00391
00392 Int_t adc_ch = fpmd->adc[crate][c][s][ch];
00393 if(adc_ch>0 && chmax<ch) {chmax = ch; chain = nChain;}
00394 adc[adcChCount]=adc_ch;
00395 adcChCount++;
00396
00397
00398
00399
00400
00401
00402 if(adc_ch>0 ||ped_mean>0){
00403 chain_adc[nChain]->Fill(ch,adc_ch);
00404 chain_mean[nChain]->Fill(ch,ped_mean);
00405 chain_rms[nChain]->Fill(ch,ped_rms);
00406
00407
00408 }
00409 }
00410
00411 }
00412 }
00413 }
00414
00415
00416
00417
00418 Int_t result=ApplyMapping(&adc[0]);
00419
00420 if(result!=kStOK){gMessMgr->Info("Problem in getting PMD data:ApplyMap");
00421 return kStWarn;
00422 }
00423 }
00424
00425
00426
00427
00428
00429
00430
00431
00432
00433
00434
00435
00436
00437
00438
00439
00440
00441
00442
00443
00444
00445
00446
00447
00448
00449
00450
00451
00452
00453
00454
00455
00456
00457
00458
00459
00460
00461
00462
00463
00464
00465
00466
00467
00468
00469
00470
00471
00472
00473
00474
00475
00476
00477 }
00478
00479
00480 return kStOK;
00481 }
00482
00483
00484 Int_t StPmdReadMaker:: ApplyMapping(int *adc)
00485 {
00486
00487
00488
00489
00490
00491
00492
00493
00494
00495
00496
00497
00498
00499
00500
00501 Int_t rn=0; Int_t year=0;
00502 mPmdGeom->GetRunYear(mRunNumber,rn,year);
00503 if(Debug())cout<<"runNo="<<mRunNumber<<" year="<<year<<endl;
00504
00506 if(mRunNumber<1){
00507 gMessMgr->Info("Run number >11 , returning from applymapping ");
00508 return kStWarn;
00509 }
00510 mPmdGeom->readBoardDetail(mRunNumber);
00511
00512 mPmdCollection = new StPmdCollection("PmdCollection");
00513 m_DataSet->Add(mPmdCollection);
00514 StPmdDetector* det0 = mPmdCollection->detector(0);
00515 StPmdDetector* det1 = mPmdCollection->detector(1);
00516
00517
00518 Int_t Chain_No,supmod,row,col,SubDet=0,chtemp;
00519 Int_t AddCh_Count=0;
00520 Int_t orig_nhits = 0;
00521 Int_t nhits=0;
00522 Int_t nhits_sm[24]={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
00523 for(Int_t SEC=0; SEC < PMD_SECTOR; SEC++){
00524 for(Int_t CRAM=0; CRAM < PMD_CRAMS_MAX; CRAM++){
00525 for(Int_t BLOCK=0; BLOCK < PMD_CRAMS_BLOCK; BLOCK++){
00526 for(Int_t CHANNEL=0; CHANNEL < PMD_CRAMS_CH_MAX; CHANNEL++){
00527 Int_t channel=CHANNEL;
00528
00529
00530
00531 switch (mVmeCond){
00532
00533 case 1:
00534 {
00535 if(SEC==0){
00536 if(BLOCK==0)Chain_No=25+CRAM;
00537 if(BLOCK==1)Chain_No=37+CRAM;
00538 }
00539 else break;
00540 }
00541 break;
00542 case 2:
00543 {
00544 Chain_No=(CRAM+1)+(SEC*PMD_CRAMS_MAX)+(BLOCK*2*PMD_CRAMS_MAX);
00545 }
00546 break;
00547 case 3:
00548 {
00549 if(SEC==0 && BLOCK==0 && CRAM==9) Chain_No = 39;
00550 else if(SEC==0 && BLOCK==0 && CRAM==10) Chain_No = 40;
00551 else Chain_No=(CRAM+1)+(SEC*PMD_CRAMS_MAX)+(BLOCK*2*PMD_CRAMS_MAX);
00552 }
00553 break;
00554 case 4:
00555 {
00556 if(SEC==0 && BLOCK==0 && CRAM==5) Chain_No = 36;
00557 else Chain_No=(CRAM+1)+(SEC*PMD_CRAMS_MAX)+(BLOCK*2*PMD_CRAMS_MAX);
00558 }
00559 break;
00560 case 5:
00561 {
00562
00563 if(SEC==0 && BLOCK==0 && CRAM==5) Chain_No = 36;
00564 else Chain_No=(CRAM+1)+(SEC*PMD_CRAMS_MAX)+(BLOCK*2*PMD_CRAMS_MAX);
00565 }
00566 break;
00567 }
00568 if(mVmeCond==4){
00569
00570
00571 Int_t Chain_original=Chain_No;
00572 if(Chain_original==45)Chain_No=46;
00573 if(Chain_original==46)Chain_No=45;
00574
00575 }
00576
00577
00578
00579
00580 if (Chain_No >= 1 && Chain_No < 25) SubDet = 2;
00581 if (Chain_No >= 25 && Chain_No <= 48) SubDet = 1;
00582
00583
00584
00585
00586 Int_t mapp=0;
00587 supmod=0;
00588 row=0;
00589 col=0;
00590 chtemp=-1;
00591
00592 if(mRunNumber < 6000000)mapp=mPmdGeom->ChainMapping(Chain_No,channel,supmod,col,row,chtemp);
00593 if(mRunNumber >= 6000000)mapp=mPmdGeom->ChainMapping(Chain_No,channel,supmod,col,row,chtemp,year);
00594 Int_t DaqADC=adc[AddCh_Count];
00595
00596 if(channel==0)DaqADC=0;
00597
00598 AddCh_Count++;
00599
00600 if(DaqADC>0 && mapp==kStOK){
00601 orig_nhits++;
00602
00603 m_chain_channel->Fill(channel,Chain_No-1);
00604
00605
00606
00607 Float_t cellgain = 1;
00608 Float_t smchaingain = 1;
00609 Float_t cellstatus = 1;
00610
00611
00612 if(mCalibFlag){
00613 Float_t calib = 1;
00614 Float_t final_factor = 0;
00615
00616 if(supmod<=(2*PMD_CRAMS_MAX) && row <=PMD_ROW_MAX && col <=PMD_COL_MAX){
00617
00618 Int_t stCalib = GetCalib(supmod,row,col,calib);
00619 if(stCalib != kStOK)gMessMgr->Info("Problem in getting Calibration Constant");
00620
00621 if(mRunNumber < 8000000){
00622
00623 final_factor=1.;
00624 }
00625 if(mRunNumber >= 8000000){
00626
00627 cellgain=calib;
00628 smchaingain=SM_chain_factor[supmod-1][Chain_No-1];
00629
00630 final_factor=calib*SM_chain_factor[supmod-1][Chain_No-1];
00631
00632 if(!Accept(Chain_No,channel)){
00633 final_factor=0.0;
00634 cellstatus=0;
00635 }
00636
00637 }
00638
00639
00640
00641 if(final_factor>0){
00642
00643
00644 }else{
00645
00646 }
00647
00648
00649 }
00650 }
00651
00652
00653 Float_t edep=0;
00654
00655
00656
00657
00658
00659
00660 edep = DaqADC *cellstatus/(cellgain*smchaingain);
00661 if(edep<0) edep=0;
00662
00663 if(DaqADC>0){
00664
00665
00666 StPmdHit *pmdhit = new StPmdHit();
00667 nhits_sm[supmod-1]++;
00668 if(supmod>PMD_CRAMS_MAX)supmod-=PMD_CRAMS_MAX;
00669 pmdhit->setGsuper(Int_t(supmod));
00670 pmdhit->setSubDetector(Int_t(SubDet));
00671 pmdhit->setRow(Int_t(row));
00672 pmdhit->setColumn(Int_t(col));
00673 pmdhit->setAdc(Int_t(DaqADC));
00674 pmdhit->setEdep(Float_t(edep));
00675
00676 pmdhit->setGainCell(Float_t(cellgain));
00677 pmdhit->setGainSmChain(Float_t(smchaingain));
00678 pmdhit->setCellStatus(Float_t(cellstatus));
00679
00680 if(SubDet==2)det0->addHit(pmdhit);
00681 if(SubDet==1)det1->addHit(pmdhit);
00682 nhits++;
00683 }
00684
00685 }
00686
00687 }
00688 }
00689 }
00690 }
00691
00692 if(Debug()){
00693 cout<<" NUmber of channels read ="<<AddCh_Count<<endl;
00694 cout<<" NUmber of original hits ="<<orig_nhits<<endl;
00695 cout<<" number of hits="<<nhits<<endl;
00696 for(Int_t ism = 0;ism<24;ism++){
00697 if(nhits_sm[ism]>0) cout<<"number of hits in module "<<ism+1<<" is ="<<nhits_sm[ism]<<endl;
00698 }
00699 }
00700 if(mPmdPrint)gMessMgr->Info("StEvent to be called **");
00701 Int_t testevt=fillStEvent(det0,det1);
00702 if(testevt!=kStOK){
00703 gMessMgr->Info("Problem in fillStEvent");
00704 return kStWarn;
00705 }
00706
00707 return kStOK;
00708 }
00709
00710
00711 Int_t StPmdReadMaker::fillStEvent(StPmdDetector* cpv_det, StPmdDetector* pmd_det){
00712
00713 StEvent *currevent = (StEvent*)GetInputDS("StEvent");
00714
00715 if(!currevent){
00716 gMessMgr->Info("NO STEVENT**");
00717
00718
00719 return kStWarn;
00720 }
00721
00722
00723
00724 mEvtPmdCollection = new StPhmdCollection();
00725 currevent->setPhmdCollection(mEvtPmdCollection);
00726
00727
00728 if(mEvtPmdCollection){
00729 mPmdEvent = mEvtPmdCollection->detector(StDetectorId(kPhmdId));
00730 mCpvEvent = mEvtPmdCollection->detector(StDetectorId(kPhmdCpvId));
00731 }
00732 Int_t tothit_pmd=0;
00733 Int_t tothit_cpv=0;
00734
00735
00736
00737
00738
00739
00740
00741
00742
00743
00744
00745
00746 for(Int_t id=1;id<(PMD_CRAMS_MAX+1);id++){
00747
00748
00749
00750
00751 StPmdModule * pmd_mod=pmd_det->module(id);
00752 Int_t nmh1=pmd_det->module_hit(id);
00753
00754 if(nmh1>0){
00755
00756 TIter next(pmd_mod->Hits());
00757 StPmdHit *spmcl1;
00758 for(Int_t im=0; im<nmh1; im++)
00759 {
00760 spmcl1 = (StPmdHit*)next();
00761 if(spmcl1){
00762 Int_t subdet=spmcl1->SubDetector();
00763 Int_t gsuper=spmcl1->Gsuper();
00764 Int_t col=spmcl1->Column();
00765 Int_t row=spmcl1->Row();
00766 Float_t edep=spmcl1->Edep();
00767 Int_t adc=spmcl1->Adc();
00768
00770
00771 StPhmdHit *phit = new StPhmdHit();
00772
00773
00774
00775
00776
00777
00778
00779
00780
00781 phit->setSuperModule(Int_t(gsuper-1));
00782 phit->setSubDetector(Int_t(subdet-1));
00783 phit->setRow(Int_t(row-1));
00784 phit->setColumn(Int_t(col-1));
00785 phit->setEnergy(edep);
00786 phit->setAdc(adc);
00787 tothit_pmd++;
00788 if(mPmdEvent)mPmdEvent->addHit(phit);
00789 }
00790 }
00791 }
00792
00793
00794
00795 Int_t nmh2=cpv_det->module_hit(id);
00796 StPmdModule * cpv_mod=cpv_det->module(id);
00797
00798 if(nmh2>0)
00799 {
00800 cout<<" PMD: Filled "<<nmh2<<" hits in CPV"<<endl;
00801 TIter next(cpv_mod->Hits());
00802 StPmdHit *spmcl2;
00803 for(Int_t im=0; im<nmh2; im++)
00804 {
00805 spmcl2 = (StPmdHit*)next();
00806 if(spmcl2){
00807 Int_t subdet=spmcl2->SubDetector();
00808 Int_t gsuper=spmcl2->Gsuper();
00809 Int_t col=spmcl2->Column();
00810 Int_t row=spmcl2->Row();
00811 Float_t edep=spmcl2->Edep();
00812 Int_t adc=spmcl2->Adc();
00813
00814 StPhmdHit *phit = new StPhmdHit();
00815
00816
00817 phit->setSuperModule(Int_t(gsuper-1));
00818 phit->setSubDetector(Int_t(subdet-1));
00819 phit->setRow(Int_t(row-1));
00820 phit->setColumn(Int_t(col-1));
00821 phit->setEnergy(edep);
00822 phit->setAdc(adc);
00823
00824 tothit_cpv++;
00825 if(mCpvEvent)mCpvEvent->addHit(phit);
00826 }
00827 }
00828 }
00829 }
00830
00831
00832
00833 return kStOK;
00834 }
00835
00836
00837
00838 Int_t StPmdReadMaker::Finish() {
00839 if(mPmdPrint)gMessMgr->Info("StPmdReadMaker::Finish()");
00840 TFile * f = new TFile("11030019run_2010_histo_QA.root", "RECREATE");
00841 for(Int_t nchain=0; nchain<49; nchain++)
00842 {
00843 chain_mean[nchain]->Write();
00844 chain_rms[nchain]->Write();
00845 chain_adc[nchain]->Write();
00846 }
00847 pmdhit_tof->Write();
00848 pmdadc_tof->Write();
00849 f->Close();
00850 return StMaker::Finish();
00851 }
00852
00853
00854
00855 void StPmdReadMaker::bookHist(){
00856
00857
00858 pmdhit_tof = new TH2F("pmdhit_tof","",1000,0,100000, 1000, 0, 10000);
00859 pmdadc_tof = new TH2F("pmdadc_tof","",1000,0,100000, 1000, 0, 10000);
00860
00861 m_chain_channel = new TH2F("chain_chan","channel vs chain No ",1728,-0.5,1727.5,48,-0.5,47.5);
00862 for (Int_t chain1 =0;chain1<49;chain1++)
00863 {
00864 Char_t text[20],title[20];
00865 sprintf(text,"chain_rms%02d",chain1);
00866 sprintf(title,"chain_rms%02d",chain1);
00867 chain_rms[chain1] = new TH1D(text,title,1730,0,1730);
00868 sprintf(text,"chain_mean%02d",chain1);
00869 sprintf(title,"chain_mean%02d",chain1);
00870 chain_mean[chain1] = new TH1D(text,title,1730,0,1730);
00871 Char_t text1[20],title1[20];
00872 sprintf(text1,"chain_adc%02d",chain1);
00873 sprintf(title1,"chain_adc%02d",chain1);
00874 chain_adc[chain1] = new TH1D(text1,title1,1730,0,1730);
00875 }
00876 }
00877
00878
00879 Bool_t StPmdReadMaker::IsHot(Int_t chain,Int_t channel){
00880
00881
00882
00883 if (!mHotCells) return kFALSE;
00884
00885
00886 Int_t offset = channel/32;
00887 Int_t bit = channel%32;
00888
00889 pmdHotCells_st* chainCells = mHotCells->GetTable(chain-1);
00890 unsigned int* bitMask = &(chainCells->m00);
00891 bitMask += offset;
00892 Bool_t isHot = ( ((*bitMask) & (((unsigned int) 1) << (31-bit))) != 0 );
00893
00894 if (isHot) {
00895
00896
00897
00898
00899
00900 }
00901
00902
00903
00904 return isHot;
00905 }
00906
00907
00908
00909 Bool_t StPmdReadMaker::Accept(Int_t chain,Int_t channel){
00910
00911 if (channel==0)return kFALSE;
00912
00913
00914 for(Int_t i=0;i<25;i++){
00915
00916 if (chain==BadChain[i]){
00917
00918 return kFALSE;
00919 }
00920 }
00921
00922
00923 return !IsHot(chain,channel);
00924
00925 }
00926
00927
00928
00929 Bool_t StPmdReadMaker::ReadCalibrationsConst(){
00930
00931 if(Debug()) cout<<" StPmdReadMaker::I AM IN READCALIB "<<endl;
00932
00933 StDbManager* mgr=StDbManager::Instance();
00934 StDbConfigNode* node=mgr->initConfig("Calibrations_pmd");
00935 node->setVersion("SMChain");
00936
00937 mDb=NULL;
00938 m_PmdCalibConst=NULL;
00939 TString DbName = "Calibrations/pmd";
00940 mDb=GetInputDB(DbName.Data());
00941 if(Debug())cout<<"after mDB"<<endl;
00942 if(!mDb) return kFALSE;
00943
00944
00945 for(Int_t ism=0;ism<24;ism++){
00946 for(Int_t chain=0;chain<48;chain++){
00947 SM_chain_factor[ism][chain]=0.;
00948 }
00949 }
00950
00951
00952
00953 pmdCalSummary_st* pmdcalsum = NULL;
00954 St_pmdCalSummary* summ = (St_pmdCalSummary*) mDb->Find("pmdCalSummary");
00955 if(summ) pmdcalsum = summ->GetTable();
00956
00957 pmdSMCalib_st* pmdcalibst = NULL;
00958 TString TableName;
00959 St_pmdSMCalib* a = (St_pmdSMCalib*) mDb->Find("pmdSMCalib");
00960 if(a) pmdcalibst = a->GetTable();
00961 if(!pmdcalibst) return kFALSE;
00962 m_PmdCalibConst=pmdcalibst;
00963 if(Debug())cout<<"obtained the Cell_GNF Tables"<<endl;
00964
00965
00966 mHotCells = (St_pmdHotCells*) mDb->Find("pmdHotCells");
00967 if (!mHotCells) {
00968 gMessMgr->Warning("pmdHotCells not found!");
00969 return kFALSE;
00970 }
00971 Int_t nhot = 0;
00972 for (Int_t chain=1; chain <= 48; chain++) {
00973 pmdHotCells_st* chainCells = mHotCells->GetTable(chain-1);
00974 if (!chainCells) {
00975 cout<<"End-of-DbTable. Stopping."<<endl;
00976 return kFALSE;
00977 }
00978
00979 for (Int_t offset=0; offset<54; offset++) {
00980 unsigned int* bitMask = &(chainCells->m00);
00981 bitMask += offset;
00982
00983 for (Int_t bit=31; bit>=0; bit--) {
00984 if ( ((*bitMask) & (((unsigned int) 1) << bit)) != 0 ) {
00985
00986
00987
00988 nhot++;
00989 }
00990 }
00991 }
00992
00993 }
00994 if(Debug()) cout<<" number of hot cells is "<< nhot<<endl;
00995
00996
00997
00998
00999 St_pmdSMChain_GNF * tab = (St_pmdSMChain_GNF*) mDb->Find("pmdSMChain_GNF");
01000 if (!tab) {
01001 cout<<"No pmdSMChain_GNF DBTable. Stopping."<<endl;
01002 return kFALSE;
01003 }
01004
01005
01006
01007
01008
01009
01010
01011 for (Int_t ismchain=0; ismchain<64; ismchain++) {
01012 pmdSMChain_GNF_st* smchain = tab->GetTable(ismchain);
01013 if (!smchain) {
01014 cout<<"End-of-SmChain DbTable. Stopping."<<endl;
01015 return kFALSE;
01016 }
01017
01018 long supmod = smchain->sm;
01019 long chainNo=smchain->chain;
01020 float MeanFactor = smchain->mean_factor;
01021 float MPVFactor = smchain->mpv_factor;
01022
01023 SM_chain_factor[supmod-1][chainNo-1]=MeanFactor;
01024
01025
01026
01027
01028
01029
01030
01031
01032
01033 if(Debug()){
01034 if(supmod>0 && chainNo>0){
01035 cout<<"SM,Chain,mean_factor,mpv_factor "<<supmod<<" "<<chainNo<<" "<<MeanFactor<<" "<<MPVFactor<<" "<<SM_chain_factor[supmod-1][chainNo-1]<<endl;
01036 }
01037 }
01038 }
01039 return kTRUE;
01040
01041 }
01042
01043
01044
01045 Int_t StPmdReadMaker::GetCalib(int sm,int row,int col,float& calib)
01046 {
01047 if(sm>0 && row>0 && col>0)
01048 if(m_PmdCalibConst)calib=m_PmdCalibConst[sm-1].CellGain[row-1][col-1];
01049
01050
01051
01052 return kStOK;
01053
01054 }
01055
01056