Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

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)
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

Constructor & Destructor Documentation

LIPlexMaps::LIPlexMaps  ) 
 

Definition at line 107 of file LIPlexMaps.cxx.

References MSG.

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

LIPlexMaps::~LIPlexMaps  ) 
 

Definition at line 118 of file LIPlexMaps.cxx.

References MSG.

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


Member Function Documentation

void LIPlexMaps::ADCRailEffect  ) 
 

Definition at line 917 of file LIPlexMaps.cxx.

References MSG.

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

void LIPlexMaps::Attenuation  ) 
 

Definition at line 354 of file LIPlexMaps.cxx.

References MSG, and LILookup::TGraphVect().

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

void LIPlexMaps::BinomialGen std::vector< Double_t > &  v,
Int_t  N,
Double_t  p
 

Definition at line 245 of file LIPlexMaps.cxx.

References FactorialGen(), MSG, and pow().

00246 {
00247   MSG("LIPlexMaps",Msg::kDebug) 
00248     <<" ** Running BinomialGen method... **"<<endl;
00249 
00250   //Note: This analytical method goes wrong for N>170 
00251   //because the precision of 
00252   //the doubles can't handle the large factorials
00253   //in this case the approximation to a gaussian will be used
00254 
00255   //prob of r events in N is:
00256   //N!/r!*(N-r)! * p**r * (1-p)**(N-r)
00257   //where p is the probability of a success
00258 
00259   Double_t totalProb=0;
00260 
00261   if (N<=170){
00262     vector<Double_t> factorials(N+1);
00263     this->FactorialGen(factorials);
00264     
00265     for (UInt_t r=0;r<v.size();r++){
00266       Double_t perm=factorials[N]/(factorials[r]*factorials[N-r]);
00267       Double_t successes=pow(p,(Int_t)(r));
00268       Double_t failures=pow(1-p,(Int_t)(N-r));
00269       v[r]=perm*successes*failures;
00270       totalProb+=v[r];
00271       MSG("LIPlexMaps",Msg::kInfo)
00272         <<"Prob of "<<r<<" events = "<<v[r]
00273         <<" (perm="<<perm
00274         <<", succ="<<successes
00275         <<", fail="<<failures<<")"
00276         <<endl;
00277 
00278       MSG("LIPlexMaps",Msg::kInfo)<<"Total prob = "<<totalProb<<endl;
00279     }
00280   }
00281   else if (N>170){
00282     //use gaussian distribution with following
00283     //mean=prob*ntot+0.5
00284     //standard deviation = sqrt(ntot*prob*(1-prob).
00285     MSG("LIPlexMaps",Msg::kInfo)
00286       <<"Above N=170 this has not been implemented"<<endl;
00287   }
00288 
00289   MSG("LIPlexMaps",Msg::kDebug) 
00290     <<" ** Finished BinomialGen method **"<<endl;
00291 }

void LIPlexMaps::CompareStripToStrip Int_t  det,
VldTimeStamp  ts,
Int_t  taskA,
Int_t  taskB
 

Definition at line 5866 of file LIPlexMaps.cxx.

References VldTimeStamp::GetDate(), PlexStripEndId::GetEnd(), PlexPlaneId::GetPlane(), CalStripToStrip::GetResponse(), DbiResultPtr< T >::GetRow(), PlexStripEndId::GetStrip(), CalStripToStrip::GetStripEndId(), MAXMSG, MSG, DbiResultPtr< T >::NewQuery(), VldContext::Print(), and LILookup::SetDetector().

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

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

Definition at line 6967 of file LIPlexMaps.cxx.

References UtilMCFlag::AsString(), Detector::AsString(), PlexStripEndId::BuildPlnStripEndKey(), 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(), MsgService::IsActive(), IsScintStrip(), MSG, DbiResultPtr< T >::NewQuery(), NormaliseVector(), PlexHandle::Print(), VldTimeStamp::Print(), LILookup::SetDetector(), SetGraphAxisEtc(), LILookup::TGraphVect(), and LILookup::UnencodePlnStripEndKey().

