LIPlexMaps Class Reference

#include <LIPlexMaps.h>

Inheritance diagram for LIPlexMaps:
LILookup

List of all members.

Public Member Functions

 LIPlexMaps ()
 ~LIPlexMaps ()
void CompareStripToStrip (Int_t det, VldTimeStamp ts, Int_t taskA, Int_t taskB)
void DriftWithTime (VldRange vldRng, Float_t pointSpacingMinutes=20)
std::map< Int_t, Float_t > GetRawPinMap (VldContext vldCtx)
std::map< PlexLedId, LIPulserPinGetRawPinLedMap (VldContext vldCtx)
std::map< Int_t, LIPulserPinGetRefAdcPinRatio (VldContext vldCtx)
void DumpCalStripToStrip (std::string sDataFileName, Detector::Detector_t det, SimFlag::ESimFlag simFlag, VldTimeStamp ts, Int_t task) const
void DumpCalStripAtten (std::string sDataFileName, Detector::Detector_t det, SimFlag::ESimFlag simFlag, VldTimeStamp ts, Int_t task)
Bool_t IsPermitted () const
void MakeCalAdcToPe (std::string gainsFileName, Detector::Detector_t det, SimFlag::ESimFlag simFlag, VldTimeStamp vldStart, VldTimeStamp vldEnd, Int_t aggNo, Int_t task, Int_t aggStat[484], VldTimeStamp creationDate, std::string dbName, std::string sLogComment, Int_t gainTooHigh, Int_t gainCeiling, Bool_t writeToDb=false)
void MakeCalStripToStrip (std::string sDataFileName, Detector::Detector_t det, SimFlag::ESimFlag simFlag, VldTimeStamp vldStart, VldTimeStamp vldEnd, Int_t aggNo, Int_t task, VldTimeStamp creationDate, std::string dbName, std::string sLogComment, Bool_t writeToDb=false)
void MakeCalStripAtten (std::string sDataFileName, Detector::Detector_t det, SimFlag::ESimFlag simFlag, VldTimeStamp vldStart, VldTimeStamp vldEnd, Int_t aggNo, Int_t task, VldTimeStamp creationDate, std::string dbName, std::string sLongComment, Int_t iFileFormat, Bool_t writeToDb=false)
void MakeCalMIPCalibration (Float_t scale, Detector::Detector_t det, SimFlag::ESimFlag simFlag, VldTimeStamp vldStart, VldTimeStamp vldEnd, Int_t aggNo, Int_t task, VldTimeStamp creationDate, std::string dbName, std::string sLogComment, Bool_t writeToDb)
void MakePinPlexTables ()
void MakePlexStripEndToLed (Bool_t writeToDb=false)
void NormaliseVector (std::vector< Double_t > &v, Int_t mode=1)
void PlotPlexPinMap ()
void PlotPlexStripMap (Int_t detectorType)
void PrintPlexPinDiodeInfo (Int_t detectorType)
void PrintDbPinDiodeInfo ()
void RatioRawToRefDrift ()
void ReadDbCalStripToStrip (Int_t det, VldTimeStamp ts, Int_t task)
void ReadDbCalStripAtten (Int_t det, VldTimeStamp ts, Int_t task)
void ReadDbGains (Int_t det, SimFlag::ESimFlag simFlag, VldTimeStamp ts, std::string runNumber, std::string sAgg, Int_t task=0)
Double_t ReadDbGainAverage (Detector::Detector_t det, VldTimeStamp ts, VldTimeStamp *end=0, VldTimeStamp *start=0)
TH1D * ReadDbGains (Detector::Detector_t det, VldTimeStamp ts)
std::map< Int_t, Double_t > GetGainMap (Detector::Detector_t det, VldTimeStamp ts)
TH1D GainDifference (Detector::Detector_t det, VldTimeStamp t1, VldTimeStamp t2)
TH2D GainDifferenceSvP (Detector::Detector_t det, VldTimeStamp t1, VldTimeStamp t2)
void DumpGains (Detector::Detector_t det, VldTimeStamp ts, std::string filename)
 Dumps the gains from a time-point into a text file.
void ReadDbPulserDrift (Int_t det, VldTimeStamp ts)
void ReadDbPulserDriftPin ()
void ReadDbPulserRawGain ()
void SetGraphAxisEtc (TGraph *g, Int_t startTimeSecs, Int_t endTimeSecs)
void ADCRailEffect ()
void Attenuation ()
void BinomialGen (std::vector< Double_t > &v, Int_t N, Double_t p)
void FactorialGen (std::vector< Double_t > &v)
void LIErrors ()
void NonLinearity ()
void PeGen ()
Int_t SampleDist (std::vector< Double_t > v, TRandom *tRand)
void ScaleVector (std::vector< Double_t > &v, Double_t scaleFactor)

Private Member Functions

std::string GetElecString (RawChannelId rChId)
Bool_t IsScintStrip (PlexStripEndId &stripEndId, PlexHandle *plexHandle)

Private Attributes

std::string fS
LILookup fLookup

Detailed Description

Definition at line 86 of file LIPlexMaps.h.


Constructor & Destructor Documentation

LIPlexMaps::LIPlexMaps (  ) 

Definition at line 109 of file LIPlexMaps.cxx.

References Msg::kDebug, and MSG.

00110 {
00111   MSG("LIPlexMaps",Msg::kDebug)<<"LIPlexMaps Constructor"<<endl;
00112 
00113   //set the pretty palette
00114   gStyle->SetPalette(1,(Int_t*)0);
00115 
00116 }

LIPlexMaps::~LIPlexMaps (  ) 

Definition at line 120 of file LIPlexMaps.cxx.

References Msg::kDebug, and MSG.

00121 {
00122   MSG("LIPlexMaps",Msg::kDebug)<<"LIPlexMaps Destructor"<<endl;
00123 }


Member Function Documentation

void LIPlexMaps::ADCRailEffect (  ) 

Definition at line 919 of file LIPlexMaps.cxx.

References Msg::kInfo, kQE, and MSG.

00920 {
00921   MSG("LIPlexMaps",Msg::kInfo) 
00922     <<" ** Running ADCRailEffect method... **"<<endl;
00923 
00925   //Theory
00927   //gain=rms**2/mean * 1/(1-p)
00928   //thus
00929   //rms=sqrt(gain*mean*(1-p))
00930   //and
00931   //npe=(mean/rms)**2 * (1-p)
00932 
00933   //use the pretty palette
00934   gStyle->SetPalette(1);
00935   //include the under and overflow counts
00936   gStyle->SetOptStat(1111111);
00937 
00938   TStopwatch stopwatch;
00939 
00940   //these two are defined
00941   const Double_t kQE=0.13;
00942   
00943   //TRandom has a periodicity of 10^8 so if you have >100 photons
00944   //then you shouldn't use more than 1e6 points in the binomial 
00945   //distribution since you will have started at the beginning of 
00946   //the list of random numbers again
00947   //not sure how this will affect things but it seems dodgy
00948   const Int_t kNumBinomPoints=static_cast<Int_t>(1e6);//1e7 is slow
00949 
00950   MSG("LIPlexMaps",Msg::kInfo) 
00951     <<endl<<"The following parameters are used in the MC:"<<endl
00952     <<"kQE="<<kQE<<endl
00953     <<"kNumBinomPoints="<<kNumBinomPoints<<endl;
00954 
00955   Int_t maxN=150;
00956   TH1F *hBinomial= new TH1F("hBinomial","Binomial distribution",
00957                             maxN+5,-1,maxN+4);
00958   hBinomial->SetFillColor(0);
00959   hBinomial->SetBit(TH1::kCanRebin);
00960 
00961   TH1F *hBinomial2= new TH1F("hBinomial2","Binomial distribution",
00962                             maxN+5,-1,maxN+4);
00963   hBinomial2->SetFillColor(0);
00964   hBinomial2->SetLineColor(2);
00965   hBinomial2->SetBit(TH1::kCanRebin);
00966 
00967   TH1F *hBinomial3= new TH1F("hBinomial3","Binomial distribution",
00968                             maxN+5,-1,maxN+4);
00969   hBinomial3->SetFillColor(0);
00970   hBinomial3->SetLineColor(3);
00971   hBinomial3->SetBit(TH1::kCanRebin);
00972 
00973   //create a histogram based on the binomial
00974   TRandom *tRandom=new TRandom(0);
00975   
00976   for (Int_t N=100;N<160;N+=20){
00977     static Int_t counter=0;
00978     counter++;
00979     
00980     MSG("LIPlexMaps",Msg::kInfo) 
00981       <<endl<<"Generating binomial distribution..."<<endl;
00982     for (Int_t i=0;i<kNumBinomPoints;i++){
00983       //generate a binomial distribution and fill histo
00984       //this works by performing a little MC
00985       //It does N trials and see how many are below the probability p
00986       Int_t r1=tRandom->Binomial(static_cast<Int_t>(N),
00987                                  static_cast<Double_t>(kQE));
00988     
00989       //apply rail
00990       if (r1>15) r1=15;
00991 
00992       if (counter==1) hBinomial->Fill(r1);
00993       if (counter==2) hBinomial2->Fill(r1);
00994       if (counter==3) hBinomial3->Fill(r1);
00995 
00996       //print out loop progress
00997       Float_t fract=ceil(kNumBinomPoints/5.);
00998       if (ceil(((Float_t)i)/fract)==((Float_t)i)/fract){
00999         MSG("LIPlexMaps",Msg::kInfo) 
01000           <<"Fraction of loop complete: "<<i 
01001           <<"/"<<kNumBinomPoints<<"  ("
01002           <<(Int_t)(100.*i/kNumBinomPoints)<<"%)"<<endl;
01003       }    
01004     }
01005     MSG("LIPlexMaps",Msg::kInfo) 
01006       <<"Binomial distribution done"<<endl;
01007   }
01008 
01009   //draw binomial distribution
01010   TCanvas *cBinomial=new TCanvas("cBinomial","cBinomial",1,1,1000,800);
01011   cBinomial->SetFillColor(0);
01012   cBinomial->cd();
01013   hBinomial->Draw();
01014   hBinomial2->Draw("sames");
01015   hBinomial3->Draw("sames");
01016 
01017   MSG("LIPlexMaps",Msg::kInfo) 
01018     <<" ** Finished ADCRailEffect method **"<<endl;
01019 }

void LIPlexMaps::Attenuation (  ) 

Definition at line 356 of file LIPlexMaps.cxx.

References Msg::kDebug, Msg::kInfo, MSG, and LILookup::TGraphVect().

00357 {
00358   MSG("LIPlexMaps",Msg::kInfo) 
00359     <<" ** Running Attenuation method... **"<<endl;
00360 
00361   vector<Double_t> x;
00362   vector<Double_t> xNorm;
00363   vector<Double_t> yGreenAtt1;
00364   vector<Double_t> yGreenAtt2;
00365   vector<Double_t> yGreen;
00366   vector<Double_t> yClear;
00367   vector<Double_t> y12C;
00368   vector<Double_t> y6G;
00369   vector<Double_t> y2G;
00370   vector<Double_t> y1G_12C_1G_1;
00371   vector<Double_t> y1G_12C_1G_2;
00372   vector<Double_t> y1G_12C_1G_3;
00373   vector<Double_t> x1G_12C_1G_1;
00374   vector<Double_t> x1G_12C_1G_2;
00375   vector<Double_t> x1G_12C_1G_3;
00376   vector<Double_t> y8G;
00377   vector<Double_t> y3GNear;
00378   vector<Double_t> y6CNear;
00379   vector<Double_t> y3GFar;
00380   vector<Double_t> y6CFar;
00381 
00382   vector<Double_t> boost12C;
00383   vector<Double_t> boost6G;
00384   vector<Double_t> boost8G;
00385   vector<Double_t> boost1G_12C_1G;
00386   vector<Double_t> reflectivity;
00387 
00388   Double_t maxCableLength=20;
00389   Int_t numPoints=1000;
00390 
00391   //attenuation lengths in meters
00392   Double_t greenAtt1=1;
00393   Double_t greenAtt2=10;//6m from Leo, 10m from KR off-axis talk
00394   Double_t clearAtt=12;
00395 
00396   //from MK
00397   //Double_t greenAtt1=0.5;
00398   //Double_t greenAtt2=6.7;
00399   //Double_t clearAtt=12.5;
00400 
00401   Double_t ref=1.0;
00402 
00403   Double_t ref12C=exp(-12./clearAtt);
00404   Double_t ref6G=0.5*(exp(-6./greenAtt1)+exp(-6./greenAtt2));
00405   Double_t ref2G=0.5*(exp(-2./greenAtt1)+exp(-2./greenAtt2));
00406   Double_t ref8G=0.5*(exp(-8./greenAtt1)+exp(-8./greenAtt2));
00407   Double_t ref1G_12C_1G=ref2G*ref12C;
00408 
00409   MSG("LIPlexMaps",Msg::kInfo)
00410     <<"Reflectivity = "<<ref
00411     <<endl
00412     <<"6m green = "<<ref6G<<" (0.22)"
00413     <<endl
00414     <<"12m clear = "<<ref12C<<" (0.20)"
00415     <<endl
00416     <<"8m green = "<<ref8G<<" (0.06)"
00417     <<endl
00418     <<"1mG & 12mC & 1mG = "<<ref1G_12C_1G<<" (0.09)"
00419     <<endl;
00420 
00421   MSG("LIPlexMaps",Msg::kInfo) 
00422     <<"Calculating boosts..."<<endl;
00423   for (Int_t i=0;i<numPoints;i++){
00424     reflectivity.push_back(0);
00425     boost12C.push_back(0);
00426     boost6G.push_back(0);
00427     boost1G_12C_1G.push_back(0);
00428     boost8G.push_back(0);
00429 
00430     Double_t connectorEff=1.0;
00431 
00432     reflectivity[i]=i*1./numPoints;
00433     boost12C[i]=connectorEff*reflectivity[i]*ref12C;
00434     boost1G_12C_1G[i]=connectorEff*reflectivity[i]*ref12C*ref2G;
00435 
00436     boost6G[i]=reflectivity[i]*ref6G;
00437     boost8G[i]=reflectivity[i]*ref8G;
00438   }
00439 
00440   MSG("LIPlexMaps",Msg::kInfo) 
00441     <<"Calculating basic attenuation curves..."<<endl;
00442   for (Int_t i=0;i<numPoints;i++){
00443     x.push_back(0);
00444     yGreenAtt1.push_back(0);
00445     yGreenAtt2.push_back(0);
00446     yGreen.push_back(0);
00447     yClear.push_back(0);
00448     
00449     x[i]=i*maxCableLength/numPoints;
00450     yGreenAtt1[i]=exp(-x[i]/greenAtt1);
00451     yGreenAtt2[i]=exp(-x[i]/greenAtt2);
00452     yGreen[i]=0.5*(exp(-x[i]/greenAtt1)+exp(-x[i]/greenAtt2));
00453     yClear[i]=exp(-x[i]/clearAtt);
00454   }
00455 
00456   MSG("LIPlexMaps",Msg::kInfo) 
00457     <<"Calculating for 1st 1 m of green..."<<endl;
00458   for (Int_t i=0;i<numPoints;i++){
00459     Double_t x=i*1./numPoints;
00460     xNorm.push_back(0);
00461     y12C.push_back(0);
00462     y6G.push_back(0);
00463     y2G.push_back(0);
00464     y8G.push_back(0);
00465 
00466     //only 1 (~meter) for fractional reflected length
00467     xNorm[i]=i*1./numPoints;
00468     
00469     y12C[i]=exp(-12*xNorm[i]/clearAtt);
00470     y6G[i]=0.5*(exp(-6*xNorm[i]/greenAtt1)+exp(-6*xNorm[i]/greenAtt2));
00471     y2G[i]=0.5*(exp(-2*xNorm[i]/greenAtt1)+exp(-2*xNorm[i]/greenAtt2));
00472 
00473     if (x<1./14){
00474       Double_t x2=i*1./((1./14)*numPoints);
00475       y1G_12C_1G_1.push_back(0);
00476       x1G_12C_1G_1.push_back(0);
00477       x1G_12C_1G_1[i]=x;
00478       y1G_12C_1G_1[i]=0.5*(exp(-1*x2/greenAtt1)+exp(-1*x2/greenAtt2));
00479       MSG("LIPlexMaps",Msg::kDebug) 
00480         <<"x="<<x<<", x2="<<x2
00481         <<", x1G_12C_1G_1[i]="<<x1G_12C_1G_1[i]
00482         <<", y1G_12C_1G_1[i]="<<y1G_12C_1G_1[i]
00483         <<endl;
00484     }
00485     y8G[i]=0.5*(exp(-8*xNorm[i]/greenAtt1)+exp(-8*xNorm[i]/greenAtt2));
00486   }
00487 
00488   UInt_t size_1=y1G_12C_1G_1.size();
00489   Int_t counter=0;
00490 
00491   MSG("LIPlexMaps",Msg::kInfo) 
00492     <<"Calculating for 12 m of clear..."<<endl;
00493   for (Int_t i=0;i<numPoints;i++){
00494     Double_t x=i*1./numPoints;
00495 
00496     if (x>1./14 && x<13./14){
00497       Double_t x2=counter*1./((12./14)*numPoints);
00498       y1G_12C_1G_2.push_back(0);
00499       x1G_12C_1G_2.push_back(0);
00500       x1G_12C_1G_2[counter]=x;
00501       y1G_12C_1G_2[counter]=y1G_12C_1G_1[size_1-1]*exp(-12*x2/clearAtt);
00502       MSG("LIPlexMaps",Msg::kDebug) 
00503         <<"x="<<x<<", x2="<<x2
00504         <<", x1G_12C_1G_2[i]="<<x1G_12C_1G_2[counter]
00505         <<", y1G_12C_1G_2[i]="<<y1G_12C_1G_2[counter]
00506         <<endl;
00507       counter++;
00508     }
00509   }
00510   
00511   UInt_t size_2=y1G_12C_1G_2.size();
00512   counter=0;
00513 
00514   MSG("LIPlexMaps",Msg::kInfo) 
00515     <<"Calculating for last 1 m of green..."<<endl;
00516   for (Int_t i=0;i<numPoints;i++){
00517     Double_t x=i*1./numPoints;
00518 
00519     if (x>13./14){
00520       Double_t x2=counter*1./((1./14)*numPoints);
00521       y1G_12C_1G_3.push_back(0);
00522       x1G_12C_1G_3.push_back(0);
00523       x1G_12C_1G_3[counter]=x;
00524 
00525       //take account of the x2+1 using scaleFactor
00526       Double_t scaleFactor=1./y1G_12C_1G_1[size_1-1];
00527       y1G_12C_1G_3[counter]=scaleFactor*y1G_12C_1G_2[size_2-1]*0.5*
00528         (exp(-1*(x2+1)/greenAtt1)+
00529          exp(-1*(x2+1)/greenAtt2));
00530       MSG("LIPlexMaps",Msg::kDebug) 
00531         <<"x="<<x<<", x2="<<x2
00532         <<", x1G_12C_1G_3[i]="<<x1G_12C_1G_3[counter]
00533         <<", y1G_12C_1G_3[i]="<<y1G_12C_1G_3[counter]
00534         <<endl;
00535       counter++;
00536     }
00537   }
00538 
00539   UInt_t size_3=y1G_12C_1G_3.size();
00540   UInt_t size_8G=y8G.size();
00541 
00542   MSG("LIPlexMaps",Msg::kInfo) 
00543     <<"Calculating for last section to PMT..."<<endl;
00544   MSG("LIPlexMaps",Msg::kInfo) 
00545     <<"Near side..."<<endl;
00546   for (Int_t i=0;i<numPoints;i++){
00547     Double_t x=i*1./numPoints;
00548 
00549     y3GNear.push_back(0);
00550     y6CNear.push_back(0);
00551     
00552     y3GNear[i]=y1G_12C_1G_3[size_3-1]*0.5*
00553       (exp(-3.*x/greenAtt1)+exp(-3.*x/greenAtt2));
00554     y6CNear[i]=y8G[size_8G-1]*exp(-6.*x/clearAtt);
00555     
00556     MSG("LIPlexMaps",Msg::kDebug) 
00557       <<"x="<<x
00558       <<", y3GNear[i]="<<y3GNear[i]
00559       <<", y6CNear[i]"<<y6CNear[i]
00560       <<endl;
00561   }
00562 
00563   UInt_t size_12C=y12C.size();
00564   UInt_t size_6G=y6G.size();
00565 
00566   MSG("LIPlexMaps",Msg::kInfo) 
00567     <<"Far side..."<<endl;
00568   for (Int_t i=0;i<numPoints;i++){
00569     Double_t x=i*1./numPoints;
00570 
00571     y3GFar.push_back(0);
00572     y6CFar.push_back(0);
00573     
00574     y3GFar[i]=y12C[size_12C-1]*0.5*
00575       (exp(-3.*x/greenAtt1)+exp(-3.*x/greenAtt2));
00576     y6CFar[i]=y6G[size_6G-1]*exp(-6.*x/clearAtt);
00577     
00578     MSG("LIPlexMaps",Msg::kDebug) 
00579       <<"x="<<x
00580       <<", y3GFar[i]="<<y3GFar[i]
00581       <<", y6CFar[i]"<<y6CFar[i]
00582       <<endl;
00583   }
00584 
00585   //create canvas
00586   TCanvas *cAttenuation=new TCanvas("cAttenuation","cAttenuation",
00587                                   1,1,1000,800);
00588   cAttenuation->SetFillColor(0);
00589   cAttenuation->Divide(2,2);
00590 
00591   //create graph
00592   TGraph* gGreen=TGraphVect(x,yGreen);
00593   gGreen->SetTitle("Green Attenuation length (1+2)");
00594   gGreen->SetMarkerStyle(3);
00595   gGreen->SetMarkerColor(3);
00596   gGreen->SetMarkerSize(0.2);
00597   cAttenuation->cd(1);
00598   gGreen->Draw("AP");
00599   gGreen->GetXaxis()->SetTitle("Cable length");
00600   gGreen->GetYaxis()->SetTitle("Intensity");
00601   gGreen->GetXaxis()->CenterTitle();
00602   gGreen->GetYaxis()->CenterTitle();
00603   gGreen->SetMinimum(0);
00604   
00605   //create graph
00606   TGraph* gGreenAtt1=TGraphVect(x,yGreenAtt1);
00607   gGreenAtt1->SetTitle("Green Attenuation length 1");
00608   gGreenAtt1->SetMarkerStyle(3);
00609   gGreenAtt1->SetMarkerColor(30);
00610   gGreenAtt1->SetMarkerSize(0.2);
00611   cAttenuation->cd(2);
00612   gGreenAtt1->Draw("AP");
00613   gGreenAtt1->GetXaxis()->SetTitle("Cable length");
00614   gGreenAtt1->GetYaxis()->SetTitle("Intensity");
00615   gGreenAtt1->GetXaxis()->CenterTitle();
00616   gGreenAtt1->GetYaxis()->CenterTitle();
00617   gGreenAtt1->SetMinimum(0);
00618 
00619   //create graph
00620   TGraph* gGreenAtt2=TGraphVect(x,yGreenAtt2);
00621   gGreenAtt2->SetTitle("Green Attenuation length 2");
00622   gGreenAtt2->SetMarkerStyle(3);
00623   gGreenAtt2->SetMarkerColor(8);
00624   gGreenAtt2->SetMarkerSize(0.2);
00625   cAttenuation->cd(3);
00626   gGreenAtt2->Draw("AP");
00627   gGreenAtt2->GetXaxis()->SetTitle("Cable length");
00628   gGreenAtt2->GetYaxis()->SetTitle("Intensity");
00629   gGreenAtt2->GetXaxis()->CenterTitle();
00630   gGreenAtt2->GetYaxis()->CenterTitle();
00631   gGreenAtt2->SetMinimum(0);
00632 
00633   //create graph
00634   TGraph* gClear=TGraphVect(x,yClear);
00635   gClear->SetTitle("Clear Attenuation length");
00636   gClear->SetMarkerStyle(3);
00637   gClear->SetMarkerColor(1);
00638   gClear->SetMarkerSize(0.2);
00639   cAttenuation->cd(4);
00640   gClear->Draw("AP");
00641   gClear->GetXaxis()->SetTitle("Cable length");
00642   gClear->GetYaxis()->SetTitle("Intensity");
00643   gClear->GetXaxis()->CenterTitle();
00644   gClear->GetYaxis()->CenterTitle();
00645   gClear->SetMinimum(0);
00646 
00648   //create canvas
00650   MSG("LIPlexMaps",Msg::kInfo) 
00651     <<"Drawing cAttCalDet canvas..."<<endl;
00652   TCanvas *cAttCalDet=new TCanvas("cAttCalDet","cAttCalDet",
00653                                   1,1,1000,800);
00654   cAttCalDet->SetFillColor(0);
00655   //cAttCalDet->Divide(2,2);
00656 
00657   //create graph
00658   TGraph* g12C=TGraphVect(xNorm,y12C);
00659   g12C->SetTitle("Fractional Attenuation (LI Far Side)");
00660   g12C->SetMarkerStyle(3);
00661   g12C->SetMarkerColor(1);
00662   g12C->SetMarkerSize(0.2);
00663   cAttCalDet->cd(1);
00664   g12C->Draw("AP");
00665   g12C->GetXaxis()->SetTitle("Fraction of reflected distance (m)");
00666   g12C->GetYaxis()->SetTitle("Intensity");
00667   g12C->GetXaxis()->CenterTitle();
00668   g12C->GetYaxis()->CenterTitle();
00669   g12C->SetMinimum(0);
00670 
00671   //create graph
00672   TGraph* g6G=TGraphVect(xNorm,y6G);
00673   g6G->SetTitle("Fractional Attenuation");
00674   g6G->SetMarkerStyle(3);
00675   g6G->SetMarkerColor(3);
00676   g6G->SetMarkerSize(0.2);
00677   cAttCalDet->cd(1);
00678   g6G->Draw("P");
00679 
00680   //create graph
00681   TGraph* g12C_2=TGraphVect(xNorm,y12C);
00682   g12C_2->SetTitle("12 m Clear Attenuation");
00683   g12C_2->SetMarkerStyle(3);
00684   g12C_2->SetMarkerColor(1);
00685   g12C_2->SetMarkerSize(0.2);
00686   //cAttCalDet->cd(2);
00687   //g12C_2->Draw("AP");
00688   g12C_2->GetXaxis()->SetTitle("Fraction of reflected distance (m)");
00689   g12C_2->GetYaxis()->SetTitle("Intensity");
00690   g12C_2->GetXaxis()->CenterTitle();
00691   g12C_2->GetYaxis()->CenterTitle();
00692   g12C_2->SetMinimum(0);
00693 
00694   //create graph
00695   g6G->SetTitle("6 m Green Attenuation");
00696   g6G->SetMarkerStyle(3);
00697   g6G->SetMarkerColor(3);
00698   g6G->SetMarkerSize(0.2);
00699   //cAttCalDet->cd(3);
00700   //g6G->Draw("AP");
00701   g6G->GetXaxis()->SetTitle("Fraction of reflected distance (m)");
00702   g6G->GetYaxis()->SetTitle("Intensity");
00703   g6G->GetXaxis()->CenterTitle();
00704   g6G->GetYaxis()->CenterTitle();
00705   g6G->SetMinimum(0);
00706   
00708   //create canvas
00710   MSG("LIPlexMaps",Msg::kInfo) 
00711     <<"Drawing cAttCalDet2 canvas..."<<endl;
00712   TCanvas *cAttCalDet2=new TCanvas("cAttCalDet2","cAttCalDet2",
00713                                    1,1,1000,800);
00714   cAttCalDet2->SetFillColor(0);
00715   cAttCalDet2->Divide(1,1);
00716 
00717   //create graph
00718   TGraph* gDummy=TGraphVect(xNorm,xNorm);
00719   gDummy->SetTitle("Fractional Attenuation (LI Near Side)");
00720   gDummy->SetMinimum(0);
00721   gDummy->SetMaximum(1.2);
00722   gDummy->SetMarkerColor(0);
00723   cAttCalDet2->cd(1);
00724   gDummy->Draw("AP");
00725   gDummy->GetXaxis()->SetTitle("Fraction of reflected distance (m)");
00726   gDummy->GetYaxis()->SetTitle("Intensity");
00727   gDummy->GetXaxis()->CenterTitle();
00728   gDummy->GetYaxis()->CenterTitle();
00729 
00730   //create graph
00731   TGraph* g1G_12C_1G_1=TGraphVect(x1G_12C_1G_1,y1G_12C_1G_1);
00732   g1G_12C_1G_1->SetTitle("Fractional Attenuation");
00733   g1G_12C_1G_1->SetMarkerStyle(3);
00734   g1G_12C_1G_1->SetMarkerColor(3);
00735   g1G_12C_1G_1->SetMarkerSize(0.2);
00736   cAttCalDet2->cd(1);
00737   g1G_12C_1G_1->Draw("p");
00738   g1G_12C_1G_1->SetMinimum(0);
00739 
00740   //create graph
00741   TGraph* g1G_12C_1G_2=TGraphVect(x1G_12C_1G_2,y1G_12C_1G_2);
00742   g1G_12C_1G_2->SetTitle("Fractional Attenuation");
00743   g1G_12C_1G_2->SetMarkerStyle(3);
00744   g1G_12C_1G_2->SetMarkerColor(1);
00745   g1G_12C_1G_2->SetMarkerSize(0.2);
00746   cAttCalDet2->cd(1);
00747   g1G_12C_1G_2->Draw("P");
00748   g1G_12C_1G_2->SetMinimum(0);
00749 
00750   //create graph
00751   TGraph* g1G_12C_1G_3=TGraphVect(x1G_12C_1G_3,y1G_12C_1G_3);
00752   g1G_12C_1G_3->SetTitle("Fractional Attenuation");
00753   g1G_12C_1G_3->SetMarkerStyle(3);
00754   g1G_12C_1G_3->SetMarkerColor(3);
00755   g1G_12C_1G_3->SetMarkerSize(0.2);
00756   cAttCalDet2->cd(1);
00757   g1G_12C_1G_3->Draw("P");
00758   g1G_12C_1G_3->SetMinimum(0);
00759 
00760   //create graph
00761   TGraph* g8G=TGraphVect(xNorm,y8G);
00762   g8G->SetTitle("Fractional Attenuation");
00763   g8G->SetMarkerStyle(3);
00764   g8G->SetMarkerColor(8);
00765   g8G->SetMarkerSize(0.2);
00766   cAttCalDet2->cd(1);
00767   g8G->Draw("P");
00768   g8G->SetMinimum(0);
00769 
00771   //create canvas
00773   /*
00774   MSG("LIPlexMaps",Msg::kInfo) 
00775     <<"Drawing cAttCalDetNear canvas..."<<endl;
00776   TCanvas *cAttCalDetNear=new TCanvas("cAttCalDetNear","cAttCalDetNear",
00777                                       1,1,1000,800);
00778   cAttCalDetNear->SetFillColor(0);
00779   cAttCalDetNear->Divide(1,1);
00780 
00781   //create graph
00782   TGraph* g3GNear=TGraphVect(xNorm,y3GNear);
00783   g3GNear->SetTitle("Fractional Attenuation (LI Near Side)");
00784   g3GNear->SetMarkerStyle(3);
00785   g3GNear->SetMarkerColor(3);
00786   g3GNear->SetMarkerSize(0.2);
00787   cAttCalDetNear->cd(1);
00788   g3GNear->Draw("AP");
00789   g3GNear->GetXaxis()->SetTitle("Fraction of distance to PMT (m)");
00790   g3GNear->GetYaxis()->SetTitle("Intensity");
00791   g3GNear->GetXaxis()->CenterTitle();
00792   g3GNear->GetYaxis()->CenterTitle();
00793   g3GNear->SetMaximum(1.2);
00794   g3GNear->SetMinimum(0);
00795 
00796   //create graph
00797   TGraph* g6CNear=TGraphVect(xNorm,y6CNear);
00798   g6CNear->SetTitle("Fractional Attenuation (LI Near Side)");
00799   g6CNear->SetMarkerStyle(3);
00800   g6CNear->SetMarkerColor(1);
00801   g6CNear->SetMarkerSize(0.2);
00802   cAttCalDetNear->cd(1);
00803   g6CNear->Draw("P");
00804   g6CNear->SetMinimum(0);
00805 
00807   //create canvas
00809   MSG("LIPlexMaps",Msg::kInfo) 
00810     <<"Drawing cAttCalDetFar canvas..."<<endl;
00811   TCanvas *cAttCalDetFar=new TCanvas("cAttCalDetFar","cAttCalDetFar",
00812                                      1,1,1000,800);
00813   cAttCalDetFar->SetFillColor(0);
00814   cAttCalDetFar->Divide(1,1);
00815 
00816   //create graph
00817   TGraph* g3GFar=TGraphVect(xNorm,y3GFar);
00818   g3GFar->SetTitle("Fractional Attenuation (LI Far Side)");
00819   g3GFar->SetMarkerStyle(3);
00820   g3GFar->SetMarkerColor(3);
00821   g3GFar->SetMarkerSize(0.2);
00822   cAttCalDetFar->cd(1);
00823   g3GFar->Draw("AP");
00824   g3GFar->GetXaxis()->SetTitle("Fraction of distance to PMT (m)");
00825   g3GFar->GetYaxis()->SetTitle("Intensity");
00826   g3GFar->GetXaxis()->CenterTitle();
00827   g3GFar->GetYaxis()->CenterTitle();
00828   g3GFar->SetMaximum(1.2);
00829   g3GFar->SetMinimum(0);
00830 
00831   //create graph
00832   TGraph* g6CFar=TGraphVect(xNorm,y6CFar);
00833   g6CFar->SetTitle("Fractional Attenuation (LI Far Side)");
00834   g6CFar->SetMarkerStyle(3);
00835   g6CFar->SetMarkerColor(1);
00836   g6CFar->SetMarkerSize(0.2);
00837   cAttCalDetFar->cd(1);
00838   g6CFar->Draw("P");
00839   g6CFar->SetMinimum(0);
00840   */
00841 
00843   //create canvas
00845   MSG("LIPlexMaps",Msg::kInfo) 
00846     <<"Drawing cBoostsFar canvas..."<<endl;
00847   TCanvas *cBoostsFar=new TCanvas("cBoostsFar","cBoostsFar",
00848                                   1,1,1000,800);
00849   cBoostsFar->SetFillColor(0);
00850   cBoostsFar->Divide(1,1);
00851 
00852   //create graph
00853   TGraph* cBoost6G=TGraphVect(reflectivity,boost6G);
00854   cBoost6G->SetTitle("Fractional Boost vs Reflectivity");
00855   cBoost6G->SetMarkerStyle(3);
00856   cBoost6G->SetMarkerColor(3);
00857   cBoost6G->SetMarkerSize(0.2);
00858   cBoostsFar->cd(1);
00859   cBoost6G->Draw("AP");
00860   cBoost6G->GetXaxis()->SetTitle("Reflectivity");
00861   cBoost6G->GetYaxis()->SetTitle("Fractional Boost");
00862   cBoost6G->GetXaxis()->CenterTitle();
00863   cBoost6G->GetYaxis()->CenterTitle();
00864   cBoost6G->SetMaximum(1.2);
00865   cBoost6G->SetMinimum(0);
00866 
00867   //create graph
00868   TGraph* cBoost12C=TGraphVect(reflectivity,boost12C);
00869   cBoost12C->SetTitle("Fractional Boost vs Reflectivity");
00870   cBoost12C->SetMarkerStyle(3);
00871   cBoost12C->SetMarkerColor(1);
00872   cBoost12C->SetMarkerSize(0.2);
00873   cBoostsFar->cd(1);
00874   cBoost12C->Draw("P");
00875   cBoost12C->SetMinimum(0);
00876 
00877 
00879   //create canvas
00881   MSG("LIPlexMaps",Msg::kInfo) 
00882     <<"Drawing cBoostsNear canvas..."<<endl;
00883   TCanvas *cBoostsNear=new TCanvas("cBoostsNear","cBoostsNear",
00884                                   1,1,1000,800);
00885   cBoostsNear->SetFillColor(0);
00886   cBoostsNear->Divide(1,1);
00887 
00888   //create graph
00889   TGraph* cBoost8G=TGraphVect(reflectivity,boost8G);
00890   cBoost8G->SetTitle("Fractional Boost vs Reflectivity");
00891   cBoost8G->SetMarkerStyle(3);
00892   cBoost8G->SetMarkerColor(3);
00893   cBoost8G->SetMarkerSize(0.2);
00894   cBoostsNear->cd(1);
00895   cBoost8G->Draw("AP");
00896   cBoost8G->GetXaxis()->SetTitle("Reflectivity");
00897   cBoost8G->GetYaxis()->SetTitle("Fractional Boost");
00898   cBoost8G->GetXaxis()->CenterTitle();
00899   cBoost8G->GetYaxis()->CenterTitle();
00900   cBoost8G->SetMaximum(1.2);
00901   cBoost8G->SetMinimum(0);
00902 
00903   //create graph
00904   TGraph* cBoost1G_12C_1G=TGraphVect(reflectivity,boost1G_12C_1G);
00905   cBoost1G_12C_1G->SetTitle("Fractional Boost vs Reflectivity");
00906   cBoost1G_12C_1G->SetMarkerStyle(3);
00907   cBoost1G_12C_1G->SetMarkerColor(1);
00908   cBoost1G_12C_1G->SetMarkerSize(0.2);
00909   cBoostsNear->cd(1);
00910   cBoost1G_12C_1G->Draw("P");
00911   cBoost1G_12C_1G->SetMinimum(0);
00912 
00913   MSG("LIPlexMaps",Msg::kInfo) 
00914     <<" ** Finished Attenuation method **"<<endl;
00915 }

void LIPlexMaps::BinomialGen ( std::vector< Double_t > &  v,
Int_t  N,
Double_t  p 
)
void LIPlexMaps::CompareStripToStrip ( Int_t  det,
VldTimeStamp  ts,
Int_t  taskA,
Int_t  taskB 
)

Definition at line 5922 of file LIPlexMaps.cxx.

References LILookup::FIRSTPLANE, LILookup::FIRSTSTRIP, VldTimeStamp::GetDate(), CalStripToStrip::GetResponse(), DbiResultPtr< T >::GetRow(), CalStripToStrip::GetStripEndId(), SimFlag::kData, Msg::kDebug, StripEnd::kEast, Msg::kInfo, Msg::kWarning, StripEnd::kWest, LILookup::LASTPLANE, LILookup::LASTSTRIP, MAXMSG, MSG, DbiResultPtr< T >::NewQuery(), VldContext::Print(), LILookup::SetDetector(), and Munits::year.

05924 {
05925   MSG("LIPlexMaps",Msg::kInfo)
05926     <<endl<<" ** Running the CompareStripToStrip() method... ** "<<endl;
05927   //this must go first
05928   this->SetDetector(det);
05929 
05930   const Int_t firstStripBin=FIRSTSTRIP-2;//-8;
05931   const Int_t lastStripBin=LASTSTRIP+2;//+9, 200;
05932   const Int_t stripBins=lastStripBin-firstStripBin;
05933 
05934   const Int_t firstPlaneBin=FIRSTPLANE-2;;
05935   const Int_t lastPlaneBin=LASTPLANE+2;
05936   const Int_t planeBins=lastPlaneBin-firstPlaneBin;
05937 
05938 
05939   TH1F *hResponse=new TH1F("hResponse","hResponse",300,-1,10);
05940   hResponse->GetXaxis()->SetTitle("Response of Stripends");
05941   hResponse->GetXaxis()->CenterTitle();
05942   hResponse->GetYaxis()->SetTitle("");
05943   hResponse->GetYaxis()->CenterTitle();
05944   hResponse->SetLineColor(2);
05945   hResponse->SetFillStyle(3015);
05946   hResponse->SetFillColor(2);
05947   hResponse->SetLineWidth(3);
05948   //hResponse->SetBit(TH1::kCanRebin);
05949 
05950   TH1F *hResponseErr=new TH1F("hResponseErr","hResponseErr",
05951                               200,-0.02,0.2);
05952   hResponseErr->GetXaxis()->SetTitle("ResponseErr of Stripends");
05953   hResponseErr->GetXaxis()->CenterTitle();
05954   hResponseErr->GetYaxis()->SetTitle("");
05955   hResponseErr->GetYaxis()->CenterTitle();
05956   hResponseErr->SetLineColor(3);
05957   hResponseErr->SetFillStyle(3015);
05958   hResponseErr->SetFillColor(3);
05959   hResponseErr->SetLineWidth(3);
05960   //hResponseErr->SetBit(TH1::kCanRebin);
05961 
05962   TProfile* pRatioVsPlane=new TProfile
05963     ("pRatioVsPlane","pRatioVsPlane",
05964      planeBins,firstPlaneBin,lastPlaneBin);
05965   pRatioVsPlane->GetXaxis()->SetTitle("Plane");
05966   pRatioVsPlane->GetXaxis()->CenterTitle();
05967   pRatioVsPlane->GetYaxis()->SetTitle("Ratio");
05968   pRatioVsPlane->GetYaxis()->CenterTitle();
05969   pRatioVsPlane->SetLineColor(2);
05970   pRatioVsPlane->SetLineWidth(3);
05971   //pRatioVsPlane->SetBit(TH1::kCanRebin);
05972 
05973   TProfile* pRatioVsPlaneCoarse=new TProfile
05974     ("pRatioVsPlaneCoarse","pRatioVsPlaneCoarse",6,0,60);
05975   pRatioVsPlaneCoarse->SetTitle("Ratio of S2S Cal. Const. (Cosmic/PS)");
05976   pRatioVsPlaneCoarse->GetXaxis()->SetTitle("Plane");
05977   pRatioVsPlaneCoarse->GetXaxis()->CenterTitle();
05978   pRatioVsPlaneCoarse->GetYaxis()->SetTitle("Ratio");
05979   pRatioVsPlaneCoarse->GetYaxis()->CenterTitle();
05980   pRatioVsPlaneCoarse->SetLineColor(2);
05981   pRatioVsPlaneCoarse->SetLineWidth(3);
05982   //pRatioVsPlaneCoarse->SetBit(TH1::kCanRebin);
05983 
05984   TProfile* pRatioVsPlane1=new TProfile
05985     ("pRatioVsPlane1","pRatioVsPlane1",
05986      planeBins,firstPlaneBin,lastPlaneBin);
05987   pRatioVsPlane1->GetXaxis()->SetTitle("Plane");
05988   pRatioVsPlane1->GetXaxis()->CenterTitle();
05989   pRatioVsPlane1->GetYaxis()->SetTitle("Ratio");
05990   pRatioVsPlane1->GetYaxis()->CenterTitle();
05991   pRatioVsPlane1->SetLineColor(2);
05992   pRatioVsPlane1->SetLineWidth(3);
05993   //pRatioVsPlane1->SetBit(TH1::kCanRebin);
05994 
05995   TProfile* pRatioVsPlane2=new TProfile
05996     ("pRatioVsPlane2","pRatioVsPlane2",
05997      planeBins,firstPlaneBin,lastPlaneBin);
05998   pRatioVsPlane2->GetXaxis()->SetTitle("Plane");
05999   pRatioVsPlane2->GetXaxis()->CenterTitle();
06000   pRatioVsPlane2->GetYaxis()->SetTitle("Ratio");
06001   pRatioVsPlane2->GetYaxis()->CenterTitle();
06002   pRatioVsPlane2->SetLineColor(2);
06003   pRatioVsPlane2->SetLineWidth(3);
06004   //pRatioVsPlane2->SetBit(TH1::kCanRebin);
06005 
06006   Int_t coarseStBins=(lastStripBin-firstStripBin)/2;
06007   TProfile* pRatioVsStripO1=new TProfile
06008     ("pRatioVsStripO1","pRatioVsStripO1",
06009      coarseStBins,firstStripBin,lastStripBin);
06010   pRatioVsStripO1->GetXaxis()->SetTitle("Strip");
06011   pRatioVsStripO1->GetXaxis()->CenterTitle();
06012   pRatioVsStripO1->GetYaxis()->SetTitle("Ratio");
06013   pRatioVsStripO1->GetYaxis()->CenterTitle();
06014   pRatioVsStripO1->SetLineColor(2);
06015   pRatioVsStripO1->SetLineWidth(3);
06016   //pRatioVsStripO1->SetBit(TH1::kCanRebin);
06017 
06018   TProfile* pRatioVsStripO2=new TProfile
06019     ("pRatioVsStripO2","pRatioVsStripO2",
06020      coarseStBins,firstStripBin,lastStripBin);
06021   pRatioVsStripO2->GetXaxis()->SetTitle("Strip");
06022   pRatioVsStripO2->GetXaxis()->CenterTitle();
06023   pRatioVsStripO2->GetYaxis()->SetTitle("Ratio");
06024   pRatioVsStripO2->GetYaxis()->CenterTitle();
06025   pRatioVsStripO2->SetLineColor(2);
06026   pRatioVsStripO2->SetLineWidth(3);
06027   //pRatioVsStripO2->SetBit(TH1::kCanRebin);
06028 
06029   TProfile* pRatioVsStripE1=new TProfile
06030     ("pRatioVsStripE1","pRatioVsStripE1",
06031      coarseStBins,firstStripBin,lastStripBin);
06032   pRatioVsStripE1->GetXaxis()->SetTitle("Strip");
06033   pRatioVsStripE1->GetXaxis()->CenterTitle();
06034   pRatioVsStripE1->GetYaxis()->SetTitle("Ratio");
06035   pRatioVsStripE1->GetYaxis()->CenterTitle();
06036   pRatioVsStripE1->SetLineColor(2);
06037   pRatioVsStripE1->SetLineWidth(3);
06038   //pRatioVsStripE1->SetBit(TH1::kCanRebin);
06039 
06040   TProfile* pRatioVsStripE2=new TProfile
06041     ("pRatioVsStripE2","pRatioVsStripE2",
06042      coarseStBins,firstStripBin,lastStripBin);
06043   pRatioVsStripE2->GetXaxis()->SetTitle("Strip");
06044   pRatioVsStripE2->GetXaxis()->CenterTitle();
06045   pRatioVsStripE2->GetYaxis()->SetTitle("Ratio");
06046   pRatioVsStripE2->GetYaxis()->CenterTitle();
06047   pRatioVsStripE2->SetLineColor(2);
06048   pRatioVsStripE2->SetLineWidth(3);
06049   //pRatioVsStripE2->SetBit(TH1::kCanRebin);
06050 
06051   TProfile* pRatioVsStrip=new TProfile
06052     ("pRatioVsStrip","pRatioVsStrip",
06053      stripBins,firstStripBin,lastStripBin);
06054   pRatioVsStrip->GetXaxis()->SetTitle("Strip");
06055   pRatioVsStrip->GetXaxis()->CenterTitle();
06056   pRatioVsStrip->GetYaxis()->SetTitle("Ratio");
06057   pRatioVsStrip->GetYaxis()->CenterTitle();
06058   pRatioVsStrip->SetLineColor(4);
06059   pRatioVsStrip->SetLineWidth(3);
06060   //pRatioVsStrip->SetBit(TH1::kCanRebin);
06061 
06062   TProfile* pRatioVsStripCoarse=new TProfile
06063     ("pRatioVsStripCoarse","pRatioVsStripCoarse",12,0,24);
06064   pRatioVsStripCoarse->SetTitle("Ratio of S2S Cal. Const. (Cosmic/PS)");
06065   pRatioVsStripCoarse->GetXaxis()->SetTitle("Strip");
06066   pRatioVsStripCoarse->GetXaxis()->CenterTitle();
06067   pRatioVsStripCoarse->GetYaxis()->SetTitle("Ratio");
06068   pRatioVsStripCoarse->GetYaxis()->CenterTitle();
06069   pRatioVsStripCoarse->SetLineColor(2);
06070   pRatioVsStripCoarse->SetLineWidth(3);
06071   //pRatioVsStripCoarse->SetBit(TH1::kCanRebin);
06072 
06073   TProfile* pRatioVsStripCoarseFront=new TProfile
06074     ("pRatioVsStripCoarseFront","pRatioVsStripCoarseFront",12,0,24);
06075   pRatioVsStripCoarseFront->
06076     SetTitle("Ratio of S2S Cal. Const. Det. Front (Cosmic/PS)");
06077   pRatioVsStripCoarseFront->GetXaxis()->SetTitle("Strip");
06078   pRatioVsStripCoarseFront->GetXaxis()->CenterTitle();
06079   pRatioVsStripCoarseFront->GetYaxis()->SetTitle("Ratio");
06080   pRatioVsStripCoarseFront->GetYaxis()->CenterTitle();
06081   pRatioVsStripCoarseFront->SetLineColor(2);
06082   pRatioVsStripCoarseFront->SetLineWidth(3);
06083   //pRatioVsStripCoarseFront->SetBit(TH1::kCanRebin);
06084 
06085   TProfile* pRatioVsStripCoarseBack=new TProfile
06086     ("pRatioVsStripCoarseBack","pRatioVsStripCoarseBack",12,0,24);
06087   pRatioVsStripCoarseBack->
06088     SetTitle("Ratio of S2S Cal. Const. Det. Back (Cosmic/PS)");
06089   pRatioVsStripCoarseBack->GetXaxis()->SetTitle("Strip");
06090   pRatioVsStripCoarseBack->GetXaxis()->CenterTitle();
06091   pRatioVsStripCoarseBack->GetYaxis()->SetTitle("Ratio");
06092   pRatioVsStripCoarseBack->GetYaxis()->CenterTitle();
06093   pRatioVsStripCoarseBack->SetLineColor(2);
06094   pRatioVsStripCoarseBack->SetLineWidth(3);
06095   //pRatioVsStripCoarseBack->SetBit(TH1::kCanRebin);
06096 
06097   TProfile* pRatioVsStrip1=new TProfile
06098     ("pRatioVsStrip1","pRatioVsStrip1",
06099      stripBins,firstStripBin,lastStripBin);
06100   pRatioVsStrip1->GetXaxis()->SetTitle("Strip");
06101   pRatioVsStrip1->GetXaxis()->CenterTitle();
06102   pRatioVsStrip1->GetYaxis()->SetTitle("Ratio");
06103   pRatioVsStrip1->GetYaxis()->CenterTitle();
06104   pRatioVsStrip1->SetLineColor(4);
06105   pRatioVsStrip1->SetLineWidth(3);
06106   //pRatioVsStrip1->SetBit(TH1::kCanRebin);
06107 
06108   TProfile* pRatioVsStrip2=new TProfile
06109     ("pRatioVsStrip2","pRatioVsStrip2",
06110      stripBins,firstStripBin,lastStripBin);
06111   pRatioVsStrip2->GetXaxis()->SetTitle("Strip");
06112   pRatioVsStrip2->GetXaxis()->CenterTitle();
06113   pRatioVsStrip2->GetYaxis()->SetTitle("Ratio");
06114   pRatioVsStrip2->GetYaxis()->CenterTitle();
06115   pRatioVsStrip2->SetLineColor(4);
06116   pRatioVsStrip2->SetLineWidth(3);
06117   //pRatioVsStrip2->SetBit(TH1::kCanRebin);
06118 
06119   TProfile2D* pStVsPlRatio1=new TProfile2D
06120     ("pStVsPlRatio1","pStVsPlRatio1",
06121      planeBins,firstPlaneBin,lastPlaneBin,
06122      stripBins,firstStripBin,lastStripBin);
06123   pStVsPlRatio1->GetXaxis()->SetTitle("Plane");
06124   pStVsPlRatio1->GetXaxis()->CenterTitle();
06125   pStVsPlRatio1->GetYaxis()->SetTitle("Strip");
06126   pStVsPlRatio1->GetYaxis()->CenterTitle();
06127   //pStVsPlRatio1->SetBit(TH1::kCanRebin);
06128 
06129   TProfile2D* pStVsPlRatio2=new TProfile2D
06130     ("pStVsPlRatio2","pStVsPlRatio2",
06131      planeBins,firstPlaneBin,lastPlaneBin,
06132      stripBins,firstStripBin,lastStripBin);
06133   pStVsPlRatio2->GetXaxis()->SetTitle("Plane");
06134   pStVsPlRatio2->GetXaxis()->CenterTitle();
06135   pStVsPlRatio2->GetYaxis()->SetTitle("Strip");
06136   pStVsPlRatio2->GetYaxis()->CenterTitle();
06137   //pStVsPlRatio2->SetBit(TH1::kCanRebin);
06138 
06139   map<PlexStripEndId,Float_t> sigCorA;
06140   map<PlexStripEndId,Float_t> sigCorB;
06141 
06142   VldContext vldCtx(static_cast<Detector::Detector_t>(det),
06143                     SimFlag::kData,ts);
06144   vldCtx.Print();
06145   UInt_t year=0;
06146   ts.GetDate(true,0,&year);
06147 
06148   DbiResultPtr<CalStripToStrip> dbiCalStripToStrip;
06149 
06150   //get taskA
06151   UInt_t numRows=dbiCalStripToStrip.NewQuery(vldCtx,taskA);
06152 
06153   MSG("LIPlexMaps",Msg::kInfo)
06154     <<"New DB query produced "<<numRows<<" rows"
06155     <<", using task="<<taskA<<endl
06156     <<"Looping over rows..."<<endl;
06157   //loop over the rows
06158   for(UInt_t i=0;i<numRows;i++) {
06159     const CalStripToStrip* calStripToStrip=dbiCalStripToStrip.GetRow(i);
06160 
06161     Float_t response=calStripToStrip->GetResponse();
06162     PlexStripEndId seid=calStripToStrip->GetStripEndId();
06163     sigCorA[seid]=response;
06164   }
06165 
06166   //now get taskB
06167   numRows=dbiCalStripToStrip.NewQuery(vldCtx,taskB);
06168 
06169   MSG("LIPlexMaps",Msg::kInfo)
06170     <<"New DB query produced "<<numRows<<" rows"
06171     <<", using task="<<taskB<<endl
06172     <<"Looping over rows..."<<endl;
06173   //loop over the rows
06174   for(UInt_t i=0;i<numRows;i++) {
06175     const CalStripToStrip* calStripToStrip=dbiCalStripToStrip.GetRow(i);
06176 
06177     Float_t response=calStripToStrip->GetResponse();
06178     PlexStripEndId seid=calStripToStrip->GetStripEndId();
06179     sigCorB[seid]=response;
06180   }
06181 
06182   MSG("LIPlexMaps",Msg::kInfo)
06183     <<"Found maps, sigCorA size="<<sigCorA.size()
06184     <<", sigCorB size="<<sigCorB.size()<<endl;
06185   
06186   for (map<PlexStripEndId,Float_t>::iterator iterA=sigCorA.begin();
06187        iterA!=sigCorA.end();++iterA){
06188 
06189     map<PlexStripEndId,Float_t>::iterator iterB=
06190       sigCorB.find(iterA->first);
06191 
06192     if (iterB==sigCorB.end()){
06193       MSG("LIPlexMaps",Msg::kWarning)
06194         <<"Ahhhhhh, missing iterB"<<endl;
06195       continue;
06196     }
06197 
06198     Int_t planeA=iterA->first.GetPlane();
06199     Int_t stripA=iterA->first.GetStrip();
06200     Int_t seA=iterA->first.GetEnd();
06201     Int_t planeB=iterB->first.GetPlane();
06202     Int_t stripB=iterB->first.GetStrip();
06203     Int_t seB=iterB->first.GetEnd();
06204 
06205     MSG("LIPlexMaps",Msg::kDebug)
06206       <<"A: st="<<stripA<<", pl="<<planeA<<", se="<<seA<<endl;
06207     MSG("LIPlexMaps",Msg::kDebug)
06208       <<"B: st="<<stripB<<", pl="<<planeB<<", se="<<seB<<endl;
06209 
06210     Float_t sigCorDiff=1;
06211     if (iterB->second!=0){
06212       //iterA->second-iterB->second;
06213       sigCorDiff=iterA->second/iterB->second;
06214     }
06215     else{
06216       MSG("LIPlexMaps",Msg::kWarning)<<"Ahh, zero calib constant"<<endl;
06217     }
06218 
06219     //make bad channel cuts...
06220     //cut out plane zero, since it is known to be badly calibrated
06221     if (planeA==0){
06222       MAXMSG("LIPlexMaps",Msg::kWarning,1)
06223         <<"Cutting out plane 0. It's known to be bad!"<<endl;
06224       continue;
06225     }
06226     else if (planeA==25 && stripA==5){
06227       MAXMSG("LIPlexMaps",Msg::kWarning,1)
06228         <<"Cutting out plane 25, strip 5. It's used to be bad"<<endl;
06229       continue;
06230     }
06231     else if (planeA==35 && year==2002){
06232       MAXMSG("LIPlexMaps",Msg::kWarning,1)
06233         <<"Cutting out plane 35. It's bad in 2002"<<endl;
06234       continue;
06235     }
06236     else if ((planeA==56 || planeA==58) && seA==StripEnd::kWest && 
06237              year==2003){
06238       MAXMSG("LIPlexMaps",Msg::kWarning,1)
06239         <<"Cutting out plane 56 & 58. It's bad in 2003"<<endl;
06240       continue;
06241     }
06242     else if ((planeA==33 || planeA==35) && year==2003){
06243       MAXMSG("LIPlexMaps",Msg::kWarning,1)
06244         <<"Cutting out plane 33 & 35. It's bad in 2003"<<endl;
06245       continue;
06246     }
06247 
06248     //fill strip vs plane maps
06249     if (seA==StripEnd::kEast){
06250       pStVsPlRatio1->Fill(planeA,stripA,sigCorDiff);
06251     }
06252     else if (seA==StripEnd::kWest){
06253       pStVsPlRatio2->Fill(planeA,stripA,sigCorDiff);
06254     }
06255 
06256     //make fiducial volume cut
06257     if (stripA>=22 || stripA<=1){
06258       MAXMSG("LIPlexMaps",Msg::kWarning,1)
06259         <<"Making fiducial volume cut on strip"<<endl;
06260       continue;
06261     }
06262 
06263     hResponse->Fill(sigCorDiff);
06264     pRatioVsStrip->Fill(stripA,sigCorDiff);
06265     pRatioVsPlane->Fill(planeA,sigCorDiff);
06266     pRatioVsStripCoarse->Fill(stripA,sigCorDiff);
06267     if (planeA<=30) pRatioVsStripCoarseFront->Fill(stripA,sigCorDiff);
06268     if (planeA>30) pRatioVsStripCoarseBack->Fill(stripA,sigCorDiff);
06269     pRatioVsPlaneCoarse->Fill(planeA,sigCorDiff);
06270 
06271     if (seA==StripEnd::kEast){
06272       pRatioVsStrip1->Fill(stripA,sigCorDiff);
06273       pRatioVsPlane1->Fill(planeA,sigCorDiff);
06274       if (planeA%2==0) pRatioVsStripE1->Fill(stripA,sigCorDiff);
06275       else if (planeA%2==1) pRatioVsStripO1->Fill(stripA,sigCorDiff);
06276     }
06277     else if (seA==StripEnd::kWest){
06278       pRatioVsStrip2->Fill(stripA,sigCorDiff);
06279       pRatioVsPlane2->Fill(planeA,sigCorDiff);
06280       if (planeA%2==0) pRatioVsStripE2->Fill(stripA,sigCorDiff);
06281       else if (planeA%2==1) pRatioVsStripO2->Fill(stripA,sigCorDiff);
06282     }
06283   }
06284   
06285   TCanvas *cResponse=new TCanvas
06286     ("cResponse","cResponse",0,0,1000,800);
06287   cResponse->SetFillColor(0);
06288   cResponse->Divide(2,1);
06289   cResponse->cd(1);
06290   hResponse->Draw();
06291   cResponse->cd(2);
06292   hResponseErr->Draw();
06293 
06294   TCanvas *cPlSt=new TCanvas
06295     ("cPlSt","cPlSt",0,0,800,1000);
06296   cPlSt->SetFillColor(0);
06297   cPlSt->Divide(1,2);
06298   cPlSt->cd(1);
06299   pRatioVsPlane->Draw();
06300   cPlSt->cd(2);
06301   pRatioVsStrip->Draw();
06302 
06303   TCanvas *cPlStCoarse=new TCanvas
06304     ("cPlStCoarse","cPlStCoarse",0,0,800,1000);
06305   cPlStCoarse->SetFillColor(0);
06306   cPlStCoarse->Divide(1,2);
06307   cPlStCoarse->cd(1);
06308   pRatioVsPlaneCoarse->Draw();
06309   cPlStCoarse->cd(2);
06310   pRatioVsStripCoarse->Draw();
06311 
06312   TCanvas *cStCoarse=new TCanvas
06313     ("cStCoarse","cStCoarse",0,0,800,1000);
06314   cStCoarse->SetFillColor(0);
06315   cStCoarse->Divide(1,2);
06316   cStCoarse->cd(1);
06317   pRatioVsStripCoarseFront->Draw();
06318   cStCoarse->cd(2);
06319   pRatioVsStripCoarseBack->Draw();
06320 
06321   TCanvas *cPlSt1_2=new TCanvas
06322     ("cPlSt1_2","cPlSt1_2",0,0,1000,1000);
06323   cPlSt1_2->SetFillColor(0);
06324   cPlSt1_2->Divide(2,2);
06325   cPlSt1_2->cd(1);
06326   pRatioVsPlane1->Draw();
06327   cPlSt1_2->cd(2);
06328   pRatioVsPlane2->Draw();
06329   cPlSt1_2->cd(3);
06330   pRatioVsStrip1->Draw();
06331   cPlSt1_2->cd(4);
06332   pRatioVsStrip2->Draw();
06333 
06334   TCanvas *cPlSt1_2OE=new TCanvas
06335     ("cPlSt1_2OE","cPlSt1_2OE",0,0,1000,1000);
06336   cPlSt1_2OE->SetFillColor(0);
06337   cPlSt1_2OE->Divide(2,2);
06338   cPlSt1_2OE->cd(1);
06339   pRatioVsStripO1->Draw();
06340   cPlSt1_2OE->cd(2);
06341   pRatioVsStripE1->Draw();
06342   cPlSt1_2OE->cd(3);
06343   pRatioVsStripO2->Draw();
06344   cPlSt1_2OE->cd(4);
06345   pRatioVsStripE2->Draw();
06346 
06347   TCanvas *cStVsPl=new TCanvas
06348     ("cStVsPl","cStVsPl",0,0,800,800);
06349   cStVsPl->SetFillColor(0);
06350   cStVsPl->Divide(1,2);
06351   cStVsPl->cd(1);
06352   pStVsPlRatio1->Draw("colz");
06353   cStVsPl->cd(2);
06354   pStVsPlRatio2->Draw("colz");
06355 
06356   MSG("LIPlexMaps",Msg::kInfo)
06357     <<endl<<" ** Finished the CompareStripToStrip() method... **"<<endl;
06358 }

void LIPlexMaps::DriftWithTime ( VldRange  vldRng,
Float_t  pointSpacingMinutes = 20 
)

Definition at line 7114 of file LIPlexMaps.cxx.

References bfld::AsString(), PlexStripEndId::BuildPlnStripEndKey(), exit(), LILookup::FIRSTEND, LILookup::FIRSTLED, LILookup::FIRSTPLANE, LILookup::FIRSTPULSERBOX, LILookup::FIRSTSTRIP, fLookup, Form(), fS, VldRange::GetDetectorMask(), PulserRawDriftF::GetError(), PulserRawDrift::GetError(), PulserRawDriftF::GetMean(), PulserRawDrift::GetMean(), PulserRawDriftF::GetNumEntries(), PulserRawDrift::GetNumEntries(), GetRawPinLedMap(), GetRawPinMap(), GetRefAdcPinRatio(), DbiResultPtr< T >::GetRowByIndex(), VldTimeStamp::GetSec(), VldRange::GetSimMask(), PulserRawDrift::GetStripEnd(), VldRange::GetTimeEnd(), VldRange::GetTimeStart(), DbiResultPtr< T >::GetValidityRec(), DbiValidityRec::GetVldRange(), MsgService::Instance(), IsScintStrip(), Detector::kCalDet, SimFlag::kData, Msg::kDebug, StripEnd::kEast, Detector::kFar, Msg::kInfo, Detector::kNear, StripEnd::kUnknown, Msg::kVerbose, Msg::kWarning, StripEnd::kWest, LILookup::LASTLED, LILookup::LASTPLANE, LILookup::LASTPULSERBOX, LILookup::LASTSTRIP, MSG, DbiResultPtr< T >::NewQuery(), NormaliseVector(), LILookup::NUMENDS, LILookup::NUMPLANES, LILookup::NUMSTRIPS, VldTimeStamp::Print(), LILookup::SECONDEND, LILookup::SetDetector(), SetGraphAxisEtc(), LILookup::TGraphVect(), and LILookup::UnencodePlnStripEndKey().

07116 {
07117   MSG("LIPlexMaps",Msg::kInfo)
07118     <<endl<<" ** Running the DriftWithTime method... ** "<<endl; 
07119 
07120   //get all the info from the validity range
07121   VldTimeStamp startTime=vldRng.GetTimeStart();
07122   VldTimeStamp endTime=vldRng.GetTimeEnd();
07123   const Detector::Detector_t det=static_cast
07124     <Detector::Detector_t>(vldRng.GetDetectorMask());
07125   const SimFlag::ESimFlag simFlag=static_cast
07126     <SimFlag::ESimFlag>(vldRng.GetSimMask());
07127 
07128   //make a vld context for the start time
07129   VldContext startVldCtx(det,simFlag,startTime);
07130 
07131   //only set detector once at the highest/first point
07132   if (det==Detector::kCalDet){
07133     fLookup.SetDetector(static_cast<Int_t>(det));
07134   }
07135   else if (det==Detector::kFar){
07136     fLookup.SetDetector(static_cast<Int_t>(det));
07137   }
07138   else if (det==Detector::kNear){
07139     fLookup.SetDetector(static_cast<Int_t>(det));
07140   }
07141   else{
07142     MSG("LIPlexMaps",Msg::kWarning)
07143       <<"Detector not supported="
07144       <<Detector::AsString(det)<<endl
07145       <<"Program will exit here..."<<endl;
07146     exit(1);
07147   }
07148 
07149   DbiResultPtr<PulserRawDrift> dbiPulserDrift;
07150   DbiResultPtr<PulserRawDriftF> dbiPulserDriftF;
07151 
07152   MSG("LIPlexMaps",Msg::kInfo)
07153     <<"Creating maps..."<<endl;
07154   //a map to hold the reference pin info
07155   map<Int_t,LIPulserPin> refAdcPinRatio=this->
07156     GetRefAdcPinRatio(startVldCtx);//get it once to start with
07157   //maps to hold drift point info
07158   map<UInt_t,LIRun> stripEnds;
07159   map<PlexLedId,LIRun> pins;
07160 
07161   VldContext* vldCtx=0;
07162   const PulserRawDrift *pulserDrift;
07163   const PulserRawDriftF *pulserDriftF;
07164   string sLastVldRange="Not set!";
07165 
07166   //declare stripendtype
07167   StripEnd::EStripEnd stripEndType=StripEnd::kUnknown;
07168   StripEnd::EStripEnd stripEndTypeF=StripEnd::kUnknown;
07169 
07170   //create a plex handle
07171   PlexHandle* plexHandle=0;
07172 
07173   Int_t pointSpacingSecs=static_cast<Int_t>(pointSpacingMinutes*60);
07174   Int_t startTimeSecs=startTime.GetSec();
07175   Int_t endTimeSecs=endTime.GetSec();
07176   Int_t secCounter=startTimeSecs;
07177 
07178   MSG("LIPlexMaps",Msg::kInfo)
07179     <<"Starting main loop over vld range..."<<endl;
07180   while(secCounter<endTimeSecs){
07181     VldTimeStamp currentLoopTime(secCounter,0);
07182 
07183     //print out the current loop time
07184     if (MsgService::Instance()->IsActive("LIPlexMaps",Msg::kInfo)){
07185       MSG("LIPlexMaps",Msg::kInfo)<<"New Loop ";
07186       currentLoopTime.Print();
07187     }
07188     vldCtx=new VldContext(Detector::kCalDet,SimFlag::kData,
07189                           currentLoopTime);
07190 
07191     //check for a new pin reference point
07192     map<Int_t,LIPulserPin> tempRefAdcPinRatio=
07193       this->GetRefAdcPinRatio(*vldCtx);
07194     if (tempRefAdcPinRatio.size()>0){
07195       refAdcPinRatio=tempRefAdcPinRatio;
07196       MSG("LIPlexMaps",Msg::kInfo)
07197         <<"New pin reference point, regenerated map"<<endl;
07198     }
07199     else{
07200       MSG("LIPlexMaps",Msg::kDebug)
07201         <<"Checked for new pin reference point, doing nothing"
07202         <<" because same as before"<<endl;
07203     }
07204 
07205     //create a plex handle
07206     plexHandle=new PlexHandle(*vldCtx);
07207 
07208     UInt_t numRows=dbiPulserDrift.NewQuery(*vldCtx,0);
07209     
07210     if (numRows!=static_cast<UInt_t>(NUMPLANES*NUMSTRIPS*NUMENDS)){
07211       MSG("LIPlexMaps",Msg::kWarning)
07212         <<"PulserRawDrift only contains "<<numRows<<" rows"
07213         <<", it should have "<<NUMPLANES*NUMSTRIPS*NUMENDS<<endl;
07214     }
07215 
07216     string sVldRange=dbiPulserDrift.GetValidityRec()->GetVldRange().
07217       AsString();
07218 
07219     MSG("LIPlexMaps",Msg::kVerbose)
07220       <<"Vld range = "<<sVldRange<<endl;
07221 
07222     if (sVldRange==sLastVldRange){
07223       MSG("LIPlexMaps",Msg::kInfo)
07224         <<"Skipping this point because validity range is the same"
07225         <<" as the previous point"<<endl;
07226       MSG("LIPlexMaps",Msg::kDebug)
07227         <<endl
07228         <<"VldRange="<<sVldRange<<endl
07229         <<"Previous VldRange="<<sLastVldRange<<endl;
07230       //set the last range now it has been used in this loop
07231       sLastVldRange=sVldRange;
07232 
07233       //increment the time
07234       secCounter+=pointSpacingSecs;
07235         
07236       //delete currentLoopTime;
07237       delete vldCtx;
07238       delete plexHandle;
07239       continue;
07240     }
07241 
07242     //set the last range now it has been used in this loop
07243     sLastVldRange=sVldRange;
07244 
07245     map<Int_t,Float_t> rawPin=this->GetRawPinMap(*vldCtx);
07246     map<PlexLedId,LIPulserPin> rawPinLedMap=this->
07247       GetRawPinLedMap(*vldCtx);
07248     UInt_t numRowsF=dbiPulserDriftF.NewQuery(*vldCtx,0);
07249 
07250     if (numRows!=numRowsF){
07251       MSG("LIPlexMaps",Msg::kInfo)
07252         <<"Near and far end tables are different sizes! Near="
07253         <<numRows<<", far="<<numRowsF<<endl;
07254     }
07255 
07257     //loop over the pin values for all the leds
07259     for(Int_t pb=FIRSTPULSERBOX;pb<=LASTPULSERBOX;pb++){
07260       for(Int_t led=FIRSTLED;led<=LASTLED;led++){
07261         //create an ledid to then use the encoded value
07262         PlexLedId ledId(det,pb,led);
07263 
07264         //add the point
07265         pins[ledId].AddPoint
07266           (secCounter,rawPinLedMap[ledId].mean,
07267            rawPinLedMap[ledId].error,rawPinLedMap[ledId].numEnt);
07268 
07269         MSG("LIPlexMaps",Msg::kDebug)
07270           <<"Adding point to lirun "<<rawPinLedMap[ledId].mean<<endl;
07271       }
07272     }
07275     
07276     for(Int_t pl=FIRSTPLANE;pl<=LASTPLANE;pl++){
07277         
07278       //quick hack
07279       if (pl>5) continue;
07280 
07281       for(Int_t st=FIRSTSTRIP;st<=LASTSTRIP;st++){
07282         for(Int_t end=FIRSTEND;end<=SECONDEND;end++){
07283 
07284           if (end==StripEnd::kEast) stripEndType=StripEnd::kEast;
07285           else if (end==StripEnd::kWest) stripEndType=StripEnd::kWest;
07286 
07287           if (end==StripEnd::kEast) stripEndTypeF=StripEnd::kWest;
07288           else if(end==StripEnd::kWest) stripEndTypeF=StripEnd::kEast;
07289 
07290           PlexStripEndId stripEndId(det,pl,st,stripEndType);
07291           PlexStripEndId stripEndIdF(det,pl,st,stripEndTypeF);
07292 
07293           //skip the stripends that aren't attached to readout
07294           if (!this->IsScintStrip(stripEndId,plexHandle)) continue;
07295 
07296           pulserDrift=0;//initialise
07297           pulserDrift=dbiPulserDrift.GetRowByIndex
07298             (stripEndId.BuildPlnStripEndKey());
07299           //get the opposite strip end for the to do ND/FD
07300           pulserDriftF=0;//initialise
07301           pulserDriftF=dbiPulserDriftF.GetRowByIndex
07302             (stripEndIdF.BuildPlnStripEndKey());
07303 
07304           if (pulserDrift){
07305             Float_t mean=pulserDrift->GetMean();
07306             Float_t error=pulserDrift->GetError();
07307             Float_t numEntries=pulserDrift->GetNumEntries();
07308             UInt_t seidkey=pulserDrift->GetStripEnd();
07309 
07310             Float_t meanF=-1;
07311             Float_t errorF=-1;
07312             Float_t numEntriesF=-1;
07313 
07314             if (pulserDriftF){
07315               meanF=pulserDriftF->GetMean();
07316               errorF=pulserDriftF->GetError();
07317               numEntriesF=pulserDriftF->GetNumEntries();
07318             }
07319 
07320             Float_t nearOverFar=-1;
07321             if (meanF>0){
07322               if (stripEndType==StripEnd::kWest){
07323                 nearOverFar=mean/meanF;
07324               }
07325               else if (stripEndType==StripEnd::kEast){
07326                 nearOverFar=meanF/mean;
07327               }
07328             }
07329 
07330             Float_t adcPinRatio=-1;
07331             if (rawPin[seidkey]>0){
07332               adcPinRatio=mean/rawPin[seidkey];
07333             }
07334             else {
07335               MSG("LIPlexMaps",Msg::kDebug)
07336                 <<"Raw pin has zero mean!"<<endl;
07337             }
07338 
07339             Float_t gainDrift=-1;
07340             if (refAdcPinRatio[seidkey].mean>0){//protect fpe
07341               if (adcPinRatio>0){//only bother if this is good
07342                 gainDrift=adcPinRatio/refAdcPinRatio[seidkey].mean;
07343               }
07344             }
07345             else {
07346               MSG("LIPlexMaps",Msg::kWarning)
07347                 <<"Ref ADC/PIN ratio has zero mean!"<<endl;
07348             }
07349 
07350             MSG("LIPlexMaps",Msg::kDebug)
07351               <<"Gain drift="<<gainDrift<<endl;
07352               
07353             if (numEntries>500 && gainDrift>0){
07354               stripEnds[seidkey].AddPoint(secCounter,mean,error,
07355                                           numEntries,gainDrift,
07356                                           nearOverFar);
07357             }
07358               
07359             Int_t plane=-1;
07360             Int_t strip=-1;
07361             Int_t end=-1;
07362             fLookup.UnencodePlnStripEndKey(seidkey,det,plane,strip,
07363                                            end);
07364               
07365             string sMean=Form("%.1f",mean);
07366             string sError=Form("%.2f",error);
07367             string sNumEntries=Form("%.0f",numEntries);
07368             string sSeId=Form("%d",seidkey);
07369 
07370             MSG("LIPlexMaps",Msg::kDebug)
07371               <<"("<<plane<<";"<<strip<<";"<<end<<")"
07372               <<" Mean="<<sMean<<", error="<<sError
07373               <<", numEnt="<<sNumEntries
07374               <<", seidkey="<<sSeId<<endl;
07375           }
07376         }
07377       }
07378     }
07379 
07380     //increment the time
07381     secCounter+=pointSpacingSecs;
07382 
07383     //delete currentLoopTime;
07384     delete vldCtx;
07385     delete plexHandle;
07386   }
07387   //}
07388   
07389   MSG("LIPlexMaps",Msg::kInfo)
07390     <<"Finished main loop over vld range"<<endl;
07391 
07392   //declare the canvas sizes
07393   Int_t canvasXmax=1200;
07394   Int_t canvasYmax=600;
07395 
07396   //create the canvases
07397   TCanvas *cMeanVsTime=new TCanvas("cMeanVsTime","MeanVsTime",
07398                                    0,0,canvasXmax,canvasYmax);
07399   cMeanVsTime->SetFillColor(0);
07400   TCanvas *cErrorVsTime=new TCanvas("cErrorVsTime","ErrorVsTime",
07401                                     0,0,canvasXmax,canvasYmax);
07402   cErrorVsTime->SetFillColor(0);
07403   TCanvas *cNumEntVsTime=new TCanvas("cNumEntVsTime","NumEntVsTime",
07404                                      0,0,canvasXmax,canvasYmax);
07405   cNumEntVsTime->SetFillColor(0);
07406   TCanvas *cGainDriftVsTime=new TCanvas("cGainDriftVsTime",
07407                                         "GainDriftVsTime",
07408                                         0,0,canvasXmax,canvasYmax);
07409   cGainDriftVsTime->SetFillColor(0);
07410   TCanvas *cGainDriftVsTimeZoom=new TCanvas("cGainDriftVsTimeZoom",
07411                                         "GainDriftVsTimeZoom",
07412                                         0,0,canvasXmax,canvasYmax);
07413   cGainDriftVsTimeZoom->SetFillColor(0);
07414   TCanvas *cPinVsTime=new TCanvas("cPinVsTime","PinVsTime",
07415                                    0,0,canvasXmax,canvasYmax);
07416   cPinVsTime->SetFillColor(0);
07417   TCanvas *cNormPinVsTime=new TCanvas("cNormPinVsTime","NormPinVsTime",
07418                                       0,0,canvasXmax,canvasYmax);
07419   cNormPinVsTime->SetFillColor(0);
07420   TCanvas *cNormPinVsTimeZoom=new TCanvas("cNormPinVsTimeZoom",
07421                                           "NormPinVsTimeZoom",
07422                                           0,0,canvasXmax,canvasYmax);
07423   cNormPinVsTimeZoom->SetFillColor(0);
07424   TCanvas *cPinErrorVsTime=new TCanvas("cPinErrorVsTime",
07425                                        "PinErrorVsTime",
07426                                        0,0,canvasXmax,canvasYmax);
07427   cPinErrorVsTime->SetFillColor(0);
07428   TCanvas *cPinNumEntVsTime=new TCanvas("cPinNumEntVsTime",
07429                                         "PinNumEntVsTime",
07430                                         0,0,canvasXmax,canvasYmax);
07431   cPinNumEntVsTime->SetFillColor(0);
07432   TCanvas *cNearOverFarVsTime=new TCanvas("cNearOverFarVsTime",
07433                                     "NearOverFarVsTime",
07434                                     0,0,canvasXmax,canvasYmax);
07435   cNearOverFarVsTime->SetFillColor(0);
07436   TCanvas *cNormNearOverFarVsTime=new TCanvas("cNormNearOverFarVsTime",
07437                                     "NormNearOverFarVsTime",
07438                                     0,0,canvasXmax,canvasYmax);
07439   cNormNearOverFarVsTime->SetFillColor(0);
07440 
07441   string sMeanVsTime="MeanVsTime.ps";
07442   string sErrorVsTime="ErrorVsTime.ps";
07443   string sNumEntVsTime="NumEntVsTime.ps";
07444   string sGainDriftVsTime="GainDriftVsTime.ps";
07445   string sGainDriftVsTimeZoom="GainDriftVsTimeZoom.ps";
07446   string sPinVsTime="PinVsTime.ps";
07447   string sNormPinVsTime="NormPinVsTime.ps";
07448   string sNormPinVsTimeZoom="NormPinVsTimeZoom.ps";
07449   string sPinErrorVsTime="PinErrorVsTime.ps";
07450   string sPinNumEntVsTime="PinNumEntVsTime.ps";
07451   string sNearOverFarVsTime="NearOverFarVsTime.ps";
07452   string sNormNearOverFarVsTime="NormNearOverFarVsTime.ps";
07453 
07454   //open the files
07455   cMeanVsTime->Print((sMeanVsTime+"[").c_str());
07456   cErrorVsTime->Print((sErrorVsTime+"[").c_str());
07457   cNumEntVsTime->Print((sNumEntVsTime+"[").c_str());
07458   cGainDriftVsTime->Print((sGainDriftVsTime+"[").c_str());
07459   cGainDriftVsTimeZoom->Print((sGainDriftVsTimeZoom+"[").c_str());
07460   cPinVsTime->Print((sPinVsTime+"[").c_str());
07461   cNormPinVsTime->Print((sNormPinVsTime+"[").c_str());
07462   cNormPinVsTimeZoom->Print((sNormPinVsTimeZoom+"[").c_str());
07463   cPinErrorVsTime->Print((sPinErrorVsTime+"[").c_str());
07464   cPinNumEntVsTime->Print((sPinNumEntVsTime+"[").c_str());
07465   cNearOverFarVsTime->Print((sNearOverFarVsTime+"[").c_str());
07466   cNormNearOverFarVsTime->Print((sNormNearOverFarVsTime+"[").c_str());
07467 
07468   gErrorIgnoreLevel=1;//suppress printing each page messages
07469 
07471   //Loop over the pins
07473   map<PlexLedId,LIRun>::iterator pinIt=pins.begin();
07474 
07475   MSG("LIPlexMaps",Msg::kInfo)
07476     <<"Iterating over the pins..."<<endl;
07477   while(pinIt!=pins.end()){
07478 
07479     //get the vectors, the names are all wrong but 
07480     //the correct values were stored above
07481     vector<Double_t> vTime=pinIt->second.GetPh();
07482     vector<Double_t> vMean=pinIt->second.GetAdc();
07483     vector<Double_t> vError=pinIt->second.GetPin(1);
07484     vector<Double_t> vNumEnt=pinIt->second.GetPin(2);
07485 
07486     TGraph* gPinVsTime=0;
07487     TGraph* gNormPinVsTime=0;
07488     TGraph* gNormPinVsTimeZoom=0;
07489     TGraph* gPinErrorVsTime=0;
07490     TGraph* gPinNumEntVsTime=0;
07491     
07492     gPinVsTime=TGraphVect(vTime,vMean);
07493     gPinErrorVsTime=TGraphVect(vTime,vError);
07494     gPinNumEntVsTime=TGraphVect(vTime,vNumEnt);
07495 
07496     string sPb=Form("%d",pinIt->first.GetPulserBox());
07497     string sLed=Form("%d",pinIt->first.GetLedInBox());
07498 
07499     MSG("LIPlexMaps",Msg::kInfo)
07500       <<"Printing ("<<sPb<<":"<<sLed<<")"
07501       <<" to postscript"<<endl;
07502 
07503     cPinVsTime->cd();
07504     cPinVsTime->Clear();
07505     fS="Light level drifts (PIN ADC) with time (PB,LED)=("+
07506       sPb+","+sLed+")";
07507     gPinVsTime->Draw("AP");
07508     gPinVsTime->SetTitle(fS.c_str());
07509     gPinVsTime->GetYaxis()->SetTitle("Pin ADC");
07510     gPinVsTime->GetYaxis()->CenterTitle();
07511     this->SetGraphAxisEtc(gPinVsTime,startTimeSecs,endTimeSecs);
07512 
07513     //normalise the vector then get the graph
07514     this->NormaliseVector(vMean,2);
07515     gNormPinVsTime=TGraphVect(vTime,vMean);
07516     gNormPinVsTimeZoom=TGraphVect(vTime,vMean);
07517 
07518     cNormPinVsTime->cd();
07519     cNormPinVsTime->Clear();
07520     fS="Fractional Drifts in PIN ADC with time (PB,LED)=("+
07521       sPb+","+sLed+")";
07522     gNormPinVsTime->Draw("AP");
07523     gNormPinVsTime->SetTitle(fS.c_str());
07524     gNormPinVsTime->GetYaxis()->SetTitle("Normalised Pin ADC");
07525     gNormPinVsTime->GetYaxis()->CenterTitle();
07526     this->SetGraphAxisEtc(gNormPinVsTime,startTimeSecs,endTimeSecs); 
07527 
07528     cNormPinVsTimeZoom->cd();
07529     cNormPinVsTimeZoom->Clear();
07530     fS="Fractional Drifts in PIN ADC with time, zoomed (PB,LED)=("+
07531       sPb+","+sLed+")";
07532     gNormPinVsTimeZoom->Draw("AP");
07533     gNormPinVsTimeZoom->SetTitle(fS.c_str());
07534     gNormPinVsTimeZoom->GetYaxis()->SetTitle("Normalised Pin ADC");
07535     gNormPinVsTimeZoom->GetYaxis()->CenterTitle();
07536     this->SetGraphAxisEtc(gNormPinVsTimeZoom,startTimeSecs,endTimeSecs);
07537     gNormPinVsTimeZoom->SetMinimum(0.97);
07538     gNormPinVsTimeZoom->SetMaximum(1.03);
07539     //gNormPinVsTimeZoom->SetMinimum(1.13);
07540     //gNormPinVsTimeZoom->SetMaximum(1.23);
07541 
07542     cPinErrorVsTime->cd();
07543     cPinErrorVsTime->Clear();
07544     fS="Error on the PIN vs time (PB,LED)=("+
07545       sPb+","+sLed+")";
07546     gPinErrorVsTime->Draw("AP");
07547     gPinErrorVsTime->SetTitle(fS.c_str());
07548     gPinErrorVsTime->GetYaxis()->SetTitle("PinError in ADCs");
07549     gPinErrorVsTime->GetYaxis()->CenterTitle();
07550     this->SetGraphAxisEtc(gPinErrorVsTime,startTimeSecs,endTimeSecs); 
07551 
07552     cPinNumEntVsTime->cd();
07553     cPinNumEntVsTime->Clear();
07554     fS="PIN Number of Entries vs Time (PB,LED)=("+
07555       sPb+","+sLed+")";
07556     gPinNumEntVsTime->Draw("AP");
07557     gPinNumEntVsTime->SetTitle(fS.c_str());
07558     gPinNumEntVsTime->GetYaxis()->SetTitle("Pin's Number of Entries");
07559     gPinNumEntVsTime->GetYaxis()->CenterTitle();
07560     this->SetGraphAxisEtc(gPinNumEntVsTime,startTimeSecs,endTimeSecs); 
07561 
07562     //print to postscript
07563     cPinVsTime->Print(sPinVsTime.c_str());
07564     cNormPinVsTime->Print(sNormPinVsTime.c_str());
07565     cNormPinVsTimeZoom->Print(sNormPinVsTimeZoom.c_str());
07566     cPinErrorVsTime->Print(sPinErrorVsTime.c_str());
07567     cPinNumEntVsTime->Print(sPinNumEntVsTime.c_str());
07568 
07569     //avoid program getting too big
07570     delete gPinVsTime;
07571     delete gNormPinVsTime;
07572     delete gNormPinVsTimeZoom;
07573     delete gPinErrorVsTime;
07574     delete gPinNumEntVsTime;
07575     
07576     //go to next pin
07577     pinIt++;
07578   }
07579   MSG("LIPlexMaps",Msg::kInfo)
07580     <<"Finished iterating over the pins"<<endl;
07581 
07583   //Now look at the stripends
07585   map<UInt_t,LIRun>::iterator seIt=stripEnds.begin();
07586   Int_t pageCounter=0;
07587 
07588   MSG("LIPlexMaps",Msg::kInfo)
07589     <<endl<<"Iterating over the stripends..."
07590     <<endl<<"Map size="<<stripEnds.size()<<endl;
07591   while(seIt!=stripEnds.end()){
07592 
07593     Int_t seidkey=seIt->first;
07594     Int_t plane=-1;
07595     Int_t strip=-1;
07596     Int_t end=-1;
07597     fLookup.UnencodePlnStripEndKey(seidkey,det,plane,strip,end);
07598 
07599     string sPlane=Form("%d",plane);
07600     string sStrip=Form("%d",strip);
07601     string sEnd=Form("%d",end);
07602 
07603     //get the vectors, the names are all wrong but 
07604     //the correct values were stored above
07605     vector<Double_t> vTime=seIt->second.GetPh();
07606     vector<Double_t> vMean=seIt->second.GetAdc();
07607     vector<Double_t> vError=seIt->second.GetPin(1);
07608     vector<Double_t> vNumEnt=seIt->second.GetPin(2);
07609     vector<Double_t> vGainDrift=seIt->second.GetAdcF();
07610     vector<Double_t> vGainDriftZoom=seIt->second.GetAdcF();
07611     vector<Double_t> vNearOverFar=seIt->second.GetAdcLow();
07612 
07613     TGraph* gMeanVsTime=0;
07614     TGraph* gErrorVsTime=0;
07615     TGraph* gNumEntVsTime=0;
07616     TGraph* gGainDriftVsTime=0;
07617     TGraph* gGainDriftVsTimeZoom=0;
07618     TGraph* gNearOverFarVsTime=0;
07619     TGraph* gNormNearOverFarVsTime=0;
07620     
07621     gMeanVsTime=TGraphVect(vTime,vMean);
07622     gErrorVsTime=TGraphVect(vTime,vError);
07623     gNumEntVsTime=TGraphVect(vTime,vNumEnt);
07624     gGainDriftVsTime=TGraphVect(vTime,vGainDrift);
07625     gGainDriftVsTimeZoom=TGraphVect(vTime,vGainDriftZoom);
07626 
07627     gNearOverFarVsTime=0;
07628     if (vNearOverFar.size()>0){
07629       gNearOverFarVsTime=TGraphVect(vTime,vNearOverFar);
07630     }
07631 
07632     if (gMeanVsTime){
07633       cMeanVsTime->cd();
07634       cMeanVsTime->Clear();
07635       fS="Mean drifting with time (Pl,St,End)=("+sPlane+","+sStrip+","+
07636         sEnd+")";
07637       gMeanVsTime->Draw("AP");
07638       gMeanVsTime->SetTitle(fS.c_str());
07639       gMeanVsTime->GetYaxis()->SetTitle("Mean ADC");
07640       gMeanVsTime->GetYaxis()->CenterTitle();
07641       this->SetGraphAxisEtc(gMeanVsTime,startTimeSecs,endTimeSecs); 
07642     }
07643     else{
07644       //go to next se
07645       seIt++;
07646       MSG("LIPlexMaps",Msg::kInfo)
07647         <<"Skipping: ("<<plane<<";"<<strip<<";"<<end<<")"<<endl;
07648       continue;
07649     }
07650 
07651     if (gErrorVsTime){
07652       cErrorVsTime->cd();
07653       cErrorVsTime->Clear();
07654       fS="Error on mean over time (Pl,St,End)=("+sPlane+","+sStrip+","+
07655         sEnd+")";
07656       gErrorVsTime->Draw("AP");
07657       gErrorVsTime->SetTitle(fS.c_str());
07658       gErrorVsTime->GetYaxis()->SetTitle("Error (ADCs)");
07659       gErrorVsTime->GetYaxis()->CenterTitle();
07660       this->SetGraphAxisEtc(gErrorVsTime,startTimeSecs,endTimeSecs); 
07661     }
07662 
07663     if (gNumEntVsTime){
07664       cNumEntVsTime->cd();
07665       cNumEntVsTime->Clear();
07666       fS="NumEnt over time (Pl,St,End)=("+sPlane+","+sStrip+","+
07667         sEnd+")";
07668       gNumEntVsTime->Draw("AP");
07669       gNumEntVsTime->SetTitle(fS.c_str());
07670       gNumEntVsTime->GetYaxis()->SetTitle("NumEnt");
07671       gNumEntVsTime->GetYaxis()->CenterTitle();
07672       this->SetGraphAxisEtc(gNumEntVsTime,startTimeSecs,endTimeSecs);
07673     }
07674 
07675     if (gGainDriftVsTime){
07676       cGainDriftVsTime->cd();
07677       cGainDriftVsTime->Clear();
07678       fS="Gain drift over time (Pl,St,End)=("+sPlane+","+sStrip+","+
07679         sEnd+")";
07680       gGainDriftVsTime->Draw("AP");
07681       gGainDriftVsTime->SetTitle(fS.c_str());
07682       gGainDriftVsTime->GetYaxis()->SetTitle("Gain Drift");
07683       gGainDriftVsTime->GetYaxis()->CenterTitle();
07684       this->SetGraphAxisEtc(gGainDriftVsTime,startTimeSecs,
07685                             endTimeSecs); 
07686     }
07687       
07688     if (gGainDriftVsTimeZoom){
07689       cGainDriftVsTimeZoom->cd();
07690       cGainDriftVsTimeZoom->Clear();
07691       fS="Gain drift over time - zoomed (Pl,St,End)=("+
07692         sPlane+","+sStrip+","+sEnd+")";
07693       gGainDriftVsTimeZoom->Draw("AP");
07694       gGainDriftVsTimeZoom->SetTitle(fS.c_str());
07695       gGainDriftVsTimeZoom->GetYaxis()->SetTitle("Gain Drift");
07696       gGainDriftVsTimeZoom->GetYaxis()->CenterTitle();
07697       this->SetGraphAxisEtc(gGainDriftVsTimeZoom,startTimeSecs,
07698                             endTimeSecs);  
07699       gGainDriftVsTimeZoom->SetMaximum(1.11);
07700       gGainDriftVsTimeZoom->SetMinimum(0.89);
07701     }
07702 
07703     if (gNearOverFarVsTime){
07704       cNearOverFarVsTime->cd();
07705       cNearOverFarVsTime->Clear();
07706       fS="Ratio of ND/FD vs Time (Pl,St,End)=("+
07707         sPlane+","+sStrip+","+sEnd+")";
07708       gNearOverFarVsTime->Draw("AP");
07709       gNearOverFarVsTime->SetTitle(fS.c_str());
07710       gNearOverFarVsTime->GetYaxis()->SetTitle("Ratio ND/FD");
07711       gNearOverFarVsTime->GetYaxis()->CenterTitle();
07712       this->SetGraphAxisEtc(gNearOverFarVsTime,startTimeSecs,
07713                             endTimeSecs);
07714     }
07715     
07716     gNormNearOverFarVsTime=0;
07717     if (vNearOverFar.size()>0){
07718       this->NormaliseVector(vNearOverFar);
07719       gNormNearOverFarVsTime=TGraphVect(vTime,vNearOverFar);
07720     }
07721 
07722     if (gNormNearOverFarVsTime){
07723       cNormNearOverFarVsTime->cd();
07724       cNormNearOverFarVsTime->Clear();
07725       fS="Ratio of Normalised ND/FD vs Time (Pl,St,End)=("+
07726         sPlane+","+sStrip+","+sEnd+")";
07727       gNormNearOverFarVsTime->Draw("AP");
07728       gNormNearOverFarVsTime->SetTitle(fS.c_str());
07729       gNormNearOverFarVsTime->GetYaxis()->SetTitle("Ratio ND/FD");
07730       gNormNearOverFarVsTime->GetYaxis()->CenterTitle();
07731       this->SetGraphAxisEtc(gNormNearOverFarVsTime,startTimeSecs,
07732                             endTimeSecs);
07733     }
07734 
07735     //print to postscript
07736     cMeanVsTime->Print(sMeanVsTime.c_str());
07737     cErrorVsTime->Print(sErrorVsTime.c_str());
07738     cNumEntVsTime->Print(sNumEntVsTime.c_str());
07739     cGainDriftVsTime->Print(sGainDriftVsTime.c_str());
07740     cGainDriftVsTimeZoom->Print(sGainDriftVsTimeZoom.c_str());
07741     cNearOverFarVsTime->Print(sNearOverFarVsTime.c_str());
07742     cNormNearOverFarVsTime->Print(sNormNearOverFarVsTime.c_str());
07743 
07744     //avoid program getting too big
07745     MSG("LIPlexMaps",Msg::kVerbose)
07746       <<"Deleting graphs..."<<endl;
07747     delete gMeanVsTime;
07748     delete gErrorVsTime;
07749     delete gNumEntVsTime;
07750     delete gGainDriftVsTime;
07751     delete gGainDriftVsTimeZoom;
07752     delete gNearOverFarVsTime;
07753     delete gNormNearOverFarVsTime;
07754 
07755     pageCounter++;
07756     if (pageCounter%50==0){
07757       MSG("LIPlexMaps",Msg::kInfo)
07758         <<"Number of pages = "<<pageCounter<<endl;
07759     }
07760     else {
07761       MSG("LIPlexMaps",Msg::kVerbose)
07762         <<"Number of pages = "<<pageCounter<<endl;
07763     }
07764 
07765     //go to next se
07766     seIt++;
07767   }
07768   
07769   //close the files
07770   gErrorIgnoreLevel=0;//turn on printing messages 
07771   cMeanVsTime->Print((sMeanVsTime+"]").c_str());
07772   cErrorVsTime->Print((sErrorVsTime+"]").c_str());
07773   cNumEntVsTime->Print((sNumEntVsTime+"]").c_str());
07774   cGainDriftVsTime->Print((sGainDriftVsTime+"]").c_str());
07775   cGainDriftVsTimeZoom->Print((sGainDriftVsTimeZoom+"]").c_str());
07776   cNearOverFarVsTime->Print((sNearOverFarVsTime+"]").c_str());
07777   cNormNearOverFarVsTime->Print((sNormNearOverFarVsTime+"]").c_str());
07778 
07779   cPinVsTime->Print((sPinVsTime+"]").c_str());
07780   cNormPinVsTime->Print((sNormPinVsTime+"]").c_str());
07781   cNormPinVsTimeZoom->Print((sNormPinVsTimeZoom+"]").c_str());
07782   cPinErrorVsTime->Print((sPinErrorVsTime+"]").c_str());
07783   cPinNumEntVsTime->Print((sPinNumEntVsTime+"]").c_str());
07784 
07785   MSG("LIPlexMaps",Msg::kInfo)
07786     <<endl<<" ** Finished the DriftWithTime method... ** "<<endl; 
07787 }

void LIPlexMaps::DumpCalStripAtten ( std::string  sDataFileName,
Detector::Detector_t  det,
SimFlag::ESimFlag  simFlag,
VldTimeStamp  ts,
Int_t  task 
)

Definition at line 4498 of file LIPlexMaps.cxx.

References LILookup::FIRSTSCINTPLANE, LILookup::FIRSTSTRIP, PlexStripEndId::GetEncoded(), PlexStripEndId::GetEnd(), CalStripAtten::GetFrac1(), CalStripAtten::GetFrac1Err(), CalStripAtten::GetLambda1(), CalStripAtten::GetLambda1Err(), CalStripAtten::GetLambda2(), CalStripAtten::GetLambda2Err(), PlexPlaneId::GetPlane(), DbiResultPtr< T >::GetRow(), CalStripAtten::GetSEIDkey(), PlexStripEndId::GetStrip(), CalStripAtten::GetStripEndId(), StripEnd::kEast, Msg::kInfo, LILookup::LASTSCINTPLANE, LILookup::LASTSTRIP, MAXMSG, MSG, DbiResultPtr< T >::NewQuery(), and LILookup::SetDetector().

04502 {
04503   MSG("LIPlexMaps",Msg::kInfo)
04504     <<endl<<" ** Running the DumpCalStripAtten() method... **"<<endl;
04505 
04506   //this must go first
04507   this->SetDetector(static_cast<Int_t>(det));
04508 
04509   const Int_t firstStripBin=FIRSTSTRIP-8;//-8;
04510   const Int_t lastStripBin=LASTSTRIP+9;//200;
04511   const Int_t bins=lastStripBin-firstStripBin;
04512   
04513   string s="Lambda1, East side";
04514   TH2F *hStripVsPlaneLambda1East=new TH2F(s.c_str(),s.c_str(),
04515                                       LASTSCINTPLANE-FIRSTSCINTPLANE+2,
04516                                       0,LASTSCINTPLANE+1,
04517                                       bins,firstStripBin,lastStripBin);
04518   hStripVsPlaneLambda1East->GetXaxis()->SetTitle("Plane");
04519   hStripVsPlaneLambda1East->GetXaxis()->CenterTitle();
04520   hStripVsPlaneLambda1East->GetYaxis()->SetTitle("Strip");
04521   hStripVsPlaneLambda1East->GetYaxis()->CenterTitle();
04522   
04523   s="Lambda1, West side";
04524   TH2F *hStripVsPlaneLambda1West=new TH2F(s.c_str(),s.c_str(),
04525                                       LASTSCINTPLANE-FIRSTSCINTPLANE+2,
04526                                       0,LASTSCINTPLANE+1,
04527                                       bins,firstStripBin,lastStripBin);
04528   hStripVsPlaneLambda1West->GetXaxis()->SetTitle("Plane");
04529   hStripVsPlaneLambda1West->GetXaxis()->CenterTitle();
04530   hStripVsPlaneLambda1West->GetYaxis()->SetTitle("Strip");
04531   hStripVsPlaneLambda1West->GetYaxis()->CenterTitle();
04532 
04533   s="Lambda2, East side";
04534   TH2F *hStripVsPlaneLambda2East=new TH2F(s.c_str(),s.c_str(),
04535                                       LASTSCINTPLANE-FIRSTSCINTPLANE+2,
04536                                       0,LASTSCINTPLANE+1,
04537                                       bins,firstStripBin,lastStripBin);
04538   hStripVsPlaneLambda2East->GetXaxis()->SetTitle("Plane");
04539   hStripVsPlaneLambda2East->GetXaxis()->CenterTitle();
04540   hStripVsPlaneLambda2East->GetYaxis()->SetTitle("Strip");
04541   hStripVsPlaneLambda2East->GetYaxis()->CenterTitle();
04542   
04543   s="Lambda2, West side";
04544   TH2F *hStripVsPlaneLambda2West=new TH2F(s.c_str(),s.c_str(),
04545                                       LASTSCINTPLANE-FIRSTSCINTPLANE+2,
04546                                       0,LASTSCINTPLANE+1,
04547                                       bins,firstStripBin,lastStripBin);
04548   hStripVsPlaneLambda2West->GetXaxis()->SetTitle("Plane");
04549   hStripVsPlaneLambda2West->GetXaxis()->CenterTitle();
04550   hStripVsPlaneLambda2West->GetYaxis()->SetTitle("Strip");
04551   hStripVsPlaneLambda2West->GetYaxis()->CenterTitle();
04552 
04553   s="Frac1, East side";
04554   TH2F *hStripVsPlaneFrac1East=new TH2F(s.c_str(),s.c_str(),
04555                                       LASTSCINTPLANE-FIRSTSCINTPLANE+2,
04556                                       0,LASTSCINTPLANE+1,
04557                                       bins,firstStripBin,lastStripBin);
04558   hStripVsPlaneFrac1East->GetXaxis()->SetTitle("Plane");
04559   hStripVsPlaneFrac1East->GetXaxis()->CenterTitle();
04560   hStripVsPlaneFrac1East->GetYaxis()->SetTitle("Strip");
04561   hStripVsPlaneFrac1East->GetYaxis()->CenterTitle();
04562   
04563   s="Frac1, West side";
04564   TH2F *hStripVsPlaneFrac1West=new TH2F(s.c_str(),s.c_str(),
04565                                       LASTSCINTPLANE-FIRSTSCINTPLANE+2,
04566                                       0,LASTSCINTPLANE+1,
04567                                       bins,firstStripBin,lastStripBin);
04568   hStripVsPlaneFrac1West->GetXaxis()->SetTitle("Plane");
04569   hStripVsPlaneFrac1West->GetXaxis()->CenterTitle();
04570   hStripVsPlaneFrac1West->GetYaxis()->SetTitle("Strip");
04571   hStripVsPlaneFrac1West->GetYaxis()->CenterTitle();
04572 
04573   s="Atten, East side";
04574   TH2F *hStripVsPlaneAttenEast=new TH2F(s.c_str(),s.c_str(),
04575                                       LASTSCINTPLANE-FIRSTSCINTPLANE+2,
04576                                       0,LASTSCINTPLANE+1,
04577                                       bins,firstStripBin,lastStripBin);
04578   hStripVsPlaneAttenEast->GetXaxis()->SetTitle("Plane");
04579   hStripVsPlaneAttenEast->GetXaxis()->CenterTitle();
04580   hStripVsPlaneAttenEast->GetYaxis()->SetTitle("Strip");
04581   hStripVsPlaneAttenEast->GetYaxis()->CenterTitle();
04582   
04583   s="Atten, West side";
04584   TH2F *hStripVsPlaneAttenWest=new TH2F(s.c_str(),s.c_str(),
04585                                       LASTSCINTPLANE-FIRSTSCINTPLANE+2,
04586                                       0,LASTSCINTPLANE+1,
04587                                       bins,firstStripBin,lastStripBin);
04588   hStripVsPlaneAttenWest->GetXaxis()->SetTitle("Plane");
04589   hStripVsPlaneAttenWest->GetXaxis()->CenterTitle();
04590   hStripVsPlaneAttenWest->GetYaxis()->SetTitle("Strip");
04591   hStripVsPlaneAttenWest->GetYaxis()->CenterTitle();
04592   
04593   DbiResultPtr<CalStripAtten> dbiCalStripAtten;
04594   VldContext vldCtx(det,simFlag,ts);
04595   UInt_t numRows=dbiCalStripAtten.NewQuery(vldCtx,task);
04596   
04597   //open the file  
04598   MSG("LIPlexMaps",Msg::kInfo)
04599     <<"Opening file "<<sDataFileName<<"..."<<endl;
04600   ofstream odataFile(sDataFileName.c_str());
04601 
04602   MSG("LIPlexMaps",Msg::kInfo)
04603     <<"New DB query produced "<<numRows<<" rows"
04604     <<", using task="<<task<<endl
04605     <<"Looping over rows..."<<endl;
04606   //loop over the rows
04607   for(UInt_t i=0;i<numRows;i++) {
04608     const CalStripAtten* calStripAtten=dbiCalStripAtten.GetRow(i);
04609     
04610     /*
04611   CalStripAtten (const PlexStripEndId &seid, Float_t lambda1, Float_t lambda2, Float_t frac1, Float_t lambda1err, Float_t lambda2err, Float_t frac1err) 
04612   CalStripAtten (Int_t seid_enc, Float_t lambda1, Float_t lambda2, Float_t frac1, Float_t lambda1err, Float_t lambda2err, Float_t frac1err) 
04613 virtual  ~CalStripAtten () 
04614 Bool_t  CanL2Cache () const  
04615 UInt_t  GetIndex (UInt_t) const  
04616 PlexStripEndId  GetStripEndId () const  
04617 UInt_t  GetSEIDkey () const  
04618 Float_t  GetLambda1 () const  
04619 Float_t  GetLambda2 () const  
04620 Float_t  GetFrac1 () const  
04621 Float_t  GetFrac2 () const  
04622 Float_t  GetLambda1Err () const  
04623 Float_t  GetLambda2Err () const  
04624 Float_t  GetFrac1Err () const  
04625     */
04626 
04627 
04628     Int_t seid_enc=calStripAtten->GetStripEndId().GetEncoded();    
04629     Float_t lambda1=calStripAtten->GetLambda1();
04630     Float_t lambda2=calStripAtten->GetLambda2();
04631     Float_t frac1=calStripAtten->GetFrac1();
04632     Float_t lambda1Err=calStripAtten->GetLambda1Err();
04633     Float_t lambda2Err=calStripAtten->GetLambda2Err();
04634     Float_t frac1Err=calStripAtten->GetFrac1Err();
04635     
04636     MAXMSG("LIPlexMaps",Msg::kInfo,10)
04637       <<"seid_enc="<<seid_enc
04638       <<", GetSEIDkey="<<calStripAtten->GetSEIDkey()<<endl;
04639 
04640     PlexStripEndId seid=calStripAtten->GetStripEndId();
04641     Int_t plane=seid.GetPlane();
04642     Int_t strip=seid.GetStrip();
04643     Int_t se=seid.GetEnd();
04644     Float_t x=1.5;
04645 
04646     //try changing units of distance
04647     //x=0.15;
04648 
04649     //try flipping frac1 
04650     //frac1=1-frac1;
04651 
04652     Float_t atten=frac1*exp(-x/lambda1)+(1-frac1)*exp(-x/lambda2);
04653 
04654     if (se==StripEnd::kEast){
04655       hStripVsPlaneLambda1East->Fill(plane,strip,lambda1);
04656       hStripVsPlaneLambda2East->Fill(plane,strip,lambda2);
04657       hStripVsPlaneFrac1East->Fill(plane,strip,frac1);
04658       hStripVsPlaneAttenEast->Fill(plane,strip,atten);
04659     }
04660     else {
04661       hStripVsPlaneLambda1West->Fill(plane,strip,lambda1);
04662       hStripVsPlaneLambda2West->Fill(plane,strip,lambda2);
04663       hStripVsPlaneFrac1West->Fill(plane,strip,frac1);
04664       hStripVsPlaneAttenWest->Fill(plane,strip,atten);
04665     }
04666 
04667     odataFile<<seid_enc
04668              <<"\t"<<lambda1
04669              <<"\t"<<lambda2
04670              <<"\t"<<frac1
04671              <<"\t"<<lambda1Err
04672              <<"\t"<<lambda2Err
04673              <<"\t"<<frac1Err
04674              <<endl;
04675   }
04676   MSG("LIPlexMaps",Msg::kInfo)
04677     <<"Output file completed"<<endl;
04678 
04679   TCanvas *cStripVsPlaneLambda1=new TCanvas
04680     ("cStripVsPlaneLambda1","StripVsPlane: Mean",0,0,1100,800);
04681   cStripVsPlaneLambda1->SetFillColor(0);
04682   cStripVsPlaneLambda1->Divide(1,2);
04683   cStripVsPlaneLambda1->cd(1);
04684   hStripVsPlaneLambda1East->Draw("colz");
04685   cStripVsPlaneLambda1->cd(2);
04686   hStripVsPlaneLambda1West->Draw("colz");
04687 
04688   TCanvas *cStripVsPlaneLambda2=new TCanvas
04689     ("cStripVsPlaneLambda2","StripVsPlane: Mean",0,0,1100,800);
04690   cStripVsPlaneLambda2->SetFillColor(0);
04691   cStripVsPlaneLambda2->Divide(1,2);
04692   cStripVsPlaneLambda2->cd(1);
04693   hStripVsPlaneLambda2East->Draw("colz");
04694   cStripVsPlaneLambda2->cd(2);
04695   hStripVsPlaneLambda2West->Draw("colz");
04696 
04697   TCanvas *cStripVsPlaneFrac1=new TCanvas
04698     ("cStripVsPlaneFrac1","StripVsPlane: Mean",0,0,1100,800);
04699   cStripVsPlaneFrac1->SetFillColor(0);
04700   cStripVsPlaneFrac1->Divide(1,2);
04701   cStripVsPlaneFrac1->cd(1);
04702   hStripVsPlaneFrac1East->Draw("colz");
04703   cStripVsPlaneFrac1->cd(2);
04704   hStripVsPlaneFrac1West->Draw("colz");
04705 
04706   TCanvas *cStripVsPlaneAtten=new TCanvas
04707     ("cStripVsPlaneAtten","StripVsPlane: Mean",0,0,1100,800);
04708   cStripVsPlaneAtten->SetFillColor(0);
04709   cStripVsPlaneAtten->Divide(1,2);
04710   cStripVsPlaneAtten->cd(1);
04711   hStripVsPlaneAttenEast->Draw("colz");
04712   cStripVsPlaneAtten->cd(2);
04713   hStripVsPlaneAttenWest->Draw("colz");
04714 
04715   MSG("LIPlexMaps",Msg::kInfo)
04716     <<endl<<" ** Finished the DumpCalStripAtten method... ** "<<endl;
04717 }

void LIPlexMaps::DumpCalStripToStrip ( std::string  sDataFileName,
Detector::Detector_t  det,
SimFlag::ESimFlag  simFlag,
VldTimeStamp  ts,
Int_t  task 
) const

Definition at line 4458 of file LIPlexMaps.cxx.

References PlexStripEndId::GetEncoded(), CalStripToStrip::GetResponse(), CalStripToStrip::GetResponseErr(), DbiResultPtr< T >::GetRow(), CalStripToStrip::GetStripEndId(), Msg::kInfo, MSG, and DbiResultPtr< T >::NewQuery().

04462 {
04463   MSG("LIPlexMaps",Msg::kInfo)
04464     <<endl<<" ** Running the DumpCalStripToStrip() method... **"<<endl;
04465 
04466   DbiResultPtr<CalStripToStrip> dbiCalStripToStrip;
04467   VldContext vldCtx(det,simFlag,ts);
04468   UInt_t numRows=dbiCalStripToStrip.NewQuery(vldCtx,task);
04469   
04470   //open the file  
04471   MSG("LIPlexMaps",Msg::kInfo)
04472     <<"Opening file "<<sDataFileName<<"..."<<endl;
04473   ofstream odataFile(sDataFileName.c_str());
04474 
04475   MSG("LIPlexMaps",Msg::kInfo)
04476     <<"New DB query produced "<<numRows<<" rows"
04477     <<", using task="<<task<<endl
04478     <<"Looping over rows..."<<endl;
04479   //loop over the rows
04480   for(UInt_t i=0;i<numRows;i++) {
04481     const CalStripToStrip* calStripToStrip=dbiCalStripToStrip.GetRow(i);
04482     
04483     Int_t seid_enc=calStripToStrip->GetStripEndId().GetEncoded();    
04484     Float_t resp=calStripToStrip->GetResponse();
04485     Float_t respErr=calStripToStrip->GetResponseErr();
04486     
04487     odataFile<<seid_enc<<"\t"<<resp<<"\t"<<respErr<<endl;
04488   }
04489   MSG("LIPlexMaps",Msg::kInfo)
04490     <<"Output file completed"<<endl;
04491 
04492   MSG("LIPlexMaps",Msg::kInfo)
04493     <<endl<<" ** Finished the DumpCalStripToStrip method... ** "<<endl;
04494 }

void LIPlexMaps::DumpGains ( Detector::Detector_t  det,
VldTimeStamp  ts,
std::string  filename 
)

Dumps the gains from a time-point into a text file.

Definition at line 8866 of file LIPlexMaps.cxx.

References fLookup, CalADCtoPEs::GetAggregateNo(), CalADCtoPEs::GetGain(), CalADCtoPEs::GetGainErr(), DbiResultPtr< T >::GetRow(), CalADCtoPEs::GetSEIDkey(), SimFlag::kData, Msg::kFatal, Msg::kInfo, Detector::kNear, MSG, DbiResultPtr< T >::NewQuery(), and LILookup::UnencodePlnStripEndKey().

08867 {
08868   // Set up the validity context
08869   VldContext vldCtx(det, SimFlag::kData, ts);
08870 
08871   // and the database
08872   DbiResultPtr<CalADCtoPEs> dbiCalADCtoPEs;
08873 
08874   // Work out the task....
08875   Int_t task = 0;
08876   if (det == Detector::kNear) task = 1;
08877 
08878 
08879   // Run the query
08880   UInt_t numRows = dbiCalADCtoPEs.NewQuery(vldCtx,task);
08881 
08882   // Open the text file
08883   ofstream gaindump(gaindump_filename.c_str());
08884   if (gaindump.is_open()) {
08885     MSG("LIPlexMaps",Msg::kInfo) << "Dumping gain values to " << gaindump_filename << endl;
08886     // Write a header to the gaindump
08887     gaindump  << "#"
08888               << setw(3) << "Pl" << " "
08889               << setw(3) << "Str" << " "
08890               << setw(3) << "End" << " "
08891               << setw(4) << "Agg" << " "
08892               << setw(6) << "SEID" << " "
08893               << setw(9) << "Gain" << " "
08894               << setw(9) << "Error"
08895               << "\n";
08896     
08897   } else {
08898     MSG("LIPlexMaps",Msg::kFatal) << "Error writing to gain dump file " << gaindump_filename << endl;
08899   }
08900   
08901   // Now run over each row in the query
08902   for (UInt_t i = 0; i < numRows; ++i)
08903   {
08904     // Grab the query row and extract information
08905     const CalADCtoPEs* calAdcToPe = dbiCalADCtoPEs.GetRow(i);
08906     
08907     // Get the easier values
08908     Int_t aggno = calAdcToPe->GetAggregateNo();
08909     Float_t gain = calAdcToPe->GetGain();
08910     Float_t gainerr = calAdcToPe->GetGainErr();
08911     Int_t seid = calAdcToPe->GetSEIDkey();
08912     
08913     // Calculate the strip, plane
08914     Int_t plane=-1;
08915     Int_t strip=-1;
08916     Int_t end=-1;
08917     fLookup.UnencodePlnStripEndKey(seid,det,plane,strip,end);
08918     
08919     // Now, write them all to file
08920     gaindump  << setw(4) << plane << " "
08921               << setw(3) << strip << " "
08922               << setw(3) << end << " "
08923               << setw(4) << aggno << " "
08924               << setw(6) << seid << " "
08925               << setw(9) << gain << " "
08926               << setw(9) << gainerr
08927               << "\n";
08928   } 
08929 }

void LIPlexMaps::FactorialGen ( std::vector< Double_t > &  v  ) 
TH1D LIPlexMaps::GainDifference ( Detector::Detector_t  det,
VldTimeStamp  t1,
VldTimeStamp  t2 
)

Definition at line 8767 of file LIPlexMaps.cxx.

References fLookup, GetGainMap(), it, Msg::kFatal, MSG, and LILookup::UnencodePlnStripEndKey().

08768 {
08769   
08770   LIPlexMaps LIPlex;
08771   
08772   // Read in maps for both of these
08773   std::map<Int_t,Double_t> pt1 = LIPlex.GetGainMap(det, first);
08774   std::map<Int_t,Double_t> pt2 = LIPlex.GetGainMap(det, second);
08775   
08776   cout << "First point SEIDs:  " << pt1.size() << endl;
08777   cout << "Second point SEIDs: " << pt2.size() << endl;
08778 
08779   // Make histograms
08780   TH1D gaindiff("gaindiff", "Difference in gains", 120, -30, 30);
08781   // TH2D stripvsplane("stripvsplane", "Strip versus plane differences", 290, 0, 290, 100, 0, 100);
08782 
08783   // Loop through every SEID
08784   for (map<Int_t,Double_t>::const_iterator it = pt1.begin(); it != pt1.end(); ++it) {
08785     UInt_t seid = it->first;
08786     Double_t gain = it->second;
08787 
08788     // check the other entry has this key
08789     if (!pt2.count(seid)) {
08790       MSG("LIPlexMaps",Msg::kFatal) << "Second timestamp does not have stripend-id " << seid << endl;
08791       throw runtime_error("Timestamps do not have matching SEIDs");
08792     }
08793     // Calculate the strip, plane
08794     Int_t plane=-1;
08795     Int_t strip=-1;
08796     Int_t end=-1;
08797     fLookup.UnencodePlnStripEndKey(seid,det,plane,strip,end);
08798 //    cout << "SEID: " << seid << " (Plane " << plane << ", strip " << strip << ") = " << gain << endl;
08799     
08800     Double_t diff = pt2[seid] - gain;
08801 
08802     // Fill the histograms
08803     gaindiff.Fill(diff);
08804     // stripvsplane.Fill(plane,strip, diff);
08805 
08806   }
08807 
08808   // // Now write these out
08809   // TFile tf(outfile.c_str(),"recreate");
08810   // gaindiff.Write();
08811   // stripvsplane.Write();
08812   // tf.Close();
08813   
08814   return gaindiff;
08815   
08816 }

TH2D LIPlexMaps::GainDifferenceSvP ( Detector::Detector_t  det,
VldTimeStamp  t1,
VldTimeStamp  t2 
)

Definition at line 8818 of file LIPlexMaps.cxx.

References fLookup, GetGainMap(), it, Detector::kFar, Msg::kFatal, MSG, and LILookup::UnencodePlnStripEndKey().

08819 {
08820   LIPlexMaps LIPlex;
08821   
08822   // Read in maps for both of these
08823   std::map<Int_t,Double_t> pt1 = LIPlex.GetGainMap(det, first);
08824   std::map<Int_t,Double_t> pt2 = LIPlex.GetGainMap(det, second);
08825   
08826   cout << "First point SEIDs:  " << pt1.size() << endl;
08827   cout << "Second point SEIDs: " << pt2.size() << endl;
08828   
08829   Int_t maxp, maxs;
08830   if (det == Detector::kFar) {
08831     maxp = 500;
08832     maxs = 200;
08833   } else {
08834     maxp = 300;
08835     maxs = 100;
08836   }
08837   TH2D stripvsplane("stripvsplane", "Strip versus plane differences", maxp, 0, maxp, maxs, 0, maxs);
08838   
08839   // Loop through every SEID
08840   for (map<Int_t,Double_t>::const_iterator it = pt1.begin(); it != pt1.end(); ++it) {
08841     UInt_t seid = it->first;
08842     Double_t gain = it->second;
08843 
08844     // check the other entry has this key
08845     if (!pt2.count(seid)) {
08846       MSG("LIPlexMaps",Msg::kFatal) << "Second timestamp does not have stripend-id " << seid << endl;
08847       throw runtime_error("Timestamps do not have matching SEIDs");
08848     }
08849     // Calculate the strip, plane
08850     Int_t plane=-1;
08851     Int_t strip=-1;
08852     Int_t end=-1;
08853     fLookup.UnencodePlnStripEndKey(seid,det,plane,strip,end);
08854 //    cout << "SEID: " << seid << " (Plane " << plane << ", strip " << strip << ") = " << gain << endl;
08855 
08856     Double_t diff = pt2[seid] - gain;
08857 
08858     // Fill the histograms
08859     // gaindiff.Fill(diff);
08860     stripvsplane.Fill(plane,strip, diff);
08861   }
08862   
08863   return stripvsplane;
08864 }

string LIPlexMaps::GetElecString ( RawChannelId  rChId  )  [private]

Definition at line 2725 of file LIPlexMaps.cxx.

References bfld::AsString(), Form(), RawChannelId::GetCrate(), RawChannelId::GetElecType(), RawChannelId::GetGeographicAddress(), RawChannelId::GetMasterChannel(), RawChannelId::GetMinderChannel(), RawChannelId::GetVaAdcSel(), RawChannelId::GetVaChannel(), RawChannelId::GetVaChip(), RawChannelId::GetVarcId(), RawChannelId::GetVmm(), ElecType::kQIE, ElecType::kVA, Msg::kVerbose, and MSG.

Referenced by PrintDbPinDiodeInfo(), and PrintPlexPinDiodeInfo().

02726 {
02727   MSG("LISummarySorter",Msg::kVerbose) 
02728     <<"Running GetElecString method..."<<endl;
02729 
02730   string elecString="";
02731   string sCrate=Form("%d",rChId.GetCrate());
02732   string sElecType=ElecType::AsString(rChId.GetElecType());
02733 
02734   if (rChId.GetElecType()==ElecType::kVA){
02735     string sVarc=Form("%d",rChId.GetVarcId());
02736     string sVmm=Form("%d",rChId.GetVmm());
02737     string sVfb=Form("%d",rChId.GetVaAdcSel());
02738     string sChip=Form("%d",rChId.GetVaChip());
02739     string sChannel=Form("%d",rChId.GetVaChannel());
02740 
02741     elecString=sElecType+
02742       "("+sCrate+","+sVarc+","+sVmm+","+sVfb+","+sChip+","+sChannel+")";
02743   }     
02744   else if (rChId.GetElecType()==ElecType::kQIE){
02745     string sGeoAdd=Form("%d",rChId.GetGeographicAddress());
02746     string sMaster=Form("%d",rChId.GetMasterChannel());
02747     string sMinder=Form("%d",rChId.GetMinderChannel());
02748         
02749     elecString=sElecType+
02750       "("+sCrate+","+sGeoAdd+","+sMaster+","+sMinder+")";
02751   }
02752   return elecString;
02753 }

std::map< Int_t, Double_t > LIPlexMaps::GetGainMap ( Detector::Detector_t  det,
VldTimeStamp  ts 
)

Definition at line 8732 of file LIPlexMaps.cxx.

References CalADCtoPEs::GetGain(), DbiResultPtr< T >::GetRow(), CalADCtoPEs::GetSEIDkey(), SimFlag::kData, Detector::kNear, and DbiResultPtr< T >::NewQuery().

Referenced by GainDifference(), and GainDifferenceSvP().

08733 {
08734   std::map<Int_t,Double_t> gainmap;
08735 
08736   // Set up the validity context
08737   VldContext vldCtx(det, SimFlag::kData, ts);
08738   // and the database
08739   DbiResultPtr<CalADCtoPEs> dbiCalADCtoPEs;
08740 
08741   // Work out the task....
08742   Int_t task = 0;
08743   if (det == Detector::kNear) task = 1;
08744 
08745   // Run the query
08746   UInt_t numRows = dbiCalADCtoPEs.NewQuery(vldCtx,task);
08747 
08748   // TH1D *detgains = new TH1D("detgains", "detgains", 200, 0, 200);
08749   // if (det == Detector::kNear) {
08750   //   detgains->SetNameTitle("neargains", "Near Detector Gains");
08751   // } else {
08752   //   detgains->SetNameTitle("fargains", "Far Detector Gains");
08753   // }
08754   // Now run over each row in the query, keeping a running average  
08755   for (UInt_t i = 0; i < numRows; ++i)
08756   {
08757     const CalADCtoPEs* calAdcToPe = dbiCalADCtoPEs.GetRow(i);
08758     Float_t gain = calAdcToPe->GetGain();
08759     UInt_t seid = calAdcToPe->GetSEIDkey();
08760     // detgains->Fill(gain);
08761     gainmap[seid] = gain;
08762   }
08763   
08764   return gainmap;
08765 }

map< PlexLedId, LIPulserPin > LIPlexMaps::GetRawPinLedMap ( VldContext  vldCtx  ) 

Definition at line 8366 of file LIPlexMaps.cxx.

References PulserRawDriftPin::GetError(), PlexHandle::GetLedId(), PlexLedId::GetLedInBox(), PulserRawDriftPin::GetMean(), PulserRawDriftPin::GetNumEntries(), PulserRawDriftPin::GetPinDiodeId(), PlexLedId::GetPulserBox(), DbiResultPtr< T >::GetRow(), MsgService::Instance(), Msg::kDebug, Msg::kInfo, Msg::kWarning, MSG, DbiResultPtr< T >::NewQuery(), and PlexPinDiodeId::Print().

Referenced by DriftWithTime().

08367 {
08368   MSG("LIPlexMaps",Msg::kDebug)
08369     <<endl<<" ** Running the GetRawPinLedMap method... **"<<endl;
08370 
08371   PlexHandle *plexHandle=new PlexHandle(vldCtx);   
08372 
08373   DbiResultPtr<PulserRawDriftPin> driftRawPin;
08374   UInt_t numRowsPin=driftRawPin.NewQuery(vldCtx,0);
08375 
08376   if (static_cast<Int_t>(numRowsPin)!=NUMLEDS*NUMPULSERBOXES*2){
08377     MSG("LIPlexMaps",Msg::kWarning)
08378       <<"PulserRawDriftPin only contains "<<numRowsPin<<" rows"
08379       <<", expected "<<NUMLEDS*NUMPULSERBOXES*2<<endl;
08380   }
08381 
08382   map<PlexLedId,Float_t> pinAdc;
08383   map<PlexLedId,LIPulserPin> pinAdcOb;
08384 
08385   Int_t mapEntCounter=0;
08386 
08388   //loop over the pin rows
08390   for(UInt_t i=0;i<numRowsPin;i++) {
08391 
08392     //get the raw pin
08393     const PulserRawDriftPin* rawPin=driftRawPin.GetRow(i);
08394       
08395     PlexLedId ledId=plexHandle->GetLedId(rawPin->GetPinDiodeId());
08396 
08397     pair<PlexPinDiodeId,PlexPinDiodeId> plexPins=plexHandle->
08398       GetPinDiodeIds(ledId); // hi, low
08399 
08400     //ignore the low gain for now
08401     //if (rawPin->GetPinDiodeId()==plexPins.second) continue;
08402 
08403     //ignore the high gain for now
08404     if (rawPin->GetPinDiodeId()==plexPins.first) continue;
08405 
08406     MSG("LIPlexMaps",Msg::kDebug)
08407       <<"Got high gain pin:"<<endl;
08408     if (MsgService::Instance()->IsActive("LIPlexMaps",Msg::kDebug)){
08409       rawPin->GetPinDiodeId().Print();
08410     }
08411 
08412     //add the pin to the map
08413     pinAdc[ledId]=rawPin->GetMean();
08414 
08415     MSG("LIPlexMaps",Msg::kDebug)
08416       <<"Added pin mean="<<rawPin->GetMean()<<endl;
08417 
08418     pinAdcOb[ledId].mean=rawPin->GetMean();
08419     pinAdcOb[ledId].error=rawPin->GetError();
08420     pinAdcOb[ledId].numEnt=rawPin->GetNumEntries();
08421 
08422     if (rawPin->GetMean()<=0){
08423       MSG("LIPlexMaps",Msg::kInfo)
08424         <<"Warning bad pin="<<rawPin->GetMean()<<" (PB:LED)=("
08425         <<ledId.GetPulserBox()<<":"<<ledId.GetLedInBox()<<")"<<endl;
08426     }
08427 
08428     //count the number of entries
08429     mapEntCounter++;
08430   }
08431 
08432   //check the number of leds
08433   if (mapEntCounter!=NUMLEDS){
08434     MSG("LIPlexMaps",Msg::kWarning)
08435       <<"Only "<<mapEntCounter<<" entries added to pin map"<<endl;
08436   }
08437 
08438   MSG("LIPlexMaps",Msg::kDebug)
08439     <<endl<<" ** Finished the GetRawPinLedMap method... ** "<<endl; 
08440   return pinAdcOb;
08441 }

map< Int_t, Float_t > LIPlexMaps::GetRawPinMap ( VldContext  vldCtx  ) 

Definition at line 8240 of file LIPlexMaps.cxx.

References PlexStripEndId::BuildPlnStripEndKey(), LILookup::FIRSTEND, LILookup::FIRSTPLANE, LILookup::FIRSTSTRIP, PlexHandle::GetLedId(), PulserRawDriftPin::GetMean(), PulserRawDriftPin::GetPinDiodeId(), LILookup::GetPinDiodeIds(), DbiResultPtr< T >::GetRow(), MsgService::Instance(), Detector::kCalDet, Msg::kDebug, StripEnd::kEast, StripEnd::kUnknown, Msg::kVerbose, Msg::kWarning, StripEnd::kWest, LILookup::LASTPLANE, LILookup::LASTSTRIP, MSG, DbiResultPtr< T >::NewQuery(), LILookup::NUMENDS, LILookup::NUMLEDS, LILookup::NUMPLANES, LILookup::NUMPULSERBOXES, LILookup::NUMSTRIPS, PlexPinDiodeId::Print(), and LILookup::SECONDEND.

Referenced by DriftWithTime().

08241 {
08242   MSG("LIPlexMaps",Msg::kDebug)
08243     <<endl<<" ** Running the GetRawPinMap method... **"<<endl;
08244 
08245   Detector::Detector_t det=Detector::kCalDet;
08246   StripEnd::EStripEnd stripEndType = StripEnd::kUnknown;
08247 
08248   PlexHandle *plexHandle=new PlexHandle(vldCtx);   
08249 
08250   DbiResultPtr<PulserRawDriftPin> driftRawPin;
08251   UInt_t numRowsPin=driftRawPin.NewQuery(vldCtx,0);
08252 
08253   if (numRowsPin!=static_cast<UInt_t>(NUMLEDS*NUMPULSERBOXES*2)){
08254     MSG("LIPlexMaps",Msg::kWarning)
08255       <<"PulserRawDriftPin only contains "<<numRowsPin<<" rows"<<endl;
08256   }
08257   map<Int_t,Float_t> pinAdc;
08258 
08259   Int_t mapEntCounter=0;
08260 
08262   //loop over the pin rows
08264   for(UInt_t i=0;i<numRowsPin;i++) {
08265 
08266     //get the raw pin
08267     const PulserRawDriftPin* rawPin=driftRawPin.GetRow(i);
08268       
08269     PlexLedId ledId=plexHandle->GetLedId(rawPin->GetPinDiodeId());
08270 
08271     pair<PlexPinDiodeId,PlexPinDiodeId> plexPins=plexHandle->
08272       GetPinDiodeIds(ledId); // hi, low
08273 
08274     //ignore the low gain for now
08275     if (rawPin->GetPinDiodeId()==plexPins.second) continue;
08276 
08277     MSG("LIPlexMaps",Msg::kDebug)
08278       <<"Got high gain pin:"<<endl;
08279     if (MsgService::Instance()->IsActive("LIPlexMaps",Msg::kDebug)){
08280       rawPin->GetPinDiodeId().Print();
08281     }
08282 
08283     for(Int_t pl=FIRSTPLANE;pl<=LASTPLANE;pl++){
08284       for(Int_t st=FIRSTSTRIP;st<=LASTSTRIP;st++){
08285         for(Int_t end=FIRSTEND;end<=SECONDEND;end++){
08286           
08287           if (end==StripEnd::kEast) stripEndType=StripEnd::kEast;
08288           else if (end==StripEnd::kWest) stripEndType=StripEnd::kWest;
08289           
08290           PlexStripEndId stripEndId(det,pl,st,stripEndType);
08291           
08292           PlexLedId currentSELedId=plexHandle->GetLedId(stripEndId);
08293 
08294           if (currentSELedId==ledId){
08295             pinAdc[stripEndId.BuildPlnStripEndKey()]=rawPin->GetMean();
08296             
08297             MSG("LIPlexMaps",Msg::kVerbose)
08298               <<"Filling map, mean="<<rawPin->GetMean()<<endl;
08299             mapEntCounter++;
08300           }
08301         }
08302       }
08303     }
08304   }
08305 
08306   if (mapEntCounter!=NUMPLANES*NUMSTRIPS*NUMENDS){
08307     MSG("LIPlexMaps",Msg::kWarning)
08308       <<"Only "<<mapEntCounter<<" entries added to pin map"<<endl;
08309   }
08310 
08311   MSG("LIPlexMaps",Msg::kDebug)
08312     <<endl<<" ** Finished the GetRawPinMap method... ** "<<endl; 
08313   return pinAdc;
08314 }

map< Int_t, LIPulserPin > LIPlexMaps::GetRefAdcPinRatio ( VldContext  vldCtx  ) 

Definition at line 8445 of file LIPlexMaps.cxx.

References PlexStripEndId::BuildPlnStripEndKey(), LILookup::FIRSTEND, LILookup::FIRSTPLANE, LILookup::FIRSTSTRIP, VldContext::GetDetector(), PulserRefDrift::GetError(), PlexHandle::GetLedId(), PulserRefDriftPin::GetMean(), PulserRefDrift::GetMean(), PulserRefDrift::GetNumEntries(), PulserRefDriftPin::GetPinDiodeId(), LILookup::GetPinDiodeIds(), DbiResultPtr< T >::GetRow(), PulserRefDrift::GetStripEnd(), DbiResultPtr< T >::GetValidityRec(), MsgService::Instance(), IsScintStrip(), Msg::kDebug, StripEnd::kEast, Msg::kInfo, StripEnd::kUnknown, Msg::kWarning, StripEnd::kWest, LILookup::LASTPLANE, LILookup::LASTSTRIP, MSG, DbiResultPtr< T >::NewQuery(), PlexPinDiodeId::Print(), and LILookup::SECONDEND.

Referenced by DriftWithTime().

08446 {
08447   MSG("LIPlexMaps",Msg::kDebug)
08448     <<endl<<" ** Running the GetRefAdcPinRatio method... **"<<endl;
08449 
08450   map<Int_t,LIPulserPin> pinAdc;
08451 
08452   Detector::Detector_t det=vldCtx.GetDetector();
08453   StripEnd::EStripEnd stripEndType = StripEnd::kUnknown;
08454 
08455   PlexHandle *plexHandle=new PlexHandle(vldCtx);   
08456 
08457   DbiResultPtr<PulserRefDriftPin> driftRefPin;
08458   UInt_t numRowsPin=driftRefPin.NewQuery(vldCtx,0);
08459 
08460   DbiResultPtr<PulserRefDrift> dbiPulserRefDrift;
08461   UInt_t numRowsDrift=dbiPulserRefDrift.NewQuery(vldCtx,0);
08462 
08463   static string sVldRange=dbiPulserRefDrift.GetValidityRec()->
08464     GetVldRange().AsString();
08465   static Bool_t firstTime=true;
08466 
08467   if (sVldRange==dbiPulserRefDrift.GetValidityRec()->
08468       GetVldRange().AsString() && !firstTime){
08469     return pinAdc;
08470   }
08471 
08472   MSG("LIPlexMaps",Msg::kInfo)
08473     <<endl<<"Running the GetRefAdcPinRatio method..."<<endl;
08474 
08475   //set up control variables for next time
08476   firstTime=false;
08477   sVldRange=dbiPulserRefDrift.GetValidityRec()->
08478     GetVldRange().AsString();
08479 
08480   MSG("LIPlexMaps",Msg::kInfo)
08481     <<"PulserRefDrift contains "<<numRowsDrift<<" rows"<<endl
08482     <<"PulserRefDriftPin contains "<<numRowsPin<<" rows"<<endl;
08483 
08484   Int_t mapEntCounter=0;
08485 
08487   //loop over the pin rows
08489   for(UInt_t i=0;i<numRowsPin;i++) {
08490 
08491     //get the ref pin
08492     const PulserRefDriftPin* refPin=driftRefPin.GetRow(i);
08493       
08494     PlexLedId ledId=plexHandle->GetLedId(refPin->GetPinDiodeId());
08495 
08496     pair<PlexPinDiodeId,PlexPinDiodeId> plexPins=plexHandle->
08497       GetPinDiodeIds(ledId); // hi, low
08498 
08499     //ignore the low gain for now
08500     if (refPin->GetPinDiodeId()==plexPins.second) continue;
08501 
08502     MSG("LIPlexMaps",Msg::kDebug)
08503       <<"Got high gain pin:"<<endl;
08504     if (MsgService::Instance()->IsActive("LIPlexMaps",Msg::kDebug)){
08505       refPin->GetPinDiodeId().Print();
08506     }
08507 
08508     for(Int_t pl=FIRSTPLANE;pl<=LASTPLANE;pl++){
08509       for(Int_t st=FIRSTSTRIP;st<=LASTSTRIP;st++){
08510         for(Int_t end=FIRSTEND;end<=SECONDEND;end++){
08511           
08512           if (end==StripEnd::kEast) stripEndType=StripEnd::kEast;
08513           else if (end==StripEnd::kWest) stripEndType=StripEnd::kWest;
08514           
08515           PlexStripEndId stripEndId(det,pl,st,stripEndType);
08516           
08517           if (!this->IsScintStrip(stripEndId,plexHandle)) continue;
08518 
08519           PlexLedId currentSELedId=plexHandle->GetLedId(stripEndId);
08520 
08521           if (currentSELedId==ledId){
08522             pinAdc[stripEndId.BuildPlnStripEndKey()].mean=refPin->
08523               GetMean();
08524             pinAdc[stripEndId.BuildPlnStripEndKey()].error=refPin->
08525               GetError();
08526             pinAdc[stripEndId.BuildPlnStripEndKey()].numEnt=refPin->
08527               GetNumEntries();
08528             
08529             MSG("LIPlexMaps",Msg::kDebug)
08530               <<"Filling map; mean="<<refPin->GetMean()<<endl;
08531             mapEntCounter++;
08532           }
08533         }
08534       }
08535     }
08536   }
08537   MSG("LIPlexMaps",Msg::kInfo)
08538     <<"Total entries added to pin map = "<<mapEntCounter<<endl;
08539 
08540   //create the map
08541   map<Int_t,LIPulserPin> adcPinRatio;
08542   
08543   //initialise the map
08544   for(Int_t pl=FIRSTPLANE;pl<=LASTPLANE;pl++){
08545     for(Int_t st=FIRSTSTRIP;st<=LASTSTRIP;st++){
08546       for(Int_t end=FIRSTEND;end<=SECONDEND;end++){
08547         
08548         if (end==StripEnd::kEast) stripEndType=StripEnd::kEast;
08549         else if (end==StripEnd::kWest) stripEndType=StripEnd::kWest;
08550         
08551         PlexStripEndId stripEndId(det,pl,st,stripEndType);
08552         
08553         adcPinRatio[stripEndId.BuildPlnStripEndKey()].mean=-1;
08554         adcPinRatio[stripEndId.BuildPlnStripEndKey()].error=-1;
08555         adcPinRatio[stripEndId.BuildPlnStripEndKey()].numEnt=-1;
08556         
08557       }
08558     }
08559   }
08560   
08562   //loop over the pulser drift rows
08564   for(UInt_t i=0;i<numRowsDrift;i++) {
08565     //get the ref drift 
08566     const PulserRefDrift* pulserRefDrift=dbiPulserRefDrift.GetRow(i);
08567 
08568     UInt_t seidkey=pulserRefDrift->GetStripEnd();
08569 
08570     //fill the map
08571     adcPinRatio[seidkey].mean=pulserRefDrift->GetMean();
08572     adcPinRatio[seidkey].error=pulserRefDrift->GetError();
08573     adcPinRatio[seidkey].numEnt=pulserRefDrift->GetNumEntries();
08574 
08575     //calculate adc/pin (protect against fpe)
08576     if (pinAdc[seidkey].mean>0){
08577       adcPinRatio[seidkey].mean/=pinAdc[seidkey].mean;
08578 
08579       //covert the error to be a relative error
08580       adcPinRatio[seidkey].error/=pulserRefDrift->GetMean();
08581 
08582       MSG("LIPlexMaps",Msg::kDebug)
08583         <<"Filling ratio map="<<adcPinRatio[seidkey].mean
08584         <<" (+/- "<<adcPinRatio[seidkey].error*100<<"%)"<<endl;
08585     }
08586     else {
08587       MSG("LIPlexMaps",Msg::kWarning)
08588         <<"Reference pin has zero mean!"<<endl;
08589     }
08590   }
08592   //finished loop over the rows
08594 
08595   MSG("LIPlexMaps",Msg::kDebug)
08596     <<endl<<" ** Finished the GetRefAdcPinRatio method... ** "<<endl;
08597   return adcPinRatio;
08598 }

Bool_t LIPlexMaps::IsPermitted (  )  const

Definition at line 127 of file LIPlexMaps.cxx.

References Msg::kDebug, Msg::kWarning, and MSG.

Referenced by MakeCalMIPCalibration(), MakeCalStripAtten(), MakeCalStripToStrip(), and MakePlexStripEndToLed().

00128 {
00129   MSG("LIPlexMaps",Msg::kDebug) 
00130     <<" ** Running IsPermitted method... **"<<endl;
00131 
00132   char* envVariable=getenv("LITSQLPERMISSION");
00133   if (envVariable==NULL){
00134     MSG("LIAnalysis",Msg::kWarning)
00135       <<endl<<endl
00136       <<"*************************************************************"
00137       <<endl
00138       <<"WARNING: You have tried to do a sensitive operation."<<endl
00139       <<"This feature is designed to make you stop and think."<<endl
00140       <<"If you know what you are doing then look at the code."<<endl
00141       <<"*************************************************************"
00142       <<endl<<endl;
00143     return false;
00144   }
00145 
00146   MSG("LIPlexMaps",Msg::kDebug) 
00147     <<" ** Finished IsPermitted method **"<<endl;
00148   return true;
00149 }

Bool_t LIPlexMaps::IsScintStrip ( PlexStripEndId stripEndId,
PlexHandle plexHandle 
) [private]

Definition at line 8602 of file LIPlexMaps.cxx.

References bfld::AsString(), PlexHandle::GetRawChannelId(), PlexHandle::GetReadoutType(), ReadoutType::kScintStrip, Msg::kVerbose, and MSG.

Referenced by DriftWithTime(), and GetRefAdcPinRatio().

08604 {
08605   MSG("LIPlexMaps",Msg::kVerbose)
08606     <<" ** Running the IsScintStrip method... **"<<endl;
08607 
08608   //get a raw channel id
08609   RawChannelId tempRawChId=plexHandle->GetRawChannelId(stripEndId);
08610   
08611   //check if rcid is a scintstrip
08612   if (plexHandle->GetReadoutType(tempRawChId)!=
08613       ReadoutType::kScintStrip){
08614     
08615     MSG("LIPlexMaps",Msg::kVerbose)
08616       <<"Ignoring ReadoutType="<<ReadoutType::AsString
08617       (plexHandle->GetReadoutType(tempRawChId))
08618       <<endl;       
08619     return false;
08620   }
08621 
08622   MSG("LIPlexMaps",Msg::kVerbose)
08623     <<" ** Finished IsScintStrip method... ** "<<endl; 
08624   return true;
08625 }

void LIPlexMaps::LIErrors (  ) 

Definition at line 1630 of file LIPlexMaps.cxx.

References LILookup::CalcNpe(), LILookup::CalcRms(), fLookup, Msg::kInfo, kQE, DmxStatTypes::kRms, and MSG.

01631 {
01632   MSG("LIPlexMaps",Msg::kInfo) 
01633     <<" ** Running LIErrors method... **"<<endl;
01634 
01635   //use the pretty palette
01636   gStyle->SetPalette(1);
01637   //include the under and overflow counts
01638   gStyle->SetOptStat(1111111);
01639 
01640   //these two are defined
01641   const Double_t kQE=0.13;
01642   const Double_t kGain=80;
01643 
01644   const Int_t kNumPoints=50;  
01645 
01646   TGraph *gGainErrorNormVsMean=new TGraph(kNumPoints);
01647   TGraph *gMeanErrorNormVsMean=new TGraph(kNumPoints);
01648   TGraph *gRmsErrorNormVsMean=new TGraph(kNumPoints);
01649 
01650   for (Int_t i=0;i<kNumPoints;i++){
01651 
01652     //these rough numbers allow a number of photons to be derived
01653     //by specifying the roughMean
01654     //probably a bit pointless!!!
01655     Double_t roughMean=200*(i+1);
01656     Double_t roughRms=fLookup.CalcRms(roughMean,kGain,kQE);
01657     Double_t roughNpe=fLookup.CalcNpe(roughMean,roughRms,kQE);
01658     
01659     //round up the number of photons
01660     Double_t tempN=-1;
01661     Double_t rem=0;
01662     rem=modf(roughNpe/kQE,&tempN);
01663     if (rem>=0.5) tempN++;
01664     
01665     //the number of photons is the number from which all others
01666     //must be derived
01667     const Int_t kN=static_cast<Int_t>(tempN);//number of photons
01668     const Double_t kNpe=kN*kQE;
01669     const Double_t kMean=kGain*kNpe;
01670     const Double_t kRms=fLookup.CalcRms(kMean,kGain,kQE);
01671     const Double_t kAdcsPerPe=kMean/kNpe;
01672     
01673     MSG("LIPlexMaps",Msg::kInfo) 
01674       <<endl<<"The following parameters are used in the MC:"<<endl
01675       <<"kQE="<<kQE<<endl
01676       <<"kN="<<kN<<endl
01677       <<"kMean="<<kMean<<endl
01678       <<"kRms="<<kRms<<endl
01679       <<"kGain="<<kGain<<endl
01680       <<"kNpe="<<kNpe<<endl
01681       <<"kAdcsPerPe="<<kAdcsPerPe<<endl;
01682 
01683     Double_t numFlashes=1000;    
01684     Double_t errorOnMeanN=-1;
01685     Double_t errorOnGainN=-1;
01686     Double_t errorOnRmsN=-1;
01687     
01688     //calcualte the errors analytically
01689     //error on mean (and rms) = rms/sqrt(NumFlashes)
01690       
01691     //calcualte fractional errors
01692     errorOnMeanN=(kRms/sqrt(numFlashes))/kMean;
01693     errorOnRmsN=1/sqrt(numFlashes);
01694     errorOnGainN=sqrt(pow(errorOnRmsN,2)*2+
01695                          pow(errorOnMeanN,2));
01696     
01697     MSG("LIPlexMaps",Msg::kInfo)
01698       <<"Mean="<<kMean<<", rms="<<kRms
01699       <<", N="<<numFlashes
01700       <<", Errors: eMean="
01701       <<"("<<errorOnMeanN*100<<"%)"
01702       <<", eRms="
01703       <<"("<<errorOnRmsN*100<<"%)"
01704       <<", eGain="<<"("<<errorOnGainN*100<<"%)"
01705       <<endl;      
01706     
01707     gGainErrorNormVsMean->SetPoint(i,kMean,errorOnGainN);
01708     gMeanErrorNormVsMean->SetPoint(i,kMean,errorOnMeanN);
01709     gRmsErrorNormVsMean->SetPoint(i,kMean,errorOnRmsN);
01710   }
01711     
01713   //plot the errors on the gain
01715   //create canvas
01716   TCanvas *cGainErrorVsMean=new TCanvas("cGainErrorVsMean",
01717                                         "cGainErrorVsMean",
01718                                         1,1,1000,800);
01719   cGainErrorVsMean->SetFillColor(0);
01720     
01721   gGainErrorNormVsMean->SetTitle("Fractional Error on Gain Vs Mean");
01722   gGainErrorNormVsMean->SetMarkerStyle(3);
01723   gGainErrorNormVsMean->SetMarkerColor(2);
01724   gGainErrorNormVsMean->SetMarkerSize(0.2);
01725   cGainErrorVsMean->cd(1);
01726   gGainErrorNormVsMean->Draw("AP");
01727   gGainErrorNormVsMean->GetXaxis()->SetTitle("Mean");
01728   gGainErrorNormVsMean->GetYaxis()->SetTitle
01729     ("Fractional Error on Gain");
01730   gGainErrorNormVsMean->GetXaxis()->CenterTitle();
01731   gGainErrorNormVsMean->GetYaxis()->CenterTitle();
01732   gGainErrorNormVsMean->SetMinimum(0);
01733     
01735   //plot the errors on the mean
01737   //create canvas
01738   TCanvas *cMeanErrorVsMean=new TCanvas("cMeanErrorVsMean",
01739                                         "cMeanErrorVsMean",
01740                                         1,1,1000,800);
01741   cMeanErrorVsMean->SetFillColor(0);
01742 
01743   gMeanErrorNormVsMean->SetTitle("Fractional Error on Mean Vs Mean");
01744   gMeanErrorNormVsMean->SetMarkerStyle(3);
01745   gMeanErrorNormVsMean->SetMarkerColor(2);
01746   gMeanErrorNormVsMean->SetMarkerSize(0.2);
01747   cMeanErrorVsMean->cd(1);
01748   gMeanErrorNormVsMean->Draw("AP");
01749   gMeanErrorNormVsMean->GetXaxis()->SetTitle("Mean");
01750   gMeanErrorNormVsMean->GetYaxis()->SetTitle
01751     ("Fractional Error on Mean");
01752   gMeanErrorNormVsMean->GetXaxis()->CenterTitle();
01753   gMeanErrorNormVsMean->GetYaxis()->CenterTitle();
01754   gMeanErrorNormVsMean->SetMinimum(0);
01755     
01757   //plot the errors on the rms
01759   //create canvas
01760   TCanvas *cRmsErrVsMean=new TCanvas("cRmsErrVsMean","cRmsErrVsMean",
01761                                      1,1,1000,800);
01762   cRmsErrVsMean->SetFillColor(0);
01763 
01764   gRmsErrorNormVsMean->SetTitle
01765     ("Fractional Error on Rms Vs Mean");
01766   gRmsErrorNormVsMean->SetMarkerStyle(3);
01767   gRmsErrorNormVsMean->SetMarkerColor(2);
01768   gRmsErrorNormVsMean->SetMarkerSize(0.2);
01769   cRmsErrVsMean->cd(1);
01770   gRmsErrorNormVsMean->Draw("AP");
01771   gRmsErrorNormVsMean->GetXaxis()->SetTitle("Mean");
01772   gRmsErrorNormVsMean->GetYaxis()->SetTitle
01773     ("Fractional Error on Rms");
01774   gRmsErrorNormVsMean->GetXaxis()->CenterTitle();
01775   gRmsErrorNormVsMean->GetYaxis()->CenterTitle();
01776   gRmsErrorNormVsMean->SetMinimum(0);
01777   
01778   MSG("LIPlexMaps",Msg::kInfo)
01779     <<" ** Finished the LIErrors method ** "<<endl;
01780 }

void LIPlexMaps::MakeCalAdcToPe ( std::string  gainsFileName,
Detector::Detector_t  det,
SimFlag::ESimFlag  simFlag,
VldTimeStamp  vldStart,
VldTimeStamp  vldEnd,
Int_t  aggNo,
Int_t  task,
Int_t  aggStat[484],
VldTimeStamp  creationDate,
std::string  dbName,
std::string  sLogComment,
Int_t  gainTooHigh,
Int_t  gainCeiling,
Bool_t  writeToDb = false 
)
void LIPlexMaps::MakeCalMIPCalibration ( Float_t  scale,
Detector::Detector_t  det,
SimFlag::ESimFlag  simFlag,
VldTimeStamp  vldStart,
VldTimeStamp  vldEnd,
Int_t  aggNo,
Int_t  task,
VldTimeStamp  creationDate,
std::string  dbName,
std::string  sLogComment,
Bool_t  writeToDb 
)

Definition at line 5032 of file LIPlexMaps.cxx.

References VldRange::AsString(), DbiWriter< T >::CanOutput(), DbiWriter< T >::Close(), DbiWriter< T >::IsOpen(), IsPermitted(), Msg::kInfo, and MSG.

05043 {
05044   MSG("LIPlexMaps",Msg::kInfo)
05045     <<endl<<" ** Running the MakeCalMIPCalibration() method... **"<<endl; 
05046   //this->SetDetector(det);
05047 
05048   //make validity range
05049   VldRange vr(det,simFlag,vldStart,vldEnd,
05050               "LISummary/LIPlexMaps::MakeCalMIPCalibration");
05051   MSG("LIPlexMaps",Msg::kInfo)
05052     <<"Using Validity Range: "<<vr.AsString()<<endl;
05053 
05054   MSG("LIPlexMaps",Msg::kInfo)
05055     <<"Other settings used:"<<endl
05056     <<"aggNo="<<aggNo<<endl
05057     <<"task="<<task<<endl
05058     <<"creationDate="<<creationDate<<endl
05059     <<"dbName="<<dbName<<endl
05060     <<"sLogComment="<<sLogComment<<endl
05061     <<"writeToDb="<<writeToDb<<endl;
05062 
05063   //create the writer
05064   DbiWriter<CalMIPCalibration> writer(vr,aggNo,task,creationDate,dbName,
05065                                       sLogComment);
05066 
05067   //set these to zero since you only need one entry and the calibrator
05068   //wont check the values
05069   Int_t seidkey=0;
05070   Int_t stripendid=0;
05071 
05072   //create CALADCTOPE table row
05073   CalMIPCalibration calMIPCalibration(seidkey,stripendid,scale);
05074   MSG("LIPlexMaps",Msg::kInfo)
05075     <<"Writing point with:"<<endl
05076     <<"  seidkey="<<seidkey<<endl
05077     <<"  stripendid="<<stripendid<<endl
05078     <<"  scale="<<scale<<endl;
05079 
05080   //write the row to the dbiwriter
05081   writer<<calMIPCalibration;
05082         
05083   MSG("LIPlexMaps",Msg::kInfo)
05084     <<"DbiWriter.IsOpen="<<writer.IsOpen()<<endl
05085     <<"DbiWriter.CanOutput="<<writer.CanOutput()<<endl;
05086   
05087   if (writeToDb){
05088     if (this->IsPermitted()){
05089       MSG("LIPlexMaps",Msg::kInfo)
05090         <<"Writing to database..."<<endl;
05091       //this is the line that actually writes to the database
05092       writer.Close();
05093       MSG("LIPlexMaps",Msg::kInfo)
05094         <<"Finished writing to database"<<endl;
05095     }
05096   }
05097   else {
05098     MSG("LIPlexMaps",Msg::kInfo)
05099       <<"Mode is set to NOT write to database"<<endl;
05100   }
05101 
05102   MSG("LIPlexMaps",Msg::kInfo)
05103     <<endl<<" ** Finished the MakeCalMIPCalibration method... ** "<<endl;
05104 }

void LIPlexMaps::MakeCalStripAtten ( std::string  sDataFileName,
Detector::Detector_t  det,
SimFlag::ESimFlag  simFlag,
VldTimeStamp  vldStart,
VldTimeStamp  vldEnd,
Int_t  aggNo,
Int_t  task,
VldTimeStamp  creationDate,
std::string  dbName,
std::string  sLongComment,
Int_t  iFileFormat,
Bool_t  writeToDb = false 
)

Definition at line 4872 of file LIPlexMaps.cxx.

References PlexStripEndId::AsString(), VldRange::AsString(), DbiWriter< T >::CanOutput(), DbiWriter< T >::Close(), exit(), DbiWriter< T >::IsOpen(), IsPermitted(), Msg::kError, Msg::kInfo, Detector::kNear, StripEnd::kWest, MAXMSG, MSG, and LILookup::SetDetector().

04884 {
04885   MSG("LIPlexMaps",Msg::kInfo)
04886     <<endl<<" ** Running the MakeCalStripAtten() method... **"<<endl;
04887   //this must go first
04888   this->SetDetector(static_cast<Int_t>(det));
04889 
04890   //open the file
04891   MSG("LIPlexMaps",Msg::kInfo)
04892     <<"Opening file "<<sDataFileName<<"..."<<endl;
04893   ifstream dataFile(sDataFileName.c_str());
04894   
04895   if (!dataFile){
04896     MSG("LIPlexMaps",Msg::kInfo)
04897       <<"Can't open file "<<sDataFileName<<endl
04898       <<"Exiting here..."<<endl;
04899     exit(1);
04900   }
04901   
04902   //make validity range
04903   VldRange vr(det,simFlag,vldStart,vldEnd,
04904               "LISummary/LIPlexMaps::MakeCalStripAtten");
04905   MSG("LIPlexMaps",Msg::kInfo)
04906     <<"Using Validity Range: "<<vr.AsString()<<endl;
04907 
04908   MSG("LIPlexMaps",Msg::kInfo)
04909     <<"Log comment="<<sLogComment<<endl;
04910 
04911   //create the writer
04912   DbiWriter<CalStripAtten> writer(vr,aggNo,task,creationDate,dbName,
04913                                   sLogComment);
04914   Int_t counter=0;
04915 
04916   if (iFileFormat==0) {//this is leon/jiajie's file format
04917     MAXMSG("LIPlexMaps",Msg::kInfo,100)
04918       <<"Assuming fileFormat=0 (=Leon/Jiajie's format)"<<endl;
04919     Int_t TotalLines=12000;
04920     Char_t buffer[248], moduleid[11];
04921     Int_t plane,strip,module_strip,ndf;
04922     Double_t chi2,shortAmp,shortAmp_err,shortAtt,shortAtt_err;
04923     Double_t longAmp,longAmp_err,longAtt,longAtt_err;
04924     
04925     dataFile.getline(buffer,248);
04926     
04927     for(Int_t i=0; i<TotalLines; i++) {
04928       if(!dataFile.good()) break;
04929       dataFile >> moduleid >> module_strip >> plane >> strip >> shortAmp
04930                >> shortAmp_err >> shortAtt >> shortAtt_err >> longAmp
04931                >> longAmp_err >> longAtt >> longAtt_err >> chi2 >> ndf;
04932       
04933       Double_t frac1 = shortAmp/(shortAmp+longAmp);
04934       Double_t frac1_err = 0;
04935       Double_t SAerr_2 = pow(shortAmp_err,2);
04936       Double_t LAerr_2 = pow(longAmp_err,2);
04937       Double_t SLA = shortAmp + longAmp;
04938       
04939       if(shortAmp>0) 
04940         frac1_err = frac1 * sqrt(SAerr_2/(2*shortAmp)+
04941                                  (SAerr_2+LAerr_2)/pow(SLA,2));
04942       PlexStripEndId seid(Detector::kNear,plane,strip,StripEnd::kWest);
04943       
04944       MAXMSG("LIPlexMaps",Msg::kInfo,100)
04945         <<"Found line in file: seid_enc="<<seid.AsString()
04946         <<", shortAtt="<<shortAtt/100.<< ", longAtt=" <<longAtt/100.
04947         <<", frac1="<<frac1 << endl;
04948       
04949       CalStripAtten calStripAtten(seid,shortAtt/100.,longAtt/100.,
04950                                   frac1,shortAtt_err/100,longAtt_err/100.,
04951                                   frac1_err);
04952       writer << calStripAtten;
04953       counter++;
04954     }
04955     dataFile.getline(buffer,248);
04956   }
04957   else if (iFileFormat==1) { //this is the format from DumpCalStripAtten
04958     MAXMSG("LIPlexMaps",Msg::kInfo,100)
04959       <<"Assuming fileFormat=1 (=DumpCalStripAtten)"<<endl;
04960 
04961     Int_t seid_enc=-1;
04962     Float_t lambda1=-1;
04963     Float_t lambda2=-1;
04964     Float_t frac1=-1;
04965     Float_t lambda1Err=-1;
04966     Float_t lambda2Err=-1;
04967     Float_t frac1Err=-1;
04968 
04969     //read in from the text file and fill objects
04970     while(dataFile
04971           >>seid_enc
04972           >>lambda1
04973           >>lambda2
04974           >>frac1
04975           >>lambda1Err
04976           >>lambda2Err
04977           >>frac1Err) {
04978     
04979       MAXMSG("LIPlexMaps",Msg::kInfo,10)
04980         <<"Found line in file: seid_enc="<<seid_enc
04981         <<", lambda1="<<lambda1
04982         <<", lambda2="<<lambda2
04983         <<", frac1="<<frac1
04984         <<endl;
04985    
04986       //create CALSTRIPATTEN table row
04987       CalStripAtten calStripAtten(seid_enc,lambda1,lambda2,frac1,
04988                                   lambda1Err,lambda2Err,frac1Err);   
04989       
04990       //write the row to the dbiwriter
04991       writer<<calStripAtten;
04992       
04993       counter++;
04994     }
04995   }
04996   else {
04997     MSG("LIPlexMaps",Msg::kError)
04998       <<"Input file format not recognised = "<<iFileFormat
04999       <<", will exit here..."<<endl;
05000     exit(1);
05001   }
05002   dataFile.close();
05003   
05004   MSG("LIPlexMaps",Msg::kInfo)
05005     <<"Found "<<counter<<" rows in file: "<<sDataFileName<<endl;
05006 
05007   MSG("LIPlexMaps",Msg::kInfo)
05008     <<"DbiWriter.IsOpen="<<writer.IsOpen()<<endl
05009     <<"DbiWriter.CanOutput="<<writer.CanOutput()<<endl;
05010 
05011   if (writeToDb){
05012     if (this->IsPermitted()){
05013       MSG("LIPlexMaps",Msg::kInfo)
05014     <<"Writing to database..."<<endl;
05015       //this is the line that actually writes to the database
05016       writer.Close();
05017       MSG("LIPlexMaps",Msg::kInfo)
05018     <<"Finished writing to database"<<endl;
05019     }
05020   }
05021   else {
05022     MSG("LIPlexMaps",Msg::kInfo)
05023       <<"Mode is set to NOT write to database"<<endl;
05024   }
05025 
05026   MSG("LIPlexMaps",Msg::kInfo)
05027     <<endl<<" ** Finished the MakeCalStripAtten method... ** "<<endl;
05028 }

void LIPlexMaps::MakeCalStripToStrip ( std::string  sDataFileName,
Detector::Detector_t  det,
SimFlag::ESimFlag  simFlag,
VldTimeStamp  vldStart,
VldTimeStamp  vldEnd,
Int_t  aggNo,
Int_t  task,
VldTimeStamp  creationDate,
std::string  dbName,
std::string  sLogComment,
Bool_t  writeToDb = false 
)

Definition at line 4721 of file LIPlexMaps.cxx.

References VldRange::AsString(), DbiWriter< T >::CanOutput(), DbiWriter< T >::Close(), exit(), LILookup::FIRSTSCINTPLANE, LILookup::FIRSTSTRIP, PlexStripEndId::GetEncoded(), DbiWriter< T >::IsOpen(), IsPermitted(), it, StripEnd::kEast, Detector::kFar, Msg::kInfo, Detector::kNear, StripEnd::kWest, LILookup::LASTSCINTPLANE, LILookup::LASTSTRIP, MAXMSG, MSG, myCalStripToStrip::response, myCalStripToStrip::responseErr, myCalStripToStrip::seid_enc, and LILookup::SetDetector().

04732 {
04733   MSG("LIPlexMaps",Msg::kInfo)
04734     <<endl<<" ** Running the MakeCalStripToStrip() method... **"<<endl; 
04735   //this must go first
04736   this->SetDetector(static_cast<Int_t>(det));
04737 
04738   //open the file  
04739   MSG("LIPlexMaps",Msg::kInfo)
04740     <<"Opening file "<<sDataFileName<<"..."<<endl;
04741   ifstream dataFile(sDataFileName.c_str());
04742 
04743   if (!dataFile){
04744     MSG("LIPlexMaps",Msg::kInfo)
04745       <<"Can't open file "<<sDataFileName<<endl
04746       <<"Exiting here..."<<endl;
04747     exit(1);
04748   }
04749  
04750   //make validity range
04751   VldRange vr(det,simFlag,vldStart,vldEnd,
04752               "LISummary/LIPlexMaps::MakeCalStripToStrip");
04753   MSG("LIPlexMaps",Msg::kInfo)
04754     <<"Using Validity Range: "<<vr.AsString()<<endl;
04755   
04756   MSG("LIPlexMaps",Msg::kInfo)
04757     <<"Log comment="<<sLogComment<<endl;
04758 
04759   //create the writer
04760   DbiWriter<CalStripToStrip> writer(vr,aggNo,task,creationDate,dbName,
04761                                     sLogComment);
04762    
04763   Int_t seid_enc=-1;
04764   Float_t resp=-1;
04765   Float_t respErr=-1;
04766   Float_t defaultResp=1;
04767   Float_t defaultRespErr=1;
04768 
04769   Int_t counter=0;
04770 
04771   //map to store all the calsts
04772   map<Int_t,myCalStripToStrip> inputCalSts;
04773   
04774   //initialise map according to the expected number of strips
04775   //this was written to fill gaps in tables
04776   for (Int_t pl=FIRSTSCINTPLANE;pl<=LASTSCINTPLANE;pl++){
04777     for (Int_t st=FIRSTSTRIP;st<=LASTSTRIP;st++){
04778 
04779       //continue if not FI - happens in pl!=6,11,16,...
04780       if (det==Detector::kNear && st>67 && (pl-1)%5!=0) continue; 
04781       
04782       //continue if in spectrometer and not pl=121,126,131,...
04783       if (det==Detector::kNear && pl>120 && (pl-1)%5!=0) continue; 
04784       
04785       //cut out the SM2 bookend
04786       if (det==Detector::kFar && pl==249) continue;
04787 
04788       MAXMSG("LIPlexMaps",Msg::kInfo,10)
04789         <<"pl="<<pl<<", st="<<st<<endl;
04790 
04791       PlexStripEndId seidE(det,pl,st,StripEnd::kEast);
04792       PlexStripEndId seidW(det,pl,st,StripEnd::kWest);
04793       
04794       //only write the east side if not ND
04795       if (det!=Detector::kNear){
04796         MAXMSG("LIPlexMaps",Msg::kInfo,1)
04797           <<endl<<"Detector is not ND thus creating East stripends..."
04798           <<endl;
04799         inputCalSts[seidE.GetEncoded()]=myCalStripToStrip
04800           (seidE.GetEncoded(),defaultResp,defaultRespErr);;
04801       }
04802       
04803       //always write the west side
04804       inputCalSts[seidW.GetEncoded()]=myCalStripToStrip
04805         (seidW.GetEncoded(),defaultResp,defaultRespErr);;
04806       //inputCalSts[seidW.GetEncoded()]=calStripToStripW;
04807     }
04808   }
04809 
04810   MSG("LIPlexMaps",Msg::kInfo)
04811     <<"Map initialised with size="<<inputCalSts.size()<<endl;
04812 
04813   //read in from the text file and fill objects
04814   while(dataFile>>seid_enc>>resp>>respErr) {
04815     
04816     MAXMSG("LIPlexMaps",Msg::kInfo,10)
04817       <<"Found line in file: seid_enc="<<seid_enc
04818       <<", resp="<<resp<<", respErr="<<respErr<<endl;
04819 
04820     //create CALSTRIPTOSTRIP table row
04821     //CalStripToStrip calStripToStrip(seid_enc,resp,respErr);
04822 
04823     //write the new calsts to the map (this overwrites initial object)    
04824     inputCalSts[seid_enc]=myCalStripToStrip(seid_enc,resp,respErr);;
04825 
04826     //write the row to the dbiwriter
04827     //writer<<calStripToStrip;//can write below if rows missing
04828 
04829     counter++;
04830   }
04831 
04832   MSG("LIPlexMaps",Msg::kInfo)
04833     <<"Found "<<counter<<" rows in file: "<<sDataFileName
04834     <<", mapSize="<<inputCalSts.size()<<endl;
04835 
04836   //loop over map and write to database
04837   typedef map<Int_t,myCalStripToStrip>::const_iterator stsIt;
04838   for (stsIt it=inputCalSts.begin();it!=inputCalSts.end();it++){
04839     const myCalStripToStrip& c=it->second;
04840     CalStripToStrip calStripToStrip(c.seid_enc,c.response,c.responseErr);
04841     MAXMSG("LIPlexMaps",Msg::kInfo,10)
04842       <<"Writing to database: seidEnc="<<c.seid_enc
04843       <<", resp="<<c.response<<", respErr="<<c.responseErr<<endl;
04844     writer<<calStripToStrip;
04845   }
04846 
04847   MSG("LIPlexMaps",Msg::kInfo)
04848     <<"DbiWriter.IsOpen="<<writer.IsOpen()<<endl
04849     <<"DbiWriter.CanOutput="<<writer.CanOutput()<<endl;
04850   
04851   if (writeToDb){
04852     if (this->IsPermitted()){
04853       MSG("LIPlexMaps",Msg::kInfo)
04854         <<"Writing to database..."<<endl;
04855       //this is the line that actually writes to the database
04856       writer.Close();
04857       MSG("LIPlexMaps",Msg::kInfo)
04858         <<"Finished writing to database"<<endl;
04859     }
04860   }
04861   else {
04862     MSG("LIPlexMaps",Msg::kInfo)
04863       <<"Mode is set to NOT write to database"<<endl;
04864   }
04865 
04866   MSG("LIPlexMaps",Msg::kInfo)
04867     <<endl<<" ** Finished the MakeCalStripToStrip method... ** "<<endl;
04868 }

void LIPlexMaps::MakePinPlexTables (  ) 

Definition at line 3431 of file LIPlexMaps.cxx.

References fLookup, PlexLedId::GetEncoded(), PlexLedId::GetLedInBox(), LILookup::GetPinDiodeIds(), PlexLedId::GetPulserBox(), SimFlag::kData, Detector::kFar, Msg::kInfo, LILookup::LASTPULSERBOX, MSG, and LILookup::NUMPULSERBOXES.

03432 {
03433   MSG("LIPlexMaps",Msg::kInfo)
03434     <<endl<<" ** Running the MakePinPlexTables() method... ** "
03435     <<endl; 
03436   
03437   //Thanks to Ryan for the DB code of this method
03438   
03439   //First fill the pin diode table
03440   VldTimeStamp farpinstart = VldTimeStamp(2000,1,1,12,0,0);
03441   VldTimeStamp farpinend = VldTimeStamp(2010,1,1,12,0,0);
03442   VldRange farpinvr(Detector::kFar,SimFlag::kData,farpinstart,
03443                     farpinend,"LIPlexMaps");
03444   VldTimeStamp create; // now!
03445   VldContext vc(Detector::kFar,SimFlag::kData,create);
03446   PlexHandle plexHandle(vc);
03447 
03448   for(Int_t pb=0;pb<NUMPULSERBOXES;pb++){
03449     for(Int_t led=1;led<=LASTPULSERBOX;led++){
03450 
03451       PlexLedId ledId(Detector::kFar,pb,led);
03452 
03453       int aggNo = 0x7ff & ledId.GetEncoded();
03454 
03455       DbiWriter<PlexPinDiodeToLed> writer(farpinvr,aggNo,0,create);
03456 
03457       std::pair<PlexPinDiodeId,PlexPinDiodeId> newPins=fLookup.
03458         GetPinDiodeIds(plexHandle,ledId.GetLedInBox());
03459 
03460       PlexPinDiodeToLed hpin2led(newPins.first.GetDetector(),
03461                                  newPins.first.GetElecType(),
03462                                  newPins.first.GetEastWest(),
03463                                  newPins.first.GetRackLevel(),
03464                                  newPins.first.GetRackBay(),
03465                                  newPins.first.GetInRack(),
03466                                  newPins.first.GetInBox(),
03467                                  newPins.first.GetGain(),
03468                                  ledId.GetPulserBox(),
03469                                  ledId.GetLedInBox());
03470       PlexPinDiodeToLed lpin2led(newPins.second.GetDetector(),
03471                                  newPins.second.GetElecType(),
03472                                  newPins.second.GetEastWest(),
03473                                  newPins.second.GetRackLevel(),
03474                                  newPins.second.GetRackBay(),
03475                                  newPins.second.GetInRack(),
03476                                  newPins.second.GetInBox(),
03477                                  newPins.second.GetGain(),
03478                                  ledId.GetPulserBox(),
03479                                  ledId.GetLedInBox());
03480       writer <<hpin2led;
03481       writer <<lpin2led;
03482       //writer.Close();
03483     }
03484   }
03485 
03486   MSG("LIPlexMaps",Msg::kInfo)
03487     <<endl<<" ** Finished the MakePinPlexTables() method... ** "
03488     <<endl; 
03489 }

void LIPlexMaps::MakePlexStripEndToLed ( Bool_t  writeToDb = false  ) 

a hack for caldet because both side of plane zero

Definition at line 5108 of file LIPlexMaps.cxx.

References bfld::AsString(), DbiWriter< T >::CanOutput(), DbiWriter< T >::Close(), LILookup::FIRSTEND, LILookup::FIRSTPLANE, LILookup::FIRSTSTRIP, fLookup, Form(), fS, PlexLedId::GetEncoded(), PlexHandle::GetRawChannelId(), PlexHandle::GetReadoutType(), DbiWriter< T >::IsOpen(), IsPermitted(), Detector::kCalDet, SimFlag::kData, Msg::kDebug, StripEnd::kEast, Detector::kFar, Msg::kInfo, ReadoutType::kScintStrip, StripEnd::kUnknown, StripEnd::kWest, LILookup::LASTPLANE, LILookup::LASTSTRIP, MSG, LILookup::NUMPULSERBOXES, VldRange::Print(), VldTimeStamp::Print(), LILookup::SECONDEND, LILookup::SetPbPlanes(), and LILookup::Strip2Led().

05109 {
05110   MSG("LIPlexMaps",Msg::kInfo)
05111     <<endl<<" ** Running the MakePlexStripEndToLed method... ** "
05112     <<endl;   
05113   //Thanks to Ryan for the DB code of this method  
05114 
05115   Detector::Detector_t det=Detector::kCalDet;
05116   
05117   Int_t* planeMax=new Int_t[NUMCRATES];
05118   Int_t* planeMin=new Int_t[NUMCRATES];
05119   fLookup.SetPbPlanes(planeMin,planeMax,det);
05120   
05121   const Int_t firstStripBin=FIRSTSTRIP-8;//-8;
05122   const Int_t lastStripBin=LASTSTRIP+9;//200;
05123   const Int_t bins=lastStripBin-firstStripBin;
05124 
05125   string sConstantBit="";
05126 
05127   MSG("LIAnalysis",Msg::kInfo)
05128     <<"sConstantBit="<<sConstantBit<<endl;
05129 
05130   TH2F **hStripVsPlaneLed=0;
05131   hStripVsPlaneLed= new TH2F*[NUMCRATES];
05132   for (Int_t i=0;i<NUMCRATES;i++){
05133     string sPb=Form("%d",i);
05134     fS="Led (Crate "+sPb+")";
05135     hStripVsPlaneLed[i]=new TH2F(fS.c_str(),fS.c_str(),
05136                                       planeMax[i]-planeMin[i],
05137                                       planeMin[i],planeMax[i],
05138                                       bins,firstStripBin,lastStripBin);
05139     hStripVsPlaneLed[i]->GetXaxis()->SetTitle("Plane");
05140     hStripVsPlaneLed[i]->GetXaxis()->CenterTitle();
05141     hStripVsPlaneLed[i]->GetYaxis()->SetTitle("Strip");
05142     hStripVsPlaneLed[i]->GetYaxis()->CenterTitle();
05143     hStripVsPlaneLed[i]->SetFillColor(0);
05144     //hStripVsPlaneLed[i]->SetBit(TH1::kCanRebin);
05145   }
05146 
05147   //First fill the pin diode table
05148   VldTimeStamp tsStart=VldTimeStamp(2003,3,1,12,0,0);
05149   MSG("LIPlexMaps",Msg::kInfo)
05150     <<"Vld start time: ";
05151   tsStart.Print();
05152   MSG("LIPlexMaps",Msg::kInfo)
05153     <<endl;
05154   VldTimeStamp tsEnd=VldTimeStamp(2010,1,1,12,0,0);
05155   MSG("LIPlexMaps",Msg::kInfo)
05156     <<"Vld end time: ";
05157   tsEnd.Print();
05158   MSG("LIPlexMaps",Msg::kInfo)
05159     <<endl;
05160 
05161   //set validity range
05162   VldRange vldRng(det,SimFlag::kData,tsStart,tsEnd,
05163                   "MakePlexStripEndToLed");
05164   MSG("LIPlexMaps",Msg::kInfo)
05165     <<"Validity range: ";
05166   vldRng.Print();
05167   MSG("LIPlexMaps",Msg::kInfo)
05168     <<endl;
05169 
05170   VldTimeStamp tsNow; // now!
05171   VldContext vldNow(det,SimFlag::kData,tsNow);
05172   PlexHandle plexHandle(vldNow);
05173   
05174   //This is the encoding of the ledId.
05175   //15 bits of 32 are used, only the first 11 are needed to
05176   //tell you the pulser box and led
05178   //This was copied from the plex
05180   //    MSB                          LSB
05181   //     3         2         1         0
05182   //    10987654321098765432109876543210
05183   //                     ddddpppppiiiiii
05184   //
05185   //const UInt_t defaultPlexLedId    =  0;
05186   
05187   //const UInt_t bitsPlexLedIdLedInBox    =  6; // iiiiii    0:63
05188   //const UInt_t bitsPlexLedIdPulserBox   =  5; // ppppp     1:31
05189   //const UInt_t bitsPlexLedIdDetector    =  4; // dddd   near,far,caldet,teststand           
05190 
05191   //Note: The aggregate number in the database is the first eleven
05192   //bits of the ledId encoding, i.e. just the pulser box and 
05193   //led information without the detector info  
05194 
05195   //Now try and fill the PlexStripEndToLed
05196   for(Int_t pb=0;pb<NUMPULSERBOXES;pb++){
05197     for(Int_t led=4;led<=6;led++){
05198       //for(Int_t led=FIRSTLED;led<=LASTLED;led++){
05199       MSG("LIPlexMaps",Msg::kInfo)
05200         <<"Pulser box="<<pb<<", led="<<led<<endl;
05201 
05202       //create the plex led id
05203       PlexLedId ledId(det,pb,led);
05204 
05205       //0x7ff=2047=eleven 1s which is the led + pulser box bits
05206       int aggNo=0x7ff & ledId.GetEncoded(); 
05207       MSG("LIPlexMaps",Msg::kInfo)
05208         <<"aggNo="<<aggNo<<", encoded="<<ledId.GetEncoded()
05209         <<", det="<<(ledId.GetEncoded()>>11)<<endl;
05210 
05211       //set log comment
05212       string logComment="Updated to reflect the state of the detector";
05213       //set database number
05214       UInt_t dbNo=1;//1 is the second database in the cascade (string)
05215 
05216       //create the dbi writer
05217       DbiWriter<PlexStripEndToLed> writer(vldRng,aggNo,0,tsNow,dbNo,
05218                                           logComment);
05219       
05220       MSG("LIPlexMaps",Msg::kInfo)
05221         <<"DbiWriter.IsOpen="<<writer.IsOpen()<<endl;
05222       //<<"DbiWriter.CanOutput="<<writer.CanOutput()<<endl;
05223 
05224       //DbiWriter (const VldRange &vr, Int_t aggNo, Dbi::Task task=0, VldTimeStamp creationDate=VldTimeStamp(0, 0), UInt_t dbNo=0,const std::string &LogComment="")
05225 
05226       //loop over all the strips and planes
05227       for(Int_t plane=FIRSTPLANE;plane<=LASTPLANE;plane++){
05228         for(Int_t strip=FIRSTSTRIP;strip<=LASTSTRIP;strip++){
05229           for(Int_t end=FIRSTEND;end<=SECONDEND;end++){
05230 
05231             StripEnd::StripEnd_t stripEndType = StripEnd::kUnknown;         
05232             if (end==StripEnd::kEast) stripEndType=StripEnd::kEast;
05233             else if (end==StripEnd::kWest) stripEndType=StripEnd::kWest;
05234 
05235             PlexStripEndId stripEndId(det,plane,strip,stripEndType);
05236  
05237             //get the crate associated with the strip and plane
05238             Int_t crate=plexHandle.GetRawChannelId(stripEndId).
05239               GetCrate();
05240 
05242             //are readout by the ND
05243             if (plane==0 && end==1 && (crate==1 || crate==2) &&
05244                 det==Detector::kCalDet){
05245               crate=0;
05246               MSG("LIPlexMaps",Msg::kInfo)
05247                 <<"Doing plane 0 caldet hack"<<endl;
05248             }
05249             
05250             //create a plex strip end to led for 
05251             //current strip and plane
05252             PlexStripEndToLed stripEndToLed
05253               (det,plane,strip,stripEndType,pb,
05254                fLookup.Strip2Led(strip,plane,det,crate));
05255               //(Detector::kCalDet,1,1,StripEnd::kWest,0,1);
05256 
05257 
05258             MSG("LIPlexMaps",Msg::kDebug)
05259               <<"("<<plane<<";"<<strip<<";"<<stripEndType<<")"
05260               <<" ("<<pb<<":"<<led<<")"
05261               <<", strip2led="
05262               <<fLookup.Strip2Led(strip,plane,det,crate)<<")"
05263               <<", crate="<<crate
05264               <<", aggNo="<<stripEndToLed.GetAggregateNo()
05265               <<endl;
05266 
05267             ReadoutType::Readout_t rt=plexHandle.GetReadoutType
05268               (plexHandle.GetRawChannelId(stripEndToLed.
05269                                           GetPlexStripEndId()));
05270             
05271             if (rt!=ReadoutType::kScintStrip){
05272               MSG("LIPlexMaps",Msg::kInfo)
05273                 <<"rt="<<ReadoutType::AsString(rt)<<endl;
05274               continue;
05275             }
05276             
05277             //check that stripend to led isn't bad
05278             if(stripEndToLed.GetPlexStripEndId().GetPlane()!=plane ||
05279                stripEndToLed.GetPlexStripEndId().IsSteel() ||
05280                stripEndToLed.GetPlexStripEndId().IsVetoShield() ||
05281                !stripEndToLed.GetPlexStripEndId().IsValid()) {
05282 
05283               MSG("LIPlexMaps",Msg::kInfo)
05284                 <<"Stripend to led was bad: IsSteel="
05285                 <<stripEndToLed.GetPlexStripEndId().IsSteel()
05286                 <<", IsVetoShield="
05287                 <<stripEndToLed.GetPlexStripEndId().IsVetoShield()
05288                 <<", IsValid="
05289                 <<stripEndToLed.GetPlexStripEndId().IsValid()
05290                 <<", GetPlane="
05291                 <<stripEndToLed.GetPlexStripEndId().GetPlane()
05292                 <<", plane="<<plane
05293                 <<endl;
05294               continue;
05295             }
05296 
05297             //check that the led and pulser box encoded in the
05298             //strip end to led are the same as the ledid
05299             if(stripEndToLed.GetPlexLedId().GetEncoded()==
05300                ledId.GetEncoded()) {
05301                
05302               //if the crate is the same as the pulser box
05303               //then write to DB
05304               //this only applies to the far detector since 
05305               //there are multiple pulser boxes
05306               if(crate!=pb && det==Detector::kFar) continue;
05307 
05308               MSG("LIPlexMaps",Msg::kInfo)
05309                 <<stripEndToLed.GetAggregateNo()<<" "
05310                 <<stripEndToLed.GetPlexStripEndId().GetPlane()<<" "
05311                 <<stripEndToLed.GetPlexStripEndId().GetStrip()<<" "
05312                 <<stripEndToLed.GetPlexStripEndId().GetEnd()<<" "
05313                 <<stripEndToLed.GetPlexLedId().GetPulserBox()<<" "
05314                 <<stripEndToLed.GetPlexLedId().GetLedInBox()<<endl;
05315               
05316               //fill the histo for easy visualisation
05317               hStripVsPlaneLed[end-1]->Fill
05318                 (stripEndToLed.GetPlexStripEndId().GetPlane(),
05319                  stripEndToLed.GetPlexStripEndId().GetStrip(),
05320                  stripEndToLed.GetPlexLedId().GetLedInBox());
05321 
05322               writer<<stripEndToLed;
05323               
05324             }//end of if
05325             else{
05326               MSG("LIPlexMaps",Msg::kDebug)
05327                 <<"("<<plane<<";"<<strip<<";"<<stripEndType<<")"
05328                 <<" ("<<pb<<":"<<led<<")"
05329                 <<" These don't match: stripend to led encoded="
05330                 <<stripEndToLed.GetPlexLedId().GetEncoded()
05331                 <<", ledid encoded="<<ledId.GetEncoded()
05332                 <<endl;
05333             }
05334           }//end of strip end loop
05335         }//end of strip loop
05336       }//end of plane loop
05337 
05338       MSG("LIPlexMaps",Msg::kInfo)
05339         <<"DbiWriter.IsOpen="<<writer.IsOpen()<<endl
05340         <<"DbiWriter.CanOutput="<<writer.CanOutput()<<endl;
05341 
05342       if (writeToDb){
05343         if (this->IsPermitted()){
05344           MSG("LIPlexMaps",Msg::kInfo)
05345             <<"Writing to database..."<<endl;
05346           //this is the line that actually writes to the database
05347           writer.Close();
05348           MSG("LIPlexMaps",Msg::kInfo)
05349             <<"Finished writing to database"<<endl;
05350         }
05351       }
05352       else {
05353         MSG("LIPlexMaps",Msg::kInfo)
05354           <<"Mode is set to NOT write to database"<<endl;
05355       }
05356       
05357     }//end of led loop
05358   }//end of pb loop
05359 
05360   //set stats info off
05361   gStyle->SetOptStat(0);
05362 
05363   TCanvas *cStripVsPlaneLed=new TCanvas  
05364     ("cStripVsPlaneLed","StripVsPlane: Led",0,0,1000,800);  
05365   cStripVsPlaneLed->SetFillColor(0);  
05366   cStripVsPlaneLed->Divide(1,2);  
05367   cStripVsPlaneLed->cd(1);  
05368   hStripVsPlaneLed[0]->Draw("textcolz");  
05369   cStripVsPlaneLed->cd(2);  
05370   hStripVsPlaneLed[1]->Draw("textcolz");  
05371 
05372   MSG("LIPlexMaps",Msg::kInfo)
05373     <<endl<<" ** Finished the MakePlexStripEndToLed method... ** "
05374     <<endl; 
05375 }

void LIPlexMaps::NonLinearity (  ) 

Definition at line 1023 of file LIPlexMaps.cxx.

References Munits::g, Munits::gauss, Msg::kInfo, MSG, and LILookup::TGraphVect().

01024 {
01025   MSG("LIPlexMaps",Msg::kInfo) 
01026     <<" ** Running NonLinearity method... **"<<endl;
01027 
01028   //use the pretty palette
01029   gStyle->SetPalette(1);
01030   //include the under and overflow counts
01031   gStyle->SetOptStat(1111111);
01032 
01033   Int_t maxN=1000;
01034 
01035   TH1F *hBinomial= new TH1F("hBinomial","Binomial distribution",
01036                             maxN+5,-1,maxN+4);
01037   hBinomial->SetFillColor(0);
01038   hBinomial->SetLineColor(3);
01039   hBinomial->SetBit(TH1::kCanRebin);
01040 
01041   TH1F *hAdc= new TH1F("hAdc","Binomial distribution",
01042                             60*maxN+5,-1,60*maxN+4);
01043   hAdc->SetFillColor(0);
01044   hAdc->SetLineColor(3);
01045   hAdc->SetBit(TH1::kCanRebin);
01046 
01047   TH1F *hGauss= new TH1F("hGauss","Binomial distribution",
01048                             maxN+5,-1,maxN+4);
01049   hGauss->SetFillColor(0);
01050   hGauss->SetLineColor(2);
01051   hGauss->SetBit(TH1::kCanRebin);
01052 
01053   //create a histogram based on the binomial
01054   TRandom *tRandom=new TRandom(0);
01055   //Double_t kQE=0.13;
01056   Int_t kNumBinomPoints=10000;
01057   vector<Double_t> vPe;
01058   vector<Double_t> vAdc;
01059 
01060   for (Int_t N=120;N<270;N+=2){
01061     static Int_t counter=0;
01062     counter++;
01063     
01064     hBinomial->Reset();
01065     hAdc->Reset();
01066     hGauss->Reset();
01067 
01068     MSG("LIPlexMaps",Msg::kInfo) 
01069       <<endl<<"Generating distribution, N="<<N<<endl;
01070     for (Int_t i=0;i<kNumBinomPoints;i++){
01071 
01072       Double_t gauss=tRandom->Gaus(1.*N,sqrt(1.*N));
01073       hGauss->Fill(gauss);
01074 
01075       Double_t adc=70.*gauss-(1.3e-6*pow(1.*gauss,4.));
01076 
01077       //apply the rail at 237
01078       if (gauss>237) adc=70*237-(1.3e-6*pow(237,4.));
01079     
01080       hAdc->Fill(adc);
01081     }
01082 
01083     vPe.push_back(1.*N);
01084     vAdc.push_back(hAdc->GetMean());
01085   }
01086 
01087   //original numbers, but 420 pe for saturation is too high
01088   /*
01089   for (Int_t N=250;N<480;N+=2){
01090     static Int_t counter=0;
01091     counter++;
01092     
01093     hBinomial->Reset();
01094     hAdc->Reset();
01095     hGauss->Reset();
01096 
01097     MSG("LIPlexMaps",Msg::kInfo) 
01098       <<endl<<"Generating distribution, N="<<N<<endl;
01099     for (Int_t i=0;i<kNumBinomPoints;i++){
01100       //generate a binomial distribution and fill histo
01101       //this works by performing a little MC
01102       //It does N trials and see how many are below the probability p
01103       //Int_t r1=tRandom->Binomial(static_cast<Int_t>(N),
01104       //                         static_cast<Double_t>(kQE));
01105       //hBinomial->Fill(r1);
01106 
01107       //Double_t gauss=tRandom->Gaus(N*kQE,3.29);
01108       Double_t gauss=tRandom->Gaus(1.*N,sqrt(1.*N));
01109       hGauss->Fill(gauss);
01110 
01111       Double_t adc=60.*gauss-(2e-7*pow(1.*gauss,4.));
01112 
01113       //apply the rail at 420
01114       if (gauss>420) adc=60*420-(2e-7*pow(420,4.));
01115 
01116       hAdc->Fill(adc);
01117     }
01118 
01119     vPe.push_back(1.*N);
01120     vAdc.push_back(hAdc->GetMean());
01121   }
01122   */
01123 
01124   //draw binomial distribution
01125   TCanvas *cBinomial=new TCanvas("cBinomial","cBinomial",1,1,1000,800);
01126   cBinomial->SetFillColor(0);
01127   cBinomial->cd();
01128   hBinomial->Draw();
01129   hGauss->Draw("sames");
01130 
01131   //draw distribution
01132   TCanvas *cAdc=new TCanvas("cAdc","cAdc",1,1,1000,800);
01133   cAdc->SetFillColor(0);
01134   cAdc->cd();
01135   hAdc->Draw();
01136 
01137   vector<Double_t> vx;
01138   vector<Double_t> vy;
01139   vector<Double_t> vStraight;
01140 
01141   for (Double_t i=0;i<300;i+=1){
01142     Double_t x=i;
01143     Double_t y=70*x-(1.3e-6*pow(x,4.));
01144 
01145     //apply the rail at 237
01146     if (x>237) y=70*237-(1.3e-6*pow(237,4.));
01147 
01148     vx.push_back(x);
01149     vy.push_back(y);
01150     vStraight.push_back(70*x);
01151 
01152   }
01153 
01154   TGraph* g=this->TGraphVect(vx,vy);
01155   TGraph* gStraight=this->TGraphVect(vx,vStraight);
01156   TGraph* gAdcVsPe=this->TGraphVect(vPe,vAdc);
01157 
01158   //draw graph
01159   TCanvas *cNonLin=new TCanvas("cNonLin","cNonLin",1,1,1000,800);
01160   cNonLin->SetFillColor(0);
01161   cNonLin->cd();
01162   g->Draw("AP");
01163   g->SetMarkerSize(1);
01164   g->SetMarkerStyle(3);
01165   g->SetMarkerColor(3);
01166   gStraight->Draw("p");
01167   gStraight->SetMarkerSize(1);
01168   gStraight->SetMarkerStyle(3);
01169   gStraight->SetMarkerColor(1);
01170   gAdcVsPe->Draw("p");
01171   gAdcVsPe->SetMarkerSize(1);
01172   gAdcVsPe->SetMarkerStyle(3);
01173   gAdcVsPe->SetMarkerColor(2);
01174   //these graphs show that the measured nonlinearity is not
01175   //the same as the actual nonlinearity near the saturation
01176   //level. But the two only differ by <1% so it shouldn't
01177   //matter too much.
01178 
01179   MSG("LIPlexMaps",Msg::kInfo) 
01180     <<" ** Finished NonLinearity method **"<<endl;
01181 }

void LIPlexMaps::NormaliseVector ( std::vector< Double_t > &  v,
Int_t  mode = 1 
)

Referenced by DriftWithTime().

void LIPlexMaps::PeGen (  ) 

Definition at line 1185 of file LIPlexMaps.cxx.

References LILookup::CalcGain(), LILookup::CalcNpe(), LILookup::CalcRms(), fLookup, Msg::kInfo, kQE, DmxStatTypes::kRms, Msg::kVerbose, MSG, SampleDist(), and ScaleVector().

01186 {
01187   MSG("LIPlexMaps",Msg::kInfo) 
01188     <<" ** Running PeGen method... **"<<endl;
01189 
01191   //Theory
01193   //gain=rms**2/mean * 1/(1-p)
01194   //thus
01195   //rms=sqrt(gain*mean*(1-p))
01196   //and
01197   //npe=(mean/rms)**2 * (1-p)
01198 
01199   //use the pretty palette
01200   gStyle->SetPalette(1);
01201   //include the under and overflow counts
01202   gStyle->SetOptStat(1111111);
01203 
01204   TStopwatch stopwatch;
01205 
01206   //these two are defined
01207   const Double_t kQE=0.13;
01208   const Double_t kGain=80;
01209 
01210   //these rough numbers allow a number of photons to be derived
01211   //by specifying the roughMean
01212   //probably a bit pointless!!!
01213   Double_t roughMean=500;
01214   Double_t roughRms=fLookup.CalcRms(roughMean,kGain,kQE);
01215   Double_t roughNpe=fLookup.CalcNpe(roughMean,roughRms,kQE);
01216   
01217   //round up the number of photons
01218   Double_t tempN=-1;
01219   Double_t rem=0;
01220   rem=modf(roughNpe/kQE,&tempN);
01221   if (rem>=0.5) tempN++;
01222   
01223   //the number of photons is the number from which all others
01224   //must be derived
01225   const Int_t kN=static_cast<Int_t>(tempN);//number of photons
01226   const Double_t kNpe=kN*kQE;
01227   const Double_t kMean=kGain*kNpe;
01228   const Double_t kRms=fLookup.CalcRms(kMean,kGain,kQE);
01229   const Double_t kAdcsPerPe=kMean/kNpe;
01230 
01231   //TRandom has a periodicity of 10^8 so if you have >100 photons
01232   //then you shouldn't use more than 1e6 points in the binomial 
01233   //distribution since you will have started at the beginning of 
01234   //the list of random numbers again
01235   //not sure how this will affect things but it seems dodgy
01236   const Int_t kNumBinomPoints=static_cast<Int_t>(1e6);//1e7 is slow
01237 
01238   MSG("LIPlexMaps",Msg::kInfo) 
01239     <<endl<<"The following parameters are used in the MC:"<<endl
01240     <<"kQE="<<kQE<<endl
01241     <<"kN="<<kN<<endl
01242     <<"kMean="<<kMean<<endl
01243     <<"kRms="<<kRms<<endl
01244     <<"kGain="<<kGain<<endl
01245     <<"kNpe="<<kNpe<<endl
01246     <<"kAdcsPerPe="<<kAdcsPerPe<<endl
01247     <<"kNumBinomPoints="<<kNumBinomPoints<<endl;
01248 
01249   TH1F *hBinomial= new TH1F("hBinomial","Binomial distribution",
01250                             kN+3,-1,kN+2);
01251   hBinomial->SetFillColor(0);
01252   hBinomial->SetBit(TH1::kCanRebin);
01253 
01254   TH1F *hADC= new TH1F("hADC","hADC",15000,-1,15000);
01255   hADC->SetFillColor(0);
01256   hADC->SetBit(TH1::kCanRebin);
01257   TH1F *hADC2= new TH1F("hADC2","hADC2",15000,-1,15000);
01258   hADC2->SetFillColor(0);
01259   hADC2->SetBit(TH1::kCanRebin);
01260 
01261   vector<Double_t> vBinomial(kN+1);
01262   Double_t maxInBinomial=0;  
01263   Int_t maxInBinomialPos=0;  
01264 
01265   //create a histogram based on the binomial
01266   TRandom *tRandom=new TRandom(0);
01267   MSG("LIPlexMaps",Msg::kInfo) 
01268     <<endl<<"Generating binomial distribution..."<<endl;
01269   for (Int_t i=0;i<kNumBinomPoints;i++){
01270     //generate a binomial distribution and fill histo
01271     //this works by performing a little MC
01272     //It does N trials and see how many are below the probability p
01273     Int_t r1=tRandom->Binomial(static_cast<Int_t>(kN),
01274                                static_cast<Double_t>(kQE));
01275     hBinomial->Fill(r1);
01276     vBinomial[r1]++;
01277 
01278     //keep track of the maximum in the distribution
01279     if (vBinomial[r1]>maxInBinomial){
01280       maxInBinomial=vBinomial[r1];
01281       maxInBinomialPos=r1;
01282     }
01283 
01284     //print out loop progress
01285     Float_t fract=ceil(kNumBinomPoints/5.);
01286     if (ceil(((Float_t)i)/fract)==((Float_t)i)/fract){
01287       MSG("LIPlexMaps",Msg::kInfo) 
01288         <<"Fraction of loop complete: "<<i 
01289         <<"/"<<kNumBinomPoints<<"  ("
01290         <<(Int_t)(100.*i/kNumBinomPoints)<<"%)"<<endl;
01291     }    
01292   }
01293   MSG("LIPlexMaps",Msg::kInfo) 
01294     <<"Binomial distribution done"<<endl;
01295 
01296   //draw binomial distribution
01297   TCanvas *cBinomial=new TCanvas("cBinomial","cBinomial",1,1,1000,800);
01298   cBinomial->SetFillColor(0);
01299   cBinomial->cd();
01300   hBinomial->Draw();
01301 
01302   //scale the binomial by the max
01303   this->ScaleVector(vBinomial,1/maxInBinomial);
01304 
01305   //fill a histogram that will look like the adc distribution
01306   //you would get from the binomial distribution above
01307   for (Int_t i=0;i<2500;i++){
01308     MSG("LIPlexMaps",Msg::kVerbose)<<"i="<<i<<endl;
01309     hADC->Fill(kAdcsPerPe*hBinomial->GetRandom());
01310     Int_t npe=this->SampleDist(vBinomial,tRandom);
01311     hADC2->Fill(kAdcsPerPe*npe);
01312   }
01313 
01314   //draw the adc distribution you would expect from the binomial above
01315   TCanvas *cAdc=new TCanvas("cAdc","cAdc",1,1,1000,800);
01316   cAdc->SetFillColor(0);
01317   cAdc->Divide(2,1);
01318   cAdc->cd(1);
01319   hADC->Draw();
01320   cAdc->cd(2);
01321   hADC2->Draw();
01322 
01323   const Int_t kNumPoints=20;
01324   const Int_t kFlashes=500; 
01325   Double_t *numFlashes=new Double_t[kNumPoints];
01326 
01327   MSG("LIPlexMaps",Msg::kInfo)
01328     <<endl<<"Calculating errors analytically"<<endl;
01329   //analytically
01330   for (Int_t j=0;j<kNumPoints;j++){
01331     numFlashes[j]=static_cast<Double_t>((j+1)*kFlashes);
01332     MSG("LIPlexMaps",Msg::kInfo)
01333       <<endl<<"Point "<<j+1<<"/"<<kNumPoints
01334       <<", numFlashes="<<numFlashes[j]<<endl;
01335 
01336     //calcualte and print out the errors analytically
01337     //error on mean = rms/sqrt(NumFlashes)
01338     MSG("LIPlexMaps",Msg::kInfo)
01339       <<"Mean="<<kMean<<", rms="<<kRms
01340       <<", N="<<numFlashes[j]
01341       <<", Errors: eMean="<<kRms/sqrt(numFlashes[j])
01342       <<" ("<<((kRms/sqrt(numFlashes[j]))/kMean)*100<<"%)"
01343       <<", eRms="<<kRms/sqrt(numFlashes[j])
01344       <<" ("<<(1/sqrt(numFlashes[j]))*100<<"%)"
01345       <<", eGain="
01346       <<"("<<((1/sqrt(numFlashes[j]))*2+
01347               (kRms/sqrt(numFlashes[j]))/kMean)*100<<"%)"
01348       <<" quad="
01349       <<"("<<sqrt((1/numFlashes[j])*2+
01350                   pow((kRms/sqrt(numFlashes[j]))/kMean,2))*100<<"%)"
01351       <<endl;      
01352   }
01353 
01354   Double_t *mean=new Double_t[kNumPoints*kFlashes];
01355   Double_t *rms=new Double_t[kNumPoints*kFlashes];
01356   Double_t *gain=new Double_t[kNumPoints*kFlashes];
01357   Double_t *xAxis=new Double_t[kNumPoints*kFlashes];
01358 
01359   Double_t *rmsOfMean=new Double_t[kNumPoints];
01360   Double_t *rmsOfGain=new Double_t[kNumPoints];
01361   Double_t *rmsOfRms=new Double_t[kNumPoints];
01362   Double_t *errorOnMean=new Double_t[kNumPoints];
01363   Double_t *errorOnGain=new Double_t[kNumPoints];
01364   Double_t *errorOnRms=new Double_t[kNumPoints];
01365   Double_t *errorOnMeanN=new Double_t[kNumPoints];
01366   Double_t *errorOnGainN=new Double_t[kNumPoints];
01367   Double_t *errorOnRmsN=new Double_t[kNumPoints];
01368 
01369   const Int_t kNumLiRuns=1000;
01370 
01371   MSG("LIPlexMaps",Msg::kInfo)
01372     <<endl<<"Calculating errors by MC"<<endl;
01373   //MC
01374   for (Int_t j=0;j<kNumPoints;j++){
01375     numFlashes[j]=static_cast<Double_t>((j+1)*kFlashes);
01376     MSG("LIPlexMaps",Msg::kInfo)
01377       <<endl<<"Point "<<j+1<<"/"<<kNumPoints
01378       <<", numFlashes="<<numFlashes[j]<<endl;
01379     
01380     stopwatch.Start();
01381     
01382     //take many "runs"
01383     for (Int_t k=0;k<kNumLiRuns;k++){
01384       hADC->Reset();
01385       for (Int_t i=0;i<(j+1)*kFlashes;i++){
01386         //hADC->Fill(kAdcsPerPe*hBinomial->GetRandom());
01387         hADC->Fill(kAdcsPerPe*this->SampleDist(vBinomial,tRandom));
01388       }
01389       mean[k]=hADC->GetMean();
01390       rms[k]=hADC->GetRMS();
01391       gain[k]=fLookup.CalcGain(mean[k],rms[k],kQE);
01392       xAxis[k]=static_cast<Double_t>(k);
01393       rmsOfMean[j]+=pow(kMean-mean[k],2);
01394       rmsOfGain[j]+=pow(kGain-gain[k],2);
01395       rmsOfRms[j]+=pow(kRms-rms[k],2);
01396     }
01397     
01398     stopwatch.Stop();
01399     MSG("LIPlexMaps",Msg::kInfo)
01400       <<"Time elapsed, real="<<stopwatch.RealTime()
01401       <<", cpu="<<stopwatch.CpuTime()
01402       <<endl;
01403     
01404     //final step in rms calculation
01405     rmsOfMean[j]=sqrt(rmsOfMean[j]/kNumLiRuns);
01406     rmsOfGain[j]=sqrt(rmsOfGain[j]/kNumLiRuns);
01407     rmsOfRms[j]=sqrt(rmsOfRms[j]/kNumLiRuns);
01408     
01409     //don't do sqrt of numLiRuns because you don't want
01410     //the error on the gain if you take 1000 runs
01411     //but rather the error on each individual run!!!
01412     errorOnMean[j]=rmsOfMean[j]/sqrt(1.);
01413     errorOnGain[j]=rmsOfGain[j]/sqrt(1.);
01414     errorOnRms[j]=rmsOfRms[j]/sqrt(1.);
01415 
01416     //calcualte fractional errors
01417     errorOnMeanN[j]=errorOnMean[j]/kMean;
01418     errorOnGainN[j]=errorOnGain[j]/kGain;
01419     errorOnRmsN[j]=errorOnRms[j]/kRms;
01420     
01421     MSG("LIPlexMaps",Msg::kInfo)
01422       <<"Errors: eMean="<<errorOnMean[j]
01423       <<" ("<<errorOnMeanN[j]*100<<"%)"
01424       <<", eGain="<<errorOnGain[j]
01425       <<" ("<<errorOnGainN[j]*100<<"%)"
01426       <<", eRms="<<errorOnRms[j]
01427       <<" ("<<errorOnRmsN[j]*100<<"%)"
01428       <<endl;
01429   }
01430 
01431   //
01432   TCanvas *cGain=new TCanvas("cGain","cGain",1,1,1000,800);
01433   cGain->SetFillColor(0);
01434   cGain->Divide(1,2);
01435 
01436   TGraph *gGain=new TGraph(kNumLiRuns,xAxis,gain);
01437   gGain->SetTitle("Gain Vs 'run'");
01438   gGain->SetMarkerStyle(3);
01439   gGain->SetMarkerColor(2);
01440   gGain->SetMarkerSize(0.4);
01441   cGain->cd(1);
01442   gGain->Draw("AP");
01443   gGain->GetXaxis()->SetTitle("'run' number");
01444   gGain->GetYaxis()->SetTitle("Gain");
01445   gGain->GetXaxis()->CenterTitle();
01446   gGain->GetYaxis()->CenterTitle();
01447 
01448   TGraph *gMean=new TGraph(kNumLiRuns,xAxis,mean);
01449   gMean->SetTitle("Mean Vs 'run'");
01450   gMean->SetMarkerStyle(3);
01451   gMean->SetMarkerColor(2);
01452   gMean->SetMarkerSize(0.4);
01453   cGain->cd(2);
01454   gMean->Draw("AP");
01455   gMean->GetXaxis()->SetTitle("'run' number");
01456   gMean->GetYaxis()->SetTitle("Mean");
01457   gMean->GetXaxis()->CenterTitle();
01458   gMean->GetYaxis()->CenterTitle();
01459 
01461   //plot the errors on the gain
01463   //create canvas
01464   TCanvas *cGainError=new TCanvas("cGainError","cGainError",
01465                                   1,1,1000,800);
01466   cGainError->SetFillColor(0);
01467   cGainError->Divide(1,2);
01468   
01469   //create graph
01470   TGraph *gGainErrorNormVsFlashes=new TGraph(kNumPoints,
01471                                              numFlashes,errorOnGainN);
01472   gGainErrorNormVsFlashes->SetTitle
01473     ("Fractional Error on Gain Vs Flashes");
01474   gGainErrorNormVsFlashes->SetMarkerStyle(3);
01475   gGainErrorNormVsFlashes->SetMarkerColor(2);
01476   gGainErrorNormVsFlashes->SetMarkerSize(0.2);
01477   cGainError->cd(1);
01478   gGainErrorNormVsFlashes->Draw("AP");
01479   gGainErrorNormVsFlashes->GetXaxis()->SetTitle("Number of Flashes");
01480   gGainErrorNormVsFlashes->GetYaxis()->SetTitle
01481     ("Fractional Error on Gain");
01482   gGainErrorNormVsFlashes->GetXaxis()->CenterTitle();
01483   gGainErrorNormVsFlashes->GetYaxis()->CenterTitle();
01484   gGainErrorNormVsFlashes->SetMinimum(0);
01485 
01486   //create graph
01487   TGraph *gGainErrorVsFlashes=new TGraph(kNumPoints,
01488                                          numFlashes,errorOnGain);
01489   gGainErrorVsFlashes->SetTitle("Error on Gain Vs Flashes");
01490   gGainErrorVsFlashes->SetMarkerStyle(3);
01491   gGainErrorVsFlashes->SetMarkerColor(2);
01492   gGainErrorVsFlashes->SetMarkerSize(0.2);
01493   cGainError->cd(2);
01494   gGainErrorVsFlashes->Draw("AP");
01495   gGainErrorVsFlashes->GetXaxis()->SetTitle("Number of Flashes");
01496   gGainErrorVsFlashes->GetYaxis()->SetTitle("Error on Gain");
01497   gGainErrorVsFlashes->GetXaxis()->CenterTitle();
01498   gGainErrorVsFlashes->GetYaxis()->CenterTitle();
01499 
01501   //plot the errors on the mean
01503   //create canvas
01504   TCanvas *cGainMean=new TCanvas("cGainMean","cGainMean",1,1,1000,800);
01505   cGainMean->SetFillColor(0);
01506   cGainMean->Divide(1,2);
01507   
01508   //create graph
01509   TGraph *gMeanErrorNormVsFlashes=new TGraph(kNumPoints,
01510                                              numFlashes,errorOnMeanN);
01511   gMeanErrorNormVsFlashes->SetTitle
01512     ("Fractional Error on Mean Vs Flashes");
01513   gMeanErrorNormVsFlashes->SetMarkerStyle(3);
01514   gMeanErrorNormVsFlashes->SetMarkerColor(2);
01515   gMeanErrorNormVsFlashes->SetMarkerSize(0.2);
01516   cGainMean->cd(1);
01517   gMeanErrorNormVsFlashes->Draw("AP");
01518   gMeanErrorNormVsFlashes->GetXaxis()->SetTitle("Number of Flashes");
01519   gMeanErrorNormVsFlashes->GetYaxis()->SetTitle
01520     ("Fractional Error on Mean");
01521   gMeanErrorNormVsFlashes->GetXaxis()->CenterTitle();
01522   gMeanErrorNormVsFlashes->GetYaxis()->CenterTitle();
01523   gMeanErrorNormVsFlashes->SetMinimum(0);
01524 
01525   //create graph
01526   TGraph *gMeanErrorVsFlashes=new TGraph(kNumPoints,
01527                                          numFlashes,errorOnMean);
01528   gMeanErrorVsFlashes->SetTitle("Error on Mean Vs Flashes");
01529   gMeanErrorVsFlashes->SetMarkerStyle(3);
01530   gMeanErrorVsFlashes->SetMarkerColor(2);
01531   gMeanErrorVsFlashes->SetMarkerSize(0.2);
01532   cGainMean->cd(2);
01533   gMeanErrorVsFlashes->Draw("AP");
01534   gMeanErrorVsFlashes->GetXaxis()->SetTitle("Number of Flashes");
01535   gMeanErrorVsFlashes->GetYaxis()->SetTitle("Error on Mean");
01536   gMeanErrorVsFlashes->GetXaxis()->CenterTitle();
01537   gMeanErrorVsFlashes->GetYaxis()->CenterTitle();
01538 
01540   //plot the errors on the rms
01542   //create canvas
01543   TCanvas *cRmsErr=new TCanvas("cRmsErr","cRmsErr",1,1,1000,800);
01544   cRmsErr->SetFillColor(0);
01545   cRmsErr->Divide(1,2);
01546   
01547   //create graph
01548   TGraph *gRmsErrorNormVsFlashes=new TGraph(kNumPoints,
01549                                              numFlashes,errorOnRmsN);
01550   gRmsErrorNormVsFlashes->SetTitle
01551     ("Fractional Error on Rms Vs Flashes");
01552   gRmsErrorNormVsFlashes->SetMarkerStyle(3);
01553   gRmsErrorNormVsFlashes->SetMarkerColor(2);
01554   gRmsErrorNormVsFlashes->SetMarkerSize(0.2);
01555   cRmsErr->cd(1);
01556   gRmsErrorNormVsFlashes->Draw("AP");
01557   gRmsErrorNormVsFlashes->GetXaxis()->SetTitle("Number of Flashes");
01558   gRmsErrorNormVsFlashes->GetYaxis()->SetTitle
01559     ("Fractional Error on Rms");
01560   gRmsErrorNormVsFlashes->GetXaxis()->CenterTitle();
01561   gRmsErrorNormVsFlashes->GetYaxis()->CenterTitle();
01562   gRmsErrorNormVsFlashes->SetMinimum(0);
01563 
01564   //create graph
01565   TGraph *gRmsErrorVsFlashes=new TGraph(kNumPoints,
01566                                          numFlashes,errorOnRms);
01567   gRmsErrorVsFlashes->SetTitle("Error on Rms Vs Flashes");
01568   gRmsErrorVsFlashes->SetMarkerStyle(3);
01569   gRmsErrorVsFlashes->SetMarkerColor(2);
01570   gRmsErrorVsFlashes->SetMarkerSize(0.2);
01571   cRmsErr->cd(2);
01572   gRmsErrorVsFlashes->Draw("AP");
01573   gRmsErrorVsFlashes->GetXaxis()->SetTitle("Number of Flashes");
01574   gRmsErrorVsFlashes->GetYaxis()->SetTitle("Error on Rms");
01575   gRmsErrorVsFlashes->GetXaxis()->CenterTitle();
01576   gRmsErrorVsFlashes->GetYaxis()->CenterTitle();
01577 
01578   /*
01579   // get a random energy value between 0-40 GeV
01580   enNeutrino=(Float_t)(gRandom->Rndm())*39.99;
01581   enNeutrinoBin=(Int_t)(enNeutrino*5.+1.);
01582   enNeutrinoProb=leevents[enNeutrinoBin]; 
01583 
01584       if ((Float_t)(gRandom->Rndm())<=enNeutrinoProb){
01585 
01586         // get a random y value between 0-1 
01587         yValue=(Float_t)(gRandom->Rndm())*0.99999999;
01588         
01589         // determine the energy range  
01590         yEnergyRange=(Int_t)(enNeutrino/5.);
01591         if (yEnergyRange>5) {yEnergyRange=5;}
01592         
01593         // select y value prob from suitable y 
01594         //distribution given the energy range
01595         yValueProb=ydist[yEnergyRange*10+(Int_t)(yValue*10.)];
01596         
01597         if ((Float_t)(gRandom->Rndm())<=yValueProb){
01598           eventSelectedFlag=1;
01599           neutrinoEnergy[i]=enNeutrino;
01600           
01601           neutrinoEn=enNeutrino;
01602           if (neutrinoEn>29.9999999){neutrinoEn=29.999999;}
01603 
01604           muEffProb[i]=mueff[((Int_t)(yValue*10.)*30)+
01605                             (Int_t)(neutrinoEn)];
01606           ncEffProb[i]=nceff[((Int_t)(yValue*10.)*30)+
01607                             (Int_t)(neutrinoEn)];
01608           
01609           eHadSmeared[i]=(yValue*enNeutrino)*
01610             (1.+0.55*(gRandom->Gaus(0.,1.))/
01611              sqrt(yValue*enNeutrino));
01612           if (eHadSmeared[i]<0.) {(eHadSmeared[i]=0.);}
01613         
01614           eMuSmeared=((1-yValue)*enNeutrino)*
01615             (1+0.11*(gRandom->Gaus(0.,1.)));
01616           reconEnergy[i]=eHadSmeared[i]+eMuSmeared;
01617           //Double_t Gaus(Double_t mean, Double_t sigma) 
01618         } //end of if 
01619       } //end of if
01620     } //end of while
01621   } //end of for
01622   */
01623 
01624   MSG("LIPlexMaps",Msg::kInfo)
01625     <<" ** Finished the PeGen method ** "<<endl;
01626 }

void LIPlexMaps::PlotPlexPinMap (  ) 

Definition at line 1784 of file LIPlexMaps.cxx.

References Msg::kInfo, and MSG.

01785 {
01786   MSG("LIAnalysis",Msg::kInfo) 
01787     <<"Running PlotPlexPinMap method..."<<endl;
01788 
01789   //commented out whole method to prevent array warnings!!!
01790   //should use an object or something instead, no time at the mo
01791 
01792   /*    
01793   //set validity context to todays date and far detector and real data
01794   VldTimeStamp timeStamp(2002,10,1,1,1,1,1,0,0);
01795   VldContext validityContext(Detector::kFar,SimFlag::kData,
01796                              timeStamp);
01797 
01798   MSG("LIAnalysis",Msg::kInfo) 
01799     <<"Using validity context: "<<validityContext.AsString()<<endl;
01800 
01801   PlexHandle *myplexhandle= new PlexHandle(validityContext);   
01802 
01803   Float_t numMux=8.;
01804   Float_t numRacks=16.;
01805   const Int_t const_numCrates=static_cast<Int_t>(numRacks/2.);
01806 
01807   const Int_t const_numEastWest=2;
01808   const Int_t const_numRackLevels=2;
01809   const Int_t const_numRacks=static_cast<Int_t>(numRacks);
01810   const Int_t const_numMux=static_cast<Int_t>(numMux);
01811   const Int_t const_numPins=2;
01812   const Int_t const_numGains=2;
01813 
01814   //declare arrays
01815   Int_t pinPulserBox[const_numEastWest][const_numRackLevels]
01816     [const_numRacks][const_numMux][const_numPins][const_numGains];
01817 
01818   Int_t pinLed[const_numEastWest][const_numRackLevels]
01819     [const_numRacks][const_numMux][const_numPins][const_numGains];
01820 
01821   Int_t pinNumEntries[const_numEastWest][const_numRackLevels]
01822     [const_numRacks][const_numMux][const_numPins][const_numGains];
01823 
01824   Int_t pinVaChip[const_numEastWest][const_numRackLevels]
01825     [const_numRacks][const_numMux][const_numPins][const_numGains];
01826 
01827   //initialise arrays
01828   for (Int_t i=0; i<const_numEastWest; i++){
01829     for (Int_t j=0; j<const_numRackLevels; j++){
01830       for (Int_t k=0; k<const_numRacks;k++){
01831         for (Int_t l=0; l<const_numMux;l++){
01832           for (Int_t m=0; m<const_numPins;m++){
01833             for (Int_t n=0; n<const_numGains;n++){
01834               pinPulserBox[i][j][k][l][m][n]=-1;
01835               pinLed[i][j][k][l][m][n]=-1;
01836               pinNumEntries[i][j][k][l][m][n]=0;
01837               pinVaChip[i][j][k][l][m][n]=-1;
01838             }
01839           }
01840         }
01841       }
01842     }
01843   }
01844   
01845   //variables 
01846   Char_t eastWest='!'; //E=0 and W=1
01847   Char_t rackLevel='!';//L=0 and U=1
01848   UInt_t rackBay=0; 
01849   UInt_t inRack=0;
01850   UInt_t inBox=0;
01851   UInt_t gain=0;
01852 
01853   //loop over every possible combination of variables
01854   for (Int_t iEastWest=0;iEastWest<const_numEastWest;iEastWest++){
01855     //convert integers into characters
01856     //E=0 and W=1
01857     if (iEastWest==0){
01858       eastWest='E';
01859     }
01860     else if (iEastWest==1){
01861       eastWest='W';
01862     }
01863     
01864     for (Int_t iRackLevel=0;iRackLevel<const_numRackLevels;
01865          iRackLevel++){
01866       //convert integers into characters
01867       //L=0 and U=1
01868       if (iRackLevel==1){
01869         rackLevel='U';
01870       }
01871       else if (iRackLevel==0){
01872         rackLevel='L';
01873       }
01874       
01875       for (rackBay=0;rackBay<static_cast<UInt_t>(const_numRacks);
01876            rackBay++){
01877         for (inRack=0;inRack<static_cast<UInt_t>(const_numMux);
01878              inRack++){
01879           for (inBox=0;inBox<static_cast<UInt_t>(const_numPins);
01880                inBox++){
01881             for (gain=0;gain<static_cast<UInt_t>(const_numPins);gain++){
01882             
01883               //create a pindiodeId according to 
01884               //loop iteration variables
01885               const PlexPinDiodeId *plexPinId =new PlexPinDiodeId
01886                 (Detector::kFar,ElecType::kVA,eastWest,rackLevel,
01887                  rackBay+1,inRack,inBox,gain); 
01888               
01889               //check if pindiodeid is valid
01890               //if not then print to screen and go to next iteration
01891               if (plexPinId->IsValid()){
01892                 
01893                 PlexLedId plexLedId=myplexhandle->GetLedId(*plexPinId);
01894                 
01895                 RawChannelId plexRawChId=myplexhandle->
01896                   GetRawChannelId(*plexPinId);
01897                 
01898                 //get va chip associated with rawchannel
01899                 pinVaChip[iEastWest][iRackLevel][rackBay][inRack]
01900                   [inBox][gain]=plexRawChId.GetVaChip();
01901 
01902                 //only set array values is ledid is valid
01903                 //else leave initial values, e.g. led=-1
01904                 if (plexLedId.IsValid()){
01905                   //get LED info
01906                   Int_t plexLedInBox=plexLedId.GetLedInBox();
01907                   Int_t plexPulserBox=plexLedId.GetPulserBox();
01908                   
01909                   pinLed[iEastWest][iRackLevel][rackBay][inRack]
01910                     [inBox][gain]=plexLedInBox;
01911 
01912                   pinPulserBox[iEastWest][iRackLevel][rackBay][inRack]
01913                     [inBox][gain]=plexPulserBox;
01914 
01915                   pinNumEntries[iEastWest][iRackLevel][rackBay][inRack]
01916                     [inBox][gain]++;
01917 
01918                   MSG("LIAnalysis",Msg::kVerbose) 
01919                     <<"plexLedInBox="<<plexLedInBox
01920                     <<", plexPulserBox="<<plexPulserBox
01921                     <<endl;
01922                   MSG("LIAnalysis",Msg::kVerbose) 
01923                     <<"plexLedId="<<plexLedId.AsString() 
01924                     <<endl;
01925                 }
01926                 else{
01927                   MSG("LIAnalysis",Msg::kVerbose) 
01928                     <<"ledId not valid:"
01929                     <<" plexLedId="<<plexLedId.AsString() 
01930                     <<endl
01931                     <<"plexPinId="<<plexPinId->AsString() 
01932                     <<endl;
01933                 }
01934               }
01935               else{
01936                 MSG("LIAnalysis",Msg::kVerbose) 
01937                   <<"pinId not valid:"
01938                   <<" plexPinId="<<plexPinId->AsString()<<endl;
01939               }
01940               delete plexPinId;
01941             }//end of for
01942           }//end of for
01943         }//end of for
01944       }//end of for
01945     }//end of for
01946   }//end of for
01947 
01948   TCanvas *cEast=new TCanvas("cEast","cEast",0,0,1200,800);
01949   cEast->SetFillColor(0);
01950 
01951   TCanvas *cWest=new TCanvas("cWest","cWest",0,0,1200,800);
01952   cWest->SetFillColor(0);
01953   cWest->cd();
01954 
01955   TText *titleE = new TText(0.28,0.955,
01956                             "Plex PIN Diode Map (East Side)");
01957   titleE->SetTextSize(0.045);
01958   TText *titleW = new TText(0.28,0.955,
01959                             "Plex PIN Diode Map (West Side)");
01960   titleW->SetTextSize(0.045);
01961   cEast->cd();
01962   titleE->Draw();
01963   cWest->cd();
01964   titleW->Draw();
01965 
01966   TPaveText *info=new TPaveText(0.75,0.94,1.0,1.0);
01967   info->SetBorderSize(0);
01968   info->SetFillColor(0);
01969   info->SetTextSize(0.018);
01970   info->SetTextColor(4);
01971   info->AddText("Numbers in mux boxes are LED numbers"); 
01972   info->AddText("Dark colour number is high gain pin");
01973   info->AddText("Mux box shading indicates Pulser Box"); 
01974   cEast->cd();
01975   info->Draw();
01976   cWest->cd();
01977   info->Draw();
01978   
01979   TPad *levelUE= new TPad("levelUE","pad for mux boxes",
01980                           0.01,0.59,0.99,0.94);
01981   TPad *levelME= new TPad("levelME","pad for crates",
01982                           0.01,0.39,0.99,0.56);
01983   TPad *levelLE= new TPad("levelLE","pad for mux boxes",
01984                           0.01,0.01,0.99,0.36);
01985   TPad *levelUW= new TPad("levelUW","pad for mux boxes",
01986                           0.01,0.59,0.99,0.94);
01987   TPad *levelMW= new TPad("levelMW","pad for crates",
01988                           0.01,0.39,0.99,0.56);
01989   TPad *levelLW= new TPad("levelLW","pad for mux boxes",
01990                           0.01,0.01,0.99,0.36);
01991 
01992   levelUE->SetFillColor(11);
01993   levelUE->SetBorderSize(3);
01994   levelUW->SetFillColor(11);
01995   levelUW->SetBorderSize(3);
01996 
01997   levelME->SetFillColor(11);
01998   levelME->SetBorderSize(2);
01999   levelMW->SetFillColor(11);
02000   levelMW->SetBorderSize(2);
02001 
02002   levelLE->SetFillColor(11);
02003   levelLE->SetBorderSize(1);
02004   levelLE->SetBorderMode(0);
02005   levelLW->SetFillColor(11);
02006   levelLW->SetBorderSize(1);
02007   levelLW->SetBorderMode(0);
02008 
02009   cEast->cd();
02010   levelUE->Draw();
02011   levelME->Draw();
02012   levelLE->Draw();
02013   cWest->cd();
02014   levelUW->Draw();
02015   levelMW->Draw();
02016   levelLW->Draw();
02017 
02018   
02019   TText *tLevelUE = new TText(0.01,0.89,
02020                               "Mux Box Racks (East Side, Upper Level)");
02021   TText *tLevelUW = new TText(0.01,0.89,
02022                               "Mux Box Racks (West Side, Upper Level)");
02023   TText *tLevelME = new TText
02024     (0.01,0.89,"Electronics Crates (East Side, Middle Level)");
02025   TText *tLevelMW = new TText
02026     (0.01,0.89,"Electronics Crates (West Side, Middle Level)");
02027   TText *tLevelLE = new TText(0.01,0.89,
02028                               "Mux Box Racks (East Side, Lower Level)");
02029   TText *tLevelLW = new TText(0.01,0.89,
02030                               "Mux Box Racks (West Side, Lower Level)");
02031 
02032   tLevelUE->SetTextSize(0.1);
02033   tLevelUW->SetTextSize(0.1);
02034   tLevelME->SetTextSize(0.08);
02035   tLevelMW->SetTextSize(0.08);
02036   tLevelLE->SetTextSize(0.1);
02037   tLevelLW->SetTextSize(0.1);
02038 
02039   levelUE->cd();
02040   tLevelUE->Draw();
02041   levelUW->cd();
02042   tLevelUW->Draw();
02043 
02044   levelME->cd();
02045   tLevelME->Draw();
02046   levelMW->cd();
02047   tLevelMW->Draw();
02048   
02049   levelLE->cd();
02050   tLevelLE->Draw();
02051   levelLW->cd();
02052   tLevelLW->Draw();
02053   
02054   Float_t rackSpace=0.07/(numRacks+1.);
02055   Float_t crateSpace=3.0*rackSpace;
02056   Float_t rackWidth=(1.-((numRacks/2)+2)*rackSpace-
02057                      ((numRacks/2)-1)*crateSpace)/numRacks;
02058   Float_t xMin=-1.;
02059   MSG("LIAnalysis",Msg::kDebug) 
02060     <<"rackSpace="<<rackSpace<<", crateSpace="<<crateSpace
02061     <<", rackWidth="<<rackWidth<<endl;
02062 
02063   TPad **rackUE=0;
02064   TPad **rackUW=0;
02065   TPad **rackLE=0;
02066   TPad **rackLW=0;
02067   
02068   rackUE=new TPad*[const_numRacks];
02069   rackUW=new TPad*[const_numRacks];
02070   rackLE=new TPad*[const_numRacks];
02071   rackLW=new TPad*[const_numRacks];
02072 
02073   for (Int_t rack=0;rack<const_numRacks;rack++){
02074     Float_t crate=floor(static_cast<Float_t>(rack)/2.);
02075     
02076     xMin=rackSpace
02077       +floor((static_cast<Float_t>(rack)+1)/2)*rackSpace
02078       +crate*crateSpace
02079       +static_cast<Float_t>(rack)*rackWidth;
02080     
02081     rackUE[rack]= new TPad("rackUE","Upper East Racks",
02082                            xMin,0.,xMin+rackWidth,0.87,17,3);
02083     rackUW[rack]= new TPad("rackUW","Upper West Racks",
02084                            xMin,0.,xMin+rackWidth,0.87,17,3);
02085     rackLE[rack]= new TPad("rackLE","Lower East Racks",
02086                            xMin,0.,xMin+rackWidth,0.87,17,3);
02087     rackLW[rack]= new TPad("rackLW","Lower West Racks",
02088                            xMin,0.,xMin+rackWidth,0.87,17,3);
02089 
02090 
02091     rackUE[rack]->SetFillColor(5);
02092     rackUW[rack]->SetFillColor(5);
02093     rackLE[rack]->SetFillColor(5);
02094     rackLW[rack]->SetFillColor(5);
02095 
02096     rackUE[rack]->SetBorderSize(0);
02097     rackUW[rack]->SetBorderSize(0);
02098     rackLE[rack]->SetBorderSize(0);
02099     rackLW[rack]->SetBorderSize(0);
02100 
02101     rackUE[rack]->SetBorderMode(0);
02102     rackUW[rack]->SetBorderMode(0);
02103     rackLE[rack]->SetBorderMode(0);
02104     rackLW[rack]->SetBorderMode(0);
02105 
02106     levelUE->cd();
02107     rackUE[rack]->Draw();
02108     levelUW->cd();
02109     rackUW[rack]->Draw();
02110     levelLE->cd();
02111     rackLE[rack]->Draw();
02112     levelLW->cd();
02113     rackLW[rack]->Draw();
02114   }
02115   
02116   //create mux boxes and draw
02117   TPaveText **muxBoxBg=0;
02118   muxBoxBg=new TPaveText*[const_numRacks];
02119 
02120   for (Int_t rack=0;rack<const_numRacks;rack++){
02121     
02122     muxBoxBg[rack]=new TPaveText(0.06,0.01,0.94,0.97);
02123     muxBoxBg[rack]->SetBorderSize(0);
02124     muxBoxBg[rack]->SetFillColor(0);
02125 
02126     rackUE[rack]->cd();
02127     muxBoxBg[rack]->Draw();
02128     rackUW[rack]->cd();
02129     muxBoxBg[rack]->Draw();
02130     rackLE[rack]->cd();
02131     muxBoxBg[rack]->Draw();
02132     rackLW[rack]->cd(); 
02133     muxBoxBg[rack]->Draw();
02134   }
02135 
02136   //create mux boxes labels
02137   TPaveText ***muxTextUE=0;
02138   muxTextUE=new TPaveText**[const_numRacks];
02139   TPaveText ***muxTextUW=0;
02140   muxTextUW=new TPaveText**[const_numRacks];
02141   TPaveText ***muxTextLE=0;
02142   muxTextLE=new TPaveText**[const_numRacks];
02143   TPaveText ***muxTextLW=0;
02144   muxTextLW=new TPaveText**[const_numRacks];
02145   for (Int_t rack=0;rack<const_numRacks;rack++){
02146     muxTextUE[rack]=new TPaveText*[2*const_numMux]; 
02147     muxTextUW[rack]=new TPaveText*[2*const_numMux]; 
02148     muxTextLE[rack]=new TPaveText*[2*const_numMux]; 
02149     muxTextLW[rack]=new TPaveText*[2*const_numMux];
02150  
02151     for (Int_t pin=0;pin<2*const_numMux;pin++){
02152       (muxTextUE[rack])[pin]=new TPaveText
02153         (0.09,
02154          0.015+static_cast<Int_t>(pin)*0.06,
02155          0.93,
02156          0.015+static_cast<Int_t>(pin+1)*0.06-0.010*(pin%2));
02157       (muxTextUW[rack])[pin]=new TPaveText
02158         (0.09,
02159          0.015+static_cast<Int_t>(pin)*0.06,
02160          0.93,
02161          0.015+static_cast<Int_t>(pin+1)*0.06-0.010*(pin%2));
02162       (muxTextLE[rack])[pin]=new TPaveText
02163         (0.09,
02164          0.015+static_cast<Int_t>(pin)*0.06,
02165          0.93,
02166          0.015+static_cast<Int_t>(pin+1)*0.06-0.010*(pin%2));
02167       (muxTextLW[rack])[pin]=new TPaveText
02168         (0.09,
02169          0.015+static_cast<Int_t>(pin)*0.06,
02170          0.93,
02171          0.015+static_cast<Int_t>(pin+1)*0.06-0.010*(pin%2));
02172       (muxTextUE[rack])[pin]->SetBorderSize(0);
02173       (muxTextUW[rack])[pin]->SetBorderSize(0);
02174       (muxTextLE[rack])[pin]->SetBorderSize(0);
02175       (muxTextLW[rack])[pin]->SetBorderSize(0);
02176 
02177       (muxTextUE[rack])[pin]->SetTextSize(0.2);
02178       (muxTextUW[rack])[pin]->SetTextSize(0.2);
02179       (muxTextLE[rack])[pin]->SetTextSize(0.2);
02180       (muxTextLW[rack])[pin]->SetTextSize(0.2);
02181 
02182       (muxTextUE[rack])[pin]->SetTextColor(5);
02183       (muxTextUW[rack])[pin]->SetTextColor(5);
02184       (muxTextLE[rack])[pin]->SetTextColor(5);
02185       (muxTextLW[rack])[pin]->SetTextColor(5);
02186 
02187       (muxTextUE[rack])[pin]->SetTextFont(2);
02188       (muxTextUW[rack])[pin]->SetTextFont(2);
02189       (muxTextLE[rack])[pin]->SetTextFont(2);
02190       (muxTextLW[rack])[pin]->SetTextFont(2);
02191 
02192       (muxTextUE[rack])[pin]->SetFillColor(20);//18
02193       (muxTextUW[rack])[pin]->SetFillColor(20);//18
02194       (muxTextLE[rack])[pin]->SetFillColor(20);//18
02195       (muxTextLW[rack])[pin]->SetFillColor(20);//18
02196     }
02197   }
02198  
02199   MSG("LIAnalysis",Msg::kInfo) 
02200     <<"Filling and drawing mux box labels..."<<endl;
02201   //fill and draw mux box labels
02202   for (Int_t iEastWest=0;iEastWest<const_numEastWest;iEastWest++){
02203     for (Int_t iRackLevel=0;iRackLevel<const_numRackLevels;
02204          iRackLevel++){
02205       for (rackBay=0;rackBay<static_cast<UInt_t>(const_numRacks);
02206            rackBay++){
02207         
02208         //draw in the correct rack bay
02209         if (iRackLevel==0){
02210           if (iEastWest==0){
02211             rackLE[rackBay]->cd();
02212             MSG("LIAnalysis",Msg::kInfo)<<"Lower East:"<<endl;
02213           }
02214           else if (iEastWest==1){
02215             rackLW[const_numRacks-1-rackBay]->cd();
02216             MSG("LIAnalysis",Msg::kInfo)<<"Lower West:"<<endl;
02217           }
02218         }
02219         else if (iRackLevel==1){
02220           if (iEastWest==0){
02221             rackUE[rackBay]->cd();
02222             MSG("LIAnalysis",Msg::kInfo)<<"Upper East:"<<endl;
02223           }
02224           else if (iEastWest==1){
02225             rackUW[const_numRacks-1-rackBay]->cd();
02226             MSG("LIAnalysis",Msg::kInfo)<<"Upper West:"<<endl;
02227           }
02228         }
02229         for (inRack=0;inRack<static_cast<UInt_t>(const_numMux);
02230              inRack++){
02231           for (inBox=0;inBox<static_cast<UInt_t>(const_numPins);
02232                inBox++){
02233             for (gain=0;gain<static_cast<UInt_t>(const_numPins);gain++){
02234 
02235               //The vfbs are flipped on the east side relative
02236               //to the west side, thus whether pin 1 is plotted
02237               //nearest the floor or the ceiling must change
02238               //depending on the side
02239               Int_t pin=-1;
02240               //On the east side pin 1 is nearest floor and pin one
02241               //nearest ceiling
02242               if (iEastWest==0){//East
02243                 //pins ordered ordered: 1,0, 3,2, 5,4, 7,6 etc
02244                 if (inBox==0){
02245                   pin=2*inRack+1;
02246                 }
02247                 else if (inBox==1){
02248                   pin=2*inRack+0;
02249                 }
02250               }
02251               //On the west side pin 1 is nearest ceiling and pin one
02252               //nearest floor
02253               else if (iEastWest==1){//West
02254                 pin=2*inRack+inBox;//0-15 from bottom to top
02255               }
02256 
02257               MSG("LIAnalysis",Msg::kInfo)
02258                 <<"E/W="<<iEastWest
02259                 <<", U/L="<<iRackLevel
02260                 <<", rack="<<rackBay
02261                 <<", mux="<<inRack
02262                 <<", inBox="<<inBox
02263                 <<", gain="<<gain
02264                 <<", pin="<<pin
02265                 <<", pb=" 
02266                 <<pinPulserBox[iEastWest][iRackLevel][rackBay]
02267                 [inRack][inBox][gain]
02268                 <<", led=" 
02269                 <<pinLed[iEastWest][iRackLevel][rackBay][inRack]
02270                 [inBox][gain]
02271                 <<", va=" 
02272                 <<pinVaChip[iEastWest][iRackLevel][rackBay][inRack]
02273                 [inBox][gain]
02274                 <<endl;
02275               
02276               //check if led illuminates pin
02277               if (pinNumEntries[iEastWest][iRackLevel][rackBay][inRack]
02278                   [inBox][gain]==1){
02279 
02280                 string s = Form("%d",pinLed[iEastWest][iRackLevel][rackBay][inRack][inBox][gain]);
02281 
02282                 if (iEastWest==0){//East
02283                   if (iRackLevel==1){
02284                     //label mux box according to led number
02285                     (muxTextUE[rackBay])[pin]->AddText
02286                       (0.5,0.5,s.c_str());
02287                     //set fill colour according to pulser box number
02288                     (muxTextUE[rackBay])[pin]->SetFillColor
02289                       (19-pinPulserBox[iEastWest][iRackLevel][rackBay]
02290                        [inRack][inBox][gain]/2);
02291 
02292                     if (gain==0){//low gain
02293                       (muxTextUE[rackBay])[pin]->SetTextColor(7);
02294                       //7=aqua
02295                     }
02296                     else if (gain==1){//high gain
02297                       (muxTextUE[rackBay])[pin]->SetTextColor(4);
02298                       //4=bright blue
02299                     }
02300                   }
02301                   else if (iRackLevel==0){
02302                     //label mux box according to led number
02303                     (muxTextLE[rackBay])[pin]->AddText
02304                       (0.5,0.5,s.c_str()); 
02305                     //set fill colour according to pulser box number
02306                     (muxTextLE[rackBay])[pin]->SetFillColor
02307                       (19-pinPulserBox[iEastWest][iRackLevel][rackBay]
02308                        [inRack][inBox][gain]/2);
02309 
02310                     if (gain==0){//low gain
02311                       (muxTextLE[rackBay])[pin]->SetTextColor(7);
02312                       //7=aqua
02313                     }
02314                     else if (gain==1){//high gain
02315                       (muxTextLE[rackBay])[pin]->SetTextColor(4);
02316                       //4=bright blue
02317                     }
02318                   }
02319                 }                 
02320                 else if (iEastWest==1){//West
02321                   if (iRackLevel==1){
02322                     //label mux box according to led number
02323                     (muxTextUW[rackBay])[pin]->AddText
02324                       (0.5,0.5,s.c_str()); 
02325                     //set fill colour according to pulser box number
02326                     (muxTextUW[rackBay])[pin]->
02327                       SetFillColor
02328                       (19-pinPulserBox[iEastWest][iRackLevel][rackBay]
02329                        [inRack][inBox][gain]/2);
02330 
02331                     if (gain==0){//low gain
02332                       (muxTextUW[rackBay])[pin]->
02333                         SetTextColor(7);
02334                       //7=aqua
02335                     }
02336                     else if (gain==1){//high gain
02337                       (muxTextUW[rackBay])[pin]->
02338                         SetTextColor(4);
02339                       //4=bright blue
02340                     }
02341                   }
02342                   else if (iRackLevel==0){  
02343                     //label mux box according to led number
02344                     (muxTextLW[rackBay])[pin]->
02345                       AddText
02346                       (0.5,0.5,s.c_str()); 
02347                     //set fill colour according to pulser box number
02348                     (muxTextLW[rackBay])[pin]->
02349                       SetFillColor
02350                       (19-pinPulserBox[iEastWest][iRackLevel][rackBay]
02351                        [inRack][inBox][gain]/2);
02352 
02353                     if (gain==0){//low gain
02354                       (muxTextLW[rackBay])[pin]->
02355                         SetTextColor(7);
02356                       //7=aqua
02357                     }
02358                     else if (gain==1){//high gain
02359                       (muxTextLW[rackBay])[pin]->
02360                         SetTextColor(4);
02361                       //4=bright blue
02362                     }
02363                   }
02364                 }
02365               }
02366               //there should be zero entries if the pin socket is empty
02367               else if(pinNumEntries[iEastWest][iRackLevel][rackBay]
02368                       [inRack][inBox][gain]==0){
02369                 if (gain==0){
02370                   //check if there is an led on the high gain [1] pin
02371                   //because you don't want to write in the same
02372                   //box twice
02373                   if (pinNumEntries[iEastWest][iRackLevel][rackBay]
02374                       [inRack][inBox][1]==0){               
02375                     //there was no led on either h or l pin so:
02376                     if (iEastWest==0){
02377                       if (iRackLevel==1){
02378                         (muxTextUE[rackBay])[pin]->AddText
02379                           (0.5,0.5,"NO LED"); 
02380                       }
02381                       else if (iRackLevel==0){
02382                         (muxTextLE[rackBay])[pin]->AddText
02383                           (0.5,0.5,"NO LED"); 
02384                       }
02385                     }
02386                     else if (iEastWest==1){
02387                       if (iRackLevel==1){
02388                         (muxTextUW[rackBay])[pin]->
02389                           AddText(0.5,0.5,"NO LED"); 
02390                       }
02391                       else if (iRackLevel==0){
02392                         (muxTextLW[rackBay])[pin]->
02393                           AddText(0.5,0.5,"NO LED"); 
02394                       }
02395                     }
02396                   }
02397                 }
02398                 else {//gain==1
02399                   //this will have already been set, if required, 
02400                   //because you get to the gain==0 pin first
02401                 }
02402               }
02403               else{
02404                 if (iEastWest==0){
02405                   if (iRackLevel==1){
02406                     (muxTextUE[rackBay])[pin]->AddText
02407                       (0.5,0.5,"Error!"); 
02408                   }
02409                   else if (iRackLevel==0){
02410                     (muxTextLE[rackBay])[pin]->AddText
02411                       (0.5,0.5,"Error!"); 
02412                   }
02413                 }
02414                 else if (iEastWest==1){
02415                   if (iRackLevel==1){
02416                     (muxTextUW[rackBay])[pin]->AddText
02417                       (0.5,0.5,"Error!"); 
02418                   }
02419                   else if (iRackLevel==0){
02420                     (muxTextLW[rackBay])[pin]->AddText
02421                       (0.5,0.5,"Error!"); 
02422                   }
02423                 }               
02424                 MSG("LIAnalysis",Msg::kWarning) 
02425                   <<"Warning: numEntries=" 
02426                   <<pinNumEntries[iEastWest][iRackLevel][rackBay]
02427                   [inRack][inBox][gain]
02428                   <<" for rackBay="<<rackBay<<", pin="<<pin
02429                   <<endl;
02430               }
02431 
02432               //determine which set of mux boxes need drawing         
02433               if (iEastWest==0){
02434                 if (iRackLevel==1){
02435                   (muxTextUE[rackBay])[pin]->Draw();
02436                 }
02437                 else if (iRackLevel==0){
02438                   (muxTextLE[rackBay])[pin]->Draw();
02439                 }
02440               }
02441               else if (iEastWest==1){
02442                 if (iRackLevel==1){
02443                   (muxTextUW[rackBay])[pin]->Draw();
02444                 }
02445                 else if (iRackLevel==0){
02446                   (muxTextLW[rackBay])[pin]->Draw();
02447                 }
02448               }
02449             }
02450           }
02451         }
02452       }
02453     }
02454   }
02455   MSG("LIAnalysis",Msg::kInfo)<<"... OK"<<endl;
02456   
02457   //draw crates
02458   MSG("LIAnalysis",Msg::kInfo)<<"Drawing crates..."<<endl;
02459   TPad **cratesE=0;
02460   cratesE=new TPad*[const_numCrates];
02461   TPad **cratesW=0;
02462   cratesW=new TPad*[const_numCrates];
02463   
02464   TPaveText **crateLabelE=0;
02465   crateLabelE=new TPaveText*[const_numCrates];
02466   TPaveText **crateLabelW=0;
02467   crateLabelW=new TPaveText*[const_numCrates];
02468 
02469   //calculate space between crates
02470   crateSpace=(1
02471               -(numRacks/2)*rackWidth
02472               -2*(1.5*rackSpace+(rackWidth/2))
02473               )/((numRacks/2)-1);
02474 
02475   //loop over crates
02476   for (Int_t cra=0;cra<static_cast<Int_t>(numRacks/2);cra++){
02477 
02478     xMin=1.5*rackSpace+(rackWidth/2)
02479       +static_cast<Float_t>(cra)*crateSpace
02480       +static_cast<Float_t>(cra)*rackWidth;
02481 
02482     cratesE[cra]=new TPad("crates","Crates",
02483                           xMin,0.,xMin+rackWidth,0.85,17,3);
02484     cratesE[cra]->SetFillColor(5);
02485     cratesE[cra]->SetBorderSize(0);
02486     cratesE[cra]->SetBorderMode(0);
02487     levelME->cd();
02488     cratesE[cra]->Draw();
02489 
02490     cratesW[cra]=new TPad("crates","Crates",
02491                           xMin,0.,xMin+rackWidth,0.85,17,3);
02492     cratesW[cra]->SetFillColor(5);
02493     cratesW[cra]->SetBorderSize(0);
02494     cratesW[cra]->SetBorderMode(0);
02495     levelMW->cd();
02496     cratesW[cra]->Draw();
02497 
02498     crateLabelE[cra]=new TPaveText(0.1,0.01,0.9,0.95);
02499     crateLabelE[cra]->SetBorderSize(0);
02500     crateLabelW[cra]=new TPaveText(0.1,0.01,0.9,0.95);
02501     crateLabelW[cra]->SetBorderSize(0);
02502 
02503     string s=Form("%d",2*cra);
02504     crateLabelE[cra]->AddText(0.5,0.95,"Pulser");
02505     crateLabelE[cra]->AddText(0.5,0.8,"Box");
02506     crateLabelE[cra]->AddText(0.5,0.65,s.c_str());
02507     crateLabelE[cra]->SetTextSize(0.25);
02508     //set fill colour according to pulser box number
02509     crateLabelE[cra]->SetFillColor(19-cra);
02510     //crateLabelE[cra]->SetFillStyle(3008-cra);
02511     cratesE[cra]->cd();
02512     crateLabelE[cra]->Draw();
02513 
02514     string sW=Form("%d",15-(2*cra));
02515     crateLabelW[cra]->AddText(0.5,0.95,"Pulser");
02516     crateLabelW[cra]->AddText(0.5,0.8,"Box");
02517     crateLabelW[cra]->AddText(0.5,0.65,sW.c_str());
02518     crateLabelW[cra]->SetTextSize(0.25);
02519     //set fill colour according to pulser box number
02520     crateLabelW[cra]->SetFillColor(12+cra);
02521     //crateLabelE[cra]->SetFillStyle(3001+cra);
02522     cratesW[cra]->cd();
02523     crateLabelW[cra]->Draw();
02524   }
02525   MSG("LIAnalysis",Msg::kInfo)<<"... OK"<<endl;
02526 
02527   delete myplexhandle;
02528 */
02529   MSG("LIAnalysis",Msg::kInfo) 
02530     <<"PlotPlexPinMap method finished"<<endl;
02531 }

void LIPlexMaps::PlotPlexStripMap ( Int_t  detectorType  ) 

Definition at line 2757 of file LIPlexMaps.cxx.

References VldContext::AsString(), draw(), exit(), LILookup::FIRSTSCINTPLANE, LILookup::FIRSTSTRIP, PlexStripEndId::GetEnd(), PlexHandle::GetLedId(), PlexLedId::GetLedInBox(), PlexPixelSpotId::GetPixel(), PlexHandle::GetPixelSpotId(), PlexPlaneId::GetPlane(), PlexPlaneId::GetPlaneView(), PlexLedId::GetPulserBox(), PlexHandle::GetRawChannelId(), PlexPixelSpotId::GetSpot(), PlexStripEndId::GetStrip(), RawChannelId::GetVaAdcSel(), RawChannelId::GetVaChannel(), RawChannelId::GetVaChip(), RawChannelId::GetVarcId(), RawChannelId::GetVmm(), PlexLedId::IsValid(), PlexPixelSpotId::IsValid(), PlexPlaneId::IsValid(), PlexStripEndId::IsValid(), Detector::kCalDet, SimFlag::kData, StripEnd::kEast, Msg::kError, Detector::kFar, Msg::kInfo, Detector::kNear, StripEnd::kUnknown, Msg::kVerbose, StripEnd::kWest, LILookup::LASTSCINTPLANE, LILookup::LASTSTRIP, MSG, LILookup::NUMSIDES, and LILookup::NUMSTRIPS.

02758 {
02759   MSG("LIPlexMaps",Msg::kInfo) 
02760     <<"Running PlotPlexStripMap method..."<<endl;
02761 
02762   Int_t planeMax=-1;
02763   Int_t planeMin=-1;
02764 
02765   planeMin=FIRSTSCINTPLANE-2;
02766   planeMax=LASTSCINTPLANE+5;
02767 
02768   const Int_t firstStripBin=FIRSTSTRIP-8;//-8;
02769   const Int_t lastStripBin=LASTSTRIP+9;//200 for fardet;
02770   const Int_t bins=lastStripBin-firstStripBin;
02771 
02772   //set validity context to todays date and far detector and real data
02773   //VldTimeStamp timeStamp(2002,9,14,1,1,1,1,0,0);
02774   //VldTimeStamp timeStamp(2003,8,17,1,1,1,1,0,0);
02775   VldTimeStamp timeStamp(2001,7,1,1,1,1,1,0,0);
02776   //VldTimeStamp timeStamp;//now
02777 
02778   VldContext* validityContext;
02779 
02780   if (detectorType==Detector::kFar){
02781     validityContext=new VldContext(Detector::kFar,
02782                                    SimFlag::kData,timeStamp);
02783   }
02784   else if (detectorType==Detector::kCalDet){
02785     validityContext=new VldContext(Detector::kCalDet,
02786                                    SimFlag::kData,timeStamp);
02787   }
02788   else if (detectorType==Detector::kNear){
02789     validityContext=new VldContext(Detector::kNear,
02790                                    SimFlag::kData,timeStamp);
02791   }
02792   else{
02793     MSG("LIPlexMaps",Msg::kError)
02794       <<"Detector type not known = "<<detectorType
02795       <<endl<<"Program will exit here!"<<endl;
02796     exit(1);
02797   }
02798 
02799   MSG("LIPlexMaps",Msg::kInfo) 
02800     <<"Using validity context: "<<validityContext->AsString()<<endl;
02801 
02802   PlexHandle *plexhandle=new PlexHandle(*validityContext);   
02803 
02804   TH2F *hStripVsPlaneLed=new TH2F("hStripVsPlaneLed",
02805                                    "Led (StripEnd=kNeg=kEast)",
02806                                    planeMax-planeMin,
02807                                    planeMin,planeMax,
02808                                    bins,firstStripBin,lastStripBin);
02809   hStripVsPlaneLed->GetXaxis()->SetTitle("Plane");
02810   hStripVsPlaneLed->GetXaxis()->CenterTitle();
02811   hStripVsPlaneLed->GetYaxis()->SetTitle("Strip");
02812   hStripVsPlaneLed->GetYaxis()->CenterTitle();
02813   hStripVsPlaneLed->SetFillColor(0);
02814   //hStripVsPlaneLed->SetBit(TH1::kCanRebin);
02815 
02816   TH2F *hStripVsPlanePix=new TH2F("hStripVsPlanePix",
02817                                    "Pixel (StripEnd=kNeg=kEast)",
02818                                    planeMax-planeMin,planeMin,planeMax,
02819                                    bins,firstStripBin,lastStripBin);
02820   hStripVsPlanePix->GetXaxis()->SetTitle("Plane");
02821   hStripVsPlanePix->GetXaxis()->CenterTitle();
02822   hStripVsPlanePix->GetYaxis()->SetTitle("Strip");
02823   hStripVsPlanePix->GetYaxis()->CenterTitle();
02824   hStripVsPlanePix->SetFillColor(0);
02825   hStripVsPlanePix->SetMinimum(-2);
02826   //hStripVsPlanePix->SetBit(TH1::kCanRebin);
02827 
02828   TH2F *hStripVsPlaneCrate=new TH2F("hStripVsPlaneCrate",
02829                                      "Crate (StripEnd=kNeg=kEast)",
02830                                      planeMax-planeMin,planeMin,
02831                                     planeMax,
02832                                      bins,firstStripBin,lastStripBin);
02833   hStripVsPlaneCrate->GetXaxis()->SetTitle("Plane");
02834   hStripVsPlaneCrate->GetXaxis()->CenterTitle();
02835   hStripVsPlaneCrate->GetYaxis()->SetTitle("Strip");
02836   hStripVsPlaneCrate->GetYaxis()->CenterTitle();
02837   hStripVsPlaneCrate->SetFillColor(0);
02838   hStripVsPlaneCrate->SetMinimum(-2);
02839   //hStripVsPlaneCrate->SetBit(TH1::kCanRebin);
02840 
02841   TH2F *hStripVsPlaneVarc=new TH2F("hStripVsPlaneVarc",
02842                                     "Varc (StripEnd=kNeg=kEast)",
02843                                     planeMax-planeMin,planeMin,planeMax,
02844                                     bins,firstStripBin,lastStripBin);
02845   hStripVsPlaneVarc->GetXaxis()->SetTitle("Plane");
02846   hStripVsPlaneVarc->GetXaxis()->CenterTitle();
02847   hStripVsPlaneVarc->GetYaxis()->SetTitle("Strip");
02848   hStripVsPlaneVarc->GetYaxis()->CenterTitle();
02849   hStripVsPlaneVarc->SetFillColor(0);
02850   hStripVsPlaneVarc->SetMinimum(-2);
02851   //hStripVsPlaneVarc->SetBit(TH1::kCanRebin);
02852 
02853   TH2F *hStripVsPlaneVmm=new TH2F("hStripVsPlaneVmm",
02854                                    "Vmm (StripEnd=kNeg=kEast)",
02855                                    planeMax-planeMin,planeMin,planeMax,
02856                                    bins,firstStripBin,lastStripBin);
02857   hStripVsPlaneVmm->GetXaxis()->SetTitle("Plane");
02858   hStripVsPlaneVmm->GetXaxis()->CenterTitle();
02859   hStripVsPlaneVmm->GetYaxis()->SetTitle("Strip");
02860   hStripVsPlaneVmm->GetYaxis()->CenterTitle();
02861   hStripVsPlaneVmm->SetFillColor(0);
02862   hStripVsPlaneVmm->SetMinimum(-2);
02863   //hStripVsPlaneVmm->SetBit(TH1::kCanRebin);
02864 
02865   TH2F *hStripVsPlaneVfb=new TH2F("hStripVsPlaneVfb",
02866                                    "Vfb (StripEnd=kNeg=kEast)",
02867                                    planeMax-planeMin,planeMin,planeMax,
02868                                    bins,firstStripBin,lastStripBin);
02869   hStripVsPlaneVfb->GetXaxis()->SetTitle("Plane");
02870   hStripVsPlaneVfb->GetXaxis()->CenterTitle();
02871   hStripVsPlaneVfb->GetYaxis()->SetTitle("Strip");
02872   hStripVsPlaneVfb->GetYaxis()->CenterTitle();
02873   hStripVsPlaneVfb->SetFillColor(0);
02874   hStripVsPlaneVfb->SetMinimum(-2);
02875   //hStripVsPlaneVfb->SetBit(TH1::kCanRebin);
02876 
02877   TH2F *hStripVsPlaneVaChip=new TH2F("hStripVsPlaneVaChip",
02878                                   "VA Chip (StripEnd=kNeg=kEast)",
02879                                   planeMax-planeMin,planeMin,planeMax,
02880                                   bins,firstStripBin,lastStripBin);
02881   hStripVsPlaneVaChip->GetXaxis()->SetTitle("Plane");
02882   hStripVsPlaneVaChip->GetXaxis()->CenterTitle();
02883   hStripVsPlaneVaChip->GetYaxis()->SetTitle("Strip");
02884   hStripVsPlaneVaChip->GetYaxis()->CenterTitle();
02885   hStripVsPlaneVaChip->SetFillColor(0);
02886   hStripVsPlaneVaChip->SetMinimum(-2);
02887   //hStripVsPlaneVaChip->SetBit(TH1::kCanRebin);
02888 
02889   TH2F *hStripVsPlaneCh=new TH2F("hStripVsPlaneCh",
02890                                   "VA Channel (StripEnd=kNeg=kEast)",
02891                                   planeMax-planeMin,planeMin,planeMax,
02892                                   bins,firstStripBin,lastStripBin);
02893   hStripVsPlaneCh->GetXaxis()->SetTitle("Plane");
02894   hStripVsPlaneCh->GetXaxis()->CenterTitle();
02895   hStripVsPlaneCh->GetYaxis()->SetTitle("Strip");
02896   hStripVsPlaneCh->GetYaxis()->CenterTitle();
02897   hStripVsPlaneCh->SetFillColor(0);
02898   hStripVsPlaneCh->SetMinimum(-2);
02899   //hStripVsPlaneCh->SetBit(TH1::kCanRebin);
02900 
02901   TH2F *hStripVsPlaneGeoAdd=new TH2F("hStripVsPlaneGeoAdd",
02902                                      "Geographic Address (StripEnd=kNeg=kEast)",
02903                                      planeMax-planeMin,planeMin,
02904                                      planeMax,
02905                                      bins,firstStripBin,lastStripBin);
02906   hStripVsPlaneGeoAdd->GetXaxis()->SetTitle("Plane");
02907   hStripVsPlaneGeoAdd->GetXaxis()->CenterTitle();
02908   hStripVsPlaneGeoAdd->GetYaxis()->SetTitle("Strip");
02909   hStripVsPlaneGeoAdd->GetYaxis()->CenterTitle();
02910   hStripVsPlaneGeoAdd->SetFillColor(0);
02911   hStripVsPlaneGeoAdd->SetMinimum(-2);
02912   //hStripVsPlaneGeoAdd->SetBit(TH1::kCanRebin);
02913 
02914   TH2F *hStripVsPlaneMasterCh=new TH2F("hStripVsPlaneMasterCh",
02915                                        "Master Channel (StripEnd=kNeg=kEast)",
02916                                         planeMax-planeMin,
02917                                         planeMin,planeMax,
02918                                         bins,
02919                                         firstStripBin,lastStripBin);
02920   hStripVsPlaneMasterCh->GetXaxis()->SetTitle("Plane");
02921   hStripVsPlaneMasterCh->GetXaxis()->CenterTitle();
02922   hStripVsPlaneMasterCh->GetYaxis()->SetTitle("Strip");
02923   hStripVsPlaneMasterCh->GetYaxis()->CenterTitle();
02924   hStripVsPlaneMasterCh->SetFillColor(0);
02925   hStripVsPlaneMasterCh->SetMinimum(-2);
02926   //hStripVsPlaneMasterCh->SetBit(TH1::kCanRebin);
02927 
02928   TH2F *hStripVsPlaneMinderCh=new TH2F("hStripVsPlaneMinderCh",
02929                                        "Minder Channel (StripEnd=kNeg=kEast)",
02930                                        planeMax-planeMin,
02931                                        planeMin,planeMax,
02932                                        bins,
02933                                        firstStripBin,lastStripBin);
02934   hStripVsPlaneMinderCh->GetXaxis()->SetTitle("Plane");
02935   hStripVsPlaneMinderCh->GetXaxis()->CenterTitle();
02936   hStripVsPlaneMinderCh->GetYaxis()->SetTitle("Strip");
02937   hStripVsPlaneMinderCh->GetYaxis()->CenterTitle();
02938   hStripVsPlaneMinderCh->SetFillColor(0);
02939   hStripVsPlaneMinderCh->SetMinimum(-2);
02940   //hStripVsPlaneMinderCh->SetBit(TH1::kCanRebin);
02941 
02942   TH2F *hStripVsPlaneSpot=new TH2F("hStripVsPlaneSpot",
02943                                    "Pixel Spot (StripEnd=kNeg=kEast)",
02944                                     planeMax-planeMin,planeMin,planeMax,
02945                                     bins,firstStripBin,lastStripBin);
02946   hStripVsPlaneSpot->GetXaxis()->SetTitle("Plane");
02947   hStripVsPlaneSpot->GetXaxis()->CenterTitle();
02948   hStripVsPlaneSpot->GetYaxis()->SetTitle("Strip");
02949   hStripVsPlaneSpot->GetYaxis()->CenterTitle();
02950   hStripVsPlaneSpot->SetFillColor(0);
02951   hStripVsPlaneSpot->SetMinimum(-2);
02952   //hStripVsPlaneSpot->SetBit(TH1::kCanRebin);
02953 
02954   TH2F *hStripVsPlaneEnt=new TH2F("hStripVsPlaneEnt",
02955                                   "Number Entries (StripEnd=kNeg=kEast)",
02956                                    planeMax-planeMin,planeMin,planeMax,
02957                                    bins,firstStripBin,lastStripBin);
02958   hStripVsPlaneEnt->GetXaxis()->SetTitle("Plane");
02959   hStripVsPlaneEnt->GetXaxis()->CenterTitle();
02960   hStripVsPlaneEnt->GetYaxis()->SetTitle("Strip");
02961   hStripVsPlaneEnt->GetYaxis()->CenterTitle();
02962   hStripVsPlaneEnt->SetFillColor(0);
02963   hStripVsPlaneEnt->SetMinimum(-2);
02964   //hStripVsPlaneEnt->SetBit(TH1::kCanRebin);
02965 
02967   //histos for the second side
02969   TH2F *hStripVsPlane2Led=new TH2F("hStripVsPlane2Led",
02970                                     "Led (StripEnd=kPos=kWest)",
02971                                    planeMax-planeMin,
02972                                    planeMin,planeMax,
02973                                    bins,firstStripBin,lastStripBin);
02974   hStripVsPlane2Led->GetXaxis()->SetTitle("Plane");
02975   hStripVsPlane2Led->GetXaxis()->CenterTitle();
02976   hStripVsPlane2Led->GetYaxis()->SetTitle("Strip");
02977   hStripVsPlane2Led->GetYaxis()->CenterTitle();
02978   hStripVsPlane2Led->SetFillColor(0);
02979   //hStripVsPlane2Led->SetBit(TH1::kCanRebin);
02980 
02981   TH2F *hStripVsPlane2Pix=new TH2F("hStripVsPlane2Pix",
02982                                    "Pixel (StripEnd=kPos=kWest)",
02983                                    planeMax-planeMin,planeMin,planeMax,
02984                                    bins,firstStripBin,lastStripBin);
02985   hStripVsPlane2Pix->GetXaxis()->SetTitle("Plane");
02986   hStripVsPlane2Pix->GetXaxis()->CenterTitle();
02987   hStripVsPlane2Pix->GetYaxis()->SetTitle("Strip");
02988   hStripVsPlane2Pix->GetYaxis()->CenterTitle();
02989   hStripVsPlane2Pix->SetFillColor(0);
02990   hStripVsPlane2Pix->SetMinimum(-2);
02991   //hStripVsPlane2Pix->SetBit(TH1::kCanRebin);
02992 
02993   TH2F *hStripVsPlane2Crate=new TH2F("hStripVsPlane2Crate",
02994                                      "Crate (StripEnd=kPos=kWest)",
02995                                      planeMax-planeMin,planeMin,planeMax,
02996                                      bins,firstStripBin,lastStripBin);
02997   hStripVsPlane2Crate->GetXaxis()->SetTitle("Plane");
02998   hStripVsPlane2Crate->GetXaxis()->CenterTitle();
02999   hStripVsPlane2Crate->GetYaxis()->SetTitle("Strip");
03000   hStripVsPlane2Crate->GetYaxis()->CenterTitle();
03001   hStripVsPlane2Crate->SetFillColor(0);
03002   hStripVsPlane2Crate->SetMinimum(-2);
03003   //hStripVsPlane2Crate->SetBit(TH1::kCanRebin);
03004 
03005   TH2F *hStripVsPlane2Varc=new TH2F("hStripVsPlane2Varc",
03006                                     "Varc (StripEnd=kPos=kWest)",
03007                                     planeMax-planeMin,planeMin,planeMax,
03008                                     bins,firstStripBin,lastStripBin);
03009   hStripVsPlane2Varc->GetXaxis()->SetTitle("Plane");
03010   hStripVsPlane2Varc->GetXaxis()->CenterTitle();
03011   hStripVsPlane2Varc->GetYaxis()->SetTitle("Strip");
03012   hStripVsPlane2Varc->GetYaxis()->CenterTitle();
03013   hStripVsPlane2Varc->SetFillColor(0);
03014   hStripVsPlane2Varc->SetMinimum(-2);
03015   //hStripVsPlane2Varc->SetBit(TH1::kCanRebin);
03016 
03017   TH2F *hStripVsPlane2Vmm=new TH2F("hStripVsPlane2Vmm",
03018                                    "Vmm (StripEnd=kPos=kWest)",
03019                                    planeMax-planeMin,planeMin,planeMax,
03020                                    bins,firstStripBin,lastStripBin);
03021   hStripVsPlane2Vmm->GetXaxis()->SetTitle("Plane");
03022   hStripVsPlane2Vmm->GetXaxis()->CenterTitle();
03023   hStripVsPlane2Vmm->GetYaxis()->SetTitle("Strip");
03024   hStripVsPlane2Vmm->GetYaxis()->CenterTitle();
03025   hStripVsPlane2Vmm->SetFillColor(0);
03026   hStripVsPlane2Vmm->SetMinimum(-2);
03027   //hStripVsPlane2Vmm->SetBit(TH1::kCanRebin);
03028 
03029   TH2F *hStripVsPlane2Vfb=new TH2F("hStripVsPlane2Vfb",
03030                                    "Vfb (StripEnd=kPos=kWest)",
03031                                    planeMax-planeMin,planeMin,planeMax,
03032                                    bins,firstStripBin,lastStripBin);
03033   hStripVsPlane2Vfb->GetXaxis()->SetTitle("Plane");
03034   hStripVsPlane2Vfb->GetXaxis()->CenterTitle();
03035   hStripVsPlane2Vfb->GetYaxis()->SetTitle("Strip");
03036   hStripVsPlane2Vfb->GetYaxis()->CenterTitle();
03037   hStripVsPlane2Vfb->SetFillColor(0);
03038   hStripVsPlane2Vfb->SetMinimum(-2);
03039   //hStripVsPlane2Vfb->SetBit(TH1::kCanRebin);
03040 
03041   TH2F *hStripVsPlane2VaChip=new TH2F("hStripVsPlane2VaChip",
03042                                   "Va Chip(StripEnd=kPos=kWest)",
03043                                   planeMax-planeMin,planeMin,planeMax,
03044                                   bins,firstStripBin,lastStripBin);
03045   hStripVsPlane2VaChip->GetXaxis()->SetTitle("Plane");
03046   hStripVsPlane2VaChip->GetXaxis()->CenterTitle();
03047   hStripVsPlane2VaChip->GetYaxis()->SetTitle("Strip");
03048   hStripVsPlane2VaChip->GetYaxis()->CenterTitle();
03049   hStripVsPlane2VaChip->SetFillColor(0);
03050   hStripVsPlane2VaChip->SetMinimum(-2);
03051   //hStripVsPlane2VaChip->SetBit(TH1::kCanRebin);
03052 
03053   TH2F *hStripVsPlane2Ch=new TH2F("hStripVsPlane2Ch",
03054                                   "VA Channel (StripEnd=kPos=kWest)",
03055                                   planeMax-planeMin,planeMin,planeMax,
03056                                   bins,firstStripBin,lastStripBin);
03057   hStripVsPlane2Ch->GetXaxis()->SetTitle("Plane");
03058   hStripVsPlane2Ch->GetXaxis()->CenterTitle();
03059   hStripVsPlane2Ch->GetYaxis()->SetTitle("Strip");
03060   hStripVsPlane2Ch->GetYaxis()->CenterTitle();
03061   hStripVsPlane2Ch->SetFillColor(0);
03062   hStripVsPlane2Ch->SetMinimum(-2);
03063   //hStripVsPlane2Ch->SetBit(TH1::kCanRebin);
03064 
03065   TH2F *hStripVsPlane2GeoAdd=new TH2F("hStripVsPlane2GeoAdd",
03066                                       "Geographic Address (StripEnd=kPos=kWest)",
03067                                       planeMax-planeMin,
03068                                       planeMin,planeMax,
03069                                       bins,firstStripBin,lastStripBin);
03070   hStripVsPlane2GeoAdd->GetXaxis()->SetTitle("Plane");
03071   hStripVsPlane2GeoAdd->GetXaxis()->CenterTitle();
03072   hStripVsPlane2GeoAdd->GetYaxis()->SetTitle("Strip");
03073   hStripVsPlane2GeoAdd->GetYaxis()->CenterTitle();
03074   hStripVsPlane2GeoAdd->SetFillColor(0);
03075   hStripVsPlane2GeoAdd->SetMinimum(-2);
03076   //hStripVsPlane2GeoAdd->SetBit(TH1::kCanRebin);
03077 
03078   TH2F *hStripVsPlane2MasterCh=new TH2F("hStripVsPlane2MasterCh",
03079                                         "Master Channel (StripEnd=kPos=kWest)",
03080                                         planeMax-planeMin,
03081                                         planeMin,planeMax,
03082                                         bins,
03083                                         firstStripBin,lastStripBin);
03084   hStripVsPlane2MasterCh->GetXaxis()->SetTitle("Plane");
03085   hStripVsPlane2MasterCh->GetXaxis()->CenterTitle();
03086   hStripVsPlane2MasterCh->GetYaxis()->SetTitle("Strip");
03087   hStripVsPlane2MasterCh->GetYaxis()->CenterTitle();
03088   hStripVsPlane2MasterCh->SetFillColor(0);
03089   hStripVsPlane2MasterCh->SetMinimum(-2);
03090   //hStripVsPlane2MasterCh->SetBit(TH1::kCanRebin);
03091 
03092   TH2F *hStripVsPlane2MinderCh=new TH2F("hStripVsPlane2MinderCh",
03093                                         "Minder Channel (StripEnd=kPos=kWest)",
03094                                         planeMax-planeMin,planeMin,
03095                                         planeMax,
03096                                         bins,firstStripBin,
03097                                         lastStripBin);
03098   hStripVsPlane2MinderCh->GetXaxis()->SetTitle("Plane");
03099   hStripVsPlane2MinderCh->GetXaxis()->CenterTitle();
03100   hStripVsPlane2MinderCh->GetYaxis()->SetTitle("Strip");
03101   hStripVsPlane2MinderCh->GetYaxis()->CenterTitle();
03102   hStripVsPlane2MinderCh->SetFillColor(0);
03103   hStripVsPlane2MinderCh->SetMinimum(-2);
03104   //hStripVsPlane2MinderCh->SetBit(TH1::kCanRebin);
03105 
03106   TH2F *hStripVsPlane2Spot=new TH2F("hStripVsPlane2Spot",
03107                                     "Pixel Spot (StripEnd=kPos=kWest)",
03108                                     planeMax-planeMin,planeMin,planeMax,
03109                                     bins,firstStripBin,lastStripBin);
03110   hStripVsPlane2Spot->GetXaxis()->SetTitle("Plane");
03111   hStripVsPlane2Spot->GetXaxis()->CenterTitle();
03112   hStripVsPlane2Spot->GetYaxis()->SetTitle("Strip");
03113   hStripVsPlane2Spot->GetYaxis()->CenterTitle();
03114   hStripVsPlane2Spot->SetFillColor(0);
03115   hStripVsPlane2Spot->SetMinimum(-2);
03116   //hStripVsPlane2Spot->SetBit(TH1::kCanRebin);
03117 
03118   TH2F *hStripVsPlane2Ent=new TH2F("hStripVsPlane2Ent",
03119                                    "Number Entries (StripEnd=kPos=kWest)",
03120                                    planeMax-planeMin,planeMin,planeMax,
03121                                    bins,firstStripBin,lastStripBin);
03122   hStripVsPlane2Ent->GetXaxis()->SetTitle("Plane");
03123   hStripVsPlane2Ent->GetXaxis()->CenterTitle();
03124   hStripVsPlane2Ent->GetYaxis()->SetTitle("Strip");
03125   hStripVsPlane2Ent->GetYaxis()->CenterTitle();
03126   hStripVsPlane2Ent->SetFillColor(0);
03127   hStripVsPlane2Ent->SetMinimum(-2);
03128   //hStripVsPlane2Ent->SetBit(TH1::kCanRebin);
03129 
03130   //create the plex plane id for use below
03131   PlexPlaneId* planeId;
03132 
03136 
03137   for (Int_t pl=planeMin;pl<planeMax;pl++){
03138 
03139     //get the plane ids
03140     if (detectorType==Detector::kFar){
03141       planeId=new PlexPlaneId(Detector::kFar,pl);
03142     }
03143     else if (detectorType==Detector::kCalDet){
03144       planeId=new PlexPlaneId(Detector::kCalDet,pl);
03145     }
03146     else{
03147       planeId=new PlexPlaneId(Detector::kNear,pl);
03148     }
03149 
03150     MSG("LIPlexMaps",Msg::kInfo) 
03151       <<"pl="<<pl<<", gPl="<<planeId->GetPlane()
03152       <<", view="<<planeId->GetPlaneView()
03153       <<", valid="<<planeId->IsValid()
03154       <<endl;
03155 
03156     for (Int_t st=-1;st<NUMSTRIPS+2;st++){
03157       for (Int_t se=0;se<NUMSIDES;se++){
03158 
03159         //create the strip end type
03160         StripEnd::EStripEnd stripEnd = StripEnd::kUnknown;
03161         
03162         //set the strip end type
03163         if (se==0) stripEnd=StripEnd::kEast;//FD=kNeg
03164         else if (se==1) stripEnd=StripEnd::kWest;//ND=kPos
03165 
03166         //Generate strip end id      
03167         PlexStripEndId stripEndId(*planeId,st,stripEnd);    
03168   
03169         //get led and pixel ids from strip end
03170         PlexLedId ledId=plexhandle->GetLedId(stripEndId);
03171         PlexPixelSpotId pixelId=plexhandle->GetPixelSpotId(stripEndId);
03172 
03173         Int_t crate=plexhandle->GetRawChannelId(stripEndId).
03174           GetCrate();
03175         Int_t varc=plexhandle->GetRawChannelId(stripEndId).GetVarcId();
03176         Int_t vmm=plexhandle->GetRawChannelId(stripEndId).GetVmm();
03177         Int_t vfb=plexhandle->GetRawChannelId(stripEndId).GetVaAdcSel();
03178         Int_t vaChip=plexhandle->GetRawChannelId(stripEndId).GetVaChip();
03179         Int_t ch=plexhandle->GetRawChannelId(stripEndId).GetVaChannel();
03180 
03181         Int_t masterCh=plexhandle->GetRawChannelId(stripEndId).
03182           GetMasterChannel();
03183         Int_t minderCh=plexhandle->GetRawChannelId(stripEndId).
03184           GetMinderChannel();
03185         Int_t geoAdd=plexhandle->GetRawChannelId(stripEndId).
03186           GetGeographicAddress();
03187 
03188         if (geoAdd>60000) geoAdd=-1;
03189         if (masterCh>60000) masterCh=-1;
03190         if (minderCh>60000) minderCh=-1;
03191 
03192         if (varc>60000) varc=-1;
03193         if (vmm>60000) vmm=-1;
03194         if (vfb>60000) vfb=-1;
03195         if (vaChip>60000) vaChip=-1;
03196         if (ch>60000) ch=-1;
03197 
03198         //get led and pixel from ids
03199         Int_t led=static_cast<Int_t>(ledId.GetLedInBox());
03200         Int_t pix=static_cast<Int_t>(pixelId.GetPixel());
03201         Int_t spot=pixelId.GetSpot();
03202 
03203         MSG("LIPlexMaps",Msg::kVerbose) 
03204           <<"st="<<st<<", gSt="<<stripEndId.GetStrip()
03205           <<", end="<<stripEndId.GetEnd()
03206           <<", val="<<stripEndId.IsValid()
03207           <<", gled="<<led
03208           <<", gpB="<<ledId.GetPulserBox()
03209           <<", val="<<ledId.IsValid()
03210           <<", pixel="<<pix
03211           <<", val="<<pixelId.IsValid()
03212           <<endl;
03213 
03214         if (se==0){
03215           //fill histograms
03216           hStripVsPlanePix->Fill(pl,st,pix);
03217           hStripVsPlaneSpot->Fill(pl,st,spot);
03218           hStripVsPlaneCrate->Fill(pl,st,crate);
03219           hStripVsPlaneVarc->Fill(pl,st,varc);
03220           hStripVsPlaneVmm->Fill(pl,st,vmm);
03221           hStripVsPlaneVfb->Fill(pl,st,vfb);
03222           hStripVsPlaneVaChip->Fill(pl,st,vaChip);
03223           hStripVsPlaneCh->Fill(pl,st,ch);
03224           hStripVsPlaneGeoAdd->Fill(pl,st,geoAdd);
03225           hStripVsPlaneMasterCh->Fill(pl,st,masterCh);
03226           hStripVsPlaneMinderCh->Fill(pl,st,minderCh);
03227           hStripVsPlaneLed->Fill(pl,st,led);
03228           hStripVsPlaneEnt->Fill(pl,st,1.);
03229         }
03230         else if (se==1){
03231           //fill histograms
03232           hStripVsPlane2Pix->Fill(pl,st,pix);
03233           hStripVsPlane2Spot->Fill(pl,st,spot);
03234           hStripVsPlane2Crate->Fill(pl,st,crate);
03235           hStripVsPlane2Varc->Fill(pl,st,varc);
03236           hStripVsPlane2Vmm->Fill(pl,st,vmm);
03237           hStripVsPlane2Vfb->Fill(pl,st,vfb);
03238           hStripVsPlane2VaChip->Fill(pl,st,vaChip);
03239           hStripVsPlane2Ch->Fill(pl,st,ch);
03240           hStripVsPlane2GeoAdd->Fill(pl,st,geoAdd);
03241           hStripVsPlane2MasterCh->Fill(pl,st,masterCh);
03242           hStripVsPlane2MinderCh->Fill(pl,st,minderCh);
03243           hStripVsPlane2Led->Fill(pl,st,led);
03244           hStripVsPlane2Ent->Fill(pl,st,1.);
03245         }
03246       }
03247     }
03248   }
03249 
03253 
03254   //get rid of the stats info
03255   gStyle->SetOptStat(0);
03256 
03257   Int_t draw=1;
03258   if (draw==1){
03259   TCanvas *cStripVsPlaneLed=new TCanvas
03260     ("cStripVsPlaneLed","StripVsPlane: Led",0,0,1000,800);
03261   cStripVsPlaneLed->SetFillColor(0);
03262   cStripVsPlaneLed->cd();
03263   hStripVsPlaneLed->Draw("colz");
03264 
03265   TCanvas *cStripVsPlanePix=new TCanvas
03266     ("cStripVsPlanePix","StripVsPlane: Pixel",0,0,1000,800);
03267   cStripVsPlanePix->SetFillColor(0);
03268   cStripVsPlanePix->cd();
03269   hStripVsPlanePix->Draw("textcolz");
03270   
03271   TCanvas *cStripVsPlaneCrate=new TCanvas
03272     ("cStripVsPlaneCrate","StripVsPlane: Crate",0,0,1000,800);
03273   cStripVsPlaneCrate->SetFillColor(0);
03274   cStripVsPlaneCrate->cd();
03275   hStripVsPlaneCrate->Draw("textcolz");
03276 
03277   TCanvas *cStripVsPlaneVarc=new TCanvas
03278     ("cStripVsPlaneVarc","StripVsPlane: Varc",0,0,1000,800);
03279   cStripVsPlaneVarc->SetFillColor(0);
03280   cStripVsPlaneVarc->cd();
03281   hStripVsPlaneVarc->Draw("textcolz");
03282  
03283   TCanvas *cStripVsPlaneVmm=new TCanvas
03284     ("cStripVsPlaneVmm","StripVsPlane: Vmm",0,0,1000,800);
03285   cStripVsPlaneVmm->SetFillColor(0);
03286   cStripVsPlaneVmm->cd();
03287   hStripVsPlaneVmm->Draw("textcolz");
03288 
03289   TCanvas *cStripVsPlaneVfb=new TCanvas
03290     ("cStripVsPlaneVfb","StripVsPlane: Vfb",0,0,1000,800);
03291   cStripVsPlaneVfb->SetFillColor(0);
03292   cStripVsPlaneVfb->cd();
03293   hStripVsPlaneVfb->Draw("textcolz");
03294 
03295   TCanvas *cStripVsPlaneVaChip=new TCanvas
03296     ("cStripVsPlaneVaChip","StripVsPlane: VaChip",0,0,1000,800);
03297   cStripVsPlaneVaChip->SetFillColor(0);
03298   cStripVsPlaneVaChip->cd();
03299   hStripVsPlaneVaChip->Draw("textcolz");
03300 
03301   TCanvas *cStripVsPlaneCh=new TCanvas
03302     ("cStripVsPlaneCh","StripVsPlane: Ch",0,0,1000,800);
03303   cStripVsPlaneCh->SetFillColor(0);
03304   cStripVsPlaneCh->cd();
03305   hStripVsPlaneCh->Draw("textcolz");
03306 
03307   TCanvas *cStripVsPlaneGeoAdd=new TCanvas
03308     ("cStripVsPlaneGeoAdd","StripVsPlane: GeoAdd",0,0,1000,800);
03309   cStripVsPlaneGeoAdd->SetFillColor(0);
03310   cStripVsPlaneGeoAdd->cd();
03311   hStripVsPlaneGeoAdd->Draw("textcolz");
03312 
03313   TCanvas *cStripVsPlaneMasterCh=new TCanvas
03314     ("cStripVsPlaneMasterCh","StripVsPlane: Master Channel",
03315      0,0,1000,800);
03316   cStripVsPlaneMasterCh->SetFillColor(0);
03317   cStripVsPlaneMasterCh->cd();
03318   hStripVsPlaneMasterCh->Draw("textcolz");
03319 
03320   }
03321 
03322   TCanvas *cStripVsPlaneMinderCh=new TCanvas
03323     ("cStripVsPlaneMinderCh","StripVsPlane: MinderCh",0,0,1000,800);
03324   cStripVsPlaneMinderCh->SetFillColor(0);
03325   cStripVsPlaneMinderCh->cd();
03326   hStripVsPlaneMinderCh->Draw("textcolz");
03327 
03328   TCanvas *cStripVsPlaneSpot=new TCanvas
03329     ("cStripVsPlaneSpot","StripVsPlane: Spot",0,0,1000,800);
03330   cStripVsPlaneSpot->SetFillColor(0);
03331   cStripVsPlaneSpot->cd();
03332   hStripVsPlaneSpot->Draw("textcolz");
03333 
03334   TCanvas *cStripVsPlaneEnt=new TCanvas
03335     ("cStripVsPlaneEnt","StripVsPlane: NumEntries",0,0,1000,800);
03336   cStripVsPlaneEnt->SetFillColor(0);
03337   cStripVsPlaneEnt->cd();
03338   hStripVsPlaneEnt->Draw("textcolz");
03339   
03340 
03342   //Draw the kPos=kWest side
03344 
03345   TCanvas *cStripVsPlane2Led=new TCanvas
03346     ("cStripVsPlane2Led","StripVsPlane2: Led",0,0,1000,800);
03347   cStripVsPlane2Led->SetFillColor(0);
03348   cStripVsPlane2Led->cd();
03349   hStripVsPlane2Led->Draw("colz");
03350 
03351   TCanvas *cStripVsPlane2Pix=new TCanvas
03352     ("cStripVsPlane2Pix","StripVsPlane2: Pixel",0,0,1000,800);
03353   cStripVsPlane2Pix->SetFillColor(0);
03354   cStripVsPlane2Pix->cd();
03355   hStripVsPlane2Pix->Draw("textcolz");
03356   
03357   TCanvas *cStripVsPlane2Crate=new TCanvas
03358     ("cStripVsPlane2Crate","StripVsPlane2: Crate",0,0,1000,800);
03359   cStripVsPlane2Crate->SetFillColor(0);
03360   cStripVsPlane2Crate->cd();
03361   hStripVsPlane2Crate->Draw("textcolz");
03362 
03363   TCanvas *cStripVsPlane2Varc=new TCanvas
03364     ("cStripVsPlane2Varc","StripVsPlane2: Varc",0,0,1000,800);
03365   cStripVsPlane2Varc->SetFillColor(0);
03366   cStripVsPlane2Varc->cd();
03367   hStripVsPlane2Varc->Draw("textcolz");
03368  
03369   TCanvas *cStripVsPlane2Vmm=new TCanvas
03370     ("cStripVsPlane2Vmm","StripVsPlane2: Vmm",0,0,1000,800);
03371   cStripVsPlane2Vmm->SetFillColor(0);
03372   cStripVsPlane2Vmm->cd();
03373   hStripVsPlane2Vmm->Draw("textcolz");
03374 
03375   TCanvas *cStripVsPlane2Vfb=new TCanvas
03376     ("cStripVsPlane2Vfb","StripVsPlane2: Vfb",0,0,1000,800);
03377   cStripVsPlane2Vfb->SetFillColor(0);
03378   cStripVsPlane2Vfb->cd();
03379   hStripVsPlane2Vfb->Draw("textcolz");
03380 
03381   TCanvas *cStripVsPlane2VaChip=new TCanvas
03382     ("cStripVsPlane2VaChip","StripVsPlane2: VaChip",0,0,1000,800);
03383   cStripVsPlane2VaChip->SetFillColor(0);
03384   cStripVsPlane2VaChip->cd();
03385   hStripVsPlane2VaChip->Draw("textcolz");
03386 
03387   TCanvas *cStripVsPlane2Ch=new TCanvas
03388     ("cStripVsPlane2Ch","StripVsPlane2: Ch",0,0,1000,800);
03389   cStripVsPlane2Ch->SetFillColor(0);
03390   cStripVsPlane2Ch->cd();
03391   hStripVsPlane2Ch->Draw("textcolz");
03392 
03393   TCanvas *cStripVsPlane2GeoAdd=new TCanvas
03394     ("cStripVsPlane2GeoAdd","StripVsPlane2: GeoAdd",0,0,1000,800);
03395   cStripVsPlane2GeoAdd->SetFillColor(0);
03396   cStripVsPlane2GeoAdd->cd();
03397   hStripVsPlane2GeoAdd->Draw("textcolz");
03398 
03399   TCanvas *cStripVsPlane2MasterCh=new TCanvas
03400     ("cStripVsPlane2MasterCh","StripVsPlane2: Master Channel",
03401      0,0,1000,800);
03402   cStripVsPlane2MasterCh->SetFillColor(0);
03403   cStripVsPlane2MasterCh->cd();
03404   hStripVsPlane2MasterCh->Draw("textcolz");
03405 
03406   TCanvas *cStripVsPlane2MinderCh=new TCanvas
03407     ("cStripVsPlane2MinderCh","StripVsPlane2: MinderCh",0,0,1000,800);
03408   cStripVsPlane2MinderCh->SetFillColor(0);
03409   cStripVsPlane2MinderCh->cd();
03410   hStripVsPlane2MinderCh->Draw("textcolz");
03411 
03412   TCanvas *cStripVsPlane2Spot=new TCanvas
03413     ("cStripVsPlane2Spot","StripVsPlane2: Spot",0,0,1000,800);
03414   cStripVsPlane2Spot->SetFillColor(0);
03415   cStripVsPlane2Spot->cd();
03416   hStripVsPlane2Spot->Draw("textcolz");
03417 
03418   TCanvas *cStripVsPlane2Ent=new TCanvas
03419     ("cStripVsPlane2Ent","StripVsPlane2: NumEntries",0,0,1000,800);
03420   cStripVsPlane2Ent->SetFillColor(0);
03421   cStripVsPlane2Ent->cd();
03422   hStripVsPlane2Ent->Draw("textcolz");
03423   
03424   MSG("LIPlexMaps",Msg::kInfo)
03425     <<endl<<" ** Finished the PlotPlexStripMap method ** " 
03426     <<endl;
03427 }

void LIPlexMaps::PrintDbPinDiodeInfo (  ) 

Definition at line 2535 of file LIPlexMaps.cxx.

References GetElecString(), PlexPinDiodeId::GetGain(), PlexPinDiodeId::GetInBox(), DbiResultPtr< T >::GetNumRows(), PlexRawChannelToPinDiode::GetPlexPinDiodeId(), PlexRawChannelToPinDiode::GetRawChannelId(), DbiResultPtr< T >::GetRow(), SimFlag::kData, and Detector::kFar.

02536 {
02537   VldTimeStamp timeStamp;//now
02538   
02539   //get validity context for detector
02540   VldContext vldc(Detector::kFar,SimFlag::kData,timeStamp);
02541   
02542   DbiResultPtr<PlexRawChannelToPinDiode> rc2pdResPtr(vldc);
02543 
02544   cout<<"Num of PlexRawChannelToPinDiode rows="
02545       <<rc2pdResPtr.GetNumRows()<<endl;
02546   
02547   for (UInt_t irow = 0; irow < rc2pdResPtr.GetNumRows(); ++irow) {
02548     
02549     const PlexRawChannelToPinDiode* rc2pd = rc2pdResPtr.GetRow(irow);
02550     
02551     RawChannelId    rcid = rc2pd->GetRawChannelId();
02552     PlexPinDiodeId pinid = rc2pd->GetPlexPinDiodeId();
02553 
02554     cout<<"row="<<irow<<", rcid="<<this->GetElecString(rcid)
02555         <<", pinid="<<pinid<<", g="<<pinid.GetGain()
02556         <<", inbox="<<pinid.GetInBox()<<endl;
02557   }
02558   
02559   //print gain==0
02560   cout<<"gain==0"<<endl;
02561   for (UInt_t irow = 0; irow < rc2pdResPtr.GetNumRows(); ++irow) {
02562     
02563     const PlexRawChannelToPinDiode* rc2pd = rc2pdResPtr.GetRow(irow);
02564     
02565     RawChannelId    rcid = rc2pd->GetRawChannelId();
02566     PlexPinDiodeId pinid = rc2pd->GetPlexPinDiodeId();
02567 
02568     if (pinid.GetGain()==0){
02569       cout<<"row="<<irow<<", rcid="<<this->GetElecString(rcid)
02570           <<", pinid="<<pinid<<", g="<<pinid.GetGain()
02571         //<<", inbox="<<pinid.GetInBox()
02572           <<endl;
02573     }
02574   }
02575 
02576   //print gain==1
02577   cout<<"gain==1"<<endl;
02578   for (UInt_t irow = 0; irow < rc2pdResPtr.GetNumRows(); ++irow) {
02579     
02580     const PlexRawChannelToPinDiode* rc2pd = rc2pdResPtr.GetRow(irow);
02581     
02582     RawChannelId    rcid = rc2pd->GetRawChannelId();
02583     PlexPinDiodeId pinid = rc2pd->GetPlexPinDiodeId();
02584 
02585     if (pinid.GetGain()==1){
02586       cout<<"row="<<irow<<", rcid="<<this->GetElecString(rcid)
02587           <<", pinid="<<pinid<<", g="<<pinid.GetGain()
02588         //<<", inbox="<<pinid.GetInBox()
02589           <<endl;
02590     }
02591   }
02592 
02593 }

void LIPlexMaps::PrintPlexPinDiodeInfo ( Int_t  detectorType  ) 

Definition at line 2597 of file LIPlexMaps.cxx.

References VldContext::AsString(), exit(), fLookup, Form(), GetElecString(), LILookup::GetPinDiodeIds(), LILookup::GetPinDiodePlanes(), PlexHandle::GetRawChannelId(), Detector::kCalDet, SimFlag::kData, Msg::kError, Detector::kFar, Msg::kInfo, Detector::kNear, Msg::kVerbose, Msg::kWarning, and MSG.

02598 {
02599   MSG("LIPlexMaps",Msg::kInfo) 
02600     <<"Running PrintPlexPinDiodeInfo method..."<<endl;
02601 
02602   //set validity context to todays date and real data
02603   //VldTimeStamp timeStamp(2002,9,14,1,1,1,1,0,0);
02604   VldTimeStamp timeStamp;//now
02605   //VldTimeStamp timeStamp(2003,8,17,1,1,1,1,0,0);
02606   //  VldTimeStamp timeStamp(2003,3,1,1,1,1,1,0,0);
02607 
02608   //get validity context for detector
02609   VldContext* validityContext;
02610   if (detectorType==Detector::kFar){
02611     validityContext=new VldContext(Detector::kFar,SimFlag::kData,
02612                                    timeStamp);
02613   }
02614   else if (detectorType==Detector::kCalDet){
02615     validityContext=new VldContext(Detector::kCalDet,SimFlag::kData,
02616                                    timeStamp);
02617   }
02618   else if (detectorType==Detector::kNear){
02619     validityContext=new VldContext(Detector::kNear,SimFlag::kData,
02620                                    timeStamp);
02621   }
02622   else{
02623     MSG("LIPlexMaps",Msg::kError)
02624       <<"Detector type not known = "<<detectorType
02625       <<endl<<"Program will exit here!"<<endl;
02626     exit(1);
02627   }
02628 
02629   MSG("LIPlexMaps",Msg::kInfo) 
02630     <<"Using validity context: "<<validityContext->AsString()<<endl;
02631 
02632   //create a plex handle to access the database
02633   PlexHandle *plexHandle=new PlexHandle(*validityContext);   
02634 
02635   //get list of leds with given validity context
02636   LedIdList leds(*validityContext);
02637   LedIdList::iterator ledId=leds.begin();
02638 
02639   //leave a line
02640   MSG("LIPlexMaps",Msg::kInfo)
02641     <<endl
02642     <<"The pin diode information in the plex is as follows"<<endl
02643     <<"The electronics information is in descending hierarchial order"
02644     <<endl
02645     <<"(x:y) is pulser box x and led y"<<endl
02646     <<"e.g. (crate,varc,vmm,vfb,VA chip,VA channel)"<<endl<<endl;
02647 
02648   //start to loop over leds
02649   while (ledId!=leds.end()){
02650     
02651     if (!(*ledId).IsValid()){
02652       MSG("LIPlexMaps",Msg::kWarning)
02653         <<"LedId not valid = "<<ledId->AsString()<<endl;
02654     }
02655     
02656     //create a pair to hold the two possible pin diode ids
02657     pair<PlexPinDiodeId,PlexPinDiodeId> plexPins=plexHandle->
02658       GetPinDiodeIds(*ledId);
02659   
02660     //first is gain=1, second is gain=0
02661     MSG("LIPlexMaps",Msg::kVerbose) 
02662       <<"first pin gain="<<plexPins.first.GetGain()
02663       <<", second pin gain="<<plexPins.second.GetGain()<<endl;
02664   
02665     //get the two planes associated with the pin diodes
02666     pair<Int_t,Int_t> pin1Planes=fLookup.GetPinDiodePlanes
02667       (plexPins.first,plexHandle);
02668     pair<Int_t,Int_t> pin2Planes=fLookup.GetPinDiodePlanes
02669       (plexPins.second,plexHandle);
02670 
02671     //get the raw channel ids of the pins
02672     pair<RawChannelId,RawChannelId> rawChanIds;
02673     rawChanIds.first=plexHandle->GetRawChannelId(plexPins.first);
02674     rawChanIds.second=plexHandle->GetRawChannelId(plexPins.second);
02675     
02676     //create the planes string 
02677     //either 1 or 2 planes depending on whether shared pmt is used
02678     string sPlane1=Form("%d",pin1Planes.first);
02679     string sPlane2=Form("%d",pin1Planes.second);
02680 
02681     string sPin1Planes="  Planes="+sPlane1+"&"+sPlane2;
02682     if (pin1Planes.second==-1){
02683       sPin1Planes="  Plane="+sPlane1;
02684     }
02685 
02686     sPlane1=Form("%d",pin2Planes.first);
02687     sPlane2=Form("%d",pin2Planes.second);
02688     string sPin2Planes="  Planes="+sPlane1+"&"+sPlane2;
02689     if (pin2Planes.second==-1){
02690       sPin2Planes="  Plane="+sPlane1;
02691     }
02692 
02693     MSG("LIPlexMaps",Msg::kInfo)
02694       <<endl
02695       <<"("<<ledId->GetPulserBox()<<":"<<ledId->GetLedInBox()<<")"
02696       <<"  Pin1="<<this->GetElecString(rawChanIds.first)
02697       <<"="<<rawChanIds.first.GetChAdd()
02698       <<"  MUX BOX: E/W="<<plexPins.first.GetEastWest()
02699       <<", rLevel="<<plexPins.first.GetRackLevel()
02700       <<", rBay="<<plexPins.first.GetRackBay()
02701       <<", inRack="<<plexPins.first.GetInRack()
02702       <<sPin1Planes
02703       <<endl
02704       //now pin2
02705       <<"("<<ledId->GetPulserBox()<<":"<<ledId->GetLedInBox()<<")"
02706       <<"  Pin2="<<this->GetElecString(rawChanIds.second)
02707       <<"="<<rawChanIds.second.GetChAdd()
02708       <<"  MUX BOX: E/W="<<plexPins.second.GetEastWest()
02709       <<", rLevel="<<plexPins.second.GetRackLevel()
02710       <<", rBay="<<plexPins.second.GetRackBay()
02711       <<", inRack="<<plexPins.second.GetInRack()
02712       <<sPin2Planes
02713       <<endl;
02714 
02715     ledId++;
02716   }
02717   
02718   MSG("LIPlexMaps",Msg::kInfo)
02719     <<endl<<" ** Finished the PrintPlexPinDiodeInfo method ** " 
02720     <<endl;
02721 }

void LIPlexMaps::RatioRawToRefDrift (  ) 

Definition at line 8062 of file LIPlexMaps.cxx.

References LILookup::FIRSTSTRIP, fLookup, Form(), fS, DbiResultPtr< T >::GetRow(), PulserRawDrift::GetStripEnd(), PulserRefDrift::GetStripEnd(), Detector::kCalDet, SimFlag::kData, Msg::kError, Msg::kInfo, LILookup::LASTSTRIP, MSG, DbiResultPtr< T >::NewQuery(), LILookup::SetPbPlanes(), and LILookup::UnencodePlnStripEndKey().

08063 {
08064   MSG("LIPlexMaps",Msg::kInfo)
08065     <<endl<<" ** Running the RatioRawToRefDrift() method... ** "<<endl; 
08066 
08067   //Thanks to Ryan for the DB code of this method  
08068   
08069   Int_t detectorType=4;
08070 
08071   Int_t* planeMax=new Int_t[NUMCRATES];
08072   Int_t* planeMin=new Int_t[NUMCRATES];
08073   fLookup.SetPbPlanes(planeMin,planeMax,detectorType);
08074 
08075   const Int_t firstStripBin=FIRSTSTRIP-8;//-8;
08076   const Int_t lastStripBin=LASTSTRIP+9;//200;
08077   const Int_t bins=lastStripBin-firstStripBin;
08078 
08079   string sConstantBit="";
08080 
08081   MSG("LIAnalysis",Msg::kInfo)
08082     <<"sConstantBit="<<sConstantBit<<endl;
08083 
08084   TH2F **hStripVsPlaneRawToRef=0;
08085   hStripVsPlaneRawToRef= new TH2F*[NUMCRATES];
08086   for (Int_t i=0;i<NUMCRATES;i++){
08087     string sPb=Form("%d",i);
08088     fS="RawToRef (Crate "+sPb+")";
08089     hStripVsPlaneRawToRef[i]=new TH2F(fS.c_str(),fS.c_str(),
08090                                   planeMax[i]-planeMin[i],
08091                                   planeMin[i],planeMax[i],
08092                                   bins,firstStripBin,lastStripBin);
08093     hStripVsPlaneRawToRef[i]->GetXaxis()->SetTitle("Plane");
08094     hStripVsPlaneRawToRef[i]->GetXaxis()->CenterTitle();
08095     hStripVsPlaneRawToRef[i]->GetYaxis()->SetTitle("Strip");
08096     hStripVsPlaneRawToRef[i]->GetYaxis()->CenterTitle();
08097     hStripVsPlaneRawToRef[i]->SetFillColor(0);
08098     //hStripVsPlaneRawToRef[i]->SetBit(TH1::kCanRebin);
08099   }
08100 
08101   Detector::Detector_t det=Detector::kCalDet;
08102   VldTimeStamp tsNow;
08103   VldContext vldNow(det,SimFlag::kData,tsNow);
08104 
08105   DbiResultPtr<PulserRawDrift> dbiPulserRawDrift;
08106   DbiResultPtr<PulserRefDrift> dbiPulserRefDrift;
08107 
08108   UInt_t numRowsRaw=dbiPulserRawDrift.NewQuery(vldNow,0);
08109   UInt_t numRowsRef=dbiPulserRefDrift.NewQuery(vldNow,0);
08110 
08111   if (numRowsRef!=numRowsRaw) {
08112     MSG("LIPlexMaps",Msg::kError)
08113       <<"Raw and Ref PulserDrift tables are different sizes"<<endl;
08114       //<<"Program will exit here..."<<endl;
08115     //exit(0);
08116   }
08117 
08118   UInt_t numRows=numRowsRaw;
08119   if (numRowsRaw>numRowsRef) numRows=numRowsRef;
08120 
08121   MSG("LIPlexMaps",Msg::kInfo)
08122     <<"Using "<<numRows<<" rows"<<endl;
08123 
08124   map<Int_t,PulserRawDrift> rawDrift;
08125   map<Int_t,PulserRefDrift> refDrift;
08126 
08128   //loop over the rows
08130   for(UInt_t i=0;i<numRows;i++) {
08131     const PulserRawDrift* pulserRawDrift=dbiPulserRawDrift.GetRow(i);
08132     const PulserRefDrift* pulserRefDrift=dbiPulserRefDrift.GetRow(i);
08133 
08134     //insert into map
08135     rawDrift[pulserRawDrift->GetStripEnd()]=*pulserRawDrift;
08136     refDrift[pulserRefDrift->GetStripEnd()]=*pulserRefDrift;
08137   }
08139   //finished loop over the rows
08141 
08142   MSG("LIPlexMaps",Msg::kInfo)
08143     <<"Finished loop"<<endl;
08144 
08145   map<Int_t,PulserRawDrift>::iterator raw=rawDrift.begin();
08146   map<Int_t,PulserRefDrift>::iterator ref=refDrift.begin();
08147 
08148   //now loop over map
08149   while(raw!=rawDrift.end()){
08150 
08151     Float_t meanRaw=raw->second.GetMean();
08152     Float_t errorRaw=raw->second.GetError();
08153     Float_t numEntriesRaw=raw->second.GetNumEntries();
08154     UInt_t seidkeyRaw=raw->first;
08155     Int_t planeRaw=-1;
08156     Int_t stripRaw=-1;
08157     Int_t endRaw=-1;
08158     fLookup.UnencodePlnStripEndKey(seidkeyRaw,det,planeRaw,stripRaw,
08159                                    endRaw);
08160 
08161     Float_t meanRef=ref->second.GetMean();
08162     Float_t errorRef=ref->second.GetError();
08163     Float_t numEntriesRef=ref->second.GetNumEntries();
08164     UInt_t seidkeyRef=ref->first;
08165     Int_t planeRef=-1;
08166     Int_t stripRef=-1;
08167     Int_t endRef=-1;
08168     fLookup.UnencodePlnStripEndKey(seidkeyRef,det,planeRef,stripRef,
08169                                    endRef);
08170     
08171     //check sanity of procedure
08172     if (seidkeyRef!=seidkeyRaw){
08173       MSG("LIPlexMaps",Msg::kError)
08174         <<"Raw and Ref seidkeys are different"<<endl;
08175         //<<"Program will exit here..."<<endl;
08176       //exit(0);
08177       raw++;
08178       ref++;    
08179       continue;
08180     }
08181 
08182     //protect against fpe
08183     if (meanRef>0){
08184       hStripVsPlaneRawToRef[endRef-1]->Fill(planeRef,stripRef,
08185                                             meanRaw/meanRef);
08186     }
08187 
08188     //get lots of strings
08189     string sMeanRaw=Form("%.1f",meanRaw);
08190     string sErrorRaw=Form("%.2f",errorRaw);
08191     string sNumEntriesRaw=Form("%.0f",numEntriesRaw);
08192     string sSeIdRaw=Form("%d",seidkeyRaw);
08193 
08194     string sMeanRef=Form("%.1f",meanRef);
08195     string sErrorRef=Form("%.2f",errorRef);
08196     string sNumEntriesRef=Form("%.0f",numEntriesRef);
08197     string sSeIdRef=Form("%d",seidkeyRef);
08198 
08199     string sMeanDif=Form("%.1f",meanRef-meanRaw);
08200     string sErrorDif=Form("%.2f",errorRef-errorRaw);
08201     string sNumEntriesDif=Form("%.0f",numEntriesRef-numEntriesRaw);
08202     string sSeIdDiff=Form("%d",seidkeyRef-seidkeyRaw);
08203 
08204     MSG("LIPlexMaps",Msg::kInfo)
08205       <<endl
08206       <<"Ref (m,er,num,seid)=("<<sMeanRef<<";"<<sErrorRef
08207       <<";"<<sNumEntriesRef<<";"<<sSeIdRef<<")"
08208       <<endl
08209       <<"Raw (m,er,num,seid)=("<<sMeanRaw<<";"<<sErrorRaw
08210       <<";"<<sNumEntriesRaw<<";"<<sSeIdRaw<<")"
08211       <<endl
08212       <<"Diff (m,er,num,seid)=("<<sMeanDif<<";"<<sErrorDif
08213       <<";"<<sNumEntriesDif<<";"<<sSeIdDiff<<")"
08214       <<endl;
08215 
08216     raw++;
08217     ref++;    
08218   }
08219 
08220   //set stats info off
08221   gStyle->SetOptStat(0);
08222 
08223   TCanvas *cStripVsPlaneRawToRef=new TCanvas  
08224     ("cStripVsPlaneRawToRef","StripVsPlane: RawToRef",0,0,1000,800);  
08225   cStripVsPlaneRawToRef->SetFillColor(0);  
08226   cStripVsPlaneRawToRef->Divide(1,2);  
08227   cStripVsPlaneRawToRef->cd(1);  
08228   hStripVsPlaneRawToRef[0]->Draw("colz");  
08229   cStripVsPlaneRawToRef->cd(2);  
08230   hStripVsPlaneRawToRef[1]->Draw("colz");  
08231 
08232   MSG("LIPlexMaps",Msg::kInfo)
08233     <<endl<<" ** Finished the RatioRawToRefDrift() method... ** "
08234     <<endl; 
08235 }

void LIPlexMaps::ReadDbCalStripAtten ( Int_t  det,
VldTimeStamp  ts,
Int_t  task 
)

Definition at line 5741 of file LIPlexMaps.cxx.

References CalStripAtten::GetFrac1(), CalStripAtten::GetLambda1(), CalStripAtten::GetLambda2(), PlexPlaneId::GetPlane(), DbiResultPtr< T >::GetRow(), PlexStripEndId::GetStrip(), CalStripAtten::GetStripEndId(), SimFlag::kData, Msg::kInfo, MSG, DbiResultPtr< T >::NewQuery(), VldContext::Print(), and LILookup::SetDetector().

05741                                                                           {
05742   MSG("LIPlexMaps",Msg::kInfo)
05743     <<endl<<" ** Running the ReadDbCalStripToStrip() method... ** "<<endl;
05744   //this must go first
05745   this->SetDetector(det);
05746 
05747   TH1F *hShortAmp = new TH1F("hShortAmp","Short Attenuation fraction",200,0,1);
05748   hShortAmp->GetXaxis()->SetTitle("Short Attenuation fraction");
05749   hShortAmp->GetXaxis()->CenterTitle();
05750   hShortAmp->GetYaxis()->SetTitle("");
05751   hShortAmp->GetYaxis()->CenterTitle();
05752   hShortAmp->SetLineColor(2);
05753   hShortAmp->SetFillStyle(3015);
05754   hShortAmp->SetFillColor(2);
05755   hShortAmp->SetLineWidth(3);
05756   //hShortAmp->SetBit(TH1::kCanRebin);
05757 
05758   TH2F *hShortAmpDet = new TH2F("hShortAmpDet","Short Attenuation fraction",282,0,282,96,0,96);
05759   hShortAmpDet->GetXaxis()->SetTitle("Plane NO.");
05760   hShortAmpDet->GetXaxis()->CenterTitle();
05761   hShortAmpDet->GetYaxis()->SetTitle("Strip NO.");
05762   hShortAmpDet->GetYaxis()->CenterTitle();
05763   
05764   TH1F *hLongAmp = new TH1F("hLongAmp","Long Attenuation fraction",200,0,1);
05765   hLongAmp->GetXaxis()->SetTitle("Long Attenuation fraction");
05766   hLongAmp->GetXaxis()->CenterTitle();
05767   hLongAmp->GetYaxis()->SetTitle("");
05768   hLongAmp->GetYaxis()->CenterTitle();
05769   hLongAmp->SetLineColor(4);
05770   hLongAmp->SetFillStyle(3015);
05771   hLongAmp->SetFillColor(4);
05772   hLongAmp->SetLineWidth(3);
05773   // hLongAmp->SetBit(TH1::kCanRebin);
05774 
05775   TH2F *hLongAmpDet = new TH2F("hLongAmpDet","Long Attenuation fraction",282,0,282,96,0,96);
05776   hLongAmpDet->GetXaxis()->SetTitle("Plane NO.");
05777   hLongAmpDet->GetXaxis()->CenterTitle();
05778   hLongAmpDet->GetYaxis()->SetTitle("Strip NO.");
05779   hLongAmpDet->GetYaxis()->CenterTitle();
05780 
05781   TH1F *hShortLength = new TH1F("hShortLength","Short Attenuation Length",200,0,5.);
05782   hShortLength->GetXaxis()->SetTitle("Short Attenuation Length (m)");
05783   hShortLength->GetXaxis()->CenterTitle();
05784   hShortLength->GetYaxis()->SetTitle("");
05785   hShortLength->GetYaxis()->CenterTitle();
05786   hShortLength->SetLineColor(2);
05787   hShortLength->SetFillStyle(3015);
05788   hShortLength->SetFillColor(2);
05789   hShortLength->SetLineWidth(3);
05790   //hShortLength->SetBit(TH1::kCanRebin);
05791   
05792   TH2F *hShortLenDet = new TH2F("hShortLenDet","Short Attenuation Length",282,0,282,96,0,96);
05793   hShortLenDet->GetXaxis()->SetTitle("Plane NO.");
05794   hShortLenDet->GetXaxis()->CenterTitle();
05795   hShortLenDet->GetYaxis()->SetTitle("Strip NO.");
05796   hShortLenDet->GetYaxis()->CenterTitle();
05797 
05798   TH1F *hLongLength = new TH1F("hLongLength","Long Attenuation Length",200,0,50);
05799   hLongLength->GetXaxis()->SetTitle("Long Attenuation Length (m)");
05800   hLongLength->GetXaxis()->CenterTitle();
05801   hLongLength->GetYaxis()->SetTitle("");
05802   hLongLength->GetYaxis()->CenterTitle();
05803   hLongLength->SetLineColor(4);
05804   hLongLength->SetFillStyle(3015);
05805   hLongLength->SetFillColor(4);
05806   hLongLength->SetLineWidth(3);
05807   //hLongLength->SetBit(TH1::kCanRebin);
05808 
05809   TH2F *hLongLenDet = new TH2F("hLongLenDet","Long Attenuation Length",282,0,282,96,0,96);
05810   hLongLenDet->GetXaxis()->SetTitle("Plane NO.");
05811   hLongLenDet->GetXaxis()->CenterTitle();
05812   hLongLenDet->GetYaxis()->SetTitle("Strip NO.");
05813   hLongLenDet->GetYaxis()->CenterTitle();
05814 
05815   VldContext vldCtx(static_cast<Detector::Detector_t>(det),SimFlag::kData,ts);
05816   vldCtx.Print();
05817 
05818   DbiResultPtr<CalStripAtten> dbiCalStripAtten;
05819   UInt_t numRows = dbiCalStripAtten.NewQuery(vldCtx,task);
05820 
05821   MSG("LIPlexMaps",Msg::kInfo)
05822     <<"New DB query produced "<<numRows<<" rows"
05823     <<", using task="<<task<<endl
05824     <<"Looping over rows..."<<endl;
05825 
05826   //plane 0 is the first plane in the ND and is a bookend
05827   //plane 281 is the last plane in the ND
05828   //plane 1,11,21,31 is FI ?-view
05829   //plane 6,16,26,36 is FI ?-view
05830   //plane 3,5,7,9,  13,15,17,19,  23,25,27,29,  33,35,...PI ?-view
05831   //plane 2,4,  8,10,12,14,  18,20,22,24,  28,30,... PI ?-view
05832 
05833   //plane 116 is the last FI in the calorimeter
05834   //plane 120 is the last plane (PI) in the calorimeter
05835   //plane 121 is the first FI in the spectrometer  
05836   //plane 281 is the last ND plane
05837   
05838   //expect 
05839   //strips are 0-95(96), pl 8,10: 4-67(64), pl 7,9: 0-63(64)
05840   //plane 6 has low strips in PI part (I think 0-67)
05841   //plane 11 has high strips in PI part (I think -95)
05842 
05843   //strips TPos:
05844   //plane 6 goes -2.64 -> 1.32 m
05845   //plane 11 goes -1.32 -> 2.64 m
05846   
05847   //plane 4,8,10 goes -2.40 -> 0.24 m
05848   //plane 5,7,9 goes -0.24 -> 2.40 m
05849   
05850   //2.64 - 2.40 = 24 cm = 5.85 strips
05851   //the FI planes "stick out" by ~6 strips
05852 
05853   //Jaijie has 12000 rows
05854   //I believe that there are 68 scintillator strips in each PI plane 
05855   //but only 64 are read out
05856   //96 PI planes in the ND (thus 96*68=6528 strips in PI planes)
05857   //24 FI planes in ND calorimeter + 33 FI in spect. (24+33=57 total)
05858   //        =57*96=5472 strips in FI planes
05859 
05860   //total strips in ND (includes strips not read out) is
05861   //        5472+6528=12000 strips, which agrees with Jiajie's number
05862 
05863   //loop over the rows
05864   for(UInt_t i=0;i<numRows;i++) {
05865     const CalStripAtten* calStripAtten=dbiCalStripAtten.GetRow(i);
05866     Float_t Lambda1 = calStripAtten->GetLambda1();
05867     Float_t Lambda2 = calStripAtten->GetLambda2();
05868     Float_t frac1   = calStripAtten->GetFrac1();
05869     //Float_t frac1err = calStripAtten->GetFrac1Err();    
05870     //Float_t Lambda1err  = calStripAtten->GetLambda1Err();
05871     //Float_t Lambda2err  = calStripAtten->GetLambda2Err();
05872     PlexStripEndId seid = calStripAtten->GetStripEndId();
05873     Int_t plane = seid.GetPlane();
05874     Int_t strip = seid.GetStrip();
05875     //Int_t se = seid.GetEnd();
05876     
05877     hShortAmp->Fill(frac1);
05878     hLongAmp->Fill(1-frac1);
05879     hShortLength->Fill(Lambda1);
05880     hLongLength->Fill(Lambda2);
05881     hShortAmpDet->Fill(plane,strip,frac1);
05882     hLongAmpDet->Fill(plane,strip,1-frac1);
05883     hShortLenDet->Fill(plane,strip,Lambda1);
05884     hLongLenDet->Fill(plane,strip,Lambda2);
05885   }  
05886   
05887   TCanvas *cAtten = new TCanvas("cAtten","Attenuation Parameters",0,0,800,1000);
05888   cAtten->SetFillColor(0);
05889   cAtten->Divide(2,2);
05890   cAtten->cd(1);
05891   hShortAmp->Draw();
05892   cAtten->cd(2);
05893   hLongAmp->Draw();
05894   cAtten->cd(3);
05895   hShortLength->Draw();
05896   cAtten->cd(4);
05897   hLongLength->Draw();
05898   
05899   TCanvas *cDet = new TCanvas("cDet","Attenuation Parameters for All the Strips",0,0,800,1000);
05900   cDet->SetFillColor(0);
05901   cDet->Divide(2,2);
05902   cDet->cd(1);
05903   hShortAmpDet->Draw("colz");
05904   cDet->cd(2);
05905   hLongAmpDet->Draw("colz");
05906   cDet->cd(3);
05907   hShortLenDet->Draw("colz");
05908   cDet->cd(4);
05909   hLongLenDet->Draw("colz");
05910 
05911   cDet->Print("stripAtten.ps[");
05912   cDet->Print("stripAtten.ps");
05913   cAtten->Print("stripAtten.ps");
05914   cDet->Print("stripAtten.ps]");
05915 
05916   MSG("LIPlexMaps",Msg::kInfo)
05917       <<endl<<" ** Finished the ReadDbCalStripAtten() method... ** "<<endl;
05918 }

void LIPlexMaps::ReadDbCalStripToStrip ( Int_t  det,
VldTimeStamp  ts,
Int_t  task 
)

Definition at line 5379 of file LIPlexMaps.cxx.

References LILookup::FIRSTPLANE, LILookup::FIRSTSTRIP, PlexStripEndId::GetEnd(), PlexPlaneId::GetPlane(), CalStripToStrip::GetResponse(), CalStripToStrip::GetResponseErr(), DbiResultPtr< T >::GetRow(), PlexStripEndId::GetStrip(), CalStripToStrip::GetStripEndId(), SimFlag::kData, StripEnd::kEast, Msg::kInfo, StripEnd::kWest, LILookup::LASTPLANE, LILookup::LASTSTRIP, MSG, DbiResultPtr< T >::NewQuery(), VldContext::Print(), and LILookup::SetDetector().

05381 {
05382   MSG("LIPlexMaps",Msg::kInfo)
05383     <<endl<<" ** Running the ReadDbCalStripToStrip() method... ** "<<endl; 
05384   //this must go first
05385   this->SetDetector(det);
05386 
05387   const Int_t firstStripBin=FIRSTSTRIP-2;//-8;
05388   const Int_t lastStripBin=LASTSTRIP+2;//+9, 200;
05389   const Int_t stripBins=lastStripBin-firstStripBin;
05390 
05391   const Int_t firstPlaneBin=FIRSTPLANE-2;;
05392   const Int_t lastPlaneBin=LASTPLANE+2;
05393   const Int_t planeBins=lastPlaneBin-firstPlaneBin;
05394 
05395   TH2F* hStVsPlResp1=new TH2F("hStVsPlResp1","hStVsPlResp1",
05396                              planeBins,firstPlaneBin,lastPlaneBin,
05397                              stripBins,firstStripBin,lastStripBin);
05398   hStVsPlResp1->SetTitle("Detector Response (East side)");
05399   hStVsPlResp1->GetXaxis()->SetTitle("Plane");
05400   hStVsPlResp1->GetXaxis()->CenterTitle();
05401   hStVsPlResp1->GetYaxis()->SetTitle("Strip");
05402   hStVsPlResp1->GetYaxis()->CenterTitle();
05403   hStVsPlResp1->SetFillColor(0);
05404 
05405   TH2F* hStVsPlRespErr1=new TH2F("hStVsPlRespErr1","hStVsPlRespErr1",
05406                              planeBins,firstPlaneBin,lastPlaneBin,
05407                              stripBins,firstStripBin,lastStripBin);
05408   hStVsPlRespErr1->SetTitle("Detector Response Error (East side)");
05409   hStVsPlRespErr1->GetXaxis()->SetTitle("Plane");
05410   hStVsPlRespErr1->GetXaxis()->CenterTitle();
05411   hStVsPlRespErr1->GetYaxis()->SetTitle("Strip");
05412   hStVsPlRespErr1->GetYaxis()->CenterTitle();
05413   hStVsPlRespErr1->SetFillColor(0);
05414 
05415   TH2F* hStVsPlResp2=new TH2F("hStVsPlResp2","hStVsPlResp2",
05416                              planeBins,firstPlaneBin,lastPlaneBin,
05417                              stripBins,firstStripBin,lastStripBin);
05418   hStVsPlResp2->SetTitle("Detector Response (West side)");
05419   hStVsPlResp2->GetXaxis()->SetTitle("Plane");
05420   hStVsPlResp2->GetXaxis()->CenterTitle();
05421   hStVsPlResp2->GetYaxis()->SetTitle("Strip");
05422   hStVsPlResp2->GetYaxis()->CenterTitle();
05423   hStVsPlResp2->SetFillColor(0);
05424 
05425   TH2F* hStVsPlRespErr2=new TH2F("hStVsPlRespErr2","hStVsPlRespErr2",
05426                              planeBins,firstPlaneBin,lastPlaneBin,
05427                              stripBins,firstStripBin,lastStripBin);
05428   hStVsPlRespErr2->SetTitle("Detector Response Error (West side)");
05429   hStVsPlRespErr2->GetXaxis()->SetTitle("Plane");
05430   hStVsPlRespErr2->GetXaxis()->CenterTitle();
05431   hStVsPlRespErr2->GetYaxis()->SetTitle("Strip");
05432   hStVsPlRespErr2->GetYaxis()->CenterTitle();
05433   hStVsPlRespErr2->SetFillColor(0);
05434 
05435   TH1F *hResponse=new TH1F("hResponse","hResponse",300,-1,10);
05436   hResponse->GetXaxis()->SetTitle("Response of Stripends");
05437   hResponse->GetXaxis()->CenterTitle();
05438   hResponse->GetYaxis()->SetTitle("");
05439   hResponse->GetYaxis()->CenterTitle();
05440   hResponse->SetLineColor(2);
05441   hResponse->SetFillStyle(3015);
05442   hResponse->SetFillColor(2);
05443   hResponse->SetLineWidth(3);
05444   //hResponse->SetBit(TH1::kCanRebin);
05445 
05446   TH1F *hRespE=new TH1F("hRespE","hRespE",500,-1,10);
05447   hRespE->GetXaxis()->SetTitle("Response of East Stripends");
05448   hRespE->GetXaxis()->CenterTitle();
05449   hRespE->GetYaxis()->SetTitle("");
05450   hRespE->GetYaxis()->CenterTitle();
05451   hRespE->SetLineColor(4);
05452   hRespE->SetFillStyle(3015);
05453   hRespE->SetFillColor(4);
05454   hRespE->SetLineWidth(3);
05455   //hRespE->SetBit(TH1::kCanRebin);
05456 
05457   TH1F *hRespW=new TH1F("hRespW","hRespW",500,-1,10);
05458   hRespW->GetXaxis()->SetTitle("Response of West Stripends");
05459   hRespW->GetXaxis()->CenterTitle();
05460   hRespW->GetYaxis()->SetTitle("");
05461   hRespW->GetYaxis()->CenterTitle();
05462   hRespW->SetLineColor(2);
05463   hRespW->SetFillStyle(3015);
05464   hRespW->SetFillColor(2);
05465   hRespW->SetLineWidth(3);
05466   //hRespW->SetBit(TH1::kCanRebin);
05467 
05468   TH1F *hResponseErr=new TH1F("hResponseErr","hResponseErr",
05469                               200,-0.02,0.2);
05470   hResponseErr->GetXaxis()->SetTitle("ResponseErr of Stripends");
05471   hResponseErr->GetXaxis()->CenterTitle();
05472   hResponseErr->GetYaxis()->SetTitle("");
05473   hResponseErr->GetYaxis()->CenterTitle();
05474   hResponseErr->SetLineColor(3);
05475   hResponseErr->SetFillStyle(3015);
05476   hResponseErr->SetFillColor(3);
05477   hResponseErr->SetLineWidth(3);
05478   //hResponseErr->SetBit(TH1::kCanRebin);
05479 
05480   TProfile* pSigCorVsPlane=new TProfile
05481     ("pSigCorVsPlane","pSigCorVsPlane",
05482      planeBins,firstPlaneBin,lastPlaneBin);
05483   pSigCorVsPlane->GetXaxis()->SetTitle("Plane");
05484   pSigCorVsPlane->GetXaxis()->CenterTitle();
05485   pSigCorVsPlane->GetYaxis()->SetTitle("SigCor");
05486   pSigCorVsPlane->GetYaxis()->CenterTitle();
05487   pSigCorVsPlane->SetLineColor(2);
05488   pSigCorVsPlane->SetLineWidth(3);
05489   //pSigCorVsPlane->SetBit(TH1::kCanRebin);
05490 
05491   TProfile* pSigCorVsPlaneCoarse=new TProfile
05492     ("pSigCorVsPlaneCoarse","pSigCorVsPlaneCoarse",6,0,60);
05493   pSigCorVsPlaneCoarse->GetXaxis()->SetTitle("Plane");
05494   pSigCorVsPlaneCoarse->GetXaxis()->CenterTitle();
05495   pSigCorVsPlaneCoarse->GetYaxis()->SetTitle("SigCor");
05496   pSigCorVsPlaneCoarse->GetYaxis()->CenterTitle();
05497   pSigCorVsPlaneCoarse->SetLineColor(2);
05498   pSigCorVsPlaneCoarse->SetLineWidth(3);
05499   //pSigCorVsPlaneCoarse->SetBit(TH1::kCanRebin);
05500 
05501   TProfile* pSigCorVsPlane1=new TProfile
05502     ("pSigCorVsPlane1","pSigCorVsPlane1",
05503      planeBins,firstPlaneBin,lastPlaneBin);
05504   pSigCorVsPlane1->GetXaxis()->SetTitle("Plane");
05505   pSigCorVsPlane1->GetXaxis()->CenterTitle();
05506   pSigCorVsPlane1->GetYaxis()->SetTitle("SigCor");
05507   pSigCorVsPlane1->GetYaxis()->CenterTitle();
05508   pSigCorVsPlane1->SetLineColor(2);
05509   pSigCorVsPlane1->SetLineWidth(3);
05510   //pSigCorVsPlane1->SetBit(TH1::kCanRebin);
05511 
05512   TProfile* pSigCorVsPlane2=new TProfile
05513     ("pSigCorVsPlane2","pSigCorVsPlane2",
05514      planeBins,firstPlaneBin,lastPlaneBin);
05515   pSigCorVsPlane2->GetXaxis()->SetTitle("Plane");
05516   pSigCorVsPlane2->GetXaxis()->CenterTitle();
05517   pSigCorVsPlane2->GetYaxis()->SetTitle("SigCor");
05518   pSigCorVsPlane2->GetYaxis()->CenterTitle();
05519   pSigCorVsPlane2->SetLineColor(2);
05520   pSigCorVsPlane2->SetLineWidth(3);
05521   //pSigCorVsPlane2->SetBit(TH1::kCanRebin);
05522 
05523   TProfile* pSigCorVsStrip=new TProfile
05524     ("pSigCorVsStrip","pSigCorVsStrip",
05525      stripBins,firstStripBin,lastStripBin);
05526   pSigCorVsStrip->GetXaxis()->SetTitle("Strip");
05527   pSigCorVsStrip->GetXaxis()->CenterTitle();
05528   pSigCorVsStrip->GetYaxis()->SetTitle("SigCor");
05529   pSigCorVsStrip->GetYaxis()->CenterTitle();
05530   pSigCorVsStrip->SetLineColor(4);
05531   pSigCorVsStrip->SetLineWidth(3);
05532   //pSigCorVsStrip->SetBit(TH1::kCanRebin);
05533 
05534   TProfile* pSigCorVsStripCoarse=new TProfile
05535     ("pSigCorVsStripCoarse","pSigCorVsStripCoarse",12,0,24);
05536   pSigCorVsStripCoarse->GetXaxis()->SetTitle("Strip");
05537   pSigCorVsStripCoarse->GetXaxis()->CenterTitle();
05538   pSigCorVsStripCoarse->GetYaxis()->SetTitle("SigCor");
05539   pSigCorVsStripCoarse->GetYaxis()->CenterTitle();
05540   pSigCorVsStripCoarse->SetLineColor(2);
05541   pSigCorVsStripCoarse->SetLineWidth(3);
05542   //pSigCorVsStripCoarse->SetBit(TH1::kCanRebin);
05543 
05544   TProfile* pSigCorVsStrip1=new TProfile
05545     ("pSigCorVsStrip1","pSigCorVsStrip1",
05546      stripBins,firstStripBin,lastStripBin);
05547   pSigCorVsStrip1->GetXaxis()->SetTitle("Strip");
05548   pSigCorVsStrip1->GetXaxis()->CenterTitle();
05549   pSigCorVsStrip1->GetYaxis()->SetTitle("SigCor");
05550   pSigCorVsStrip1->GetYaxis()->CenterTitle();
05551   pSigCorVsStrip1->SetLineColor(4);
05552   pSigCorVsStrip1->SetLineWidth(3);
05553   //pSigCorVsStrip1->SetBit(TH1::kCanRebin);
05554 
05555   TProfile* pSigCorVsStrip2=new TProfile
05556     ("pSigCorVsStrip2","pSigCorVsStrip2",
05557      stripBins,firstStripBin,lastStripBin);
05558   pSigCorVsStrip2->GetXaxis()->SetTitle("Strip");
05559   pSigCorVsStrip2->GetXaxis()->CenterTitle();
05560   pSigCorVsStrip2->GetYaxis()->SetTitle("SigCor");
05561   pSigCorVsStrip2->GetYaxis()->CenterTitle();
05562   pSigCorVsStrip2->SetLineColor(4);
05563   pSigCorVsStrip2->SetLineWidth(3);
05564   //pSigCorVsStrip2->SetBit(TH1::kCanRebin);
05565 
05566   Float_t avRespSpect=0;
05567   Float_t avCorSpect=0;
05568   Float_t avRespSpectCounter=0;
05569   Float_t avRespCalor=0;
05570   Float_t avCorCalor=0;
05571   Float_t avRespCalorCounter=0;
05572   
05573   map<Int_t,Float_t> mStripResp1;
05574   map<Int_t,Float_t> mStripResp2;
05575 
05576   VldContext vldCtx(static_cast<Detector::Detector_t>(det),
05577                     SimFlag::kData,ts);
05578   vldCtx.Print();
05579 
05580   DbiResultPtr<CalStripToStrip> dbiCalStripToStrip;  
05581   UInt_t numRows=dbiCalStripToStrip.NewQuery(vldCtx,task);
05582 
05583   MSG("LIPlexMaps",Msg::kInfo)
05584     <<"New DB query produced "<<numRows<<" rows"
05585     <<", using task="<<task<<endl
05586     <<"Looping over rows..."<<endl;
05587 
05588   //loop over the rows
05589   for(UInt_t i=0;i<numRows;i++) {
05590     const CalStripToStrip* calStripToStrip=dbiCalStripToStrip.GetRow(i);
05591 
05592     Float_t response=calStripToStrip->GetResponse();
05593     Float_t responseErr=calStripToStrip->GetResponseErr();
05594     PlexStripEndId seid=calStripToStrip->GetStripEndId();
05595     Int_t plane=seid.GetPlane();
05596     Int_t strip=seid.GetStrip();
05597     Int_t se=seid.GetEnd();
05598 
05599     if (plane==2){
05600       if (se==1){
05601         mStripResp1[strip]=response;
05602       }
05603       else if (se==2){
05604         mStripResp2[strip]=response;
05605       }
05606     }
05607     
05608     pSigCorVsStrip->Fill(strip,response);
05609     pSigCorVsPlane->Fill(plane,response);
05610 
05611     if (se==StripEnd::kEast){
05612       hRespE->Fill(response);
05613       pSigCorVsStrip1->Fill(strip,response);
05614       pSigCorVsPlane1->Fill(plane,response);
05615       hStVsPlResp1->Fill(plane,strip,response);
05616       hStVsPlRespErr1->Fill(plane,strip,responseErr);
05617     }
05618     else if (se==StripEnd::kWest){
05619       hRespW->Fill(response);
05620       pSigCorVsStrip2->Fill(strip,response);
05621       pSigCorVsPlane2->Fill(plane,response);
05622       hStVsPlResp2->Fill(plane,strip,response);
05623       hStVsPlRespErr2->Fill(plane,strip,responseErr);
05624 
05625       if (plane>120) {
05626         avRespSpect+=response;
05627         avCorSpect+=1./response;
05628         avRespSpectCounter++;
05629       }
05630       else {
05631         avRespCalor+=response;
05632         avCorCalor+=1./response;
05633         avRespCalorCounter++;
05634       }
05635     }
05636     else cout<<"Ahhhhh"<<endl;
05637 
05638     hResponse->Fill(response);
05639     hResponseErr->Fill(responseErr);
05640   }
05641 
05642   MSG("LIPlexMaps",Msg::kInfo)
05643     <<"Av response="<<hResponse->GetMean()
05644     <<" (N="<<hResponse->GetEntries()<<")"<<endl
05645     <<"  East av response="<<hRespE->GetMean()
05646     <<" (N="<<hRespE->GetEntries()<<")"<<endl
05647     <<"  West av response="<<hRespW->GetMean()
05648     <<" (N="<<hRespW->GetEntries()<<")"<<endl;
05649 
05650   //calc av
05651   avRespSpect/=avRespSpectCounter;
05652   avCorSpect/=avRespSpectCounter;
05653   avRespCalor/=avRespCalorCounter;
05654   avCorCalor/=avRespCalorCounter;
05655 
05656   MSG("LIPlexMaps",Msg::kInfo)
05657     <<endl
05658     <<"Calorimeter av response   ="<<avRespCalor
05659     <<"(N="<<avRespCalorCounter<<")"
05660     <<endl
05661     <<"Calorimeter av correction ="<<avCorCalor
05662     <<endl
05663     <<"Spectrometer av response  ="<<avRespSpect
05664     <<"(N="<<avRespSpectCounter<<")"
05665     <<endl
05666     <<"Spectrometer av correction="<<avCorSpect
05667     <<endl;
05668 
05669   for (UInt_t i=0;i<mStripResp2.size();i++){
05670     cout<<"Strip="<<i<<", response 1="<<mStripResp1[i]
05671         <<" response 2="<<mStripResp2[i]<<endl;
05672   }
05673 
05674   TCanvas *cResponse=new TCanvas
05675     ("cResponse","cResponse",0,0,1000,1000);
05676   cResponse->SetFillColor(0);
05677   cResponse->Divide(2,1);
05678   cResponse->cd(1);
05679   hResponse->Draw();
05680   cResponse->cd(2);
05681   hResponseErr->Draw();
05682 
05683   TCanvas *cPlSt=new TCanvas
05684     ("cPlSt","cPlSt",0,0,1000,1000);
05685   cPlSt->SetFillColor(0);
05686   cPlSt->Divide(1,2);
05687   cPlSt->cd(1);
05688   pSigCorVsPlane->Draw();
05689   cPlSt->cd(2);
05690   pSigCorVsStrip->Draw();
05691 
05692   TCanvas *cPlSt1_2=new TCanvas
05693     ("cPlSt1_2","cPlSt1_2",0,0,1000,1000);
05694   cPlSt1_2->SetFillColor(0);
05695   cPlSt1_2->Divide(2,2);
05696   cPlSt1_2->cd(1);
05697   pSigCorVsPlane1->Draw();
05698   cPlSt1_2->cd(2);
05699   pSigCorVsPlane2->Draw();
05700   cPlSt1_2->cd(3);
05701   pSigCorVsStrip1->Draw();
05702   cPlSt1_2->cd(4);
05703   pSigCorVsStrip2->Draw();
05704 
05705   TCanvas *cStVsPlResp=new TCanvas
05706     ("cStVsPlResp","cStVsPlResp",0,0,1000,1000);
05707   cStVsPlResp->SetFillColor(0);
05708   cStVsPlResp->Divide(1,2);
05709   cStVsPlResp->cd(1);
05710   hStVsPlResp1->Draw("colz");
05711   cStVsPlResp->cd(2);
05712   hStVsPlResp2->Draw("colz");
05713 
05714   TCanvas *cStVsPlRespErr=new TCanvas
05715     ("cStVsPlRespErr","cStVsPlRespErr",0,0,1000,1000);
05716   cStVsPlRespErr->SetFillColor(0);
05717   cStVsPlRespErr->Divide(1,2);
05718   cStVsPlRespErr->cd(1);  
05719   hStVsPlRespErr1->SetMaximum(0.12);
05720   hStVsPlRespErr2->SetMaximum(0.12);
05721   hStVsPlRespErr1->Draw("colz");
05722   cStVsPlRespErr->cd(2);
05723   hStVsPlRespErr2->Draw("colz");
05724 
05725   cout<<"Printing histos..."<<endl;
05726   cResponse->Print("stripToStrip.ps[");
05727   cResponse->Print("stripToStrip.ps");
05728   cStVsPlResp->Print("stripToStrip.ps");
05729   cStVsPlRespErr->Print("stripToStrip.ps");
05730   cPlSt->Print("stripToStrip.ps");
05731   cPlSt1_2->Print("stripToStrip.ps");
05732   cResponse->Print("stripToStrip.ps]");
05733   cout<<"Finished printing histos"<<endl;
05734 
05735   MSG("LIPlexMaps",Msg::kInfo)
05736     <<endl<<" ** Finished the ReadDbCalStripToStrip() method... **"<<endl; 
05737 }

Double_t LIPlexMaps::ReadDbGainAverage ( Detector::Detector_t  det,
VldTimeStamp  ts,
VldTimeStamp end = 0,
VldTimeStamp start = 0 
)

Returns an average detector gain response.

Definition at line 6855 of file LIPlexMaps.cxx.

References CalADCtoPEs::GetGain(), DbiResultPtr< T >::GetRow(), VldRange::GetTimeEnd(), VldRange::GetTimeStart(), DbiResultPtr< T >::GetValidityRec(), DbiValidityRec::GetVldRange(), SimFlag::kData, Detector::kNear, and DbiResultPtr< T >::NewQuery().

06856 {
06857   // Set up the validity context
06858   // Would you ever wnat to get gains out of MC?
06859   VldContext vldCtx(det, SimFlag::kData, ts);
06860 //  vldCtx.Print();
06861   
06862   // and the database
06863   DbiResultPtr<CalADCtoPEs> dbiCalADCtoPEs;
06864   
06865   // Work out the task....
06866   Int_t task = 0;
06867   if (det == Detector::kNear) task = 1;
06868   
06869   // Run the query
06870   UInt_t numRows = dbiCalADCtoPEs.NewQuery(vldCtx,task);
06871 
06872   // Now run over each row in the query, keeping a running average  
06873   Double_t gainaverage = 0.0;
06874   for (UInt_t i = 0; i < numRows; ++i)
06875   {
06876     // Grab the query row and extract information
06877     const CalADCtoPEs* calAdcToPe = dbiCalADCtoPEs.GetRow(i);
06878     Float_t gain = calAdcToPe->GetGain();
06879 
06880     gainaverage += (gain - gainaverage) / (i+1);    
06881   }
06882   
06883   // If we were passed an 'end' pointer, we want it to be filled with the end of the validity
06884   VldTimeStamp endtime = dbiCalADCtoPEs.GetValidityRec()->GetVldRange().GetTimeEnd();
06885   VldTimeStamp starttime = dbiCalADCtoPEs.GetValidityRec()->GetVldRange().GetTimeStart();
06886   // cout << "End of validity record: " << endtime.AsString() << endl;
06887   if (end) *end = endtime;
06888   if (start) *start = starttime;
06889   return gainaverage;
06890 }

TH1D * LIPlexMaps::ReadDbGains ( Detector::Detector_t  det,
VldTimeStamp  ts 
)

Returns a histogram filled with all the gain values from a timestamp

Definition at line 6895 of file LIPlexMaps.cxx.

References CalADCtoPEs::GetGain(), DbiResultPtr< T >::GetRow(), SimFlag::kData, Detector::kNear, and DbiResultPtr< T >::NewQuery().

06896 {
06897   // Set up the validity context
06898   VldContext vldCtx(det, SimFlag::kData, ts);
06899   // and the database
06900   DbiResultPtr<CalADCtoPEs> dbiCalADCtoPEs;
06901 
06902   // Work out the task....
06903   Int_t task = 0;
06904   if (det == Detector::kNear) task = 1;
06905 
06906   // Run the query
06907   UInt_t numRows = dbiCalADCtoPEs.NewQuery(vldCtx,task);
06908 
06909   TH1D *detgains = new TH1D("detgains", "detgains", 200, 0, 200);
06910   if (det == Detector::kNear) {
06911     detgains->SetNameTitle("neargains", "Near Detector Gains");
06912   } else {
06913     detgains->SetNameTitle("fargains", "Far Detector Gains");    
06914   }
06915   // Now run over each row in the query, keeping a running average  
06916   for (UInt_t i = 0; i < numRows; ++i)
06917   {
06918     const CalADCtoPEs* calAdcToPe = dbiCalADCtoPEs.GetRow(i);
06919     Float_t gain = calAdcToPe->GetGain();
06920     detgains->Fill(gain);
06921   }
06922 
06923   return detgains;
06924 }

void LIPlexMaps::ReadDbGains ( Int_t  det,
SimFlag::ESimFlag  simFlag,
VldTimeStamp  ts,
std::string  runNumber,
std::string  sAgg,
Int_t  task = 0 
)

Definition at line 6362 of file LIPlexMaps.cxx.

References LIPmt::AddMultiPoint(), bfld::AsString(), VldTimeStamp::AsString(), Draw(), LILookup::FIRSTCRATE, LILookup::FIRSTSTRIP, fLookup, Form(), fS, RawChannelId::GetCrate(), CalADCtoPE::GetGain(), CalADCtoPEs::GetGain(), CalADCtoPE::GetGainErr(), CalADCtoPEs::GetGainErr(), PlexMuxBoxId::GetInRack(), PlexMuxBoxId::GetNumericMuxBox(), PlexPixelSpotId::GetPixel(), LIPmt::GetPixelGain(), PlexHandle::GetPixelSpotId(), LIPmt::GetPmtFaceMap(), PlexMuxBoxId::GetRackBay(), PlexMuxBoxId::GetRackLevel(), PlexHandle::GetRawChannelId(), DbiResultPtr< T >::GetRow(), CalADCtoPE::GetSEIDkey(), CalADCtoPEs::GetSEIDkey(), CalADCtoPE::GetSPEWidth(), CalADCtoPEs::GetSPEWidth(), CalADCtoPEs::GetSPEWidthErr(), PlexPixelSpotId::GetSpot(), CalADCtoPE::GetStripEndId(), PlexPixelSpotId::GetTube(), RawChannelId::GetVaAdcSel(), RawChannelId::GetVaChannel(), RawChannelId::GetVaChip(), RawChannelId::GetVarcId(), RawChannelId::GetVmm(), LIPmt::Initialise(), MsgService::Instance(), LIPmt::IsEmpty(), it, Detector::kCalDet, Msg::kDebug, Detector::kFar, Msg::kInfo, Detector::kNear, ElecType::kQIE, ElecType::kVA, StripEnd::kWest, LILookup::LASTCRATE, LILookup::LASTSTRIP, MSG, DbiResultPtr< T >::NewQuery(), LILookup::NUMSIDES, LILookup::NUMSTRIPS, VldContext::Print(), print(), LILookup::SetDetector(), LILookup::SetPbPlanes(), and LILookup::UnencodePlnStripEndKey().

06364 {
06365 
06366   MSG("LIPlexMaps",Msg::kInfo)
06367     <<endl<<" ** Running the ReadDbGains() method... ** "<<endl; 
06368 
06369   //set up useful string
06370   string fileName=runNumber+"GainsDB.dat";
06371   //open the file
06372   ofstream TextFile(fileName.c_str());
06373 
06374   //this must go first
06375   this->SetDetector(det);
06376 
06377   //create pmts to calc detector average
06378   LIPmt avM64SE1;
06379   LIPmt avM64SE2;
06380   LIPmt avM16VA0SE1;
06381   LIPmt avM16VA0SE2;
06382   LIPmt avM16VA1SE1;
06383   LIPmt avM16VA1SE2;
06384   LIPmt avM16VA2SE1;
06385   LIPmt avM16VA2SE2;
06386 
06387   //initialise pmts
06388   avM64SE1.Initialise(64,1);
06389   avM64SE2.Initialise(64,1);
06390   avM16VA0SE1.Initialise(16,8);
06391   avM16VA0SE2.Initialise(16,8);
06392   avM16VA1SE1.Initialise(16,8);
06393   avM16VA1SE2.Initialise(16,8);
06394   avM16VA2SE1.Initialise(16,8);
06395   avM16VA2SE2.Initialise(16,8);
06396 
06397   //store pointers to all the pmts in a vector
06398   vector<LIPmt*> vPmts;
06399   vPmts.push_back(&avM64SE1);
06400   vPmts.push_back(&avM64SE2);
06401   vPmts.push_back(&avM16VA0SE1);
06402   vPmts.push_back(&avM16VA0SE2);
06403   vPmts.push_back(&avM16VA1SE1);
06404   vPmts.push_back(&avM16VA1SE2);
06405   vPmts.push_back(&avM16VA2SE1);
06406   vPmts.push_back(&avM16VA2SE2);
06407 
06408   Int_t* planeMax=new Int_t[NUMCRATES];
06409   Int_t* planeMin=new Int_t[NUMCRATES];
06410   fLookup.SetPbPlanes(planeMin,planeMax,det);
06411 
06412   //const Int_t firstStripBin=FIRSTSTRIP-2;//-8;
06413   //const Int_t lastStripBin=LASTSTRIP+2;//+9, 200;
06414   const Int_t firstStripBin=FIRSTSTRIP-8; //down to -8
06415   const Int_t lastStripBin=LASTSTRIP+9; //up to 200
06416   const Int_t bins=lastStripBin-firstStripBin;
06417 
06418   string sConstantBit="";
06419 
06420   MSG("LIAnalysis",Msg::kInfo)
06421     <<"sConstantBit="<<sConstantBit<<endl;
06422 
06423   TH2F **hStripVsPlaneGain=0;
06424   hStripVsPlaneGain= new TH2F*[NUMCRATES];
06425   for (Int_t i=0;i<NUMCRATES;i++){
06426     string sPb=Form("%d",i);
06427     string sTs=ts.AsString("s");
06428     //fS="Gains (Crate "+sPb+", "+sTs+")";
06429     fS="Gains (Crate "+sPb+")";
06430     hStripVsPlaneGain[i]=new TH2F(fS.c_str(),fS.c_str(),
06431                                   planeMax[i]-planeMin[i],
06432                                   planeMin[i],planeMax[i],
06433                                   bins,firstStripBin,lastStripBin);
06434     hStripVsPlaneGain[i]->GetXaxis()->SetTitle("Plane");
06435     hStripVsPlaneGain[i]->GetXaxis()->CenterTitle();
06436     hStripVsPlaneGain[i]->GetYaxis()->SetTitle("Strip");
06437     hStripVsPlaneGain[i]->GetYaxis()->CenterTitle();
06438     hStripVsPlaneGain[i]->SetFillColor(0);
06439     //hStripVsPlaneGain[i]->SetBit(TH1::kCanRebin);
06440   }
06441 
06442   TH2F **hAvDetGains=0;
06443   hAvDetGains= new TH2F*[NUMCRATES];
06444   for (Int_t i=0;i<NUMCRATES;i++){
06445     string sPb=Form("%d",i);
06446     string sTs=ts.AsString("s");
06447     //fS="Av Detector Gains (Crate "+sPb+", "+sTs+")";
06448     fS="Av Detector Gains (Crate "+sPb+")";
06449     hAvDetGains[i]=new TH2F(fS.c_str(),fS.c_str(),
06450                                   planeMax[i]-planeMin[i],
06451                                   planeMin[i],planeMax[i],
06452                                   bins,firstStripBin,lastStripBin);
06453     hAvDetGains[i]->GetXaxis()->SetTitle("Plane");
06454     hAvDetGains[i]->GetXaxis()->CenterTitle();
06455     hAvDetGains[i]->GetYaxis()->SetTitle("Strip");
06456     hAvDetGains[i]->GetYaxis()->CenterTitle();
06457     hAvDetGains[i]->SetFillColor(0);
06458     //hAvDetGains[i]->SetBit(TH1::kCanRebin);
06459   }
06460 
06461   TH2F **hStripVsPlaneGainErr=0;
06462   hStripVsPlaneGainErr= new TH2F*[NUMCRATES];
06463   for (Int_t i=0;i<NUMCRATES;i++){
06464     string sPb=Form("%d",i);
06465     fS="Gain Errors (Crate "+sPb+")";
06466     hStripVsPlaneGainErr[i]=new TH2F(fS.c_str(),fS.c_str(),
06467                                      planeMax[i]-planeMin[i],
06468                                      planeMin[i],planeMax[i],
06469                                      bins,firstStripBin,lastStripBin);
06470     hStripVsPlaneGainErr[i]->GetXaxis()->SetTitle("Plane");
06471     hStripVsPlaneGainErr[i]->GetXaxis()->CenterTitle();
06472     hStripVsPlaneGainErr[i]->GetYaxis()->SetTitle("Strip");
06473     hStripVsPlaneGainErr[i]->GetYaxis()->CenterTitle();
06474     hStripVsPlaneGainErr[i]->SetFillColor(0);
06475     //hStripVsPlaneGainErr[i]->SetBit(TH1::kCanRebin);
06476   }
06477 
06478   TH2F **hStripVsPlaneSPEWidth=0;
06479   hStripVsPlaneSPEWidth= new TH2F*[NUMCRATES];
06480   for (Int_t i=0;i<NUMCRATES;i++){
06481     string sPb=Form("%d",i);
06482     fS="Single PE Width (Crate "+sPb+")";
06483     hStripVsPlaneSPEWidth[i]=new TH2F(fS.c_str(),fS.c_str(),
06484                                      planeMax[i]-planeMin[i],
06485                                      planeMin[i],planeMax[i],
06486                                      bins,firstStripBin,lastStripBin);
06487     hStripVsPlaneSPEWidth[i]->GetXaxis()->SetTitle("Plane");
06488     hStripVsPlaneSPEWidth[i]->GetXaxis()->CenterTitle();
06489     hStripVsPlaneSPEWidth[i]->GetYaxis()->SetTitle("Strip");
06490     hStripVsPlaneSPEWidth[i]->GetYaxis()->CenterTitle();
06491     hStripVsPlaneSPEWidth[i]->SetFillColor(0);
06492     //hStripVsPlaneSPEWidth[i]->SetBit(TH1::kCanRebin);
06493   }
06494 
06495   TH1F *hGains=new TH1F("hGains","hGains",200,-1,200);
06496   hGains->GetXaxis()->SetTitle("Response of Stripends");
06497   hGains->GetXaxis()->CenterTitle();
06498   hGains->GetYaxis()->SetTitle("");
06499   hGains->GetYaxis()->CenterTitle();
06500   hGains->SetLineColor(2);
06501   hGains->SetFillStyle(3015);
06502   hGains->SetFillColor(2);
06503   hGains->SetLineWidth(3);
06504   //hGains->SetBit(TH1::kCanRebin);
06505 
06506   TH1F *hGainsAll=new TH1F("hGainsAll","hGainsAll",400,-1,300);
06507   hGainsAll->GetXaxis()->SetTitle("Response of Stripends");
06508   hGainsAll->GetXaxis()->CenterTitle();
06509   hGainsAll->GetYaxis()->SetTitle("");
06510   hGainsAll->GetYaxis()->CenterTitle();
06511   hGainsAll->SetLineColor(2);
06512   hGainsAll->SetFillStyle(3015);
06513   hGainsAll->SetFillColor(2);
06514   hGainsAll->SetLineWidth(3);
06515   hGainsAll->SetBit(TH1::kCanRebin);
06516 
06517   VldContext vldCtx(static_cast<Detector::Detector_t>(det),
06518                     simFlag,ts);
06519   vldCtx.Print();
06520 
06521   //create a plex handle
06522   PlexHandle plexHandle(vldCtx);
06523 
06524   DbiResultPtr<CalADCtoPE> dbiCalADCtoPE;
06525   DbiResultPtr<CalADCtoPEs> dbiCalADCtoPEs;
06526 
06527   UInt_t numRows=dbiCalADCtoPE.NewQuery(vldCtx,task);
06528   if(sAgg!="-1") numRows=dbiCalADCtoPEs.NewQuery(vldCtx,task);
06529 
06530   MSG("LIPlexMaps",Msg::kInfo)<<endl
06531     <<"New DB query produced "<<numRows<<" rows"<<endl
06532     <<"Looping over rows..."<<endl;
06533 
06534   //loop over the rows
06535   for(UInt_t i=0;i<numRows;i++) {
06536 
06537     Float_t gain, gainErr, SPEWidth, SPEWidthErr;
06538     Int_t seId;
06539     UInt_t seidkey;
06540     
06541     if(sAgg=="-1") {
06542       const CalADCtoPE* calAdcToPe = dbiCalADCtoPE.GetRow(i);
06543       gain=calAdcToPe->GetGain();
06544       gainErr=calAdcToPe->GetGainErr();
06545       SPEWidth=calAdcToPe->GetSPEWidth();
06546       seId=calAdcToPe->GetStripEndId();
06547       seidkey=calAdcToPe->GetSEIDkey();
06548     } else {
06549       const CalADCtoPEs* calAdcToPe = dbiCalADCtoPEs.GetRow(i);
06550       gain=calAdcToPe->GetGain();
06551       gainErr=calAdcToPe->GetGainErr();
06552       SPEWidth=calAdcToPe->GetSPEWidth();
06553       SPEWidthErr=calAdcToPe->GetSPEWidthErr();
06554       seidkey=calAdcToPe->GetSEIDkey();
06555     }
06556 
06557     Int_t plane=-1;
06558     Int_t strip=-1;
06559     Int_t end=-1;
06560     fLookup.UnencodePlnStripEndKey(seidkey,static_cast<Detector::
06561                                    Detector_t>(det),plane,strip,end);
06562 
06563     //fill the gains histos
06564     hGains->Fill(gain);
06565     hGainsAll->Fill(gain);
06566 
06567     //get stripend id
06568     PlexStripEndId seid(static_cast<Detector::Detector_t>(det),
06569                         plane,strip,
06570                         static_cast<StripEnd::EStripEnd>(end));
06571     //get pixel spot id
06572     PlexPixelSpotId pixSpotId=plexHandle.GetPixelSpotId(seid);
06573 
06574     MSG("LIPlexMaps",Msg::kDebug)
06575       <<"pl="<<plane<<", st="<<strip<<", end="<<end
06576       <<", pix="<<pixSpotId.GetPixel()
06577       <<", pixSpot="<<pixSpotId.GetSpot()
06578       <<endl;
06579 
06580     ElecType::Elec_t elecType=plexHandle.GetRawChannelId(seid).
06581       GetElecType();
06582     Int_t vaChip=plexHandle.GetRawChannelId(seid).GetVaChip();
06583 
06584     //add point to average detector PMT
06585     //depending on electype and va chip
06586     if (elecType==ElecType::kQIE){
06587       if (plane%2==1) avM64SE1.AddMultiPoint(pixSpotId.GetPixel(),
06588                                              pixSpotId.GetSpot(),gain);
06589       else if (plane%2==0) avM64SE2.AddMultiPoint(pixSpotId.GetPixel(),
06590                                                   pixSpotId.GetSpot(),gain);
06591     }
06592     else if (elecType==ElecType::kVA){
06593       if (vaChip==0){
06594         if (end==1) avM16VA0SE1.AddMultiPoint(pixSpotId.GetPixel(),
06595                                               pixSpotId.GetSpot(),gain);
06596         if (end==2) avM16VA0SE2.AddMultiPoint(pixSpotId.GetPixel(),
06597                                               pixSpotId.GetSpot(),gain);
06598       }
06599       else if (vaChip==1){
06600         if (end==1) avM16VA1SE1.AddMultiPoint(pixSpotId.GetPixel(),
06601                                               pixSpotId.GetSpot(),gain);
06602         if (end==2) avM16VA1SE2.AddMultiPoint(pixSpotId.GetPixel(),
06603                                               pixSpotId.GetSpot(),gain);
06604       }
06605       else if (vaChip==2){
06606         if (end==1) avM16VA2SE1.AddMultiPoint(pixSpotId.GetPixel(),
06607                                               pixSpotId.GetSpot(),gain);
06608         if (end==2) avM16VA2SE2.AddMultiPoint(pixSpotId.GetPixel(),
06609                                               pixSpotId.GetSpot(),gain);
06610       }
06611     }
06612 
06613     PlexPixelSpotId pixelId=plexHandle.GetPixelSpotId(seid);
06614     //Some values to be written out
06615     Int_t crate=plexHandle.GetRawChannelId(seid).GetCrate();
06616     Int_t Varc=plexHandle.GetRawChannelId(seid).GetVarcId();
06617     Int_t Vmm=plexHandle.GetRawChannelId(seid).GetVmm();
06618     //Int_t vaChip=plexhandle->GetRawChannelId(seid).GetVaChip();
06619     Int_t Vaadc=plexHandle.GetRawChannelId(seid).GetVaAdcSel();
06620     Int_t channel=plexHandle.GetRawChannelId(seid).GetVaChannel();
06621     Int_t pixel=static_cast<Int_t>(pixelId.GetPixel());
06622     //Int_t channel=static_cast<Int_t>(pixelId.GetChannel());
06623     Int_t inRack=static_cast<Int_t>(pixelId.GetInRack());
06624     Int_t numericMuxBox=static_cast<Int_t>(pixelId.GetNumericMuxBox());
06625     Int_t rackBay=static_cast<Int_t>(pixelId.GetRackBay());
06626     Char_t rackLevel=static_cast<Char_t>(pixelId.GetRackLevel());
06627     Int_t tube=static_cast<Int_t>(pixelId.GetTube());
06628 
06629     //write to file
06630     TextFile<<plane<<"\t"<<strip<< "\t"<<end
06631             <<"\t" <<gain<<"\t" <<gainErr<<"\t" <<SPEWidth<<"\t"<<crate<<"\t"<<Varc<<"\t"<<Vmm<<"\t"<<Vaadc<<"\t"<<channel<<"\t"<<pixel
06632             <<"\t"<<vaChip<<"\t"<<inRack<<"\t"<<numericMuxBox
06633             <<"\t"<<rackBay<<"\t"<<rackLevel<<"\t"<<tube<<endl;
06634 
06635     if (crate>=FIRSTCRATE && crate<=LASTCRATE){
06636       hStripVsPlaneGainErr[crate]->Fill(plane,strip,gainErr);
06637       hStripVsPlaneGain[crate]->Fill(plane,strip,gain);
06638       hStripVsPlaneSPEWidth[crate]->Fill(plane,strip,SPEWidth);
06639     }
06640 
06641     Bool_t print=false;
06642     if (det==Detector::kCalDet) print=true;
06643     else if (det==Detector::kFar && 
06644              MsgService::Instance()->
06645              IsActive("LIPlexMaps",Msg::kDebug)) print=true;
06646     else if (det==Detector::kNear && 
06647              MsgService::Instance()->
06648              IsActive("LIPlexMaps",Msg::kDebug)) print=true;
06649     
06650     if (print){
06651       MSG("LIPlexMaps",Msg::kInfo)
06652         <<"("<<plane<<";"<<strip<<";"<<end<<")"
06653         <<" Gain="<<gain<<", gainErr="<<gainErr<<", SPEW="<<SPEWidth<<endl;
06654         //<<", seId="<<seId<<endl;
06655         //<<", SPEWErr="<<SPEWidthErr<<endl;
06656     }
06657   }
06658 
06659   for (vector<LIPmt*>::iterator it=vPmts.begin(); 
06660        it!=vPmts.end();it++) {
06661 
06662     if ((*it)->IsEmpty()) cout<<"empty"<<endl;
06663     else{
06664       cout<<"not emp"<<endl;
06665       (*it)->Print();
06666     }
06667   }
06668 
06669 
06670 
06671   for (Int_t pl=*planeMin;pl<*planeMax;pl++){
06672     for (Int_t st=-1;st<NUMSTRIPS+2;st++){
06673       for (Int_t se=0;se<NUMSIDES;se++){
06674 
06675         //get stripend id
06676         PlexStripEndId seid(static_cast<Detector::Detector_t>
06677                             (det),pl,st,
06678                             static_cast<StripEnd::EStripEnd>(se+1));
06679         
06680         //get pixel ids from strip end
06681         PlexPixelSpotId psid=plexHandle.GetPixelSpotId(seid);
06682         ElecType::Elec_t elecType=plexHandle.GetRawChannelId(seid).
06683           GetElecType();
06684 
06685         if (se+1==StripEnd::kWest && elecType==ElecType::kQIE){
06686           
06687           Double_t gain=avM64SE2.GetPixelGain(psid.GetPixel());
06688           
06689           hAvDetGains[1]->Fill(pl,st,gain);
06690         }
06691       }
06692     }
06693   }
06694 
06695   gStyle->SetOptStat(1111111);
06696 
06697   //draw the m64s
06698   if (!avM64SE1.IsEmpty() || !avM64SE2.IsEmpty()){
06699     TCanvas *cPmtFaceM64=new TCanvas
06700       ("cPmtFaceM64","cPmtFaceM64",0,0,1000,550);
06701     cPmtFaceM64->SetFillColor(0);
06702     cPmtFaceM64->Divide(2,1);
06703     cPmtFaceM64->cd(1);
06704     fS="M64 Gains (U view)"; 
06705     if (!avM64SE1.IsEmpty()) avM64SE1.GetPmtFaceMap(fS.c_str())->
06706                                 Draw("colztext");
06707     cPmtFaceM64->cd(2);
06708     fS="M64 Gains (V view)"; 
06709     if (!avM64SE2.IsEmpty()) avM64SE2.GetPmtFaceMap(fS.c_str())->
06710                                 Draw("colztext");
06711 
06712     string sDbPmts="DbPmts";
06713     sDbPmts+=Detector::AsString(static_cast<Detector::
06714                                      Detector_t>(det));
06715     sDbPmts+=".ps";
06716     cPmtFaceM64->Print(sDbPmts.c_str());
06717 
06718   }
06719 
06720   //draw the m16s
06721   if (!avM16VA0SE1.IsEmpty() || !avM16VA0SE1.IsEmpty() ||
06722       !avM16VA1SE1.IsEmpty() || !avM16VA1SE1.IsEmpty() ||
06723       !avM16VA2SE1.IsEmpty() || !avM16VA2SE1.IsEmpty()){
06724 
06725     TCanvas *cPmtFaceM16=new TCanvas
06726       ("cPmtFaceM16","cPmtFaceM16",0,0,1000,700);
06727     cPmtFaceM16->SetFillColor(0);
06728     cPmtFaceM16->Divide(3,2);
06729     cPmtFaceM16->cd(1);
06730     fS="M16 Gains (VA0, stripend1)"; 
06731     if (!avM16VA0SE1.IsEmpty()) avM16VA0SE1.GetPmtFaceMap(fS.c_str())->
06732                                    Draw("colztext");
06733     cPmtFaceM16->cd(2);
06734     fS="M16 Gains (VA1, stripend1)"; 
06735     if (!avM16VA1SE1.IsEmpty()) avM16VA1SE1.GetPmtFaceMap(fS.c_str())->
06736                                    Draw("colztext");
06737     cPmtFaceM16->cd(3);
06738     fS="M16 Gains (VA2, stripend1)"; 
06739     if (!avM16VA2SE1.IsEmpty()) avM16VA2SE1.GetPmtFaceMap(fS.c_str())->
06740                                    Draw("colztext");
06741     cPmtFaceM16->cd(4);
06742     fS="M16 Gains (VA0, stripend2)"; 
06743     if (!avM16VA0SE2.IsEmpty()) avM16VA0SE2.GetPmtFaceMap(fS.c_str())->
06744                                    Draw("colztext");
06745     cPmtFaceM16->cd(5);
06746     fS="M16 Gains (VA1, stripend2)"; 
06747     if (!avM16VA1SE2.IsEmpty()) avM16VA1SE2.GetPmtFaceMap(fS.c_str())->
06748                                    Draw("colztext");
06749     cPmtFaceM16->cd(6);
06750     fS="M16 Gains (VA2, stripend2)"; 
06751     if (!avM16VA2SE2.IsEmpty()) avM16VA2SE2.GetPmtFaceMap(fS.c_str())->
06752                                    Draw("colztext");
06753 
06754     string sDbPmts="DbPmts";
06755     sDbPmts+=Detector::AsString(static_cast<Detector::
06756                                      Detector_t>(det));
06757     sDbPmts+=".ps";
06758     cPmtFaceM16->Print(sDbPmts.c_str());
06759 
06760   }
06761 
06762   //do gains
06763   TCanvas *cAvDetGain=new TCanvas
06764     ("cAvDetGain","cAvDetGain",0,0,1000,800);
06765   cAvDetGain->SetFillColor(0);
06766   cAvDetGain->cd();
06767   hAvDetGains[1]->Draw("colz");
06768 
06769   //set stats info off
06770   gStyle->SetOptStat(0);
06771 
06772   //do gains
06773   TCanvas *cStripVsPlaneGain=new TCanvas
06774     ("cStripVsPlaneGain","StripVsPlane: Gain",0,0,1000,800);
06775   cStripVsPlaneGain->SetFillColor(0);
06776   cStripVsPlaneGain->cd();
06777   string sDbGains="DbGains";
06778   sDbGains+=Detector::AsString(static_cast<Detector::
06779                                    Detector_t>(det));
06780   sDbGains+=".ps";
06781   cStripVsPlaneGain->Print((sDbGains+"[").c_str());
06782   gErrorIgnoreLevel=1;
06783   for (Int_t i=0;i<NUMCRATES;i++){  
06784     cStripVsPlaneGain->Clear();
06785     hStripVsPlaneGain[i]->Draw("colz");
06786     cStripVsPlaneGain->Print(sDbGains.c_str());
06787   }
06788   cStripVsPlaneGain->Print((sDbGains+"]").c_str());
06789   gErrorIgnoreLevel=0;
06790 
06791   //do gain errs
06792   TCanvas *cStripVsPlaneGainErr=new TCanvas
06793     ("cStripVsPlaneGainErr","StripVsPlane: GainErr",0,0,1000,800);
06794   cStripVsPlaneGainErr->SetFillColor(0);
06795   cStripVsPlaneGainErr->cd();
06796   string sDbGainErrs="DbGainErrs";
06797   sDbGainErrs+=Detector::AsString(static_cast<Detector::
06798                                        Detector_t>(det));
06799   sDbGainErrs+=".ps";
06800   cStripVsPlaneGainErr->Print((sDbGainErrs+"[").c_str());
06801   gErrorIgnoreLevel=1;
06802   for (Int_t i=0;i<NUMCRATES;i++){  
06803     cStripVsPlaneGainErr->Clear();
06804     hStripVsPlaneGainErr[i]->Draw("colz");
06805     cStripVsPlaneGainErr->Print(sDbGainErrs.c_str());
06806   }
06807   cStripVsPlaneGainErr->Print((sDbGainErrs+"]").c_str());
06808   gErrorIgnoreLevel=0;
06809 
06810   //do SPEWidths
06811   TCanvas *cStripVsPlaneSPEWidth=new TCanvas
06812     ("cStripVsPlaneSPEWidth","StripVsPlane: SPEWidth",0,0,1000,800);
06813   cStripVsPlaneSPEWidth->SetFillColor(0);
06814   cStripVsPlaneSPEWidth->cd();
06815   string sDbSPEWidths="DbSPEWidths";
06816   sDbSPEWidths+=Detector::AsString(static_cast<Detector::
06817                                        Detector_t>(det));
06818   sDbSPEWidths+=".ps";
06819   cStripVsPlaneSPEWidth->Print((sDbSPEWidths+"[").c_str());
06820   gErrorIgnoreLevel=1;
06821   for (Int_t i=0;i<NUMCRATES;i++){  
06822     cStripVsPlaneSPEWidth->Clear();
06823     hStripVsPlaneSPEWidth[i]->Draw("colz");
06824     cStripVsPlaneSPEWidth->Print(sDbSPEWidths.c_str());
06825   }
06826   cStripVsPlaneSPEWidth->Print((sDbSPEWidths+"]").c_str());
06827   gErrorIgnoreLevel=0;
06828 
06829   if (det==Detector::kCalDet){
06830     TCanvas *cGain=new TCanvas("cGain","cGain",0,0,1000,800);
06831     cGain->SetFillColor(0);
06832     cGain->Divide(1,2);
06833     cGain->cd(1);
06834     hStripVsPlaneGain[0]->Draw("colz");
06835     cGain->cd(2);
06836     hStripVsPlaneGain[1]->Draw("colz");
06837   }
06838   
06839   gStyle->SetOptStat(1111);
06840   TCanvas *cGain=new TCanvas("cGain","cGain",0,0,1000,800);
06841   cGain->SetFillColor(0);
06842   cGain->Divide(2,1);
06843   cGain->cd(1);
06844   hGains->Draw();
06845   cGain->cd(2);
06846   hGainsAll->Draw();
06847 
06848   MSG("LIPlexMaps",Msg::kInfo)
06849     <<endl<<" ** Finished the ReadDbGains() method... ** "<<endl; 
06850 }

void LIPlexMaps::ReadDbPulserDrift ( Int_t  det,
VldTimeStamp  ts 
)

Definition at line 6928 of file LIPlexMaps.cxx.

References bfld::AsString(), LILookup::FIRSTCRATE, LILookup::FIRSTSTRIP, fLookup, Form(), fS, PulserRefDrift::GetError(), PulserRefDrift::GetMean(), PulserRefDrift::GetNumEntries(), DbiResultPtr< T >::GetRow(), PulserRefDrift::GetStripEnd(), MsgService::Instance(), Detector::kCalDet, SimFlag::kData, Msg::kDebug, Detector::kFar, Msg::kInfo, Detector::kNear, LILookup::LASTCRATE, LILookup::LASTSTRIP, MSG, DbiResultPtr< T >::NewQuery(), LILookup::Plane2Crate(), VldContext::Print(), print(), LILookup::SetDetector(), LILookup::SetPbPlanes(), and LILookup::UnencodePlnStripEndKey().

06929 {
06930   MSG("LIPlexMaps",Msg::kInfo)
06931     <<endl<<" ** Running the ReadDbPulserDrift() method... ** "<<endl; 
06932 
06933   //Thanks to Ryan for the DB code of this method  
06934   
06935   this->SetDetector(det);
06936 
06937   Int_t* planeMax=new Int_t[NUMCRATES];
06938   Int_t* planeMin=new Int_t[NUMCRATES];
06939   fLookup.SetPbPlanes(planeMin,planeMax,det);
06940 
06941   const Int_t firstStripBin=FIRSTSTRIP-8;//-8;
06942   const Int_t lastStripBin=LASTSTRIP+9;//200;
06943   const Int_t bins=lastStripBin-firstStripBin;
06944 
06945   string sConstantBit="";
06946 
06947   MSG("LIAnalysis",Msg::kInfo)
06948     <<"sConstantBit="<<sConstantBit<<endl;
06949 
06950   TH2F **hStripVsPlaneMean=0;
06951   hStripVsPlaneMean= new TH2F*[NUMCRATES];
06952   for (Int_t i=0;i<NUMCRATES;i++){
06953     string sPb=Form("%d",i);
06954     fS="Mean (Crate "+sPb+")";
06955     hStripVsPlaneMean[i]=new TH2F(fS.c_str(),fS.c_str(),
06956                                   planeMax[i]-planeMin[i],
06957                                   planeMin[i],planeMax[i],
06958                                   bins,firstStripBin,lastStripBin);
06959     hStripVsPlaneMean[i]->GetXaxis()->SetTitle("Plane");
06960     hStripVsPlaneMean[i]->GetXaxis()->CenterTitle();
06961     hStripVsPlaneMean[i]->GetYaxis()->SetTitle("Strip");
06962     hStripVsPlaneMean[i]->GetYaxis()->CenterTitle();
06963     hStripVsPlaneMean[i]->SetFillColor(0);
06964     //hStripVsPlaneMean[i]->SetBit(TH1::kCanRebin);
06965   }
06966 
06967   TH2F **hStripVsPlaneError=0;
06968   hStripVsPlaneError= new TH2F*[NUMCRATES];
06969   for (Int_t i=0;i<NUMCRATES;i++){
06970     string sPb=Form("%d",i);
06971     fS="Gain Error (Crate "+sPb+")";
06972     hStripVsPlaneError[i]=new TH2F(fS.c_str(),fS.c_str(),
06973                                      planeMax[i]-planeMin[i],
06974                                      planeMin[i],planeMax[i],
06975                                      bins,firstStripBin,lastStripBin);
06976     hStripVsPlaneError[i]->GetXaxis()->SetTitle("Plane");
06977     hStripVsPlaneError[i]->GetXaxis()->CenterTitle();
06978     hStripVsPlaneError[i]->GetYaxis()->SetTitle("Strip");
06979     hStripVsPlaneError[i]->GetYaxis()->CenterTitle();
06980     hStripVsPlaneError[i]->SetFillColor(0);
06981     //hStripVsPlaneError[i]->SetBit(TH1::kCanRebin);
06982   }
06983   
06984   TH2F **hStripVsPlaneNumEntries=0;
06985   hStripVsPlaneNumEntries= new TH2F*[NUMCRATES];
06986   for (Int_t i=0;i<NUMCRATES;i++){
06987     string sPb=Form("%d",i);
06988     fS="NumEntries_Crate"+sPb;
06989     hStripVsPlaneNumEntries[i]=new TH2F(fS.c_str(),fS.c_str(),
06990                                      planeMax[i]-planeMin[i],
06991                                      planeMin[i],planeMax[i],
06992                                      bins,firstStripBin,lastStripBin);
06993     hStripVsPlaneNumEntries[i]->GetXaxis()->SetTitle("Plane");
06994     hStripVsPlaneNumEntries[i]->GetXaxis()->CenterTitle();
06995     hStripVsPlaneNumEntries[i]->GetYaxis()->SetTitle("Strip");
06996     hStripVsPlaneNumEntries[i]->GetYaxis()->CenterTitle();
06997     hStripVsPlaneNumEntries[i]->SetFillColor(0);
06998     //hStripVsPlaneNumEntries[i]->SetBit(TH1::kCanRebin);
06999   }
07000 
07001   VldContext vldCtx(static_cast<Detector::Detector_t>(det),
07002                     SimFlag::kData,ts);
07003   vldCtx.Print();
07004 
07005   //DbiResultPtr<PulserRawDrift> dbiPulserDrift;
07006   //DbiResultPtr<PulserRawDriftF> dbiPulserDrift;
07007   DbiResultPtr<PulserRefDrift> dbiPulserDrift;
07008   //DbiResultPtr<PulserRefDriftF> dbiPulserDrift;
07009 
07010   UInt_t numRows=dbiPulserDrift.NewQuery(vldCtx,0);
07011 
07012   MSG("LIPlexMaps",Msg::kInfo)
07013     <<"New DB query produced "<<numRows<<" rows"<<endl
07014     <<"Looping over rows..."<<endl;
07015 
07017   //loop over the rows
07019   for(UInt_t i=0;i<numRows;i++) {
07020     //const PulserRawDrift* pulserDrift = dbiPulserDrift.GetRow(i);
07021     //const PulserRawDriftF* pulserDrift = dbiPulserDrift.GetRow(i);
07022     const PulserRefDrift* pulserDrift = dbiPulserDrift.GetRow(i);
07023     //const PulserRefDriftF* pulserDrift = dbiPulserDrift.GetRow(i);
07024 
07025     Float_t mean=pulserDrift->GetMean();
07026     Float_t error=pulserDrift->GetError();
07027     Float_t numEntries=pulserDrift->GetNumEntries();
07028 
07029     UInt_t seidkey=pulserDrift->GetStripEnd();
07030     Int_t plane=-1;
07031     Int_t strip=-1;
07032     Int_t end=-1;
07033     fLookup.UnencodePlnStripEndKey(seidkey,static_cast<Detector::
07034                                    Detector_t>(det),plane,strip,end);
07035 
07036     Int_t crate=Plane2Crate(plane,end,det);
07037     if (crate>=FIRSTCRATE && crate<=LASTCRATE){
07038       hStripVsPlaneMean[crate]->Fill(plane,strip,mean);
07039       hStripVsPlaneError[crate]->Fill(plane,strip,error);
07040       hStripVsPlaneNumEntries[crate]->Fill(plane,strip,numEntries);
07041     }
07042 
07043     Bool_t print=false;
07044 
07045     if (det==Detector::kCalDet) print=true;
07046     else if (det==Detector::kFar && 
07047              MsgService::Instance()->
07048              IsActive("LIPlexMaps",Msg::kDebug)) print=true;
07049     else if (det==Detector::kNear && 
07050              MsgService::Instance()->
07051              IsActive("LIPlexMaps",Msg::kDebug)) print=true;
07052     
07053     if (print){
07054       MSG("LIPlexMaps",Msg::kInfo)
07055         <<"("<<plane<<";"<<strip<<";"<<end<<")"
07056         <<" Mean="<<mean<<", error="<<error<<", numEnt="<<numEntries
07057         <<", seidkey="<<seidkey<<endl;
07058     }
07059   }
07061   //finished loop over the rows
07063 
07064   //set stats info off
07065   gStyle->SetOptStat(0);
07066 
07067   //do the means
07068   TCanvas *cStripVsPlaneMean=new TCanvas
07069     ("cStripVsPlaneMean","StripVsPlane: Mean",0,0,1000,800);
07070   cStripVsPlaneMean->SetFillColor(0);
07071   cStripVsPlaneMean->cd();
07072   string sDbMeans="DbDrift";
07073   sDbMeans+=Detector::AsString(static_cast<Detector::
07074                                    Detector_t>(det));
07075   sDbMeans+=".ps";
07076   cStripVsPlaneMean->Print((sDbMeans+"[").c_str());
07077   gErrorIgnoreLevel=1;
07078   //set stats info off
07079   gStyle->SetOptStat(0);
07080   for (Int_t i=0;i<NUMCRATES;i++){
07081     cStripVsPlaneMean->Clear();
07082     hStripVsPlaneMean[i]->Draw("colz");
07083     cStripVsPlaneMean->Print(sDbMeans.c_str());
07084   }
07085   //close the file
07086   cStripVsPlaneMean->Print((sDbMeans+"]").c_str());
07087   gErrorIgnoreLevel=0;
07088 
07089   TCanvas *cStripVsPlaneError=new TCanvas  
07090     ("cStripVsPlaneError","StripVsPlane: Error",0,0,1000,800);  
07091   cStripVsPlaneError->SetFillColor(0);  
07092   cStripVsPlaneError->Divide(1,2);  
07093   cStripVsPlaneError->cd(1);  
07094   hStripVsPlaneError[0]->Draw("colz");  
07095   cStripVsPlaneError->cd(2);  
07096   hStripVsPlaneError[1]->Draw("colz");  
07097 
07098   TCanvas *cStripVsPlaneNumEntries=new TCanvas  
07099     ("cStripVsPlaneNumEntries","StripVsPlane: NumEntries",
07100      0,0,1000,800);  
07101   cStripVsPlaneNumEntries->SetFillColor(0);  
07102   cStripVsPlaneNumEntries->Divide(1,2);  
07103   cStripVsPlaneNumEntries->cd(1);  
07104   hStripVsPlaneNumEntries[0]->Draw("colz");  
07105   cStripVsPlaneNumEntries->cd(2);  
07106   hStripVsPlaneNumEntries[1]->Draw("colz");  
07107 
07108   MSG("LIPlexMaps",Msg::kInfo)
07109     <<endl<<" ** Finished the ReadDbPulserDrift() method... ** "<<endl; 
07110 }

void LIPlexMaps::ReadDbPulserDriftPin (  ) 

Definition at line 8629 of file LIPlexMaps.cxx.

References Form(), PulserRawDriftPin::GetPinDiodeId(), PulserRefDriftPin::GetPinDiodeId(), PlexHandle::GetRawChannelId(), DbiResultPtr< T >::GetRow(), Detector::kCalDet, SimFlag::kData, Msg::kInfo, MSG, and DbiResultPtr< T >::NewQuery().

08630 {
08631   MSG("LIPlexMaps",Msg::kInfo)
08632     <<endl<<" ** Running the ReadDbPulserDriftPin() method... **"<<endl;
08633 
08634   //Thanks to Ryan for the DB code of this method  
08635   
08636   VldTimeStamp tsNow;
08637   VldContext vldNow(Detector::kCalDet,SimFlag::kData,tsNow);
08638   PlexHandle *plexHandle=new PlexHandle(vldNow);   
08639 
08640   DbiResultPtr<PulserRawDriftPin> driftRawPin;
08641   DbiResultPtr<PulserRefDriftPin> driftRefPin;
08642 
08643   //UInt_t numRows=dbiPulserDriftPin.NewQuery(vldNow,0);
08644   UInt_t numRows=driftRawPin.NewQuery(vldNow,0);
08645   driftRefPin.NewQuery(vldNow,0);
08646 
08647   MSG("LIPlexMaps",Msg::kInfo)
08648     <<"New DB query produced "<<numRows<<" rows"<<endl;
08649 
08650   map<Int_t,PulserRawDriftPin> rawPin;
08651   map<Int_t,PulserRefDriftPin> refPin;
08652 
08654   //loop over the rows
08656   for(UInt_t i=0;i<numRows;i++) {
08657   //const PulserRawDriftPin* pulserDriftPin=dbiPulserDriftPin.GetRow(i);
08658   //const PulserRefDriftPin* pulserDriftPin=dbiPulserDriftPin.GetRow(i);
08659       
08660     Int_t chAddRaw=plexHandle->GetRawChannelId
08661       (driftRawPin.GetRow(i)->GetPinDiodeId()).GetChAdd();
08662     Int_t chAddRef=plexHandle->GetRawChannelId
08663       (driftRefPin.GetRow(i)->GetPinDiodeId()).GetChAdd();
08664     
08665     rawPin[chAddRaw]=*driftRawPin.GetRow(i);
08666     refPin[chAddRef]=*driftRefPin.GetRow(i);
08667   }
08669   //finished loop over the rows
08671 
08672   MSG("LIPlexMaps",Msg::kInfo)
08673     <<"Finished loop"<<endl;
08674 
08675   map<Int_t,PulserRawDriftPin>::iterator raw=rawPin.begin();
08676   map<Int_t,PulserRefDriftPin>::iterator ref=refPin.begin();
08677 
08678   while(raw!=rawPin.end()){
08679 
08680     Float_t meanRaw=raw->second.GetMean();
08681     Float_t errorRaw=raw->second.GetError();
08682     Float_t numEntriesRaw=raw->second.GetNumEntries();
08683     Int_t chAddRaw=plexHandle->GetRawChannelId
08684       (raw->second.GetPinDiodeId()).GetChAdd();
08685 
08686     Float_t meanRef=ref->second.GetMean();
08687     Float_t errorRef=ref->second.GetError();
08688     Float_t numEntriesRef=ref->second.GetNumEntries();
08689     Int_t chAddRef=plexHandle->GetRawChannelId
08690       (ref->second.GetPinDiodeId()).GetChAdd();
08691 
08692     string sMeanRaw=Form("%.1f",meanRaw);
08693     string sErrorRaw=Form("%.2f",errorRaw);
08694     string sNumEntriesRaw=Form("%.0f",numEntriesRaw);
08695     string sChAddRaw=Form("%d",chAddRaw);
08696 
08697     string sMeanRef=Form("%.1f",meanRef);
08698     string sErrorRef=Form("%.2f",errorRef);
08699     string sNumEntriesRef=Form("%.0f",numEntriesRef);
08700     string sChAddRef=Form("%d",chAddRef); 
08701 
08702     string sMeanDif=Form("%.1f",meanRef-meanRaw);
08703     string sErrorDif=Form("%.2f",errorRef-errorRaw);
08704     string sNumEntriesDif=Form("%.0f",numEntriesRef-numEntriesRaw);
08705     string sChAddDif=Form("%d",chAddRef-chAddRaw); 
08706 
08707     MSG("LIPlexMaps",Msg::kInfo)
08708       <<endl
08709       <<"Ref (m,er,num,ch)=("<<sMeanRef<<";"<<sErrorRef
08710       <<";"<<sNumEntriesRef<<";"<<sChAddRef<<")"
08711       <<endl
08712       <<"Raw (m,er,num,ch)=("<<sMeanRaw<<";"<<sErrorRaw
08713       <<";"<<sNumEntriesRaw<<";"<<sChAddRaw<<")"
08714       <<endl
08715       <<"Diff (m,er,num,ch)=("<<sMeanDif<<";"<<sErrorDif
08716       <<";"<<sNumEntriesDif<<";"<<sChAddDif<<")"
08717       <<endl;
08718 
08719     raw++;
08720     ref++;    
08721   }
08722 
08723 
08724   MSG("LIPlexMaps",Msg::kInfo)
08725     <<endl<<" ** Finished the ReadDbPulserDriftPin() method... ** "
08726     <<endl; 
08727 }

void LIPlexMaps::ReadDbPulserRawGain (  ) 

Definition at line 7909 of file LIPlexMaps.cxx.

References LILookup::FIRSTSTRIP, fLookup, Form(), fS, PulserRawGain::GetError(), PulserRawGain::GetMean(), PulserRawGain::GetNumEntries(), DbiResultPtr< T >::GetRow(), PulserRawGain::GetStripEnd(), Detector::kCalDet, SimFlag::kData, Msg::kInfo, LILookup::LASTSTRIP, MSG, DbiResultPtr< T >::NewQuery(), LILookup::SetPbPlanes(), and LILookup::UnencodePlnStripEndKey().

07910 {
07911   MSG("LIPlexMaps",Msg::kInfo)
07912     <<endl<<" ** Running the ReadDbPulserRawGain() method... ** "<<endl;
07913 
07914   //Thanks to Ryan for the DB code of this method  
07915   
07916   Int_t detectorType=4;
07917 
07918   Int_t* planeMax=new Int_t[NUMCRATES];
07919   Int_t* planeMin=new Int_t[NUMCRATES];
07920   fLookup.SetPbPlanes(planeMin,planeMax,detectorType);
07921 
07922   const Int_t firstStripBin=FIRSTSTRIP-8;//-8;
07923   const Int_t lastStripBin=LASTSTRIP+9;//200;
07924   const Int_t bins=lastStripBin-firstStripBin;
07925 
07926   string sConstantBit="";
07927 
07928   MSG("LIAnalysis",Msg::kInfo)
07929     <<"sConstantBit="<<sConstantBit<<endl;
07930 
07931   Int_t mycrates=5;
07932 
07933   TH2F **hStripVsPlaneGain=0;
07934   hStripVsPlaneGain= new TH2F*[mycrates];
07935   for (Int_t i=0;i<NUMCRATES;i++){
07936     string sPb=Form("%d",i);
07937     fS="Gain (Crate "+sPb+")";
07938     hStripVsPlaneGain[i]=new TH2F(fS.c_str(),fS.c_str(),
07939                                   planeMax[i]-planeMin[i],
07940                                   planeMin[i],planeMax[i],
07941                                   bins,firstStripBin,lastStripBin);
07942     hStripVsPlaneGain[i]->GetXaxis()->SetTitle("Plane");
07943     hStripVsPlaneGain[i]->GetXaxis()->CenterTitle();
07944     hStripVsPlaneGain[i]->GetYaxis()->SetTitle("Strip");
07945     hStripVsPlaneGain[i]->GetYaxis()->CenterTitle();
07946     hStripVsPlaneGain[i]->SetFillColor(0);
07947     //hStripVsPlaneGain[i]->SetBit(TH1::kCanRebin);
07948   }
07949 
07950   TH2F **hStripVsPlaneError=0;
07951   hStripVsPlaneError= new TH2F*[NUMCRATES];
07952   for (Int_t i=0;i<NUMCRATES;i++){
07953     string sPb=Form("%d",i);
07954     fS="Gain Error (Crate "+sPb+")";
07955     hStripVsPlaneError[i]=new TH2F(fS.c_str(),fS.c_str(),
07956                                      planeMax[i]-planeMin[i],
07957                                      planeMin[i],planeMax[i],
07958                                      bins,firstStripBin,lastStripBin);
07959     hStripVsPlaneError[i]->GetXaxis()->SetTitle("Plane");
07960     hStripVsPlaneError[i]->GetXaxis()->CenterTitle();
07961     hStripVsPlaneError[i]->GetYaxis()->SetTitle("Strip");
07962     hStripVsPlaneError[i]->GetYaxis()->CenterTitle();
07963     hStripVsPlaneError[i]->SetFillColor(0);
07964     //hStripVsPlaneError[i]->SetBit(TH1::kCanRebin);
07965   }
07966   
07967   TH2F **hStripVsPlaneNumEntries=0;
07968   hStripVsPlaneNumEntries= new TH2F*[NUMCRATES];
07969   for (Int_t i=0;i<NUMCRATES;i++){
07970     string sPb=Form("%d",i);
07971     fS="NumEntries_Crate"+sPb;
07972     hStripVsPlaneNumEntries[i]=new TH2F(fS.c_str(),fS.c_str(),
07973                                      planeMax[i]-planeMin[i],
07974                                      planeMin[i],planeMax[i],
07975                                      bins,firstStripBin,lastStripBin);
07976     hStripVsPlaneNumEntries[i]->GetXaxis()->SetTitle("Plane");
07977     hStripVsPlaneNumEntries[i]->GetXaxis()->CenterTitle();
07978     hStripVsPlaneNumEntries[i]->GetYaxis()->SetTitle("Strip");
07979     hStripVsPlaneNumEntries[i]->GetYaxis()->CenterTitle();
07980     hStripVsPlaneNumEntries[i]->SetFillColor(0);
07981     //hStripVsPlaneNumEntries[i]->SetBit(TH1::kCanRebin);
07982   }
07983 
07984   Detector::Detector_t det=Detector::kCalDet;
07985 
07986   VldTimeStamp tsNow;
07987   VldContext vldNow(det,SimFlag::kData,tsNow);
07988 
07989   DbiResultPtr<PulserRawGain> dbiPulserRawGain;
07990 
07991   UInt_t numRows=dbiPulserRawGain.NewQuery(vldNow,0);
07992 
07993   MSG("LIPlexMaps",Msg::kInfo)
07994     <<"New DB query produced "<<numRows<<" rows"<<endl;
07995 
07997   //loop over the rows
07999   for(UInt_t i=0;i<numRows;i++) {
08000     const PulserRawGain* pulserRawGain=dbiPulserRawGain.GetRow(i);
08001 
08002     Float_t gain=*pulserRawGain->GetMean();
08003     Float_t error=*pulserRawGain->GetError();
08004     Float_t numEntries=*pulserRawGain->GetNumEntries();
08005 
08006     UInt_t seidkey=pulserRawGain->GetStripEnd();
08007     Int_t plane=-1;
08008     Int_t strip=-1;
08009     Int_t end=-1;
08010     fLookup.UnencodePlnStripEndKey(seidkey,det,plane,strip,end);
08011 
08012     hStripVsPlaneGain[end-1]->Fill(plane,strip,gain);
08013     hStripVsPlaneError[end-1]->Fill(plane,strip,error);
08014     hStripVsPlaneNumEntries[end-1]->Fill(plane,strip,numEntries);
08015 
08016     MSG("LIPlexMaps",Msg::kInfo)
08017       <<"("<<plane<<";"<<strip<<";"<<end<<")"
08018       <<" gain="<<gain<<", error="<<error<<", numEnt="<<numEntries
08019       <<", seidkey="<<seidkey<<endl;
08020   }
08022   //finished loop over the rows
08024 
08025   //set stats info off
08026   gStyle->SetOptStat(0);
08027 
08028   TCanvas *cStripVsPlaneGain=new TCanvas  
08029     ("cStripVsPlaneGain","StripVsPlane: Gain",0,0,1000,800);  
08030   cStripVsPlaneGain->SetFillColor(0);  
08031   cStripVsPlaneGain->Divide(1,2);  
08032   cStripVsPlaneGain->cd(1);  
08033   hStripVsPlaneGain[0]->Draw("colz");  
08034   cStripVsPlaneGain->cd(2);  
08035   hStripVsPlaneGain[1]->Draw("colz");  
08036 
08037   TCanvas *cStripVsPlaneError=new TCanvas  
08038     ("cStripVsPlaneError","StripVsPlane: Error",0,0,1000,800);  
08039   cStripVsPlaneError->SetFillColor(0);  
08040   cStripVsPlaneError->Divide(1,2);  
08041   cStripVsPlaneError->cd(1);  
08042   hStripVsPlaneError[0]->Draw("colz");  
08043   cStripVsPlaneError->cd(2);  
08044   hStripVsPlaneError[1]->Draw("colz");  
08045 
08046   TCanvas *cStripVsPlaneNumEntries=new TCanvas  
08047     ("cStripVsPlaneNumEntries","StripVsPlane: NumEntries",
08048      0,0,1000,800);  
08049   cStripVsPlaneNumEntries->SetFillColor(0);  
08050   cStripVsPlaneNumEntries->Divide(1,2);  
08051   cStripVsPlaneNumEntries->cd(1);  
08052   hStripVsPlaneNumEntries[0]->Draw("colz");  
08053   cStripVsPlaneNumEntries->cd(2);  
08054   hStripVsPlaneNumEntries[1]->Draw("colz");  
08055 
08056   MSG("LIPlexMaps",Msg::kInfo)
08057     <<endl<<" ** Finished the ReadDbPulserRawGain() method... **"<<endl;
08058 }

Int_t LIPlexMaps::SampleDist ( std::vector< Double_t >  v,
TRandom *  tRand 
)

Referenced by PeGen().

void LIPlexMaps::ScaleVector ( std::vector< Double_t > &  v,
Double_t  scaleFactor 
)

Referenced by PeGen().

void LIPlexMaps::SetGraphAxisEtc ( TGraph *  g,
Int_t  startTimeSecs,
Int_t  endTimeSecs 
)

Definition at line 7791 of file LIPlexMaps.cxx.

References Form(), Msg::kError, Msg::kInfo, Msg::kVerbose, and MSG.

Referenced by DriftWithTime().

07793 {
07794   MSG("LIPlexMaps",Msg::kVerbose)
07795     <<endl<<" ** Running the SetGraphAxisEtc method... ** "<<endl;
07796 
07797   TDatime startDatime;
07798   startDatime.Set(startTimeSecs);
07799 
07800   TDatime endDatime;
07801   endDatime.Set(endTimeSecs);
07802 
07803   //play around with the formatting a little
07804   string sStartHour=Form("%d",startDatime.GetHour());
07805   string sStartMinute=Form("%d",startDatime.GetMinute());
07806   string sStartSecond=Form("%d",startDatime.GetSecond());
07807   string sStartYear=Form("%d",startDatime.GetYear());
07808   string sStartMonth=Form("%d",startDatime.GetMonth());
07809   string sStartDay=Form("%d",startDatime.GetDay());
07810   if (startDatime.GetHour()<10) sStartHour="0"+sStartHour;
07811   if (startDatime.GetMinute()<10) sStartMinute="0"+sStartMinute;
07812   if (startDatime.GetSecond()<10) sStartSecond="0"+sStartSecond;
07813   if (startDatime.GetMonth()<10) sStartMonth="0"+sStartMonth;
07814   if (startDatime.GetDay()<10) sStartDay="0"+sStartDay;
07815 
07816   //play around with the formatting a little
07817   string sEndHour=Form("%d",endDatime.GetHour());
07818   string sEndMinute=Form("%d",endDatime.GetMinute());
07819   string sEndSecond=Form("%d",endDatime.GetSecond());
07820   string sEndYear=Form("%d",endDatime.GetYear());
07821   string sEndMonth=Form("%d",endDatime.GetMonth());
07822   string sEndDay=Form("%d",endDatime.GetDay());
07823   if (endDatime.GetHour()<10) sEndHour="0"+sEndHour;
07824   if (endDatime.GetMinute()<10) sEndMinute="0"+sEndMinute;
07825   if (endDatime.GetSecond()<10) sEndSecond="0"+sEndSecond;
07826   if (endDatime.GetMonth()<10) sEndMonth="0"+sEndMonth;
07827   if (endDatime.GetDay()<10) sEndDay="0"+sEndDay;
07828 
07829   static Bool_t firstTime=true;
07830   if (firstTime){
07831     MSG("LIAnalysis",Msg::kInfo) 
07832       <<"Setting graph axis info:"<<endl;
07833     MSG("LIAnalysis",Msg::kInfo) 
07834       <<"  Start time "<<sStartHour
07835       <<":"<<sStartMinute
07836       <<":"<<sStartSecond
07837       <<" on "<<startDatime.GetYear()
07838       <<"/"<<sStartMonth
07839       <<"/"<<sStartDay
07840       <<endl;
07841     
07842     MSG("LIAnalysis",Msg::kInfo) 
07843       <<"  End time "<<sEndHour
07844       <<":"<<sEndMinute
07845       <<":"<<sEndSecond
07846       <<" on "<<endDatime.GetYear()
07847       <<"/"<<sEndMonth
07848       <<"/"<<sEndDay
07849       <<endl;
07850   }
07851   firstTime=false;
07852 
07853   Int_t timeRange=endTimeSecs-startTimeSecs;
07854 
07855   //check graph pointer is not null
07856   if (g){
07857     if (sStartDay==sEndDay && timeRange<1*24*60*60){
07858       string title="Time ("+sStartYear+"/"+sStartMonth+"/"+sStartDay+")";
07859       g->GetXaxis()->SetTitle(title.c_str());
07860       g->GetXaxis()->SetTimeFormat("%H:%M");
07861     }
07862     else if (timeRange>1*24*60*60 && timeRange<2*24*60*60){//1-2 days
07863       string title="Time ("+sStartYear+"/"+sStartMonth+"/"+sStartDay
07864         +" - "+sEndYear+"/"+sEndMonth+"/"+sEndDay+")";
07865       g->GetXaxis()->SetTitle(title.c_str());
07866       g->GetXaxis()->SetTimeFormat("%H:%M");
07867     }
07868     else if (timeRange>2*24*60*60 && timeRange<5*24*60*60){//2-5 days
07869       string title="Time ("+sStartYear+"/"+sStartMonth+"/"+sStartDay
07870         +" - "+sEndYear+"/"+sEndMonth+"/"+sEndDay+")";
07871       g->GetXaxis()->SetTitle(title.c_str());
07872       g->GetXaxis()->SetTimeFormat("%H:%M-%d/%m");
07873     }
07874     else{
07875       string title="Time ("+sStartYear+"/"+sStartMonth+"/"+sStartDay
07876         +" - "+sEndYear+"/"+sEndMonth+"/"+sEndDay+")";
07877       g->GetXaxis()->SetTitle(title.c_str());
07878       g->GetXaxis()->SetTimeFormat("%H:%M-%d/%m");
07879       //stop it cramming loads of days on the axis!
07880       g->GetXaxis()->SetNdivisions(506);
07881       //n = N1 + 100*N2 + 10000*N3
07882       //N1=number of primary divisions.
07883       //N2=number of secondary divisions.
07884       //N3=number of 3rd divisions.
07885     }
07886     
07887     //other x-axis defaults
07888     g->GetXaxis()->SetTimeDisplay(1);
07889     g->GetXaxis()->CenterTitle();
07890     
07891     //other defaults
07892     g->SetMarkerStyle(3);
07893     g->SetMarkerColor(2);
07894     g->SetMarkerSize(0.35);
07895     g->SetLineColor(46);
07896   }
07897   else{
07898     MSG("LIPlexMaps",Msg::kError)
07899       <<"Input graph pointer is null!"
07900       <<" Will do nothing."<<endl;
07901   }
07902 
07903   MSG("LIPlexMaps",Msg::kVerbose)
07904     <<endl<<" ** Finished the SetGraphAxisEtc method... **"<<endl;
07905 }


Member Data Documentation

std::string LIPlexMaps::fS [private]

The documentation for this class was generated from the following files:

Generated on 2 Nov 2017 for loon by  doxygen 1.6.1