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

LIAnalysis Class Reference

#include <LIAnalysis.h>

Inheritance diagram for LIAnalysis:

LILookup List of all members.

Public Member Functions

 LIAnalysis (Int_t analyseChainFlag)
 ~LIAnalysis ()
void AdcVsChannel (Int_t plane, Int_t crate)
void AdcDistribution ()
void AdcVsLed ()
void AdcVsPin ()
void AdcVsPixel (Int_t plane, Int_t AshtrayMin=-1, Int_t AshtrayMax=-1, Int_t led=-1)
void AshtrayVsPlane (Int_t nearPb, Int_t farPb)
void CalcAdcAv ()
void ChannelAdc (Int_t chan, Int_t chan2)
void CheckData (Int_t rt=-1)
void ClearFibres ()
void GainCurves (Int_t pulserBoxToPlot=0, Int_t maxLedToPlot=6)
void GainCurves_Led ()
void GainVsTime ()
void DebugPins ()
void HighGainSearch (Int_t maxAdcThreshold, Float_t gainThreshold)
void IndividualChannels ()
void LedTuning (Int_t pNum, Int_t pWidth, Int_t idealAdc, const Int_t numGcPoints, Double_t firstGcPoint, Double_t lastGcPoint, Double_t dADCdPHAtSat, Int_t numCalibPoints=-1, Int_t numSecondFile=0)
void LISnarlProblem ()
void MiswiringSearch (Int_t adcThreshold)
void NumPulses ()
void PinDiode ()
void PinDiodeChips ()
void PinMap ()
void PixelVsPlane (Int_t nearPb, Int_t farPb)
void PmtGain (Int_t plane, Int_t cr, Int_t printGain)
void PrintElec ()
void PrintPmt ()
void Reflectors (LILookup::ELINearOrFarSide nearOrFarSide)
void ReflectorsGc (LILookup::ELINearOrFarSide nearOrFarSide)
void SearchForBadLeds (Int_t minNumHits=200)
void StripVsPlane (Int_t nearPb=0, Int_t farPb=0, Int_t ledCut=-1)
void StripVsPlaneWholeDet ()
void Template ()
void Test ()
void TriggerPmt ()
void WriteGainCurveTextFile ()
void WriteGainsTextFile (Int_t task=1)
void WriteOldGainsTextFile ()
void NoisyChips (Float_t)

Private Member Functions

void AnalyseChain ()
void AppendVect (std::vector< Double_t > &trunk, std::vector< Double_t > appendix)
std::string GetElecString ()
void InitialiseLoopVariables ()
void MakeChain ()
void PrintBigMessage ()
void PrintBlockInfo (std::string preString)
void PrintGainTableRow (Int_t pl, Int_t st, Int_t end, std::string sPrefix, std::string sAdcN, std::string sGainN, std::string sGainErrN, std::string sNumN, std::string sAdcF, std::string sGainF, std::string sGainErrF, std::string sNumF, std::string sLogLevel="Debug")
void SetChainBranches ()
void SetLoopVariables (Int_t entry, Int_t printOnNewLed=0, Bool_t doInfoPrint=true)
TGraph * TGraphVect (std::vector< Double_t > &vX, std::vector< Double_t > &vY)

Private Attributes

Int_t ashtray
Int_t calibPoint
Int_t calibType
Int_t chAdd
TChain * chain
Int_t channel
Int_t chip
Int_t correlatedHit
Int_t crate
Int_t detectorType
Int_t eastWest
Int_t elecType
Int_t farLed
Int_t farPulserBox
Int_t firstRunNumber
Int_t geoAdd
char histname [80]
Int_t highRunNumber
Int_t inRack
Int_t lastLed
Int_t lastCalibPoint
Int_t lastPulserBox
Int_t lastRunNumber
Int_t led
Int_t liEvent
Int_t liRunNum
LILookup lookup
Int_t lowRunNumber
Int_t masterCh
Int_t maxLedNum
Int_t maxPbNum
Int_t maxCalibPoint
Float_t mean
Int_t minderCh
Int_t nearLed
Int_t nearPulserBox
Int_t numCalibPoints
Int_t numEntries
Int_t numericMuxBox
Int_t numEvents
Int_t numLeds
Int_t numLiEvents
std::map< Int_t, Int_t > numLiEventsL
std::map< Int_t, Int_t > numLiEventsP
Int_t numLiRuns
Int_t period
Int_t pixel
Int_t pinGain
Int_t pinInBox
Int_t plane
Int_t previousRunNumber
Int_t pulseHeight
Int_t pulserBox
Int_t pulses
Int_t pulseWidth
Int_t rackBay
Int_t rackLevel
Int_t readoutType
Float_t rms
Int_t run
Int_t runNumber
Int_t runNumberSub
Int_t runType
std::string s
std::string fS
Int_t strip
Int_t stripEnd
Int_t summaryCounter
Int_t timestamp
Int_t timestampNanoSec
Int_t varc
Int_t vfb
Int_t vmm

Constructor & Destructor Documentation

LIAnalysis::LIAnalysis Int_t  analyseChainFlag  ) 
 

Definition at line 65 of file LIAnalysis.cxx.

References AnalyseChain(), ashtray, calibPoint, calibType, chAdd, chain, channel, chip, correlatedHit, crate, detectorType, eastWest, elecType, farLed, farPulserBox, firstRunNumber, fS, geoAdd, highRunNumber, histname, inRack, lastCalibPoint, lastLed, lastPulserBox, lastRunNumber, led, liEvent, liRunNum, lowRunNumber, MakeChain(), masterCh, maxCalibPoint, maxLedNum, maxPbNum, mean, minderCh, MSG, nearLed, nearPulserBox, numCalibPoints, numEntries, numericMuxBox, numEvents, numLeds, numLiEvents, numLiEventsL, numLiEventsP, numLiRuns, period, pinGain, pinInBox, pixel, plane, previousRunNumber, pulseHeight, pulserBox, pulses, pulseWidth, rackBay, rackLevel, readoutType, rms, run, runNumber, runNumberSub, runType, s, SetChainBranches(), LILookup::SetDetector(), strip, stripEnd, summaryCounter, timestamp, timestampNanoSec, varc, vfb, and vmm.

00066 {
00067   MSG("LIAnalysis", Msg::kDebug) 
00068     <<"Running LIAnalysis constructor..."<<endl;
00069 
00070   //use the pretty palette
00071   gStyle->SetPalette(1);
00072   //include the under and overflow counts
00073   gStyle->SetOptStat(1111111);
00074   gStyle->SetOptFit(1111);
00075 
00076   //data members
00077   ashtray=-1;
00078   calibPoint=-1;
00079   calibType=-1;
00080   chAdd=-1;
00081   chain=0;
00082   channel=-1;
00083   chip=-1;
00084   correlatedHit=-1;
00085   crate=-1;
00086   detectorType=-1;
00087   eastWest=-1;//0 is east, 1 is west 
00088   elecType=-1;
00089   farLed=-1;
00090   farPulserBox=-1;
00091   firstRunNumber=-1;
00092   geoAdd=-1;
00093   highRunNumber=-1;
00094   for (Int_t i=0;i<80;i++){
00095     histname[i]='?';
00096   }
00097   inRack=-1;//determines mux box in rack 0-7
00098   lastLed=-1;
00099   lastCalibPoint=-1;
00100   lastPulserBox=-1;
00101   lastRunNumber=-1;
00102   led=-1;
00103   liEvent=-1;
00104   liRunNum=-1;
00105   lowRunNumber=-1;
00106   masterCh=-1;
00107   maxLedNum=-1;
00108   maxPbNum=-1;
00109   maxCalibPoint=-1;
00110   mean=-1.;
00111   minderCh=-1;
00112   nearLed=-1;
00113   nearPulserBox=-1;
00114   numCalibPoints=0;
00115   numEntries=-1;
00116   numericMuxBox=-1;
00117   numEvents=-1; 
00118   numLeds=-1;
00119   numLiEvents=-1;
00120   for (Int_t i=0;i<NUMLEDS;i++){
00121     numLiEventsL[i]=0;
00122   }
00123   for (Int_t i=0;i<NUMPULSERBOXES;i++){
00124     numLiEventsP[i]=0;
00125   }
00126   numLiRuns=-1;
00127   period=-1;
00128   pixel=-1;
00129   pinGain=-1;//0 is low, 1 is high gain
00130   pinInBox=-1;//0 is low gain (VA=0), 1 is high gain (VA=1)
00131   plane=-1;
00132   previousRunNumber=-1;
00133   pulseHeight=-1;
00134   pulserBox=-1;
00135   pulses=-1;
00136   pulseWidth=-1;
00137   rackBay=-1;//determines which rack 0-15
00138   rackLevel=-1;//0 is top, 1 is bottom
00139   readoutType=-1;
00140   rms=-1.;
00141   run=-1;
00142   runNumber=-1;
00143   runNumberSub=-1;
00144   runType=-1;
00145   s="";
00146   fS="";
00147   strip=-1;
00148   stripEnd=-1;
00149   summaryCounter=-1;
00150   timestamp=-1;
00151   timestampNanoSec=-1;
00152   varc=-1;
00153   vfb=-1;
00154   vmm=-1;
00155 
00156   //set up the chain and perform some checks
00157   this->MakeChain();
00158   this->SetChainBranches();
00159   numEvents=static_cast<Int_t>(chain->GetEntries());
00160   MSG("LIAnalysis",Msg::kInfo) 
00161     <<"Number of events in chain="<<numEvents<<endl; 
00162   if (analyseChainFlag==1){
00163     this->AnalyseChain();
00164   }
00165   
00166   //get the last event
00167   chain->GetEvent(numEvents-1);  
00168   lastRunNumber=runNumber;
00169   
00170   //get the first event
00171   chain->GetEvent(0);  
00172   firstRunNumber=runNumber;//never need to touch this again
00173 
00174   //set which detector to use
00175   this->SetDetector(detectorType);
00176 
00177   //set the high run number to be the highest of the first and last
00178   //it will get changed if there is a higher run number
00179   //between the first and the last
00180   highRunNumber=firstRunNumber;
00181   if (lastRunNumber>firstRunNumber) highRunNumber=lastRunNumber;
00182   //similarly for low run number
00183   lowRunNumber=firstRunNumber;
00184   if (lastRunNumber<firstRunNumber) lowRunNumber=lastRunNumber;
00185 
00186   if (firstRunNumber!=lastRunNumber){
00187     MSG("LIAnalysis",Msg::kInfo)
00188       <<"First run number = "<<firstRunNumber
00189       <<", last = "<<lastRunNumber<<endl;
00190   }
00191 
00192   MSG("LIAnalysis", Msg::kInfo) 
00193     <<"Finished LIAnalysis constructor"<<endl;
00194 }

LIAnalysis::~LIAnalysis  ) 
 

Definition at line 198 of file LIAnalysis.cxx.

References MSG.

00199 {
00200   MSG("LIAnalysis", Msg::kDebug) 
00201     <<"Running LIAnalysis destructor..."<<endl;
00202 
00203 
00204   MSG("LIAnalysis", Msg::kDebug) 
00205     <<"Finished LIAnalysis destructor"<<endl;
00206 }


Member Function Documentation

void LIAnalysis::AdcDistribution  ) 
 

Definition at line 6350 of file LIAnalysis.cxx.

References calibPoint, correlatedHit, crate, detectorType, eastWest, farPulserBox, Form(), histname, InitialiseLoopVariables(), led, lookup, mean, MSG, LILookup::NearOrFar(), nearPulserBox, numEntries, period, plane, pulseHeight, pulserBox, pulseWidth, readoutType, rms, runNumber, s, and SetLoopVariables().

06351 {
06352   MSG("LIAnalysis",Msg::kInfo) 
06353     <<endl<<" ** Running the AdcDistribution method... ** "<<endl;
06354 
06355   //include the under and overflow counts 
06356   gStyle->SetOptStat(1111111); 
06357 
06358   TH1F *hMean= new TH1F("hMean","Mean",150,-5,15005);
06359   hMean->GetXaxis()->SetTitle("Mean");
06360   hMean->GetXaxis()->CenterTitle();
06361   hMean->GetYaxis()->SetTitle("Number");
06362   hMean->GetYaxis()->CenterTitle();
06363   hMean->SetFillColor(0);
06364   hMean->SetBit(TH1::kCanRebin);
06365 
06366   TH1F *hMeanCorrelated= new TH1F("hMeanCorrelated","MeanCorrelated",
06367                                   150,-5,15005);
06368   hMeanCorrelated->GetXaxis()->SetTitle("Mean");
06369   hMeanCorrelated->GetXaxis()->CenterTitle();
06370   hMeanCorrelated->GetYaxis()->SetTitle("Number");
06371   hMeanCorrelated->GetYaxis()->CenterTitle();
06372   hMeanCorrelated->SetFillColor(0);
06373   hMeanCorrelated->SetLineColor(4);
06374   hMeanCorrelated->SetBit(TH1::kCanRebin);
06375 
06376   TH1F *hMeanEast= new TH1F("hMeanEast","MeanEast",
06377                                   150,-5,15005);
06378   hMeanEast->GetXaxis()->SetTitle("Mean");
06379   hMeanEast->GetXaxis()->CenterTitle();
06380   hMeanEast->GetYaxis()->SetTitle("Number");
06381   hMeanEast->GetYaxis()->CenterTitle();
06382   hMeanEast->SetLineColor(4);
06383   hMeanEast->SetFillStyle(3015); 
06384   hMeanEast->SetFillColor(4); 
06385   hMeanEast->SetLineWidth(6);
06386   hMeanEast->SetBit(TH1::kCanRebin);
06387 
06388   TH1F *hMeanWest= new TH1F("hMeanWest","MeanWest",
06389                                   150,-5,15005);
06390   hMeanWest->GetXaxis()->SetTitle("Mean");
06391   hMeanWest->GetXaxis()->CenterTitle();
06392   hMeanWest->GetYaxis()->SetTitle("Number");
06393   hMeanWest->GetYaxis()->CenterTitle();
06394   hMeanWest->SetLineColor(2);
06395   hMeanWest->SetFillStyle(3015); 
06396   hMeanWest->SetFillColor(2); 
06397   hMeanWest->SetLineWidth(6);
06398   hMeanWest->SetBit(TH1::kCanRebin);
06399 
06400   TH1F *hMeanNearPb= new TH1F("hMeanNearPb","MeanNearPb",
06401                               150,-5,15005);
06402   hMeanNearPb->GetXaxis()->SetTitle("Mean");
06403   hMeanNearPb->GetXaxis()->CenterTitle();
06404   hMeanNearPb->GetYaxis()->SetTitle("Number");
06405   hMeanNearPb->GetYaxis()->CenterTitle();
06406   hMeanNearPb->SetFillColor(0);
06407   hMeanNearPb->SetLineColor(2);
06408   hMeanNearPb->SetBit(TH1::kCanRebin);
06409 
06410   TH1F *hMeanFarPb= new TH1F("hMeanFarPb","MeanFarPb",
06411                              150,-5,15005);
06412   hMeanFarPb->GetXaxis()->SetTitle("Mean");
06413   hMeanFarPb->GetXaxis()->CenterTitle();
06414   hMeanFarPb->GetYaxis()->SetTitle("Number");
06415   hMeanFarPb->GetYaxis()->CenterTitle();
06416   hMeanFarPb->SetFillColor(0);
06417   hMeanFarPb->SetLineColor(3);
06418   hMeanFarPb->SetBit(TH1::kCanRebin);
06419 
06420   //histos for different calib points / pulse heights
06421   const Int_t const_numCalibPoints=10;
06422   Int_t pulseHeights[const_numCalibPoints];
06423   TH1F **hAdcPh=0;
06424   hAdcPh= new TH1F*[const_numCalibPoints];
06425   for (Int_t i=0;i<const_numCalibPoints;i++){
06426     //initialise heights
06427     pulseHeights[i]=-1;
06428     //initialse histos
06429     sprintf(histname,"Adc Distribution, calibpoint %d",i+1);
06430     hAdcPh[i]=new TH1F(histname,histname,200,0,15000);
06431     hAdcPh[i]->GetXaxis()->SetTitle("ADC");
06432     hAdcPh[i]->GetXaxis()->CenterTitle();
06433     hAdcPh[i]->GetYaxis()->SetTitle("Number of Entries");
06434     hAdcPh[i]->GetYaxis()->CenterTitle();
06435     hAdcPh[i]->SetFillColor(0);
06436     hAdcPh[i]->Fill(1);
06437     //hAdcPh[i]->SetBit(TH1::kCanRebin);
06438   }
06439 
06440   TH1F **hAdcPhNearPb=0;
06441   hAdcPhNearPb= new TH1F*[const_numCalibPoints];
06442   for (Int_t i=0;i<const_numCalibPoints;i++){
06443     sprintf(histname,"AdcPhNearPb Distribution, calibpoint %d",i+1);
06444     hAdcPhNearPb[i]=new TH1F(histname,histname,200,0,15000);
06445     
06446     hAdcPhNearPb[i]->GetXaxis()->SetTitle("ADC");
06447     hAdcPhNearPb[i]->GetXaxis()->CenterTitle();
06448     hAdcPhNearPb[i]->GetYaxis()->SetTitle("Number of Entries");
06449     hAdcPhNearPb[i]->GetYaxis()->CenterTitle();
06450     hAdcPhNearPb[i]->SetFillColor(0);
06451     hAdcPhNearPb[i]->SetLineColor(2);
06452     hAdcPhNearPb[i]->Fill(1);
06453     //hAdcPhNearPb[i]->SetBit(TH1::kCanRebin);
06454   }
06455 
06456   TH1F **hAdcPhFarPb=0;
06457   hAdcPhFarPb= new TH1F*[const_numCalibPoints];
06458   for (Int_t i=0;i<const_numCalibPoints;i++){
06459     sprintf(histname,"AdcPh FarPb Distribution, calibpoint %d",i+1);
06460     hAdcPhFarPb[i]=new TH1F(histname,histname,200,0,15000);
06461     
06462     hAdcPhFarPb[i]->GetXaxis()->SetTitle("ADC");
06463     hAdcPhFarPb[i]->GetXaxis()->CenterTitle();
06464     hAdcPhFarPb[i]->GetYaxis()->SetTitle("Number of Entries");
06465     hAdcPhFarPb[i]->GetYaxis()->CenterTitle();
06466     hAdcPhFarPb[i]->SetFillColor(0);
06467     hAdcPhFarPb[i]->SetLineColor(3);
06468     hAdcPhFarPb[i]->Fill(1);
06469     //hAdcPhFarPb[i]->SetBit(TH1::kCanRebin);
06470   }
06471 
06472   //histos for different pulser boxes
06473   TH1F **hAdcPb=0;
06474   hAdcPb= new TH1F*[NUMPULSERBOXES];
06475   for (Int_t i=0;i<NUMPULSERBOXES;i++){
06476     //initialse histos
06477     sprintf(histname,"Adc Distribution, pulser box %d",i);
06478     hAdcPb[i]=new TH1F(histname,histname,200,0,15000);
06479     hAdcPb[i]->GetXaxis()->SetTitle("ADC");
06480     hAdcPb[i]->GetXaxis()->CenterTitle();
06481     hAdcPb[i]->GetYaxis()->SetTitle("Number of Entries");
06482     hAdcPb[i]->GetYaxis()->CenterTitle();
06483     hAdcPb[i]->SetFillColor(0);
06484     hAdcPb[i]->Fill(1);
06485     //hAdcPb[i]->SetBit(TH1::kCanRebin);
06486   }
06487 
06488   TH1F **hAdcPbNearPb=0;
06489   hAdcPbNearPb= new TH1F*[NUMPULSERBOXES];
06490   for (Int_t i=0;i<NUMPULSERBOXES;i++){
06491     sprintf(histname,"AdcPbNearPb Distribution, pulser box %d",i);
06492     hAdcPbNearPb[i]=new TH1F(histname,histname,200,0,15000);
06493     
06494     hAdcPbNearPb[i]->GetXaxis()->SetTitle("ADC");
06495     hAdcPbNearPb[i]->GetXaxis()->CenterTitle();
06496     hAdcPbNearPb[i]->GetYaxis()->SetTitle("Number of Entries");
06497     hAdcPbNearPb[i]->GetYaxis()->CenterTitle();
06498     hAdcPbNearPb[i]->SetFillColor(0);
06499     hAdcPbNearPb[i]->SetLineColor(2);
06500     hAdcPbNearPb[i]->Fill(1);
06501     //hAdcPbNearPb[i]->SetBit(TH1::kCanRebin);
06502   }
06503 
06504   TH1F **hAdcPbFarPb=0;
06505   hAdcPbFarPb= new TH1F*[NUMPULSERBOXES];
06506   for (Int_t i=0;i<NUMPULSERBOXES;i++){
06507     sprintf(histname,"AdcPbFarPb Distribution, pulser box %d",i);
06508     hAdcPbFarPb[i]=new TH1F(histname,histname,200,0,15000);
06509     
06510     hAdcPbFarPb[i]->GetXaxis()->SetTitle("ADC");
06511     hAdcPbFarPb[i]->GetXaxis()->CenterTitle();
06512     hAdcPbFarPb[i]->GetYaxis()->SetTitle("Number of Entries");
06513     hAdcPbFarPb[i]->GetYaxis()->CenterTitle();
06514     hAdcPbFarPb[i]->SetFillColor(0);
06515     hAdcPbFarPb[i]->SetLineColor(3);
06516     hAdcPbFarPb[i]->Fill(1);
06517     //hAdcPbFarPb[i]->SetBit(TH1::kCanRebin);
06518   }
06519 
06520   //histos for different pulse widths
06521   const Int_t const_numPulseWidths=3; 
06522   TH1F **hAdcPw=0;
06523   hAdcPw= new TH1F*[const_numPulseWidths];
06524   for (Int_t i=0;i<const_numPulseWidths;i++){
06525     //initialse histos
06526     sprintf(histname,"Adc Distribution, pulse width %d",i);
06527     hAdcPw[i]=new TH1F(histname,histname,200,0,15000);
06528     hAdcPw[i]->GetXaxis()->SetTitle("ADC");
06529     hAdcPw[i]->GetXaxis()->CenterTitle();
06530     hAdcPw[i]->GetYaxis()->SetTitle("Number of Entries");
06531     hAdcPw[i]->GetYaxis()->CenterTitle();
06532     hAdcPw[i]->SetFillColor(0);
06533     hAdcPw[i]->Fill(1);
06534     //hAdcPw[i]->SetBit(TH1::kCanRebin);
06535   }
06536 
06537   TH1F **hAdcPwNearPb=0;
06538   hAdcPwNearPb= new TH1F*[const_numPulseWidths];
06539   for (Int_t i=0;i<const_numPulseWidths;i++){
06540     sprintf(histname,"AdcPwNearPb Distribution, pulser box %d",i);
06541     hAdcPwNearPb[i]=new TH1F(histname,histname,200,0,15000);
06542     
06543     hAdcPwNearPb[i]->GetXaxis()->SetTitle("ADC");
06544     hAdcPwNearPb[i]->GetXaxis()->CenterTitle();
06545     hAdcPwNearPb[i]->GetYaxis()->SetTitle("Number of Entries");
06546     hAdcPwNearPb[i]->GetYaxis()->CenterTitle();
06547     hAdcPwNearPb[i]->SetFillColor(0);
06548     hAdcPwNearPb[i]->SetLineColor(2);
06549     hAdcPwNearPb[i]->Fill(1);
06550     //hAdcPwNearPb[i]->SetBit(TH1::kCanRebin);
06551   }
06552 
06553   TH1F **hAdcPwFarPb=0;
06554   hAdcPwFarPb= new TH1F*[const_numPulseWidths];
06555   for (Int_t i=0;i<const_numPulseWidths;i++){
06556     sprintf(histname,"AdcPwFarPb Distribution, pulser box %d",i);
06557     hAdcPwFarPb[i]=new TH1F(histname,histname,200,0,15000);
06558     
06559     hAdcPwFarPb[i]->GetXaxis()->SetTitle("ADC");
06560     hAdcPwFarPb[i]->GetXaxis()->CenterTitle();
06561     hAdcPwFarPb[i]->GetYaxis()->SetTitle("Number of Entries");
06562     hAdcPwFarPb[i]->GetYaxis()->CenterTitle();
06563     hAdcPwFarPb[i]->SetFillColor(0);
06564     hAdcPwFarPb[i]->SetLineColor(3);
06565     hAdcPwFarPb[i]->Fill(1);
06566     //hAdcPwFarPb[i]->SetBit(TH1::kCanRebin);
06567   }
06568 
06572 
06573   this->InitialiseLoopVariables();  
06574   
06575   for(Int_t entry=0;entry<numEvents;entry++){
06576     
06577     this->SetLoopVariables(entry,0);
06578     
06579     //avoid divide by zero errors and skip irrelevant data
06580     if (rms==0. || mean==0. || numEntries==0) continue;
06581     //only look at scintillator strips
06582     if (readoutType!=ReadoutType::kScintStrip) continue;
06583 
06584     hMean->Fill(mean);
06585 
06586     if (correlatedHit==1){
06587 
06588       if (detectorType==Detector::kCalDet){
06589         if (plane>0 && plane<=LASTPLANE && 
06590             lookup.NearOrFar(crate,pulserBox,nearPulserBox,
06591                              farPulserBox,led,detectorType,
06592                              plane,runNumber)==
06593             LILookup::kNearSide){
06594           if (eastWest==1) hMeanEast->Fill(mean);
06595           else if (eastWest==2) hMeanWest->Fill(mean);
06596         }
06597       }
06598 
06599       //fill histogram for appropriate pulse height
06600       if (calibPoint>0 && calibPoint<=const_numCalibPoints){
06601         pulseHeights[calibPoint-1]=pulseHeight;
06602         hAdcPh[calibPoint-1]->Fill(mean);
06603       }
06604 
06605       //fill histo for appropriate pulser box      
06606       if (pulserBox>=FIRSTPULSERBOX && pulserBox<=LASTPULSERBOX){
06607         hAdcPb[pulserBox]->Fill(mean);
06608       }
06609 
06610       //fill histo for appropriate pulse width      
06611       if (pulseWidth>=1 && pulseWidth<=const_numPulseWidths){
06612         hAdcPw[pulseWidth-1]->Fill(mean);
06613       }
06614 
06615       //fill general histo
06616       hMeanCorrelated->Fill(mean);
06617 
06618       //fill histos with when pulser box is near pulser box
06619       if (nearPulserBox==pulserBox) {
06620         //fill histogram for appropriate pulse height
06621         if (calibPoint>0 && calibPoint<=const_numCalibPoints){
06622           hAdcPhNearPb[calibPoint-1]->Fill(mean);
06623         }
06624         
06625         //fill histo for appropriate pulser box     
06626         if (pulserBox>=FIRSTPULSERBOX && pulserBox<=LASTPULSERBOX){
06627           hAdcPbNearPb[pulserBox]->Fill(mean);
06628         }
06629 
06630         //fill histo for appropriate pulse width      
06631         if (pulseWidth>=1 && pulseWidth<=const_numPulseWidths){
06632           hAdcPwNearPb[pulseWidth-1]->Fill(mean);
06633         }
06634         //fill general histo
06635         hMeanNearPb->Fill(mean);
06636       }      
06637       //fill histos with when pulser box is far pulser box
06638       else if (farPulserBox==pulserBox) {
06639         //fill histogram for appropriate pulse height
06640         if (calibPoint>0 && calibPoint<=const_numCalibPoints){
06641           hAdcPhFarPb[calibPoint-1]->Fill(mean);
06642         }
06643 
06644         //fill histo for appropriate pulser box     
06645         if (pulserBox>=FIRSTPULSERBOX && pulserBox<=LASTPULSERBOX){
06646           hAdcPbFarPb[pulserBox]->Fill(mean);
06647         }
06648 
06649         //fill histo for appropriate pulse width      
06650         if (pulseWidth>=1 && pulseWidth<=const_numPulseWidths){
06651           hAdcPwFarPb[pulseWidth-1]->Fill(mean);
06652         }
06653         //fill general histo
06654         hMeanFarPb->Fill(mean);
06655       }
06656       else {
06657         MSG("LIAnalysis",Msg::kWarning) 
06658           <<" ** Wrong Pb **"<<endl;
06659       }
06660     }    
06661   }//end of for
06662 
06666 
06667   MSG("LIAnalysis",Msg::kInfo)<<"Finished main loop"<<endl;
06668 
06669   string sRunNumber=Form("%d",runNumber);
06670 
06671   TCanvas *cMean=new TCanvas("cMean","cMean",0,0,1000,600);
06672   cMean->SetFillColor(0);
06673   cMean->cd();
06674   cMean->SetLogy();
06675   hMean->Draw();
06676   hMeanNearPb->Draw("same");
06677   hMeanFarPb->Draw("same");
06678   //hMeanCorrelated->Draw("same");
06679 
06680   TCanvas *cMeanEW=new TCanvas("cMeanEW","cMeanEW",0,0,1000,600);
06681   cMeanEW->SetFillColor(0);
06682   cMeanEW->cd();
06683   hMeanWest->Draw();
06684   hMeanEast->Draw("sames");
06685 
06687   //sorted by calibration point section
06689   //get the maximum in order to scale all plots
06690   Int_t maxNumEnt=0;
06691   for (Int_t i=0;i<const_numCalibPoints;i++){
06692     if (hAdcPh[i]->GetMaximum()>maxNumEnt){
06693       maxNumEnt=static_cast<Int_t>(hAdcPh[i]->GetMaximum());
06694       MSG("LIAnalysis",Msg::kInfo) 
06695         <<"Calculating max in calib point section, current highest="
06696         <<maxNumEnt<<endl;
06697     }
06698   }
06699   //create the canvas and draw
06700   TCanvas *cAdcPh=new TCanvas("cAdcPh","cAdcPh",0,0,1000,600);
06701   cAdcPh->SetFillColor(0);
06702   cAdcPh->cd();
06703   cAdcPh->SetLogy();
06704   MSG("LIAnalysis",Msg::kInfo)
06705     <<endl<<"Number of calibration points = "<<const_numCalibPoints
06706     <<endl;  
06707   for (Int_t i=0;i<const_numCalibPoints;i++){
06708     cAdcPh->Clear();
06709     hAdcPh[i]->SetMaximum(maxNumEnt);
06710     string sPulseWidth=Form("%d",pulseWidth);
06711     string sPulseHeight=Form("%d",pulseHeights[i]);
06712     string sPulseFreq=Form("%d",static_cast<Int_t>
06713                            (ceil(1.0/(period*1.0e-5))));
06714     MSG("LIAnalysis",Msg::kInfo)
06715       <<"LI parameters: "
06716       <<", PH="<<sPulseHeight
06717       <<", PW="<<sPulseWidth
06718       <<", PF="<<sPulseFreq
06719       <<", period="<<period
06720       <<endl;
06721     s="ADC Values, Near&Far side, PH="+
06722       sPulseHeight+", PW="+sPulseWidth+
06723       ", PF="+sPulseFreq+" Hz";
06724     hAdcPh[i]->SetTitle(s.c_str());
06725     hAdcPh[i]->Draw();
06726     hAdcPhNearPb[i]->Draw("same");
06727     hAdcPhFarPb[i]->Draw("same");
06728     if (i==0){
06729       s=sRunNumber+"AdcPhHisto.ps(";
06730       cAdcPh->Print(s.c_str());
06731     }
06732     else if(i==const_numCalibPoints-1){
06733       s=sRunNumber+"AdcPhHisto.ps)";
06734       cAdcPh->Print(s.c_str()); 
06735     }
06736     else{
06737       s=sRunNumber+"AdcPhHisto.ps";
06738       cAdcPh->Print(s.c_str());
06739     }
06740   }
06741   cAdcPh->Clear();
06742   hAdcPh[0]->Draw();
06743   hAdcPhNearPb[0]->Draw("same");
06744   hAdcPhFarPb[0]->Draw("same");
06745 
06747   //sorted by pulser box section
06749   //get the maximum in order to scale all plots
06750   maxNumEnt=0;
06751   for (Int_t i=0;i<NUMPULSERBOXES;i++){
06752     if (hAdcPb[i]->GetMaximum()>maxNumEnt){
06753       maxNumEnt=static_cast<Int_t>(hAdcPb[i]->GetMaximum());
06754       MSG("LIAnalysis",Msg::kInfo) 
06755         <<"Calculating max in pulser box section, current highest="
06756         <<maxNumEnt<<endl;
06757     }
06758   }
06759   //create the canvas and draw
06760   TCanvas *cAdcPb=new TCanvas("cAdcPb","cAdcPb",0,0,1000,600);
06761   cAdcPb->SetFillColor(0);
06762   cAdcPb->cd();
06763   cAdcPb->SetLogy();
06764   MSG("LIAnalysis",Msg::kInfo)
06765     <<endl<<"Number of pulser boxes = "<<NUMPULSERBOXES<<endl;
06766   for (Int_t i=0;i<NUMPULSERBOXES;i++){
06767     cAdcPb->Clear();
06768     hAdcPb[i]->SetMaximum(maxNumEnt);
06769     string sPulserBox=Form("%d",i);
06770     string sPulseWidth=Form("%d",pulseWidth);
06771     string sPulseHeight=Form("%d",pulseHeight);
06772     string sPulseFreq=Form("%d",static_cast<Int_t>
06773                            (ceil(1.0/(period*1.0e-5))));
06774     MSG("LIAnalysis",Msg::kInfo)
06775       <<"LI parameters: "
06776       <<", PB="<<sPulserBox
06777       <<", PH="<<sPulseHeight
06778       <<", PW="<<sPulseWidth
06779       <<", PF="<<sPulseFreq
06780       <<", period="<<period
06781       <<endl;
06782     s="ADC Values, Near&Far side, PB="+sPulserBox+
06783       ", PH="+sPulseHeight+", PW="+sPulseWidth+
06784       ", PF="+sPulseFreq+" Hz";
06785     hAdcPb[i]->SetTitle(s.c_str());
06786     hAdcPb[i]->Draw();
06787     hAdcPbNearPb[i]->Draw("same");
06788     hAdcPbFarPb[i]->Draw("same");
06789     if (i==0){
06790       s=sRunNumber+"AdcPbHisto.ps(";
06791       cAdcPb->Print(s.c_str());
06792     }
06793     else if(i==NUMPULSERBOXES-1){
06794       s=sRunNumber+"AdcPbHisto.ps)";
06795       cAdcPb->Print(s.c_str()); 
06796     }
06797     else{
06798       s=sRunNumber+"AdcPbHisto.ps";
06799       cAdcPb->Print(s.c_str());
06800     }
06801   }
06802   cAdcPb->Clear();
06803   hAdcPb[0]->Draw();
06804   hAdcPbNearPb[0]->Draw("same");
06805   hAdcPbFarPb[0]->Draw("same");
06806 
06808   //sorted by pulse width
06810   //get the maximum in order to scale all plots
06811   maxNumEnt=0;
06812   for (Int_t i=0;i<const_numPulseWidths;i++){
06813     if (hAdcPw[i]->GetMaximum()>maxNumEnt){
06814       maxNumEnt=static_cast<Int_t>(hAdcPw[i]->GetMaximum());
06815       MSG("LIAnalysis",Msg::kInfo) 
06816         <<"Calculating max in pulse width section, current highest="
06817         <<maxNumEnt<<endl;
06818     }
06819   }
06820   //create the canvas and draw
06821   TCanvas *cAdcPw=new TCanvas("cAdcPw","cAdcPw",0,0,1000,600);
06822   cAdcPw->SetFillColor(0);
06823   cAdcPw->cd();
06824   cAdcPw->SetLogy();
06825   MSG("LIAnalysis",Msg::kInfo)
06826     <<endl<<"Number of pulse widths = "<<const_numPulseWidths<<endl;
06827   for (Int_t i=0;i<const_numPulseWidths;i++){
06828     cAdcPw->Clear();
06829     hAdcPw[i]->SetMaximum(maxNumEnt);
06830     string sPulseWidth=Form("%d",i+1);
06831     string sPulseHeight=Form("%d",pulseHeight);
06832     string sPulseFreq=Form("%d",static_cast<Int_t>
06833                            (ceil(1.0/(period*1.0e-5))));
06834     MSG("LIAnalysis",Msg::kInfo)
06835       <<"LI parameters: "
06836       <<", PH="<<sPulseHeight
06837       <<", PW="<<sPulseWidth
06838       <<", PF="<<sPulseFreq
06839       <<", period="<<period
06840       <<endl;
06841     s="ADC Values, Near&Far side, PH="+sPulseHeight+
06842       ", PW="+sPulseWidth+
06843       ", PF="+sPulseFreq+" Hz";
06844     hAdcPw[i]->SetTitle(s.c_str());
06845     hAdcPw[i]->Draw();
06846     hAdcPwNearPb[i]->Draw("same");
06847     hAdcPwFarPb[i]->Draw("same");
06848     if (i==0){
06849       s=sRunNumber+"AdcPwHisto.ps(";
06850       cAdcPw->Print(s.c_str());
06851     }
06852     else if(i==const_numPulseWidths-1){
06853       s=sRunNumber+"AdcPwHisto.ps)";
06854       cAdcPw->Print(s.c_str()); 
06855     }
06856     else{
06857       s=sRunNumber+"AdcPwHisto.ps";
06858       cAdcPw->Print(s.c_str());
06859     }
06860   }
06861   cAdcPw->Clear();
06862   hAdcPw[0]->Draw();
06863   hAdcPwNearPb[0]->Draw("same");
06864   hAdcPwFarPb[0]->Draw("same");
06865 
06866   MSG("LIAnalysis",Msg::kInfo) 
06867     <<endl<<" ** Finished the AdcDistribution method ** "<<endl;
06868 }

void LIAnalysis::AdcVsChannel Int_t  plane,
Int_t  crate
 

Definition at line 5708 of file LIAnalysis.cxx.

References channel, chip, correlatedHit, crate, histname, InitialiseLoopVariables(), mean, MSG, numEntries, pixel, plane, pulserBox, readoutType, rms, SetLoopVariables(), and strip.

05709 {  
05710   //get rid of the stats info
05711   gStyle->SetOptStat(0);
05712   
05713   MSG("LIAnalysis",Msg::kInfo)
05714     <<endl<<" ** Running the AdcVsChannel method... **"<<endl;
05715 
05716   TH2F **hAdcVsChannel=0;
05717   hAdcVsChannel= new TH2F*[NUMCHIPS];
05718   for (Int_t i=0;i<NUMCHIPS;i++){
05719     sprintf(histname,"Adc Vs Channel (VA chip %i)",i);
05720     hAdcVsChannel[i]=new TH2F
05721       (histname,histname,23,0,23,15000,0,15000);
05722     hAdcVsChannel[i]->GetXaxis()->SetTitle("Channel");
05723     hAdcVsChannel[i]->GetXaxis()->CenterTitle();
05724     hAdcVsChannel[i]->GetYaxis()->SetTitle("Adc");
05725     hAdcVsChannel[i]->GetYaxis()->CenterTitle();
05726     hAdcVsChannel[i]->SetFillColor(0);
05727     hAdcVsChannel[i]->SetBit(TH1::kCanRebin);
05728   }
05729   
05733   
05734   this->InitialiseLoopVariables();  
05735   
05736   for(Int_t entry=0;entry<numEvents;entry++){
05737     
05738     this->SetLoopVariables(entry,0);
05739     
05740     //avoid divide by zero errors and skip irrelevant data
05741     if (rms==0. || mean==0. || numEntries==0) continue;
05742     //only look at scintillator strips
05743     if (readoutType!=ReadoutType::kScintStrip) continue;
05744     
05745     if (plane==pl && crate==cr){
05746       if (correlatedHit==1){
05747         if (pulserBox==crate){
05748           hAdcVsChannel[chip]->Fill(channel,mean,20);
05749         }
05750         else if (pulserBox!=crate){
05751           hAdcVsChannel[chip]->Fill(channel,mean,10);
05752         }
05753       }
05754       else{
05755         hAdcVsChannel[chip]->Fill(channel,mean,1);
05756       }
05757       if (chip==0 && pulserBox==7){
05758         MSG("LIAnalysis",Msg::kVerbose) 
05759           <<"plane="<<plane
05760           <<", pb="<<pulserBox
05761           <<", chip="<<chip     
05762           <<", pixel="<<pixel
05763           <<", channel="<<channel
05764           <<", strip="<<strip
05765           <<", mean="<<mean 
05766           <<endl;
05767       }
05768       else if (chip==0 && pulserBox==6){
05769         MSG("LIAnalysis",Msg::kVerbose) 
05770           <<"****** plane="<<plane
05771           <<", pb="<<pulserBox
05772           <<", chip="<<chip     
05773           <<", pixel="<<pixel
05774           <<", channel="<<channel
05775           <<", strip="<<strip
05776           <<", mean="<<mean 
05777           <<endl;
05778       }
05779     }
05780 
05781 
05782   }//end of for
05783    
05787 
05788   MSG("LIAnalysis",Msg::kInfo)<<"Finished main loop"<<endl;
05789 
05790   TCanvas *cAdcVsChannel=new TCanvas
05791     ("cAdcVsChannel","Adc Vs Channel",0,0,1200,800);
05792   cAdcVsChannel->SetFillColor(0);
05793   cAdcVsChannel->Divide(2,2);
05794   for (Int_t i=0;i<NUMCHIPS;i++){
05795     cAdcVsChannel->cd(i+1);
05796     hAdcVsChannel[i]->Draw("colz");
05797   }
05798 
05799   MSG("LIAnalysis",Msg::kInfo)
05800     <<" ** Finished the AdcVsChannel method ** "<<endl;
05801 }

void LIAnalysis::AdcVsLed  ) 
 

Definition at line 9619 of file LIAnalysis.cxx.

References correlatedHit, crate, detectorType, draw(), farPulserBox, Form(), histname, InitialiseLoopVariables(), led, lookup, lowRunNumber, mean, MSG, LILookup::NearOrFar(), nearPulserBox, numEntries, period, plane, pulseHeight, pulserBox, pulses, pulseWidth, rackLevel, readoutType, rms, runNumber, s, SetLoopVariables(), and stripEnd.

09620 { 
09621   MSG("LIAnalysis",Msg::kInfo)
09622     <<endl<<" ** Running the AdcVsLed method... ** "<<endl;
09623 
09624   Int_t numAdcBins=150;
09625 
09626   //histos for different leds
09627   TH1F **hAdcLed=0;
09628   hAdcLed= new TH1F*[NUMLEDS*NUMPULSERBOXES];
09629   for (Int_t i=0;i<NUMPULSERBOXES;i++){
09630     for (Int_t j=0;j<NUMLEDS;j++){
09631       //calculate array number
09632       Int_t l=i*NUMLEDS+j;
09633       //initialse histos
09634       sprintf(histname,"Adc Distribution, PB %d, LED %d",i,j+1);
09635       hAdcLed[l]=new TH1F(histname,histname,numAdcBins,0,15000);
09636       hAdcLed[l]->GetXaxis()->SetTitle("ADC");
09637       hAdcLed[l]->GetXaxis()->CenterTitle();
09638       hAdcLed[l]->GetYaxis()->SetTitle("Number of Entries");
09639       hAdcLed[l]->GetYaxis()->CenterTitle();
09640       hAdcLed[l]->SetFillColor(0);
09641       hAdcLed[l]->Fill(1);
09642       hAdcLed[l]->SetBit(TH1::kCanRebin);
09643     }
09644   }
09645 
09646   TH1F **hAdcLedNearPb=0;
09647   hAdcLedNearPb= new TH1F*[NUMLEDS*NUMPULSERBOXES];
09648   for (Int_t i=0;i<NUMPULSERBOXES;i++){
09649     for (Int_t j=0;j<NUMLEDS;j++){
09650       //calculate array number
09651       Int_t l=i*NUMLEDS+j;
09652       sprintf(histname,"Adc NearPb Distribution, PB %d, LED %d",i,j+1);
09653       hAdcLedNearPb[l]=new TH1F(histname,histname,numAdcBins,0,15000);
09654       hAdcLedNearPb[l]->GetXaxis()->SetTitle("ADC");
09655       hAdcLedNearPb[l]->GetXaxis()->CenterTitle();
09656       hAdcLedNearPb[l]->GetYaxis()->SetTitle("Number of Entries");
09657       hAdcLedNearPb[l]->GetYaxis()->CenterTitle();
09658       hAdcLedNearPb[l]->SetFillColor(0);
09659       hAdcLedNearPb[l]->SetLineColor(2);
09660       hAdcLedNearPb[l]->Fill(1);
09661       hAdcLedNearPb[l]->SetBit(TH1::kCanRebin);
09662     }
09663   }
09664 
09665   TH1F **hAdcLedFarPb=0;
09666   hAdcLedFarPb= new TH1F*[NUMLEDS*NUMPULSERBOXES];
09667   for (Int_t i=0;i<NUMPULSERBOXES;i++){
09668     for (Int_t j=0;j<NUMLEDS;j++){
09669       //calculate array number
09670       Int_t l=i*NUMLEDS+j;
09671       sprintf(histname,"Adc FarPb Distribution, PB %d, LED %d",i,j+1);
09672       hAdcLedFarPb[l]=new TH1F(histname,histname,numAdcBins,0,15000);
09673       hAdcLedFarPb[l]->GetXaxis()->SetTitle("ADC");
09674       hAdcLedFarPb[l]->GetXaxis()->CenterTitle();
09675       hAdcLedFarPb[l]->GetYaxis()->SetTitle("Number of Entries");
09676       hAdcLedFarPb[l]->GetYaxis()->CenterTitle();
09677       hAdcLedFarPb[l]->SetFillColor(0);
09678       hAdcLedFarPb[l]->SetLineColor(3);
09679       hAdcLedFarPb[l]->Fill(1);
09680       hAdcLedFarPb[l]->SetBit(TH1::kCanRebin);
09681     }
09682   }
09683 
09684   TH1F **hGain=0;
09685   hGain= new TH1F*[NUMLEDS*NUMPULSERBOXES];
09686   for (Int_t i=0;i<NUMPULSERBOXES;i++){
09687     for (Int_t j=0;j<NUMLEDS;j++){
09688       //calculate array number
09689       Int_t l=i*NUMLEDS+j;
09690       sprintf(histname,"Gain Distribution, Near Side, PB %d, LED %d",
09691               i,j+1);
09692       hGain[l]=new TH1F(histname,histname,numAdcBins,0,200);
09693       hGain[l]->GetXaxis()->SetTitle("ADC");
09694       hGain[l]->GetXaxis()->CenterTitle();
09695       hGain[l]->GetYaxis()->SetTitle("Number of Entries");
09696       hGain[l]->GetYaxis()->CenterTitle();
09697       hGain[l]->SetFillColor(0);
09698       hGain[l]->SetLineColor(2);
09699       hGain[l]->SetBit(TH1::kCanRebin);
09700     }
09701   }
09702 
09703   TH1F **hGainUE=0;
09704   hGainUE= new TH1F*[NUMLEDS*NUMPULSERBOXES];
09705   for (Int_t i=0;i<NUMPULSERBOXES;i++){
09706     for (Int_t j=0;j<NUMLEDS;j++){
09707       //calculate array number
09708       Int_t l=i*NUMLEDS+j;
09709       sprintf(histname,"Gain Distribution UE, PB %d, LED %d",i,j+1);
09710       hGainUE[l]=new TH1F(histname,histname,numAdcBins,0,200);
09711       hGainUE[l]->GetXaxis()->SetTitle("ADC");
09712       hGainUE[l]->GetXaxis()->CenterTitle();
09713       hGainUE[l]->GetYaxis()->SetTitle("Number of Entries");
09714       hGainUE[l]->GetYaxis()->CenterTitle();
09715       hGainUE[l]->SetFillColor(0);
09716       hGainUE[l]->SetLineColor(1);
09717       hGainUE[l]->SetBit(TH1::kCanRebin);
09718     }
09719   }
09720 
09721   TH1F **hGainUW=0;
09722   hGainUW= new TH1F*[NUMLEDS*NUMPULSERBOXES];
09723   for (Int_t i=0;i<NUMPULSERBOXES;i++){
09724     for (Int_t j=0;j<NUMLEDS;j++){
09725       //calculate array number
09726       Int_t l=i*NUMLEDS+j;
09727       sprintf(histname,"Gain Distribution UW, PB %d, LED %d",
09728               i,j+1);
09729       hGainUW[l]=new TH1F(histname,histname,numAdcBins,0,200);
09730       hGainUW[l]->GetXaxis()->SetTitle("ADC");
09731       hGainUW[l]->GetXaxis()->CenterTitle();
09732       hGainUW[l]->GetYaxis()->SetTitle("Number of Entries");
09733       hGainUW[l]->GetYaxis()->CenterTitle();
09734       hGainUW[l]->SetFillColor(0);
09735       hGainUW[l]->SetLineColor(2);
09736       hGainUW[l]->SetBit(TH1::kCanRebin);
09737     }
09738   }
09739 
09740   TH1F **hGainLE=0;
09741   hGainLE= new TH1F*[NUMLEDS*NUMPULSERBOXES];
09742   for (Int_t i=0;i<NUMPULSERBOXES;i++){
09743     for (Int_t j=0;j<NUMLEDS;j++){
09744       //calculate array number
09745       Int_t l=i*NUMLEDS+j;
09746       sprintf(histname,"Gain Distribution LE, PB %d, LED %d",
09747               i,j+1);
09748       hGainLE[l]=new TH1F(histname,histname,numAdcBins,0,200);
09749       hGainLE[l]->GetXaxis()->SetTitle("ADC");
09750       hGainLE[l]->GetXaxis()->CenterTitle();
09751       hGainLE[l]->GetYaxis()->SetTitle("Number of Entries");
09752       hGainLE[l]->GetYaxis()->CenterTitle();
09753       hGainLE[l]->SetFillColor(0);
09754       hGainLE[l]->SetLineColor(3);
09755       hGainLE[l]->SetBit(TH1::kCanRebin);
09756     }
09757   }
09758 
09759   TH1F **hGainLW=0;
09760   hGainLW= new TH1F*[NUMLEDS*NUMPULSERBOXES];
09761   for (Int_t i=0;i<NUMPULSERBOXES;i++){
09762     for (Int_t j=0;j<NUMLEDS;j++){
09763       //calculate array number
09764       Int_t l=i*NUMLEDS+j;
09765       sprintf(histname,"Gain Distribution LW, Near Side, PB %d, LED %d",
09766               i,j+1);
09767       hGainLW[l]=new TH1F(histname,histname,numAdcBins,0,200);
09768       hGainLW[l]->GetXaxis()->SetTitle("ADC");
09769       hGainLW[l]->GetXaxis()->CenterTitle();
09770       hGainLW[l]->GetYaxis()->SetTitle("Number of Entries");
09771       hGainLW[l]->GetYaxis()->CenterTitle();
09772       hGainLW[l]->SetFillColor(0);
09773       hGainLW[l]->SetLineColor(4);
09774       hGainLW[l]->SetBit(TH1::kCanRebin);
09775     }
09776   }
09777 
09778   TH1F **hGainF=0;
09779   hGainF= new TH1F*[NUMLEDS*NUMPULSERBOXES];
09780   for (Int_t i=0;i<NUMPULSERBOXES;i++){
09781     for (Int_t j=0;j<NUMLEDS;j++){
09782       //calculate array number
09783       Int_t l=i*NUMLEDS+j;
09784       sprintf(histname,"Gain Distribution, Far Side, PB %d, LED %d",
09785               i,j+1);
09786       hGainF[l]=new TH1F(histname,histname,numAdcBins,0,200);
09787       hGainF[l]->GetXaxis()->SetTitle("ADC");
09788       hGainF[l]->GetXaxis()->CenterTitle();
09789       hGainF[l]->GetYaxis()->SetTitle("Number of Entries");
09790       hGainF[l]->GetYaxis()->CenterTitle();
09791       hGainF[l]->SetFillColor(0);
09792       hGainF[l]->SetLineColor(3);
09793       hGainF[l]->SetBit(TH1::kCanRebin);
09794     }
09795   }
09796  
09797   TH1F **hNpe=0;
09798   hNpe= new TH1F*[NUMLEDS*NUMPULSERBOXES];
09799   for (Int_t i=0;i<NUMPULSERBOXES;i++){
09800     for (Int_t j=0;j<NUMLEDS;j++){
09801       //calculate array number
09802       Int_t l=i*NUMLEDS+j;
09803       sprintf(histname,"Npe Distribution, Near Side, PB %d, LED %d",
09804               i,j+1);
09805       hNpe[l]=new TH1F(histname,histname,numAdcBins,0,300);
09806       hNpe[l]->GetXaxis()->SetTitle("Npe");
09807       hNpe[l]->GetXaxis()->CenterTitle();
09808       hNpe[l]->GetYaxis()->SetTitle("Number of Entries");
09809       hNpe[l]->GetYaxis()->CenterTitle();
09810       hNpe[l]->SetFillColor(0);
09811       hNpe[l]->SetLineColor(2);
09812       hNpe[l]->SetBit(TH1::kCanRebin);
09813     }
09814   }
09815 
09816   TH1F **hNpeF=0;
09817   hNpeF= new TH1F*[NUMLEDS*NUMPULSERBOXES];
09818   for (Int_t i=0;i<NUMPULSERBOXES;i++){
09819     for (Int_t j=0;j<NUMLEDS;j++){
09820       //calculate array number
09821       Int_t l=i*NUMLEDS+j;
09822       sprintf(histname,"Npe Distribution, Far Side, PB %d, LED %d",
09823               i,j+1);
09824       hNpeF[l]=new TH1F(histname,histname,numAdcBins,0,300);
09825       hNpeF[l]->GetXaxis()->SetTitle("Npe");
09826       hNpeF[l]->GetXaxis()->CenterTitle();
09827       hNpeF[l]->GetYaxis()->SetTitle("Number of Entries");
09828       hNpeF[l]->GetYaxis()->CenterTitle();
09829       hNpeF[l]->SetFillColor(0);
09830       hNpeF[l]->SetLineColor(3);
09831       hNpeF[l]->SetBit(TH1::kCanRebin);
09832     }
09833   }
09834 
09835   TH1F **hFlash=0;
09836   hFlash= new TH1F*[NUMLEDS*NUMPULSERBOXES];
09837   for (Int_t i=0;i<NUMPULSERBOXES;i++){
09838     for (Int_t j=0;j<NUMLEDS;j++){
09839       //calculate array number
09840       Int_t l=i*NUMLEDS+j;
09841       sprintf(histname,"Number of Flashes Distribution, Near Side, PB %d, LED %d",
09842               i,j+1);
09843       hFlash[l]=new TH1F(histname,histname,numAdcBins,0,1500);
09844       hFlash[l]->GetXaxis()->SetTitle("Number of Flashes");
09845       hFlash[l]->GetXaxis()->CenterTitle();
09846       hFlash[l]->GetYaxis()->SetTitle("Number of Entries");
09847       hFlash[l]->GetYaxis()->CenterTitle();
09848       hFlash[l]->SetFillColor(0);
09849       hFlash[l]->SetLineColor(2);
09850       hFlash[l]->SetBit(TH1::kCanRebin);
09851     }
09852   }
09853 
09854   TH1F **hRms=0;
09855   hRms= new TH1F*[NUMLEDS*NUMPULSERBOXES];
09856   for (Int_t i=0;i<NUMPULSERBOXES;i++){
09857     for (Int_t j=0;j<NUMLEDS;j++){
09858       //calculate array number
09859       Int_t l=i*NUMLEDS+j;
09860       sprintf(histname,"RMS Distribution, Near Side, PB %d, LED %d",
09861               i,j+1);
09862       hRms[l]=new TH1F(histname,histname,numAdcBins,0,15000);
09863       hRms[l]->GetXaxis()->SetTitle("RMS");
09864       hRms[l]->GetXaxis()->CenterTitle();
09865       hRms[l]->GetYaxis()->SetTitle("Number of Entries");
09866       hRms[l]->GetYaxis()->CenterTitle();
09867       hRms[l]->SetFillColor(0);
09868       hRms[l]->SetLineColor(2);
09869       hRms[l]->SetBit(TH1::kCanRebin);
09870     }
09871   }
09872 
09873   //array to hold the pulse heights
09874   Int_t* ph=new Int_t[NUMPULSERBOXES*NUMLEDS];
09875   for (Int_t i=0;i<NUMPULSERBOXES;i++){
09876     for (Int_t j=0;j<NUMLEDS;j++){
09877       Int_t l=i*NUMLEDS+j;
09878       ph[l]=0;
09879     }
09880   }
09881 
09885    
09886   this->InitialiseLoopVariables();   
09887    
09888   for(Int_t entry=0;entry<numEvents;entry++){ 
09889      
09890     this->SetLoopVariables(entry,0); 
09891      
09892     //ignore any zeros that slipped through 
09893     if (mean==0 || rms==0 || numEntries==0) continue;    
09894     //only look at scint strips 
09895     if (readoutType!=ReadoutType::kScintStrip) continue; 
09896 
09897     //calculate npe and gain
09898     Float_t npe=mean*mean/(rms*rms);
09899     Float_t gain=0.8*mean/npe;
09900 
09901     // PMT fudge factor for M64 (near detector): 0.844
09902     if (detectorType==Detector::kNear) gain = 0.844*rms*rms/mean;
09903 
09904     //led index
09905     Int_t l=pulserBox*NUMLEDS+led-1;
09906 
09907     if (correlatedHit==1){
09908       //fill histograms
09909       if (detectorType==Detector::kFar 
09910           || detectorType==Detector::kNear){
09911         if (pulserBox>=FIRSTPULSERBOX && pulserBox<=LASTPULSERBOX &&
09912             led>=FIRSTLED && led<=LASTLED){
09913           
09914           //fill array to store pulse heights
09915           ph[l]=pulseHeight;
09916           
09917           //fill histo for appropriate led
09918           hAdcLed[l]->Fill(mean);
09919           //fill histos when pulser box is near pulser box
09920           if (nearPulserBox==pulserBox) {
09921             hAdcLedNearPb[l]->Fill(mean);
09922             if (mean>500 && mean<8000){
09923               hGain[l]->Fill(gain);
09924               hNpe[l]->Fill(npe);
09925               hFlash[l]->Fill(numEntries); hRms[l]->Fill(rms);
09926 
09927               //fill histos
09928               if (rackLevel==0 && stripEnd==StripEnd::kEast){
09929                 hGainLE[l]->Fill(gain);
09930               }
09931               if (rackLevel==0 && stripEnd==StripEnd::kWest){
09932                 hGainLW[l]->Fill(gain);
09933               }
09934               if (rackLevel==1 && stripEnd==StripEnd::kEast){
09935                 hGainUE[l]->Fill(gain);
09936               }         
09937               if (rackLevel==1 && stripEnd==StripEnd::kWest){
09938                 hGainUW[l]->Fill(gain);
09939               }
09940             }
09941           }
09942           //fill histos when pulser box is far pulser box
09943           else if (farPulserBox==pulserBox) {
09944             hAdcLedFarPb[l]->Fill(mean);
09945             if (mean>500 && mean<8000){
09946               hGainF[l]->Fill(gain);
09947               hNpeF[l]->Fill(npe);
09948             }
09949           }
09950         }
09951       }
09952       //change the farPb to farLed for calDet
09953       else if (detectorType==Detector::kCalDet){
09954         if (pulserBox>=FIRSTPULSERBOX && pulserBox<=LASTPULSERBOX &&
09955             crate>=FIRSTCRATE && crate<=LASTCRATE &&
09956             led>=FIRSTLED && led<=LASTLED){
09957           
09958           //fill array to store pulse heights
09959           ph[l]=pulseHeight;
09960           
09961           //fill histo for appropriate led
09962           hAdcLed[l]->Fill(mean);
09963           //fill histos when pulser box is near pulser box
09964           if (lookup.NearOrFar(crate,pulserBox,nearPulserBox,
09965                                farPulserBox,led,detectorType,
09966                                plane,runNumber)==
09967               LILookup::kNearSide) {
09968             hAdcLedNearPb[l]->Fill(mean);
09969             if (mean>500 && mean<8000){
09970               hGain[l]->Fill(gain);
09971               hNpe[l]->Fill(npe);
09972               hFlash[l]->Fill(numEntries); hRms[l]->Fill(rms);
09973             }
09974           }
09975           //fill histos when pulser box is far pulser box
09976           else if (lookup.NearOrFar(crate,pulserBox,nearPulserBox,
09977                                     farPulserBox,led,detectorType,
09978                                     plane,runNumber)==
09979                    LILookup::kFarSide) {
09980             hAdcLedFarPb[l]->Fill(mean);
09981             if (mean>500 && mean<8000){
09982               hGainF[l]->Fill(gain);
09983               hNpeF[l]->Fill(npe);
09984             }
09985           }
09986         }
09987       }
09988     }    
09989   }//end of for     
09990    
09994  
09995   MSG("LIAnalysis",Msg::kInfo)<<"Finished main loop"<<endl;
09996 
09997   //include the under and overflow counts 
09998   gStyle->SetOptStat(1111111); 
09999   //set up useful string 
10000   string sRunNumber=Form("%d",runNumber); 
10001   string sLowRunNumber=Form("%d",lowRunNumber);
10002   
10003   //get the maximum in order to scale all plots
10004   Double_t maxNumEntAdc=0;
10005   Double_t maxNumEntGain=0;
10006   Double_t maxNumEntNpe=0;
10007   Double_t maxNumEntFlash=0;
10008   Double_t maxNumEntRms=0;
10009   for (Int_t i=0;i<NUMPULSERBOXES*NUMLEDS;i++){
10010     if (hAdcLed[i]->GetMean()>500){
10011       //find the maxs for each type of histo
10012       if (hAdcLed[i]->GetMaximum()>maxNumEntAdc){
10013         maxNumEntAdc=hAdcLed[i]->GetMaximum();
10014         MSG("LIAnalysis",Msg::kInfo)
10015           <<"Calculating max num ADC entries, current highest="
10016           <<maxNumEntAdc<<", l="<<i<<endl;
10017       }
10018       if (hGain[i]->GetMaximum()>maxNumEntGain){
10019         maxNumEntGain=hGain[i]->GetMaximum();
10020         MSG("LIAnalysis",Msg::kInfo)
10021           <<"Calculating max num gain entries, current highest="
10022           <<maxNumEntGain<<", l="<<i<<endl;
10023       }
10024       if (hNpe[i]->GetMaximum()>maxNumEntNpe){
10025         maxNumEntNpe=hNpe[i]->GetMaximum();
10026         MSG("LIAnalysis",Msg::kInfo)
10027           <<"Calculating max num npe entries, current highest="
10028           <<maxNumEntNpe<<", l="<<i<<endl;
10029       }
10030       if (hFlash[i]->GetMaximum()>maxNumEntFlash){
10031         maxNumEntFlash=hFlash[i]->GetMaximum();
10032         MSG("LIAnalysis",Msg::kInfo)
10033           <<"Calculating max num flash entries, current highest="
10034           <<maxNumEntFlash<<", l="<<i<<endl;
10035       }
10036       if (hRms[i]->GetMaximum()>maxNumEntRms){
10037         maxNumEntRms=hRms[i]->GetMaximum();
10038         MSG("LIAnalysis",Msg::kInfo)
10039           <<"Calculating max num RMS entries, current highest="
10040           <<maxNumEntRms<<", l="<<i<<endl;
10041       }
10042     }
10043   }
10044 
10045   //allocate space for TGraphs then loop and fill them below
10046   TGraphAsymmErrors *gErrorsAdcLedNear=new 
10047     TGraphAsymmErrors(NUMPULSERBOXES*NUMLEDS);
10048   TGraphAsymmErrors *gErrorsAdcLedFar=new 
10049     TGraphAsymmErrors(NUMPULSERBOXES*NUMLEDS);
10050   TGraph *gAdcLedNear=new TGraph(NUMPULSERBOXES*NUMLEDS);
10051   TGraph *gAdcLedFar=new TGraph(NUMPULSERBOXES*NUMLEDS);
10052 
10053   TGraph *gGain=new TGraph(NUMPULSERBOXES*NUMLEDS);
10054   TGraph *gGainF=new TGraph(NUMPULSERBOXES*NUMLEDS);
10055   TGraph *gNpe=new TGraph(NUMPULSERBOXES*NUMLEDS);
10056   TGraph *gNpeF=new TGraph(NUMPULSERBOXES*NUMLEDS);
10057 
10058   TGraph *gFlash=new TGraph(NUMPULSERBOXES*NUMLEDS);
10059   TGraph *gRms=new TGraph(NUMPULSERBOXES*NUMLEDS);
10060 
10061   TGraph *gGainUE=new TGraph(7);//((NUMPULSERBOXES-2)/2);//for fardet
10062   TGraph *gGainUW=new TGraph(7);//((NUMPULSERBOXES-2)/2);//for fardet
10063   TGraph *gGainLE=new TGraph(7);//((NUMPULSERBOXES-2)/2);//for fardet
10064   TGraph *gGainLW=new TGraph(7);//((NUMPULSERBOXES-2)/2);//for fardet
10065 
10066   gErrorsAdcLedNear->SetMinimum(-1);
10067   gErrorsAdcLedFar->SetMinimum(-1);
10068   gAdcLedNear->SetMinimum(-1);
10069   gAdcLedFar->SetMinimum(-1);
10070   gErrorsAdcLedNear->SetMaximum(15000);
10071   gErrorsAdcLedFar->SetMaximum(15000);
10072   gAdcLedNear->SetMaximum(15000);
10073   gAdcLedFar->SetMaximum(15000);
10074   gGain->SetMinimum(-1);
10075   gGainF->SetMinimum(-1);
10076   gNpe->SetMinimum(-1);
10077   gNpeF->SetMinimum(-1);
10078 
10079   Double_t nearAdcMax=0;
10080   Double_t farAdcMax=0;
10081   
10082   //create the canvas and draw
10083   TCanvas *cAdcLed=new TCanvas("cAdcLed","cAdcLed",0,0,1000,600);
10084   cAdcLed->SetFillColor(0);
10085   TCanvas *cGainLed=new TCanvas("cGainLed","cGainLed",0,0,1000,600);
10086   cGainLed->SetFillColor(0);
10087   TCanvas *cNpeLed=new TCanvas("cNpeLed","cNpeLed",0,0,1000,600);
10088   cNpeLed->SetFillColor(0);
10089 
10090   if (detectorType==Detector::kFar){
10091     Float_t* gainUE=new Float_t[NUMPULSERBOXES];
10092     Float_t* gainUW=new Float_t[NUMPULSERBOXES];
10093     Float_t* gainLE=new Float_t[NUMPULSERBOXES];
10094     Float_t* gainLW=new Float_t[NUMPULSERBOXES];
10095     
10096     for (Int_t i=0;i<NUMPULSERBOXES;i++){
10097       MSG("LIAnalysis",Msg::kInfo)
10098         <<"Analysing PB="<<i<<endl;
10099       gainUE[i]=0;
10100       gainUW[i]=0;
10101       gainLE[i]=0;
10102       gainLW[i]=0;
10103     }
10104     
10105     Float_t maxGain=0;
10106     Float_t minGain=100000; 
10107     
10108     for (Int_t i=0;i<NUMPULSERBOXES-2;i++){
10109       MSG("LIAnalysis",Msg::kInfo)
10110         <<"Analysing PB="<<i<<endl;
10111       for (Int_t j=0;j<NUMLEDS;j++){
10112         Int_t l=i*NUMLEDS+j;
10113         gainUE[i]+=hGainUE[l]->GetMean();
10114         gainUW[i]+=hGainUW[l]->GetMean();
10115         gainLE[i]+=hGainLE[l]->GetMean();
10116         gainLW[i]+=hGainLW[l]->GetMean();
10117       }
10118       gainUE[i]/=NUMLEDS;
10119       gainUW[i]/=NUMLEDS;
10120       gainLE[i]/=NUMLEDS;
10121       gainLW[i]/=NUMLEDS;
10122       if (gainUE[i]>maxGain) maxGain=gainUE[i];
10123       if (gainUW[i]>maxGain) maxGain=gainUW[i];
10124       if (gainLE[i]>maxGain) maxGain=gainLE[i];
10125       if (gainLW[i]>maxGain) maxGain=gainLW[i];
10126       
10127       if (i%2==0){
10128         if (gainUE[i]<minGain) minGain=gainUE[i];
10129         if (gainLE[i]<minGain) minGain=gainLE[i];
10130       }
10131       if (i%2==1){
10132         if (gainLW[i]<minGain) minGain=gainLW[i];
10133         if (gainUW[i]<minGain) minGain=gainUW[i];
10134       }
10135       MSG("LIAnalysis",Msg::kInfo)
10136         <<"Max gain="<<maxGain<<", minGain="<<minGain<<endl;
10137     }
10138     
10139     MSG("LIAnalysis",Msg::kInfo)
10140       <<"Max gain="<<maxGain<<", minGain="<<minGain<<endl;
10141     
10142     Float_t z=3.84;
10143     Int_t sm2=0;
10144     
10145     for (Int_t i=0;i<NUMPULSERBOXES-2;i++){
10146       MSG("LIAnalysis",Msg::kInfo)
10147         <<"Filling EW UL graphs, PB="<<i<<endl;
10148       
10149       if (i>=8) sm2=1;
10150       
10151       //fill gains
10152       if (i%2==0){
10153         gGainUE->SetPoint((i+1)/2,(static_cast<Float_t>
10154                                    ((i+1)/2)+1)*z+sm2-2,
10155                           gainUE[i]);
10156         gGainLE->SetPoint((i+1)/2,(static_cast<Float_t>
10157                                    ((i+1)/2)+1)*z+sm2-2,
10158                           gainLE[i]);
10159         MSG("LIAnalysis",Msg::kInfo)
10160           <<"East, i="<<i<<", (i+1)/2="<<(i+1)/2
10161           <<", gainUE[i]="<<gainUE[i]<<", gainLE[i]="<<gainLE[i]<<endl;
10162       }
10163       else if (i%2==1){
10164         gGainUW->SetPoint(i/2,(static_cast<Float_t>(i/2)+1)*z+sm2-2,
10165                           gainUW[i]);
10166         gGainLW->SetPoint(i/2,(static_cast<Float_t>(i/2)+1)*z+sm2-2,
10167                           gainLW[i]);
10168         MSG("LIAnalysis",Msg::kInfo)
10169           <<"West, i="<<i<<", i/2="<<i/2
10170           <<", gainUW[i]="<<gainUW[i]<<", gainLW[i]="<<gainLW[i]<<endl;
10171       }
10172     }
10173 
10174     //draw the graphs
10175     TCanvas *c=new TCanvas("c","c",0,0,1200,600);
10176     c->SetFillColor(0);
10177     c->cd();
10178     gGainUE->Draw("APL");
10179     s="Average Gain vs Z position";
10180     gGainUE->SetTitle(s.c_str());
10181     gGainUE->GetXaxis()->SetTitle("Z position (m)");
10182     gGainUE->GetYaxis()->SetTitle("Average Gain (Adcs/p.e.)");
10183     gGainUE->GetXaxis()->CenterTitle();
10184     gGainUE->GetYaxis()->CenterTitle();
10185     gGainUE->SetMarkerStyle(3);
10186     gGainUE->SetMarkerColor(1);
10187     gGainUE->SetMarkerSize(0.3);
10188     gGainUE->SetLineColor(1);
10189     gGainUE->SetLineStyle(2);
10190     gGainUE->SetMaximum(maxGain+0.07*maxGain);
10191     gGainUE->SetMinimum(minGain-0.07*minGain);
10192     
10193     gGainUW->Draw("PL");
10194     gGainUW->SetMarkerStyle(3);
10195     gGainUW->SetMarkerColor(1);
10196     gGainUW->SetMarkerSize(0.3);
10197     gGainUW->SetLineColor(1);
10198     
10199     gGainLW->Draw("PL");
10200     gGainLW->SetMarkerStyle(3);
10201     gGainLW->SetMarkerColor(2);
10202     gGainLW->SetMarkerSize(0.3);
10203     gGainLW->SetLineColor(2);
10204     
10205     gGainLE->Draw("PL");
10206     gGainLE->SetMarkerStyle(3);
10207     gGainLE->SetMarkerColor(2);
10208     gGainLE->SetMarkerSize(0.3);
10209     gGainLE->SetLineColor(2);
10210     gGainLE->SetLineStyle(2);
10211   }
10212 
10213   for (Int_t i=0;i<NUMPULSERBOXES;i++){
10214     MSG("LIAnalysis",Msg::kInfo)
10215       <<"Analysing PB="<<i<<endl;
10216     for (Int_t j=0;j<NUMLEDS;j++){
10217       Int_t l=i*NUMLEDS+j;
10218 
10219       Double_t nearAdc=hAdcLedNearPb[l]->GetMean();
10220       Double_t farAdc=hAdcLedFarPb[l]->GetMean();
10221 
10222       //set points for graphs
10223       gErrorsAdcLedNear->SetPoint(l,static_cast<Float_t>(l+1),nearAdc);
10224       gErrorsAdcLedFar->SetPoint(l,static_cast<Float_t>(l+1),farAdc);
10225       gAdcLedNear->SetPoint(l,static_cast<Float_t>(l+1),nearAdc);
10226       gAdcLedFar->SetPoint(l,static_cast<Float_t>(l+1),farAdc);
10227       gGain->SetPoint(l,static_cast<Float_t>(l+1),hGain[l]->GetMean());
10228       gGainF->SetPoint(l,
10229                        static_cast<Float_t>(l+1),hGainF[l]->GetMean());
10230       gNpe->SetPoint(l,static_cast<Float_t>(l+1),hNpe[l]->GetMean());
10231       gNpeF->SetPoint(l,static_cast<Float_t>(l+1),hNpeF[l]->GetMean());
10232 
10233       gFlash->SetPoint(l,static_cast<Float_t>(l+1),hFlash[l]->GetMean());
10234       gRms->SetPoint(l,static_cast<Float_t>(l+1),hRms[l]->GetMean());
10235 
10236       //calculate the maxs
10237       if (nearAdc>nearAdcMax) nearAdcMax=nearAdc;
10238       if (farAdc>farAdcMax) farAdcMax=farAdc;
10239 
10240       //set near PB errors
10241       Int_t ent=static_cast<Int_t>(hAdcLedNearPb[l]->GetEntries());
10242       Float_t runningTotal=0;
10243       Int_t errorSetL=0;
10244       Int_t errorSetH=0;
10245       Double_t eyl=0;
10246       Double_t eyh=0;
10247       for (Int_t k=0;k<hAdcLedNearPb[l]->GetNbinsX();k++){
10248         if (ent==0) break;
10249         runningTotal+=hAdcLedNearPb[l]->GetBinContent(k);
10250         
10251         if (runningTotal/ent>0.05 && errorSetL==0){
10252           eyl=static_cast<Double_t>(hAdcLedNearPb[l]->GetBinLowEdge(k));
10253           if (eyl<hAdcLedNearPb[l]->GetMean()){
10254             eyl=hAdcLedNearPb[l]->GetMean()-eyl;
10255           }
10256           else{
10257             MSG("LIAnalysis",Msg::kWarning)
10258               <<"Near: Lower error greater than mean!"
10259               <<"mean="<<hAdcLedNearPb[l]->GetMean()<<", eyl="<<eyl
10260               <<endl;
10261             eyl=0;
10262           }
10263           errorSetL=1;
10264           MSG("LIAnalysis",Msg::kDebug)
10265             <<"Near: Low error set, bin="<<k<<", low edge="<<eyl
10266             <<", percentage="<<100*runningTotal/ent<<endl;
10267         }
10268         else if (runningTotal/ent>0.95 && errorSetH==0){
10269           eyh=static_cast<Double_t>(hAdcLedNearPb[l]->GetBinLowEdge(k));
10270           if (eyh>hAdcLedNearPb[l]->GetMean()){
10271             eyh=eyh-hAdcLedNearPb[l]->GetMean();
10272           }
10273           else{
10274             MSG("LIAnalysis",Msg::kWarning)
10275               <<"Near: Upper error less than mean!"
10276               <<"mean="<<hAdcLedNearPb[l]->GetMean()<<", eyh="<<eyh
10277               <<endl;
10278             eyh=0;
10279           }
10280           errorSetH=1;
10281           MSG("LIAnalysis",Msg::kDebug)
10282             <<"Near: High error set, bin="<<k<<", low edge="<<eyh
10283             <<", percentage="<<100*runningTotal/ent<<endl;
10284         }
10285       }
10286       gErrorsAdcLedNear->SetPointError(l,0,0,eyl,eyh);
10287       MSG("LIAnalysis",Msg::kDebug)
10288         <<"eyl="<<eyl<<", get error="<<*gErrorsAdcLedNear->GetEYlow()
10289         <<", eyh="<<eyh<<", get error="<<*gErrorsAdcLedNear->GetEYhigh()
10290         <<endl;
10291       
10292       //set far PB errors
10293       ent=static_cast<Int_t>(hAdcLedFarPb[l]->GetEntries());
10294       runningTotal=0;
10295       errorSetL=0;
10296       errorSetH=0;
10297       eyl=0;
10298       eyh=0;
10299       for (Int_t k=0;k<hAdcLedFarPb[l]->GetNbinsX();k++){
10300         if (ent==1) break;
10301         runningTotal+=hAdcLedFarPb[l]->GetBinContent(k);
10302         if (runningTotal/ent>0.05 && errorSetL==0){
10303           eyl=static_cast<Double_t>(hAdcLedFarPb[l]->GetBinLowEdge(k));
10304           if (eyl<hAdcLedFarPb[l]->GetMean()){
10305             eyl=hAdcLedFarPb[l]->GetMean()-eyl;
10306           }
10307           else{
10308             MSG("LIAnalysis",Msg::kWarning)
10309               <<"Far: Lower error greater than mean!"
10310               <<"mean="<<hAdcLedFarPb[l]->GetMean()
10311               <<", eyl="<<eyl<<endl;
10312             eyl=0;
10313           }
10314           errorSetL=1;
10315           MSG("LIAnalysis",Msg::kDebug)
10316             <<"Far: Low error set, bin="<<k<<", low edge="<<eyl
10317             <<", percentage="<<100*runningTotal/ent<<endl;
10318         }
10319         else if (runningTotal/ent>0.95 && errorSetH==0){
10320           eyh=static_cast<Double_t>(hAdcLedFarPb[l]->GetBinLowEdge(k));
10321           if (eyh>hAdcLedFarPb[l]->GetMean()){
10322             eyh=eyh-hAdcLedFarPb[l]->GetMean();
10323           }
10324           else{
10325             MSG("LIAnalysis",Msg::kWarning)
10326               <<"Far: Upper error less than mean!"
10327               <<"mean="<<hAdcLedFarPb[l]->GetMean()
10328               <<", eyh="<<eyh<<endl;
10329             eyh=0;
10330           }
10331           errorSetH=1;
10332           MSG("LIAnalysis",Msg::kDebug)
10333             <<"Far: High error set, bin="<<k<<", low edge="<<eyh
10334             <<", percentage="<<100*runningTotal/ent<<endl;
10335         }
10336       }
10337       gErrorsAdcLedFar->SetPointError(l,0,0,eyl,eyh);
10338 
10339       Int_t draw=0;
10340       if (draw==1){
10341         string sPulserBox=Form("%d",i);
10342         string sLed=Form("%d",j+1);
10343         string sPulseWidth=Form("%d",pulseWidth);
10344         string sPulseHeight=Form("%d",ph[l]);
10345         string sPulseFreq=Form("%d",static_cast<Int_t>
10346                                (ceil(1.0/(period*1.0e-5))));
10347         string sConstantBit=", PB="+sPulserBox+
10348           ", LED="+sLed+", PH="+sPulseHeight+", PW="+sPulseWidth+
10349           ", PF="+sPulseFreq+" Hz";
10350 
10351         MSG("LIAnalysis",Msg::kDebug)
10352           <<"LI parameters: "<<", PB="<<sPulserBox
10353           <<", LED="<<sLed<<", PH="<<sPulseHeight
10354           <<", PW="<<sPulseWidth<<", PF="<<sPulseFreq<<endl;
10355         
10356         //set histo titles
10357         s="ADC Values, Near&Far side"+sConstantBit;
10358         hAdcLed[l]->SetTitle(s.c_str());
10359         s="Gain Values, Near side"+sConstantBit;
10360         hGain[l]->SetTitle(s.c_str());
10361         s="Npe Values, Near side"+sConstantBit;
10362         hNpe[l]->SetTitle(s.c_str());
10363         s="Flash Values, Near side"+sConstantBit;
10364         hFlash[l]->SetTitle(s.c_str());
10365         s="RMS Values, Near side"+sConstantBit;
10366         hRms[l]->SetTitle(s.c_str());
10367         
10368         //set maximums
10369         hAdcLed[l]->SetMaximum(maxNumEntAdc);
10370         hGain[l]->SetMaximum(maxNumEntGain);
10371         hNpe[l]->SetMaximum(maxNumEntNpe);
10372         hFlash[l]->SetMaximum(maxNumEntFlash);
10373         hRms[l]->SetMaximum(maxNumEntRms);
10374 
10375         cAdcLed->Clear();
10376         cAdcLed->cd();
10377         if (sLowRunNumber==sRunNumber) s=sRunNumber+
10378                                            "AdcLedHisto.ps";
10379         else s=sLowRunNumber+"-"+sRunNumber+"AdcLedHisto.ps";   
10380         if (i*NUMLEDS+j==0){
10381           s+="(";
10382           gErrorIgnoreLevel=1;
10383         }
10384         else if(i*NUMLEDS+j==NUMLEDS*NUMPULSERBOXES-1){
10385           s+=")";
10386           gErrorIgnoreLevel=0;
10387           MSG("LIAnalysis",Msg::kInfo)<<"Done last plot"<<endl;  
10388         }
10389         hAdcLed[l]->Draw();
10390         hAdcLedNearPb[l]->Draw("same");
10391         hAdcLedFarPb[l]->Draw("same");
10392         cAdcLed->Print(s.c_str());
10393         
10394         cGainLed->Clear();
10395         cGainLed->cd();
10396         if (sLowRunNumber==sRunNumber) s=sRunNumber+"GainLedHisto.ps";
10397         else s=sLowRunNumber+"-"+sRunNumber+"GainLedHisto.ps";
10398         if (i*NUMLEDS+j==0){
10399           s+="(";
10400           gErrorIgnoreLevel=1;
10401         }
10402         else if(i*NUMLEDS+j==NUMLEDS*NUMPULSERBOXES-1){
10403           s+=")";
10404           gErrorIgnoreLevel=0;
10405           MSG("LIAnalysis",Msg::kInfo)<<"Done last plot"<<endl;  
10406         }
10407         hGain[l]->Draw();
10408         cGainLed->Print(s.c_str());
10409         
10410         cNpeLed->Clear();
10411         cNpeLed->cd();
10412         if (sLowRunNumber==sRunNumber) s=sRunNumber+"NpeLedHisto.ps";
10413         else s=sLowRunNumber+"-"+sRunNumber+"NpeLedHisto.ps";
10414         if (i*NUMLEDS+j==0){
10415           s+="("; 
10416           gErrorIgnoreLevel=1;
10417         }
10418         else if(i*NUMLEDS+j==NUMLEDS*NUMPULSERBOXES-1){
10419           s+=")";
10420           gErrorIgnoreLevel=0;
10421           MSG("LIAnalysis",Msg::kInfo)<<"Done last plot"<<endl;  
10422           }
10423         hNpe[l]->Draw();
10424         cNpeLed->Print(s.c_str());
10425       }
10426     }
10427   }
10428 
10429   //print out a list of the near and far average adcs
10430   for (Int_t i=0;i<NUMPULSERBOXES;i++){
10431     for (Int_t j=0;j<NUMLEDS;j++){
10432       Int_t l=i*NUMLEDS+j;
10433       Double_t yNear=-1;
10434       Double_t yFar=-1;
10435       Double_t x=-1;
10436       gAdcLedNear->GetPoint(l,x,yNear);
10437       gAdcLedFar->GetPoint(l,x,yFar);
10438 
10439       Double_t npeNear=-1, gainNear=-1; gNpe->GetPoint(l,x,npeNear); gGain->GetPoint(l,x,gainNear);
10440       //Double_t npeFar=-1, gainFar=-1; gNpeF->GetPoint(l,x,npeFar); gGainF->GetPoint(l,x,gainFar);
10441       Double_t flashNear=-1, rmsNear=-1; gFlash->GetPoint(l,x,flashNear); gRms->GetPoint(l,x,rmsNear);
10442 
10443       if (yNear>1){
10444 
10445         string sPulseWidth=Form("%d",pulseWidth);
10446         string sPulseHeight=Form("%d",ph[l]);
10447         string sPulseFreq=Form("%d",static_cast<Int_t>
10448                                (ceil(1.0/(period*1.0e-5))));
10449         string sNF=Form("%d",pulses);
10450         string sConstantBit="NF= "+sNF+" PH= "+sPulseHeight;
10451         //string sConstantBit="NF= "+sNF+" PF= "+sPulseFreq+" PH= "+sPulseHeight+" PW= "+sPulseWidth;
10452 
10453       }
10454     }
10455   }
10456 
10457   //set strings for use in titles
10458   string sPulseWidth=Form("%d",pulseWidth);
10459   string sPulseHeight=Form("%d",pulseHeight);
10460   string sPulseFreq=Form("%d",static_cast<Int_t>
10461                          (ceil(1.0/(period*1.0e-5))));
10462   string sConstantBit=", PW="+sPulseWidth+", PF="+sPulseFreq+" Hz)";
10463 
10464   //draw the graph without errors
10465   TCanvas *cAdcLedGraph=new TCanvas("cAdcLedGraph","cAdcLedGraph",
10466                                     0,0,1200,600);
10467   cAdcLedGraph->SetFillColor(0);
10468   cAdcLedGraph->cd();
10469   gAdcLedNear->Draw("AP");
10470   s="Average ADC vs LED (Near Side"+sConstantBit;
10471   gAdcLedNear->SetTitle(s.c_str());
10472   gAdcLedNear->GetXaxis()->SetTitle("Pulser Box * NUM LEDS + LED");
10473   gAdcLedNear->GetYaxis()->SetTitle("Average ADC");
10474   gAdcLedNear->GetXaxis()->CenterTitle();
10475   gAdcLedNear->GetYaxis()->CenterTitle();
10476   gAdcLedNear->SetMarkerStyle(3);
10477   gAdcLedNear->SetMarkerColor(2);
10478   gAdcLedNear->SetMarkerSize(0.2);
10479   gAdcLedNear->SetLineColor(46);
10480   gAdcLedNear->SetMaximum(15000);
10481 
10482   /*
10483   gAdcLedFar->Draw("P");
10484   s="Average ADC vs LED (Near&Far"+sConstantBit;
10485   gAdcLedFar->SetTitle(s.c_str());
10486   gAdcLedFar->SetMarkerStyle(3);
10487   gAdcLedFar->SetMarkerColor(3);
10488   gAdcLedFar->SetMarkerSize(0.3);
10489   gAdcLedFar->SetLineColor(30);
10490   */  
10491   //print graph to postscript
10492   if (sLowRunNumber==sRunNumber) s=sRunNumber+"AdcVsLed.ps(";
10493   else s=sLowRunNumber+"-"+sRunNumber+"AdcVsLed.ps(";
10494   cAdcLedGraph->Print(s.c_str());
10495 
10496   //draw the graphs with errors
10497   TCanvas *cErrorsAdcLedGraph=new TCanvas("cErrorsAdcLedGraph",
10498                                           "cErrorsAdcLedGraph",
10499                                           0,0,1200,600);
10500   cErrorsAdcLedGraph->SetFillColor(0);
10501   cErrorsAdcLedGraph->cd();
10502 
10503   gErrorsAdcLedNear->Draw("AP");
10504   s="Average ADC vs LED (Near&Far, Error=+/-5% Cut"+sConstantBit;
10505   gErrorsAdcLedNear->SetTitle(s.c_str());
10506   gErrorsAdcLedNear->GetXaxis()->SetTitle("Pulser Box * NUM LEDS + LED");
10507   gErrorsAdcLedNear->GetYaxis()->SetTitle("Average ADC");
10508   gErrorsAdcLedNear->GetXaxis()->CenterTitle();
10509   gErrorsAdcLedNear->GetYaxis()->CenterTitle();
10510   gErrorsAdcLedNear->SetMarkerStyle(3);
10511   gErrorsAdcLedNear->SetMarkerColor(2);
10512   gErrorsAdcLedNear->SetMarkerSize(0.2);
10513   gErrorsAdcLedNear->SetLineColor(46);
10514 
10515   gErrorsAdcLedFar->Draw("P");
10516 
10517   gErrorsAdcLedFar->SetTitle(s.c_str());
10518   gErrorsAdcLedFar->SetMarkerStyle(3);
10519   gErrorsAdcLedFar->SetMarkerColor(3);
10520   gErrorsAdcLedFar->SetMarkerSize(0.3);
10521   gErrorsAdcLedFar->SetLineColor(30);
10522   //print graph to postscript
10523   if (sLowRunNumber==sRunNumber) s=sRunNumber+"AdcVsLed.ps";
10524   else s=sLowRunNumber+"-"+sRunNumber+"AdcVsLed.ps";
10525   cErrorsAdcLedGraph->Print(s.c_str());
10526 
10527   //draw graphs separately
10528   TCanvas *cErrorsAdcLedGraphNear=new TCanvas("cErrorsAdcLedGraphNear",
10529                                         "cErrorsAdcLedGraphNear",
10530                                         0,0,1200,600);
10531   cErrorsAdcLedGraphNear->SetFillColor(0);
10532   cErrorsAdcLedGraphNear->cd();
10533   gErrorsAdcLedNear->Draw("AP");
10534   s="Average ADC vs LED (Near Side, Error=+/-5% Cut"+sConstantBit;
10535   gErrorsAdcLedNear->SetTitle(s.c_str());
10536   gErrorsAdcLedNear->SetLineColor(46);
10537   //print graph to postscript
10538   if (sLowRunNumber==sRunNumber) s=sRunNumber+"AdcVsLed.ps";
10539   else s=sLowRunNumber+"-"+sRunNumber+"AdcVsLed.ps";
10540   cErrorsAdcLedGraphNear->Print(s.c_str());
10541 
10542   TCanvas *cErrorsAdcLedGraphFar=new TCanvas("cErrorsAdcLedGraphFar",
10543                                        "cErrorsAdcLedGraphFar",
10544                                        0,0,1200,600);
10545   cErrorsAdcLedGraphFar->SetFillColor(0);
10546   cErrorsAdcLedGraphFar->cd();
10547   gErrorsAdcLedFar->SetMaximum();//set to default to trigger recomputing
10548   gErrorsAdcLedFar->SetMinimum();//of the range
10549   gErrorsAdcLedFar->Draw("AP");
10550   s="Average ADC vs LED (Far Side, Error=+/-5% Cut"+sConstantBit;
10551   gErrorsAdcLedFar->SetTitle(s.c_str());
10552   gErrorsAdcLedFar->GetXaxis()->SetTitle("Pulser Box * NUM LEDS + LED");
10553   gErrorsAdcLedFar->GetYaxis()->SetTitle("Average ADC");
10554   gErrorsAdcLedFar->GetXaxis()->CenterTitle();
10555   gErrorsAdcLedFar->GetYaxis()->CenterTitle();
10556   gErrorsAdcLedFar->SetLineColor(30);
10557   //print to graph to postscript
10558   if (sLowRunNumber==sRunNumber) s=sRunNumber+"AdcVsLed.ps)";
10559   else s=sLowRunNumber+"-"+sRunNumber+"AdcVsLed.ps)";
10560   cErrorsAdcLedGraphFar->Print(s.c_str());
10561 
10562   //draw gain plots
10563   TCanvas *cGain=new TCanvas("cGain","cGain",0,0,1200,600);
10564   cGain->SetFillColor(0);
10565   cGain->cd();
10566   gGain->Draw("AP");
10567   s="Average Gain vs LED (Near&Far"+sConstantBit;
10568   gGain->SetTitle(s.c_str());
10569   gGain->GetXaxis()->SetTitle("Pulser Box * NUM LEDS + LED");
10570   gGain->GetYaxis()->SetTitle("Average Gain");
10571   gGain->GetXaxis()->CenterTitle();
10572   gGain->GetYaxis()->CenterTitle();
10573   gGain->SetMarkerStyle(3);
10574   gGain->SetMarkerColor(2);
10575   gGain->SetMarkerSize(0.2);
10576   gGain->SetLineColor(46);
10577   gGain->SetMinimum(-1);
10578 
10579   gGainF->Draw("P");
10580   s="Average Gain vs LED (Near&Far"+sConstantBit;
10581   gGainF->SetTitle(s.c_str());
10582   gGainF->SetMarkerStyle(3);
10583   gGainF->SetMarkerColor(3);
10584   gGainF->SetMarkerSize(0.2);
10585   gGainF->SetLineColor(30);
10586   //print to graph to postscript
10587   if (sLowRunNumber==sRunNumber) s=sRunNumber+"GainVsLed.ps(";
10588   else s=sLowRunNumber+"-"+sRunNumber+"GainVsLed.ps(";
10589   cGain->Print(s.c_str());
10590 
10591   cGain->Clear();
10592   cGain->cd();
10593   gGain->Draw("AP");
10594   s="Average Gain vs LED (Near Side"+sConstantBit;
10595   gGain->SetTitle(s.c_str());
10596   gGain->GetXaxis()->SetTitle("Pulser Box * NUM LEDS + LED");
10597   gGain->GetYaxis()->SetTitle("Average Gain");
10598   gGain->GetXaxis()->CenterTitle();
10599   gGain->GetYaxis()->CenterTitle();
10600   gGain->SetMarkerStyle(3);
10601   gGain->SetMarkerColor(2);
10602   gGain->SetMarkerSize(0.2);
10603   gGain->SetLineColor(46);
10604   gGain->SetMinimum(-1);
10605   //print to graph to postscript
10606   if (sLowRunNumber==sRunNumber) s=sRunNumber+"GainVsLed.ps";
10607   else s=sLowRunNumber+"-"+sRunNumber+"GainVsLed.ps";
10608   cGain->Print(s.c_str());
10609 
10610   cGain->Clear();
10611   cGain->cd();
10612   gGainF->Draw("AP");
10613   s="Average Gain vs LED (Far Side"+sConstantBit;
10614   gGainF->SetTitle(s.c_str());
10615   gGainF->GetXaxis()->SetTitle("Pulser Box * NUM LEDS + LED");
10616   gGainF->GetYaxis()->SetTitle("Average Gain");
10617   gGainF->GetXaxis()->CenterTitle();
10618   gGainF->GetYaxis()->CenterTitle();
10619   gGainF->SetMarkerStyle(3);
10620   gGainF->SetMarkerColor(3);
10621   gGainF->SetMarkerSize(0.2);
10622   gGainF->SetLineColor(30);
10623   gGainF->SetMinimum(-1);
10624   //print to graph to postscript
10625   if (sLowRunNumber==sRunNumber) s=sRunNumber+"GainVsLed.ps)";
10626   else s=sLowRunNumber+"-"+sRunNumber+"GainVsLed.ps)";
10627   cGain->Print(s.c_str());
10628 
10629   //draw npe plots
10630   TCanvas *cNpe=new TCanvas("cNpe","cNpe",0,0,1200,600);
10631   cNpe->SetFillColor(0);
10632   cNpe->cd();
10633   gNpe->Draw("AP");
10634   s="Average Npe vs LED (Near&Far"+sConstantBit;
10635   gNpe->SetTitle(s.c_str());
10636   gNpe->GetXaxis()->SetTitle("Pulser Box * NUM LEDS + LED");
10637   gNpe->GetYaxis()->SetTitle("Average Npe");
10638   gNpe->GetXaxis()->CenterTitle();
10639   gNpe->GetYaxis()->CenterTitle();
10640   gNpe->SetMarkerStyle(3);
10641   gNpe->SetMarkerColor(2);
10642   gNpe->SetMarkerSize(0.2);
10643   gNpe->SetLineColor(46);
10644   gNpe->SetMinimum(-1);
10645 
10646   gNpeF->Draw("P");
10647   s="Average Npe vs LED (Near&Far"+sConstantBit;
10648   gNpeF->SetTitle(s.c_str());
10649   gNpeF->SetMarkerStyle(3);
10650   gNpeF->SetMarkerColor(3);
10651   gNpeF->SetMarkerSize(0.2);
10652   gNpeF->SetLineColor(30);
10653   //print to graph to postscript
10654   if (sLowRunNumber==sRunNumber) s=sRunNumber+"NpeVsLed.ps(";
10655   else s=sLowRunNumber+"-"+sRunNumber+"NpeVsLed.ps(";
10656   cNpe->Print(s.c_str());
10657 
10658   cNpe->Clear();
10659   cNpe->cd();
10660   gNpe->Draw("AP");
10661   s="Average Npe vs LED (Near Side"+sConstantBit;
10662   gNpe->SetTitle(s.c_str());
10663   gNpe->GetXaxis()->SetTitle("Pulser Box * NUM LEDS + LED");
10664   gNpe->GetYaxis()->SetTitle("Average Npe");
10665   gNpe->GetXaxis()->CenterTitle();
10666   gNpe->GetYaxis()->CenterTitle();
10667   gNpe->SetMarkerStyle(3);
10668   gNpe->SetMarkerColor(2);
10669   gNpe->SetMarkerSize(0.2);
10670   gNpe->SetLineColor(46);
10671   gNpe->SetMinimum(-1);
10672   //print to graph to postscript
10673   if (sLowRunNumber==sRunNumber) s=sRunNumber+"NpeVsLed.ps";
10674   else s=sLowRunNumber+"-"+sRunNumber+"NpeVsLed.ps";
10675   cNpe->Print(s.c_str());
10676 
10677   cNpe->Clear();
10678   cNpe->cd();
10679   gNpeF->Draw("AP");
10680   s="Average Npe vs LED (Far Side"+sConstantBit;
10681   gNpeF->SetTitle(s.c_str());
10682   gNpeF->GetXaxis()->SetTitle("Pulser Box * NUM LEDS + LED");
10683   gNpeF->GetYaxis()->SetTitle("Average Npe");
10684   gNpeF->GetXaxis()->CenterTitle();
10685   gNpeF->GetYaxis()->CenterTitle();
10686   gNpeF->SetMarkerStyle(3);
10687   gNpeF->SetMarkerColor(3);
10688   gNpeF->SetMarkerSize(0.2);
10689   gNpeF->SetLineColor(30);
10690   gNpeF->SetMinimum(-1);
10691   //print to graph to postscript
10692   if (sLowRunNumber==sRunNumber) s=sRunNumber+"NpeVsLed.ps)";
10693   else s=sLowRunNumber+"-"+sRunNumber+"NpeVsLed.ps)";
10694   cNpe->Print(s.c_str());
10695 
10696   MSG("LIAnalysis",Msg::kInfo)  
10697     <<endl<<" ** Finished the AdcVsLed method ** "<<endl; 
10698 } 

void LIAnalysis::AdcVsPin  ) 
 

Definition at line 1083 of file LIAnalysis.cxx.

References chain, chip, correlatedHit, draw(), Form(), GetElecString(), histname, InitialiseLoopVariables(), led, lowRunNumber, mean, MSG, numEntries, period, pinGain, pulseHeight, pulserBox, pulses, pulseWidth, readoutType, rms, runNumber, s, and SetLoopVariables().

01084 {
01085   MSG("LIAnalysis",Msg::kInfo) 
01086     <<endl<<" ** Running the AdcVsPin method... ** "<<endl;
01087 
01088   Int_t numAdcBins=150;
01089 
01090   //histos for different pins, high gain
01091   TH1F **hAdcHighPin=0;
01092   hAdcHighPin= new TH1F*[NUMLEDS*NUMPULSERBOXES];
01093   for (Int_t i=0;i<NUMPULSERBOXES;i++){
01094     for (Int_t j=0;j<NUMLEDS;j++){
01095       //calculate array number
01096       Int_t l=i*NUMLEDS+j;
01097       //initialse histos
01098       sprintf(histname,"High Gain PIN Adc Distribution, PB %d, LED %d",
01099               i,j+1);
01100       hAdcHighPin[l]=new TH1F(histname,histname,numAdcBins,0,15000);
01101       hAdcHighPin[l]->GetXaxis()->SetTitle("ADC");
01102       hAdcHighPin[l]->GetXaxis()->CenterTitle();
01103       hAdcHighPin[l]->GetYaxis()->SetTitle("Number of Entries");
01104       hAdcHighPin[l]->GetYaxis()->CenterTitle();
01105       hAdcHighPin[l]->SetFillColor(0);
01106       hAdcHighPin[l]->SetLineColor(2);
01107       hAdcHighPin[l]->Fill(1);
01108       //hAdcHighPin[l]->SetBit(TH1::kCanRebin);
01109     }
01110   }
01111  
01112   //histos for different pins, low gain
01113   TH1F **hAdcLowPin=0;
01114   hAdcLowPin= new TH1F*[NUMLEDS*NUMPULSERBOXES];
01115   for (Int_t i=0;i<NUMPULSERBOXES;i++){
01116     for (Int_t j=0;j<NUMLEDS;j++){
01117       //calculate array number
01118       Int_t l=i*NUMLEDS+j;
01119       //initialse histos
01120       sprintf(histname,"Low Gain PIN Adc Distribution, PB %d, LED %d",
01121               i,j+1);
01122       hAdcLowPin[l]=new TH1F(histname,histname,numAdcBins,0,15000);
01123       hAdcLowPin[l]->GetXaxis()->SetTitle("ADC");
01124       hAdcLowPin[l]->GetXaxis()->CenterTitle();
01125       hAdcLowPin[l]->GetYaxis()->SetTitle("Number of Entries");
01126       hAdcLowPin[l]->GetYaxis()->CenterTitle();
01127       hAdcLowPin[l]->SetFillColor(0);
01128       hAdcLowPin[l]->SetLineColor(3);
01129       hAdcLowPin[l]->Fill(1);
01130       //hAdcLowPin[l]->SetBit(TH1::kCanRebin);
01131     }
01132   }
01133 
01134   Float_t* maxAdcHighPin=new Float_t[NUMLEDS*NUMPULSERBOXES];
01135   Float_t* maxAdcLowPin=new Float_t[NUMLEDS*NUMPULSERBOXES]; 
01136   Float_t* rmsHighPin=new Float_t[NUMLEDS*NUMPULSERBOXES];
01137   Float_t* rmsLowPin=new Float_t[NUMLEDS*NUMPULSERBOXES]; 
01138   Float_t* rms2HighPin=new Float_t[NUMLEDS*NUMPULSERBOXES];
01139   Float_t* rms2LowPin=new Float_t[NUMLEDS*NUMPULSERBOXES]; 
01140   Float_t* numHighPin=new Float_t[NUMLEDS*NUMPULSERBOXES];
01141   Float_t* numLowPin=new Float_t[NUMLEDS*NUMPULSERBOXES]; 
01142 
01143   //initialise arrays
01144   for (Int_t i=0;i<NUMLEDS*NUMPULSERBOXES;i++){ 
01145     maxAdcHighPin[i]=0;
01146     maxAdcLowPin[i]=0;
01147     rmsHighPin[i]=0;
01148     rmsLowPin[i]=0;
01149     rms2HighPin[i]=0;
01150     rms2LowPin[i]=0;
01151     numHighPin[i]=0;
01152     numLowPin[i]=0;
01153   }
01154 
01158    
01159   this->InitialiseLoopVariables();   
01160    
01161   for(Int_t entry=0;entry<numEvents;entry++){ 
01162      
01163     this->SetLoopVariables(entry,0); 
01164      
01165     //ignore any zeros 
01166     if (mean==0 || rms==0 || numEntries==0) continue; 
01167     
01168     //only look at pins 
01169     if (readoutType!=ReadoutType::kPinDiode) continue; 
01170 
01171     //cut out strange pins with high mean
01172     if (numEntries<0.8*pulses) continue;
01173 
01174     if (pulserBox>=FIRSTPULSERBOX && pulserBox<=LASTPULSERBOX &&
01175         led>=FIRSTLED && led<=LASTLED){
01176       //define led number
01177       Int_t l=pulserBox*NUMLEDS+led-1;
01178 
01179       if (numEntries<0.5*pulses && mean>1000){
01180         MSG("LIAnalysis",Msg::kInfo)
01181           <<"**** Strange pin: ("<<pulserBox<<":"<<led
01182           <<") on"
01183           <<" "<<this->GetElecString()
01184           <<", plex gain="<<pinGain<<", mean="<<mean<<", rms="<<rms
01185           <<", num="<<numEntries<<", cHit="<<correlatedHit<<endl;
01186       }
01187       
01188       //will require a correlated hit when plex is working
01189       //fill histo for appropriate pin
01190       if (chip==1){//high gain (=0) (chip 1)
01191         hAdcHighPin[l]->Fill(mean);
01192         //find max value for high gain pin
01193         if (mean>maxAdcHighPin[l]) {
01194           maxAdcHighPin[l]=mean;
01195           rmsHighPin[l]=rms;
01196           rms2HighPin[l]=rms*rms;
01197           numHighPin[l]=numEntries;
01198           MSG("LIAnalysis",Msg::kInfo)
01199             <<"HG Pin ("<<pulserBox<<":"<<led
01200             <<") on"
01201             <<" "<<this->GetElecString()
01202             <<", plex gain="<<pinGain<<", mean="<<mean<<", rms="<<rms
01203             <<", num="<<numEntries<<", cHit="<<correlatedHit<<endl;
01204         }
01205       }
01206       else if (chip==0){//low gain (=1) (chip 0)
01207         hAdcLowPin[l]->Fill(mean);
01208         //find max value for low gain pin
01209         if (mean>maxAdcLowPin[l]) {
01210           maxAdcLowPin[l]=mean;
01211           rmsLowPin[l]=rms;
01212           rms2LowPin[l]=rms*rms;
01213           numLowPin[l]=numEntries;
01214           MSG("LIAnalysis",Msg::kInfo)
01215             <<"LG Pin ("<<pulserBox<<":"<<led
01216             <<") on"
01217             <<" "<<this->GetElecString()
01218             <<", plex gain="<<pinGain<<", mean="<<mean<<", rms="<<rms
01219             <<", num="<<numEntries<<", cHit="<<correlatedHit<<endl;
01220         }
01221       }
01222 
01223       //print out warnings if there are inconsistencies
01224       if ((pinGain!=1 && chip==0) || (pinGain!=0 && chip==1)) {
01225         MSG("LIAnalysis",Msg::kDebug)
01226           <<"**** Strange pin, wrong gain in plex,"
01227           <<" "<<this->GetElecString()
01228           <<", plex gain="<<pinGain<<", mean="<<mean<<", rms="<<rms
01229           <<", num="<<numEntries<<", cHit="<<correlatedHit<<endl;
01230       }
01231     }
01232   }//end of for
01233 
01237  
01238   MSG("LIAnalysis",Msg::kInfo)<<"Finished main loop"<<endl;
01239  
01240   //include the under and overflow counts 
01241   gStyle->SetOptStat(1111111); 
01242   //set up useful string 
01243   string sRunNumber=Form("%d",runNumber); 
01244   string sLowRunNumber=Form("%d",lowRunNumber);
01245   
01246   MSG("LIAnalysis",Msg::kInfo)
01247     <<"List of pins:"<<endl;
01248   MSG("LIAnalysis",Msg::kInfo)
01249     <<"  HG pins:"<<endl;
01250   for (Int_t i=0;i<NUMPULSERBOXES;i++){
01251     for (Int_t j=0;j<NUMLEDS;j++){
01252       Int_t l=i*NUMLEDS+j;  
01253       MSG("LIAnalysis",Msg::kInfo)
01254         <<"    ("<<i<<":"<<j+1<<") mean="<<maxAdcHighPin[l]
01255         <<", rms="<<rmsHighPin[l]
01256         <<", num="<<numHighPin[l]<<endl;
01257     }
01258   }
01259 
01260   MSG("LIAnalysis",Msg::kInfo)
01261     <<"  LG pins:"<<endl;
01262   for (Int_t i=0;i<NUMPULSERBOXES;i++){
01263     for (Int_t j=0;j<NUMLEDS;j++){
01264       Int_t l=i*NUMLEDS+j;
01265       MSG("LIAnalysis",Msg::kInfo)
01266         <<"    ("<<i<<":"<<j+1<<") mean="<<maxAdcLowPin[l]
01267         <<", rms="<<rmsLowPin[l]
01268         <<", num="<<numLowPin[l]<<endl;
01269     }
01270   }
01271 
01272   //get the maximum in order to scale all plots
01273   Int_t maxNumEnt=0;
01274   for (Int_t i=0;i<NUMPULSERBOXES*NUMLEDS;i++){
01275     if (hAdcHighPin[i]->GetMaximum()>maxNumEnt){
01276       maxNumEnt=static_cast<Int_t>(hAdcHighPin[i]->GetMaximum());
01277       MSG("LIAnalysis",Msg::kInfo)
01278         <<"Calculating max number of entries, current highest="
01279         <<maxNumEnt<<", l="<<i<<endl;
01280     }
01281   }
01282 
01283   for (Int_t i=0;i<NUMPULSERBOXES*NUMLEDS;i++){
01284     if (hAdcLowPin[i]->GetMaximum()>maxNumEnt){
01285       maxNumEnt=static_cast<Int_t>(hAdcLowPin[i]->GetMaximum());
01286       MSG("LIAnalysis",Msg::kInfo)
01287         <<"Calculating max number of entries (low), current highest="
01288         <<maxNumEnt<<", l="<<i<<endl;
01289     }
01290   }
01291 
01292   //allocate space for TGraphs then loop and fill them below
01293   TGraphAsymmErrors *gErrorsAdcHighPin=new 
01294     TGraphAsymmErrors(NUMPULSERBOXES*NUMLEDS);
01295   TGraphAsymmErrors *gErrorsAdcLowPin=new 
01296     TGraphAsymmErrors(NUMPULSERBOXES*NUMLEDS);
01297   TGraph *gAdcHighPin=new TGraph(NUMPULSERBOXES*NUMLEDS);
01298   TGraph *gAdcLowPin=new TGraph(NUMPULSERBOXES*NUMLEDS);
01299   TGraph *gRmsHighPin=new TGraph(NUMPULSERBOXES*NUMLEDS);
01300   TGraph *gRmsLowPin=new TGraph(NUMPULSERBOXES*NUMLEDS);
01301   TGraph *gRms2HighPin=new TGraph(NUMPULSERBOXES*NUMLEDS);
01302   TGraph *gRms2LowPin=new TGraph(NUMPULSERBOXES*NUMLEDS);
01303   TGraph *gNumHighPin=new TGraph(NUMPULSERBOXES*NUMLEDS);
01304   TGraph *gNumLowPin=new TGraph(NUMPULSERBOXES*NUMLEDS);
01305   TGraph *gResHighPin=new TGraph(NUMPULSERBOXES*NUMLEDS);
01306   TGraph *gResLowPin=new TGraph(NUMPULSERBOXES*NUMLEDS);
01307 
01308 
01309   gAdcHighPin->SetMinimum(0);
01310   gAdcLowPin->SetMinimum(0);
01311   gRmsHighPin->SetMinimum(0);
01312   gRmsLowPin->SetMinimum(0);
01313   gRms2HighPin->SetMinimum(0);
01314   gRms2LowPin->SetMinimum(0);
01315   gNumHighPin->SetMinimum(0);
01316   gNumLowPin->SetMinimum(0);
01317   gResHighPin->SetMinimum(0);  
01318   gResLowPin->SetMinimum(0);
01319 
01320   //create the canvas and draw
01321   TCanvas *cAdcPin=new TCanvas("cAdcPin","cAdcPin",0,0,1000,600);
01322   cAdcPin->SetFillColor(0);
01323   cAdcPin->cd();
01324   for (Int_t i=0;i<NUMPULSERBOXES;i++){
01325     for (Int_t j=0;j<NUMLEDS;j++){
01326       Int_t l=i*NUMLEDS+j;
01327 
01328       //set points for graphs
01329       gErrorsAdcHighPin->SetPoint(l,static_cast<Float_t>(l+1),
01330                                   maxAdcHighPin[l]);
01331       gErrorsAdcLowPin->SetPoint(l,static_cast<Float_t>(l+1),
01332                                  maxAdcLowPin[l]);
01333       gAdcHighPin->SetPoint(l,static_cast<Float_t>(l+1),
01334                             maxAdcHighPin[l]);
01335       gAdcLowPin->SetPoint(l,static_cast<Float_t>(l+1),maxAdcLowPin[l]);
01336 
01337       gRmsHighPin->SetPoint(l,static_cast<Float_t>(l+1),rmsHighPin[l]);
01338       gRmsLowPin->SetPoint(l,static_cast<Float_t>(l+1),rmsLowPin[l]);
01339       gRms2HighPin->SetPoint(l,static_cast<Float_t>(l+1),
01340                              rms2HighPin[l]);
01341       gRms2LowPin->SetPoint(l,static_cast<Float_t>(l+1),rms2LowPin[l]);
01342       gNumHighPin->SetPoint(l,static_cast<Float_t>(l+1),numHighPin[l]);
01343       gNumLowPin->SetPoint(l,static_cast<Float_t>(l+1),numLowPin[l]);
01344       if (maxAdcHighPin[l]>0){
01345         gResHighPin->SetPoint(l,static_cast<Float_t>(l+1),
01346                               rmsHighPin[l]/maxAdcHighPin[l]);
01347       }
01348       else {
01349         gResHighPin->SetPoint(l,static_cast<Float_t>(l+1),0);
01350       }
01351       if (maxAdcLowPin[l]>0){
01352         gResLowPin->SetPoint(l,static_cast<Float_t>(l+1),
01353                              rmsLowPin[l]/maxAdcLowPin[l]);
01354       }
01355       else {
01356         gResLowPin->SetPoint(l,static_cast<Float_t>(l+1),0);
01357       }
01358 
01359       //plot histograms
01360       cAdcPin->Clear();
01361       hAdcHighPin[l]->SetMaximum(maxNumEnt);
01362       string sPulserBox=Form("%d",i);
01363       string sLed=Form("%d",j+1);
01364       string sPulseWidth=Form("%d",pulseWidth);
01365       string sPulseHeight=Form("%d",pulseHeight);
01366       string sPulseFreq=Form("%d",static_cast<Int_t>
01367                              (ceil(1.0/(period*1.0e-5))));
01368       MSG("LIAnalysis",Msg::kDebug)
01369         <<"LI parameters: "
01370         <<", PB="<<sPulserBox
01371         <<", LED="<<sLed
01372         <<", PH="<<sPulseHeight
01373         <<", PW="<<sPulseWidth
01374         <<", PF="<<sPulseFreq
01375         <<endl;
01376       s="Pin ADC Values (High&Low Gain, PB="+sPulserBox+
01377         ", LED="+sLed+", PH="+sPulseHeight+", PW="+sPulseWidth+
01378         ", PF="+sPulseFreq+" Hz)";
01379       hAdcHighPin[l]->SetTitle(s.c_str());
01380 
01381       Int_t draw=1;
01382       if (draw==1){
01383         hAdcHighPin[l]->Draw();
01384         hAdcLowPin[l]->Draw("same");
01385         if (i*NUMLEDS+j==0){
01386           if (sLowRunNumber==sRunNumber) s=sRunNumber+
01387                                              "PinAdcHisto.ps(";
01388           else s=sLowRunNumber+"-"+sRunNumber+"PinAdcHisto.ps(";
01389           cAdcPin->Print(s.c_str());
01390           gErrorIgnoreLevel=1;
01391         }
01392         else if(i*NUMLEDS+j==NUMLEDS*NUMPULSERBOXES-1){
01393           gErrorIgnoreLevel=0;
01394           if (sLowRunNumber==sRunNumber) s=sRunNumber+
01395                                              "PinAdcHisto.ps)";
01396           else s=sLowRunNumber+"-"+sRunNumber+"PinAdcHisto.ps)";
01397           cAdcPin->Print(s.c_str());
01398           MSG("LIAnalysis",Msg::kInfo)<<"Done last plot"<<endl;  
01399         }
01400         else{
01401           if (sLowRunNumber==sRunNumber) s=sRunNumber+
01402                                              "PinAdcHisto.ps";
01403           else s=sLowRunNumber+"-"+sRunNumber+"PinAdcHisto.ps";
01404           cAdcPin->Print(s.c_str());
01405         }
01406       }
01407     }
01408   }
01409   cAdcPin->Clear();
01410   hAdcHighPin[0]->Draw();
01411   hAdcLowPin[0]->Draw("same");
01412 
01413   //set strings for use in titles
01414   string sPulseWidth=Form("%d",pulseWidth);
01415   string sPulseHeight=Form("%d",pulseHeight);
01416   string sPulseFreq=Form("%d",static_cast<Int_t>
01417                          (ceil(1.0/(period*1.0e-5))));
01418   string sPulses=Form("%d",pulses);
01419   string sConstantBit="";
01420 
01421   if (runNumber>=13123){//don't use pulse height
01422     Int_t fph=pulseHeight;
01423     chain->GetEvent(numEvents-1);
01424     Int_t lph=-10;//pulseHeight;
01425     
01426     MSG("LIAnalysis",Msg::kInfo)
01427       <<"first ph="<<fph<<", last ph="<<lph<<endl;
01428 
01429     if (lph==fph){
01430       sConstantBit=+", PH="+sPulseHeight+", PW="+sPulseWidth+
01431         ", PF="+sPulseFreq+" Hz, PN="+sPulses+")";
01432     }
01433     else if (lph!=fph){
01434       sConstantBit=+", PW="+sPulseWidth+
01435         ", PF="+sPulseFreq+" Hz, PN="+sPulses+")";
01436     } 
01437   }
01438   else{
01439     sConstantBit=+", PH="+sPulseHeight+", PW="+sPulseWidth+
01440       ", PF="+sPulseFreq+" Hz, PN="+sPulses+")";
01441   }
01442 
01444   //draw the adc graph
01446   TCanvas *cAdcPinGraph=new TCanvas("cAdcPinGraph","cAdcPinGraph",
01447                                     0,0,1200,600);
01448   cAdcPinGraph->SetFillColor(0);
01449   cAdcPinGraph->cd();
01450   gAdcHighPin->Draw("AP");
01451   s="Max Pin ADC vs LED (High&Low"+sConstantBit;
01452   gAdcHighPin->SetTitle(s.c_str());
01453   gAdcHighPin->GetXaxis()->SetTitle("Pulser Box * NUM PINS + LED");
01454   gAdcHighPin->GetYaxis()->SetTitle("Average ADC");
01455   gAdcHighPin->GetXaxis()->CenterTitle();
01456   gAdcHighPin->GetYaxis()->CenterTitle();
01457   gAdcHighPin->SetMarkerStyle(3);
01458   gAdcHighPin->SetMarkerColor(2);
01459   gAdcHighPin->SetMarkerSize(0.2);
01460   gAdcHighPin->SetLineColor(46);
01461 
01462   gAdcLowPin->Draw("P");
01463   gAdcLowPin->SetTitle(s.c_str());
01464   gAdcLowPin->SetMarkerStyle(3);
01465   gAdcLowPin->SetMarkerColor(3);
01466   gAdcLowPin->SetMarkerSize(0.3);
01467   gAdcLowPin->SetLineColor(30);
01468   //print graph to postscript
01469   if (sLowRunNumber==sRunNumber) s=sRunNumber+"PinAdcVsLed.ps(";
01470   else s=sLowRunNumber+"-"+sRunNumber+"PinAdcVsLed.ps(";
01471   //cAdcPinGraph->Modified();
01472   gAdcHighPin->SetMinimum(0);
01473   cAdcPinGraph->Print(s.c_str());
01474 
01475   //draw the adc high graph
01476   cAdcPinGraph->Clear();
01477   cAdcPinGraph->cd();
01478   //gAdcHighPin->SetMaximum(4000);
01479   gAdcHighPin->Draw("AP");
01480   s="Max Pin Adc vs LED (High Gain"+sConstantBit;
01481   gAdcHighPin->SetTitle(s.c_str());
01482   gAdcHighPin->GetXaxis()->SetTitle("Pulser Box * NUMLEDS + Led");
01483   gAdcHighPin->GetYaxis()->SetTitle("Average Adc");
01484   gAdcHighPin->GetXaxis()->CenterTitle();
01485   gAdcHighPin->GetYaxis()->CenterTitle();
01486   gAdcHighPin->SetMarkerStyle(3);
01487   gAdcHighPin->SetMarkerColor(2);
01488   gAdcHighPin->SetMarkerSize(0.2);
01489   gAdcHighPin->SetLineColor(46);
01490   //print graph to postscript
01491   if (sLowRunNumber==sRunNumber) s=sRunNumber+"PinAdcVsLed.ps";
01492   else s=sLowRunNumber+"-"+sRunNumber+"PinAdcVsLed.ps";
01493   gAdcHighPin->SetMinimum(0);
01494   cAdcPinGraph->Print(s.c_str());
01495 
01496   //draw the adc low graph
01497   cAdcPinGraph->Clear();
01498   cAdcPinGraph->cd();
01499   //gAdcLowPin->SetMaximum(2000);
01500   gAdcLowPin->Draw("AP");
01501   s="Max Pin Adc vs LED (Low Gain"+sConstantBit;
01502   gAdcLowPin->SetTitle(s.c_str());
01503   gAdcLowPin->GetXaxis()->SetTitle("Pulser Box * NUMLEDS + Led");
01504   gAdcLowPin->GetYaxis()->SetTitle("Average Adc");
01505   gAdcLowPin->GetXaxis()->CenterTitle();
01506   gAdcLowPin->GetYaxis()->CenterTitle();
01507   gAdcLowPin->SetMarkerStyle(3);
01508   gAdcLowPin->SetMarkerColor(3);
01509   gAdcLowPin->SetMarkerSize(0.2);
01510   gAdcLowPin->SetLineColor(30);
01511   //print graph to postscript
01512   if (sLowRunNumber==sRunNumber) s=sRunNumber+"PinAdcVsLed.ps)";
01513   else s=sLowRunNumber+"-"+sRunNumber+"PinAdcVsLed.ps)";
01514   gAdcLowPin->SetMinimum(0);
01515   cAdcPinGraph->Print(s.c_str());
01516 
01518   //draw the rms graph
01520   TCanvas *cRmsPinGraph=new TCanvas("cRmsPinGraph","cRmsPinGraph",
01521                                     0,0,1200,600);
01522   cRmsPinGraph->SetFillColor(0);
01523   cRmsPinGraph->cd();
01524   gRmsHighPin->Draw("AP");
01525   s="Pin RMS vs LED (High&Low Gain"+sConstantBit;
01526   gRmsHighPin->SetTitle(s.c_str());
01527   gRmsHighPin->GetXaxis()->SetTitle("Pulser Box * NUMLEDS + Led");
01528   gRmsHighPin->GetYaxis()->SetTitle("Average Rms");
01529   gRmsHighPin->GetXaxis()->CenterTitle();
01530   gRmsHighPin->GetYaxis()->CenterTitle();
01531   gRmsHighPin->SetMarkerStyle(3);
01532   gRmsHighPin->SetMarkerColor(2);
01533   gRmsHighPin->SetMarkerSize(0.2);
01534   gRmsHighPin->SetLineColor(46);
01535 
01536   gRmsLowPin->Draw("P");
01537   gRmsLowPin->SetTitle(s.c_str());
01538   gRmsLowPin->SetMarkerStyle(3);
01539   gRmsLowPin->SetMarkerColor(3);
01540   gRmsLowPin->SetMarkerSize(0.3);
01541   gRmsLowPin->SetLineColor(30);
01542   //print graph to postscript
01543   if (sLowRunNumber==sRunNumber) s=sRunNumber+"PinRmsVsLed.ps(";
01544   else s=sLowRunNumber+"-"+sRunNumber+"PinRmsVsLed.ps(";
01545   gRmsHighPin->SetMinimum(0);
01546   cRmsPinGraph->Print(s.c_str());
01547 
01548   //draw the rms high graph
01549   cRmsPinGraph->Clear();
01550   cRmsPinGraph->cd();
01551   gRmsHighPin->SetMaximum(100);
01552   gRmsHighPin->Draw("AP");
01553   s="Pin RMS vs LED (High Gain"+sConstantBit;
01554   gRmsHighPin->SetTitle(s.c_str());
01555   gRmsHighPin->GetXaxis()->SetTitle("Pulser Box * NUMLEDS + Led");
01556   gRmsHighPin->GetYaxis()->SetTitle("Average Rms");
01557   gRmsHighPin->GetXaxis()->CenterTitle();
01558   gRmsHighPin->GetYaxis()->CenterTitle();
01559   gRmsHighPin->SetMarkerStyle(3);
01560   gRmsHighPin->SetMarkerColor(2);
01561   gRmsHighPin->SetMarkerSize(0.2);
01562   gRmsHighPin->SetLineColor(46);
01563   //print graph to postscript
01564   if (sLowRunNumber==sRunNumber) s=sRunNumber+"PinRmsVsLed.ps";
01565   else s=sLowRunNumber+"-"+sRunNumber+"PinRmsVsLed.ps";
01566   gRmsHighPin->SetMinimum(0);
01567   cRmsPinGraph->Print(s.c_str());
01568 
01569   //draw the rms low graph
01570   cRmsPinGraph->Clear();
01571   cRmsPinGraph->cd();
01572   gRmsLowPin->SetMaximum(100);
01573   gRmsLowPin->Draw("AP");
01574   s="Pin RMS vs LED (Low Gain"+sConstantBit;
01575   gRmsLowPin->SetTitle(s.c_str());
01576   gRmsLowPin->GetXaxis()->SetTitle("Pulser Box * NUMLEDS + Led");
01577   gRmsLowPin->GetYaxis()->SetTitle("Average Rms");
01578   gRmsLowPin->GetXaxis()->CenterTitle();
01579   gRmsLowPin->GetYaxis()->CenterTitle();
01580   gRmsLowPin->SetMarkerStyle(3);
01581   gRmsLowPin->SetMarkerColor(3);
01582   gRmsLowPin->SetMarkerSize(0.2);
01583   gRmsLowPin->SetLineColor(30);
01584   //print graph to postscript
01585   if (sLowRunNumber==sRunNumber) s=sRunNumber+"PinRmsVsLed.ps)";
01586   else s=sLowRunNumber+"-"+sRunNumber+"PinRmsVsLed.ps)";
01587   gRmsLowPin->SetMinimum(0);
01588   cRmsPinGraph->Print(s.c_str());
01589 
01591   //draw the rms2 graph
01593   TCanvas *cRms2PinGraph=new TCanvas("cRms2PinGraph","cRms2PinGraph",
01594                                     0,0,1200,600);
01595   cRms2PinGraph->SetFillColor(0);
01596   cRms2PinGraph->cd();
01597   gRms2HighPin->Draw("AP");
01598   s="Pin RMS Sqd vs LED (High&Low Gain"+sConstantBit;
01599   gRms2HighPin->SetTitle(s.c_str());
01600   gRms2HighPin->GetXaxis()->SetTitle("Pulser Box * NUMLEDS + Led");
01601   gRms2HighPin->GetYaxis()->SetTitle("Average Rms2");
01602   gRms2HighPin->GetXaxis()->CenterTitle();
01603   gRms2HighPin->GetYaxis()->CenterTitle();
01604   gRms2HighPin->SetMarkerStyle(3);
01605   gRms2HighPin->SetMarkerColor(2);
01606   gRms2HighPin->SetMarkerSize(0.2);
01607   gRms2HighPin->SetLineColor(46);
01608 
01609   gRms2LowPin->Draw("P");
01610   gRms2LowPin->SetTitle(s.c_str());
01611   gRms2LowPin->SetMarkerStyle(3);
01612   gRms2LowPin->SetMarkerColor(3);
01613   gRms2LowPin->SetMarkerSize(0.3);
01614   gRms2LowPin->SetLineColor(30);
01615   //print graph to postscript
01616   if (sLowRunNumber==sRunNumber) s=sRunNumber+"PinRms2VsLed.ps(";
01617   else s=sLowRunNumber+"-"+sRunNumber+"PinRms2VsLed.ps(";
01618   cRms2PinGraph->Print(s.c_str());
01619 
01620   //draw the rms2 high graph
01621   cRms2PinGraph->Clear();
01622   cRms2PinGraph->cd();
01623   //gRms2HighPin->SetMaximum(1500);
01624   gRms2HighPin->Draw("AP");
01625   s="Pin RMS Sqd vs LED (High Gain"+sConstantBit;
01626   gRms2HighPin->SetTitle(s.c_str());
01627   gRms2HighPin->GetXaxis()->SetTitle("Pulser Box * NUMLEDS + Led");
01628   gRms2HighPin->GetYaxis()->SetTitle("Average Rms2");
01629   gRms2HighPin->GetXaxis()->CenterTitle();
01630   gRms2HighPin->GetYaxis()->CenterTitle();
01631   gRms2HighPin->SetMarkerStyle(3);
01632   gRms2HighPin->SetMarkerColor(2);
01633   gRms2HighPin->SetMarkerSize(0.2);
01634   gRms2HighPin->SetLineColor(46);
01635   //print graph to postscript
01636   if (sLowRunNumber==sRunNumber) s=sRunNumber+"PinRms2VsLed.ps";
01637   else s=sLowRunNumber+"-"+sRunNumber+"PinRms2VsLed.ps";
01638   cRms2PinGraph->Print(s.c_str());
01639 
01640   //draw the rms2 low graph
01641   cRms2PinGraph->Clear();
01642   cRms2PinGraph->cd();
01643   //gRms2LowPin->SetMaximum(300);
01644   gRms2LowPin->Draw("AP");
01645   s="Pin RMS Sqd vs LED (Low Gain"+sConstantBit;
01646   gRms2LowPin->SetTitle(s.c_str());
01647   gRms2LowPin->GetXaxis()->SetTitle("Pulser Box * NUMLEDS + Led");
01648   gRms2LowPin->GetYaxis()->SetTitle("Average Rms2");
01649   gRms2LowPin->GetXaxis()->CenterTitle();
01650   gRms2LowPin->GetYaxis()->CenterTitle();
01651   gRms2LowPin->SetMarkerStyle(3);
01652   gRms2LowPin->SetMarkerColor(3);
01653   gRms2LowPin->SetMarkerSize(0.2);
01654   gRms2LowPin->SetLineColor(30);
01655   //print graph to postscript
01656   if (sLowRunNumber==sRunNumber) s=sRunNumber+"PinRms2VsLed.ps)";
01657   else s=sLowRunNumber+"-"+sRunNumber+"PinRms2VsLed.ps)";
01658   cRms2PinGraph->Print(s.c_str());
01659 
01661   //draw the num graph
01663   TCanvas *cNumPinGraph=new TCanvas("cNumPinGraph","cNumPinGraph",
01664                                     0,0,1200,600);
01665   cNumPinGraph->SetFillColor(0);
01666   cNumPinGraph->cd();
01667   gNumHighPin->Draw("AP");
01668   gNumHighPin->SetMinimum(0);
01669   gNumHighPin->SetMaximum(pulses+200);
01670   s="Pin hits vs LED (High&Low Gain"+sConstantBit;
01671   gNumHighPin->SetTitle(s.c_str());
01672   gNumHighPin->GetXaxis()->SetTitle("Pulser Box * NUMLEDS + Led");
01673   gNumHighPin->GetYaxis()->SetTitle("Number of Pulses");
01674   gNumHighPin->GetXaxis()->CenterTitle();
01675   gNumHighPin->GetYaxis()->CenterTitle();
01676   gNumHighPin->SetMarkerStyle(3);
01677   gNumHighPin->SetMarkerColor(2);
01678   gNumHighPin->SetMarkerSize(0.2);
01679   gNumHighPin->SetLineColor(46);
01680 
01681   gNumLowPin->Draw("P");
01682   gNumLowPin->SetMinimum(0);
01683   gNumLowPin->SetMaximum(pulses+200);
01684   gNumLowPin->SetTitle(s.c_str());
01685   gNumLowPin->SetMarkerStyle(3);
01686   gNumLowPin->SetMarkerColor(3);
01687   gNumLowPin->SetMarkerSize(0.3);
01688   gNumLowPin->SetLineColor(30);
01689   //print graph to postscript
01690   if (sLowRunNumber==sRunNumber) s=sRunNumber+"PinNumVsLed.ps(";
01691   else s=sLowRunNumber+"-"+sRunNumber+"PinNumVsLed.ps(";
01692   cNumPinGraph->Print(s.c_str());
01693 
01694   //draw the num high graph
01695   cNumPinGraph->Clear();
01696   cNumPinGraph->cd();
01697   //gNumHighPin->SetMaximum(50);
01698   gNumHighPin->Draw("AP");
01699   s="Pin hits vs LED (High Gain"+sConstantBit;
01700   gNumHighPin->SetTitle(s.c_str());
01701   gNumHighPin->GetXaxis()->SetTitle("Pulser Box * NUMLEDS + Led");
01702   gNumHighPin->GetYaxis()->SetTitle("Number of Pulses");
01703   gNumHighPin->GetXaxis()->CenterTitle();
01704   gNumHighPin->GetYaxis()->CenterTitle();
01705   gNumHighPin->SetMarkerStyle(3);
01706   gNumHighPin->SetMarkerColor(2);
01707   gNumHighPin->SetMarkerSize(0.2);
01708   gNumHighPin->SetLineColor(46);
01709   //print graph to postscript
01710   if (sLowRunNumber==sRunNumber) s=sRunNumber+"PinNumVsLed.ps";
01711   else s=sLowRunNumber+"-"+sRunNumber+"PinNumVsLed.ps";
01712   cNumPinGraph->Print(s.c_str());
01713 
01714   //draw the num low graph
01715   cNumPinGraph->Clear();
01716   cNumPinGraph->cd();
01717   //gNumLowPin->SetMaximum(50);
01718   gNumLowPin->Draw("AP");
01719   s="Pin hits vs LED (Low Gain"+sConstantBit;
01720   gNumLowPin->SetTitle(s.c_str());
01721   gNumLowPin->GetXaxis()->SetTitle("Pulser Box * NUMLEDS + Led");
01722   gNumLowPin->GetYaxis()->SetTitle("Number of Pulses");
01723   gNumLowPin->GetXaxis()->CenterTitle();
01724   gNumLowPin->GetYaxis()->CenterTitle();
01725   gNumLowPin->SetMarkerStyle(3);
01726   gNumLowPin->SetMarkerColor(3);
01727   gNumLowPin->SetMarkerSize(0.2);
01728   gNumLowPin->SetLineColor(30);
01729   //print graph to postscript
01730   if (sLowRunNumber==sRunNumber) s=sRunNumber+"PinNumVsLed.ps)";
01731   else s=sLowRunNumber+"-"+sRunNumber+"PinNumVsLed.ps)";
01732   cNumPinGraph->Print(s.c_str());
01733 
01734 
01736   //draw the Res graph
01738   TCanvas *cResPinGraph=new TCanvas("cResPinGraph","cResPinGraph",
01739                                     0,0,1200,600);
01740   cResPinGraph->SetFillColor(0);
01741   cResPinGraph->cd();
01742   gResHighPin->Draw("AP");
01743   gResHighPin->SetMinimum(0);
01744   //gResHighPin->SetMaximum(pulses+200);
01745   s="Pin Resolution vs LED (High&Low Gain"+sConstantBit;
01746   gResHighPin->SetTitle(s.c_str());
01747   gResHighPin->GetXaxis()->SetTitle("Pulser Box * NUMLEDS + Led");
01748   gResHighPin->GetYaxis()->SetTitle("Resolution (rms/mean)");
01749   gResHighPin->GetXaxis()->CenterTitle();
01750   gResHighPin->GetYaxis()->CenterTitle();
01751   gResHighPin->SetMarkerStyle(3);
01752   gResHighPin->SetMarkerColor(2);
01753   gResHighPin->SetMarkerSize(0.2);
01754   gResHighPin->SetLineColor(46);
01755 
01756   gResLowPin->Draw("P");
01757   gResLowPin->SetMinimum(0);
01758   gResLowPin->SetMaximum(pulses+200);
01759   gResLowPin->SetTitle(s.c_str());
01760   gResLowPin->SetMarkerStyle(3);
01761   gResLowPin->SetMarkerColor(3);
01762   gResLowPin->SetMarkerSize(0.3);
01763   gResLowPin->SetLineColor(30);
01764   //print graph to postscript
01765   if (sLowRunNumber==sRunNumber) s=sRunNumber+"PinResVsLed.ps(";
01766   else s=sLowRunNumber+"-"+sRunNumber+"PinResVsLed.ps(";
01767   cResPinGraph->Print(s.c_str());
01768 
01769   //draw the Res high graph
01770   cResPinGraph->Clear();
01771   cResPinGraph->cd();
01772   gResHighPin->SetMaximum(0.2);
01773   gResHighPin->Draw("AP");
01774   s="Pin Resolution vs LED (High Gain"+sConstantBit;
01775   gResHighPin->SetTitle(s.c_str());
01776   gResHighPin->GetXaxis()->SetTitle("Pulser Box * NUMLEDS + Led");
01777   gResHighPin->GetYaxis()->SetTitle("Resolution (rms/mean)");
01778   gResHighPin->GetXaxis()->CenterTitle();
01779   gResHighPin->GetYaxis()->CenterTitle();
01780   gResHighPin->SetMarkerStyle(3);
01781   gResHighPin->SetMarkerColor(2);
01782   gResHighPin->SetMarkerSize(0.2);
01783   gResHighPin->SetLineColor(46);
01784   //print graph to postscript
01785   if (sLowRunNumber==sRunNumber) s=sRunNumber+"PinResVsLed.ps";
01786   else s=sLowRunNumber+"-"+sRunNumber+"PinResVsLed.ps";
01787   cResPinGraph->Print(s.c_str());
01788 
01789   //draw the Res low graph
01790   cResPinGraph->Clear();
01791   cResPinGraph->cd();
01792   gResLowPin->SetMaximum(0.2);
01793   gResLowPin->Draw("AP");
01794   s="Pin Resolution vs LED (Low Gain"+sConstantBit;
01795   gResLowPin->SetTitle(s.c_str());
01796   gResLowPin->GetXaxis()->SetTitle("Pulser Box * NUMLEDS + Led");
01797   gResLowPin->GetYaxis()->SetTitle("Resolution (rms/mean)");
01798   gResLowPin->GetXaxis()->CenterTitle();
01799   gResLowPin->GetYaxis()->CenterTitle();
01800   gResLowPin->SetMarkerStyle(3);
01801   gResLowPin->SetMarkerColor(3);
01802   gResLowPin->SetMarkerSize(0.2);
01803   gResLowPin->SetLineColor(30);
01804   //print graph to postscript
01805   if (sLowRunNumber==sRunNumber) s=sRunNumber+"PinResVsLed.ps)";
01806   else s=sLowRunNumber+"-"+sRunNumber+"PinResVsLed.ps)";
01807   cResPinGraph->Print(s.c_str());
01808 
01809   MSG("LIAnalysis",Msg::kInfo) 
01810     <<" ** Finished the AdcVsPin method ** "<<endl;
01811 }

void LIAnalysis::AdcVsPixel Int_t  plane,
Int_t  AshtrayMin = -1,
Int_t  AshtrayMax = -1,
Int_t  led = -1
 

Definition at line 5446 of file LIAnalysis.cxx.

References ashtray, chain, channel, chip, correlatedHit, crate, detectorType, farLed, farPulserBox, Form(), InitialiseLoopVariables(), led, lookup, mean, MSG, nearLed, LILookup::NearOrFar(), nearPulserBox, numEntries, pixel, plane, LILookup::Plane2CrateEast(), LILookup::Plane2CrateWest(), pulserBox, readoutType, rms, runNumber, s, SetLoopVariables(), and strip.

05448 {
05449   MSG("LIAnalysis",Msg::kInfo)
05450     <<endl<<" ** Running the AdcVsPixel method... ** "<<endl;
05451 
05452   //get first event
05453   chain->GetEvent(0);
05454 
05455   Int_t cr=lookup.Plane2CrateEast(pl,detectorType);
05456   Int_t crOpp=lookup.Plane2CrateWest(pl,detectorType);
05457   MSG("LIAnalysis",Msg::kInfo) 
05458     <<"Plane "<<pl<<", crates "<<cr<<" and "<<crOpp<<" selected"<<endl;
05459   if (ashtrayMax!=-1){
05460     MSG("LIAnalysis",Msg::kInfo) 
05461       <<"Only selecting correlated hits in ashtrays "<<ashtrayMin
05462       <<"-"<<ashtrayMax<<" inclusive"<<endl;
05463   }
05464   else{
05465     MSG("LIAnalysis",Msg::kInfo) 
05466       <<"Not using ashtray information"<<endl;
05467   }
05468 
05469   string sPlane=Form("%d",pl);
05470   string sAshtrayMin=Form("%d",ashtrayMin);
05471   string sAshtrayMax=Form("%d",ashtrayMax);
05472   string sConstantBit="";
05473   if (ashtrayMax!=-1) sConstantBit=", A "+sAshtrayMin+"-"+
05474                         sAshtrayMax+")";
05475   else sConstantBit=")";
05476 
05477   //variable to scale all histos to have the same colour
05478   Int_t maxColour=400;
05479 
05480   TH2F ***hAdcVsPixel=0;
05481   hAdcVsPixel=new TH2F**[NUMCRATES];
05482   for (Int_t i=0;i<NUMCRATES;i++){
05483     hAdcVsPixel[i]=new TH2F*[NUMCHIPS];
05484     for (Int_t j=0;j<NUMCHIPS;j++){
05485       string sChip=Form("%d",j);
05486       string sCrate=Form("%d",i);
05487       s="Adc Vs Pixel (Chip "+sChip+", Pl "+sPlane+", Cr "+sCrate+
05488         sConstantBit;
05489       (hAdcVsPixel[i])[j]=new TH2F(s.c_str(),s.c_str(),
05490                                    17,0,17,15000,0,15000);
05491       (hAdcVsPixel[i])[j]->GetXaxis()->SetTitle("Pixel");
05492       (hAdcVsPixel[i])[j]->GetXaxis()->CenterTitle();
05493       (hAdcVsPixel[i])[j]->GetYaxis()->SetTitle("Adc");
05494       (hAdcVsPixel[i])[j]->GetYaxis()->CenterTitle();
05495       (hAdcVsPixel[i])[j]->SetFillColor(0);
05496       (hAdcVsPixel[i])[j]->SetBit(TH1::kCanRebin);
05497       (hAdcVsPixel[i])[j]->SetMaximum(maxColour);
05498     }
05499   }
05500 
05504   
05505   this->InitialiseLoopVariables();  
05506   
05507   for(Int_t entry=0;entry<numEvents;entry++){
05508     
05509     this->SetLoopVariables(entry,0);
05510     
05511     //avoid divide by zero errors and skip irrelevant data
05512     if (rms==0 || mean==0 || numEntries==0) continue;
05513     //only look at scintillator strips
05514     if (readoutType!=ReadoutType::kScintStrip) continue;
05515 
05516     if (plane==pl && (crate==cr || crate==crOpp)){
05517       //Int_t ashtray=lookup.Led2Ashtray(led,plane);
05518 
05519       if (ashtray>=ashtrayMin && ashtray<=ashtrayMax){
05520         if (correlatedHit==1){
05521           //select the appropriate detectorType
05522           if (detectorType==Detector::kFar){
05523             if (pulserBox==nearPulserBox){
05524               (hAdcVsPixel[crate])[chip]->Fill(pixel,mean,maxColour);
05525             }
05526             else if (pulserBox==farPulserBox){
05527               (hAdcVsPixel[crate][chip])->Fill(pixel,mean,340);
05528             }
05529           }
05530           //CalDet
05531           else if (detectorType==Detector::kCalDet){
05532             if (led==l){
05533               if (lookup.NearOrFar(crate,pulserBox,nearPulserBox,
05534                                    farPulserBox,led,detectorType,
05535                                    plane,runNumber)==
05536                   LILookup::kNearSide){//near
05537                 (hAdcVsPixel[crate])[chip]->Fill(pixel,mean,400);
05538               }
05539               else if (lookup.NearOrFar(crate,pulserBox,nearPulserBox,
05540                                         farPulserBox,led,detectorType,
05541                                         plane,runNumber)==
05542                        LILookup::kFarSide){//far
05543                 (hAdcVsPixel[crate][chip])->Fill(pixel,mean,340);
05544               }
05545               else {
05546                 MSG("LIAnalysis",Msg::kInfo) 
05547                   <<"Missing stuff: cr="<<crate
05548                   <<", pb="<<pulserBox
05549                   <<", led="<<led<<", nL="<<nearLed<<", fL="<<farLed
05550                   <<", st="<<strip<<", chp="<<chip<<", pix="<<pixel
05551                   <<", ch="<<channel<<", m="<<mean <<endl;
05552               }
05553             }
05554           }
05555           //catch exceptions to detector type
05556           else {
05557             MSG("LIAnalysis",Msg::kWarning)
05558               <<"Detector Type = "<<detectorType<<" not supported yet"
05559               <<endl;
05560           }
05561 
05562           MSG("LIAnalysis",Msg::kInfo) 
05563             <<"correlated hit: cr="<<crate
05564             <<", pb="<<pulserBox<<", led="<<led
05565             <<", ash="<<ashtray<<", str="<<strip
05566             <<", chp="<<chip<<", pix="<<pixel<<", ch="<<channel
05567             <<", m="<<mean<<endl;
05568         }
05569         else{
05570           //crosstalk
05571           //select the appropriate detectorType
05572           if (detectorType==Detector::kFar){
05573             if (pulserBox==nearPulserBox){
05574               (hAdcVsPixel[crate])[chip]->Fill(pixel,mean,1);
05575             }
05576             else if (pulserBox==farPulserBox){
05577               (hAdcVsPixel[crate])[chip]->Fill(pixel,mean,130);
05578             }
05579           }
05580           //CalDet
05581           else if (detectorType==Detector::kCalDet){
05582             if (led==l){
05583               if (lookup.NearOrFar(crate,pulserBox,nearPulserBox,
05584                                    farPulserBox,led,detectorType,
05585                                    plane,runNumber)==
05586                   LILookup::kNearSide){//near
05587                 (hAdcVsPixel[crate])[chip]->Fill(pixel,mean,1);
05588               }
05589               else if (lookup.NearOrFar(crate,pulserBox,nearPulserBox,
05590                                         farPulserBox,led,detectorType,
05591                                         plane,runNumber)==
05592                        LILookup::kFarSide){//far
05593                 (hAdcVsPixel[crate])[chip]->Fill(pixel,mean,130);
05594               }
05595               else {
05596                 MSG("LIAnalysis",Msg::kInfo) 
05597                   <<"Missing stuff: cr="<<crate
05598                   <<", pb="<<pulserBox
05599                   <<", led="<<led
05600                   <<", nL="<<nearLed
05601                   <<", fL="<<farLed
05602                   <<", st="<<strip
05603                   <<", chp="<<chip      
05604                   <<", pix="<<pixel
05605                   <<", ch="<<channel<<", m="<<mean 
05606                   <<endl;
05607               }
05608             }
05609           }
05610           else {
05611             MSG("LIAnalysis",Msg::kWarning)
05612               <<"Detector Type = "<<detectorType<<" not supported yet"
05613               <<endl;
05614           }
05615           
05616           MSG("LIAnalysis",Msg::kInfo) 
05617             <<"xtalk: cr="<<crate
05618             <<", pb="<<pulserBox
05619             <<", led="<<led
05620             <<", ash="<<ashtray
05621             <<", str="<<strip
05622             <<", chp="<<chip    
05623             <<", pix="<<pixel
05624             <<", ch="<<channel<<", m="<<mean 
05625             <<endl;
05626         }
05627       }
05628     }
05629   }//end of for
05630    
05634 
05635   MSG("LIAnalysis",Msg::kInfo)<<"Finished main loop"<<endl;
05636 
05637   //get rid of the stats info
05638   gStyle->SetOptStat(0);
05639 
05640   //HAS TO BE on the heap to stay on the canvas!!!!!!!!!!!!!
05641   TPaveText textLabel=TPaveText(0.6,0.1,0.8,0.6);
05642   textLabel.SetBorderSize(0);
05643   textLabel.SetTextSize(0.8);
05644   textLabel.SetTextColor(1);
05645   textLabel.SetTextFont(2);
05646   textLabel.SetFillColor(2);
05647 
05648   TText *label=new TText(0.15,0.9,"COLOUR KEY:");
05649   TText *label1=new TText
05650     (0.15,0.81,"  Dark red   = Expected hit: Light from near side");
05651   TText *label2=new TText
05652     (0.15,0.71,"  Orange     = Expected hit: Light from far side");
05653   TText *label3=new TText
05654     (0.15,0.55,"  Dark blue  = Xtalk: Light from near side");
05655   TText *label4=new TText
05656     (0.15,0.45,"  Light blue = Xtalk: Light from far side");
05657 
05658   TCanvas *cAdcVsPixel=new TCanvas("cAdcVsPixel","Adc Vs Pixel",
05659                                    0,0,1100,850);
05660   cAdcVsPixel->SetFillColor(0);
05661   cAdcVsPixel->Divide(3,3);
05662   for (Int_t i=0;i<NUMCHIPS;i++){
05663     cAdcVsPixel->cd(i+3+1);
05664     (hAdcVsPixel[cr])[i]->Draw("colz");
05665   }
05666 
05667   //  TCanvas *cAdcVsPixelOpp=new TCanvas
05668   //("cAdcVsPixelOpp","Adc Vs PixelOpp",0,0,1200,700);
05669   //cAdcVsPixelOpp->SetFillColor(0);
05670   //cAdcVsPixelOpp->Divide(2,2);
05671   for (Int_t i=0;i<NUMCHIPS;i++){
05672     cAdcVsPixel->cd(i+6+1);
05673     (hAdcVsPixel[crOpp])[i]->Draw("colz");
05674   }
05675   //cAdcVsPixelOpp->cd(4);
05676   //label->Draw();
05677   //label1->Draw();
05678   //label2->Draw();
05679   //label3->Draw();
05680   //label4->Draw();
05681   //scr=Form("%d",crOpp);
05682   //s="adcVsPixPla"+spl+"Cr"+scr+"A"+sAshMin+"-"+sAshMax+".eps";
05683   //cAdcVsPixelOpp->Print(s.c_str());
05684   //cAdcVsPixelOpp->Update();
05685 
05686   cAdcVsPixel->cd(2);
05687   label->Draw();
05688   label1->Draw();
05689   label2->Draw();
05690   label3->Draw();
05691   label4->Draw();
05692   string scr=Form("%d",cr);
05693   string sCrOpp=Form("%d",crOpp);
05694   string spl=Form("%d",pl);
05695   string sAshMin=Form("%d",ashtrayMin);
05696   string sAshMax=Form("%d",ashtrayMax);
05697   if (ashtrayMax!=-1) sConstantBit="A "+sAshtrayMin+"-"+sAshtrayMax;
05698   else sConstantBit="";
05699   s="adcVsPixPla"+spl+"Cr"+scr+"-"+sCrOpp+sConstantBit+".eps";
05700   cAdcVsPixel->Print(s.c_str());
05701 
05702   MSG("LIAnalysis",Msg::kInfo)
05703     <<" ** Finished the AdcVsPixel method ** "<<endl;
05704 }

void LIAnalysis::AnalyseChain  )  [private]
 

Definition at line 331 of file LIAnalysis.cxx.

References calibPoint, InitialiseLoopVariables(), lastLed, led, liEvent, liRunNum, maxCalibPoint, maxLedNum, maxPbNum, MSG, numCalibPoints, numLeds, numLiEvents, numLiEventsL, numLiEventsP, numLiRuns, pulseHeight, pulserBox, pulseWidth, and SetLoopVariables().

Referenced by LIAnalysis().

00332 {
00333   this->InitialiseLoopVariables();  
00334 
00335   Int_t eventsPerLedCounter=0;
00336   Int_t lastLed2=-1;
00337   Int_t lastPulserBox2=-1;
00338   Int_t lastCalibPoint2=-1;
00339   Int_t numLiEventsC[1000];
00340   for (Int_t i=0;i<1000;i++){
00341     numLiEventsC[i]=0;
00342   }
00343 
00344   for(Int_t entry=0;entry<numEvents;entry++){
00345     
00346     this->SetLoopVariables(entry,0);
00347         
00348     if (led>maxLedNum){
00349       maxLedNum=led;
00350     }
00351     if (pulserBox>maxPbNum){
00352       maxPbNum=pulserBox;
00353     }
00354     if (calibPoint>maxCalibPoint){
00355       maxCalibPoint=calibPoint;
00356     }
00357 
00358     eventsPerLedCounter++;
00359         
00360     if (led!=lastLed2){
00361       //if an led is flashed only a few times print
00362       if (eventsPerLedCounter<100){
00363         MSG("LIAnalysis",Msg::kInfo) 
00364           <<"For LED="<<lastLed 
00365           <<", numEntries="<<eventsPerLedCounter
00366           <<endl;
00367       }
00368       eventsPerLedCounter=0;      
00369       numLiEventsL[led-1]++;
00370     }
00371 
00372     if (pulserBox!=lastPulserBox2){
00373       numLiEventsP[pulserBox]++;
00374       MSG("LIAnalysis",Msg::kInfo)<<"pulserBox="<<pulserBox<<endl;
00375     }
00376     if (calibPoint!=lastCalibPoint2){   
00377       numLiEventsC[calibPoint-1]++;
00378       MSG("LIAnalysis",Msg::kDebug) 
00379         <<"calibPoint="<<calibPoint 
00380         <<", pulseHeight="<<pulseHeight
00381         <<", pulseWidth="<<pulseWidth
00382         <<", led="<<led
00383         <<endl;
00384     }
00385     lastLed2=led;
00386     lastPulserBox2=pulserBox;
00387     lastCalibPoint2=calibPoint;
00388   }
00389 
00390   //set important variables to determine sizes of 
00391   //arrays of histograms etc
00392   numLeds=maxLedNum;
00393   numLiRuns=liRunNum+1;
00394   numLiEvents=liEvent+1;
00395   numCalibPoints=maxCalibPoint;
00396       
00397   MSG("LIAnalysis",Msg::kInfo) 
00398     <<endl
00399     <<" ** File Summary Information ** "<<endl
00400     <<"maxLedNum="<<maxLedNum<<endl
00401     <<"maxPbNum="<<maxPbNum<<endl
00402     <<"maxCalibPoint="<<maxCalibPoint<<endl
00403     <<"numLiRuns="<<numLiRuns
00404     <<", numLiRuns*maxLedNum="<<numLiRuns*maxLedNum<<endl
00405     <<"numLiEvents="<<numLiEvents<<endl;
00406 
00407   MSG("LIAnalysis",Msg::kInfo) 
00408     <<"Number of times each led was selected (any pulser box):" 
00409     <<endl;
00410   for (Int_t i=0;i<NUMLEDS;i++){
00411     MSG("LIAnalysis",Msg::kInfo) 
00412       <<"  LED "<<i+1<<" = "<<numLiEventsL[i] 
00413       <<endl;
00414   }
00415 
00416   MSG("LIAnalysis",Msg::kInfo) 
00417     <<"Number of times each pulser box was selected:"<<endl;
00418   for (Int_t i=0;i<NUMPULSERBOXES;i++){
00419     MSG("LIAnalysis",Msg::kInfo) 
00420       <<"  Pulser Box "<<i<<" = "<<numLiEventsP[i]
00421       <<endl;
00422   }
00423   
00424   MSG("LIAnalysis",Msg::kInfo) 
00425     <<"Number of times each calibration point was selected:" 
00426     <<endl;
00427   for (Int_t i=0;i<maxCalibPoint;i++){
00428     MSG("LIAnalysis",Msg::kInfo) 
00429       <<"  Calibration Point "<<i+1<<" = "<<numLiEventsC[i]
00430       <<endl;
00431   }
00432   MSG("LIAnalysis",Msg::kInfo) 
00433     <<" ** End of File Summary Information ** "<<endl;
00434 }

void LIAnalysis::AppendVect std::vector< Double_t > &  trunk,
std::vector< Double_t >  appendix
[private]
 

Definition at line 559 of file LIAnalysis.cxx.

References MSG.

Referenced by PmtGain().

00561 {
00562   MSG("LIAnalysis",Msg::kDebug) 
00563     <<" ** Running AppendVect method... **"<<endl;
00564   
00565   //should this work?
00566   //trunk.insert(trunk.end(),appendix.begin(),appendix.end());
00567 
00568   for (UInt_t i=0;i<appendix.size();i++){
00569     trunk.push_back(appendix[i]);
00570   }
00571 
00572   MSG("LIAnalysis",Msg::kDebug) 
00573     <<" ** Finished AppendVect method **"<<endl;
00574 }

void LIAnalysis::AshtrayVsPlane Int_t  nearPb,
Int_t  farPb
 

Definition at line 4915 of file LIAnalysis.cxx.

References ashtray, chain, correlatedHit, crate, detectorType, farPulserBox, Form(), histname, InitialiseLoopVariables(), lookup, mean, MSG, nearLed, nearPulserBox, numEntries, pixel, plane, pow(), pulserBox, readoutType, rms, runNumber, s, SetLoopVariables(), and LILookup::SetPbPlanes().

04916 {
04917   //get rid of the stats info
04918   gStyle->SetOptStat(0);
04919 
04920   MSG("LIAnalysis",Msg::kInfo)
04921     <<endl<<" ** Running the AshtrayVsPlane method... **"<<endl;
04922   
04923   chain->GetEvent(0);
04924 
04925   Int_t* planeMax=new Int_t[NUMPULSERBOXES];
04926   Int_t* planeMin=new Int_t[NUMPULSERBOXES];
04927   lookup.SetPbPlanes(planeMin,planeMax,detectorType);
04928 
04929   TH2F *hAshtrayVsPlaneLedB=new TH2F(" "," ",
04930                                    LASTSCINTPLANE-FIRSTSCINTPLANE+2,
04931                                    FIRSTSCINTPLANE,LASTSCINTPLANE+1,
04932                                    22,0,22);
04933   TH2F **hAshtrayVsPlaneLed=0;
04934   hAshtrayVsPlaneLed= new TH2F*[NUMPULSERBOXES];
04935   for (Int_t i=0;i<NUMPULSERBOXES;i++){
04936     sprintf(histname,"Led (Pulser Box %i)",i);
04937     hAshtrayVsPlaneLed[i]=new TH2F
04938       (histname,histname,
04939        planeMax[i]-planeMin[i],planeMin[i],planeMax[i]
04940        ,22,0,22);
04941     hAshtrayVsPlaneLed[i]->GetXaxis()->SetTitle("Plane");
04942     hAshtrayVsPlaneLed[i]->GetXaxis()->CenterTitle();
04943     hAshtrayVsPlaneLed[i]->GetYaxis()->SetTitle("Num Entries");
04944     hAshtrayVsPlaneLed[i]->GetYaxis()->CenterTitle();
04945     hAshtrayVsPlaneLed[i]->SetFillColor(0);
04946     hAshtrayVsPlaneLed[i]->SetBit(TH1::kCanRebin);
04947   }
04948 
04949   TH2F **hAshtrayVsPlaneMean=0;
04950   hAshtrayVsPlaneMean= new TH2F*[NUMPULSERBOXES];
04951   for (Int_t i=0;i<NUMPULSERBOXES;i++){
04952     sprintf(histname,"ADC Value (Near Side, Pulser Box %i)",i);
04953     hAshtrayVsPlaneMean[i]=new TH2F
04954       (histname,histname,
04955        planeMax[i]-planeMin[i],planeMin[i],planeMax[i]
04956        ,22,0,22);
04957     hAshtrayVsPlaneMean[i]->GetXaxis()->SetTitle("Plane");
04958     hAshtrayVsPlaneMean[i]->GetXaxis()->CenterTitle();
04959     hAshtrayVsPlaneMean[i]->GetYaxis()->SetTitle("Ashtray");
04960     hAshtrayVsPlaneMean[i]->GetYaxis()->CenterTitle();
04961     hAshtrayVsPlaneMean[i]->SetFillColor(0);
04962     hAshtrayVsPlaneMean[i]->SetBit(TH1::kCanRebin);
04963   }
04964 
04965   TH2F **hAshtrayVsPlaneMeanF=0;
04966   hAshtrayVsPlaneMeanF= new TH2F*[NUMPULSERBOXES];
04967   for (Int_t i=0;i<NUMPULSERBOXES;i++){
04968     sprintf(histname,"ADC Value (Far Side, Pulser Box %i)",i);
04969     hAshtrayVsPlaneMeanF[i]=new TH2F
04970       (histname,histname,
04971        planeMax[i]-planeMin[i],planeMin[i],planeMax[i]
04972        ,22,0,22);
04973     hAshtrayVsPlaneMeanF[i]->GetXaxis()->SetTitle("Plane");
04974     hAshtrayVsPlaneMeanF[i]->GetXaxis()->CenterTitle();
04975     hAshtrayVsPlaneMeanF[i]->GetYaxis()->SetTitle("Ashtray");
04976     hAshtrayVsPlaneMeanF[i]->GetYaxis()->CenterTitle();
04977     hAshtrayVsPlaneMeanF[i]->SetFillColor(0);
04978     hAshtrayVsPlaneMeanF[i]->SetBit(TH1::kCanRebin);
04979   }
04980 
04981   TH2F **hAshtrayVsPlaneNum=0;
04982   hAshtrayVsPlaneNum= new TH2F*[NUMPULSERBOXES];
04983   for (Int_t i=0;i<NUMPULSERBOXES;i++){
04984     sprintf(histname,"Num (Pulser Box %i)",i);
04985     hAshtrayVsPlaneNum[i]=new TH2F
04986       (histname,histname,
04987        planeMax[i]-planeMin[i],planeMin[i],planeMax[i]
04988        ,22,0,22);
04989     hAshtrayVsPlaneNum[i]->GetXaxis()->SetTitle("Plane");
04990     hAshtrayVsPlaneNum[i]->GetXaxis()->CenterTitle();
04991     hAshtrayVsPlaneNum[i]->GetYaxis()->SetTitle("Ashtray");
04992     hAshtrayVsPlaneNum[i]->GetYaxis()->CenterTitle();
04993     hAshtrayVsPlaneNum[i]->SetFillColor(0);
04994     hAshtrayVsPlaneNum[i]->SetBit(TH1::kCanRebin);
04995   }
04996 
04997   TH2F **hAshtrayVsPlanePix=0;
04998   hAshtrayVsPlanePix= new TH2F*[NUMPULSERBOXES];
04999   for (Int_t i=0;i<NUMPULSERBOXES;i++){
05000     sprintf(histname,"Pix (Pulser Box %i)",i);
05001     hAshtrayVsPlanePix[i]=new TH2F
05002       (histname,histname,
05003        planeMax[i]-planeMin[i],planeMin[i],planeMax[i]
05004        ,22,0,22);
05005     hAshtrayVsPlanePix[i]->GetXaxis()->SetTitle("Plane");
05006     hAshtrayVsPlanePix[i]->GetXaxis()->CenterTitle();
05007     hAshtrayVsPlanePix[i]->GetYaxis()->SetTitle("Ashtray");
05008     hAshtrayVsPlanePix[i]->GetYaxis()->CenterTitle();
05009     hAshtrayVsPlanePix[i]->SetFillColor(0);
05010     hAshtrayVsPlanePix[i]->SetBit(TH1::kCanRebin);
05011   }
05012 
05013   TH2F **hAshtrayVsPlanePixF=0;
05014   hAshtrayVsPlanePixF= new TH2F*[NUMPULSERBOXES];
05015   for (Int_t i=0;i<NUMPULSERBOXES;i++){
05016     sprintf(histname,"PixF (Pulser Box %i)",i);
05017     hAshtrayVsPlanePixF[i]=new TH2F
05018       (histname,histname,
05019        planeMax[i]-planeMin[i],planeMin[i],planeMax[i]
05020        ,22,0,22);
05021     hAshtrayVsPlanePixF[i]->GetXaxis()->SetTitle("Plane");
05022     hAshtrayVsPlanePixF[i]->GetXaxis()->CenterTitle();
05023     hAshtrayVsPlanePixF[i]->GetYaxis()->SetTitle("Ashtray");
05024     hAshtrayVsPlanePixF[i]->GetYaxis()->CenterTitle();
05025     hAshtrayVsPlanePixF[i]->SetFillColor(0);
05026     hAshtrayVsPlanePixF[i]->SetBit(TH1::kCanRebin);
05027   }
05028 
05029   TH2F **hAshtrayVsPlaneEnt=0;
05030   hAshtrayVsPlaneEnt= new TH2F*[NUMPULSERBOXES];
05031   for (Int_t i=0;i<NUMPULSERBOXES;i++){
05032     sprintf(histname,"Ent (Pulser Box %i, Near)",i);
05033     hAshtrayVsPlaneEnt[i]=new TH2F
05034       (histname,histname,
05035        planeMax[i]-planeMin[i],planeMin[i],planeMax[i]
05036        ,22,0,22);
05037     hAshtrayVsPlaneEnt[i]->GetXaxis()->SetTitle("Plane");
05038     hAshtrayVsPlaneEnt[i]->GetXaxis()->CenterTitle();
05039     hAshtrayVsPlaneEnt[i]->GetYaxis()->SetTitle("Ashtray");
05040     hAshtrayVsPlaneEnt[i]->GetYaxis()->CenterTitle();
05041     hAshtrayVsPlaneEnt[i]->SetFillColor(0);
05042     hAshtrayVsPlaneEnt[i]->SetBit(TH1::kCanRebin);
05043   }
05044 
05045   TH2F **hAshtrayVsPlaneEntF=0;
05046   hAshtrayVsPlaneEntF= new TH2F*[NUMPULSERBOXES];
05047   for (Int_t i=0;i<NUMPULSERBOXES;i++){
05048     sprintf(histname,"EntF (Pulser Box %i, Far)",i);
05049     hAshtrayVsPlaneEntF[i]=new TH2F
05050       (histname,histname,
05051        planeMax[i]-planeMin[i],planeMin[i],planeMax[i]
05052        ,22,0,22);
05053     hAshtrayVsPlaneEntF[i]->GetXaxis()->SetTitle("Plane");
05054     hAshtrayVsPlaneEntF[i]->GetXaxis()->CenterTitle();
05055     hAshtrayVsPlaneEntF[i]->GetYaxis()->SetTitle("Ashtray");
05056     hAshtrayVsPlaneEntF[i]->GetYaxis()->CenterTitle();
05057     hAshtrayVsPlaneEntF[i]->SetFillColor(0);
05058     hAshtrayVsPlaneEntF[i]->SetBit(TH1::kCanRebin);
05059   }
05060 
05064 
05065   this->InitialiseLoopVariables();  
05066   
05067   for(Int_t entry=0;entry<numEvents;entry++){
05068     
05069     this->SetLoopVariables(entry,0);
05070     
05071     //avoid divide by zero errors and skip irrelevant data
05072     if (rms==0. || mean==0. || numEntries==0) continue;
05073     //only look at scintillator strips
05074     if (readoutType!=ReadoutType::kScintStrip) continue;
05075 
05076     if (pulserBox>=FIRSTPULSERBOX && pulserBox<NUMPULSERBOXES &&
05077         correlatedHit!=1 && ashtray!=-1 && pulserBox!=crate &&
05078         ashtray<=NUMASHTRAYS && ashtray>=FIRSTASHTRAY && 
05079         plane>=FIRSTSCINTPLANE && plane<=LASTSCINTPLANE &&
05080         pulserBox==farPulserBox
05081         ){
05082       hAshtrayVsPlaneMeanF[pulserBox]->Fill(plane,ashtray,mean);
05083       hAshtrayVsPlaneEntF[pulserBox]->Fill(plane,ashtray,1);
05084       hAshtrayVsPlanePixF[pulserBox]->Fill(plane,ashtray,pixel+1);
05085     }
05086 
05087     if (pulserBox>=FIRSTPULSERBOX && pulserBox<NUMPULSERBOXES && 
05088         correlatedHit!=1  && ashtray!=-1 && pulserBox==crate  &&
05089         ashtray<=NUMASHTRAYS && ashtray>=FIRSTASHTRAY && 
05090         plane>=FIRSTSCINTPLANE && plane<=LASTSCINTPLANE &&
05091         pulserBox==nearPulserBox
05092         ){
05093       hAshtrayVsPlaneLed[pulserBox]->Fill(plane,ashtray,nearLed);
05094       hAshtrayVsPlaneMean[pulserBox]->Fill(plane,ashtray,mean);
05095       hAshtrayVsPlaneNum[pulserBox]->Fill(plane,ashtray,numEntries);
05096       hAshtrayVsPlanePix[pulserBox]->Fill(plane,ashtray,pixel+1);
05097       hAshtrayVsPlaneEnt[pulserBox]->Fill(plane,ashtray,1);
05098 
05099       MSG("LIAnalysis",Msg::kVerbose) 
05100         <<"mean="<<mean 
05101         <<", rms="<<rms 
05102         <<", npe="<<pow(mean/rms,2)
05103         <<", gain="<<mean/pow(mean/rms,2)
05104         <<endl;
05105     }
05106   }//end of for
05107    
05111   
05112   MSG("LIAnalysis",Msg::kInfo)<<"Finished main loop"<<endl;
05113 
05114   string sRunNumber=Form("%d",runNumber);
05115 
05116   Int_t maxMean=0;
05117   Int_t maxMeanF=0;
05118   //weight histograms according to number of entries
05119   for (Int_t pb=FIRSTPULSERBOX;pb<=LASTPULSERBOX;pb++){
05120     for (Int_t pl=FIRSTSCINTPLANE;pl<=LASTSCINTPLANE;pl++){
05121       for (Int_t ash=0;ash<=NUMASHTRAYS+2;ash++){
05122 
05123         //take out known miscablings
05124         if ((ash==16 || ash==17) && pl==331) continue;
05125         if ((ash==7 || ash==8) && pl==129) continue;
05126         if ((ash==9 || ash==10) && pl==130) continue;
05127 
05128         if (hAshtrayVsPlaneEnt[pb]->GetBinContent(pl,ash)>0){
05129           hAshtrayVsPlaneMean[pb]->SetBinContent
05130             (pl,ash,hAshtrayVsPlaneMean[pb]->GetBinContent(pl,ash)/
05131              hAshtrayVsPlaneEnt[pb]->GetBinContent(pl,ash));
05132           if (hAshtrayVsPlaneMean[pb]->GetBinContent(pl,ash)>maxMean){
05133             maxMean=static_cast<Int_t>
05134               (hAshtrayVsPlaneMean[pb]->GetBinContent(pl,ash));
05135           }
05136         }
05137         if (hAshtrayVsPlaneEntF[pb]->GetBinContent(pl,ash)>0){
05138           hAshtrayVsPlaneMeanF[pb]->SetBinContent
05139             (pl,ash,hAshtrayVsPlaneMeanF[pb]->GetBinContent(pl,ash)/
05140              hAshtrayVsPlaneEntF[pb]->GetBinContent(pl,ash));
05141           if (hAshtrayVsPlaneMeanF[pb]->GetBinContent(pl,ash)>maxMean){
05142             maxMeanF=static_cast<Int_t>
05143               (hAshtrayVsPlaneMeanF[pb]->GetBinContent(pl,ash));
05144           }
05145         }
05146       }
05147     }
05148   }
05149 
05150   //do this after it has been weighted
05151   for (Int_t pb=FIRSTPULSERBOX;pb<=LASTPULSERBOX;pb++){
05152     //set a ceiling
05153     if (maxMean>4000) maxMean=4000;
05154     if (maxMeanF>3000) maxMeanF=3000;
05155     hAshtrayVsPlaneMean[pb]->SetMaximum(maxMean);
05156     hAshtrayVsPlaneMeanF[pb]->SetMaximum(maxMeanF);
05157   }
05158 
05159   //   TCanvas *cAshtrayVsPlaneLed=new TCanvas
05160   //     ("cAshtrayVsPlaneLed","AshtrayVsPlane: Led",0,0,1000,800);
05161   //   cAshtrayVsPlaneLed->SetFillColor(0);
05162   //   cAshtrayVsPlaneLed->cd();
05163   //   hAshtrayVsPlaneLedB->Draw();
05164   //   for (Int_t i=0;i<NUMPULSERBOXES;i+=2){
05165   //     hAshtrayVsPlaneLed[i]->Draw("sametextcolz");
05166   //   }
05167 
05168   TCanvas *cAshtrayVsPlaneMean=new TCanvas
05169     ("cAshtrayVsPlaneMean","AshtrayVsPlane: Mean",0,0,1000,800);
05170   cAshtrayVsPlaneMean->SetFillColor(0);
05171   cAshtrayVsPlaneMean->cd();
05172   for (Int_t i=0;i<NUMPULSERBOXES;i++){    
05173     hAshtrayVsPlaneMean[i]->Draw("colz");
05174     if (i==0){
05175       s=sRunNumber+"AdcNearAshtray.ps(";
05176       cAshtrayVsPlaneMean->Print(s.c_str());
05177     }
05178     else if(i==NUMPULSERBOXES-1){
05179       s=sRunNumber+"AdcNearAshtray.ps)";
05180       cAshtrayVsPlaneMean->Print(s.c_str()); 
05181     }
05182     else{
05183       s=sRunNumber+"AdcNearAshtray.ps";
05184       cAshtrayVsPlaneMean->Print(s.c_str());
05185     }
05186   }
05187   //draw it so it stays there
05188   cAshtrayVsPlaneMean->Clear();
05189   hAshtrayVsPlaneMean[nearPb]->Draw("colz");
05190   //delete cAshtrayVsPlaneMean;
05191   
05192   TCanvas *cAshtrayVsPlaneMeanF=new TCanvas
05193     ("cAshtrayVsPlaneMeanF","AshtrayVsPlane: MeanF",0,0,1000,800);
05194   cAshtrayVsPlaneMeanF->SetFillColor(0);
05195   cAshtrayVsPlaneMeanF->cd();
05196   for (Int_t i=0;i<NUMPULSERBOXES;i++){  
05197     cAshtrayVsPlaneMeanF->Clear();
05198     hAshtrayVsPlaneMeanF[i]->Draw("colz");
05199     if (i==0){
05200       s=sRunNumber+"AdcFarAshtray.ps(";
05201       cAshtrayVsPlaneMeanF->Print(s.c_str());
05202     }
05203     else if(i==NUMPULSERBOXES-1){
05204       s=sRunNumber+"AdcFarAshtray.ps)";
05205       cAshtrayVsPlaneMeanF->Print(s.c_str()); 
05206     }
05207     else{
05208       s=sRunNumber+"AdcFarAshtray.ps";
05209       cAshtrayVsPlaneMeanF->Print(s.c_str());
05210     }
05211   }
05212   //draw it so it stays there
05213   cAshtrayVsPlaneMeanF->Clear();
05214   hAshtrayVsPlaneMeanF[farPb]->Draw("colz");
05215   //delete cAshtrayVsPlaneMeanF;
05216 
05217   //   TCanvas *cAshtrayVsPlaneNum=new TCanvas
05218   //     ("cAshtrayVsPlaneNum","AshtrayVsPlane: Number Entries",0,0,1000,800);
05219   //   cAshtrayVsPlaneNum->SetFillColor(0);
05220   //   cAshtrayVsPlaneNum->cd();
05221   //   hAshtrayVsPlaneNum[pb]->Draw("textcolz");
05222 
05223   //   TCanvas *cAshtrayVsPlanePix=new TCanvas
05224   //     ("cAshtrayVsPlanePix","AshtrayVsPlane: Ashtray",0,0,1000,800);
05225   //   cAshtrayVsPlanePix->SetFillColor(0);
05226   //   cAshtrayVsPlanePix->cd();
05227   //   hAshtrayVsPlanePix[nearPb]->Draw("textcolz");
05228 
05229   //   TCanvas *cAshtrayVsPlanePixF=new TCanvas
05230   //     ("cAshtrayVsPlanePixF","AshtrayVsPlane: Ashtray",0,0,1000,800);
05231   //   cAshtrayVsPlanePixF->SetFillColor(0);
05232   //   cAshtrayVsPlanePixF->cd();
05233   //   hAshtrayVsPlanePixF[farPb]->Draw("textcolz");
05234 
05235   TCanvas *cAshtrayVsPlaneEntEast=new TCanvas
05236     ("cAshtrayVsPlaneEntEast","AshtrayVsPlane: East Side (Near)"
05237      ,0,0,1200,800);
05238   cAshtrayVsPlaneEntEast->SetFillColor(0);
05239   cAshtrayVsPlaneEntEast->cd();
05240   hAshtrayVsPlaneLedB->SetTitle("East Side (Near)");
05241   hAshtrayVsPlaneLedB->Draw();
05242   for (Int_t i=0;i<NUMPULSERBOXES;i+=2){
05243     hAshtrayVsPlaneEnt[i]->Draw("samecolz");
05244   }
05245   s=sRunNumber+"EastNearAshtray.eps";
05246   cAshtrayVsPlaneEntEast->Print(s.c_str()); 
05247 
05248   TCanvas *cAshtrayVsPlaneEntWest=new TCanvas
05249     ("cAshtrayVsPlaneEntWest","AshtrayVsPlane: West Side (Near)"
05250      ,0,0,1200,800);
05251   cAshtrayVsPlaneEntWest->SetFillColor(0);
05252   cAshtrayVsPlaneEntWest->cd();
05253   hAshtrayVsPlaneLedB->SetTitle("West Side (Near)");
05254   hAshtrayVsPlaneLedB->Draw();
05255   for (Int_t i=1;i<NUMPULSERBOXES;i+=2){
05256     hAshtrayVsPlaneEnt[i]->Draw("samecolz");
05257   }
05258   s=sRunNumber+"WestNearAshtray.eps";
05259   cAshtrayVsPlaneEntWest->Print(s.c_str()); 
05260 
05261   TCanvas *cAshtrayVsPlaneEntWestF=new TCanvas
05262     ("cAshtrayVsPlaneEntWestF","AshtrayVsPlane: West Side (Far)"
05263      ,0,0,1200,800);
05264   cAshtrayVsPlaneEntWestF->SetFillColor(0);
05265   cAshtrayVsPlaneEntWestF->cd();
05266   hAshtrayVsPlaneLedB->SetTitle("West Side (Far)");
05267   hAshtrayVsPlaneLedB->Draw();
05268   for (Int_t i=0;i<NUMPULSERBOXES;i+=2){
05269     hAshtrayVsPlaneEntF[i]->Draw("samecolz");
05270   }
05271   s=sRunNumber+"WestFarAshtray.eps";
05272   cAshtrayVsPlaneEntWestF->Print(s.c_str());
05273 
05274   TCanvas *cAshtrayVsPlaneEntEastF=new TCanvas
05275     ("cAshtrayVsPlaneEntEastF","AshtrayVsPlane: East Side (Far)"
05276      ,0,0,1200,800);
05277   cAshtrayVsPlaneEntEastF->SetFillColor(0);
05278   cAshtrayVsPlaneEntEastF->cd();
05279   hAshtrayVsPlaneLedB->SetTitle("East Side (Far)");
05280   hAshtrayVsPlaneLedB->Draw();
05281   for (Int_t i=1;i<NUMPULSERBOXES;i+=2){
05282     hAshtrayVsPlaneEntF[i]->Draw("samecolz");
05283   }
05284   s=sRunNumber+"EastFarAshtray.eps";
05285   cAshtrayVsPlaneEntEastF->Print(s.c_str());
05286 
05287   MSG("LIAnalysis",Msg::kInfo)
05288     <<" ** Finished the AshtrayVsPlane method ** "<<endl;
05289 }

void LIAnalysis::CalcAdcAv  ) 
 

Definition at line 6872 of file LIAnalysis.cxx.

References calibPoint, histname, InitialiseLoopVariables(), led, mean, MSG, numEntries, pulserBox, readoutType, rms, and SetLoopVariables().

06873 {
06874   MSG("LIAnalysis",Msg::kInfo) 
06875     <<endl<<" ** Running the CalcAdcAv method... ** "<<endl;
06876 
06877   const Int_t const_numCalibPoints=numCalibPoints;   
06878   MSG("LIAnalysis",Msg::kInfo) 
06879     <<"Using "<<const_numCalibPoints<<" calibPoints"<<endl;
06880   MSG("LIAnalysis",Msg::kInfo) 
06881     <<"Number of pulser boxes = "<<NUMPULSERBOXES<<endl;
06882 
06883   //store the pulse heights associated with each calibPoint
06884   Int_t *pbPulseHeight=new Int_t[const_numCalibPoints];
06885 
06886   //an array of arrays to hold adc values for different pulse
06887   //heights for the different pulser boxes
06888   Float_t **pbMean=0;
06889   Float_t **pbNumEntries=0;
06890   pbMean=new Float_t*[const_numCalibPoints];
06891   pbNumEntries=new Float_t*[const_numCalibPoints];
06892   for (int i=0; i<const_numCalibPoints; i++){
06893     pbMean[i]=new Float_t[NUMPULSERBOXES];
06894     pbNumEntries[i]=new Float_t[NUMPULSERBOXES];
06895     for (int j=0; j<NUMPULSERBOXES; j++){
06896       //initialise
06897       (pbMean[i])[j]=0.;
06898       (pbNumEntries[i])[j]=0.;
06899     }
06900     pbPulseHeight[i]=0;
06901   }
06902 
06903   //histograms of the adc values for different pulse heights
06904   TH1F **hAdc=0;
06905   hAdc= new TH1F*[const_numCalibPoints];
06906   for (Int_t i=0;i<const_numCalibPoints;i++){
06907     sprintf(histname,"Adc Distribution, calibpoint %d",i+1);
06908     hAdc[i]=new TH1F(histname,histname,200,0,15000);
06909     
06910     hAdc[i]->GetXaxis()->SetTitle("Average Adc");
06911     hAdc[i]->GetXaxis()->CenterTitle();
06912     hAdc[i]->GetYaxis()->SetTitle("Num Entries");
06913     hAdc[i]->GetYaxis()->CenterTitle();
06914     hAdc[i]->SetFillColor(0);
06915     //hAdc[i]->SetBit(TH1::kCanRebin);
06916   }  
06917 
06918   //histograms of the adc values for different pulse heights
06919   TH1F **hAdcWithCut=0;
06920   hAdcWithCut= new TH1F*[const_numCalibPoints];
06921   for (Int_t i=0;i<const_numCalibPoints;i++){
06922     sprintf(histname,"Adc Distribution, calib point %i",i+1);
06923     hAdcWithCut[i]=new TH1F(histname,histname,200,0,15000);
06924     
06925     hAdcWithCut[i]->GetXaxis()->SetTitle("Average Adc");
06926     hAdcWithCut[i]->GetXaxis()->CenterTitle();
06927     hAdcWithCut[i]->GetYaxis()->SetTitle("Num Entries");
06928     hAdcWithCut[i]->GetYaxis()->CenterTitle();
06929     hAdcWithCut[i]->SetFillColor(0);
06930     hAdcWithCut[i]->SetLineColor(2);
06931     //hAdcWithCut[i]->SetBit(TH1::kCanRebin);
06932   }  
06933 
06934   //histograms of the adc values for different pulse heights
06935   TH1F ***hAdcL=0;
06936   hAdcL= new TH1F**[const_numCalibPoints];
06937   for (Int_t i=0;i<const_numCalibPoints;i++){
06938     hAdcL[i]= new TH1F*[NUMLEDS];
06939     for (Int_t j=0;j<NUMLEDS;j++){
06940       sprintf(histname,"Adc Distribution (LED), calib point %i",i+1);
06941       (hAdcL[i])[j]=new TH1F(histname,histname,60,0,15000);
06942       
06943       (hAdcL[i])[j]->GetXaxis()->SetTitle("Average Adc");
06944       (hAdcL[i])[j]->GetXaxis()->CenterTitle();
06945       (hAdcL[i])[j]->GetYaxis()->SetTitle("Num Entries");
06946       (hAdcL[i])[j]->GetYaxis()->CenterTitle();
06947       (hAdcL[i])[j]->SetFillColor(0);
06948       (hAdcL[i])[j]->SetMarkerSize(20);
06949       //(hAdc[i])[j]->SetBit(TH1::kCanRebin);
06950     }  
06951   }
06952 
06956 
06957   this->InitialiseLoopVariables();  
06958   
06959   for(Int_t entry=0;entry<numEvents;entry++){
06960     
06961     this->SetLoopVariables(entry,0);
06962     
06963     //avoid divide by zero errors and skip irrelevant data
06964     if (rms==0. || mean==0. || numEntries==0) continue;
06965     //only look at scintillator strips
06966     if (readoutType!=ReadoutType::kScintStrip) continue;
06967 
06968     if (pulserBox>=0 && pulserBox<NUMPULSERBOXES &&
06969         calibPoint>0 && calibPoint<=const_numCalibPoints &&
06970         led>0 && led<=NUMLEDS){
06971       if (pulserBox==nearPulserBox){
06972         (pbMean[calibPoint-1])[pulserBox]+=mean;
06973         (pbNumEntries[calibPoint-1])[pulserBox]++;
06974         hAdcWithCut[calibPoint-1]->Fill(mean);
06975         (hAdcL[calibPoint-1])[led-1]->Fill(mean);
06976       }
06977 
06978       hAdc[calibPoint-1]->Fill(mean);
06979       pbPulseHeight[calibPoint-1]=pulseHeight;
06980     }
06981   }//end of for
06982 
06986   
06987   MSG("LIAnalysis",Msg::kInfo)<<"Finished main loop"<<endl;
06988 
06989   MSG("LIAnalysis",Msg::kInfo) 
06990     <<endl
06991     <<"Average Adcs for each pulser box:"<<endl;
06992   for (Int_t calPoint=0;calPoint<const_numCalibPoints;calPoint++){
06993     MSG("LIAnalysis",Msg::kInfo) 
06994       <<"  With pulse height "<<pbPulseHeight[calPoint]<<endl;
06995     for (Int_t pb=0; pb<NUMPULSERBOXES; pb++){
06996 
06997       //avoid divide by zero
06998       Float_t averageMean=0.;
06999       if ((pbNumEntries[calPoint])[pb]>0){
07000         //calculte average
07001         averageMean=(pbMean[calPoint])[pb]/
07002           (pbNumEntries[calPoint])[pb];
07003       }
07004       MSG("LIAnalysis",Msg::kInfo) 
07005         <<"    Average ADC = "<<averageMean
07006         <<" for pulser box "<<pb 
07007         <<"  (Num Entries = "<<(pbNumEntries[calPoint])[pb]<<")"
07008         <<endl;
07009     }
07010   }
07011 
07012   //plot adc distributions for different pulse heights
07013   TCanvas *cAdc=new TCanvas("cAdc","ADC Distribution",0,0,800,630);
07014   cAdc->SetFillColor(0);
07015   cAdc->Divide(2,2);
07016   TCanvas *cAdc2=new TCanvas("cAdc2","ADC Distribution",0,0,800,630);
07017   cAdc2->SetFillColor(0);
07018   cAdc2->Divide(2,2);
07019   TCanvas *cAdc3=new TCanvas("cAdc3","ADC Distribution",0,0,800,630);
07020   cAdc3->SetFillColor(0);
07021   cAdc3->Divide(2,2);
07022 
07023   TLegend *lAdc= new TLegend(0.85, 0.7, 0.9, 0.9);
07024   lAdc->SetBorderSize(0);
07025   lAdc->SetFillColor(0);
07026   lAdc->SetTextSize(0.035);
07027   lAdc->AddEntry(hAdc[0]," All hits","l");
07028   lAdc->AddEntry(hAdcWithCut[0]," Hits from near PBox","l");
07029 
07030   for (Int_t i=0;i<const_numCalibPoints;i++){
07031     sprintf(histname,"Adc Distribution, pulse Height %i",
07032             pbPulseHeight[i]);
07033     hAdc[i]->SetTitle(histname);
07034     hAdcWithCut[i]->SetTitle(histname);
07035     if (i<4){
07036       cAdc->cd(i+1);   
07037       hAdc[i]->Draw();
07038       hAdcWithCut[i]->Draw("same");
07039       lAdc->Draw();
07040     }
07041     if (i>=4 && i<8){
07042       cAdc2->cd(i-3);    
07043       hAdc[i]->Draw();
07044       hAdcWithCut[i]->Draw("same");
07045       lAdc->Draw();
07046     }
07047     if (i>=8 && i<12){
07048       cAdc3->cd(i-7);    
07049       hAdc[i]->Draw();
07050       hAdcWithCut[i]->Draw("same");
07051       lAdc->Draw();
07052     }
07053   }
07054 
07055   //plot every LED
07056   TCanvas *cAdcL=new TCanvas("cAdcL","ADC Distribution",0,0,800,630);
07057   cAdcL->SetFillColor(0);
07058   cAdcL->Divide(2,2);
07059 
07060   TLegend **lAdcL=0;
07061   lAdcL= new TLegend*[5];
07062   for (Int_t i=0;i<5;i++){
07063     lAdcL[i]= new TLegend(0.85, 0.7, 0.9, 0.9);
07064     lAdcL[i]->SetBorderSize(0);
07065     lAdcL[i]->SetFillColor(0);
07066     lAdcL[i]->SetTextSize(0.035);
07067   }
07068 
07069   for (Int_t i=0;i<const_numCalibPoints;i++){
07070     if (i<4){
07071       cAdcL->cd(i+1);   
07072       hAdcWithCut[7]->Draw();
07073 
07074       for (Int_t j=i*5;j<(i+1)*5;j++){
07075         (hAdcL[7])[j]->SetLineColor(2+j-(i*5)+1);
07076         (hAdcL[7])[j]->Draw("same");
07077         sprintf(histname," LED %i",j+1);
07078         lAdcL[i]->AddEntry((hAdcL[7])[j],histname,"l");
07079       }
07080       lAdcL[i]->Draw();
07081     }
07082   }
07083 
07084   MSG("LIAnalysis",Msg::kInfo) 
07085     <<endl<<" ** Finished the CalcAdcAv method ** "<<endl;
07086 }

void LIAnalysis::ChannelAdc Int_t  chan,
Int_t  chan2
 

Definition at line 7090 of file LIAnalysis.cxx.

References correlatedHit, crate, InitialiseLoopVariables(), mean, minderCh, MSG, and SetLoopVariables().

07091 {
07092   MSG("LIAnalysis",Msg::kInfo) 
07093     <<endl<<" ** Running the ChannelAdc method... ** "<<endl;
07094 
07095   gStyle->SetOptStat(1111111);
07096 
07097   MSG("LIAnalysis",Msg::kInfo) 
07098     <<"Looking at channels "<<chan<<" and "<<chan2<<endl;
07099 
07100   TH1F *hMean=new TH1F("hMean","Mean",400,-5,15005);
07101   hMean->GetXaxis()->SetTitle("Mean");
07102   hMean->GetXaxis()->CenterTitle();
07103   hMean->GetYaxis()->SetTitle("");
07104   hMean->GetYaxis()->CenterTitle();
07105   hMean->SetFillColor(0);
07106   hMean->SetBit(TH1::kCanRebin);
07107 
07108   TH1F *hMeanCorrelated=new TH1F("hMeanCorrelated","MeanCorrelated",
07109                                   400,-5,15005);
07110   hMeanCorrelated->GetXaxis()->SetTitle("Mean");
07111   hMeanCorrelated->GetXaxis()->CenterTitle();
07112   hMeanCorrelated->GetYaxis()->SetTitle("");
07113   hMeanCorrelated->GetYaxis()->CenterTitle();
07114   hMeanCorrelated->SetFillColor(0);
07115   hMeanCorrelated->SetLineColor(2);
07116   hMeanCorrelated->SetBit(TH1::kCanRebin);
07117 
07118   TH1F *hMeanCh=new TH1F("hMeanCh","Mean",400,-5,15005);
07119   hMeanCh->GetXaxis()->SetTitle("Mean");
07120   hMeanCh->GetXaxis()->CenterTitle();
07121   hMeanCh->GetYaxis()->SetTitle("");
07122   hMeanCh->GetYaxis()->CenterTitle();
07123   hMeanCh->SetFillColor(0);
07124   hMeanCh->SetBit(TH1::kCanRebin);
07125 
07126   TH1F *hMeanChCorrelated=new TH1F("hMeanChCorrelated","MeanCorrelated",
07127                                   400,-5,15005);
07128   hMeanChCorrelated->GetXaxis()->SetTitle("Mean");
07129   hMeanChCorrelated->GetXaxis()->CenterTitle();
07130   hMeanChCorrelated->GetYaxis()->SetTitle("");
07131   hMeanChCorrelated->GetYaxis()->CenterTitle();
07132   hMeanChCorrelated->SetFillColor(0);
07133   hMeanChCorrelated->SetLineColor(2);
07134   hMeanChCorrelated->SetBit(TH1::kCanRebin);
07135 
07136   TH1F *hMeanCh2=new TH1F("hMeanCh2","Mean",400,-5,15005);
07137   hMeanCh2->GetXaxis()->SetTitle("Mean");
07138   hMeanCh2->GetXaxis()->CenterTitle();
07139   hMeanCh2->GetYaxis()->SetTitle("");
07140   hMeanCh2->GetYaxis()->CenterTitle();
07141   hMeanCh2->SetFillColor(0);
07142   hMeanCh2->SetBit(TH1::kCanRebin);
07143 
07144   TH1F *hMeanCh2Correlated=new TH1F("hMeanCh2Correlated","MeanCorrelated",
07145                                   400,-5,15005);
07146   hMeanCh2Correlated->GetXaxis()->SetTitle("Mean");
07147   hMeanCh2Correlated->GetXaxis()->CenterTitle();
07148   hMeanCh2Correlated->GetYaxis()->SetTitle("");
07149   hMeanCh2Correlated->GetYaxis()->CenterTitle();
07150   hMeanCh2Correlated->SetFillColor(0);
07151   hMeanCh2Correlated->SetLineColor(2);
07152   hMeanCh2Correlated->SetBit(TH1::kCanRebin);
07153 
07157 
07158   this->InitialiseLoopVariables();  
07159   
07160   for(Int_t entry=0;entry<numEvents;entry++){
07161     
07162     this->SetLoopVariables(entry);
07163 
07164     if (crate==0) continue;
07165    
07166     if (correlatedHit==0){
07167       hMean->Fill(mean);
07168       if (minderCh==chan) hMeanCh->Fill(mean);
07169       if (minderCh==chan2) hMeanCh2->Fill(mean);
07170     } 
07171     else if (correlatedHit==1){
07172       hMeanCorrelated->Fill(mean);
07173       if (minderCh==chan) hMeanChCorrelated->Fill(mean);
07174       if (minderCh==chan2) hMeanCh2Correlated->Fill(mean);
07175     }
07176 
07177   }//end of for
07178   
07182   
07183   MSG("LIAnalysis",Msg::kInfo)<<"Finished main loop"<<endl;
07184 
07185   TCanvas *cMeans=new TCanvas("cMeans","cMeans",0,0,1200,800);
07186   cMeans->SetFillColor(0);
07187   cMeans->Divide(2,2);
07188   cMeans->cd(1);
07189   hMean->Draw();
07190 
07191   cMeans->cd(2);
07192   hMean->Draw();
07193   hMeanCorrelated->Draw("sames");
07194 
07195   cMeans->cd(3);
07196   hMeanCh->Draw();
07197   hMeanChCorrelated->Draw("sames");
07198 
07199   cMeans->cd(4);
07200   hMeanCh2->Draw();
07201   hMeanCh2Correlated->Draw("sames");
07202 
07203   MSG("LIAnalysis",Msg::kInfo) 
07204     <<"Looked at channels "<<chan<<" and "<<chan2<<endl;
07205 
07206   MSG("LIAnalysis",Msg::kInfo) 
07207     <<endl<<" ** Finished the ChannelAdc method ** "<<endl;
07208 }

void LIAnalysis::CheckData Int_t  rt = -1  ) 
 

Definition at line 7212 of file LIAnalysis.cxx.

References ashtray, ReadoutType::AsString(), calibPoint, calibType, chAdd, channel, chip, correlatedHit, crate, eastWest, elecType, farLed, farPulserBox, geoAdd, InitialiseLoopVariables(), inRack, led, masterCh, mean, minderCh, MSG, nearLed, nearPulserBox, numEntries, numericMuxBox, period, pinGain, pinInBox, pixel, plane, print(), PrintBigMessage(), pulseHeight, pulserBox, pulses, pulseWidth, rackBay, rackLevel, readoutType, rms, runNumber, runNumberSub, runType, SetLoopVariables(), strip, stripEnd, summaryCounter, timestamp, varc, vfb, and vmm.

07213 {
07214   MSG("LIAnalysis",Msg::kInfo) 
07215     <<endl<<" ** Running the CheckData method... ** "<<endl;
07216 
07217   gStyle->SetOptStat(1111111);
07218 
07219   TH1F *hAshtray=new TH1F("hAshtray",
07220                               "Ashtray distribution",24,-2,22);
07221   hAshtray->GetXaxis()->SetTitle("Ashtray");
07222   hAshtray->GetXaxis()->CenterTitle();
07223   hAshtray->GetYaxis()->SetTitle("");
07224   hAshtray->GetYaxis()->CenterTitle();
07225   hAshtray->SetFillColor(0);
07226   hAshtray->SetBit(TH1::kCanRebin);
07227 
07228   TH1F *hCalibPoint=new TH1F("hCalibPoint",
07229                               "CalibPoint distribution",40,-5,35);
07230   hCalibPoint->GetXaxis()->SetTitle("CalibPoint");
07231   hCalibPoint->GetXaxis()->CenterTitle();
07232   hCalibPoint->GetYaxis()->SetTitle("");
07233   hCalibPoint->GetYaxis()->CenterTitle();
07234   hCalibPoint->SetFillColor(0);
07235   hCalibPoint->SetBit(TH1::kCanRebin);
07236 
07237   TH1F *hCalibType=new TH1F("hCalibType","CalibType",100,-5,95);
07238   hCalibType->GetXaxis()->SetTitle("CalibType");
07239   hCalibType->GetXaxis()->CenterTitle();
07240   hCalibType->GetYaxis()->SetTitle("");
07241   hCalibType->GetYaxis()->CenterTitle();
07242   hCalibType->SetFillColor(0);
07243   hCalibType->SetBit(TH1::kCanRebin);
07244 
07245   TH1F *hChAdd=new TH1F("hChAdd","ChAdd",8210,-205,8005);
07246   hChAdd->GetXaxis()->SetTitle("ChAdd");
07247   hChAdd->GetXaxis()->CenterTitle();
07248   hChAdd->GetYaxis()->SetTitle("Number of times hit");
07249   hChAdd->GetYaxis()->CenterTitle();
07250   hChAdd->SetFillColor(0);
07251   hChAdd->SetBit(TH1::kCanRebin);
07252 
07253   TH1F *hChannel=new TH1F("hChannel","VA Channels hit",27,-2,25);
07254   hChannel->GetXaxis()->SetTitle("VA Channel");
07255   hChannel->GetXaxis()->CenterTitle();
07256   hChannel->GetYaxis()->SetTitle("Number of times hit");
07257   hChannel->GetYaxis()->CenterTitle();
07258   hChannel->SetFillColor(0);
07259   hChannel->SetBit(TH1::kCanRebin);
07260 
07261   TH1F *hChip=new TH1F("hChip","Chips hit",7,-2,5);
07262   hChip->GetXaxis()->SetTitle("Chip");
07263   hChip->GetXaxis()->CenterTitle();
07264   hChip->GetYaxis()->SetTitle("Number of times hit");
07265   hChip->GetYaxis()->CenterTitle();
07266   hChip->SetFillColor(0);
07267 
07268   TH1F *hCorrelatedHit=new TH1F("hCorrelatedHit",
07269                                  "Correlated Hit",10,-2,8);
07270   hCorrelatedHit->GetXaxis()->SetTitle("CorrelatedHit");
07271   hCorrelatedHit->GetXaxis()->CenterTitle();
07272   hCorrelatedHit->GetYaxis()->SetTitle("num entries");
07273   hCorrelatedHit->GetYaxis()->CenterTitle();
07274   hCorrelatedHit->SetFillColor(0);
07275   hCorrelatedHit->SetBit(TH1::kCanRebin);
07276 
07277   TH1F *hCrate=new TH1F("hCrate","Crates hit",22,-2,20);
07278   hCrate->GetXaxis()->SetTitle("Crate");
07279   hCrate->GetXaxis()->CenterTitle();
07280   hCrate->GetYaxis()->SetTitle("Number of times hit");
07281   hCrate->GetYaxis()->CenterTitle();
07282   hCrate->SetFillColor(0);
07283 
07284   TH1F *hEastWest=new TH1F("hEastWest","EastWest",6,-2,4);
07285   hEastWest->GetXaxis()->SetTitle("EastWest");
07286   hEastWest->GetXaxis()->CenterTitle();
07287   hEastWest->GetYaxis()->SetTitle("");
07288   hEastWest->GetYaxis()->CenterTitle();
07289   hEastWest->SetFillColor(0);
07290   hEastWest->SetBit(TH1::kCanRebin);
07291 
07292   TH1F *hEastWestCor=new TH1F("hEastWestCor","EastWestCor",6,-2,4);
07293   hEastWestCor->GetXaxis()->SetTitle("EastWest");
07294   hEastWestCor->GetXaxis()->CenterTitle();
07295   hEastWestCor->GetYaxis()->SetTitle("");
07296   hEastWestCor->GetYaxis()->CenterTitle();
07297   hEastWestCor->SetFillColor(0);
07298   hEastWestCor->SetLineColor(2);
07299   hEastWestCor->SetBit(TH1::kCanRebin);
07300 
07301   TH1F *hElecType=new TH1F("hElecType","ElecType",12,-2,10);
07302   hElecType->GetXaxis()->SetTitle("ElecType");
07303   hElecType->GetXaxis()->CenterTitle();
07304   hElecType->GetYaxis()->SetTitle("");
07305   hElecType->GetYaxis()->CenterTitle();
07306   hElecType->SetFillColor(0);
07307   hElecType->SetLineColor(2);
07308   hElecType->SetBit(TH1::kCanRebin);
07309 
07310   TH1F *hFarLed=new TH1F("hFarLed","FarLed",30,-5,25);
07311   hFarLed->GetXaxis()->SetTitle("FarLed");
07312   hFarLed->GetXaxis()->CenterTitle();
07313   hFarLed->GetYaxis()->SetTitle("Num Entries");
07314   hFarLed->GetYaxis()->CenterTitle();
07315   hFarLed->SetFillColor(0);
07316   hFarLed->SetBit(TH1::kCanRebin);
07317 
07318   TH1F *hFarPulserBox=new TH1F("hFarPulserBox","FarPulserBox",
07319                                 30,-5,25);
07320   hFarPulserBox->GetXaxis()->SetTitle("FarPulserBox");
07321   hFarPulserBox->GetXaxis()->CenterTitle();
07322   hFarPulserBox->GetYaxis()->SetTitle("Num Entries");
07323   hFarPulserBox->GetYaxis()->CenterTitle();
07324   hFarPulserBox->SetFillColor(0);
07325   hFarPulserBox->SetBit(TH1::kCanRebin);
07326 
07327   TH1F *hGeoAdd=new TH1F("hGeoAdd","GeoAdd",
07328                                 30,-5,25);
07329   hGeoAdd->GetXaxis()->SetTitle("GeoAdd");
07330   hGeoAdd->GetXaxis()->CenterTitle();
07331   hGeoAdd->GetYaxis()->SetTitle("Num Entries");
07332   hGeoAdd->GetYaxis()->CenterTitle();
07333   hGeoAdd->SetFillColor(0);
07334   hGeoAdd->SetBit(TH1::kCanRebin);
07335 
07336   TH1F *hInRack=new TH1F("hInRack","InRack",20,-5,15);
07337   hInRack->GetXaxis()->SetTitle("InRack");
07338   hInRack->GetXaxis()->CenterTitle();
07339   hInRack->GetYaxis()->SetTitle("");
07340   hInRack->GetYaxis()->CenterTitle();
07341   hInRack->SetFillColor(0);
07342   hInRack->SetBit(TH1::kCanRebin);
07343 
07344   TH1F *hInRackCor=new TH1F("hInRackCor","InRackCor",20,-5,15);
07345   hInRackCor->GetXaxis()->SetTitle("InRack");
07346   hInRackCor->GetXaxis()->CenterTitle();
07347   hInRackCor->GetYaxis()->SetTitle("");
07348   hInRackCor->GetYaxis()->CenterTitle();
07349   hInRackCor->SetFillColor(0);
07350   hInRackCor->SetLineColor(2);
07351   hInRackCor->SetBit(TH1::kCanRebin);
07352 
07353   TH1F *hLed=new TH1F("hLed","Leds",30,-5,25);
07354   hLed->GetXaxis()->SetTitle("Led");
07355   hLed->GetXaxis()->CenterTitle();
07356   hLed->GetYaxis()->SetTitle("");
07357   hLed->GetYaxis()->CenterTitle();
07358   hLed->SetFillColor(0);
07359   hLed->SetBit(TH1::kCanRebin);
07360 
07361   TH1F *hMasterCh=new TH1F("hMasterCh","MasterCh",30,-5,25);
07362   hMasterCh->GetXaxis()->SetTitle("MasterCh");
07363   hMasterCh->GetXaxis()->CenterTitle();
07364   hMasterCh->GetYaxis()->SetTitle("");
07365   hMasterCh->GetYaxis()->CenterTitle();
07366   hMasterCh->SetFillColor(0);
07367   hMasterCh->SetBit(TH1::kCanRebin);
07368 
07369   TH1F *hMean=new TH1F("hMean","Mean",20000,-20,15005);
07370   hMean->GetXaxis()->SetTitle("Mean");
07371   hMean->GetXaxis()->CenterTitle();
07372   hMean->GetYaxis()->SetTitle("Num Entries");
07373   hMean->GetYaxis()->CenterTitle();
07374   hMean->SetFillColor(0);
07375   hMean->SetBit(TH1::kCanRebin);
07376 
07377   TH1F *hMeanCorrelated=new TH1F("hMeanCorrelated","MeanCorrelated",
07378                                   1000,-5,15005);
07379   hMeanCorrelated->GetXaxis()->SetTitle("Mean");
07380   hMeanCorrelated->GetXaxis()->CenterTitle();
07381   hMeanCorrelated->GetYaxis()->SetTitle("Num Entries");
07382   hMeanCorrelated->GetYaxis()->CenterTitle();
07383   hMeanCorrelated->SetFillColor(0);
07384   hMeanCorrelated->SetLineColor(2);
07385   hMeanCorrelated->SetBit(TH1::kCanRebin);
07386 
07387   TH1F *hMeanFarPB=new TH1F("hMeanFarPB","MeanFarPB",
07388                              1000,-5,15005);
07389   hMean->GetXaxis()->SetTitle("Mean");
07390   hMeanFarPB->GetXaxis()->CenterTitle();
07391   hMeanFarPB->GetYaxis()->SetTitle("Num Entries");
07392   hMeanFarPB->GetYaxis()->CenterTitle();
07393   hMeanFarPB->SetFillColor(0);
07394   hMeanFarPB->SetLineColor(4);
07395   hMeanFarPB->SetBit(TH1::kCanRebin);
07396 
07397   TH1F *hMeanNearPB=new TH1F("hMeanNearPB","MeanNearPB",
07398                               1000,-5,15005);
07399   hMean->GetXaxis()->SetTitle("Mean");
07400   hMeanNearPB->GetXaxis()->CenterTitle();
07401   hMeanNearPB->GetYaxis()->SetTitle("Num Entries");
07402   hMeanNearPB->GetYaxis()->CenterTitle();
07403   hMeanNearPB->SetFillColor(0);
07404   hMeanNearPB->SetLineColor(3);
07405   hMeanNearPB->SetBit(TH1::kCanRebin);
07406 
07407   TH1F *hMinderCh=new TH1F("hMinderCh","MinderCh",30,-5,25);
07408   hMinderCh->GetXaxis()->SetTitle("MinderCh");
07409   hMinderCh->GetXaxis()->CenterTitle();
07410   hMinderCh->GetYaxis()->SetTitle("");
07411   hMinderCh->GetYaxis()->CenterTitle();
07412   hMinderCh->SetFillColor(0);
07413   hMinderCh->SetBit(TH1::kCanRebin);
07414 
07415   TH1F *hNearLed=new TH1F("hNearLed","NearLed",30,-5,25);
07416   hNearLed->GetXaxis()->SetTitle("NearLed");
07417   hNearLed->GetXaxis()->CenterTitle();
07418   hNearLed->GetYaxis()->SetTitle("");
07419   hNearLed->GetYaxis()->CenterTitle();
07420   hNearLed->SetFillColor(0);
07421   hNearLed->SetBit(TH1::kCanRebin);
07422 
07423   TH1F *hNearPulserBox=new TH1F("hNearPulserBox","NearPulserBox",
07424                                  30,-5,25);
07425   hNearPulserBox->GetXaxis()->SetTitle("NearPulserBox");
07426   hNearPulserBox->GetXaxis()->CenterTitle();
07427   hNearPulserBox->GetYaxis()->SetTitle("");
07428   hNearPulserBox->GetYaxis()->CenterTitle();
07429   hNearPulserBox->SetFillColor(0);
07430   hNearPulserBox->SetBit(TH1::kCanRebin);
07431 
07432   TH1F *hNumEntries=new TH1F("hNumEntries","NumEntries",10000,-5,1000);
07433   hNumEntries->GetXaxis()->SetTitle("NumEntries");
07434   hNumEntries->GetXaxis()->CenterTitle();
07435   hNumEntries->GetYaxis()->SetTitle("");
07436   hNumEntries->GetYaxis()->CenterTitle();
07437   hNumEntries->SetFillColor(0);
07438   hNumEntries->SetBit(TH1::kCanRebin);
07439 
07440   TH1F *hNumEntriesCor=new TH1F("hNumEntriesCor","NumEntriesCor",
07441                                  1000,-5,35);
07442   hNumEntriesCor->GetXaxis()->SetTitle("NumEntriesCor");
07443   hNumEntriesCor->GetXaxis()->CenterTitle();
07444   hNumEntriesCor->GetYaxis()->SetTitle("");
07445   hNumEntriesCor->GetYaxis()->CenterTitle();
07446   hNumEntriesCor->SetFillColor(0);
07447   hNumEntriesCor->SetLineColor(2);
07448   hNumEntriesCor->SetBit(TH1::kCanRebin);
07449 
07450   TH2F *hNumEntVsPb=new TH2F("hNumEntVsPb",
07451                              "Number of Pulses Detected Vs Pulser Box (All hits)",
07452                                  NUMPULSERBOXES,FIRSTPULSERBOX, 
07453                                  LASTPULSERBOX+1,
07454                                  10000,-5,1550);
07455   hNumEntVsPb->GetXaxis()->SetTitle("Pulser box");
07456   hNumEntVsPb->GetXaxis()->CenterTitle();
07457   hNumEntVsPb->GetYaxis()->SetTitle("Number of Pulses detected");
07458   hNumEntVsPb->GetYaxis()->CenterTitle();
07459   hNumEntVsPb->SetFillColor(0);
07460   hNumEntVsPb->SetBit(TH1::kCanRebin);
07461 
07462   TH1F *hNumericMuxBox=new TH1F("hNumericMuxBox","NumericMuxBox",
07463                                  6010,-10,6000);
07464   hNumericMuxBox->GetXaxis()->SetTitle("NumericMuxBox");
07465   hNumericMuxBox->GetXaxis()->CenterTitle();
07466   hNumericMuxBox->GetYaxis()->SetTitle("");
07467   hNumericMuxBox->GetYaxis()->CenterTitle();
07468   hNumericMuxBox->SetFillColor(0);
07469   hNumericMuxBox->SetBit(TH1::kCanRebin);
07470 
07471   TH1F *hNumericMuxBoxCor=new TH1F("hNumericMuxBoxCor",
07472                                    "NumericMuxBoxCor",
07473                                    6010,-10,6000);
07474   hNumericMuxBoxCor->GetXaxis()->SetTitle("NumericMuxBox");
07475   hNumericMuxBoxCor->GetXaxis()->CenterTitle();
07476   hNumericMuxBoxCor->GetYaxis()->SetTitle("");
07477   hNumericMuxBoxCor->GetYaxis()->CenterTitle();
07478   hNumericMuxBoxCor->SetFillColor(0);
07479   hNumericMuxBoxCor->SetLineColor(2);
07480   hNumericMuxBoxCor->SetBit(TH1::kCanRebin);
07481 
07482   TH1F *hPeriod=new TH1F("hPeriod","Period",3010,-5,3005);
07483   hPeriod->GetXaxis()->SetTitle("Period");
07484   hPeriod->GetXaxis()->CenterTitle();
07485   hPeriod->GetYaxis()->SetTitle("");
07486   hPeriod->GetYaxis()->CenterTitle();
07487   hPeriod->SetFillColor(0);
07488   hPeriod->SetBit(TH1::kCanRebin);
07489 
07490   TH1F *hPinGain=new TH1F("hPinGain","PinGain",10,-5,5);
07491   hPinGain->GetXaxis()->SetTitle("PinGain");
07492   hPinGain->GetXaxis()->CenterTitle();
07493   hPinGain->GetYaxis()->SetTitle("");
07494   hPinGain->GetYaxis()->CenterTitle();
07495   hPinGain->SetFillColor(0);
07496   hPinGain->SetBit(TH1::kCanRebin);
07497 
07498   TH1F *hPinGainCor=new TH1F("hPinGainCor","PinGainCor",10,-5,5);
07499   hPinGainCor->GetXaxis()->SetTitle("PinGain");
07500   hPinGainCor->GetXaxis()->CenterTitle();
07501   hPinGainCor->GetYaxis()->SetTitle("");
07502   hPinGainCor->GetYaxis()->CenterTitle();
07503   hPinGainCor->SetFillColor(0);
07504   hPinGainCor->SetLineColor(2);
07505   hPinGainCor->SetBit(TH1::kCanRebin);
07506 
07507   TH1F *hPinInBox=new TH1F("hPinInBox","PinInBox",10,-5,5);
07508   hPinInBox->GetXaxis()->SetTitle("PinInBox");
07509   hPinInBox->GetXaxis()->CenterTitle();
07510   hPinInBox->GetYaxis()->SetTitle("");
07511   hPinInBox->GetYaxis()->CenterTitle();
07512   hPinInBox->SetFillColor(0);
07513   hPinInBox->SetBit(TH1::kCanRebin);
07514 
07515   TH1F *hPinInBoxCor=new TH1F("hPinInBoxCor","PinInBoxCor",10,-5,5);
07516   hPinInBoxCor->GetXaxis()->SetTitle("PinInBox");
07517   hPinInBoxCor->GetXaxis()->CenterTitle();
07518   hPinInBoxCor->GetYaxis()->SetTitle("");
07519   hPinInBoxCor->GetYaxis()->CenterTitle();
07520   hPinInBoxCor->SetFillColor(0);
07521   hPinInBoxCor->SetLineColor(2);
07522   hPinInBoxCor->SetBit(TH1::kCanRebin);
07523 
07524   TH1F *hPixel=new TH1F("hPixel","Pixels hit",75,-5,70);
07525   hPixel->GetXaxis()->SetTitle("Pixel");
07526   hPixel->GetXaxis()->CenterTitle();
07527   hPixel->GetYaxis()->SetTitle("Number of times hit");
07528   hPixel->GetYaxis()->CenterTitle();
07529   hPixel->SetFillColor(0);
07530   hPixel->SetBit(TH1::kCanRebin);
07531 
07532   TH1F *hPlane=new TH1F("hPlane","Planes hit",805,-5,800);
07533   hPlane->GetXaxis()->SetTitle("Plane");
07534   hPlane->GetXaxis()->CenterTitle();
07535   hPlane->GetYaxis()->SetTitle("Number of times hit");
07536   hPlane->GetYaxis()->CenterTitle();
07537   hPlane->SetFillColor(0);
07538 
07539   TH1F *hPulseHeight=new TH1F("hPulseHeight","PulseHeight",
07540                                1055,-5,1050);
07541   hPulseHeight->GetXaxis()->SetTitle("PulseHeight");
07542   hPulseHeight->GetXaxis()->CenterTitle();
07543   hPulseHeight->GetYaxis()->SetTitle("");
07544   hPulseHeight->GetYaxis()->CenterTitle();
07545   hPulseHeight->SetFillColor(0);
07546   hPulseHeight->SetBit(TH1::kCanRebin);
07547 
07548   TH1F *hPulserBox=new TH1F("hPulserBox","PulserBox",25,-5,20);
07549   hPulserBox->GetXaxis()->SetTitle("PulserBox");
07550   hPulserBox->GetXaxis()->CenterTitle();
07551   hPulserBox->GetYaxis()->SetTitle("");
07552   hPulserBox->GetYaxis()->CenterTitle();
07553   hPulserBox->SetFillColor(0);
07554   hPulserBox->SetBit(TH1::kCanRebin);
07555 
07556   TH1F *hPulses=new TH1F("hPulses","Pulses",11000,0,11000);
07557   hPulses->GetXaxis()->SetTitle("Pulses");
07558   hPulses->GetXaxis()->CenterTitle();
07559   hPulses->GetYaxis()->SetTitle("");
07560   hPulses->GetYaxis()->CenterTitle();
07561   hPulses->SetFillColor(0);
07562   hPulses->SetBit(TH1::kCanRebin);
07563 
07564   TH1F *hPulseWidth=new TH1F("hPulseWidth","PulseWidth",10,-2,8);
07565   hPulseWidth->GetXaxis()->SetTitle("PulseWidth");
07566   hPulseWidth->GetXaxis()->CenterTitle();
07567   hPulseWidth->GetYaxis()->SetTitle("Num Entries");
07568   hPulseWidth->GetYaxis()->CenterTitle();
07569   hPulseWidth->SetFillColor(0);
07570   hPulseWidth->SetBit(TH1::kCanRebin);
07571 
07572   TH1F *hRackBay=new TH1F("hRackBay","RackBay",22,-2,20);
07573   hRackBay->GetXaxis()->SetTitle("rackBay");
07574   hRackBay->GetXaxis()->CenterTitle();
07575   hRackBay->GetYaxis()->SetTitle("");
07576   hRackBay->GetYaxis()->CenterTitle();
07577   hRackBay->SetFillColor(0);
07578   hRackBay->SetBit(TH1::kCanRebin);
07579 
07580   TH1F *hRackBayCor=new TH1F("hRackBayCor","RackBayCor",20,-5,15);
07581   hRackBayCor->GetXaxis()->SetTitle("rackBay");
07582   hRackBayCor->GetXaxis()->CenterTitle();
07583   hRackBayCor->GetYaxis()->SetTitle("");
07584   hRackBayCor->GetYaxis()->CenterTitle();
07585   hRackBayCor->SetFillColor(0);
07586   hRackBayCor->SetLineColor(2);
07587   hRackBayCor->SetBit(TH1::kCanRebin);
07588 
07589   TH1F *hRackLevel=new TH1F("hRackLevel","RackLevel",5,-2,3);
07590   hRackLevel->GetXaxis()->SetTitle("RackLevel");
07591   hRackLevel->GetXaxis()->CenterTitle();
07592   hRackLevel->GetYaxis()->SetTitle("");
07593   hRackLevel->GetYaxis()->CenterTitle();
07594   hRackLevel->SetFillColor(0);
07595   hRackLevel->SetBit(TH1::kCanRebin);
07596 
07597   TH1F *hRackLevelCor=new TH1F("hRackLevelCor","RackLevelCor",5,-2,3);
07598   hRackLevelCor->GetXaxis()->SetTitle("RackLevel");
07599   hRackLevelCor->GetXaxis()->CenterTitle();
07600   hRackLevelCor->GetYaxis()->SetTitle("");
07601   hRackLevelCor->GetYaxis()->CenterTitle();
07602   hRackLevelCor->SetFillColor(0);
07603   hRackLevelCor->SetLineColor(2);
07604   hRackLevelCor->SetBit(TH1::kCanRebin);
07605 
07606   TH1F *hReadoutType=new TH1F("hReadoutType",
07607                                "ReadOut Type",100,-2,20);
07608   hReadoutType->GetXaxis()->SetTitle("ReadoutType");
07609   hReadoutType->GetXaxis()->CenterTitle();
07610   hReadoutType->GetYaxis()->SetTitle("Num Entries");
07611   hReadoutType->GetYaxis()->CenterTitle();
07612   hReadoutType->SetFillColor(0);
07613   hReadoutType->SetBit(TH1::kCanRebin);
07614 
07615   TH1F *hRms=new TH1F("hRms","Rms",9010,-5,9005);
07616   hRms->GetXaxis()->SetTitle("Rms");
07617   hRms->GetXaxis()->CenterTitle();
07618   hRms->GetYaxis()->SetTitle("Entries");
07619   hRms->GetYaxis()->CenterTitle();
07620   hRms->SetFillColor(0);
07621   hRms->SetBit(TH1::kCanRebin);
07622 
07623   TH1F *hRunNumber=new TH1F("hRunNumber","RunNumber",
07624                              30010,-5,15000);
07625   hRunNumber->GetXaxis()->SetTitle("RunNumber");
07626   hRunNumber->GetXaxis()->CenterTitle();
07627   hRunNumber->GetYaxis()->SetTitle("Entries");
07628   hRunNumber->GetYaxis()->CenterTitle();
07629   hRunNumber->SetFillColor(0);
07630   hRunNumber->SetBit(TH1::kCanRebin);
07631 
07632   TH1F *hRunNumberSub=new TH1F("hRunNumberSub","RunNumberSub",
07633                                 420,-5,100);
07634   hRunNumberSub->GetXaxis()->SetTitle("RunNumberSub");
07635   hRunNumberSub->GetXaxis()->CenterTitle();
07636   hRunNumberSub->GetYaxis()->SetTitle("Entries");
07637   hRunNumberSub->GetYaxis()->CenterTitle();
07638   hRunNumberSub->SetFillColor(0);
07639   hRunNumberSub->SetBit(TH1::kCanRebin);
07640 
07641   TH1F *hRunType=new TH1F("hRunType","RunType",
07642                            55,-5,50);
07643   hRunType->GetXaxis()->SetTitle("RunType");
07644   hRunType->GetXaxis()->CenterTitle();
07645   hRunType->GetYaxis()->SetTitle("Entries");
07646   hRunType->GetYaxis()->CenterTitle();
07647   hRunType->SetFillColor(0);
07648   hRunType->SetBit(TH1::kCanRebin);
07649 
07650   TH1F *hStrip=new TH1F("hStrip","Strips hit",205,-5,200);
07651   hStrip->GetXaxis()->SetTitle("Strip");
07652   hStrip->GetXaxis()->CenterTitle();
07653   hStrip->GetYaxis()->SetTitle("Number of times hit");
07654   hStrip->GetYaxis()->CenterTitle();
07655   hStrip->SetFillColor(0);
07656   hStrip->SetBit(TH1::kCanRebin);
07657 
07658   TH1F *hStripEnd=new TH1F("hStripEnd","StripEnds hit",40,-2,4);
07659   hStripEnd->GetXaxis()->SetTitle("StripEnd");
07660   hStripEnd->GetXaxis()->CenterTitle();
07661   hStripEnd->GetYaxis()->SetTitle("Number of times hit");
07662   hStripEnd->GetYaxis()->CenterTitle();
07663   hStripEnd->SetFillColor(0);
07664   hStripEnd->SetBit(TH1::kCanRebin);
07665 
07666   TH1F *hSummaryCounter=new TH1F("hSummaryCounter","SummaryCounter",
07667                                   1000,-5,100);
07668   hSummaryCounter->GetXaxis()->SetTitle("SummaryCounter");
07669   hSummaryCounter->GetXaxis()->CenterTitle();
07670   hSummaryCounter->GetYaxis()->SetTitle("Entries");
07671   hSummaryCounter->GetYaxis()->CenterTitle();
07672   hSummaryCounter->SetFillColor(0);
07673   hSummaryCounter->SetBit(TH1::kCanRebin);
07674 
07675   TH1F *hSummaryCounterCor=new TH1F("hSummaryCounterCor",
07676                                      "SummaryCounterCor",
07677                                      1010,-5,1005);
07678   hSummaryCounterCor->GetXaxis()->SetTitle("SummaryCounter");
07679   hSummaryCounterCor->GetXaxis()->CenterTitle();
07680   hSummaryCounterCor->GetYaxis()->SetTitle("Entries");
07681   hSummaryCounterCor->GetYaxis()->CenterTitle();
07682   hSummaryCounterCor->SetFillColor(0);
07683   hSummaryCounterCor->SetLineColor(2);
07684   hSummaryCounterCor->SetBit(TH1::kCanRebin);
07685 
07686   TH1F *hTimestamp=new TH1F("hTimestamp","Timestamp",
07687                              1000000,1.0339e9,1.0341e9);
07688   hTimestamp->GetXaxis()->SetTitle("Timestamp");
07689   hTimestamp->GetXaxis()->CenterTitle();
07690   hTimestamp->GetYaxis()->SetTitle("");
07691   hTimestamp->GetYaxis()->CenterTitle();
07692   hTimestamp->SetFillColor(0);
07693   hTimestamp->SetBit(TH1::kCanRebin);
07694 
07695   TH1F *hVarc=new TH1F("hVarc","Varcs hit",7,-2,5);
07696   hVarc->GetXaxis()->SetTitle("Varc");
07697   hVarc->GetXaxis()->CenterTitle();
07698   hVarc->GetYaxis()->SetTitle("Number of times hit");
07699   hVarc->GetYaxis()->CenterTitle();
07700   hVarc->SetFillColor(0);
07701 
07702   TH1F *hVfb=new TH1F("hVfb","Vfbs hit",7,-2,5);
07703   hVfb->GetXaxis()->SetTitle("Vfb");
07704   hVfb->GetXaxis()->CenterTitle();
07705   hVfb->GetYaxis()->SetTitle("Number of times hit");
07706   hVfb->GetYaxis()->CenterTitle();
07707   hVfb->SetFillColor(0);
07708 
07709   TH1F *hVmm=new TH1F("hVmm","Vmms hit",10,-2,8);
07710   hVmm->GetXaxis()->SetTitle("Vmm");
07711   hVmm->GetXaxis()->CenterTitle();
07712   hVmm->GetYaxis()->SetTitle("Number of times hit");
07713   hVmm->GetYaxis()->CenterTitle();
07714   hVmm->SetFillColor(0);
07715 
07719 
07720   ReadoutType::EReadoutType ert=
07721     static_cast<ReadoutType::EReadoutType>(rt);
07722 
07723   MSG("LIAnalysis",Msg::kInfo)
07724     <<endl<<"CheckData for readoutType = "
07725     <<ReadoutType::AsString(ert)<<endl<<endl;
07726  
07727   this->InitialiseLoopVariables();  
07728   
07729   for(Int_t entry=0;entry<numEvents;entry++){
07730     
07731     this->SetLoopVariables(entry,0);
07732 
07733     //user selection of what to include in histos
07734     if (rt==-1);//include everything - this is the default
07735     else if (readoutType!=rt) continue;
07736 
07737     //if (led!=0) continue;
07738     //if (crate==0 || crate==2 || geoAdd<=18) continue;
07739 
07740     if (mean<5) {
07741       this->PrintBigMessage();
07742     }
07743 
07744     if (masterCh>60000) masterCh=-2;
07745     if (minderCh>60000) minderCh=-2;
07746     if (geoAdd>60000) geoAdd=-2;
07747     if (varc>60000) varc=-2;
07748     if (vmm>60000) vmm=-2;
07749     if (vfb>60000) vfb=-2;
07750     if (chip>60000) chip=-2;
07751     if (channel>60000) channel=-2;
07752 
07753     hAshtray->Fill(ashtray);
07754     hCalibPoint->Fill(calibPoint);
07755     hPulserBox->Fill(pulserBox);
07756     hLed->Fill(led);
07757     hPulseHeight->Fill(pulseHeight);
07758     hPulseWidth->Fill(pulseWidth);
07759     hPeriod->Fill(period);
07760     hCalibType->Fill(calibType);
07761     hTimestamp->Fill(timestamp);
07762     hPulses->Fill(pulses);
07763     
07764     hPlane->Fill(plane);
07765     hStrip->Fill(strip);
07766     hStripEnd->Fill(stripEnd);
07767     hPixel->Fill(pixel);
07768     hCrate->Fill(crate);
07769     hVarc->Fill(varc);
07770     hVmm->Fill(vmm);
07771     hVfb->Fill(vfb);
07772     hChip->Fill(chip);
07773     hChannel->Fill(channel);
07774 
07775     hMasterCh->Fill(masterCh);
07776     hMinderCh->Fill(minderCh);
07777     hGeoAdd->Fill(geoAdd);
07778     hElecType->Fill(elecType);
07779     
07780     hChAdd->Fill(chAdd);
07781     
07782     hNearLed->Fill(nearLed);
07783     hFarLed->Fill(farLed);
07784     hNearPulserBox->Fill(nearPulserBox);
07785     hFarPulserBox->Fill(farPulserBox);
07786     hCorrelatedHit->Fill(correlatedHit);
07787     hReadoutType->Fill(readoutType);
07788     hMean->Fill(mean);
07789 
07790     if (correlatedHit==1){
07791       hMeanCorrelated->Fill(mean);
07792       hSummaryCounterCor->Fill(summaryCounter);
07793       hNumEntriesCor->Fill(numEntries);
07794 
07795       //mux and pin stuff
07796       hRackLevelCor->Fill(rackLevel);
07797       hEastWestCor->Fill(eastWest);
07798       hNumericMuxBoxCor->Fill(numericMuxBox);
07799       hInRackCor->Fill(inRack);
07800       hRackBayCor->Fill(rackBay);
07801       hPinGainCor->Fill(pinGain);
07802       hPinInBoxCor->Fill(pinInBox);
07803 
07804       if (nearPulserBox==pulserBox){
07805         hMeanNearPB->Fill(mean);
07806       }
07807       else if (farPulserBox==pulserBox){
07808         hMeanFarPB->Fill(mean);
07809       }
07810     }
07811 
07812     hRms->Fill(rms);
07813     hNumEntries->Fill(numEntries);
07814     hNumEntVsPb->Fill(pulserBox,numEntries);
07815     hRunNumber->Fill(runNumber);
07816     hRunNumberSub->Fill(runNumberSub);
07817     hRunType->Fill(runType);
07818     hSummaryCounter->Fill(summaryCounter);
07819 
07820     hRackLevel->Fill(rackLevel);
07821     hEastWest->Fill(eastWest);
07822     hNumericMuxBox->Fill(numericMuxBox);
07823     hInRack->Fill(inRack);
07824     hRackBay->Fill(rackBay);
07825     hPinGain->Fill(pinGain);
07826     hPinInBox->Fill(pinInBox);
07827   }//end of for
07828   
07832   
07833   MSG("LIAnalysis",Msg::kInfo)<<"Finished main loop"<<endl;
07834 
07835   //do plots of all the data in the root file
07836   Int_t print=0;
07837   
07838   TCanvas *cPlane=new TCanvas("cPlane","cPlane",0,0,1200,800);
07839   cPlane->SetFillColor(0);
07840   cPlane->Divide(2,2);
07841   cPlane->cd(1);
07842   hPlane->Draw();
07843   cPlane->cd(2);
07844   hStrip->Draw();
07845   cPlane->cd(3);
07846   hPixel->Draw();
07847   cPlane->cd(4);
07848   hStripEnd->Draw();  
07849 
07850   TCanvas *cElec=new TCanvas("cElec","cElec",0,0,1200,800);
07851   cElec->SetFillColor(0);
07852   cElec->Divide(1,3);
07853   cElec->cd(1);
07854   hCrate->Draw();
07855   cElec->cd(2);
07856   hVarc->Draw();
07857   cElec->cd(3);
07858   hVmm->Draw();
07859   
07860   TCanvas *cElec2=new TCanvas("cElec2","cElec2",0,0,1200,800);
07861   cElec2->SetFillColor(0);
07862   cElec2->Divide(1,3);
07863   cElec2->cd(1);
07864   hVfb->Draw();
07865   cElec2->cd(2);
07866   hChip->Draw();
07867   cElec2->cd(3);
07868   hChannel->Draw();
07869 
07870   TCanvas *cMean=new TCanvas("cMean","cMean",0,0,1200,800);
07871   cMean->SetFillColor(0);
07872   cMean->Divide(2,2);
07873   cMean->cd(1);
07874   hMean->Draw();  
07875   hMeanCorrelated->Draw("same");
07876   //hMeanNearPB->Draw("same");
07877   //hMeanFarPB->Draw("same");
07878   
07879   cMean->cd(2);
07880   hRms->Draw();
07881   cMean->cd(3);
07882   hNumEntries->Draw();
07883   hNumEntriesCor->Draw("same");
07884   cMean->cd(4);
07885   hSummaryCounter->Draw();
07886   hSummaryCounterCor->Draw("same");
07887 
07888 
07889     TCanvas *c18=new TCanvas("c18","c18",0,0,1200,800);
07890     c18->SetFillColor(0);
07891     c18->Divide(1,3);
07892     c18->cd(1);
07893     hCalibPoint->Draw();
07894     c18->cd(2);
07895     hPeriod->Draw();
07896     c18->cd(3);
07897     hCalibType->Draw();
07898   if (print){  
07899     TCanvas *c19=new TCanvas("c19","c19",0,0,1200,800);
07900     c19->SetFillColor(0);
07901     c19->Divide(1,2);
07902     c19->cd(1);
07903     hTimestamp->Draw();
07904     hTimestamp->GetXaxis()->SetTimeFormat("%H:%M-%d/%m");
07905     hTimestamp->GetXaxis()->SetTimeDisplay(1);
07906     //hTimestamp->GetXaxis()->SetNdivisions(520);
07907     c19->cd(2);
07908     hChAdd->Draw();
07909 }
07910   TCanvas *c20=new TCanvas("c20","c20",0,0,1200,800);
07911   c20->SetFillColor(0);
07912   c20->Divide(2,2);
07913   c20->cd(1);
07914   hPulserBox->Draw();
07915   c20->cd(2);
07916   hPulseHeight->Draw();
07917   c20->cd(3);
07918   hPulseWidth->Draw();
07919   c20->cd(4);
07920   hPulses->Draw();  
07921 
07922   TCanvas *c21=new TCanvas("c21","c21",0,0,1200,800);
07923   c21->SetFillColor(0);
07924   c21->Divide(1,2);
07925   c21->cd(1);
07926   hPinGain->Draw();
07927   hPinGainCor->Draw("same");
07928   c21->cd(2);
07929   hPinInBox->Draw();
07930   hPinInBoxCor->Draw("same");
07931 
07932   TCanvas *c22=new TCanvas("c22","c22",0,0,1200,800);
07933   c22->SetFillColor(0);
07934   c22->Divide(3,2);
07935   c22->cd(1);
07936   hRackLevel->Draw();
07937   hRackLevelCor->Draw("same");
07938   c22->cd(2);
07939   hEastWest->Draw();
07940   hEastWestCor->Draw("same");
07941   c22->cd(3);
07942   hNumericMuxBox->Draw();
07943   hNumericMuxBoxCor->Draw("same");
07944   c22->cd(4);
07945   hInRack->Draw();
07946   hInRackCor->Draw("same");
07947   c22->cd(5);
07948   hRackBay->Draw();
07949   hRackBayCor->Draw("same");
07950 
07951   TCanvas *c16=new TCanvas("c16","c16",0,0,1200,800);
07952   c16->SetFillColor(0);
07953   c16->Divide(2,2);
07954   c16->cd(1);
07955   hLed->Draw();
07956   c16->cd(2);
07957   hNearLed->Draw();
07958   c16->cd(3);
07959   hFarLed->Draw();
07960   c16->cd(4);
07961   hAshtray->Draw();
07962 
07963   TCanvas *c23=new TCanvas("c23","c23",0,0,1200,800);
07964   c23->SetFillColor(0);
07965   c23->Divide(3,3);
07966   c23->cd(1);
07967   hFarPulserBox->Draw();
07968   c23->cd(2);
07969   hNearPulserBox->Draw();
07970   c23->cd(3);
07971   hReadoutType->Draw();
07972   c23->cd(4);
07973   hRunNumber->Draw();
07974   c23->cd(5);
07975   hRunNumberSub->Draw();
07976   c23->cd(6);
07977   hRunType->Draw();
07978   c23->cd(7);
07979   hCorrelatedHit->Draw();
07980  
07981   TCanvas *cElecNear=new TCanvas("cElecNear","cElecNear",0,0,1200,800);
07982   cElecNear->SetFillColor(0);
07983   cElecNear->Divide(2,2);
07984   cElecNear->cd(1);
07985   hGeoAdd->Draw();
07986   cElecNear->cd(2);
07987   hMasterCh->Draw();
07988   cElecNear->cd(3);
07989   hMinderCh->Draw();
07990   cElecNear->cd(4);
07991   hElecType->Draw();
07992 
07993   if (print==1){
07994   TCanvas *cNumEntVsPb=new TCanvas("cNumEntVsPb","NumEntVsPb",
07995                                   0,0,1100,600);
07996   cNumEntVsPb->cd();
07997   cNumEntVsPb->SetFillColor(0);
07998   hNumEntVsPb->Draw("colz");
07999   }
08000 
08001   MSG("LIAnalysis",Msg::kInfo) 
08002     <<endl<<" ** Finished the CheckData method ** "<<endl;
08003 }

void LIAnalysis::ClearFibres  ) 
 

Definition at line 824 of file LIAnalysis.cxx.

References led, MSG, and s.

00825 {
00826   MSG("LIAnalysis",Msg::kInfo) 
00827     <<endl<<" ** Running the ClearFibres method... ** "<<endl;
00828 
00829   //these are the PHs that give you 8000 ADCs minus the
00830   //turn on point for each led
00831   //rather than the explicit turn on point I chose the 
00832   //value at which 1000 ADCs because light
00833   //level as a function of pulse height would seem
00834   //less likely to be linear when the led first turns on
00835   //I know that light level is proportional to PH 
00836   //for most of the PHs from looking at the pin response
00837   //(data for PB 11 with the new-new UV leds)
00838   Double_t ph[20]={155,175,140,125,145,
00839                    100,110,100,120,80,
00840                    80,80,60,125,120,
00841                    110,110,125,95,135};
00842 
00843   Double_t led[20]={1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20};
00844 
00845   TCanvas *cPhVsLed=new TCanvas("cPhVsLed","cPhVsLed",
00846                                     0,0,1200,600);
00847   cPhVsLed->SetFillColor(0);
00848   cPhVsLed->cd();
00849 
00850   TGraph* gPhVsLed=new TGraph(20,led,ph);
00851   gPhVsLed->Draw("AP");
00852   s="Corrected Pulse Height Vs Led Number";
00853   gPhVsLed->SetTitle(s.c_str());
00854   gPhVsLed->GetXaxis()->SetTitle("Led Number");
00855   gPhVsLed->GetYaxis()->SetTitle
00856     ("Corrected Pulse Height (for 8000 ADCs)");
00857   gPhVsLed->GetXaxis()->CenterTitle();
00858   gPhVsLed->GetYaxis()->CenterTitle();
00859   gPhVsLed->SetMarkerStyle(3);
00860   gPhVsLed->SetMarkerColor(2);
00861   gPhVsLed->SetMarkerSize(0.5);
00862   gPhVsLed->SetMinimum(0);
00863 
00864   MSG("LIAnalysis",Msg::kInfo) 
00865     <<" ** Finished the ClearFibres method ** "<<endl;
00866 }

void LIAnalysis::DebugPins  ) 
 

Definition at line 1815 of file LIAnalysis.cxx.

References chip, correlatedHit, crate, detectorType, eastWest, Form(), geoAdd, GetElecString(), InitialiseLoopVariables(), inRack, MsgService::Instance(), MsgService::IsActive(), led, lowRunNumber, masterCh, mean, MSG, numEntries, pinGain, pinInBox, PrintBigMessage(), pulserBox, pulses, rackBay, rackLevel, readoutType, rms, runNumber, and SetLoopVariables().

01816 {
01817   MSG("LIAnalysis",Msg::kInfo) 
01818     <<endl<<" ** Running the DebugPins method... ** "<<endl;
01819 
01820   Float_t* maxAdcHighPin=new Float_t[NUMLEDS*NUMPULSERBOXES];
01821   Float_t* maxAdcLowPin=new Float_t[NUMLEDS*NUMPULSERBOXES]; 
01822   Float_t* corrHitHighPin=new Float_t[NUMLEDS*NUMPULSERBOXES];
01823   Float_t* corrHitLowPin=new Float_t[NUMLEDS*NUMPULSERBOXES]; 
01824   Float_t* ledHighPin=new Float_t[NUMLEDS*NUMPULSERBOXES];
01825   Float_t* nearLedHighPin=new Float_t[NUMLEDS*NUMPULSERBOXES];
01826   Float_t* ledLowPin=new Float_t[NUMLEDS*NUMPULSERBOXES]; 
01827   Float_t* nearLedLowPin=new Float_t[NUMLEDS*NUMPULSERBOXES]; 
01828  
01829   Float_t* eastWestHighPin=new Float_t[NUMLEDS*NUMPULSERBOXES];
01830   Float_t* eastWestLowPin=new Float_t[NUMLEDS*NUMPULSERBOXES]; 
01831   Float_t* rackLevelHighPin=new Float_t[NUMLEDS*NUMPULSERBOXES];
01832   Float_t* rackLevelLowPin=new Float_t[NUMLEDS*NUMPULSERBOXES]; 
01833   Float_t* rackBayHighPin=new Float_t[NUMLEDS*NUMPULSERBOXES];
01834   Float_t* rackBayLowPin=new Float_t[NUMLEDS*NUMPULSERBOXES]; 
01835   Float_t* inRackHighPin=new Float_t[NUMLEDS*NUMPULSERBOXES];
01836   Float_t* inRackLowPin=new Float_t[NUMLEDS*NUMPULSERBOXES]; 
01837   Float_t* inBoxHighPin=new Float_t[NUMLEDS*NUMPULSERBOXES];
01838   Float_t* inBoxLowPin=new Float_t[NUMLEDS*NUMPULSERBOXES]; 
01839   Float_t* gainHighPin=new Float_t[NUMLEDS*NUMPULSERBOXES];
01840   Float_t* gainLowPin=new Float_t[NUMLEDS*NUMPULSERBOXES]; 
01841 
01842   Float_t* crateHighPin=new Float_t[NUMLEDS*NUMPULSERBOXES];
01843   Float_t* crateLowPin=new Float_t[NUMLEDS*NUMPULSERBOXES]; 
01844   Float_t* varcHighPin=new Float_t[NUMLEDS*NUMPULSERBOXES];
01845   Float_t* varcLowPin=new Float_t[NUMLEDS*NUMPULSERBOXES]; 
01846   Float_t* vmmHighPin=new Float_t[NUMLEDS*NUMPULSERBOXES];
01847   Float_t* vmmLowPin=new Float_t[NUMLEDS*NUMPULSERBOXES]; 
01848   Float_t* vfbHighPin=new Float_t[NUMLEDS*NUMPULSERBOXES];
01849   Float_t* vfbLowPin=new Float_t[NUMLEDS*NUMPULSERBOXES]; 
01850   Float_t* chipHighPin=new Float_t[NUMLEDS*NUMPULSERBOXES];
01851   Float_t* chipLowPin=new Float_t[NUMLEDS*NUMPULSERBOXES]; 
01852   Float_t* chAddHighPin=new Float_t[NUMLEDS*NUMPULSERBOXES];
01853   Float_t* chAddLowPin=new Float_t[NUMLEDS*NUMPULSERBOXES]; 
01854 
01855   Float_t* planeHighPin=new Float_t[NUMLEDS*NUMPULSERBOXES];
01856   Float_t* planeLowPin=new Float_t[NUMLEDS*NUMPULSERBOXES]; 
01857 
01858   //initialise arrays
01859   for (Int_t i=0;i<NUMLEDS*NUMPULSERBOXES;i++){ 
01860     maxAdcHighPin[i]=0;
01861     maxAdcLowPin[i]=0;
01862     corrHitHighPin[i]=-1;
01863     corrHitLowPin[i]=-1;
01864     ledHighPin[i]=0;
01865     nearLedHighPin[i]=0;
01866     ledLowPin[i]=0; 
01867     nearLedLowPin[i]=0; 
01868 
01869     eastWestHighPin[i]=0;
01870     eastWestLowPin[i]=0; 
01871     rackLevelHighPin[i]=0;
01872     rackLevelLowPin[i]=0; 
01873     rackBayHighPin[i]=0;
01874     rackBayLowPin[i]=0; 
01875     inRackHighPin[i]=0;
01876     inRackLowPin[i]=0; 
01877     inBoxHighPin[i]=0;
01878     inBoxLowPin[i]=0; 
01879     gainHighPin[i]=0;
01880     gainLowPin[i]=0;
01881 
01882     crateHighPin[i]=0;
01883     crateLowPin[i]=0; 
01884     varcHighPin[i]=0;
01885     varcLowPin[i]=0; 
01886     vmmHighPin[i]=0;
01887     vmmLowPin[i]=0; 
01888     vfbHighPin[i]=0;
01889     vfbLowPin[i]=0; 
01890     chipHighPin[i]=0;
01891     chipLowPin[i]=0; 
01892     chAddHighPin[i]=0;
01893     chAddLowPin[i]=0; 
01894 
01895     planeHighPin[i]=0;
01896     planeLowPin[i]=0; 
01897   }
01898 
01902    
01903   this->InitialiseLoopVariables();   
01904    
01905   for(Int_t entry=0;entry<numEvents;entry++){ 
01906      
01907     this->SetLoopVariables(entry,0); 
01908 
01909     //CalDet ND pins
01910     if (crate==1 && geoAdd==19 && masterCh==4 && 
01911         detectorType==Detector::kCalDet){
01912       this->PrintBigMessage();
01913     }
01914 
01915     //ignore any zeros that slipped through 
01916     if (mean==0 || rms==0 || numEntries==0) continue; 
01917     
01918     //only look at scint strips 
01919     if (readoutType!=ReadoutType::kPinDiode) continue; 
01920 
01921     //printout everything!
01922     if (MsgService::Instance()->IsActive("LIAnalysis",Msg::kDebug)){
01923       MSG("LIAnalysis",Msg::kInfo)  
01924         <<"("<<pulserBox<<":"<<led
01925         <<") CH="<<correlatedHit
01926         <<" ("<<static_cast<Int_t>(mean)
01927         <<","<<static_cast<Int_t>(rms)
01928         <<","<<numEntries
01929         <<"/"<<pulses
01930         <<"),"
01931         <<" "<<this->GetElecString()
01932         <<", mux=("<<eastWest
01933         <<","<<rackLevel
01934         <<","<<rackBay
01935         <<","<<inRack
01936         <<","<<pinInBox
01937         <<")"
01938         <<", gain="<<pinGain
01939         <<endl;   
01940     }
01941 
01942     //cut out strange pins with high mean
01943     if (numEntries<0.8*pulses) continue;
01944 
01945     if (pulserBox>=FIRSTPULSERBOX && pulserBox<=LASTPULSERBOX &&
01946         led>=FIRSTLED && led<=LASTLED){
01947       //define led number
01948       Int_t l=pulserBox*NUMLEDS+led-1;
01949       
01950       //will require a correlated hit when plex is working
01951       //fill histo for appropriate pin
01952       if (chip==1){//high gain (=0) (chip 1)
01953         //find max value for high gain pin
01954         if (mean>maxAdcHighPin[l]){
01955           maxAdcHighPin[l]=mean; 
01956           corrHitHighPin[l]=correlatedHit;
01957           ledHighPin[l]=led;
01958           nearLedHighPin[l]=nearLed;
01959 
01960           eastWestHighPin[l]=eastWest;
01961           rackLevelHighPin[l]=rackLevel;
01962           rackBayHighPin[l]=rackBay;
01963           inRackHighPin[l]=inRack;
01964           inBoxHighPin[l]=pinInBox;
01965           gainHighPin[l]=pinGain;
01966 
01967           crateHighPin[l]=crate;
01968           varcHighPin[l]=varc;
01969           vmmHighPin[l]=vmm;
01970           vfbHighPin[l]=vfb;
01971           chipHighPin[l]=chip;
01972           chAddHighPin[l]=chAdd;
01973           
01974           planeHighPin[l]=plane;
01975         }
01976       }
01977       else if (chip==0){//low gain (=1) (chip 0)
01978         //find max value for low gain pin
01979         if (mean>maxAdcLowPin[l]) {
01980           maxAdcLowPin[l]=mean; 
01981           corrHitLowPin[l]=correlatedHit;
01982           ledLowPin[l]=led; 
01983           nearLedLowPin[l]=nearLed; 
01984 
01985           eastWestLowPin[l]=eastWest;
01986           rackLevelLowPin[l]=rackLevel;
01987           rackBayLowPin[l]=rackBay;
01988           inRackLowPin[l]=inRack;
01989           inBoxLowPin[l]=pinInBox;
01990           gainLowPin[l]=pinGain;
01991 
01992           crateLowPin[l]=crate;
01993           varcLowPin[l]=varc;
01994           vmmLowPin[l]=vmm;
01995           vfbLowPin[l]=vfb;
01996           chipLowPin[l]=chip;
01997           chAddLowPin[l]=chAdd;
01998 
01999           planeLowPin[l]=plane;
02000         }
02001       }
02002       
02003       //print out warnings if there are inconsistencies
02004       if ((pinGain!=1 && chip==0) || (pinGain!=0 && chip==1)) {
02005         MSG("LIAnalysis",Msg::kVerbose)
02006           <<"Strange pin, wrong gain in plex,"
02007           <<" "<<this->GetElecString()
02008           <<", plex gain="<<pinGain<<", mean="<<mean<<", rms="<<rms
02009           <<", num="<<numEntries<<endl;
02010       }
02011     }
02012   }//end of for
02013 
02017  
02018   MSG("LIAnalysis",Msg::kInfo)<<"Finished main loop"<<endl;
02019 
02020   //include the under and overflow counts 
02021   gStyle->SetOptStat(1111111); 
02022   //set up useful string 
02023   string sRunNumber=Form("%d",runNumber); 
02024   string sLowRunNumber=Form("%d",lowRunNumber);
02025   
02026   //loop over pins and print out low ones
02027   for (Int_t i=0;i<NUMPULSERBOXES;i++){ 
02028     for (Int_t j=0;j<NUMLEDS;j++){ 
02029       Int_t l=i*NUMLEDS+j; 
02030  
02031       //print out which pins have low pulse height 
02032       if (maxAdcHighPin[l]<500 && i!=11){ 
02033         MSG("LIAnalysis",Msg::kInfo) 
02034           <<"High pin has low max: PB="<<i<<", led="<<j+1 
02035           <<", mean="<<maxAdcHighPin[l]<<endl; 
02036       } 
02037       if (maxAdcLowPin[l]<200 && i!=11){  
02038         MSG("LIAnalysis",Msg::kInfo)  
02039           <<"Low pin has low max: PB="<<i<<", led="<<j+1  
02040           <<", mean="<<maxAdcLowPin[l]<<endl;  
02041       }  
02042     }
02043   }
02044 
02045   //loop over pins to compare led and nearLed
02046   MSG("LIAnalysis",Msg::kInfo) 
02047     <<endl<<"Comparing led and nearLed for pins"<<endl;
02048   for (Int_t i=0;i<NUMPULSERBOXES;i++){  
02049     for (Int_t j=0;j<NUMLEDS;j++){  
02050       Int_t l=i*NUMLEDS+j;  
02051   
02052       MSG("LIAnalysis",Msg::kInfo)  
02053         <<"("<<i<<":"<<j+1<<") High gain pin"
02054         <<" has nearLed="<<nearLedHighPin[l]
02055         <<" (mean="<<maxAdcHighPin[l]<<", plane="<<planeHighPin[l]<<")"
02056         <<endl;  
02057       MSG("LIAnalysis",Msg::kInfo)  
02058         <<"("<<i<<":"<<j+1<<") High gain pin"   
02059         <<" has nearLed="<<nearLedLowPin[l]
02060         <<" (mean="<<maxAdcLowPin[l]<<", plane="<<planeLowPin[l]<<")"
02061         <<endl<<endl;   
02062     }   
02063   } 
02064 
02065   TH1F *hVarc=new TH1F("hVarc","Varcs hit",6,-1,5);
02066   hVarc->GetXaxis()->SetTitle("Varc");
02067   hVarc->GetXaxis()->CenterTitle();
02068   hVarc->GetYaxis()->SetTitle("Number of times hit");
02069   hVarc->GetYaxis()->CenterTitle();
02070   hVarc->SetFillColor(0);
02071 
02072   TH1F *hVfb=new TH1F("hVfb","Vfbs hit",6,-1,5);
02073   hVfb->GetXaxis()->SetTitle("Vfb");
02074   hVfb->GetXaxis()->CenterTitle();
02075   hVfb->GetYaxis()->SetTitle("Number of times hit");
02076   hVfb->GetYaxis()->CenterTitle();
02077   hVfb->SetFillColor(0);
02078 
02079   TH1F *hVmm=new TH1F("hVmm","Vmms hit",9,-1,8);
02080   hVmm->GetXaxis()->SetTitle("Vmm");
02081   hVmm->GetXaxis()->CenterTitle();
02082   hVmm->GetYaxis()->SetTitle("Number of times hit");
02083   hVmm->GetYaxis()->CenterTitle();
02084   hVmm->SetFillColor(0);
02085 
02086   TH1F *hVarcW=new TH1F("hVarcW","Varcs hit",6,-1,5);
02087   hVarcW->GetXaxis()->SetTitle("Varc");
02088   hVarcW->GetXaxis()->CenterTitle();
02089   hVarcW->GetYaxis()->SetTitle("Number of times hit");
02090   hVarcW->GetYaxis()->CenterTitle();
02091   hVarcW->SetFillColor(0);
02092   hVarcW->SetLineColor(2);
02093 
02094   TH1F *hVfbW=new TH1F("hVfbW","Vfbs hit",6,-1,5);
02095   hVfbW->GetXaxis()->SetTitle("Vfb");
02096   hVfbW->GetXaxis()->CenterTitle();
02097   hVfbW->GetYaxis()->SetTitle("Number of times hit");
02098   hVfbW->GetYaxis()->CenterTitle();
02099   hVfbW->SetFillColor(0);
02100   hVfbW->SetLineColor(2);
02101 
02102   TH1F *hVmmW=new TH1F("hVmmW","Vmms hit",9,-1,8);
02103   hVmmW->GetXaxis()->SetTitle("Vmm");
02104   hVmmW->GetXaxis()->CenterTitle();
02105   hVmmW->GetYaxis()->SetTitle("Number of times hit");
02106   hVmmW->GetYaxis()->CenterTitle();
02107   hVmmW->SetFillColor(0);
02108   hVmmW->SetLineColor(2);
02109 
02110   MSG("LIAnalysis",Msg::kInfo) 
02111     <<endl<<"Making pin location histos..."<<endl;
02112   for (Int_t i=0;i<NUMPULSERBOXES;i++){  
02113     for (Int_t j=0;j<NUMLEDS;j++){  
02114       Int_t l=i*NUMLEDS+j;  
02115   
02116       Int_t side=i%2;
02117       
02118       if (side==0){
02119         hVarc->Fill(varcHighPin[l]);
02120         hVarc->Fill(varcLowPin[l]);
02121         hVmm->Fill(vmmHighPin[l]);
02122         hVmm->Fill(vmmLowPin[l]);
02123         hVfb->Fill(vfbHighPin[l]);
02124         hVfb->Fill(vfbLowPin[l]);
02125       }
02126       else if (side==1){
02127         hVarcW->Fill(varcHighPin[l]);
02128         hVarcW->Fill(varcLowPin[l]);
02129         if (varcLowPin[l]==0){
02130           MSG("LIAnalysis",Msg::kInfo)  
02131             <<"Low pin ("<<i<<":"<<j+1
02132             <<") nL="<<nearLedLowPin[l]
02133             <<", corrHit="<<corrHitLowPin[l]
02134             <<" VA("<<crateLowPin[l]
02135             <<","<<varcLowPin[l]
02136             <<","<<vmmLowPin[l]
02137             <<","<<vfbLowPin[l]
02138             <<","<<chipLowPin[l]
02139             <<")="<<chAddLowPin[l]
02140             <<", ("<<eastWestLowPin[l]
02141             <<","<<rackLevelLowPin[l]
02142             <<","<<rackBayLowPin[l]
02143             <<","<<inRackLowPin[l]
02144             <<","<<inBoxLowPin[l]
02145             <<","<<gainLowPin[l]
02146             <<")"
02147             <<endl<<endl;   
02148         }
02149         if (varcHighPin[l]==0){
02150           MSG("LIAnalysis",Msg::kInfo)  
02151             <<"High pin ("<<i<<":"<<j+1  
02152             <<") nL="<<nearLedHighPin[l]
02153             <<", corrHit="<<corrHitHighPin[l]
02154             <<" VA("<<crateHighPin[l]
02155             <<","<<varcHighPin[l]
02156             <<","<<vmmHighPin[l]
02157             <<","<<vfbHighPin[l]
02158             <<","<<chipHighPin[l]
02159             <<")="<<chAddHighPin[l]
02160             <<", ("<<eastWestHighPin[l]
02161             <<","<<rackLevelHighPin[l]
02162             <<","<<rackBayHighPin[l]
02163             <<","<<inRackHighPin[l]
02164             <<","<<inBoxHighPin[l]
02165             <<","<<gainHighPin[l]
02166             <<")"
02167             <<endl;
02168         }
02169         
02170         hVmmW->Fill(vmmHighPin[l]);
02171         hVmmW->Fill(vmmLowPin[l]);
02172         hVfbW->Fill(vfbHighPin[l]);
02173         hVfbW->Fill(vfbLowPin[l]);
02174       }
02175       else{
02176         MSG("LIAnalysis",Msg::kInfo)  
02177           <<"Warning"<<endl;
02178       }
02179     }
02180   }
02181 
02182   MSG("LIAnalysis",Msg::kInfo) 
02183     <<endl<<"Comparing mux and elec info..."<<endl;
02184   for (Int_t i=0;i<NUMPULSERBOXES;i++){  
02185     //leave a line
02186     MSG("LIAnalysis",Msg::kInfo)<<endl;
02187     for (Int_t j=0;j<NUMLEDS;j++){  
02188       //get led index
02189       Int_t l=i*NUMLEDS+j;  
02190   
02191       MSG("LIAnalysis",Msg::kInfo)  
02192         <<"HG ("<<i<<":"<<j+1
02193         <<") nL="<<nearLedHighPin[l]
02194         <<", corrHit="<<corrHitHighPin[l]
02195         <<", VA("<<crateHighPin[l]
02196         <<","<<varcHighPin[l]
02197         <<","<<vmmHighPin[l]
02198         <<","<<vfbHighPin[l]
02199         <<","<<chipHighPin[l]
02200         <<")="<<chAddHighPin[l]
02201         <<", Position=("<<eastWestHighPin[l]
02202         <<","<<rackLevelHighPin[l]
02203         <<","<<rackBayHighPin[l]
02204         <<","<<inRackHighPin[l]
02205         <<","<<inBoxHighPin[l]
02206         <<","<<gainHighPin[l]
02207         <<")"
02208         <<endl;
02209   
02210       MSG("LIAnalysis",Msg::kInfo)   
02211         <<"LG ("<<i<<":"<<j+1   
02212         <<") nL="<<nearLedLowPin[l]
02213         <<", corrHit="<<corrHitLowPin[l]
02214         <<", VA("<<crateLowPin[l]
02215         <<","<<varcLowPin[l]
02216         <<","<<vmmLowPin[l]
02217         <<","<<vfbLowPin[l]
02218         <<","<<chipLowPin[l]
02219         <<")="<<chAddLowPin[l]
02220         <<", Position=("<<eastWestLowPin[l]
02221         <<","<<rackLevelLowPin[l]
02222         <<","<<rackBayLowPin[l]
02223         <<","<<inRackLowPin[l]
02224         <<","<<inBoxLowPin[l]
02225         <<","<<gainLowPin[l]
02226         <<")"
02227         <<endl<<endl;   
02228     }   
02229   } 
02230 
02231   MSG("LIAnalysis",Msg::kInfo) 
02232     <<endl<<endl<<"No data for these pins:"<<endl;
02233   for (Int_t i=0;i<NUMPULSERBOXES;i++){  
02234     //leave a line
02235     MSG("LIAnalysis",Msg::kInfo)<<endl;
02236     for (Int_t j=0;j<NUMLEDS;j++){  
02237       //get led index
02238       Int_t l=i*NUMLEDS+j;  
02239   
02240       if (corrHitHighPin[l]==-1){
02241         MSG("LIAnalysis",Msg::kInfo)  
02242           <<"HG ("<<i<<":"<<j+1
02243           <<") nL="<<nearLedHighPin[l]
02244           <<", corrHit="<<corrHitHighPin[l]
02245           <<", VA("<<crateHighPin[l]
02246           <<","<<varcHighPin[l]
02247           <<","<<vmmHighPin[l]
02248           <<","<<vfbHighPin[l]
02249           <<","<<chipHighPin[l]
02250           <<")="<<chAddHighPin[l]
02251           <<", Position=("<<eastWestHighPin[l]
02252           <<","<<rackLevelHighPin[l]
02253           <<","<<rackBayHighPin[l]
02254           <<","<<inRackHighPin[l]
02255           <<","<<inBoxHighPin[l]
02256           <<","<<gainHighPin[l]
02257           <<")"
02258           <<endl;
02259       }
02260 
02261       if (corrHitLowPin[l]==-1){
02262         MSG("LIAnalysis",Msg::kInfo)   
02263           <<"LG ("<<i<<":"<<j+1   
02264           <<") nL="<<nearLedLowPin[l]
02265           <<", corrHit="<<corrHitLowPin[l]
02266           <<", VA("<<crateLowPin[l]
02267           <<","<<varcLowPin[l]
02268           <<","<<vmmLowPin[l]
02269           <<","<<vfbLowPin[l]
02270           <<","<<chipLowPin[l]
02271           <<")="<<chAddLowPin[l]
02272           <<", Position=("<<eastWestLowPin[l]
02273           <<","<<rackLevelLowPin[l]
02274           <<","<<rackBayLowPin[l]
02275           <<","<<inRackLowPin[l]
02276           <<","<<inBoxLowPin[l]
02277           <<","<<gainLowPin[l]
02278           <<")"
02279           <<endl<<endl;   
02280       }
02281     }   
02282   } 
02283 
02284   //create the canvas and draw
02285   TCanvas *cPin=new TCanvas("cAdcPin","cAdcPin",0,0,1000,600);
02286   cPin->SetFillColor(0);
02287 
02288   cPin->Divide(2,2);
02289   cPin->cd(1);
02290   hVarc->Draw();
02291   hVarcW->Draw("same");
02292   cPin->cd(2);
02293   hVmm->Draw();
02294   hVmmW->Draw("same");
02295   cPin->cd(3);
02296   hVfb->Draw();
02297   hVfbW->Draw("same");
02298 
02299   //The pin diode information in the plex is as follows
02300   //The electronics information is in descending hierarchial order
02301   //(x:y) is pulser box x and led y
02302   //e.g. (crate,varc,vmm,vfb,VA chip,VA channel)
02303 
02304   //(0:1) Planes=41&43  Pin1=VA(0,2,0,0,0,18)  Pin2=VA(0,2,0,0,1,18)
02305   //(0:2) Planes=45&47  Pin1=VA(0,2,0,1,0,18)  Pin2=VA(0,2,0,1,1,18)
02306   //(0:3) Planes=49&51  Pin1=VA(0,2,1,0,0,18)  Pin2=VA(0,2,1,0,1,18)
02307   //(0:4) Planes=40&42  Pin1=VA(0,2,2,0,0,18)  Pin2=VA(0,2,2,1,1,18)
02308   //(0:5) Planes=44&46  Pin1=VA(0,2,3,0,0,18)  Pin2=VA(0,2,3,0,1,18)
02309   //(0:6) Planes=48&50  Pin1=VA(0,2,3,1,0,18)  Pin2=VA(0,2,3,1,1,18)
02310 
02311   MSG("LIAnalysis",Msg::kInfo) 
02312     <<" ** Finished the DebugPins method ** "<<endl;
02313 }

void LIAnalysis::GainCurves Int_t  pulserBoxToPlot = 0,
Int_t  maxLedToPlot = 6
 

Definition at line 12258 of file LIAnalysis.cxx.

References LILookup::CalcGain(), calibPoint, chain, chip, correlatedHit, crate, detectorType, farPulserBox, Form(), GetElecString(), highRunNumber, InitialiseLoopVariables(), MsgService::Instance(), MsgService::IsActive(), led, lookup, lowRunNumber, mean, MSG, LILookup::NearOrFar(), nearPulserBox, numEntries, period, pinGain, plane, print(), LITuning::PrintAll(), pulseHeight, pulserBox, pulses, pulseWidth, readoutType, rms, runNumber, s, SetLoopVariables(), stripEnd, and TGraphVect().

12259 { 
12260   MSG("LIAnalysis",Msg::kInfo)  
12261     <<endl<<" ** Running the GainCurves method... ** "<<endl; 
12262 
12263   chain->GetEvent(0);
12264   const Int_t const_numCalibPoints=calibType;   
12265 
12266   //just select the first pulser box if not told
12267   if (pulserBoxToPlot==-1) pulserBoxToPlot=pulserBox;
12268 
12269   MSG("LIAnalysis",Msg::kInfo) 
12270     <<"Will only look at pulser box "<<pulserBoxToPlot<<endl;
12271 
12272   MSG("LIAnalysis",Msg::kInfo) 
12273     <<"Using "<<const_numCalibPoints<<" calibPoints"<<endl;
12274   MSG("LIAnalysis",Msg::kInfo) 
12275     <<"Number of pulser boxes = "<<NUMPULSERBOXES
12276     <<", leds = "<<NUMLEDS
12277     <<endl<<endl;
12278 
12279   MSG("LIAnalysis",Msg::kInfo)
12280     <<"Creating LIRun objects"<<endl;
12281   vector<LIRun> gCurveData(NUMSIDES*NUMPLANES*NUMSTRIPS);
12282 
12283   Float_t **maxAdcHighPin=0;
12284   maxAdcHighPin=new Float_t*[NUMLEDS*NUMPULSERBOXES];
12285   Float_t **maxAdcLowPin=0;
12286   maxAdcLowPin=new Float_t*[NUMLEDS*NUMPULSERBOXES];
12287 
12288   //initialise arrays
12289   for (Int_t i=0;i<NUMPULSERBOXES;i++){
12290     for (Int_t j=0;j<NUMLEDS;j++){
12291       Int_t l=i*NUMLEDS+j;
12292 
12293       maxAdcHighPin[l]=new Float_t[const_numCalibPoints];
12294       maxAdcLowPin[l]=new Float_t[const_numCalibPoints];
12295       
12296       for (Int_t k=0;k<const_numCalibPoints;k++){
12297         maxAdcHighPin[l][k]=0;
12298         maxAdcLowPin[l][k]=0;
12299       }
12300     }
12301   }
12302 
12303   Bool_t usePinPlex=true;
12304 
12305   MSG("LIAnalysis",Msg::kInfo)  
12306     <<endl<<"Looping to find pins"<<endl; 
12307 
12311    
12312   this->InitialiseLoopVariables();   
12313    
12314   for(Int_t entry=0;entry<numEvents;entry++){ 
12315 
12316     this->SetLoopVariables(entry,0); 
12317 
12318     //ignore any zeros that slipped through 
12319     if (mean==0 || rms==0 || numEntries==0) continue; 
12320 
12321     //only look at one pulser box at a time
12322     //especially important at the far detector
12323     if (pulserBox!=pulserBoxToPlot) continue;
12324 
12325     //limit the number of leds that are plotted
12326     if (led>maxLedToPlot) continue;
12327 
12328     //cut out strange pins with high mean
12329     if (numEntries<0.5*pulses) continue;
12330 
12331     Int_t c=calibPoint-1;
12332 
12333     //look at pins 
12334     if (readoutType==ReadoutType::kPinDiode){
12335 
12336       if (pulserBox>=FIRSTPULSERBOX && pulserBox<=LASTPULSERBOX &&
12337           led>=FIRSTLED && led<=LASTLED &&
12338           c<const_numCalibPoints){
12339         //define led number
12340         Int_t l=pulserBox*NUMLEDS+led-1;
12341         
12342         if (usePinPlex){
12343           if (correlatedHit==1){
12344             if (chip==1){//high gain (chip 1)
12345               //store high gain pin
12346               maxAdcHighPin[l][c]=mean; 
12347             }
12348             else if (chip==0){//low gain (chip 0)
12349               //store low gain pin
12350               maxAdcLowPin[l][c]=mean; 
12351             }
12352           }
12353         }
12354         else{
12355           //fill histo for appropriate pin
12356           if (chip==1){//high gain (chip 1)
12357             //find max value for high gain pin
12358             if (mean>maxAdcHighPin[l][c]) {
12359               maxAdcHighPin[l][c]=mean; 
12360               MSG("LIAnalysis",Msg::kDebug)
12361                 <<"("<<pulserBox<<":"<<led<<") High pin found ("
12362                 <<", "<<this->GetElecString()
12363                 <<", plex gain="<<pinGain<<", mean="<<mean
12364                 <<", rms="<<rms
12365                 <<", num="<<numEntries<<", cHit="<<correlatedHit<<endl;
12366             }
12367           }
12368           else if (chip==0){//low gain (chip 0)
12369             //find max value for low gain pin
12370             if (mean>maxAdcLowPin[l][c]) {
12371               maxAdcLowPin[l][c]=mean; 
12372               MSG("LIAnalysis",Msg::kDebug)
12373                 <<"("<<pulserBox<<":"<<led<<") Low pin found ("
12374                 <<", "<<this->GetElecString()
12375                 <<", plex gain="<<pinGain<<", mean="<<mean
12376                 <<", rms="<<rms
12377                 <<", num="<<numEntries<<", cHit="<<correlatedHit<<endl;
12378             }
12379           }
12380         }
12381       }
12382     }
12383   }//end of for       
12384    
12388   
12389   MSG("LIAnalysis",Msg::kInfo)  
12390     <<"Finished loop to find pins"<<endl; 
12391 
12392   MSG("LIAnalysis",Msg::kInfo)  
12393     <<endl<<"Starting main loop"<<endl; 
12394 
12398    
12399   this->InitialiseLoopVariables();   
12400    
12401   for(Int_t entry=0;entry<numEvents;entry++){ 
12402 
12403     this->SetLoopVariables(entry,1); 
12404 
12405     //ignore any zeros that slipped through 
12406     if (mean==0 || rms==0 || numEntries==0) continue; 
12407 
12408     //only look at scint strips 
12409     if (readoutType!=ReadoutType::kScintStrip) continue; 
12410 
12411     //only look at one pulser box at a time
12412     //especially important at the far detector
12413     if (pulserBox!=pulserBoxToPlot) continue;
12414 
12415     //limit the number of leds that are plotted
12416     if (led>maxLedToPlot) continue;
12417 
12418     //Int_t side=crate%2;//even=0, odd=1
12419     //at CalDet crate 0 is leds 4,5,6
12420 
12421     if (correlatedHit==1 && mean<500 && 1.*numEntries/pulses<0.99){
12422       if (lookup.NearOrFar(crate,pulserBox,nearPulserBox,
12423                            farPulserBox,led,detectorType,
12424                            plane,runNumber)==
12425           LILookup::kNearSide && pulses>0){
12426         MSG("LIAnalysis",Msg::kInfo) 
12427           <<"mean="<<mean 
12428           <<" ("<<mean*numEntries/pulses<<")"
12429           <<", rms="<<rms 
12430           <<", num="<<numEntries
12431           <<"/"<<pulses
12432           <<"="<<1.*numEntries/pulses
12433           <<endl;
12434         //correct the mean for zeros
12435         mean*=(numEntries/pulses);
12436       }
12437     }
12438 
12439     //indexes
12440     Int_t c=calibPoint-1;
12441     Int_t l=pulserBox*NUMLEDS+led-1;
12442     Int_t se=(stripEnd-1)*NUMSTRIPS*NUMPLANES+plane*NUMSTRIPS+strip;
12443 
12444     //create LIRun objects
12445     if (correlatedHit==1){
12446       if (detectorType==Detector::kFar){
12447 
12448         if (pulserBox>=FIRSTPULSERBOX && pulserBox<=LASTPULSERBOX &&
12449             led>=FIRSTLED && led<=LASTLED &&
12450             calibPoint>=1 && calibPoint<=const_numCalibPoints){
12451           
12452           //fill histos with when pulser box is near pulser box
12453           if (nearPulserBox==pulserBox){
12454             gCurveData[se].SetLIInfo(pulserBox,led,LIRun::kGainCurve); 
12455             gCurveData[se].AddPoint(pulseHeight,mean,
12456                                     maxAdcHighPin[l][c],
12457                                     maxAdcLowPin[l][c],
12458                                     rms,//a bit of a hack (adcF)
12459                                     numEntries);
12460           }
12461           //fill histos with when pulser box is far pulser box
12462           else if (farPulserBox==pulserBox) {
12463 
12464           }
12465         }
12466       }
12467       //change the farPb to farLed for calDet
12468       else if (detectorType==Detector::kCalDet){
12469 
12470         MSG("LIAnalysis",Msg::kVerbose)  
12471           <<"("<<pulserBox<<":"<<led
12472           <<") caldet se="<<se<<endl; 
12473         
12474         if (pulserBox>=FIRSTPULSERBOX && pulserBox<=LASTPULSERBOX &&
12475             crate>=FIRSTCRATE && crate<=LASTCRATE &&
12476             led>=FIRSTLED && led<=LASTLED &&
12477             calibPoint>=1 && calibPoint<=const_numCalibPoints &&
12478             strip>=FIRSTSTRIP && strip<=LASTSTRIP &&
12479             plane>=FIRSTPLANE && plane<=LASTPLANE){
12480 
12481           //fill object when pulser box is near pulser box
12482           if (lookup.NearOrFar(crate,pulserBox,nearPulserBox,
12483                                farPulserBox,led,detectorType,
12484                                plane,runNumber)==
12485               LILookup::kNearSide){
12486             //add the points to the LIRun object
12487             gCurveData[se].SetLIInfo(pulserBox,led,LIRun::kGainCurve); 
12488             gCurveData[se].AddPoint(pulseHeight,mean,
12489                                     maxAdcHighPin[l][c],
12490                                     maxAdcLowPin[l][c],
12491                                     rms,//a bit of a hack (adcF)
12492                                     numEntries);
12493           }
12494           //fill object when pulser box is far pulser box
12495           else if (lookup.NearOrFar(crate,pulserBox,nearPulserBox,
12496                                     farPulserBox,led,detectorType,
12497                                     plane,runNumber)==
12498                    LILookup::kFarSide) {
12499             //MSG("LIAnalysis",Msg::kInfo)  
12500             //<<"("<<pulserBox<<":"<<led
12501             //<<") filling far se="<<se<<endl; 
12502           }
12503         }
12504       }
12505     }
12506   }//end of for       
12507    
12511   
12512   MSG("LIAnalysis",Msg::kInfo)  
12513     <<"Finished main loop"<<endl; 
12514 
12515   //include the under and overflow counts 
12516   gStyle->SetOptStat(1111111); 
12517 
12518   //turn off the fit stats box
12519   gStyle->SetOptFit(0000);
12520 
12521   //set up useful string 
12522   string sRunNumber=Form("%d",runNumber); 
12523   string sLowRunNumber=Form("%d",lowRunNumber);
12524   string sHighRunNumber=Form("%d",highRunNumber);
12525   s="";
12526   //set strings for use in titles
12527   string sPulseWidth=Form("%d",pulseWidth);
12528   string sPulseFreq=Form("%d",static_cast<Int_t>
12529                          (ceil(1.0/(period*1.0e-5))));
12530   
12531   //loop and print all the info stored in the object
12532   if (MsgService::Instance()->IsActive("LIAnalysis",Msg::kDebug)){
12533     for (Int_t k=0;k<NUMSIDES;k++){
12534       MSG("LIAnalysis",Msg::kDebug)<<"Side="<<k<<endl;
12535       for (Int_t i=0;i<NUMPLANES;i++){
12536         MSG("LIAnalysis",Msg::kDebug)<<"Plane="<<i<<endl;
12537         for (Int_t j=0;j<NUMSTRIPS;j++){
12538           Int_t se=k*NUMPLANES*NUMSTRIPS+i*NUMSTRIPS+j;
12539           MSG("LIAnalysis",Msg::kVerbose)<<"se="<<se<<endl;
12540           gCurveData[se].PrintAll();      
12541         }
12542       }
12543     }
12544   }
12545 
12546   //create canvas
12547   TCanvas *cGc=new TCanvas("cGc","cGc",0,0,1200,600);
12548   cGc->SetFillColor(0);
12549   TCanvas *cResiduals=new TCanvas("cResiduals","cResiduals",
12550                                   0,0,1200,600);
12551   cResiduals->SetFillColor(0);
12552   TCanvas *cResidPin=new TCanvas("cResidPin","cResidPin",0,0,1200,600);
12553   cResidPin->SetFillColor(0);
12554   TCanvas *cNonLin=new TCanvas("cNonLin","cNonLin",
12555                                   0,0,1200,600);
12556   cNonLin->SetFillColor(0);
12557   TCanvas *cNonLinPin=new TCanvas("cNonLinPin","cNonLinPin",
12558                                   0,0,1200,600);
12559   cNonLinPin->SetFillColor(0);
12560   TCanvas *cGain=new TCanvas("cGain","cGain",0,0,1200,600);
12561   cGain->SetFillColor(0);
12562   TCanvas *cNumEntries=new TCanvas("cNumEntries","cNumEntries",
12563                                    0,0,1200,600);
12564   cNumEntries->SetFillColor(0);
12565   
12566   //create the graphs
12567   TGraphErrors* gGc=new TGraphErrors(const_numCalibPoints);
12568   TGraphErrors* gResiduals=new TGraphErrors(const_numCalibPoints);
12569   TGraphErrors* gResidPin=new TGraphErrors(const_numCalibPoints);
12570   TGraph* gNonLin=new TGraph(const_numCalibPoints);
12571   TGraph* gNonLinPin=new TGraph(const_numCalibPoints);
12572   TGraph* gGain=new TGraph(const_numCalibPoints);
12573   TGraph* gNumEntries=new TGraph(const_numCalibPoints);
12574 
12575   vector<TGraph*> vResid(5);
12576   vResid[0]=new TGraph(const_numCalibPoints);
12577   vResid[1]=new TGraph(const_numCalibPoints);
12578   vResid[2]=new TGraph(const_numCalibPoints);
12579   vResid[3]=new TGraph(const_numCalibPoints);
12580   vResid[4]=new TGraph(const_numCalibPoints);
12581 
12582   string sResiduals=sRunNumber+"GcResidVsPmt.ps";
12583   string sResidPin=sRunNumber+"GcResidVsPin.ps";
12584   string sGc=sRunNumber+"Gc.ps";
12585   string sNonLin=sRunNumber+"GcNonLinVsPmt.ps";
12586   string sNonLinPin=sRunNumber+"GcNonLinVsPin.ps";
12587   string sGain=sRunNumber+"GcGain.ps";
12588   string sNumEntries=sRunNumber+"GcNumEntries.ps";
12589 
12590   Int_t fitPoint=-1;
12591   Int_t firstGoodAdcPoint=-1;
12592   Int_t nonLinNormPoint=-1;
12593   Double_t maxRatio=-1;
12594   Double_t pinAdcCut=10;
12595   //Int_t firstPlotDone=0;
12596 
12597   MSG("LIAnalysis",Msg::kInfo)
12598     <<"Starting loop over planes..."<<endl;
12599 
12600   for (Int_t i=0;i<NUMPLANES;i++){
12601     MSG("LIAnalysis",Msg::kDebug)<<"Plane="<<i<<endl;
12602 
12603     //ignore the pain in the arse two ends in one side on plane zero
12604     if (i==0 && detectorType==Detector::kCalDet) continue;
12605 
12606     //not too many plots either
12607     if (i>=10 && detectorType==Detector::kCalDet) continue;
12608 
12609     //print out occasionally
12610     if (i%(NUMPLANES/5)==0){
12611       MSG("LIAnalysis",Msg::kInfo)<<"Plane="<<i<<endl;
12612     }
12613     for (Int_t j=0;j<NUMSTRIPS;j++){
12614       for (Int_t k=FIRSTEND;k<=SECONDEND;k++){
12615 
12616         //calculate the index
12617         Int_t se=(k-1)*NUMPLANES*NUMSTRIPS+i*NUMSTRIPS+j;
12618 
12619         string sPlane=Form("%d",i);
12620         string sStrip=Form("%d",j);
12621         string sEnd=Form("%d",k);
12622         string sPlStEnd=" (Pl,St,End)=("+sPlane+","+sStrip+","+sEnd+")";
12623 
12624         MSG("LIAnalysis",Msg::kVerbose)<<sPlStEnd<<endl;
12625         vector<Double_t> pin;
12626         vector<Double_t> adc;
12627         pin=gCurveData[se].GetPin(2);
12628         adc=gCurveData[se].GetAdc();
12629 
12630         //use built in functionality but with wrong name
12631         vector<Double_t> numEntries;
12632         numEntries=gCurveData[se].GetAdcLow();
12633         vector<Double_t> rms;
12634         rms=gCurveData[se].GetAdcF();//a quick way to store it
12635 
12636         gGc->Clear();
12637         cGc->Clear();
12638         gResiduals->Clear();
12639         cResiduals->Clear();
12640         gResidPin->Clear();
12641         cResidPin->Clear();
12642         gNonLin->Clear();
12643         cNonLin->Clear();
12644         gNonLinPin->Clear();
12645         cNonLinPin->Clear();
12646         gGain->Clear();
12647         cGain->Clear();
12648         gNumEntries->Clear();
12649         cNumEntries->Clear();
12650 
12651         //reset the fit point
12652         fitPoint=-1;
12653         firstGoodAdcPoint=-1;
12654         nonLinNormPoint=-1;
12655         maxRatio=-1;
12656 
12657         //only look at decent gain curves
12658         if (adc.size()>0){
12659 
12660           //print out occasionally
12661           if (i%3==0 && j%6==0){
12662             MSG("LIAnalysis",Msg::kInfo)
12663               <<"Processing plane="<<sPlStEnd<<endl;
12664           }
12665 
12666           //find a load of points to help in fitting and plotting
12667           for (UInt_t p=0;p<adc.size();p++){
12668 
12669             //calcuate error
12670             Double_t ey=0;
12671             if (numEntries[p]>0){
12672               ey=rms[p]/sqrt(numEntries[p]);
12673             }
12674 
12675             //set the points on the graph
12676             gGc->SetPoint(p,pin[p],adc[p]);
12677             gGc->SetPointError(p,0.,ey);
12678 
12679             //find the max point on the graph to which to fit
12680             if (adc[p]>5500 && fitPoint==-1){
12681               fitPoint=p;
12682               MSG("LIAnalysis",Msg::kDebug)
12683                 <<sPlStEnd<<" fitPoint="<<fitPoint
12684                 <<", adc="<<adc[fitPoint]
12685                 <<", pin="<<pin[fitPoint]<<endl;
12686             }
12687 
12688             //find the first good adc point on the graph to which to fit
12689             if (adc[p]>400 && firstGoodAdcPoint==-1){// >5pe to use
12690               firstGoodAdcPoint=p;
12691               MSG("LIAnalysis",Msg::kDebug)
12692                 <<sPlStEnd<<" firstGoodAdcPoint="<<firstGoodAdcPoint
12693                 <<", adc="<<adc[firstGoodAdcPoint]
12694                 <<", pin="<<pin[firstGoodAdcPoint]<<endl;
12695 
12696               //set the pin cut to be just below the first good adc
12697               pinAdcCut=pin[firstGoodAdcPoint]-1;
12698             }
12699 
12700             Double_t ratio=-1;
12701             if (pin[p]!=0){
12702               ratio=adc[p]/pin[p];
12703             }
12704 
12705             //find the point to normalise to
12706             if (ratio>maxRatio && pin[p]>pinAdcCut){
12707               maxRatio=ratio;
12708               nonLinNormPoint=p;
12709               MSG("LIAnalysis",Msg::kVerbose)
12710                 <<sPlStEnd
12711                 <<", nonLinNormPoint="<<nonLinNormPoint
12712                 <<", adc="<<adc[nonLinNormPoint]
12713                 <<", pin="<<pin[nonLinNormPoint]<<endl;
12714             }
12715           }
12716 
12717           if (firstGoodAdcPoint==fitPoint){
12718             MSG("LIAnalysis",Msg::kWarning)
12719               <<sPlStEnd<<" Can't fit GC, firstGoodAdcPoint="
12720               <<firstGoodAdcPoint<<", fitPoint="<<fitPoint<<endl;
12721           }
12722           
12723           //protect against not finding appropriate points
12724           if (fitPoint==-1) fitPoint=0;
12725           if (firstGoodAdcPoint==-1) firstGoodAdcPoint=0;
12726           if (nonLinNormPoint==-1) nonLinNormPoint=0;
12727 
12728           //fit the gain curve in the appropriate range
12729           gGc->Fit("pol1","q","",pinAdcCut,pin[fitPoint]);
12730           TF1* func=gGc->GetFunction("pol1");
12731           Double_t funcC=func->GetParameter(0);
12732           Double_t funcM=func->GetParameter(1);
12733           
12734           //draw the gain curve
12735           cGc->cd();
12736           gGc->Draw("AP");
12737           s="Gain Curve"+sPlStEnd;
12738           gGc->Draw("AP");
12739           gGc->SetTitle(s.c_str());
12740           gGc->GetXaxis()->SetTitle("Pin Adc");
12741           gGc->GetYaxis()->SetTitle("Pmt Adc");
12742           gGc->GetXaxis()->CenterTitle();
12743           gGc->GetYaxis()->CenterTitle();
12744           gGc->SetMarkerStyle(3);
12745           gGc->SetMarkerColor(2);
12746           gGc->SetMarkerSize(0.55);
12747           gGc->SetLineColor(46);
12748           
12749           //get the axis values
12750           Axis_t xMax=gGc->GetXaxis()->GetXmax();
12751           Axis_t xMin=gGc->GetXaxis()->GetXmin();
12752           
12753           MSG("LIAnalysis",Msg::kDebug)
12754             <<sPlStEnd<<", y="<<funcM<<"x+"<<funcC
12755             <<", xMin="<<xMin<<", xMax="<<xMax<<endl;
12756           
12757           for (Int_t k=0;k<const_numCalibPoints;k++){     
12758             
12759             Double_t actualX=-1;
12760             Double_t actualYval=-1;
12761             Double_t ey=0;
12762             Double_t fractEy=0;
12763             gGc->GetPoint(k,actualX,actualYval);
12764             ey=gGc->GetErrorY(k);
12765             if (actualYval>0){
12766               fractEy=ey/actualYval;
12767             }
12768             else{
12769               MSG("LIAnalysis",Msg::kWarning)
12770                 <<sPlStEnd<<" actualY="<<actualYval<<", ey="<<ey<<endl;
12771             }
12772 
12773             //do y=mx+c to get value on straight line fit
12774             Double_t fittedYval=funcM*actualX+funcC;
12775             
12776             //calculate the residual and normalise        
12777             Double_t resid=actualYval-fittedYval;
12778             if (fittedYval!=0) resid/=fittedYval;
12779             else{ 
12780               resid=0;
12781               MSG("LIAnalysis",Msg::kWarning)
12782               <<sPlStEnd<<" Fitted y val=0, setting residual to zero"
12783               <<endl;
12784             }
12785 
12786             Double_t eResid=fractEy*resid;
12787             MSG("LIAnalysis",Msg::kVerbose)
12788               <<sPlStEnd<<" actualY="<<actualYval<<", ey="<<ey
12789               <<", resid="<<resid<<", eResid="<<eResid
12790               <<endl;
12791 
12792             //set the point on the graph
12793             //if (actualX>pinAdcCut){
12794             gResiduals->SetPoint(k,actualYval,resid);
12795             gResiduals->SetPointError(k,0,eResid);
12796             gResidPin->SetPoint(k,actualX,resid);
12797             gResidPin->SetPointError(k,0,eResid);
12798             
12799             //section for special 5 strips plot
12800             Int_t resIndex=se-25;
12801             if (resIndex>=0 && resIndex<5){
12802               vResid[resIndex]->SetPoint(k,actualYval,resid);
12803             }
12804 
12805             //}
12806             //else {
12807             //MSG("LIAnalysis",Msg::kVerbose)
12808             //<<"Setting a zero in residuals because pin too low"
12809             //<<endl;
12810             //gResiduals->SetPoint(k,0,1);
12811             //gResidPin->SetPoint(k,0,1);
12812             //}
12813             
12814             if (i<5){
12815               MSG("LIAnalysis",Msg::kDebug)
12816                 <<sPlStEnd<<", x="<<actualX
12817                 <<", y="<<actualYval
12818                 <<", fitY="<<fittedYval<<", resid="<<resid<<i<<endl;
12819             }
12820           }
12821 
12822           cResiduals->cd();
12823           s="Gain Curve: Residuals to Fit Vs PMT ADC"+sPlStEnd;
12824           gResiduals->Draw("AP");
12825           gResiduals->SetTitle(s.c_str());
12826           gResiduals->GetXaxis()->SetTitle("Pmt Adc");
12827           gResiduals->GetYaxis()->SetTitle("Fractional residual");
12828           gResiduals->GetXaxis()->CenterTitle();
12829           gResiduals->GetYaxis()->CenterTitle();
12830           gResiduals->SetMarkerStyle(3);
12831           gResiduals->SetMarkerColor(2);
12832           gResiduals->SetMarkerSize(0.55);
12833           gResiduals->SetLineColor(46);
12834           gResiduals->SetMinimum(-0.2);
12835           gResiduals->SetMaximum(0.2);
12836 
12837           cResidPin->cd();
12838           s="Gain Curve: Residuals to Fit Vs PIN ADC"+sPlStEnd;
12839           gResidPin->Draw("AP");
12840           gResidPin->SetTitle(s.c_str());
12841           gResidPin->GetXaxis()->SetTitle("Pin Adc");
12842           gResidPin->GetYaxis()->SetTitle("Fractional residual");
12843           gResidPin->GetXaxis()->CenterTitle();
12844           gResidPin->GetYaxis()->CenterTitle();
12845           gResidPin->SetMarkerStyle(3);
12846           gResidPin->SetMarkerColor(2);
12847           gResidPin->SetMarkerSize(0.55);
12848           gResidPin->SetLineColor(46);
12849           gResidPin->SetMinimum(-0.2);
12850           gResidPin->SetMaximum(0.2);
12851 
12852           gNumEntries=TGraphVect(adc,numEntries);
12853           cNumEntries->cd();
12854           s="Num Flashes Vs PMT ADC"+sPlStEnd;
12855           gNumEntries->Draw("AP");
12856           gNumEntries->SetTitle(s.c_str());
12857           gNumEntries->GetXaxis()->SetTitle("Pmt Adc");
12858           gNumEntries->GetYaxis()->SetTitle("Number of Entries");
12859           gNumEntries->GetXaxis()->CenterTitle();
12860           gNumEntries->GetYaxis()->CenterTitle();
12861           gNumEntries->SetMarkerStyle(3);
12862           gNumEntries->SetMarkerColor(2);
12863           gNumEntries->SetMarkerSize(0.55);
12864           gNumEntries->SetLineColor(46);
12865           gNumEntries->SetMaximum(pulses+0.1*pulses);
12866 
12867           //fill the graphs
12868           for (UInt_t p=0;p<adc.size();p++){
12869             //set the points on the graph
12870             if (pin[p]!=0 && pin[nonLinNormPoint]!=0 && 
12871                 adc[nonLinNormPoint]!=0){
12872               //calculate variables
12873               Double_t ratio=adc[p]/pin[p];
12874               Double_t normRatio=adc[nonLinNormPoint]/
12875                 pin[nonLinNormPoint];
12876               //fill the graphs
12877               gNonLin->SetPoint(p,adc[p],ratio/normRatio);
12878               gNonLinPin->SetPoint(p,pin[p],ratio/normRatio);
12879 
12880               // PMT fudge factor for M64 (near detector): 0.844
12881               if (detectorType==Detector::kNear) {
12882                 gGain->SetPoint
12883                   (p,adc[p],0.844*lookup.CalcGain(adc[p],rms[p],0));
12884               }
12885               else {
12886                 gGain->SetPoint
12887                   (p,adc[p],0.8*lookup.CalcGain(adc[p],rms[p],0));
12888               }
12889             }
12890             else {
12891               gNonLin->SetPoint(p,0,0);
12892               gNonLinPin->SetPoint(p,0,0);
12893               gGain->SetPoint(p,0,0);
12894             }
12895           }
12896           
12897           cNonLin->cd();
12898           s="Gain Curve: Nonlinearity Vs PMT ADC"+sPlStEnd;
12899           gNonLin->Draw("AP");
12900           gNonLin->SetTitle(s.c_str());
12901           gNonLin->GetXaxis()->SetTitle("Pmt Adc");
12902           gNonLin->GetYaxis()->SetTitle
12903             ("Fractional Nonlinearity (Norm. Pmt/Pin)");
12904           gNonLin->GetXaxis()->CenterTitle();
12905           gNonLin->GetYaxis()->CenterTitle();
12906           gNonLin->SetMarkerStyle(3);
12907           gNonLin->SetMarkerColor(2);
12908           gNonLin->SetMarkerSize(0.55);
12909           gNonLin->SetLineColor(46);
12910           gNonLin->SetMaximum(1.2);
12911 
12912           cNonLinPin->cd();
12913           s="Gain Curve: Nonlinearity Vs PIN ADC"+sPlStEnd;
12914           gNonLinPin->Draw("AP");
12915           gNonLinPin->SetTitle(s.c_str());
12916           gNonLinPin->GetXaxis()->SetTitle("Pin Adc");
12917           gNonLinPin->GetYaxis()->SetTitle
12918             ("Fractional Nonlinearity  (Norm. Pmt/Pin)");
12919           gNonLinPin->GetXaxis()->CenterTitle();
12920           gNonLinPin->GetYaxis()->CenterTitle();
12921           gNonLinPin->SetMarkerStyle(3);
12922           gNonLinPin->SetMarkerColor(2);
12923           gNonLinPin->SetMarkerSize(0.55);
12924           gNonLinPin->SetLineColor(46);
12925           gNonLinPin->SetMaximum(1.2);
12926 
12927           cGain->cd();
12928           s="Gain (mean/npe) Vs PMT Mean"+sPlStEnd; 
12929           gGain->Draw("AP");
12930           gGain->SetTitle(s.c_str());
12931           gGain->GetXaxis()->SetTitle("Pmt Adc");
12932           gGain->GetYaxis()->SetTitle("Gain (mean/npe)");
12933           gGain->GetXaxis()->CenterTitle();
12934           gGain->GetYaxis()->CenterTitle();
12935           gGain->SetMarkerStyle(3);
12936           gGain->SetMarkerColor(2);
12937           gGain->SetMarkerSize(0.55);
12938           gGain->SetLineColor(46);
12939           gGain->SetMaximum(130);
12940           gGain->SetMinimum(0);
12941 
12942           static Bool_t firstPlotDone=false;
12943           if (!firstPlotDone){
12944             //print canvases
12945             cResiduals->Print((sResiduals+"(").c_str());
12946             cResidPin->Print((sResidPin+"(").c_str());
12947             cGc->Print((sGc+"(").c_str());
12948             cNonLin->Print((sNonLin+"(").c_str());
12949             cNonLinPin->Print((sNonLinPin+"(").c_str());
12950             cGain->Print((sGain+"(").c_str());
12951             cNumEntries->Print((sNumEntries+"(").c_str());
12952 
12953             //set variables
12954             gErrorIgnoreLevel=1;
12955             firstPlotDone=true;
12956           }
12957           else {
12958             cResiduals->Print(sResiduals.c_str());
12959             cResidPin->Print(sResidPin.c_str());
12960             cGc->Print(sGc.c_str());
12961             cNonLin->Print(sNonLin.c_str());
12962             cNonLinPin->Print(sNonLinPin.c_str());
12963             cGain->Print(sGain.c_str());
12964             cNumEntries->Print(sNumEntries.c_str());
12965           }
12966         }
12967       }
12968     }
12969   }
12970          
12971   //close the files 
12972   MSG("LIAnalysis",Msg::kInfo)<<"Closing the postscript files..."<<endl;
12973   gErrorIgnoreLevel=0;
12974   cResiduals->Print((sResiduals+")").c_str());
12975   cResidPin->Print((sResidPin+")").c_str());
12976   cGc->Print((sGc+")").c_str());
12977   cNonLin->Print((sNonLin+")").c_str());
12978   cNonLinPin->Print((sNonLinPin+")").c_str());
12979   cGain->Print((sGain+")").c_str());
12980   cNumEntries->Print((sNumEntries+")").c_str());
12981   MSG("LIAnalysis",Msg::kInfo)<<"... closed"<<endl;  
12982 
12983   //a special plot for 5 on one canvas  
12984   Int_t print=0;
12985   if (print==1){
12986     
12987     cResiduals->Clear();
12988     
12989     s="Gain Curve Residuals (5 strips)";
12990     vResid[0]->Draw("AP");
12991     vResid[0]->SetTitle(s.c_str());
12992     vResid[0]->GetXaxis()->SetTitle("Pmt Adc");
12993     vResid[0]->GetYaxis()->SetTitle("Normalised residual");
12994     vResid[0]->GetXaxis()->CenterTitle();
12995     vResid[0]->GetYaxis()->CenterTitle();
12996     vResid[0]->SetMarkerStyle(3);
12997     vResid[0]->SetMarkerColor(2);
12998     vResid[0]->SetMarkerSize(0.55);
12999     vResid[0]->SetLineColor(46);
13000     vResid[0]->SetMinimum(-0.2);
13001     vResid[0]->SetMaximum(0.2);
13002     
13003     for (Int_t i=1;i<5;i++){
13004       vResid[i]->Draw("P");
13005       vResid[i]->SetTitle(s.c_str());
13006       vResid[i]->SetMarkerStyle(3);
13007       vResid[i]->SetMarkerColor(2+i);
13008       vResid[i]->SetMarkerSize(0.55);
13009       vResid[i]->SetLineColor(46);
13010       vResid[i]->SetMinimum(-0.2);
13011       vResid[i]->SetMaximum(0.2);    
13012     }    
13013     cResiduals->Print("residuals5.eps");
13014   }
13015 
13016   MSG("LIAnalysis",Msg::kInfo)  
13017     <<endl<<" ** Finished the GainCurves method ** "<<endl; 
13018 } 

void LIAnalysis::GainCurves_Led  ) 
 

Definition at line 11678 of file LIAnalysis.cxx.

References calibPoint, chain, chip, correlatedHit, crate, detectorType, farLed, farPulserBox, Form(), GetElecString(), highRunNumber, InitialiseLoopVariables(), led, lowRunNumber, mean, MSG, nearLed, nearPulserBox, numEntries, period, pinGain, pulserBox, pulseWidth, readoutType, rms, runNumber, s(), s, and SetLoopVariables().

11679 { 
11680   MSG("LIAnalysis",Msg::kInfo)  
11681     <<endl<<" ** Running the GainCurves_Led method... ** "<<endl; 
11682 
11683   chain->GetEvent(0);
11684 
11685   Int_t numAdcBins=20;
11686   const Int_t const_numCalibPoints=calibType;   
11687 
11688   MSG("LIAnalysis",Msg::kInfo) 
11689     <<"Using "<<const_numCalibPoints<<" calibPoints"<<endl;
11690   MSG("LIAnalysis",Msg::kInfo) 
11691     <<"Number of pulser boxes = "<<NUMPULSERBOXES
11692     <<", leds = "<<NUMLEDS
11693     <<endl<<endl;
11694 
11695   //store the pulse heights associated with each calibPoint
11696   Int_t **pulseHeights=0;
11697   pulseHeights=new Int_t*[NUMLEDS*NUMPULSERBOXES];
11698 
11699   Float_t **maxAdcHighPin=0;
11700   maxAdcHighPin=new Float_t*[NUMLEDS*NUMPULSERBOXES];
11701   Float_t **maxAdcLowPin=0;
11702   maxAdcLowPin=new Float_t*[NUMLEDS*NUMPULSERBOXES];
11703   Float_t **maxAdcPin=0;
11704   maxAdcPin=new Float_t*[NUMLEDS*NUMPULSERBOXES];
11705 
11706   //initialise arrays
11707   TH1F ***hAdcPh=0;
11708   hAdcPh=new TH1F**[NUMLEDS*NUMPULSERBOXES];
11709   for (Int_t i=0;i<NUMPULSERBOXES;i++){
11710     for (Int_t j=0;j<NUMLEDS;j++){
11711       Int_t l=i*NUMLEDS+j;
11712 
11713       hAdcPh[l]=new TH1F*[const_numCalibPoints];
11714 
11715       pulseHeights[l]=new Int_t[const_numCalibPoints];
11716       maxAdcHighPin[l]=new Float_t[const_numCalibPoints];
11717       maxAdcLowPin[l]=new Float_t[const_numCalibPoints];
11718       maxAdcPin[l]=new Float_t[const_numCalibPoints];
11719       
11720       for (Int_t k=0;k<const_numCalibPoints;k++){
11721         string sCalibPoint=Form("%d",k);
11722         string sPulserBox=Form("%d",i);
11723         string sLed=Form("%d",j+1);
11724         s="ADC Near&Far, PB "+sPulserBox+", LED "+sLed+
11725           ", calibPoint "+sCalibPoint;
11726         (hAdcPh[l])[k]=new TH1F(s.c_str(),s.c_str(),
11727                                    numAdcBins,0,15000);
11728         (hAdcPh[l])[k]->GetXaxis()->SetTitle("ADC");
11729         (hAdcPh[l])[k]->GetXaxis()->CenterTitle();
11730         (hAdcPh[l])[k]->GetYaxis()->SetTitle("Number of Entries");
11731         (hAdcPh[l])[k]->GetYaxis()->CenterTitle();
11732         (hAdcPh[l])[k]->SetFillColor(0);
11733         (hAdcPh[l])[k]->SetLineColor(1);
11734         (hAdcPh[l])[k]->Fill(1,0.0001);
11735         //(hAdcPh[l])[k]->SetBit(TH1::kCanRebin);
11736         pulseHeights[l][k]=0;
11737         maxAdcHighPin[l][k]=0;
11738         maxAdcLowPin[l][k]=0;
11739         maxAdcPin[l][k]=0;
11740       }
11741     }
11742   }
11743 
11744   TH1F ***hAdcPhNear=0;
11745   hAdcPhNear=new TH1F**[NUMLEDS*NUMPULSERBOXES];
11746   for (Int_t i=0;i<NUMPULSERBOXES;i++){
11747     for (Int_t j=0;j<NUMLEDS;j++){
11748       Int_t l=i*NUMLEDS+j;
11749       hAdcPhNear[l]=new TH1F*[const_numCalibPoints];
11750       for (Int_t k=0;k<const_numCalibPoints;k++){
11751         string sCalibPoint=Form("%d",k);
11752         string sPulserBox=Form("%d",i);
11753         string sLed=Form("%d",j+1);
11754         s="ADC Near Side, PB "+sPulserBox+", LED "+sLed+
11755           ", calibPoint "+sCalibPoint;
11756         Int_t l=i*NUMLEDS+j;
11757         hAdcPhNear[l][k]=new TH1F(s.c_str(),s.c_str(),
11758                                    numAdcBins,0,15000);
11759         (hAdcPhNear[l])[k]->GetXaxis()->SetTitle("ADC");
11760         (hAdcPhNear[l])[k]->GetXaxis()->CenterTitle();
11761         (hAdcPhNear[l])[k]->GetYaxis()->SetTitle("Number of Entries");
11762         (hAdcPhNear[l])[k]->GetYaxis()->CenterTitle();
11763         (hAdcPhNear[l])[k]->SetFillColor(0);
11764         (hAdcPhNear[l])[k]->SetLineColor(2);
11765         (hAdcPhNear[l])[k]->Fill(1,0.0001);
11766         //(hAdcPhNear[l])[k]->SetBit(TH1::kCanRebin);
11767       }
11768     }
11769   }
11770 
11771   TH1F ***hAdcPhFar=0;
11772   hAdcPhFar=new TH1F**[NUMLEDS*NUMPULSERBOXES];
11773   for (Int_t i=0;i<NUMPULSERBOXES;i++){
11774     for (Int_t j=0;j<NUMLEDS;j++){
11775       Int_t l=i*NUMLEDS+j;
11776       hAdcPhFar[l]=new TH1F*[const_numCalibPoints];
11777       for (Int_t k=0;k<const_numCalibPoints;k++){
11778         string sCalibPoint=Form("%d",k);
11779         string sPulserBox=Form("%d",i);
11780         string sLed=Form("%d",j+1);
11781         s="ADC Far Side, PB "+sPulserBox+", LED "+sLed+
11782           ", calibPoint "+sCalibPoint;
11783         (hAdcPhFar[l])[k]=new TH1F(s.c_str(),s.c_str(),
11784                                    numAdcBins,0,15000);
11785         (hAdcPhFar[l])[k]->GetXaxis()->SetTitle("ADC");
11786         (hAdcPhFar[l])[k]->GetXaxis()->CenterTitle();
11787         (hAdcPhFar[l])[k]->GetYaxis()->SetTitle("Number of Entries");
11788         (hAdcPhFar[l])[k]->GetYaxis()->CenterTitle();
11789         (hAdcPhFar[l])[k]->SetFillColor(0);
11790         (hAdcPhFar[l])[k]->SetLineColor(3);
11791         (hAdcPhFar[l])[k]->Fill(1,0.0001);
11792         //(hAdcPhFar[l])[k]->SetBit(TH1::kCanRebin);
11793       }
11794     }
11795   }
11796 
11797   TH2F **hGainCurvePmt=0;
11798   hGainCurvePmt=new TH2F*[NUMPULSERBOXES];
11799   for (Int_t i=0;i<NUMPULSERBOXES;i++){
11800     string sPb=Form("%d",i);
11801     s="Gain Curve Points in PMT ADCs, Pulser Box "+sPb; 
11802     hGainCurvePmt[i]=new TH2F(s.c_str(),s.c_str(),21,0,21,200,0,15000);
11803     hGainCurvePmt[i]->GetXaxis()->SetTitle("LED");
11804     hGainCurvePmt[i]->GetXaxis()->CenterTitle();
11805     hGainCurvePmt[i]->GetYaxis()->SetTitle("Pmt ADCs");
11806     hGainCurvePmt[i]->GetYaxis()->CenterTitle();
11807     hGainCurvePmt[i]->SetFillColor(0);
11808     hGainCurvePmt[i]->SetBit(TH1::kCanRebin);
11809   }
11810 
11811   TH2F **hGainCurvePin=0;
11812   hGainCurvePin=new TH2F*[NUMPULSERBOXES];
11813   for (Int_t i=0;i<NUMPULSERBOXES;i++){
11814     string sPb=Form("%d",i);
11815     s="Gain Curve Points in Pin diode ADCs, Pulser Box "+sPb; 
11816     hGainCurvePin[i]=new TH2F(s.c_str(),s.c_str(),21,0,21,200,0,15000);
11817     hGainCurvePin[i]->GetXaxis()->SetTitle("LED");
11818     hGainCurvePin[i]->GetXaxis()->CenterTitle();
11819     hGainCurvePin[i]->GetYaxis()->SetTitle("Pin ADCs");
11820     hGainCurvePin[i]->GetYaxis()->CenterTitle();
11821     hGainCurvePin[i]->SetFillColor(0);
11822     hGainCurvePin[i]->SetBit(TH1::kCanRebin);
11823   }
11824 
11825   TH2F **hGainCurvePh=0;
11826   hGainCurvePh=new TH2F*[NUMPULSERBOXES];
11827   for (Int_t i=0;i<NUMPULSERBOXES;i++){
11828     string sPb=Form("%d",i);
11829     s="Gain Curve Points Pulse Height, Pulser Box "+sPb; 
11830     hGainCurvePh[i]=new TH2F(s.c_str(),s.c_str(),21,0,21,200,0,1023);
11831     hGainCurvePh[i]->GetXaxis()->SetTitle("LED");
11832     hGainCurvePh[i]->GetXaxis()->CenterTitle();
11833     hGainCurvePh[i]->GetYaxis()->SetTitle("Pulse Height");
11834     hGainCurvePh[i]->GetYaxis()->CenterTitle();
11835     hGainCurvePh[i]->SetFillColor(0);
11836     hGainCurvePh[i]->SetBit(TH1::kCanRebin);
11837   }
11838 
11842    
11843   this->InitialiseLoopVariables();   
11844    
11845   for(Int_t entry=0;entry<numEvents;entry++){ 
11846 
11847     this->SetLoopVariables(entry,1); 
11848 
11849     //ignore any zeros that slipped through 
11850     if (mean==0 || rms==0 || numEntries==0) continue; 
11851 
11852     Int_t c=calibPoint-1;
11853 
11854     //look at pins 
11855     if (readoutType==ReadoutType::kPinDiode){
11856 
11857       if (pulserBox>=FIRSTPULSERBOX && pulserBox<=LASTPULSERBOX &&
11858           led>=FIRSTLED && led<=LASTLED){
11859         //define led number
11860         Int_t l=pulserBox*NUMLEDS+led-1;
11861         
11862         //will require a correlated hit when plex is working
11863         //fill histo for appropriate pin
11864         if (chip==1){//high gain (chip 1)
11865           //find max value for high gain pin
11866           if (mean>maxAdcHighPin[l][c]) {
11867             maxAdcHighPin[l][c]=mean; 
11868           }
11869         }
11870         else if (chip==0){//low gain (chip 0)
11871           //find max value for low gain pin
11872           if (mean>maxAdcLowPin[l][c]) {
11873             maxAdcLowPin[l][c]=mean; 
11874           }
11875         }
11876         //print out warnings if there are inconsistencies
11877         if ((pinGain!=1 && chip==0) || (pinGain!=0 && chip==1)) {
11878           MSG("LIAnalysis",Msg::kInfo)
11879             <<"**** Strange pin, wrong gain in plex, ("
11880             <<", "<<this->GetElecString()
11881             <<", plex gain="<<pinGain<<", mean="<<mean<<", rms="<<rms
11882             <<", num="<<numEntries<<", cHit="<<correlatedHit<<endl;
11883         }
11884       }
11885     }
11886 
11887     //only look at scint strips 
11888     if (readoutType!=ReadoutType::kScintStrip) continue; 
11889 
11890     //fill histograms
11891     if (correlatedHit==1){
11892       if (detectorType==Detector::kFar){
11893 
11894         if (pulserBox>=FIRSTPULSERBOX && pulserBox<=LASTPULSERBOX &&
11895             led>=FIRSTLED && led<=LASTLED &&
11896             calibPoint>=1 && calibPoint<=const_numCalibPoints){
11897           Int_t l=pulserBox*NUMLEDS+led-1;
11898           
11899           pulseHeights[l][c]=pulseHeight;
11900           
11901           //fill histo for appropriate led
11902           hAdcPh[l][c]->Fill(mean);
11903           //fill histos with when pulser box is near pulser box
11904           if (nearPulserBox==pulserBox){
11905             hAdcPhNear[l][c]->Fill(mean);
11906           }
11907           //fill histos with when pulser box is far pulser box
11908           else if (farPulserBox==pulserBox) {
11909             hAdcPhFar[l][c]->Fill(mean);
11910           }
11911         }
11912       }
11913       //change the farPb to farLed for calDet
11914       else if (detectorType==Detector::kCalDet){
11915 
11916         if (pulserBox>=FIRSTPULSERBOX && pulserBox<=LASTPULSERBOX &&
11917             crate>=FIRSTCRATE && crate<=LASTCRATE &&
11918             led>=FIRSTLED && led<=LASTLED &&
11919             calibPoint>=1 && calibPoint<=const_numCalibPoints){
11920           Int_t l=pulserBox*NUMLEDS+led-1;
11921           
11922           pulseHeights[l][c]=pulseHeight;
11923           
11924           //fill histo for appropriate led
11925           hAdcPh[l][c]->Fill(mean);
11926           //fill histos with when pulser box is near pulser box
11927           if (nearLed==led){
11928             hAdcPhNear[l][c]->Fill(mean);
11929           }
11930           //fill histos with when pulser box is far pulser box
11931           else if (farLed==led) {
11932             hAdcPhFar[l][c]->Fill(mean);
11933           }
11934         }
11935       }
11936     }
11937   }//end of for       
11938    
11942 
11943   MSG("LIAnalysis",Msg::kInfo)<<"Finished main loop"<<endl; 
11944 
11945   //include the under and overflow counts 
11946   gStyle->SetOptStat(1111111); 
11947   //set up useful string 
11948   string sRunNumber=Form("%d",runNumber); 
11949   string sLowRunNumber=Form("%d",lowRunNumber);
11950   string sHighRunNumber=Form("%d",highRunNumber);
11951   s="";
11952   //set strings for use in titles
11953   string sPulseWidth=Form("%d",pulseWidth);
11954   string sPulseFreq=Form("%d",static_cast<Int_t>
11955                          (ceil(1.0/(period*1.0e-5))));
11956 
11957   //allocate space for TGraphs then loop and create them all
11958   TGraph **gAdcVsPinNear=0;
11959   TGraph **gAdcVsPinFar=0;
11960   gAdcVsPinNear=new TGraph*[NUMPULSERBOXES*NUMLEDS];
11961   gAdcVsPinFar=new TGraph*[NUMPULSERBOXES*NUMLEDS];
11962 
11963   TGraph **gNonlinearity=0;
11964   gNonlinearity=new TGraph*[NUMPULSERBOXES*NUMLEDS];
11965   TGraph **gResiduals=0;
11966   gResiduals=new TGraph*[NUMPULSERBOXES*NUMLEDS];
11967 
11968   for ( Int_t l=0;l<NUMPULSERBOXES*NUMLEDS;l++){
11969     gAdcVsPinNear[l]=new TGraph(const_numCalibPoints);
11970     gAdcVsPinFar[l]=new TGraph(const_numCalibPoints);
11971     gNonlinearity[l]=new TGraph(const_numCalibPoints);
11972     gResiduals[l]=new TGraph(const_numCalibPoints);
11973 
11974     //set minimum on all graphs
11975     gAdcVsPinNear[l]->SetMinimum(-1);
11976     gAdcVsPinFar[l]->SetMinimum(-1);
11977     //set maximum on all graphs
11978     gAdcVsPinNear[l]->SetMaximum(15000);
11979     gAdcVsPinFar[l]->SetMaximum(15000);
11980   }
11981 
11982   Int_t maxAdc=-1;
11983   Float_t* maxRatio=new Float_t[NUMPULSERBOXES*NUMLEDS];
11984 
11985   //find the max ratio for each point  
11986   for (Int_t i=0;i<NUMPULSERBOXES;i++){
11987     for (Int_t j=0;j<NUMLEDS;j++){
11988       Int_t l=i*NUMLEDS+j;
11989       maxRatio[l]=-1;
11990       for (Int_t k=0;k<const_numCalibPoints;k++){
11991         
11992         if (maxAdcLowPin[l][k]>0){
11993           if (hAdcPhNear[l][k]->GetMean()/maxAdcLowPin[l][k]>
11994               maxRatio[l]){
11995             maxRatio[l]=hAdcPhNear[l][k]->GetMean()/maxAdcLowPin[l][k];
11996           }
11997         }
11998       }
11999     }
12000   }
12001 
12002   //fill graphs
12003   for (Int_t i=0;i<NUMPULSERBOXES;i++){
12004     for (Int_t j=0;j<NUMLEDS;j++){
12005       Int_t l=i*NUMLEDS+j;
12006       for (Int_t k=0;k<const_numCalibPoints;k++){
12007         
12008         //set points for graphs
12009         gAdcVsPinNear[l]->SetPoint(k,maxAdcLowPin[l][k],
12010                                    hAdcPhNear[l][k]->GetMean());
12011         //what is the point of this one?
12012         gAdcVsPinFar[l]->SetPoint(k,maxAdcLowPin[l][k],
12013                                   hAdcPhFar[l][k]->GetMean());
12014         if (maxAdcLowPin[l][k]>0){
12015           //do pmt_adc/pin_adc VS pin_adc
12016           gNonlinearity[l]->SetPoint(k,maxAdcLowPin[l][k],
12017                                      (hAdcPhNear[l][k]->GetMean()/
12018                                      maxAdcLowPin[l][k])/maxRatio[l]);
12019         }
12020         else{
12021           gNonlinearity[l]->SetPoint(k,maxAdcLowPin[l][k],-1);
12022           MSG("LIAnalysis",Msg::kInfo)
12023             <<"("<<i<<":"<<j+1<<") Zero point"<<endl;
12024         }
12025 
12026         //get max for plot
12027         if (hAdcPhNear[l][k]->GetMean()>maxAdc) {
12028           maxAdc=static_cast<Int_t>(hAdcPhNear[l][k]->GetMean());
12029         }
12030       }
12031     }
12032   }
12033 
12034   Axis_t pinMax[6]={1500,1200,1700,900,1600,1000};
12035 
12036   //calculate the residuals
12037   //and fill the residuals graph
12038   for (Int_t i=0;i<NUMPULSERBOXES;i++){
12039     MSG("LIAnalysis",Msg::kInfo)<<"Doing plots for PB "<<i<<endl;
12040     for (Int_t j=0;j<NUMLEDS;j++){
12041       Int_t l=i*NUMLEDS+j;
12042 
12043       //a quick and nasty hack to get results for caldet
12044       if (l<6){
12045         gAdcVsPinNear[l]->Fit("pol1","q","",10.0,pinMax[l]);
12046       }
12047       else{
12048         gAdcVsPinNear[l]->Fit("pol1","q","",10.0,1500);
12049       }
12050 
12051       TF1* func=gAdcVsPinNear[l]->GetFunction("pol1");
12052       Double_t funcC=func->GetParameter(0);
12053       Double_t funcM=func->GetParameter(1);
12054 
12055       gAdcVsPinNear[l]->Draw("AP");
12056       Axis_t xMax=gAdcVsPinNear[l]->GetXaxis()->GetXmax();
12057       Axis_t xMin=gAdcVsPinNear[l]->GetXaxis()->GetXmin();
12058 
12059       MSG("LIAnalysis",Msg::kInfo)
12060         <<"("<<i<<":"<<j+1<<") y="<<funcM<<"x+"<<funcC
12061         <<", xMin="<<xMin<<", xMax="<<xMax<<endl;
12062 
12063       for (Int_t k=0;k<const_numCalibPoints;k++){     
12064         
12065         Double_t actualX=-1;
12066         Double_t actualYval=-1;
12067         gAdcVsPinNear[l]->GetPoint(k,actualX,actualYval);
12068         //do y=mx+c to get value on straight line fit
12069         Double_t fittedYval=funcM*actualX+funcC;
12070 
12071         //calculate the residual and normalise    
12072         Double_t resid=actualYval-fittedYval;
12073         resid/=fittedYval;
12074 
12075         //set the point on the graph
12076         if (actualX>0){
12077           gResiduals[l]->SetPoint(k,actualX,resid);
12078         }
12079         else {
12080           MSG("LIAnalysis",Msg::kInfo)
12081             <<"Setting a zero in residuals"<<endl;
12082           gResiduals[l]->SetPoint(k,actualX,0);
12083         }
12084 
12085         MSG("LIAnalysis",Msg::kInfo)
12086           <<"("<<i<<":"<<j+1<<") k="<<k<<", x="<<actualX
12087           <<", y="<<actualYval
12088           <<", fitY="<<fittedYval<<", resid="<<resid<<i<<endl;
12089       }     
12090     }
12091   }
12092 
12096 
12097   //create canvas
12098   TCanvas *c=new TCanvas("c","c",0,0,1200,600);
12099   c->SetFillColor(0);
12100 
12101   //turn off the fit stats box
12102   gStyle->SetOptFit(0000);
12103                     
12104   //plot the graphs
12105   for (Int_t i=0;i<NUMPULSERBOXES;i++){
12106     MSG("LIAnalysis",Msg::kInfo)<<"Doing plots for PB "<<i<<endl;
12107     for (Int_t j=0;j<NUMLEDS;j++){
12108       Int_t l=i*NUMLEDS+j;
12109 
12110       //draw the graphs of the pin adc vs pulse height
12111       c->cd();
12112       c->Clear();
12113       string sPulserBox=Form("%d",i);
12114       string sLed=Form("%d",j+1);
12115       s="Gain Curve (PB="+sPulserBox+
12116         ", LED="+sLed+", PW="+sPulseWidth+", PF="+sPulseFreq+" Hz)";
12117       gAdcVsPinNear[l]->Draw("AP");
12118       gAdcVsPinNear[l]->SetTitle(s.c_str());
12119       gAdcVsPinNear[l]->GetXaxis()->SetTitle("Pin Adc");
12120       gAdcVsPinNear[l]->GetYaxis()->SetTitle("Pmt Adc");
12121       gAdcVsPinNear[l]->GetXaxis()->CenterTitle();
12122       gAdcVsPinNear[l]->GetYaxis()->CenterTitle();
12123       gAdcVsPinNear[l]->SetMarkerStyle(3);
12124       gAdcVsPinNear[l]->SetMarkerColor(2);
12125       gAdcVsPinNear[l]->SetMarkerSize(0.55);
12126       gAdcVsPinNear[l]->SetLineColor(46);
12127 
12128       gAdcVsPinNear[l]->SetMinimum(-1);
12129       gAdcVsPinNear[l]->SetMaximum(maxAdc);
12130 
12131       s="GainCurves_Led.ps";
12132       //print graph to postscript      
12133       if(i*NUMLEDS+j==0){
12134         if (sLowRunNumber==sHighRunNumber) s=sHighRunNumber+s+"(";
12135         else s=sLowRunNumber+"-"+sHighRunNumber+s+"(";
12136         c->Print(s.c_str());
12137       }
12138       else if(i*NUMLEDS+j==NUMLEDS*NUMPULSERBOXES-1){
12139         gErrorIgnoreLevel=0;
12140         if (sLowRunNumber==sHighRunNumber) s=sHighRunNumber+s+")";
12141         else s=sLowRunNumber+"-"+sHighRunNumber+s+")";
12142         c->Print(s.c_str());
12143         MSG("LIAnalysis",Msg::kInfo)<<"Done last plot"<<endl;
12144       }
12145       else{
12146         gErrorIgnoreLevel=1;
12147         if (sLowRunNumber==sHighRunNumber) s=sHighRunNumber+s;
12148         else s=sLowRunNumber+"-"+sHighRunNumber+s;
12149         c->Print(s.c_str());
12150       }
12151     }
12152   }
12153 
12154   //plot the graphs
12155   for (Int_t i=0;i<NUMPULSERBOXES;i++){
12156     MSG("LIAnalysis",Msg::kDebug)<<"Doing plots for PB "<<i<<endl;
12157     for (Int_t j=0;j<NUMLEDS;j++){
12158       Int_t l=i*NUMLEDS+j;
12159       MSG("LIAnalysis",Msg::kDebug)<<"Doing plots for led "<<j+1<<endl;
12160       //draw the graphs of the pin adc vs pulse height
12161       c->cd();
12162       c->Clear();
12163       string sPulserBox=Form("%d",i);
12164       string sLed=Form("%d",j+1);
12165       s="PMT Nonlinearity (PB="+sPulserBox+
12166         ", LED="+sLed+", PW="+sPulseWidth+", PF="+sPulseFreq+" Hz)";
12167       gNonlinearity[l]->Draw("AP");
12168       gNonlinearity[l]->SetTitle(s.c_str());
12169       gNonlinearity[l]->GetXaxis()->SetTitle("Pin Adc");
12170       gNonlinearity[l]->GetYaxis()->SetTitle("Pmt Adc / Pin Adc");
12171       gNonlinearity[l]->GetXaxis()->CenterTitle();
12172       gNonlinearity[l]->GetYaxis()->CenterTitle();
12173       gNonlinearity[l]->SetMarkerStyle(3);
12174       gNonlinearity[l]->SetMarkerColor(2);
12175       gNonlinearity[l]->SetMarkerSize(0.35);
12176       gNonlinearity[l]->SetLineColor(46);
12177       //gNonlinearity[l]->SetMinimum(-1);
12178       //gNonlinearity[l]->SetMaximum(maxAdc);
12179 
12180       s="GainCurvesNonLin_Led.ps";
12181       //print graph to postscript      
12182       if(i*NUMLEDS+j==0){
12183         if (sLowRunNumber==sHighRunNumber) s=sHighRunNumber+s+"(";
12184         else s=sLowRunNumber+"-"+sHighRunNumber+s+"(";
12185         c->Print(s.c_str());
12186       }
12187       else if(i*NUMLEDS+j==NUMLEDS*NUMPULSERBOXES-1){
12188         gErrorIgnoreLevel=0;
12189         if (sLowRunNumber==sHighRunNumber) s=sHighRunNumber+s+")";
12190         else s=sLowRunNumber+"-"+sHighRunNumber+s+")";
12191         c->Print(s.c_str());
12192         MSG("LIAnalysis",Msg::kInfo)<<"Done last plot"<<endl;
12193       }
12194       else{
12195         gErrorIgnoreLevel=1;
12196         if (sLowRunNumber==sHighRunNumber) s=sHighRunNumber+s;
12197         else s=sLowRunNumber+"-"+sHighRunNumber+s;
12198         c->Print(s.c_str());
12199       }
12200     }
12201   }
12202 
12203   //plot the graphs
12204   for (Int_t i=0;i<NUMPULSERBOXES;i++){
12205     MSG("LIAnalysis",Msg::kDebug)<<"Doing plots for PB "<<i<<endl;
12206     for (Int_t j=0;j<NUMLEDS;j++){
12207       Int_t l=i*NUMLEDS+j;
12208       MSG("LIAnalysis",Msg::kDebug)<<"Doing plots for led "<<j+1<<endl;
12209       //draw the graphs of the pin adc vs pulse height
12210       c->cd();
12211       c->Clear();
12212       string sPulserBox=Form("%d",i);
12213       string sLed=Form("%d",j+1);
12214       s="Residuals (PB="+sPulserBox+
12215         ", LED="+sLed+", PW="+sPulseWidth+", PF="+sPulseFreq+" Hz)";
12216       gResiduals[l]->Draw("AP");
12217       gResiduals[l]->SetTitle(s.c_str());
12218       gResiduals[l]->GetXaxis()->SetTitle("Pin Adc");
12219       gResiduals[l]->GetYaxis()->SetTitle("Residual");
12220       gResiduals[l]->GetXaxis()->CenterTitle();
12221       gResiduals[l]->GetYaxis()->CenterTitle();
12222       gResiduals[l]->SetMarkerStyle(3);
12223       gResiduals[l]->SetMarkerColor(2);
12224       gResiduals[l]->SetMarkerSize(0.55);
12225       gResiduals[l]->SetLineColor(46);
12226       gResiduals[l]->SetMinimum(-1);
12227       gResiduals[l]->SetMaximum(1);
12228 
12229       s="GainCurvesResid_Led.ps";
12230       //print graph to postscript      
12231       if(i*NUMLEDS+j==0){
12232         if (sLowRunNumber==sHighRunNumber) s=sHighRunNumber+s+"(";
12233         else s=sLowRunNumber+"-"+sHighRunNumber+s+"(";
12234         c->Print(s.c_str());
12235       }
12236       else if(i*NUMLEDS+j==NUMLEDS*NUMPULSERBOXES-1){
12237         gErrorIgnoreLevel=0;
12238         if (sLowRunNumber==sHighRunNumber) s=sHighRunNumber+s+")";
12239         else s=sLowRunNumber+"-"+sHighRunNumber+s+")";
12240         c->Print(s.c_str());
12241         MSG("LIAnalysis",Msg::kInfo)<<"Done last plot"<<endl;
12242       }
12243       else{
12244         gErrorIgnoreLevel=1;
12245         if (sLowRunNumber==sHighRunNumber) s=sHighRunNumber+s;
12246         else s=sLowRunNumber+"-"+sHighRunNumber+s;
12247         c->Print(s.c_str());
12248