06969 {
06970   MSG("LIPlexMaps",Msg::kInfo)
06971     <<endl<<" ** Running the DriftWithTime method... ** "<<endl; 
06972 
06973   //get all the info from the validity range
06974   VldTimeStamp startTime=vldRng.GetTimeStart();
06975   VldTimeStamp endTime=vldRng.GetTimeEnd();
06976   const Detector::Detector_t det=static_cast
06977     <Detector::Detector_t>(vldRng.GetDetectorMask());
06978   const SimFlag::ESimFlag simFlag=static_cast
06979     <SimFlag::ESimFlag>(vldRng.GetSimMask());
06980 
06981   //make a vld context for the start time
06982   VldContext startVldCtx(det,simFlag,startTime);
06983 
06984   //only set detector once at the highest/first point
06985   if (det==Detector::kCalDet){
06986     fLookup.SetDetector(static_cast<Int_t>(det));
06987   }
06988   else if (det==Detector::kFar){
06989     fLookup.SetDetector(static_cast<Int_t>(det));
06990   }
06991   else if (det==Detector::kNear){
06992     fLookup.SetDetector(static_cast<Int_t>(det));
06993   }
06994   else{
06995     MSG("LIPlexMaps",Msg::kWarning)
06996       <<"Detector not supported="
06997       <<Detector::AsString(det)<<endl
06998       <<"Program will exit here..."<<endl;
06999     exit(1);
07000   }
07001 
07002   DbiResultPtr<PulserRawDrift> dbiPulserDrift;
07003   DbiResultPtr<PulserRawDriftF> dbiPulserDriftF;
07004 
07005   MSG("LIPlexMaps",Msg::kInfo)
07006     <<"Creating maps..."<<endl;
07007   //a map to hold the reference pin info
07008   map<Int_t,LIPulserPin> refAdcPinRatio=this->
07009     GetRefAdcPinRatio(startVldCtx);//get it once to start with
07010   //maps to hold drift point info
07011   map<UInt_t,LIRun> stripEnds;
07012   map<PlexLedId,LIRun> pins;
07013 
07014   VldContext* vldCtx=0;
07015   const PulserRawDrift *pulserDrift;
07016   const PulserRawDriftF *pulserDriftF;
07017   string sLastVldRange="Not set!";
07018 
07019   //declare stripendtype
07020   StripEnd::EStripEnd stripEndType=StripEnd::kUnknown;
07021   StripEnd::EStripEnd stripEndTypeF=StripEnd::kUnknown;
07022 
07023   //create a plex handle
07024   PlexHandle* plexHandle=0;
07025 
07026   Int_t pointSpacingSecs=static_cast<Int_t>(pointSpacingMinutes*60);
07027   Int_t startTimeSecs=startTime.GetSec();
07028   Int_t endTimeSecs=endTime.GetSec();
07029   Int_t secCounter=startTimeSecs;
07030 
07031   MSG("LIPlexMaps",Msg::kInfo)
07032     <<"Starting main loop over vld range..."<<endl;
07033   while(secCounter<endTimeSecs){
07034     VldTimeStamp currentLoopTime(secCounter,0);
07035 
07036     //print out the current loop time
07037     if (MsgService::Instance()->IsActive("LIPlexMaps",Msg::kInfo)){
07038       MSG("LIPlexMaps",Msg::kInfo)<<"New Loop ";
07039       currentLoopTime.Print();
07040     }
07041     vldCtx=new VldContext(Detector::kCalDet,SimFlag::kData,
07042                           currentLoopTime);
07043 
07044     //check for a new pin reference point
07045     map<Int_t,LIPulserPin> tempRefAdcPinRatio=
07046       this->GetRefAdcPinRatio(*vldCtx);
07047     if (tempRefAdcPinRatio.size()>0){
07048       refAdcPinRatio=tempRefAdcPinRatio;
07049       MSG("LIPlexMaps",Msg::kInfo)
07050         <<"New pin reference point, regenerated map"<<endl;
07051     }
07052     else{
07053       MSG("LIPlexMaps",Msg::kDebug)
07054         <<"Checked for new pin reference point, doing nothing"
07055         <<" because same as before"<<endl;
07056     }
07057 
07058     //create a plex handle
07059     plexHandle=new PlexHandle(*vldCtx);
07060 
07061     UInt_t numRows=dbiPulserDrift.NewQuery(*vldCtx,0);
07062     
07063     if (numRows!=static_cast<UInt_t>(NUMPLANES*NUMSTRIPS*NUMENDS)){
07064       MSG("LIPlexMaps",Msg::kWarning)
07065         <<"PulserRawDrift only contains "<<numRows<<" rows"
07066         <<", it should have "<<NUMPLANES*NUMSTRIPS*NUMENDS<<endl;
07067     }
07068 
07069     string sVldRange=dbiPulserDrift.GetValidityRec()->GetVldRange().
07070       AsString();
07071 
07072     MSG("LIPlexMaps",Msg::kVerbose)
07073       <<"Vld range = "<<sVldRange<<endl;
07074 
07075     if (sVldRange==sLastVldRange){
07076       MSG("LIPlexMaps",Msg::kInfo)
07077         <<"Skipping this point because validity range is the same"
07078         <<" as the previous point"<<endl;
07079       MSG("LIPlexMaps",Msg::kDebug)
07080         <<endl
07081         <<"VldRange="<<sVldRange<<endl
07082         <<"Previous VldRange="<<sLastVldRange<<endl;
07083       //set the last range now it has been used in this loop
07084       sLastVldRange=sVldRange;
07085 
07086       //increment the time
07087       secCounter+=pointSpacingSecs;
07088         
07089       //delete currentLoopTime;
07090       delete vldCtx;
07091       delete plexHandle;
07092       continue;
07093     }
07094 
07095     //set the last range now it has been used in this loop
07096     sLastVldRange=sVldRange;
07097 
07098     map<Int_t,Float_t> rawPin=this->GetRawPinMap(*vldCtx);
07099     map<PlexLedId,LIPulserPin> rawPinLedMap=this->
07100       GetRawPinLedMap(*vldCtx);
07101     UInt_t numRowsF=dbiPulserDriftF.NewQuery(*vldCtx,0);
07102 
07103     if (numRows!=numRowsF){
07104       MSG("LIPlexMaps",Msg::kInfo)
07105         <<"Near and far end tables are different sizes! Near="
07106         <<numRows<<", far="<<numRowsF<<endl;
07107     }
07108 
07110     //loop over the pin values for all the leds
07112     for(Int_t pb=FIRSTPULSERBOX;pb<=LASTPULSERBOX;pb++){
07113       for(Int_t led=FIRSTLED;led<=LASTLED;led++){
07114         //create an ledid to then use the encoded value
07115         PlexLedId ledId(det,pb,led);
07116 
07117         //add the point
07118         pins[ledId].AddPoint
07119           (secCounter,rawPinLedMap[ledId].mean,
07120            rawPinLedMap[ledId].error,rawPinLedMap[ledId].numEnt);
07121 
07122         MSG("LIPlexMaps",Msg::kDebug)
07123           <<"Adding point to lirun "<<rawPinLedMap[ledId].mean<<endl;
07124       }
07125     }
07128     
07129     for(Int_t pl=FIRSTPLANE;pl<=LASTPLANE;pl++){
07130         
07131       //quick hack
07132       if (pl>5) continue;
07133 
07134       for(Int_t st=FIRSTSTRIP;st<=LASTSTRIP;st++){
07135         for(Int_t end=FIRSTEND;end<=SECONDEND;end++){
07136 
07137           if (end==StripEnd::kEast) stripEndType=StripEnd::kEast;
07138           else if (end==StripEnd::kWest) stripEndType=StripEnd::kWest;
07139 
07140           if (end==StripEnd::kEast) stripEndTypeF=StripEnd::kWest;
07141           else if(end==StripEnd::kWest) stripEndTypeF=StripEnd::kEast;
07142 
07143           PlexStripEndId stripEndId(det,pl,st,stripEndType);
07144           PlexStripEndId stripEndIdF(det,pl,st,stripEndTypeF);
07145 
07146           //skip the stripends that aren't attached to readout
07147           if (!this->IsScintStrip(stripEndId,plexHandle)) continue;
07148 
07149           pulserDrift=0;//initialise
07150           pulserDrift=dbiPulserDrift.GetRowByIndex
07151             (stripEndId.BuildPlnStripEndKey());
07152           //get the opposite strip end for the to do ND/FD
07153           pulserDriftF=0;//initialise
07154           pulserDriftF=dbiPulserDriftF.GetRowByIndex
07155             (stripEndIdF.BuildPlnStripEndKey());
07156 
07157           if (pulserDrift){
07158             Float_t mean=pulserDrift->GetMean();
07159             Float_t error=pulserDrift->GetError();
07160             Float_t numEntries=pulserDrift->GetNumEntries();
07161             UInt_t seidkey=pulserDrift->GetStripEnd();
07162 
07163             Float_t meanF=-1;
07164             Float_t errorF=-1;
07165             Float_t numEntriesF=-1;
07166 
07167             if (pulserDriftF){
07168               meanF=pulserDriftF->GetMean();
07169               errorF=pulserDriftF->GetError();
07170               numEntriesF=pulserDriftF->GetNumEntries();
07171             }
07172 
07173             Float_t nearOverFar=-1;
07174             if (meanF>0){
07175               if (stripEndType==StripEnd::kWest){
07176                 nearOverFar=mean/meanF;
07177               }
07178               else if (stripEndType==StripEnd::kEast){
07179                 nearOverFar=meanF/mean;
07180               }
07181             }
07182 
07183             Float_t adcPinRatio=-1;
07184             if (rawPin[seidkey]>0){
07185               adcPinRatio=mean/rawPin[seidkey];
07186             }
07187             else {
07188               MSG("LIPlexMaps",Msg::kDebug)
07189                 <<"Raw pin has zero mean!"<<endl;
07190             }
07191 
07192             Float_t gainDrift=-1;
07193             if (refAdcPinRatio[seidkey].mean>0){//protect fpe
07194               if (adcPinRatio>0){//only bother if this is good
07195                 gainDrift=adcPinRatio/refAdcPinRatio[seidkey].mean;
07196               }
07197             }
07198             else {
07199               MSG("LIPlexMaps",Msg::kWarning)
07200                 <<"Ref ADC/PIN ratio has zero mean!"<<endl;
07201             }
07202 
07203             MSG("LIPlexMaps",Msg::kDebug)
07204               <<"Gain drift="<<gainDrift<<endl;
07205               
07206             if (numEntries>500 && gainDrift>0){
07207               stripEnds[seidkey].AddPoint(secCounter,mean,error,
07208                                           numEntries,gainDrift,
07209                                           nearOverFar);
07210             }
07211               
07212             Int_t plane=-1;
07213             Int_t strip=-1;
07214             Int_t end=-1;
07215             fLookup.UnencodePlnStripEndKey(seidkey,det,plane,strip,
07216                                            end);
07217               
07218             string sMean=Form("%.1f",mean);
07219             string sError=Form("%.2f",error);
07220             string sNumEntries=Form("%.0f",numEntries);
07221             string sSeId=Form("%d",seidkey);
07222 
07223             MSG("LIPlexMaps",Msg::kDebug)
07224               <<"("<<plane<<";"<<strip<<";"<<end<<")"
07225               <<" Mean="<<sMean<<", error="<<sError
07226               <<", numEnt="<<sNumEntries
07227               <<", seidkey="<<sSeId<<endl;
07228           }
07229         }
07230       }
07231     }
07232 
07233     //increment the time
07234     secCounter+=pointSpacingSecs;
07235 
07236     //delete currentLoopTime;
07237     delete vldCtx;
07238     delete plexHandle;
07239   }
07240   //}
07241   
07242   MSG("LIPlexMaps",Msg::kInfo)
07243     <<"Finished main loop over vld range"<<endl;
07244 
07245   //declare the canvas sizes
07246   Int_t canvasXmax=1200;
07247   Int_t canvasYmax=600;
07248 
07249   //create the canvases
07250   TCanvas *cMeanVsTime=new TCanvas("cMeanVsTime","MeanVsTime",
07251                                    0,0,canvasXmax,canvasYmax);
07252   cMeanVsTime->SetFillColor(0);
07253   TCanvas *cErrorVsTime=new TCanvas("cErrorVsTime","ErrorVsTime",
07254                                     0,0,canvasXmax,canvasYmax);
07255   cErrorVsTime->SetFillColor(0);
07256   TCanvas *cNumEntVsTime=new TCanvas("cNumEntVsTime","NumEntVsTime",
07257                                      0,0,canvasXmax,canvasYmax);
07258   cNumEntVsTime->SetFillColor(0);
07259   TCanvas *cGainDriftVsTime=new TCanvas("cGainDriftVsTime",
07260                                         "GainDriftVsTime",
07261                                         0,0,canvasXmax,canvasYmax);
07262   cGainDriftVsTime->SetFillColor(0);
07263   TCanvas *cGainDriftVsTimeZoom=new TCanvas("cGainDriftVsTimeZoom",
07264                                         "GainDriftVsTimeZoom",
07265                                         0,0,canvasXmax,canvasYmax);
07266   cGainDriftVsTimeZoom->SetFillColor(0);
07267   TCanvas *cPinVsTime=new TCanvas("cPinVsTime","PinVsTime",
07268                                    0,0,canvasXmax,canvasYmax);
07269   cPinVsTime->SetFillColor(0);
07270   TCanvas *cNormPinVsTime=new TCanvas("cNormPinVsTime","NormPinVsTime",
07271                                       0,0,canvasXmax,canvasYmax);
07272   cNormPinVsTime->SetFillColor(0);
07273   TCanvas *cNormPinVsTimeZoom=new TCanvas("cNormPinVsTimeZoom",
07274                                           "NormPinVsTimeZoom",
07275                                           0,0,canvasXmax,canvasYmax);
07276   cNormPinVsTimeZoom->SetFillColor(0);
07277   TCanvas *cPinErrorVsTime=new TCanvas("cPinErrorVsTime",
07278                                        "PinErrorVsTime",
07279                                        0,0,canvasXmax,canvasYmax);
07280   cPinErrorVsTime->SetFillColor(0);
07281   TCanvas *cPinNumEntVsTime=new TCanvas("cPinNumEntVsTime",
07282                                         "PinNumEntVsTime",
07283                                         0,0,canvasXmax,canvasYmax);
07284   cPinNumEntVsTime->SetFillColor(0);
07285   TCanvas *cNearOverFarVsTime=new TCanvas("cNearOverFarVsTime",
07286                                     "NearOverFarVsTime",
07287                                     0,0,canvasXmax,canvasYmax);
07288   cNearOverFarVsTime->SetFillColor(0);
07289   TCanvas *cNormNearOverFarVsTime=new TCanvas("cNormNearOverFarVsTime",
07290                                     "NormNearOverFarVsTime",
07291                                     0,0,canvasXmax,canvasYmax);
07292   cNormNearOverFarVsTime->SetFillColor(0);
07293 
07294   string sMeanVsTime="MeanVsTime.ps";
07295   string sErrorVsTime="ErrorVsTime.ps";
07296   string sNumEntVsTime="NumEntVsTime.ps";
07297   string sGainDriftVsTime="GainDriftVsTime.ps";
07298   string sGainDriftVsTimeZoom="GainDriftVsTimeZoom.ps";
07299   string sPinVsTime="PinVsTime.ps";
07300   string sNormPinVsTime="NormPinVsTime.ps";
07301   string sNormPinVsTimeZoom="NormPinVsTimeZoom.ps";
07302   string sPinErrorVsTime="PinErrorVsTime.ps";
07303   string sPinNumEntVsTime="PinNumEntVsTime.ps";
07304   string sNearOverFarVsTime="NearOverFarVsTime.ps";
07305   string sNormNearOverFarVsTime="NormNearOverFarVsTime.ps";
07306 
07307   //open the files
07308   cMeanVsTime->Print((sMeanVsTime+"[").c_str());
07309   cErrorVsTime->Print((sErrorVsTime+"[").c_str());
07310   cNumEntVsTime->Print((sNumEntVsTime+"[").c_str());
07311   cGainDriftVsTime->Print((sGainDriftVsTime+"[").c_str());
07312   cGainDriftVsTimeZoom->Print((sGainDriftVsTimeZoom+"[").c_str());
07313   cPinVsTime->Print((sPinVsTime+"[").c_str());
07314   cNormPinVsTime->Print((sNormPinVsTime+"[").c_str());
07315   cNormPinVsTimeZoom->Print((sNormPinVsTimeZoom+"[").c_str());
07316   cPinErrorVsTime->Print((sPinErrorVsTime+"[").c_str());
07317   cPinNumEntVsTime->Print((sPinNumEntVsTime+"[").c_str());
07318   cNearOverFarVsTime->Print((sNearOverFarVsTime+"[").c_str());
07319   cNormNearOverFarVsTime->Print((sNormNearOverFarVsTime+"[").c_str());
07320 
07321   gErrorIgnoreLevel=1;//suppress printing each page messages
07322 
07324   //Loop over the pins
07326   map<PlexLedId,LIRun>::iterator pinIt=pins.begin();
07327 
07328   MSG("LIPlexMaps",Msg::kInfo)
07329     <<"Iterating over the pins..."<<endl;
07330   while(pinIt!=pins.end()){
07331 
07332     //get the vectors, the names are all wrong but 
07333     //the correct values were stored above
07334     vector<Double_t> vTime=pinIt->second.GetPh();
07335     vector<Double_t> vMean=pinIt->second.GetAdc();
07336     vector<Double_t> vError=pinIt->second.GetPin(1);
07337     vector<Double_t> vNumEnt=pinIt->second.GetPin(2);
07338 
07339     TGraph* gPinVsTime=0;
07340     TGraph* gNormPinVsTime=0;
07341     TGraph* gNormPinVsTimeZoom=0;
07342     TGraph* gPinErrorVsTime=0;
07343     TGraph* gPinNumEntVsTime=0;
07344     
07345     gPinVsTime=TGraphVect(vTime,vMean);
07346     gPinErrorVsTime=TGraphVect(vTime,vError);
07347     gPinNumEntVsTime=TGraphVect(vTime,vNumEnt);
07348 
07349     string sPb=Form("%d",pinIt->first.GetPulserBox());
07350     string sLed=Form("%d",pinIt->first.GetLedInBox());
07351 
07352     MSG("LIPlexMaps",Msg::kInfo)
07353       <<"Printing ("<<sPb<<":"<<sLed<<")"
07354       <<" to postscript"<<endl;
07355 
07356     cPinVsTime->cd();
07357     cPinVsTime->Clear();
07358     fS="Light level drifts (PIN ADC) with time (PB,LED)=("+
07359       sPb+","+sLed+")";
07360     gPinVsTime->Draw("AP");
07361     gPinVsTime->SetTitle(fS.c_str());
07362     gPinVsTime->GetYaxis()->SetTitle("Pin ADC");
07363     gPinVsTime->GetYaxis()->CenterTitle();
07364     this->SetGraphAxisEtc(gPinVsTime,startTimeSecs,endTimeSecs);
07365 
07366     //normalise the vector then get the graph
07367     this->NormaliseVector(vMean,2);
07368     gNormPinVsTime=TGraphVect(vTime,vMean);
07369     gNormPinVsTimeZoom=TGraphVect(vTime,vMean);
07370 
07371     cNormPinVsTime->cd();
07372     cNormPinVsTime->Clear();
07373     fS="Fractional Drifts in PIN ADC with time (PB,LED)=("+
07374       sPb+","+sLed+")";
07375     gNormPinVsTime->Draw("AP");
07376     gNormPinVsTime->SetTitle(fS.c_str());
07377     gNormPinVsTime->GetYaxis()->SetTitle("Normalised Pin ADC");
07378     gNormPinVsTime->GetYaxis()->CenterTitle();
07379     this->SetGraphAxisEtc(gNormPinVsTime,startTimeSecs,endTimeSecs); 
07380 
07381     cNormPinVsTimeZoom->cd();
07382     cNormPinVsTimeZoom->Clear();
07383     fS="Fractional Drifts in PIN ADC with time, zoomed (PB,LED)=("+
07384       sPb+","+sLed+")";
07385     gNormPinVsTimeZoom->Draw("AP");
07386     gNormPinVsTimeZoom->SetTitle(fS.c_str());
07387     gNormPinVsTimeZoom->GetYaxis()->SetTitle("Normalised Pin ADC");
07388     gNormPinVsTimeZoom->GetYaxis()->CenterTitle();
07389     this->SetGraphAxisEtc(gNormPinVsTimeZoom,startTimeSecs,endTimeSecs);
07390     gNormPinVsTimeZoom->SetMinimum(0.97);
07391     gNormPinVsTimeZoom->SetMaximum(1.03);
07392     //gNormPinVsTimeZoom->SetMinimum(1.13);
07393     //gNormPinVsTimeZoom->SetMaximum(1.23);
07394 
07395     cPinErrorVsTime->cd();
07396     cPinErrorVsTime->Clear();
07397     fS="Error on the PIN vs time (PB,LED)=("+
07398       sPb+","+sLed+")";
07399     gPinErrorVsTime->Draw("AP");
07400     gPinErrorVsTime->SetTitle(fS.c_str());
07401     gPinErrorVsTime->GetYaxis()->SetTitle("PinError in ADCs");
07402     gPinErrorVsTime->GetYaxis()->CenterTitle();
07403     this->SetGraphAxisEtc(gPinErrorVsTime,startTimeSecs,endTimeSecs); 
07404 
07405     cPinNumEntVsTime->cd();
07406     cPinNumEntVsTime->Clear();
07407     fS="PIN Number of Entries vs Time (PB,LED)=("+
07408       sPb+","+sLed+")";
07409     gPinNumEntVsTime->Draw("AP");
07410     gPinNumEntVsTime->SetTitle(fS.c_str());
07411     gPinNumEntVsTime->GetYaxis()->SetTitle("Pin's Number of Entries");
07412     gPinNumEntVsTime->GetYaxis()->CenterTitle();
07413     this->SetGraphAxisEtc(gPinNumEntVsTime,startTimeSecs,endTimeSecs); 
07414 
07415     //print to postscript
07416     cPinVsTime->Print(sPinVsTime.c_str());
07417     cNormPinVsTime->Print(sNormPinVsTime.c_str());
07418     cNormPinVsTimeZoom->Print(sNormPinVsTimeZoom.c_str());
07419     cPinErrorVsTime->Print(sPinErrorVsTime.c_str());
07420     cPinNumEntVsTime->Print(sPinNumEntVsTime.c_str());
07421 
07422     //avoid program getting too big
07423     delete gPinVsTime;
07424     delete gNormPinVsTime;
07425     delete gNormPinVsTimeZoom;
07426     delete gPinErrorVsTime;
07427     delete gPinNumEntVsTime;
07428     
07429     //go to next pin
07430     pinIt++;
07431   }
07432   MSG("LIPlexMaps",Msg::kInfo)
07433     <<"Finished iterating over the pins"<<endl;
07434 
07436   //Now look at the stripends
07438   map<UInt_t,LIRun>::iterator seIt=stripEnds.begin();
07439   Int_t pageCounter=0;
07440 
07441   MSG("LIPlexMaps",Msg::kInfo)
07442     <<endl<<"Iterating over the stripends..."
07443     <<endl<<"Map size="<<stripEnds.size()<<endl;
07444   while(seIt!=stripEnds.end()){
07445 
07446     Int_t seidkey=seIt->first;
07447     Int_t plane=-1;
07448     Int_t strip=-1;
07449     Int_t end=-1;
07450     fLookup.UnencodePlnStripEndKey(seidkey,det,plane,strip,end);
07451 
07452     string sPlane=Form("%d",plane);
07453     string sStrip=Form("%d",strip);
07454     string sEnd=Form("%d",end);
07455 
07456     //get the vectors, the names are all wrong but 
07457     //the correct values were stored above
07458     vector<Double_t> vTime=seIt->second.GetPh();
07459     vector<Double_t> vMean=seIt->second.GetAdc();
07460     vector<Double_t> vError=seIt->second.GetPin(1);
07461     vector<Double_t> vNumEnt=seIt->second.GetPin(2);
07462     vector<Double_t> vGainDrift=seIt->second.GetAdcF();
07463     vector<Double_t> vGainDriftZoom=seIt->second.GetAdcF();
07464     vector<Double_t> vNearOverFar=seIt->second.GetAdcLow();
07465 
07466     TGraph* gMeanVsTime=0;
07467     TGraph* gErrorVsTime=0;
07468     TGraph* gNumEntVsTime=0;
07469     TGraph* gGainDriftVsTime=0;
07470     TGraph* gGainDriftVsTimeZoom=0;
07471     TGraph* gNearOverFarVsTime=0;
07472     TGraph* gNormNearOverFarVsTime=0;
07473     
07474     gMeanVsTime=TGraphVect(vTime,vMean);
07475     gErrorVsTime=TGraphVect(vTime,vError);
07476     gNumEntVsTime=TGraphVect(vTime,vNumEnt);
07477     gGainDriftVsTime=TGraphVect(vTime,vGainDrift);
07478     gGainDriftVsTimeZoom=TGraphVect(vTime,vGainDriftZoom);
07479 
07480     gNearOverFarVsTime=0;
07481     if (vNearOverFar.size()>0){
07482       gNearOverFarVsTime=TGraphVect(vTime,vNearOverFar);
07483     }
07484 
07485     if (gMeanVsTime){
07486       cMeanVsTime->cd();
07487       cMeanVsTime->Clear();
07488       fS="Mean drifting with time (Pl,St,End)=("+sPlane+","+sStrip+","+
07489         sEnd+")";
07490       gMeanVsTime->Draw("AP");
07491       gMeanVsTime->SetTitle(fS.c_str());
07492       gMeanVsTime->GetYaxis()->SetTitle("Mean ADC");
07493       gMeanVsTime->GetYaxis()->CenterTitle();
07494       this->SetGraphAxisEtc(gMeanVsTime,startTimeSecs,endTimeSecs); 
07495     }
07496     else{
07497       //go to next se
07498       seIt++;
07499       MSG("LIPlexMaps",Msg::kInfo)
07500         <<"Skipping: ("<<plane<<";"<<strip<<";"<<end<<")"<<endl;
07501       continue;
07502     }
07503 
07504     if (gErrorVsTime){
07505       cErrorVsTime->cd();
07506       cErrorVsTime->Clear();
07507       fS="Error on mean over time (Pl,St,End)=("+sPlane+","+sStrip+","+
07508         sEnd+")";
07509       gErrorVsTime->Draw("AP");
07510       gErrorVsTime->SetTitle(fS.c_str());
07511       gErrorVsTime->GetYaxis()->SetTitle("Error (ADCs)");
07512       gErrorVsTime->GetYaxis()->CenterTitle();
07513       this->SetGraphAxisEtc(gErrorVsTime,startTimeSecs,endTimeSecs); 
07514     }
07515 
07516     if (gNumEntVsTime){
07517       cNumEntVsTime->cd();
07518       cNumEntVsTime->Clear();
07519       fS="NumEnt over time (Pl,St,End)=("+sPlane+","+sStrip+","+
07520         sEnd+")";
07521       gNumEntVsTime->Draw("AP");
07522       gNumEntVsTime->SetTitle(fS.c_str());
07523       gNumEntVsTime->GetYaxis()->SetTitle("NumEnt");
07524       gNumEntVsTime->GetYaxis()->CenterTitle();
07525       this->SetGraphAxisEtc(gNumEntVsTime,startTimeSecs,endTimeSecs);
07526     }
07527 
07528     if (gGainDriftVsTime){
07529       cGainDriftVsTime->cd();
07530       cGainDriftVsTime->Clear();
07531       fS="Gain drift over time (Pl,St,End)=("+sPlane+","+sStrip+","+
07532         sEnd+")";
07533       gGainDriftVsTime->Draw("AP");
07534       gGainDriftVsTime->SetTitle(fS.c_str());
07535       gGainDriftVsTime->GetYaxis()->SetTitle("Gain Drift");
07536       gGainDriftVsTime->GetYaxis()->CenterTitle();
07537       this->SetGraphAxisEtc(gGainDriftVsTime,startTimeSecs,
07538                             endTimeSecs); 
07539     }
07540       
07541     if (gGainDriftVsTimeZoom){
07542       cGainDriftVsTimeZoom->cd();
07543       cGainDriftVsTimeZoom->Clear();
07544       fS="Gain drift over time - zoomed (Pl,St,End)=("+
07545         sPlane+","+sStrip+","+sEnd+")";
07546       gGainDriftVsTimeZoom->Draw("AP");
07547       gGainDriftVsTimeZoom->SetTitle(fS.c_str());
07548       gGainDriftVsTimeZoom->GetYaxis()->SetTitle("Gain Drift");
07549       gGainDriftVsTimeZoom->GetYaxis()->CenterTitle();
07550       this->SetGraphAxisEtc(gGainDriftVsTimeZoom,startTimeSecs,
07551                             endTimeSecs);  
07552       gGainDriftVsTimeZoom->SetMaximum(1.11);
07553       gGainDriftVsTimeZoom->SetMinimum(0.89);
07554     }
07555 
07556     if (gNearOverFarVsTime){
07557       cNearOverFarVsTime->cd();
07558       cNearOverFarVsTime->Clear();
07559       fS="Ratio of ND/FD vs Time (Pl,St,End)=("+
07560         sPlane+","+sStrip+","+sEnd+")";
07561       gNearOverFarVsTime->Draw("AP");
07562       gNearOverFarVsTime->SetTitle(fS.c_str());
07563       gNearOverFarVsTime->GetYaxis()->SetTitle("Ratio ND/FD");
07564       gNearOverFarVsTime->GetYaxis()->CenterTitle();
07565       this->SetGraphAxisEtc(gNearOverFarVsTime,startTimeSecs,
07566                             endTimeSecs);
07567     }
07568     
07569     gNormNearOverFarVsTime=0;
07570     if (vNearOverFar.size()>0){
07571       this->NormaliseVector(vNearOverFar);
07572       gNormNearOverFarVsTime=TGraphVect(vTime,vNearOverFar);
07573     }
07574 
07575     if (gNormNearOverFarVsTime){
07576       cNormNearOverFarVsTime->cd();
07577       cNormNearOverFarVsTime->Clear();
07578       fS="Ratio of Normalised ND/FD vs Time (Pl,St,End)=("+
07579         sPlane+","+sStrip+","+sEnd+")";
07580       gNormNearOverFarVsTime->Draw("AP");
07581       gNormNearOverFarVsTime->SetTitle(fS.c_str());
07582       gNormNearOverFarVsTime->GetYaxis()->SetTitle("Ratio ND/FD");
07583       gNormNearOverFarVsTime->GetYaxis()->CenterTitle();
07584       this->SetGraphAxisEtc(gNormNearOverFarVsTime,startTimeSecs,
07585                             endTimeSecs);
07586     }
07587 
07588     //print to postscript
07589     cMeanVsTime->Print(sMeanVsTime.c_str());
07590     cErrorVsTime->Print(sErrorVsTime.c_str());
07591     cNumEntVsTime->Print(sNumEntVsTime.c_str());
07592     cGainDriftVsTime->Print(sGainDriftVsTime.c_str());
07593     cGainDriftVsTimeZoom->Print(sGainDriftVsTimeZoom.c_str());
07594     cNearOverFarVsTime->Print(sNearOverFarVsTime.c_str());
07595     cNormNearOverFarVsTime->Print(sNormNearOverFarVsTime.c_str());
07596 
07597     //avoid program getting too big
07598     MSG("LIPlexMaps",Msg::kVerbose)
07599       <<"Deleting graphs..."<<endl;
07600     delete gMeanVsTime;
07601     delete gErrorVsTime;
07602     delete gNumEntVsTime;
07603     delete gGainDriftVsTime;
07604     delete gGainDriftVsTimeZoom;
07605     delete gNearOverFarVsTime;
07606     delete gNormNearOverFarVsTime;
07607 
07608     pageCounter++;
07609     if (pageCounter%50==0){
07610       MSG("LIPlexMaps",Msg::kInfo)
07611         <<"Number of pages = "<<pageCounter<<endl;
07612     }
07613     else {
07614       MSG("LIPlexMaps",Msg::kVerbose)
07615         <<"Number of pages = "<<pageCounter<<endl;
07616     }
07617 
07618     //go to next se
07619     seIt++;
07620   }
07621   
07622   //close the files
07623   gErrorIgnoreLevel=0;//turn on printing messages 
07624   cMeanVsTime->Print((sMeanVsTime+"]").c_str());
07625   cErrorVsTime->Print((sErrorVsTime+"]").c_str());
07626   cNumEntVsTime->Print((sNumEntVsTime+"]").c_str());
07627   cGainDriftVsTime->Print((sGainDriftVsTime+"]").c_str());
07628   cGainDriftVsTimeZoom->Print((sGainDriftVsTimeZoom+"]").c_str());
07629   cNearOverFarVsTime->Print((sNearOverFarVsTime+"]").c_str());
07630   cNormNearOverFarVsTime->Print((sNormNearOverFarVsTime+"]").c_str());
07631 
07632   cPinVsTime->Print((sPinVsTime+"]").c_str());
07633   cNormPinVsTime->Print((sNormPinVsTime+"]").c_str());
07634   cNormPinVsTimeZoom->Print((sNormPinVsTimeZoom+"]").c_str());
07635   cPinErrorVsTime->Print((sPinErrorVsTime+"]").c_str());
07636   cPinNumEntVsTime->Print((sPinNumEntVsTime+"]").c_str());
07637 
07638   MSG("LIPlexMaps",Msg::kInfo)
07639     <<endl<<" ** Finished the DriftWithTime method... ** "<<endl; 
07640 }

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

Definition at line 4442 of file LIPlexMaps.cxx.

References 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(), MAXMSG, MSG, DbiResultPtr< T >::NewQuery(), s(), and LILookup::SetDetector().

04446 {
04447   MSG("LIPlexMaps",Msg::kInfo)
04448     <<endl<<" ** Running the DumpCalStripAtten() method... **"<<endl;
04449 
04450   //this must go first
04451   this->SetDetector(static_cast<Int_t>(det));
04452 
04453   const Int_t firstStripBin=FIRSTSTRIP-8;//-8;
04454   const Int_t lastStripBin=LASTSTRIP+9;//200;
04455   const Int_t bins=lastStripBin-firstStripBin;
04456   
04457   string s="Lambda1, East side";
04458   TH2F *hStripVsPlaneLambda1East=new TH2F(s.c_str(),s.c_str(),
04459                                       LASTSCINTPLANE-FIRSTSCINTPLANE+2,
04460                                       0,LASTSCINTPLANE+1,
04461                                       bins,firstStripBin,lastStripBin);
04462   hStripVsPlaneLambda1East->GetXaxis()->SetTitle("Plane");
04463   hStripVsPlaneLambda1East->GetXaxis()->CenterTitle();
04464   hStripVsPlaneLambda1East->GetYaxis()->SetTitle("Strip");
04465   hStripVsPlaneLambda1East->GetYaxis()->CenterTitle();
04466   
04467   s="Lambda1, West side";
04468   TH2F *hStripVsPlaneLambda1West=new TH2F(s.c_str(),s.c_str(),
04469                                       LASTSCINTPLANE-FIRSTSCINTPLANE+2,
04470                                       0,LASTSCINTPLANE+1,
04471                                       bins,firstStripBin,lastStripBin);
04472   hStripVsPlaneLambda1West->GetXaxis()->SetTitle("Plane");
04473   hStripVsPlaneLambda1West->GetXaxis()->CenterTitle();
04474   hStripVsPlaneLambda1West->GetYaxis()->SetTitle("Strip");
04475   hStripVsPlaneLambda1West->GetYaxis()->CenterTitle();
04476 
04477   s="Lambda2, East side";
04478   TH2F *hStripVsPlaneLambda2East=new TH2F(s.c_str(),s.c_str(),
04479                                       LASTSCINTPLANE-FIRSTSCINTPLANE+2,
04480                                       0,LASTSCINTPLANE+1,
04481                                       bins,firstStripBin,lastStripBin);
04482   hStripVsPlaneLambda2East->GetXaxis()->SetTitle("Plane");
04483   hStripVsPlaneLambda2East->GetXaxis()->CenterTitle();
04484   hStripVsPlaneLambda2East->GetYaxis()->SetTitle("Strip");
04485   hStripVsPlaneLambda2East->GetYaxis()->CenterTitle();
04486   
04487   s="Lambda2, West side";
04488   TH2F *hStripVsPlaneLambda2West=new TH2F(s.c_str(),s.c_str(),
04489                                       LASTSCINTPLANE-FIRSTSCINTPLANE+2,
04490                                       0,LASTSCINTPLANE+1,
04491                                       bins,firstStripBin,lastStripBin);
04492   hStripVsPlaneLambda2West->GetXaxis()->SetTitle("Plane");
04493   hStripVsPlaneLambda2West->GetXaxis()->CenterTitle();
04494   hStripVsPlaneLambda2West->GetYaxis()->SetTitle("Strip");
04495   hStripVsPlaneLambda2West->GetYaxis()->CenterTitle();
04496 
04497   s="Frac1, East side";
04498   TH2F *hStripVsPlaneFrac1East=new TH2F(s.c_str(),s.c_str(),
04499                                       LASTSCINTPLANE-FIRSTSCINTPLANE+2,
04500                                       0,LASTSCINTPLANE+1,
04501                                       bins,firstStripBin,lastStripBin);
04502   hStripVsPlaneFrac1East->GetXaxis()->SetTitle("Plane");
04503   hStripVsPlaneFrac1East->GetXaxis()->CenterTitle();
04504   hStripVsPlaneFrac1East->GetYaxis()->SetTitle("Strip");
04505   hStripVsPlaneFrac1East->GetYaxis()->CenterTitle();
04506   
04507   s="Frac1, West side";
04508   TH2F *hStripVsPlaneFrac1West=new TH2F(s.c_str(),s.c_str(),
04509                                       LASTSCINTPLANE-FIRSTSCINTPLANE+2,
04510                                       0,LASTSCINTPLANE+1,
04511                                       bins,firstStripBin,lastStripBin);
04512   hStripVsPlaneFrac1West->GetXaxis()->SetTitle("Plane");
04513   hStripVsPlaneFrac1West->GetXaxis()->CenterTitle();
04514   hStripVsPlaneFrac1West->GetYaxis()->SetTitle("Strip");
04515   hStripVsPlaneFrac1West->GetYaxis()->CenterTitle();
04516 
04517   s="Atten, East side";
04518   TH2F *hStripVsPlaneAttenEast=new TH2F(s.c_str(),s.c_str(),
04519                                       LASTSCINTPLANE-FIRSTSCINTPLANE+2,
04520                                       0,LASTSCINTPLANE+1,
04521                                       bins,firstStripBin,lastStripBin);
04522   hStripVsPlaneAttenEast->GetXaxis()->SetTitle("Plane");
04523   hStripVsPlaneAttenEast->GetXaxis()->CenterTitle();
04524   hStripVsPlaneAttenEast->GetYaxis()->SetTitle("Strip");
04525   hStripVsPlaneAttenEast->GetYaxis()->CenterTitle();
04526   
04527   s="Atten, West side";
04528   TH2F *hStripVsPlaneAttenWest=new TH2F(s.c_str(),s.c_str(),
04529                                       LASTSCINTPLANE-FIRSTSCINTPLANE+2,
04530                                       0,LASTSCINTPLANE+1,
04531                                       bins,firstStripBin,lastStripBin);
04532   hStripVsPlaneAttenWest->GetXaxis()->SetTitle("Plane");
04533   hStripVsPlaneAttenWest->GetXaxis()->CenterTitle();
04534   hStripVsPlaneAttenWest->GetYaxis()->SetTitle("Strip");
04535   hStripVsPlaneAttenWest->GetYaxis()->CenterTitle();
04536   
04537   DbiResultPtr<CalStripAtten> dbiCalStripAtten;
04538   VldContext vldCtx(det,simFlag,ts);
04539   UInt_t numRows=dbiCalStripAtten.NewQuery(vldCtx,task);
04540   
04541   //open the file  
04542   MSG("LIPlexMaps",Msg::kInfo)
04543     <<"Opening file "<<sDataFileName<<"..."<<endl;
04544   ofstream odataFile(sDataFileName.c_str());
04545 
04546   MSG("LIPlexMaps",Msg::kInfo)
04547     <<"New DB query produced "<<numRows<<" rows"
04548     <<", using task="<<task<<endl
04549     <<"Looping over rows..."<<endl;
04550   //loop over the rows
04551   for(UInt_t i=0;i<numRows;i++) {
04552     const CalStripAtten* calStripAtten=dbiCalStripAtten.GetRow(i);
04553     
04554     /*
04555   CalStripAtten (const PlexStripEndId &seid, Float_t lambda1, Float_t lambda2, Float_t frac1, Float_t lambda1err, Float_t lambda2err, Float_t frac1err) 
04556   CalStripAtten (Int_t seid_enc, Float_t lambda1, Float_t lambda2, Float_t frac1, Float_t lambda1err, Float_t lambda2err, Float_t frac1err) 
04557 virtual  ~CalStripAtten () 
04558 Bool_t  CanL2Cache () const  
04559 UInt_t  GetIndex (UInt_t) const  
04560 PlexStripEndId  GetStripEndId () const  
04561 UInt_t  GetSEIDkey () const  
04562 Float_t  GetLambda1 () const  
04563 Float_t  GetLambda2 () const  
04564 Float_t  GetFrac1 () const  
04565 Float_t  GetFrac2 () const  
04566 Float_t  GetLambda1Err () const  
04567 Float_t  GetLambda2Err () const  
04568 Float_t  GetFrac1Err () const  
04569     */
04570 
04571 
04572     Int_t seid_enc=calStripAtten->GetStripEndId().GetEncoded();    
04573     Float_t lambda1=calStripAtten->GetLambda1();
04574     Float_t lambda2=calStripAtten->GetLambda2();
04575     Float_t frac1=calStripAtten->GetFrac1();
04576     Float_t lambda1Err=calStripAtten->GetLambda1Err();
04577     Float_t lambda2Err=calStripAtten->GetLambda2Err();
04578     Float_t frac1Err=calStripAtten->GetFrac1Err();
04579     
04580     MAXMSG("LIPlexMaps",Msg::kInfo,10)
04581       <<"seid_enc="<<seid_enc
04582       <<", GetSEIDkey="<<calStripAtten->GetSEIDkey()<<endl;
04583 
04584     PlexStripEndId seid=calStripAtten->GetStripEndId();
04585     Int_t plane=seid.GetPlane();
04586     Int_t strip=seid.GetStrip();
04587     Int_t se=seid.GetEnd();
04588     Float_t x=1.5;
04589 
04590     //try changing units of distance
04591     //x=0.15;
04592 
04593     //try flipping frac1 
04594     //frac1=1-frac1;
04595 
04596     Float_t atten=frac1*exp(-x/lambda1)+(1-frac1)*exp(-x/lambda2);
04597 
04598     if (se==StripEnd::kEast){
04599       hStripVsPlaneLambda1East->Fill(plane,strip,lambda1);
04600       hStripVsPlaneLambda2East->Fill(plane,strip,lambda2);
04601       hStripVsPlaneFrac1East->Fill(plane,strip,frac1);
04602       hStripVsPlaneAttenEast->Fill(plane,strip,atten);
04603     }
04604     else {
04605       hStripVsPlaneLambda1West->Fill(plane,strip,lambda1);
04606       hStripVsPlaneLambda2West->Fill(plane,strip,lambda2);
04607       hStripVsPlaneFrac1West->Fill(plane,strip,frac1);
04608       hStripVsPlaneAttenWest->Fill(plane,strip,atten);
04609     }
04610 
04611     odataFile<<seid_enc
04612              <<"\t"<<lambda1
04613              <<"\t"<<lambda2
04614              <<"\t"<<frac1
04615              <<"\t"<<lambda1Err
04616              <<"\t"<<lambda2Err
04617              <<"\t"<<frac1Err
04618              <<endl;
04619   }
04620   MSG("LIPlexMaps",Msg::kInfo)
04621     <<"Output file completed"<<endl;
04622 
04623   TCanvas *cStripVsPlaneLambda1=new TCanvas
04624     ("cStripVsPlaneLambda1","StripVsPlane: Mean",0,0,1100,800);
04625   cStripVsPlaneLambda1->SetFillColor(0);
04626   cStripVsPlaneLambda1->Divide(1,2);
04627   cStripVsPlaneLambda1->cd(1);
04628   hStripVsPlaneLambda1East->Draw("colz");
04629   cStripVsPlaneLambda1->cd(2);
04630   hStripVsPlaneLambda1West->Draw("colz");
04631 
04632   TCanvas *cStripVsPlaneLambda2=new TCanvas
04633     ("cStripVsPlaneLambda2","StripVsPlane: Mean",0,0,1100,800);
04634   cStripVsPlaneLambda2->SetFillColor(0);
04635   cStripVsPlaneLambda2->Divide(1,2);
04636   cStripVsPlaneLambda2->cd(1);
04637   hStripVsPlaneLambda2East->Draw("colz");
04638   cStripVsPlaneLambda2->cd(2);
04639   hStripVsPlaneLambda2West->Draw("colz");
04640 
04641   TCanvas *cStripVsPlaneFrac1=new TCanvas
04642     ("cStripVsPlaneFrac1","StripVsPlane: Mean",0,0,1100,800);
04643   cStripVsPlaneFrac1->SetFillColor(0);
04644   cStripVsPlaneFrac1->Divide(1,2);
04645   cStripVsPlaneFrac1->cd(1);
04646   hStripVsPlaneFrac1East->Draw("colz");
04647   cStripVsPlaneFrac1->cd(2);
04648   hStripVsPlaneFrac1West->Draw("colz");
04649 
04650   TCanvas *cStripVsPlaneAtten=new TCanvas
04651     ("cStripVsPlaneAtten","StripVsPlane: Mean",0,0,1100,800);
04652   cStripVsPlaneAtten->SetFillColor(0);
04653   cStripVsPlaneAtten->Divide(1,2);
04654   cStripVsPlaneAtten->cd(1);
04655   hStripVsPlaneAttenEast->Draw("colz");
04656   cStripVsPlaneAtten->cd(2);
04657   hStripVsPlaneAttenWest->Draw("colz");
04658 
04659   MSG("LIPlexMaps",Msg::kInfo)
04660     <<endl<<" ** Finished the DumpCalStripAtten method... ** "<<endl;
04661 }

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

Definition at line 4402 of file LIPlexMaps.cxx.

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

04406 {
04407   MSG("LIPlexMaps",Msg::kInfo)
04408     <<endl<<" ** Running the DumpCalStripToStrip() method... **"<<endl;
04409 
04410   DbiResultPtr<CalStripToStrip> dbiCalStripToStrip;
04411   VldContext vldCtx(det,simFlag,ts);
04412   UInt_t numRows=dbiCalStripToStrip.NewQuery(vldCtx,task);
04413   
04414   //open the file  
04415   MSG("LIPlexMaps",Msg::kInfo)
04416     <<"Opening file "<<sDataFileName<<"..."<<endl;
04417   ofstream odataFile(sDataFileName.c_str());
04418 
04419   MSG("LIPlexMaps",Msg::kInfo)
04420     <<"New DB query produced "<<numRows<<" rows"
04421     <<", using task="<<task<<endl
04422     <<"Looping over rows..."<<endl;
04423   //loop over the rows
04424   for(UInt_t i=0;i<numRows;i++) {
04425     const CalStripToStrip* calStripToStrip=dbiCalStripToStrip.GetRow(i);
04426     
04427     Int_t seid_enc=calStripToStrip->GetStripEndId().GetEncoded();    
04428     Float_t resp=calStripToStrip->GetResponse();
04429     Float_t respErr=calStripToStrip->GetResponseErr();
04430     
04431     odataFile<<seid_enc<<"\t"<<resp<<"\t"<<respErr<<endl;
04432   }
04433   MSG("LIPlexMaps",Msg::kInfo)
04434     <<"Output file completed"<<endl;
04435 
04436   MSG("LIPlexMaps",Msg::kInfo)
04437     <<endl<<" ** Finished the DumpCalStripToStrip method... ** "<<endl;
04438 }

void LIPlexMaps::FactorialGen std::vector< Double_t > &  v  ) 
 

Definition at line 295 of file LIPlexMaps.cxx.

References MSG.

Referenced by BinomialGen().

00296 {
00297   MSG("LIPlexMaps",Msg::kDebug) 
00298     <<" ** Running FactorialGen method... **"<<endl;
00299 
00300   //Note: The precision of the double is not enough above 170!
00301   //166 factorial = 9.00369e+297
00302   //167 factorial = 1.50362e+300
00303   //168 factorial = 2.52608e+302
00304   //169 factorial = 4.26907e+304
00305   //170 factorial = 7.25742e+306
00306   //171 factorial = inf
00307   
00308   if (v.size()>=2){
00309     v[0]=1;
00310     v[1]=1;
00311   }
00312 
00313   for (UInt_t i=2;i<v.size();i++){
00314     v[i]=v[i-1]*i;
00315     MSG("LIPlexMaps",Msg::kInfo)<<i<<" factorial = "<<v[i]<<endl;
00316   }
00317 
00318   MSG("LIPlexMaps",Msg::kDebug) 
00319     <<" ** Finished FactorialGen method **"<<endl;
00320 }

string LIPlexMaps::GetElecString RawChannelId  rChId  )  [private]
 

Definition at line 2723 of file LIPlexMaps.cxx.

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

Referenced by PrintDbPinDiodeInfo(), and PrintPlexPinDiodeInfo().

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

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

Definition at line 8219 of file LIPlexMaps.cxx.

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

Referenced by DriftWithTime().

08220 {
08221   MSG("LIPlexMaps",Msg::kDebug)
08222     <<endl<<" ** Running the GetRawPinLedMap method... **"<<endl;
08223 
08224   PlexHandle *plexHandle=new PlexHandle(vldCtx);   
08225 
08226   DbiResultPtr<PulserRawDriftPin> driftRawPin;
08227   UInt_t numRowsPin=driftRawPin.NewQuery(vldCtx,0);
08228 
08229   if (static_cast<Int_t>(numRowsPin)!=NUMLEDS*NUMPULSERBOXES*2){
08230     MSG("LIPlexMaps",Msg::kWarning)
08231       <<"PulserRawDriftPin only contains "<<numRowsPin<<" rows"
08232       <<", expected "<<NUMLEDS*NUMPULSERBOXES*2<<endl;
08233   }
08234 
08235   map<PlexLedId,Float_t> pinAdc;
08236   map<PlexLedId,LIPulserPin> pinAdcOb;
08237 
08238   Int_t mapEntCounter=0;
08239 
08241   //loop over the pin rows
08243   for(UInt_t i=0;i<numRowsPin;i++) {
08244 
08245     //get the raw pin
08246     const PulserRawDriftPin* rawPin=driftRawPin.GetRow(i);
08247       
08248     PlexLedId ledId=plexHandle->GetLedId(rawPin->GetPinDiodeId());
08249 
08250     pair<PlexPinDiodeId,PlexPinDiodeId> plexPins=plexHandle->
08251       GetPinDiodeIds(ledId); // hi, low
08252 
08253     //ignore the low gain for now
08254     //if (rawPin->GetPinDiodeId()==plexPins.second) continue;
08255 
08256     //ignore the high gain for now
08257     if (rawPin->GetPinDiodeId()==plexPins.first) continue;
08258 
08259     MSG("LIPlexMaps",Msg::kDebug)
08260       <<"Got high gain pin:"<<endl;
08261     if (MsgService::Instance()->IsActive("LIPlexMaps",Msg::kDebug)){
08262       rawPin->GetPinDiodeId().Print();
08263     }
08264 
08265     //add the pin to the map
08266     pinAdc[ledId]=rawPin->GetMean();
08267 
08268     MSG("LIPlexMaps",Msg::kDebug)
08269       <<"Added pin mean="<<rawPin->GetMean()<<endl;
08270 
08271     pinAdcOb[ledId].mean=rawPin->GetMean();
08272     pinAdcOb[ledId].error=rawPin->GetError();
08273     pinAdcOb[ledId].numEnt=rawPin->GetNumEntries();
08274 
08275     if (rawPin->GetMean()<=0){
08276       MSG("LIPlexMaps",Msg::kInfo)
08277         <<"Warning bad pin="<<rawPin->GetMean()<<" (PB:LED)=("
08278         <<ledId.GetPulserBox()<<":"<<ledId.GetLedInBox()<<")"<<endl;
08279     }
08280 
08281     //count the number of entries
08282     mapEntCounter++;
08283   }
08284 
08285   //check the number of leds
08286   if (mapEntCounter!=NUMLEDS){
08287     MSG("LIPlexMaps",Msg::kWarning)
08288       <<"Only "<<mapEntCounter<<" entries added to pin map"<<endl;
08289   }
08290 
08291   MSG("LIPlexMaps",Msg::kDebug)
08292     <<endl<<" ** Finished the GetRawPinLedMap method... ** "<<endl; 
08293   return pinAdcOb;
08294 }

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

Definition at line 8093 of file LIPlexMaps.cxx.

References PlexStripEndId::BuildPlnStripEndKey(), PlexHandle::GetLedId(), PulserRawDriftPin::GetMean(), PulserRawDriftPin::GetPinDiodeId(), LILookup::GetPinDiodeIds(), DbiResultPtr< T >::GetRow(), MsgService::Instance(), MsgService::IsActive(), MSG, DbiResultPtr< T >::NewQuery(), and PlexPinDiodeId::Print().

Referenced by DriftWithTime().

08094 {
08095   MSG("LIPlexMaps",Msg::kDebug)
08096     <<endl<<" ** Running the GetRawPinMap method... **"<<endl;
08097 
08098   Detector::Detector_t det=Detector::kCalDet;
08099   StripEnd::EStripEnd stripEndType = StripEnd::kUnknown;
08100 
08101   PlexHandle *plexHandle=new PlexHandle(vldCtx);   
08102 
08103   DbiResultPtr<PulserRawDriftPin> driftRawPin;
08104   UInt_t numRowsPin=driftRawPin.NewQuery(vldCtx,0);
08105 
08106   if (numRowsPin!=static_cast<UInt_t>(NUMLEDS*NUMPULSERBOXES*2)){
08107     MSG("LIPlexMaps",Msg::kWarning)
08108       <<"PulserRawDriftPin only contains "<<numRowsPin<<" rows"<<endl;
08109   }
08110   map<Int_t,Float_t> pinAdc;
08111 
08112   Int_t mapEntCounter=0;
08113 
08115   //loop over the pin rows
08117   for(UInt_t i=0;i<numRowsPin;i++) {
08118 
08119     //get the raw pin
08120     const PulserRawDriftPin* rawPin=driftRawPin.GetRow(i);
08121       
08122     PlexLedId ledId=plexHandle->GetLedId(rawPin->GetPinDiodeId());
08123 
08124     pair<PlexPinDiodeId,PlexPinDiodeId> plexPins=plexHandle->
08125       GetPinDiodeIds(ledId); // hi, low
08126 
08127     //ignore the low gain for now
08128     if (rawPin->GetPinDiodeId()==plexPins.second) continue;
08129 
08130     MSG("LIPlexMaps",Msg::kDebug)
08131       <<"Got high gain pin:"<<endl;
08132     if (MsgService::Instance()->IsActive("LIPlexMaps",Msg::kDebug)){
08133       rawPin->GetPinDiodeId().Print();
08134     }
08135 
08136     for(Int_t pl=FIRSTPLANE;pl<=LASTPLANE;pl++){
08137       for(Int_t st=FIRSTSTRIP;st<=LASTSTRIP;st++){
08138         for(Int_t end=FIRSTEND;end<=SECONDEND;end++){
08139           
08140           if (end==StripEnd::kEast) stripEndType=StripEnd::kEast;
08141           else if (end==StripEnd::kWest) stripEndType=StripEnd::kWest;
08142           
08143           PlexStripEndId stripEndId(det,pl,st,stripEndType);
08144           
08145           PlexLedId currentSELedId=plexHandle->GetLedId(stripEndId);
08146 
08147           if (currentSELedId==ledId){
08148             pinAdc[stripEndId.BuildPlnStripEndKey()]=rawPin->GetMean();
08149             
08150             MSG("LIPlexMaps",Msg::kVerbose)
08151               <<"Filling map, mean="<<rawPin->GetMean()<<endl;
08152             mapEntCounter++;
08153           }
08154         }
08155       }
08156     }
08157   }
08158 
08159   if (mapEntCounter!=NUMPLANES*NUMSTRIPS*NUMENDS){
08160     MSG("LIPlexMaps",Msg::kWarning)
08161       <<"Only "<<mapEntCounter<<" entries added to pin map"<<endl;
08162   }
08163 
08164   MSG("LIPlexMaps",Msg::kDebug)
08165     <<endl<<" ** Finished the GetRawPinMap method... ** "<<endl; 
08166   return pinAdc;
08167 }

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

Definition at line 8298 of file LIPlexMaps.cxx.

References PlexStripEndId::BuildPlnStripEndKey(), VldContext::GetDetector(), PulserRefDrift::GetError(), PlexHandle::GetLedId(), PulserRefDrift::GetMean(), PulserRefDriftPin::GetMean(), PulserRefDrift::GetNumEntries(), PulserRefDriftPin::GetPinDiodeId(), LILookup::GetPinDiodeIds(), DbiResultPtr< T >::GetRow(), PulserRefDrift::GetStripEnd(), DbiResultPtr< T >::GetValidityRec(), MsgService::Instance(), MsgService::IsActive(), IsScintStrip(), MSG, DbiResultPtr< T >::NewQuery(), and PlexPinDiodeId::Print().

Referenced by DriftWithTime().

08299 {
08300   MSG("LIPlexMaps",Msg::kDebug)
08301     <<endl<<" ** Running the GetRefAdcPinRatio method... **"<<endl;
08302 
08303   map<Int_t,LIPulserPin> pinAdc;
08304 
08305   Detector::Detector_t det=vldCtx.GetDetector();
08306   StripEnd::EStripEnd stripEndType = StripEnd::kUnknown;
08307 
08308   PlexHandle *plexHandle=new PlexHandle(vldCtx);   
08309 
08310   DbiResultPtr<PulserRefDriftPin> driftRefPin;
08311   UInt_t numRowsPin=driftRefPin.NewQuery(vldCtx,0);
08312 
08313   DbiResultPtr<PulserRefDrift> dbiPulserRefDrift;
08314   UInt_t numRowsDrift=dbiPulserRefDrift.NewQuery(vldCtx,0);
08315 
08316   static string sVldRange=dbiPulserRefDrift.GetValidityRec()->
08317     GetVldRange().AsString();
08318   static Bool_t firstTime=true;
08319 
08320   if (sVldRange==dbiPulserRefDrift.GetValidityRec()->
08321       GetVldRange().AsString() && !firstTime){
08322     return pinAdc;
08323   }
08324 
08325   MSG("LIPlexMaps",Msg::kInfo)
08326     <<endl<<"Running the GetRefAdcPinRatio method..."<<endl;
08327 
08328   //set up control variables for next time
08329   firstTime=false;
08330   sVldRange=dbiPulserRefDrift.GetValidityRec()->
08331     GetVldRange().AsString();
08332 
08333   MSG("LIPlexMaps",Msg::kInfo)
08334     <<"PulserRefDrift contains "<<numRowsDrift<<" rows"<<endl
08335     <<"PulserRefDriftPin contains "<<numRowsPin<<" rows"<<endl;
08336 
08337   Int_t mapEntCounter=0;
08338 
08340   //loop over the pin rows
08342   for(UInt_t i=0;i<numRowsPin;i++) {
08343 
08344     //get the ref pin
08345     const PulserRefDriftPin* refPin=driftRefPin.GetRow(i);
08346       
08347     PlexLedId ledId=plexHandle->GetLedId(refPin->GetPinDiodeId());
08348 
08349     pair<PlexPinDiodeId,PlexPinDiodeId> plexPins=plexHandle->
08350       GetPinDiodeIds(ledId); // hi, low
08351 
08352     //ignore the low gain for now
08353     if (refPin->GetPinDiodeId()==plexPins.second) continue;
08354 
08355     MSG("LIPlexMaps",Msg::kDebug)
08356       <<"Got high gain pin:"<<endl;
08357     if (MsgService::Instance()->IsActive("LIPlexMaps",Msg::kDebug)){
08358       refPin->GetPinDiodeId().Print();
08359     }
08360 
08361     for(Int_t pl=FIRSTPLANE;pl<=LASTPLANE;pl++){
08362       for(Int_t st=FIRSTSTRIP;st<=LASTSTRIP;st++){
08363         for(Int_t end=FIRSTEND;end<=SECONDEND;end++){
08364           
08365           if (end==StripEnd::kEast) stripEndType=StripEnd::kEast;
08366           else if (end==StripEnd::kWest) stripEndType=StripEnd::kWest;
08367           
08368           PlexStripEndId stripEndId(det,pl,st,stripEndType);
08369           
08370           if (!this->IsScintStrip(stripEndId,plexHandle)) continue;
08371 
08372           PlexLedId currentSELedId=plexHandle->GetLedId(stripEndId);
08373 
08374           if (currentSELedId==ledId){
08375             pinAdc[stripEndId.BuildPlnStripEndKey()].mean=refPin->
08376               GetMean();
08377             pinAdc[stripEndId.BuildPlnStripEndKey()].error=refPin->
08378               GetError();
08379             pinAdc[stripEndId.BuildPlnStripEndKey()].numEnt=refPin->
08380               GetNumEntries();
08381             
08382             MSG("LIPlexMaps",Msg::kDebug)
08383               <<"Filling map; mean="<<refPin->GetMean()<<endl;
08384             mapEntCounter++;
08385           }
08386         }
08387       }
08388     }
08389   }
08390   MSG("LIPlexMaps",Msg::kInfo)
08391     <<"Total entries added to pin map = "<<mapEntCounter<<endl;
08392 
08393   //create the map
08394   map<Int_t,LIPulserPin> adcPinRatio;
08395   
08396   //initialise the map
08397   for(Int_t pl=FIRSTPLANE;pl<=LASTPLANE;pl++){
08398     for(Int_t st=FIRSTSTRIP;st<=LASTSTRIP;st++){
08399       for(Int_t end=FIRSTEND;end<=SECONDEND;end++){
08400         
08401         if (end==StripEnd::kEast) stripEndType=StripEnd::kEast;
08402         else if (end==StripEnd::kWest) stripEndType=StripEnd::kWest;
08403         
08404         PlexStripEndId stripEndId(det,pl,st,stripEndType);
08405         
08406         adcPinRatio[stripEndId.BuildPlnStripEndKey()].mean=-1;
08407         adcPinRatio[stripEndId.BuildPlnStripEndKey()].error=-1;
08408         adcPinRatio[stripEndId.BuildPlnStripEndKey()].numEnt=-1;
08409         
08410       }
08411     }
08412   }
08413   
08415   //loop over the pulser drift rows
08417   for(UInt_t i=0;i<numRowsDrift;i++) {
08418     //get the ref drift 
08419     const PulserRefDrift* pulserRefDrift=dbiPulserRefDrift.GetRow(i);
08420 
08421     UInt_t seidkey=pulserRefDrift->GetStripEnd();
08422 
08423     //fill the map
08424     adcPinRatio[seidkey].mean=pulserRefDrift->GetMean();
08425     adcPinRatio[seidkey].error=pulserRefDrift->GetError();
08426     adcPinRatio[seidkey].numEnt=pulserRefDrift->GetNumEntries();
08427 
08428     //calculate adc/pin (protect against fpe)
08429     if (pinAdc[seidkey].mean>0){
08430       adcPinRatio[seidkey].mean/=pinAdc[seidkey].mean;
08431 
08432       //covert the error to be a relative error
08433       adcPinRatio[seidkey].error/=pulserRefDrift->GetMean();
08434 
08435       MSG("LIPlexMaps",Msg::kDebug)
08436         <<"Filling ratio map="<<adcPinRatio[seidkey].mean
08437         <<" (+/- "<<adcPinRatio[seidkey].error*100<<"%)"<<endl;
08438     }
08439     else {
08440       MSG("LIPlexMaps",Msg::kWarning)
08441         <<"Reference pin has zero mean!"<<endl;
08442     }
08443   }
08445   //finished loop over the rows
08447 
08448   MSG("LIPlexMaps",Msg::kDebug)
08449     <<endl<<" ** Finished the GetRefAdcPinRatio method... ** "<<endl;
08450   return adcPinRatio;
08451 }

Bool_t LIPlexMaps::IsPermitted  )  const
 

Definition at line 125 of file LIPlexMaps.cxx.

References MSG.

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

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

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

Definition at line 8455 of file LIPlexMaps.cxx.

References PlexHandle::GetRawChannelId(), PlexHandle::GetReadoutType(), and MSG.

Referenced by DriftWithTime(), and GetRefAdcPinRatio().

08457 {
08458   MSG("LIPlexMaps",Msg::kVerbose)
08459     <<" ** Running the IsScintStrip method... **"<<endl;
08460 
08461   //get a raw channel id
08462   RawChannelId tempRawChId=plexHandle->GetRawChannelId(stripEndId);
08463   
08464   //check if rcid is a scintstrip
08465   if (plexHandle->GetReadoutType(tempRawChId)!=
08466       ReadoutType::kScintStrip){
08467     
08468     MSG("LIPlexMaps",Msg::kVerbose)
08469       <<"Ignoring ReadoutType="<<ReadoutType::AsString
08470       (plexHandle->GetReadoutType(tempRawChId))
08471       <<endl;       
08472     return false;
08473   }
08474 
08475   MSG("LIPlexMaps",Msg::kVerbose)
08476     <<" ** Finished IsScintStrip method... ** "<<endl; 
08477   return true;
08478 }

void LIPlexMaps::LIErrors  ) 
 

Definition at line 1628 of file LIPlexMaps.cxx.

References LILookup::CalcNpe(), LILookup::CalcRms(), fLookup, MSG, and pow().

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

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
 

Definition at line 3491 of file LIPlexMaps.cxx.

References LIPmt::AddMultiPoint(), VldRange::AsString(), PlexPixelSpotId::AsString(), Detector::AsString(), PlexStripEndId::BuildPlnStripEndKey(), DbiWriter< T >::CanOutput(), DbiWriter< T >::Close(), LIPmt::FillGainsHisto(), fLookup, Form(), fS, LIPmt::GetAvPmtGain(), RawChannelId::GetCrate(), PlexStripEndId::GetEncoded(), LILookup::GetNumericMuxBox(), PlexMuxBoxId::GetNumericMuxBox(), GetPixel(), PlexPixelSpotId::GetPixel(), PlexHandle::GetPixelSpotId(), LIPmt::GetPmtNum(), PlexHandle::GetRawChannelId(), PlexPixelSpotId::GetSpot(), PlexPixelSpotId::GetUniquePmtEncodedValue(), LIPmt::Initialise(), MsgService::Instance(), DbiWriter< T >::IsOpen(), IsPermitted(), PlexStripEndId::IsValid(), MSG, PlexPixelSpotId::Print(), PlexStripEndId::Print(), LILookup::SetDetector(), and LILookup::SetPbPlanes().

03504 {
03505   MSG("LIPlexMaps",Msg::kInfo)
03506     <<endl<<" ** Running the MakeCalAdcToPe() method... **"<<endl; 
03507 
03508   //Thanks to Ryan for the DB code of this method  
03509 
03510   //Q: What about bookends?
03511   //A: Just don't put any data in database, can't calibrate steel!
03512 
03513   //Q: What about stripends with no info?
03514   //A: Use average of that pixel.
03515 
03516   //Q: What if no info for a pixel?
03517   //A: Use the average of nearest neighbours.
03518 
03519   //Q: What about pmts with no info?
03520   //A: Use spot from a pmt that is the average of the whole detector.
03521 
03522   //Q: What about really high gains? 
03523   //A: Set error of gains over "gainTooHigh" to a high value.
03524   //   For gains over gainCeiling set gain to equal gainCeiling.
03525   //   Set the error to that for gainTooHigh.
03526 
03527   //Q: What to do about errors in above cases?
03528   //A: The errors are set to values that represent the worse case,
03529   //   where you had a two pmts from the tails of the distributions.
03530 
03531   //Q: Where to store the special values of the errors?
03532   //A: Somewhere proper eventually, but for now in cvs!
03533 
03534   //Q: What 1PE width to use?
03535   //A: The 1PE width that corresponds to the 0.8 in the gain calc
03536   //   is 0.5 of the gain. So just times gain by 0.5.
03537 
03538   //Q: How is the error calculated?
03539   //A: It is the sum of the relative errors of rms*rms/mean
03540   //   but does not include the error on the 0.8 factor.
03541 
03542   //Q: What validity range should be used?
03543   //A: For the first pass the validity is for the lifetime of the det.
03544 
03545   //Q: How would the aggregate tables be done?
03546   //A: There is a switch (aggNo). The default is "-1" for the non-aggregate tables.
03547   //   Otherwise, the tables are aggregated with the crate or the numericMuxBox
03548   //   unless aggStat of each crate or numericMuxBox has a negative value.
03549 
03550   //some old validities
03551   //VldTimeStamp fvldstart(102,9,14,15,0,1,0);   // T11 (Far-Far) 2002
03552   //VldTimeStamp fvldend(102,10,2,0,0,0,0);   // T11 (Far-Far)2002
03553   //VldTimeStamp fvldstart(102,6,6,0,0,0,0);  // T7 June 2002
03554   //VldTimeStamp fvldend(102,6,30,0,0,0,0);  // T7 June 2002
03555   //VldTimeStamp fvldstart=VldTimeStamp(2002,10,2,0,0,1); //T7 Oct 2002
03556   //VldTimeStamp fvldend=VldTimeStamp(2002,10,18,0,0,0);  //T7 Oct 2002
03557   //VldTimeStamp fvldstart=VldTimeStamp(2003,9,26,0,0,1); //T7 ND 2003
03558   //VldTimeStamp fvldend=VldTimeStamp(2003,10,8,0,0,1);  //T7 ND 2003
03559 
03560   //only do this once to set up variables
03561   this->SetDetector(det);
03562 
03563   //get a plex handle
03564   MSG("LIPlexMaps",Msg::kInfo)<<"Getting plex handle..."<<endl;
03565   VldContext vldCtx(det,SimFlag::kData,creationDate);
03566   PlexHandle plexHandle(vldCtx);
03567 
03568   gStyle->SetOptStat(1111111);
03569 
03570   TH1F *hGain=new TH1F("hGain","PMT Gains",300,-1,gainTooHigh);
03571   hGain->GetXaxis()->SetTitle("PMT Gain");
03572   hGain->GetXaxis()->CenterTitle();
03573   hGain->GetYaxis()->SetTitle("");
03574   hGain->GetYaxis()->CenterTitle();
03575   hGain->SetLineColor(2);
03576   hGain->SetFillStyle(3015);
03577   hGain->SetFillColor(2);
03578   hGain->SetLineWidth(2);
03579   //hGain->SetBit(TH1::kCanRebin);
03580 
03581   TH1F *hGainHighPmt=new TH1F("hGainHighPmt","PMT Gains: HighPmts",
03582                               100,gainTooHigh,gainCeiling+5);
03583   hGainHighPmt->GetXaxis()->SetTitle("PMT Gain");
03584   hGainHighPmt->GetXaxis()->CenterTitle();
03585   hGainHighPmt->GetYaxis()->SetTitle("");
03586   hGainHighPmt->GetYaxis()->CenterTitle();
03587   hGainHighPmt->SetLineColor(2);
03588   hGainHighPmt->SetFillStyle(3015); 
03589   hGainHighPmt->SetFillColor(2); 
03590   hGainHighPmt->SetLineWidth(2);
03591   //hGainHighPmt->SetBit(TH1::kCanRebin);
03592 
03593   TH1F *hGainCrazyHighPmt=new TH1F("hGainCrazyHighPmt",
03594                                    "PMT Gains: CrazyHighPmts",
03595                                    200,gainCeiling,gainCeiling+100);
03596   hGainCrazyHighPmt->GetXaxis()->SetTitle("PMT Gain");
03597   hGainCrazyHighPmt->GetXaxis()->CenterTitle();
03598   hGainCrazyHighPmt->GetYaxis()->SetTitle("");
03599   hGainCrazyHighPmt->GetYaxis()->CenterTitle();
03600   hGainCrazyHighPmt->SetLineColor(2);
03601   hGainCrazyHighPmt->SetFillStyle(3015); 
03602   hGainCrazyHighPmt->SetFillColor(2); 
03603   hGainCrazyHighPmt->SetLineWidth(2);
03604   hGainCrazyHighPmt->SetBit(TH1::kCanRebin);
03605 
03606   TH1F *hGainAvDet=new TH1F("hGainAvDet","PMT Gains in Av Detector PMT",
03607                             100,55,85);
03608   hGainAvDet->GetXaxis()->SetTitle("PMT Gain");
03609   hGainAvDet->GetXaxis()->CenterTitle();
03610   hGainAvDet->GetYaxis()->SetTitle("");
03611   hGainAvDet->GetYaxis()->CenterTitle();
03612   hGainAvDet->SetLineColor(2);
03613   hGainAvDet->SetFillStyle(3015); 
03614   hGainAvDet->SetFillColor(2); 
03615   hGainAvDet->SetLineWidth(2);
03616   hGainAvDet->SetBit(TH1::kCanRebin);
03617 
03618   TH1F *hGainErr=new TH1F("hGainErr","PMT GainErrs",
03619                           400,0,110);
03620   hGainErr->GetXaxis()->SetTitle("PMT GainErr");
03621   hGainErr->GetXaxis()->CenterTitle();
03622   hGainErr->GetYaxis()->SetTitle("");
03623   hGainErr->GetYaxis()->CenterTitle();
03624   hGainErr->SetLineColor(2);
03625   hGainErr->SetFillStyle(3015); 
03626   hGainErr->SetFillColor(2); 
03627   hGainErr->SetLineWidth(5);
03628   hGainErr->SetBit(TH1::kCanRebin);
03629 
03630   TH1F *hGainErrZoom=new TH1F("hGainErrZoom","PMT GainErrs (Zoomed)",
03631                           400,0,10);
03632   hGainErrZoom->GetXaxis()->SetTitle("PMT GainErrZoom");
03633   hGainErrZoom->GetXaxis()->CenterTitle();
03634   hGainErrZoom->GetYaxis()->SetTitle("");
03635   hGainErrZoom->GetYaxis()->CenterTitle();
03636   hGainErrZoom->SetLineColor(2);
03637   hGainErrZoom->SetFillStyle(3015); 
03638   hGainErrZoom->SetFillColor(2); 
03639   hGainErrZoom->SetLineWidth(2);
03640   //hGainErrZoom->SetBit(TH1::kCanRebin);
03641 
03642   TH1F *hGainErrFract=new TH1F("hGainErrFract",
03643                                "Fractional PMT GainErrs",
03644                                800,0.005,0.05);
03645   hGainErrFract->GetXaxis()->SetTitle("Fractional PMT GainErr");
03646   hGainErrFract->GetXaxis()->CenterTitle();
03647   hGainErrFract->GetYaxis()->SetTitle("");
03648   hGainErrFract->GetYaxis()->CenterTitle();
03649   hGainErrFract->SetLineColor(2);
03650   hGainErrFract->SetFillStyle(3015); 
03651   hGainErrFract->SetFillColor(2); 
03652   hGainErrFract->SetLineWidth(2);
03653   //hGainErrFract->SetBit(TH1::kCanRebin);
03654 
03655   TH1F *hSPEWidth=new TH1F("hSPEWidth","PMT SPEWidths",
03656                            300,0,gainCeiling/2+5);
03657   hSPEWidth->GetXaxis()->SetTitle("PMT SPEWidth");
03658   hSPEWidth->GetXaxis()->CenterTitle();
03659   hSPEWidth->GetYaxis()->SetTitle("");
03660   hSPEWidth->GetYaxis()->CenterTitle();
03661   hSPEWidth->SetLineColor(2);
03662   hSPEWidth->SetFillStyle(3015); 
03663   hSPEWidth->SetFillColor(2); 
03664   hSPEWidth->SetLineWidth(2);
03665   //hSPEWidth->SetBit(TH1::kCanRebin);
03666 
03667   Int_t* planeMax=new Int_t[NUMCRATES];
03668   Int_t* planeMin=new Int_t[NUMCRATES];
03669   fLookup.SetPbPlanes(planeMin,planeMax,det);
03670   
03671   const Int_t firstStripBin=FIRSTSTRIP-8;//-8;
03672   const Int_t lastStripBin=LASTSTRIP+9;//200;
03673   const Int_t bins=lastStripBin-firstStripBin;
03674 
03675   TH2F **hStripVsPlaneGain=0;
03676   hStripVsPlaneGain= new TH2F*[NUMCRATES];
03677   for (Int_t i=0;i<NUMCRATES;i++){
03678     string sPb=Form("%d",i);
03679     fS="Gains (Crate "+sPb+")";
03680     hStripVsPlaneGain[i]=new TH2F(fS.c_str(),fS.c_str(),
03681                                   planeMax[i]-planeMin[i],
03682                                   planeMin[i],planeMax[i],
03683                                   bins,firstStripBin,lastStripBin);
03684     hStripVsPlaneGain[i]->GetXaxis()->SetTitle("Plane");
03685     hStripVsPlaneGain[i]->GetXaxis()->CenterTitle();
03686     hStripVsPlaneGain[i]->GetYaxis()->SetTitle("Strip");
03687     hStripVsPlaneGain[i]->GetYaxis()->CenterTitle();
03688     hStripVsPlaneGain[i]->SetFillColor(0);
03689     //hStripVsPlaneGain[i]->SetBit(TH1::kCanRebin);
03690   }
03691 
03692   TH2F **hStripVsPlaneGainErr=0;
03693   hStripVsPlaneGainErr= new TH2F*[NUMCRATES];
03694   for (Int_t i=0;i<NUMCRATES;i++){
03695     string sPb=Form("%d",i);
03696     fS="Gain Errors (Crate "+sPb+")";
03697     hStripVsPlaneGainErr[i]=new TH2F(fS.c_str(),fS.c_str(),
03698                                      planeMax[i]-planeMin[i],
03699                                      planeMin[i],planeMax[i],
03700                                      bins,firstStripBin,lastStripBin);
03701     hStripVsPlaneGainErr[i]->GetXaxis()->SetTitle("Plane");
03702     hStripVsPlaneGainErr[i]->GetXaxis()->CenterTitle();
03703     hStripVsPlaneGainErr[i]->GetYaxis()->SetTitle("Strip");
03704     hStripVsPlaneGainErr[i]->GetYaxis()->CenterTitle();
03705     hStripVsPlaneGainErr[i]->SetFillColor(0);
03706     //hStripVsPlaneGainErr[i]->SetBit(TH1::kCanRebin);
03707   }
03708    
03709   TH2F **hStripVsPlaneSPEWidth=0;
03710   hStripVsPlaneSPEWidth= new TH2F*[NUMCRATES];
03711   for (Int_t i=0;i<NUMCRATES;i++){
03712     string sPb=Form("%d",i);
03713     fS="Single PE Width (Crate "+sPb+")";
03714     hStripVsPlaneSPEWidth[i]=new TH2F(fS.c_str(),fS.c_str(),
03715                                      planeMax[i]-planeMin[i],
03716                                      planeMin[i],planeMax[i],
03717                                      bins,firstStripBin,lastStripBin);
03718     hStripVsPlaneSPEWidth[i]->GetXaxis()->SetTitle("Plane");
03719     hStripVsPlaneSPEWidth[i]->GetXaxis()->CenterTitle();
03720     hStripVsPlaneSPEWidth[i]->GetYaxis()->SetTitle("Strip");
03721     hStripVsPlaneSPEWidth[i]->GetYaxis()->CenterTitle();
03722     hStripVsPlaneSPEWidth[i]->SetFillColor(0);
03723     //hStripVsPlaneSPEWidth[i]->SetBit(TH1::kCanRebin);
03724   }
03725 
03726   vector<Float_t> vGains(NUMPLANES*NUMSTRIPS*NUMENDS,0);
03727   vector<Float_t> vGainErrs(NUMPLANES*NUMSTRIPS*NUMENDS,0);
03728   vector<Float_t> vSPEWidths(NUMPLANES*NUMSTRIPS*NUMENDS,0);
03729   vector<Float_t> vSPEWidthErrs(NUMPLANES*NUMSTRIPS*NUMENDS,0);
03730   map<UInt_t,LIPmt> pmts;
03731   LIPmt avDetPmt;
03732   avDetPmt.Initialise(NUMPIXELS,NUMPIXELSPOTS);
03733 
03734   //variables to hold the average for whole detector
03735   Double_t gainAvDet=0;
03736   Double_t gainErrAvDet=0;
03737   Int_t gainNum=0;
03738  
03739   Float_t gainErrUnknownPixelSpot=10;//reflect variation in a pixel
03740   Float_t gainErrUnknownPixel=40;//reflect variation between NN
03741   Float_t gainErrUnknownNN=50;//reflect variation between worst pixels
03742   Float_t gainErrUnknownPmt=100;//reflect variations between worst pmts
03743   Float_t gainErrTooHighGain=90;//if cut is 150, ie could be 60
03744   Float_t SPEWidthFraction=0.5;//corresponds to the 0.8 used in gain 
03745   
03746   //open the file  
03747   MSG("LIPlexMaps",Msg::kInfo)
03748     <<"Opening file "<<sGainsFileName<<"..."<<endl;
03749   ifstream gainsFile(sGainsFileName.c_str());
03750 
03751   //check if file exists
03752   if (gainsFile){
03753 
03754     //variables to hold input from file
03755     Int_t plane=-1;
03756     Int_t strip=-1;
03757     Int_t end=-1;
03758     Float_t gain=-1;
03759     Float_t gainErr=-1;
03760     Float_t SPEWidth=-1;
03761 
03762     //printing control
03763     Int_t lastPlane=-1;
03764    
03765     //read in from the text file and fill objects
03766     while(gainsFile>>plane>>strip>>end>>gain>>gainErr>>SPEWidth) {
03767 
03768       Int_t seIndex=plane*NUMSTRIPS*NUMENDS+strip*NUMENDS+end-1;
03769 
03770       if (plane<FIRSTPLANE || plane>LASTPLANE || strip<FIRSTSTRIP || 
03771           strip>LASTSTRIP || end<FIRSTEND || end>LASTEND){
03772         MSG("LIPlexMaps",Msg::kWarning)
03773           <<"Plane, strip or stripend are out of range: plane="<<plane
03774           <<", strip="<<strip<<", end="<<end<<endl
03775           <<"Detector type is set to "<<Detector::AsString(det)
03776           <<endl
03777           <<"Program will exit here..."<<endl;
03778         exit(1);
03779       }
03780 
03781       //print stuff
03782       if (plane!=lastPlane && plane%20==0){
03783         MSG("LIPlexMaps",Msg::kInfo)<<"New plane="<<plane<<endl;
03784       }
03785       else if (plane!=lastPlane){
03786         MSG("LIPlexMaps",Msg::kDebug)<<"New plane="<<plane<<endl;
03787       }
03788       lastPlane=plane;
03789         
03790       //put file gains into vectors
03791       vGains[seIndex]=gain;
03792       vGainErrs[seIndex]=gainErr;
03793       vSPEWidths[seIndex]=SPEWidth;
03794       vSPEWidthErrs[seIndex]=0.5;
03795 
03796       //sanity check
03797       if (gain>-1 && gain<2){
03798         MSG("LIPlexMaps",Msg::kWarning)
03799           <<"What sort of gain is this? gain="<<gain<<endl;
03800       }
03801 
03802       //get stripend id
03803       PlexStripEndId seid(det,plane,strip,
03804                           static_cast<StripEnd::EStripEnd>(end));
03805       //get pixel spot id
03806       PlexPixelSpotId pixSpotId=plexHandle.GetPixelSpotId(seid);
03807 
03808       MSG("LIPlexMaps",Msg::kVerbose)
03809         <<"("<<plane<<":"<<strip<<":"<<end<<") "
03810         <<pixSpotId.AsString()<<endl;
03811 
03812       UInt_t pmtKey=pixSpotId.GetUniquePmtEncodedValue();
03813       //initialise pmt object (only done if first time)
03814       pmts[pmtKey].Initialise(NUMPIXELS,NUMPIXELSPOTS);
03815     
03816       //only add value if there is one
03817       if (gain>-1){
03818         gainErrAvDet+=gainErr;
03819         gainAvDet+=gain;
03820         gainNum++;
03821 
03822         if (pixSpotId.GetSpot()<1){
03823           seid.Print();
03824           pixSpotId.Print();
03825         }
03826 
03827         pmts[pmtKey].SetPoint(pixSpotId.GetPixel(),pixSpotId.GetSpot(),
03828                               gain);
03829         //add point to average detector PMT
03830         avDetPmt.AddMultiPoint(pixSpotId.GetPixel(),pixSpotId.GetSpot(),
03831                                gain);
03832       }
03833     }
03834   }
03835   else{
03836     MSG("LIPlexMaps",Msg::kInfo)
03837       <<"Can't open file "<<sGainsFileName<<endl
03838       <<"Exiting here..."<<endl;
03839     exit(1);
03840   }
03841   //calculate the average gain
03842   MSG("LIPlexMaps",Msg::kInfo) << "All detector gain="<<gainAvDet<<", gainErr="<<gainErrAvDet<<endl;
03843   if (gainNum!=0) gainAvDet/=gainNum;
03844   if (gainNum!=0) gainErrAvDet/=gainNum;
03845   MSG("LIPlexMaps",Msg::kInfo)
03846     <<"AverageDetector: gain= "<<gainAvDet<<" gainErr= "<<gainErrAvDet
03847     <<" gainNum= "<<gainNum
03848     <<" Npmts= "<<pmts.size()<<endl;
03849   //fill the histogram with all the gains
03850   avDetPmt.FillGainsHisto(hGainAvDet);
03851 
03853   //Section to write to database
03855   
03856   Int_t pixCounter=0;
03857   Int_t nnCounter=0;
03858   Int_t pmtCounter=0;
03859   Int_t detCounter=0;
03860   Int_t gainHighCounter=0;
03861   Int_t gainCappedCounter=0;
03862   Int_t totalCounter=0;
03863   Int_t goodCounter=0;
03864 
03865   Int_t pixgainHighCounter=0;
03866   Int_t pixgainCappedCounter=0;
03867   Int_t nngainHighCounter=0;
03868   Int_t nngainCappedCounter=0;
03869   Int_t pmtgainHighCounter=0;
03870   Int_t pmtgainCappedCounter=0;
03871   Int_t detgainHighCounter=0;
03872   Int_t detgainCappedCounter=0;
03873 
03874   //make validity range
03875   VldRange vr(det,simFlag,vldStart,vldEnd,
03876               "LISummary/LIPlexMaps::MakeCalAdcToPe");
03877 
03878   MSG("LIPlexMaps",Msg::kInfo)
03879     <<"Using Validity Range: "<<vr.AsString()<<endl;
03880 
03881   MSG("LIPlexMaps",Msg::kInfo)
03882     <<endl<<"Log comment="<<sLogComment<<endl<<endl;
03883 
03884   //create the writer
03885   DbiWriter<CalADCtoPE> writer(vr,aggNo,task,creationDate,dbName,
03886                                sLogComment);
03887 
03888   Int_t NUMAGG = NUMCRATES; if(task==1) { NUMAGG = 484; if(det==1) NUMAGG = 194; }
03889   for(Int_t agg=0;agg<NUMAGG;agg++){
03890     if(aggStat[agg]<0) continue;
03891 
03892     //create the writer
03893     if(aggNo==-1) agg = NUMAGG-1;
03894     DbiWriter<CalADCtoPEs> writers(vr,agg,task,creationDate,dbName,sLogComment);
03895 
03896     Int_t pixCounter2=0;
03897     Int_t nnCounter2=0;
03898     Int_t pmtCounter2=0;
03899     Int_t detCounter2=0;
03900     Int_t gainHighCounter2=0;
03901     Int_t gainCappedCounter2=0;
03902     Int_t totalCounter2=0;
03903     Int_t goodCounter2=0;
03904 
03905     //loop over all strip ends
03906     for(Int_t pl=FIRSTSCINTPLANE;pl<=LASTSCINTPLANE;pl++){
03907       for(Int_t st=FIRSTSTRIP;st<=LASTSTRIP;st++){
03908         for(Int_t end=FIRSTEND;end<=SECONDEND;end++) {
03909 
03910           //ignore the bookends
03911           if ((pl==SM1BOOKEND || pl==SM2BOOKEND) && 
03912               det==Detector::kFar) continue;
03913 
03914           //if (pl>70) continue;
03915           //if (pl==70) exit(1);
03916 
03917           //calculate the index
03918           Int_t seIndex=pl*NUMSTRIPS*NUMENDS+st*NUMENDS+end-1; //same to seidkey in db
03919           
03920           //get the stripend id
03921           PlexStripEndId seid(det,pl,st,
03922                               static_cast<StripEnd::EStripEnd>(end));
03923 
03924           // check whether stripend actually exists
03925           if (!seid.IsValid() ) continue;
03926 
03927           // in the near detector, a further check is needed:
03928           // partial U planes have strips 0-63
03929           // partial V planes have strips 4-67
03930           if (det==Detector::kNear) {
03931             if (((pl-1)%5) && (pl%2)    && st>63) continue;
03932             if (((pl-1)%5) && (pl%2)==0 && st<4 ) continue;
03933           }
03934           
03935           //if the crate is the same as the pbcrate, then write to DB
03936           Int_t crate=plexHandle.GetRawChannelId(seid).GetCrate();
03937           PlexPixelSpotId pixSpotId=plexHandle.GetPixelSpotId(seid);
03938           if (aggNo!=-1 && ((task==0 && crate!=agg) || (task==1 && static_cast<Int_t>(pixSpotId.GetNumericMuxBox())!=LILookup::GetNumericMuxBox(agg)))) continue;
03939 
03940           if(vGains[seIndex]==-1){
03941             
03942             Int_t pmtKey=pixSpotId.GetUniquePmtEncodedValue();
03943             
03944             //get pmt gains etc
03945             Double_t pmtGain=pmts[pmtKey].GetAvPmtGain();
03946             Int_t pmtNum=pmts[pmtKey].GetPmtNum();
03947             Double_t pixelGain=pmts[pmtKey].GetPixelGain(pixSpotId.
03948                                                          GetPixel());
03949             Int_t pixelNum=pmts[pmtKey].GetPixelNum(pixSpotId.GetPixel());
03950             Double_t nnGain=pmts[pmtKey].
03951               GetNearestNeighboursAvGain(pixSpotId.GetPixel());
03952             Int_t nnNum=pmts[pmtKey].
03953               GetNearestNeighboursNum(pixSpotId.GetPixel());
03954             
03955             Bool_t pixGood=false;
03956             Bool_t nnGood=false;
03957             Bool_t pmtGood=false;
03958             
03959             if (pixelNum>0 && pixelGain>0) pixGood=true;
03960             if (nnNum>0 && nnGain>0) nnGood=true;
03961             if (pmtNum>0 && pmtGain>0) pmtGood=true;
03962             
03963             if (pixGood){
03964               pixCounter++; pixCounter2++;
03965               vGains[seIndex]=pixelGain;
03966               vGainErrs[seIndex]=gainErrUnknownPixelSpot;
03967               vSPEWidths[seIndex]=SPEWidthFraction*vGains[seIndex];
03968               if (MsgService::Instance()->
03969                   IsActive("LIPlexMaps",Msg::kDebug)){
03970                 MSG("LIPlexMaps",Msg::kInfo)
03971                   <<"("<<pl<<":"<<st<<":"<<end<<")"
03972                   <<" No Data: Setting gain to be average of pixel ("
03973                   <<vGains[seIndex]<<")"<<endl
03974                   <<" pixGain="<<pixelGain<<" (N="<<pixelNum
03975                   <<"), nnGain="<<nnGain<<" (N="<<nnNum
03976                   <<"), pmtGain="<<pmtGain<<", (N="<<pmtNum<<")"<<endl;
03977               }
03978             }
03979             else if (nnGood){
03980               nnCounter++; nnCounter2++;
03981               vGains[seIndex]=nnGain;
03982               vGainErrs[seIndex]=gainErrUnknownPixel;
03983               vSPEWidths[seIndex]=SPEWidthFraction*vGains[seIndex];
03984               MSG("LIPlexMaps",Msg::kInfo)
03985                 <<"("<<pl<<":"<<st<<":"<<end<<")"
03986                 <<" No Data: Setting gain to be average of NN ("
03987                 <<vGains[seIndex]<<")"<<endl
03988                 <<" pixGain="<<pixelGain<<" (N="<<pixelNum
03989                 <<"), nnGain="<<nnGain<<" (N="<<nnNum
03990                 <<"), pmtGain="<<pmtGain<<", (N="<<pmtNum<<")"<<endl;
03991             }
03992             else if (pmtGood){
03993               pmtCounter++; pmtCounter2++;
03994               vGains[seIndex]=pmtGain;
03995               vGainErrs[seIndex]=gainErrUnknownNN;
03996               vSPEWidths[seIndex]=SPEWidthFraction*vGains[seIndex];
03997               MSG("LIPlexMaps",Msg::kInfo)
03998                 <<"("<<pl<<":"<<st<<":"<<end<<")"
03999                 <<" No Data: Setting gain to be average of pmt ("
04000                 <<vGains[seIndex]<<")"<<endl
04001                 <<" pixGain="<<pixelGain<<" (N="<<pixelNum
04002                 <<"), nnGain="<<nnGain<<" (N="<<nnNum
04003                 <<"), pmtGain="<<pmtGain<<", (N="<<pmtNum<<")"<<endl;
04004             }
04005             else{
04006               detCounter++; detCounter2++;
04007 
04008               Double_t avDetPmtGain=avDetPmt.GetAvPmtGain();
04009               Int_t avDetPmtNum=avDetPmt.GetPmtNum();
04010               Double_t avDetPmtPixelGain=avDetPmt.
04011                 GetPixelGain(pixSpotId.GetPixel());
04012               Int_t avDetPmtPixelNum=avDetPmt.
04013                 GetPixelNum(pixSpotId.GetPixel());
04014               
04015               Double_t avDetPmtSpotGain=avDetPmt.
04016                 GetGain(pixSpotId.GetPixel(),pixSpotId.GetSpot());
04017               
04018               vGains[seIndex]=avDetPmtSpotGain;
04019               vGainErrs[seIndex]=gainErrUnknownPmt;
04020               vSPEWidths[seIndex]=SPEWidthFraction*vGains[seIndex];
04021               MSG("LIPlexMaps",Msg::kInfo)
04022                 <<"("<<pl<<":"<<st<<":"<<end<<")"
04023                 <<" No Data: Setting gain to same spot on average pmt ("
04024                 <<vGains[seIndex]<<")"<<endl
04025                 <<" pixGain="<<avDetPmtPixelGain
04026                 <<", pixNum="<<avDetPmtPixelNum
04027                 <<", pmtGain="<<avDetPmtGain
04028                 <<", pmtNum="<<avDetPmtNum<<endl;
04029             }
04030           }
04031           else{
04032             goodCounter++; goodCounter2++;
04033           }
04034           
04035           //check that the gains aren't too high
04036           if(vGains[seIndex]>gainTooHigh){
04037             
04038             if(vGainErrs[seIndex]!=gainErrUnknownPixelSpot && vGainErrs[seIndex]!=gainErrUnknownPixel &&
04039                vGainErrs[seIndex]!=gainErrUnknownNN && vGainErrs[seIndex]!=gainErrUnknownPmt ) {
04040               
04041               //have to decrement the goodCounter if gain is too high
04042               goodCounter--; goodCounter2--;
04043               //count the high gains
04044               gainHighCounter++; gainHighCounter2++;
04045               
04046             }
04047             if(vGainErrs[seIndex]==gainErrUnknownPixelSpot) {
04048               pixgainHighCounter++; if (vGains[seIndex]>gainCeiling) pixgainCappedCounter++;
04049             }
04050             if(vGainErrs[seIndex]==gainErrUnknownPixel) {
04051               nngainHighCounter++; if (vGains[seIndex]>gainCeiling) nngainCappedCounter++;
04052             }
04053             if(vGainErrs[seIndex]==gainErrUnknownNN) {
04054               pmtgainHighCounter++; if (vGains[seIndex]>gainCeiling) pmtgainCappedCounter++;
04055             }
04056             if(vGainErrs[seIndex]==gainErrUnknownPmt) {
04057               detgainHighCounter++; if (vGains[seIndex]>gainCeiling) detgainCappedCounter++;
04058             }
04059             
04060             Int_t pmtKey=pixSpotId.GetUniquePmtEncodedValue();
04061             
04062             //get pmt gains etc
04063             Double_t pmtGain=pmts[pmtKey].GetAvPmtGain();
04064             Int_t pmtNum=pmts[pmtKey].GetPmtNum();
04065             Double_t pixelGain=pmts[pmtKey].GetPixelGain(pixSpotId.
04066                                                          GetPixel());
04067             Int_t pixelNum=pmts[pmtKey].GetPixelNum(pixSpotId.GetPixel());
04068             
04069             if (vGains[seIndex]>gainCeiling){
04070               hGainCrazyHighPmt->Fill(vGains[seIndex]);
04071              
04072               if(vGainErrs[seIndex]!=gainErrUnknownPixelSpot && vGainErrs[seIndex]!=gainErrUnknownPixel &&
04073                  vGainErrs[seIndex]!=gainErrUnknownNN && vGainErrs[seIndex]!=gainErrUnknownPmt ) {
04074  
04075                 gainCappedCounter++; gainCappedCounter2++;
04076 
04077               }
04078 
04079               Float_t oldGain=vGains[seIndex];
04080               vGains[seIndex]=gainCeiling;
04081               vSPEWidths[seIndex]=SPEWidthFraction*vGains[seIndex];
04082               
04083               MSG("LIPlexMaps",Msg::kInfo)
04084                 <<"("<<pl<<":"<<st<<":"<<end<<")"
04085                 <<" ** Capping very high gain ("<<oldGain
04086                 <<") to be gainCeiling ("<<vGains[seIndex]<<")"<<endl
04087                 <<" pixGain="<<pixelGain<<", pixNum="<<pixelNum
04088                 <<", pmtGain="<<pmtGain<<", pmtNum="<<pmtNum<<endl;
04089             }
04090             
04091             //the gain error is the same whether it was capped or not
04092             vGainErrs[seIndex]=gainErrTooHighGain;
04093             
04094             //fill the histo for high gain pmts
04095             hGainHighPmt->Fill(vGains[seIndex]);
04096           }
04097           
04098           //create CALADCTOPE table row
04099           CalADCtoPE calAdcToPe(seid.BuildPlnStripEndKey(),
04100                                 seid.GetEncoded(),vGains[seIndex],
04101                                 vGainErrs[seIndex],vSPEWidths[seIndex]);
04102           CalADCtoPEs calAdcToPes(agg,
04103                                   seid.BuildPlnStripEndKey(),vGains[seIndex],
04104                                   vGainErrs[seIndex],vSPEWidths[seIndex],vSPEWidthErrs[seIndex]);
04105 
04106           //fill the histos
04107           hGain->Fill(vGains[seIndex]);
04108           hGainErr->Fill(vGainErrs[seIndex]);
04109           hGainErrZoom->Fill(vGainErrs[seIndex]);
04110           hGainErrFract->Fill(vGainErrs[seIndex]/vGains[seIndex]);
04111           hSPEWidth->Fill(vSPEWidths[seIndex]);
04112  
04113           if (crate>=FIRSTCRATE && crate<=LASTCRATE){
04114             hStripVsPlaneGain[crate]->Fill(pl,st,vGains[seIndex]);
04115             hStripVsPlaneGainErr[crate]->Fill(pl,st,vGainErrs[seIndex]);
04116             hStripVsPlaneSPEWidth[crate]->
04117               Fill(pl,st,vSPEWidths[seIndex]);
04118           }
04119           
04120           //write the row to the dbiwriter
04121           if(aggNo==-1) writer<<calAdcToPe; else writers<<calAdcToPes;
04122           //count the number of strips written out
04123           totalCounter++; totalCounter2++;
04124           
04125           if (MsgService::Instance()->
04126               IsActive("LIPlexMaps",Msg::kVerbose)){
04127             MSG("LIPlexMaps",Msg::kInfo)
04128               <<"("<<pl<<":"<<st<<":"<<end<<")"
04129               <<" "<<vGains[seIndex]<<"  "
04130               <<vGainErrs[seIndex]<<" "<<vSPEWidths[seIndex]<<endl;
04131           }
04132         } //end of stripend loop
04133       } //end of strip loop
04134     } //end of plane loop
04135     
04136     if(aggNo!=-1) {
04137 
04138       Int_t totalCounted2=goodCounter2+pixCounter2+nnCounter2+pmtCounter2+
04139         detCounter2+gainHighCounter2;
04140       Int_t numBadStripends2=totalCounted2-goodCounter2;
04141       
04142       MSG("LIPlexMaps",Msg::kInfo)
04143         <<" AggNo= "<<setw(4)<<agg<<" Ntot= "<<setw(3)<<totalCounted2
04144         <<" Ngood= "<<setw(3)<<goodCounter2<<" Nbad= "<<setw(3)<<numBadStripends2
04145         <<" Npix= "<<setw(3)<<pixCounter2<<" Nnn= "<<setw(3)<<nnCounter2<<" Npmt= "<<setw(3)<<pmtCounter2<<" Ndet= "<<setw(3)<<detCounter2
04146         <<" Nhot= "<<setw(3)<<gainHighCounter2<<" Ncrazy= "<<setw(3)<<gainCappedCounter2<<endl;
04147 
04148       MSG("LIPlexMaps",Msg::kInfo)
04149         <<"DbiWriters.IsOpen="<<writers.IsOpen()<<endl
04150         <<"DbiWriters.CanOuptpu="<<writers.CanOutput()<<endl;
04151 
04152       if (writeToDb){
04153         if (this->IsPermitted()){
04154           MSG("LIPlexMaps",Msg::kInfo)
04155             <<"Writing to database..."<<endl;
04156           //this is the line that actually writes to the database
04157           writers.Close();
04158           MSG("LIPlexMaps",Msg::kInfo)
04159             <<"Finished writing to database"<<endl<<endl;
04160         }
04161       }
04162       else {
04163         MSG("LIPlexMaps",Msg::kInfo)
04164           <<"Mode is set to NOT write to database"<<endl<<endl;
04165       }
04166 
04167     }
04168     
04169   } //end of aggregation loop
04170 
04171   MSG("LIPlexMaps",Msg::kInfo)
04172     <<endl
04173     <<"Corrected_Info(mean+-rms): GainAvDet(overall)= "<<hGainAvDet->GetMean()<<" +- "<<hGainAvDet->GetRMS()
04174     <<" Gain(<"<<gainTooHigh<<")= "<<hGain->GetMean()<<" +- "<<hGain->GetRMS()
04175     <<" GainErrZoom= "<<hGainErrZoom->GetMean()<<" +- "<<hGainErrZoom->GetRMS()
04176     <<endl;
04177 
04178   MSG("LIPlexMaps",Msg::kInfo)
04179     <<endl
04180     <<" ** Values used in method: **"<<endl
04181     <<" NUMPLANES="<<NUMPLANES<<endl
04182     <<" NUMSTRIPS="<<NUMSTRIPS<<endl
04183     <<" NUMENDS="<<NUMENDS<<endl
04184     <<" NUMBOOKENDS="<<NUMBOOKENDS<<endl;
04185   
04186   if (det==Detector::kNear) {
04187     MSG("LIPlexMaps",Msg::kInfo)
04188       << " Total number of strip ends=" << 11616 << endl;
04189   } 
04190   else {
04191     MSG("LIPlexMaps",Msg::kInfo)
04192       <<" Total number of strip ends="
04193       <<(NUMPLANES*NUMSTRIPS*NUMENDS)-(NUMBOOKENDS*NUMSTRIPS*NUMENDS)
04194       <<endl;
04195   }
04196   
04197   Int_t totalCounted=goodCounter+pixCounter+nnCounter+pmtCounter+
04198     detCounter+gainHighCounter;
04199   Int_t numBadStripends=totalCounted-goodCounter;
04200   
04201   MSG("LIPlexMaps",Msg::kInfo)
04202     <<endl
04203     <<" ** Job Summary **"<<endl
04204     <<" Num good stripends= "<<goodCounter
04205     <<"  ( "<<100.*goodCounter/totalCounted<<" %)"<<endl
04206     <<" Num bad stripends= "<<numBadStripends
04207     <<"  ( "<<100.*numBadStripends/totalCounted<<" %)"<<endl
04208     <<"   with average pixel value= "<<pixCounter
04209     <<"  ( "<<100.*pixCounter/totalCounted<<" %)  gain too high= "<<pixgainHighCounter<<" (capped= "<<pixgainCappedCounter<<" )"<<endl
04210     <<"   with average NN value= "<<nnCounter
04211     <<"  ( "<<100.*nnCounter/totalCounted<<" %)  gain too high= "<<nngainHighCounter<<" (capped= "<<nngainCappedCounter<<" )"<<endl
04212     <<"   with average PMT value= "<<pmtCounter
04213     <<"  ( "<<100.*pmtCounter/totalCounted<<" %)  gain too high= "<<pmtgainHighCounter<<" (capped= "<<pmtgainCappedCounter<<" )"<<endl
04214     <<"   with average-detector-PMT value= "<<detCounter
04215     <<"  ( "<<100.*detCounter/totalCounted<<" %)  Equiv. num PMTs= "
04216     <<1.*detCounter/(NUMPIXELS*NUMPIXELSPOTS)<<"  gain too high= "<<detgainHighCounter<<" (capped= "<<detgainCappedCounter<<" )"<<endl
04217     <<"   with too high gain= "<<gainHighCounter
04218     <<"  ( "<<100.*gainHighCounter/totalCounted<<" %)  gain capped= "<<gainCappedCounter
04219     <<"  ( "<<100.*gainCappedCounter/totalCounted<<" %)"<<endl
04220     <<" Sum of above= "<<totalCounted<<endl
04221     <<" Total num written to DB= "<<totalCounter<<endl;
04222   
04223   if(aggNo==-1) {
04224 
04225     MSG("LIPlexMaps",Msg::kInfo)
04226       <<"DbiWriter.IsOpen="<<writer.IsOpen()<<endl
04227       <<"DbiWriter.CanOutput="<<writer.CanOutput()<<endl;
04228 
04229     if (writeToDb){
04230       if (this->IsPermitted()){
04231         MSG("LIPlexMaps",Msg::kInfo)
04232           <<"Writing to database..."<<endl;
04233         //this is the line that actually writes to the database
04234         writer.Close();
04235         MSG("LIPlexMaps",Msg::kInfo)
04236           <<"Finished writing to database"<<endl;
04237       }
04238     }
04239     else {
04240       MSG("LIPlexMaps",Msg::kInfo)
04241         <<"Mode is set to NOT write to database"<<endl;
04242     }
04243 
04244   }
04245 
04246   //set stats info
04247   gStyle->SetOptStat(1111111);
04248 
04249   //draw gains
04250   TCanvas *cGain=new TCanvas("cGain","PMT Gain",0,0,1000,600);
04251   cGain->SetFillColor(0);
04252   cGain->cd();
04253   hGain->Draw();
04254 
04255   //draw gains
04256   TCanvas *cGainHighPmt=new TCanvas("cGainHighPmt","PMT Gain: HighPmts",
04257                                     0,0,1000,600);
04258   cGainHighPmt->SetFillColor(0);
04259   cGainHighPmt->cd();
04260   hGainHighPmt->Draw();
04261   //cGainHighPmt->SetLogy();
04262 
04263   //draw crazy gains
04264   TCanvas *cGainCrazyHighPmt=new TCanvas("cGainCrazyHighPmt",
04265                                          "PMT Gain: CrazyHighPmts",
04266                                          0,0,1000,600);
04267   cGainCrazyHighPmt->SetFillColor(0);
04268   cGainCrazyHighPmt->cd();
04269   hGainCrazyHighPmt->Draw();
04270 
04271   //draw gain errs  
04272   TCanvas *cGainErr=new TCanvas("cGainErr","PMT GainErr",0,0,1000,600);
04273   cGainErr->SetFillColor(0);
04274   cGainErr->cd();
04275   hGainErr->Draw();
04276   cGainErr->SetLogy();
04277 
04278   //draw gain errs zoom
04279   TCanvas *cGainErrZoom=new TCanvas("cGainErrZoom","PMT GainErrZoom",
04280                                     0,0,1000,600);
04281   cGainErrZoom->SetFillColor(0);
04282   cGainErrZoom->cd();
04283   hGainErrZoom->Draw();
04284 
04285   //draw gain errs fract
04286   TCanvas *cGainErrFract=new TCanvas("cGainErrFract","PMT GainErrFract",
04287                                      0,0,1000,600);
04288   cGainErrFract->SetFillColor(0);
04289   cGainErrFract->cd();
04290   hGainErrFract->Draw();
04291 
04292   //draw SPEWidths
04293   TCanvas *cSPEWidth=new TCanvas("cSPEWidth","PMT SPEWidth",
04294                                  0,0,1000,600);
04295   cSPEWidth->SetFillColor(0);
04296   cSPEWidth->cd();
04297   hSPEWidth->Draw();
04298   
04299   //draw gainAvDets
04300   TCanvas *cGainAvDet=new TCanvas("cGainAvDet",
04301                                   "Gains of Av. PMT in Detector",
04302                                   0,0,1000,600);
04303   cGainAvDet->SetFillColor(0);
04304   cGainAvDet->cd();
04305   hGainAvDet->Draw();
04306 
04307   //do the gains
04308   TCanvas *cStripVsPlaneGain=new TCanvas
04309     ("cStripVsPlaneGain","StripVsPlane: Gain",0,0,1000,800);
04310   cStripVsPlaneGain->SetFillColor(0);
04311   cStripVsPlaneGain->cd();
04312   string sDbGains="DbGainsNew";
04313   sDbGains+=Detector::AsString(static_cast<Detector::
04314                                    Detector_t>(det));
04315   sDbGains+=".ps";
04316   cStripVsPlaneGain->Print((sDbGains+"[").c_str());
04317   gErrorIgnoreLevel=1;
04318   //set stats info off
04319   gStyle->SetOptStat(0);
04320   for (Int_t i=0;i<NUMCRATES;i++){  
04321     cStripVsPlaneGain->Clear();
04322     hStripVsPlaneGain[i]->Draw("colz");
04323     cStripVsPlaneGain->Print(sDbGains.c_str());
04324   }
04325   //print 1D histos at the end
04326   //set stats on
04327   gStyle->SetOptStat(1111111);
04328   cGain->Print(sDbGains.c_str());
04329   cGainAvDet->Print(sDbGains.c_str());
04330   cGainHighPmt->Print(sDbGains.c_str());
04331   cGainCrazyHighPmt->Print(sDbGains.c_str());
04332   //close the file
04333   cStripVsPlaneGain->Print((sDbGains+"]").c_str());
04334   gErrorIgnoreLevel=0;
04335 
04336   //do the gain errors
04337   TCanvas *cStripVsPlaneGainErr=new TCanvas
04338     ("cStripVsPlaneGainErr","StripVsPlane: GainErr",0,0,1000,800);
04339   cStripVsPlaneGainErr->SetFillColor(0);
04340   cStripVsPlaneGainErr->cd();
04341   string sDbGainErrs="DbGainErrsNew";
04342   sDbGainErrs+=Detector::AsString(static_cast<Detector::
04343                                        Detector_t>(det));
04344   sDbGainErrs+=".ps";
04345   cStripVsPlaneGainErr->Print((sDbGainErrs+"[").c_str());
04346   gErrorIgnoreLevel=1;
04347   //set stats off
04348   gStyle->SetOptStat(0);
04349   for (Int_t i=0;i<NUMCRATES;i++){  
04350     cStripVsPlaneGainErr->Clear();
04351     hStripVsPlaneGainErr[i]->Draw("colz");
04352     hStripVsPlaneGainErr[i]->SetMaximum(2.0*gainErrAvDet);
04353     cStripVsPlaneGainErr->Print(sDbGainErrs.c_str());
04354   }
04355   //print 1D histo at the end
04356   //set stats on
04357   gStyle->SetOptStat(1111111);
04358   cGainErr->Print(sDbGainErrs.c_str());
04359   cGainErrZoom->Print(sDbGainErrs.c_str());
04360   cGainErrFract->Print(sDbGainErrs.c_str());
04361   //close the file
04362   cStripVsPlaneGainErr->Print((sDbGainErrs+"]").c_str());
04363   gErrorIgnoreLevel=0;
04364 
04366   //do SPEWidths
04368   TCanvas *cStripVsPlaneSPEWidth=new TCanvas
04369     ("cStripVsPlaneSPEWidth","StripVsPlane: SPEWidth",0,0,1000,800);
04370   cStripVsPlaneSPEWidth->SetFillColor(0);
04371   cStripVsPlaneSPEWidth->cd();
04372   string sDbSPEWidths="DbSPEWidthsNew";
04373   sDbSPEWidths+=Detector::AsString(static_cast<Detector::
04374                                        Detector_t>(det));
04375   sDbSPEWidths+=".ps";
04376   cStripVsPlaneSPEWidth->Print((sDbSPEWidths+"[").c_str());
04377   gErrorIgnoreLevel=1;
04378   //set stats off
04379   gStyle->SetOptStat(0);
04380   for (Int_t i=0;i<NUMCRATES;i++){  
04381     cStripVsPlaneSPEWidth->Clear();
04382     hStripVsPlaneSPEWidth[i]->Draw("colz");
04383     cStripVsPlaneSPEWidth->Print(sDbSPEWidths.c_str());
04384   }
04385   //print 1D histo at the end
04386   //set stats on
04387   gStyle->SetOptStat(1111111);
04388   cSPEWidth->Print(sDbSPEWidths.c_str());
04389   //close the file
04390   cStripVsPlaneSPEWidth->Print((sDbSPEWidths+"]").c_str());
04391   gErrorIgnoreLevel=0;
04392 
04393   //set stats info on
04394   gStyle->SetOptStat(1111111);
04395 
04396   MSG("LIPlexMaps",Msg::kInfo)
04397     <<endl<<" ** Finished the MakeCalAdcToPe method... ** "<<endl;
04398 }

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 4976 of file LIPlexMaps.cxx.

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

04987 {
04988   MSG("LIPlexMaps",Msg::kInfo)
04989     <<endl<<" ** Running the MakeCalMIPCalibration() method... **"<<endl; 
04990   //this->SetDetector(det);
04991 
04992   //make validity range
04993   VldRange vr(det,simFlag,vldStart,vldEnd,
04994               "LISummary/LIPlexMaps::MakeCalMIPCalibration");
04995   MSG("LIPlexMaps",Msg::kInfo)
04996     <<"Using Validity Range: "<<vr.AsString()<<endl;
04997 
04998   MSG("LIPlexMaps",Msg::kInfo)
04999     <<"Other settings used:"<<endl
05000     <<"aggNo="<<aggNo<<endl
05001     <<"task="<<task<<endl
05002     <<"creationDate="<<creationDate<<endl
05003     <<"dbName="<<dbName<<endl
05004     <<"sLogComment="<<sLogComment<<endl
05005     <<"writeToDb="<<writeToDb<<endl;
05006 
05007   //create the writer
05008   DbiWriter<CalMIPCalibration> writer(vr,aggNo,task,creationDate,dbName,
05009                                       sLogComment);
05010 
05011   //set these to zero since you only need one entry and the calibrator
05012   //wont check the values
05013   Int_t seidkey=0;
05014   Int_t stripendid=0;
05015 
05016   //create CALADCTOPE table row
05017   CalMIPCalibration calMIPCalibration(seidkey,stripendid,scale);
05018   MSG("LIPlexMaps",Msg::kInfo)
05019     <<"Writing point with:"<<endl
05020     <<"  seidkey="<<seidkey<<endl
05021     <<"  stripendid="<<stripendid<<endl
05022     <<"  scale="<<scale<<endl;
05023 
05024   //write the row to the dbiwriter
05025   writer<<calMIPCalibration;
05026         
05027   MSG("LIPlexMaps",Msg::kInfo)
05028     <<"DbiWriter.IsOpen="<<writer.IsOpen()<<endl
05029     <<"DbiWriter.CanOutput="<<writer.CanOutput()<<endl;
05030   
05031   if (writeToDb){
05032     if (this->IsPermitted()){
05033       MSG("LIPlexMaps",Msg::kInfo)
05034         <<"Writing to database..."<<endl;
05035       //this is the line that actually writes to the database
05036       writer.Close();
05037       MSG("LIPlexMaps",Msg::kInfo)
05038         <<"Finished writing to database"<<endl;
05039     }
05040   }
05041   else {
05042     MSG("LIPlexMaps",Msg::kInfo)
05043       <<"Mode is set to NOT write to database"<<endl;
05044   }
05045 
05046   MSG("LIPlexMaps",Msg::kInfo)
05047     <<endl<<" ** Finished the MakeCalMIPCalibration method... ** "<<endl;
05048 }

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 4816 of file LIPlexMaps.cxx.

References PlexStripEndId::AsString(), VldRange::AsString(), DbiWriter< T >::CanOutput(), DbiWriter< T >::Close(), DbiWriter< T >::IsOpen(), IsPermitted(), MAXMSG, MSG, pow(), and LILookup::SetDetector().

04828 {
04829   MSG("LIPlexMaps",Msg::kInfo)
04830     <<endl<<" ** Running the MakeCalStripAtten() method... **"<<endl;
04831   //this must go first
04832   this->SetDetector(static_cast<Int_t>(det));
04833 
04834   //open the file
04835   MSG("LIPlexMaps",Msg::kInfo)
04836     <<"Opening file "<<sDataFileName<<"..."<<endl;
04837   ifstream dataFile(sDataFileName.c_str());
04838   
04839   if (!dataFile){
04840     MSG("LIPlexMaps",Msg::kInfo)
04841       <<"Can't open file "<<sDataFileName<<endl
04842       <<"Exiting here..."<<endl;
04843     exit(1);
04844   }
04845   
04846   //make validity range
04847   VldRange vr(det,simFlag,vldStart,vldEnd,
04848               "LISummary/LIPlexMaps::MakeCalStripAtten");
04849   MSG("LIPlexMaps",Msg::kInfo)
04850     <<"Using Validity Range: "<<vr.AsString()<<endl;
04851 
04852   MSG("LIPlexMaps",Msg::kInfo)
04853     <<"Log comment="<<sLogComment<<endl;
04854 
04855   //create the writer
04856   DbiWriter<CalStripAtten> writer(vr,aggNo,task,creationDate,dbName,
04857                                   sLogComment);
04858   Int_t counter=0;
04859 
04860   if (iFileFormat==0) {//this is leon/jiajie's file format
04861     MAXMSG("LIPlexMaps",Msg::kInfo,100)
04862       <<"Assuming fileFormat=0 (=Leon/Jiajie's format)"<<endl;
04863     Int_t TotalLines=12000;
04864     Char_t buffer[248], moduleid[11];
04865     Int_t plane,strip,module_strip,ndf;
04866     Double_t chi2,shortAmp,shortAmp_err,shortAtt,shortAtt_err;
04867     Double_t longAmp,longAmp_err,longAtt,longAtt_err;
04868     
04869     dataFile.getline(buffer,248);
04870     
04871     for(Int_t i=0; i<TotalLines; i++) {
04872       if(!dataFile.good()) break;
04873       dataFile >> moduleid >> module_strip >> plane >> strip >> shortAmp
04874                >> shortAmp_err >> shortAtt >> shortAtt_err >> longAmp
04875                >> longAmp_err >> longAtt >> longAtt_err >> chi2 >> ndf;
04876       
04877       Double_t frac1 = shortAmp/(shortAmp+longAmp);
04878       Double_t frac1_err = 0;
04879       Double_t SAerr_2 = pow(shortAmp_err,2);
04880       Double_t LAerr_2 = pow(longAmp_err,2);
04881       Double_t SLA = shortAmp + longAmp;
04882       
04883       if(shortAmp>0) 
04884         frac1_err = frac1 * sqrt(SAerr_2/(2*shortAmp)+
04885                                  (SAerr_2+LAerr_2)/pow(SLA,2));
04886       PlexStripEndId seid(Detector::kNear,plane,strip,StripEnd::kWest);
04887       
04888       MAXMSG("LIPlexMaps",Msg::kInfo,100)
04889         <<"Found line in file: seid_enc="<<seid.AsString()
04890         <<", shortAtt="<<shortAtt/100.<< ", longAtt=" <<longAtt/100.
04891         <<", frac1="<<frac1 << endl;
04892       
04893       CalStripAtten calStripAtten(seid,shortAtt/100.,longAtt/100.,
04894                                   frac1,shortAtt_err/100,longAtt_err/100.,
04895                                   frac1_err);
04896       writer << calStripAtten;
04897       counter++;
04898     }
04899     dataFile.getline(buffer,248);
04900   }
04901   else if (iFileFormat==1) { //this is the format from DumpCalStripAtten
04902     MAXMSG("LIPlexMaps",Msg::kInfo,100)
04903       <<"Assuming fileFormat=1 (=DumpCalStripAtten)"<<endl;
04904 
04905     Int_t seid_enc=-1;
04906     Float_t lambda1=-1;
04907     Float_t lambda2=-1;
04908     Float_t frac1=-1;
04909     Float_t lambda1Err=-1;
04910     Float_t lambda2Err=-1;
04911     Float_t frac1Err=-1;
04912 
04913     //read in from the text file and fill objects
04914     while(dataFile
04915           >>seid_enc
04916           >>lambda1
04917           >>lambda2
04918           >>frac1
04919           >>lambda1Err
04920           >>lambda2Err
04921           >>frac1Err) {
04922     
04923       MAXMSG("LIPlexMaps",Msg::kInfo,10)
04924         <<"Found line in file: seid_enc="<<seid_enc
04925         <<", lambda1="<<lambda1
04926         <<", lambda2="<<lambda2
04927         <<", frac1="<<frac1
04928         <<endl;
04929    
04930       //create CALSTRIPATTEN table row
04931       CalStripAtten calStripAtten(seid_enc,lambda1,lambda2,frac1,
04932                                   lambda1Err,lambda2Err,frac1Err);   
04933       
04934       //write the row to the dbiwriter
04935       writer<<calStripAtten;
04936       
04937       counter++;
04938     }
04939   }
04940   else {
04941     MSG("LIPlexMaps",Msg::kError)
04942       <<"Input file format not recognised = "<<iFileFormat
04943       <<", will exit here..."<<endl;
04944     exit(1);
04945   }
04946   dataFile.close();
04947   
04948   MSG("LIPlexMaps",Msg::kInfo)
04949     <<"Found "<<counter<<" rows in file: "<<sDataFileName<<endl;
04950 
04951   MSG("LIPlexMaps",Msg::kInfo)
04952     <<"DbiWriter.IsOpen="<<writer.IsOpen()<<endl
04953     <<"DbiWriter.CanOutput="<<writer.CanOutput()<<endl;
04954 
04955   if (writeToDb){
04956     if (this->IsPermitted()){
04957       MSG("LIPlexMaps",Msg::kInfo)
04958     <<"Writing to database..."<<endl;
04959       //this is the line that actually writes to the database
04960       writer.Close();
04961       MSG("LIPlexMaps",Msg::kInfo)
04962     <<"Finished writing to database"<<endl;
04963     }
04964   }
04965   else {
04966     MSG("LIPlexMaps",Msg::kInfo)
04967       <<"Mode is set to NOT write to database"<<endl;
04968   }
04969 
04970   MSG("LIPlexMaps",Msg::kInfo)
04971     <<endl<<" ** Finished the MakeCalStripAtten method... ** "<<endl;
04972 }

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 4665 of file LIPlexMaps.cxx.

References VldRange::AsString(), DbiWriter< T >::CanOutput(), DbiWriter< T >::Close(), PlexStripEndId::GetEncoded(), DbiWriter< T >::IsOpen(), IsPermitted(), MAXMSG, MSG, myCalStripToStrip::response, myCalStripToStrip::responseErr, myCalStripToStrip::seid_enc, and LILookup::SetDetector().

04676 {
04677   MSG("LIPlexMaps",Msg::kInfo)
04678     <<endl<<" ** Running the MakeCalStripToStrip() method... **"<<endl; 
04679   //this must go first
04680   this->SetDetector(static_cast<Int_t>(det));
04681 
04682   //open the file  
04683   MSG("LIPlexMaps",Msg::kInfo)
04684     <<"Opening file "<<sDataFileName<<"..."<<endl;
04685   ifstream dataFile(sDataFileName.c_str());
04686 
04687   if (!dataFile){
04688     MSG("LIPlexMaps",Msg::kInfo)
04689       <<"Can't open file "<<sDataFileName<<endl
04690       <<"Exiting here..."<<endl;
04691     exit(1);
04692   }
04693  
04694   //make validity range
04695   VldRange vr(det,simFlag,vldStart,vldEnd,
04696               "LISummary/LIPlexMaps::MakeCalStripToStrip");
04697   MSG("LIPlexMaps",Msg::kInfo)
04698     <<"Using Validity Range: "<<vr.AsString()<<endl;
04699   
04700   MSG("LIPlexMaps",Msg::kInfo)
04701     <<"Log comment="<<sLogComment<<endl;
04702 
04703   //create the writer
04704   DbiWriter<CalStripToStrip> writer(vr,aggNo,task,creationDate,dbName,
04705                                     sLogComment);
04706    
04707   Int_t seid_enc=-1;
04708   Float_t resp=-1;
04709   Float_t respErr=-1;
04710   Float_t defaultResp=1;
04711   Float_t defaultRespErr=1;
04712 
04713   Int_t counter=0;
04714 
04715   //map to store all the calsts
04716   map<Int_t,myCalStripToStrip> inputCalSts;
04717   
04718   //initialise map according to the expected number of strips
04719   //this was written to fill gaps in tables
04720   for (Int_t pl=FIRSTSCINTPLANE;pl<=LASTSCINTPLANE;pl++){
04721     for (Int_t st=FIRSTSTRIP;st<=LASTSTRIP;st++){
04722 
04723       //continue if not FI - happens in pl!=6,11,16,...
04724       if (det==Detector::kNear && st>67 && (pl-1)%5!=0) continue; 
04725       
04726       //continue if in spectrometer and not pl=121,126,131,...
04727       if (det==Detector::kNear && pl>120 && (pl-1)%5!=0) continue; 
04728       
04729       //cut out the SM2 bookend
04730       if (det==Detector::kFar && pl==249) continue;
04731 
04732       MAXMSG("LIPlexMaps",Msg::kInfo,10)
04733         <<"pl="<<pl<<", st="<<st<<endl;
04734 
04735       PlexStripEndId seidE(det,pl,st,StripEnd::kEast);
04736       PlexStripEndId seidW(det,pl,st,StripEnd::kWest);
04737       
04738       //only write the east side if not ND
04739       if (det!=Detector::kNear){
04740         MAXMSG("LIPlexMaps",Msg::kInfo,1)
04741           <<endl<<"Detector is not ND thus creating East stripends..."
04742           <<endl;
04743         inputCalSts[seidE.GetEncoded()]=myCalStripToStrip
04744           (seidE.GetEncoded(),defaultResp,defaultRespErr);;
04745       }
04746       
04747       //always write the west side
04748       inputCalSts[seidW.GetEncoded()]=myCalStripToStrip
04749         (seidW.GetEncoded(),defaultResp,defaultRespErr);;
04750       //inputCalSts[seidW.GetEncoded()]=calStripToStripW;
04751     }
04752   }
04753 
04754   MSG("LIPlexMaps",Msg::kInfo)
04755     <<"Map initialised with size="<<inputCalSts.size()<<endl;
04756 
04757   //read in from the text file and fill objects
04758   while(dataFile>>seid_enc>>resp>>respErr) {
04759     
04760     MAXMSG("LIPlexMaps",Msg::kInfo,10)
04761       <<"Found line in file: seid_enc="<<seid_enc
04762       <<", resp="<<resp<<", respErr="<<respErr<<endl;
04763 
04764     //create CALSTRIPTOSTRIP table row
04765     //CalStripToStrip calStripToStrip(seid_enc,resp,respErr);
04766 
04767     //write the new calsts to the map (this overwrites initial object)    
04768     inputCalSts[seid_enc]=myCalStripToStrip(seid_enc,resp,respErr);;
04769 
04770     //write the row to the dbiwriter
04771     //writer<<calStripToStrip;//can write below if rows missing
04772 
04773     counter++;
04774   }
04775 
04776   MSG("LIPlexMaps",Msg::kInfo)
04777     <<"Found "<<counter<<" rows in file: "<<sDataFileName
04778     <<", mapSize="<<inputCalSts.size()<<endl;
04779 
04780   //loop over map and write to database
04781   typedef map<Int_t,myCalStripToStrip>::const_iterator stsIt;
04782   for (stsIt it=inputCalSts.begin();it!=inputCalSts.end();it++){
04783     const myCalStripToStrip& c=it->second;
04784     CalStripToStrip calStripToStrip(c.seid_enc,c.response,c.responseErr);
04785     MAXMSG("LIPlexMaps",Msg::kInfo,10)
04786       <<"Writing to database: seidEnc="<<c.seid_enc
04787       <<", resp="<<c.response<<", respErr="<<c.responseErr<<endl;
04788     writer<<calStripToStrip;
04789   }
04790 
04791   MSG("LIPlexMaps",Msg::kInfo)
04792     <<"DbiWriter.IsOpen="<<writer.IsOpen()<<endl
04793     <<"DbiWriter.CanOutput="<<writer.CanOutput()<<endl;
04794   
04795   if (writeToDb){
04796     if (this->IsPermitted()){
04797       MSG("LIPlexMaps",Msg::kInfo)
04798         <<"Writing to database..."<<endl;
04799       //this is the line that actually writes to the database
04800       writer.Close();
04801       MSG("LIPlexMaps",Msg::kInfo)
04802         <<"Finished writing to database"<<endl;
04803     }
04804   }
04805   else {
04806     MSG("LIPlexMaps",Msg::kInfo)
04807       <<"Mode is set to NOT write to database"<<endl;
04808   }
04809 
04810   MSG("LIPlexMaps",Msg::kInfo)
04811     <<endl<<" ** Finished the MakeCalStripToStrip method... ** "<<endl;
04812 }

void LIPlexMaps::MakePinPlexTables  ) 
 

Definition at line 3429 of file LIPlexMaps.cxx.

References fLookup, PlexLedId::GetEncoded(), PlexLedId::GetLedInBox(), LILookup::GetPinDiodeIds(), PlexLedId::GetPulserBox(), and MSG.

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

void LIPlexMaps::MakePlexStripEndToLed Bool_t  writeToDb = false  ) 
 

a hack for caldet because both side of plane zero

Definition at line 5052 of file LIPlexMaps.cxx.

References ReadoutType::AsString(), DbiWriter< T >::CanOutput(), DbiWriter< T >::Close(), fLookup, Form(), fS, PlexLedId::GetEncoded(), PlexHandle::GetRawChannelId(), PlexHandle::GetReadoutType(), DbiWriter< T >::IsOpen(), IsPermitted(), MSG, VldRange::Print(), VldTimeStamp::Print(), LILookup::SetPbPlanes(), and LILookup::Strip2Led().

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

void LIPlexMaps::NonLinearity  ) 
 

Definition at line 1021 of file LIPlexMaps.cxx.

References MSG, pow(), and LILookup::TGraphVect().

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

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

Definition at line 164 of file LIPlexMaps.cxx.

References MSG.

Referenced by DriftWithTime().

00165 {
00166   MSG("LIPlexMaps",Msg::kDebug) 
00167     <<" ** Running NormaliseVector method... **"<<endl;
00168   
00169   if (v.size()>0){
00170 
00171     if (mode==1){//simple average
00172       //find average
00173       Double_t average=0;
00174       for (UInt_t i=0;i<v.size();i++) average+=v[i];
00175       average/=v.size();
00176       
00177       MSG("LIPlexMaps",Msg::kVerbose)<<"Average="<<average<<endl; 
00178       
00179       //normalise
00180       for (UInt_t i=0;i<v.size();i++) v[i]/=average;
00181     }
00182     else if (mode==2){//fit the function to remove effect of outliers
00183       
00184       Double_t vMax=-9e50;
00185       Double_t vMin=9e50;
00186 
00187       //work out mins and maxs
00188       for (UInt_t i=0;i<v.size();i++){
00189         if (v[i]>vMax) vMax=v[i];
00190         if (v[i]<vMin) vMin=v[i];
00191       }
00192       
00193       //limit the number of bins
00194       Int_t numBins=300;
00195       if (4*v.size()<10000) numBins=4*v.size();
00196 
00197       MSG("LIAnalysis",Msg::kInfo)
00198         <<"vMax="<<vMax <<", vMin="<<vMin<<", numBins="<<numBins<<endl;
00199 
00200       //create the histo
00201       //30/Aug/04 - changed to using fabs, not sure if this will work!
00202       TH1F* h=new TH1F("h","h",numBins,vMin-fabs(0.1*vMin),
00203                        vMax+fabs(0.1*vMin));
00204       h->SetBit(TH1::kCanRebin);
00205 
00206       Double_t average=0;
00207       for (UInt_t i=0;i<v.size();i++){
00208         //find average
00209         average+=v[i];
00210 
00211         //fill the histo
00212         h->Fill(v[i]);
00213       }
00214       average/=v.size();
00215 
00216       //fit but use 0 (zero!) otherwise it stamps on the current canvas!
00217       h->Fit("gaus","q0");
00218       TF1* func=h->GetFunction("gaus");
00219       Double_t p1=func->GetParameter(1);
00220       Double_t p2=func->GetParameter(2);
00221 
00222       //don't use the fit if it is screwed up
00223       Double_t avToNormWith=p1;
00224       if (p1<vMin || p1>vMax) avToNormWith=average;
00225 
00226       MSG("LIAnalysis",Msg::kInfo)
00227         <<"Fitted mean="<<p1
00228         <<" (average="<<average
00229         <<") fitted rms="<<p2
00230         <<", using avToNormWith="<<avToNormWith<<endl;
00231 
00232       //normalise
00233       for (UInt_t i=0;i<v.size();i++) v[i]/=avToNormWith;
00234 
00235       delete h;
00236     }
00237   }
00238 
00239   MSG("LIPlexMaps",Msg::kDebug) 
00240     <<" ** Finished NormaliseVector method **"<<endl;
00241 }

void LIPlexMaps::PeGen  ) 
 

Definition at line 1183 of file LIPlexMaps.cxx.

References LILookup::CalcGain(), LILookup::CalcNpe(), LILookup::CalcRms(), fLookup, MSG, pow(), SampleDist(), and ScaleVector().

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

void LIPlexMaps::PlotPlexPinMap  ) 
 

Definition at line 1782 of file LIPlexMaps.cxx.

References MSG.

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

void LIPlexMaps::PlotPlexStripMap Int_t  detectorType  ) 
 

Definition at line 2755 of file LIPlexMaps.cxx.

References VldContext::AsString(), draw(), 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(), PlexPixelSpotId::IsValid(), PlexLedId::IsValid(), PlexStripEndId::IsValid(), PlexPlaneId::IsValid(), and MSG.

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

void LIPlexMaps::PrintDbPinDiodeInfo  ) 
 

Definition at line 2533 of file LIPlexMaps.cxx.

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

02534 {
02535   VldTimeStamp timeStamp;//now
02536   
02537   //get validity context for detector
02538   VldContext vldc(Detector::kFar,SimFlag::kData,timeStamp);
02539   
02540   DbiResultPtr<PlexRawChannelToPinDiode> rc2pdResPtr(vldc);
02541 
02542   cout<<"Num of PlexRawChannelToPinDiode rows="
02543       <<rc2pdResPtr.GetNumRows()<<endl;
02544   
02545   for (UInt_t irow = 0; irow < rc2pdResPtr.GetNumRows(); ++irow) {
02546     
02547     const PlexRawChannelToPinDiode* rc2pd = rc2pdResPtr.GetRow(irow);
02548     
02549     RawChannelId    rcid = rc2pd->GetRawChannelId();
02550     PlexPinDiodeId pinid = rc2pd->GetPlexPinDiodeId();
02551 
02552     cout<<"row="<<irow<<", rcid="<<this->GetElecString(rcid)
02553         <<", pinid="<<pinid<<", g="<<pinid.GetGain()
02554         <<", inbox="<<pinid.GetInBox()<<