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, std::string destfilename="")
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

Detailed Description

Definition at line 28 of file LIAnalysis.h.


Constructor & Destructor Documentation

LIAnalysis::LIAnalysis ( Int_t  analyseChainFlag  ) 

Definition at line 66 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, Msg::kDebug, Msg::kInfo, lastCalibPoint, lastLed, lastPulserBox, lastRunNumber, led, liEvent, liRunNum, lowRunNumber, MakeChain(), masterCh, maxCalibPoint, maxLedNum, maxPbNum, mean, minderCh, MSG, nearLed, nearPulserBox, numCalibPoints, numEntries, numericMuxBox, numEvents, numLeds, LILookup::NUMLEDS, numLiEvents, numLiEventsL, numLiEventsP, numLiRuns, LILookup::NUMPULSERBOXES, period, pinGain, pinInBox, pixel, plane, previousRunNumber, pulseHeight, pulserBox, pulses, pulseWidth, rackBay, rackLevel, readoutType, rms, run, runNumber, runNumberSub, runType, SetChainBranches(), LILookup::SetDetector(), strip, stripEnd, summaryCounter, timestamp, timestampNanoSec, varc, vfb, and vmm.

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

LIAnalysis::~LIAnalysis (  ) 

Definition at line 199 of file LIAnalysis.cxx.

References Msg::kDebug, and MSG.

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


Member Function Documentation

void LIAnalysis::AdcDistribution (  ) 

Definition at line 6351 of file LIAnalysis.cxx.

References calibPoint, correlatedHit, crate, detectorType, MuELoss::e, eastWest, farPulserBox, LILookup::FIRSTPULSERBOX, Form(), histname, InitialiseLoopVariables(), Detector::kCalDet, Msg::kInfo, LILookup::kNearSide, ReadoutType::kScintStrip, Msg::kWarning, LILookup::LASTPLANE, LILookup::LASTPULSERBOX, led, lookup, mean, MSG, LILookup::NearOrFar(), nearPulserBox, numEntries, numEvents, LILookup::NUMPULSERBOXES, period, plane, pulseHeight, pulserBox, pulseWidth, readoutType, rms, runNumber, and SetLoopVariables().

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

void LIAnalysis::AdcVsChannel ( Int_t  plane,
Int_t  crate 
)

Definition at line 5709 of file LIAnalysis.cxx.

References channel, chip, correlatedHit, crate, histname, InitialiseLoopVariables(), Msg::kInfo, ReadoutType::kScintStrip, Msg::kVerbose, mean, MSG, LILookup::NUMCHIPS, numEntries, numEvents, pixel, plane, pulserBox, readoutType, rms, SetLoopVariables(), and strip.

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

void LIAnalysis::AdcVsLed (  ) 

Definition at line 9620 of file LIAnalysis.cxx.

References correlatedHit, crate, detectorType, draw(), MuELoss::e, farPulserBox, LILookup::FIRSTCRATE, LILookup::FIRSTLED, LILookup::FIRSTPULSERBOX, Form(), histname, InitialiseLoopVariables(), Detector::kCalDet, Msg::kDebug, StripEnd::kEast, Detector::kFar, LILookup::kFarSide, Msg::kInfo, Detector::kNear, LILookup::kNearSide, ReadoutType::kScintStrip, Msg::kWarning, StripEnd::kWest, LILookup::LASTCRATE, LILookup::LASTLED, LILookup::LASTPULSERBOX, led, lookup, lowRunNumber, mean, MSG, LILookup::NearOrFar(), nearPulserBox, numEntries, numEvents, LILookup::NUMLEDS, LILookup::NUMPULSERBOXES, period, plane, pulseHeight, pulserBox, pulses, pulseWidth, rackLevel, readoutType, rms, runNumber, SetLoopVariables(), and stripEnd.

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

void LIAnalysis::AdcVsPin (  ) 

Definition at line 1084 of file LIAnalysis.cxx.

References chain, chip, correlatedHit, draw(), MuELoss::e, LILookup::FIRSTLED, LILookup::FIRSTPULSERBOX, Form(), GetElecString(), histname, InitialiseLoopVariables(), Msg::kDebug, Msg::kInfo, ReadoutType::kPinDiode, LILookup::LASTLED, LILookup::LASTPULSERBOX, led, lowRunNumber, mean, MSG, numEntries, numEvents, LILookup::NUMLEDS, LILookup::NUMPULSERBOXES, period, pinGain, pulseHeight, pulserBox, pulses, pulseWidth, readoutType, rms, runNumber, and SetLoopVariables().

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

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

Definition at line 5447 of file LIAnalysis.cxx.

References ashtray, chain, channel, chip, correlatedHit, crate, detectorType, Draw(), farLed, farPulserBox, Form(), InitialiseLoopVariables(), Detector::kCalDet, Detector::kFar, LILookup::kFarSide, Msg::kInfo, LILookup::kNearSide, ReadoutType::kScintStrip, Msg::kWarning, led, lookup, mean, MSG, nearLed, LILookup::NearOrFar(), nearPulserBox, LILookup::NUMCHIPS, LILookup::NUMCRATES, numEntries, numEvents, pixel, plane, LILookup::Plane2CrateEast(), LILookup::Plane2CrateWest(), pulserBox, readoutType, rms, runNumber, SetFillColor(), SetLoopVariables(), and strip.

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

void LIAnalysis::AnalyseChain (  )  [private]

Definition at line 332 of file LIAnalysis.cxx.

References calibPoint, InitialiseLoopVariables(), Msg::kDebug, Msg::kInfo, lastLed, led, liEvent, liRunNum, maxCalibPoint, maxLedNum, maxPbNum, MSG, numCalibPoints, numEvents, numLeds, LILookup::NUMLEDS, numLiEvents, numLiEventsL, numLiEventsP, numLiRuns, LILookup::NUMPULSERBOXES, pulseHeight, pulserBox, pulseWidth, and SetLoopVariables().

Referenced by LIAnalysis().

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

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

Referenced by PmtGain().

void LIAnalysis::AshtrayVsPlane ( Int_t  nearPb,
Int_t  farPb 
)

Definition at line 4916 of file LIAnalysis.cxx.

References ashtray, chain, correlatedHit, crate, detectorType, farPulserBox, LILookup::FIRSTASHTRAY, LILookup::FIRSTPULSERBOX, LILookup::FIRSTSCINTPLANE, Form(), histname, InitialiseLoopVariables(), Msg::kInfo, ReadoutType::kScintStrip, Msg::kVerbose, LILookup::LASTPULSERBOX, LILookup::LASTSCINTPLANE, lookup, mean, MSG, nearLed, nearPulserBox, LILookup::NUMASHTRAYS, numEntries, numEvents, LILookup::NUMPULSERBOXES, pixel, plane, pulserBox, readoutType, rms, runNumber, SetLoopVariables(), and LILookup::SetPbPlanes().

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

void LIAnalysis::CalcAdcAv (  ) 

Definition at line 6873 of file LIAnalysis.cxx.

References calibPoint, Draw(), histname, InitialiseLoopVariables(), Msg::kInfo, ReadoutType::kScintStrip, led, mean, MSG, nearPulserBox, numCalibPoints, numEntries, numEvents, LILookup::NUMLEDS, LILookup::NUMPULSERBOXES, pulseHeight, pulserBox, readoutType, rms, SetFillColor(), and SetLoopVariables().

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

void LIAnalysis::ChannelAdc ( Int_t  chan,
Int_t  chan2 
)

Definition at line 7091 of file LIAnalysis.cxx.

References correlatedHit, crate, InitialiseLoopVariables(), Msg::kInfo, mean, minderCh, MSG, numEvents, and SetLoopVariables().

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

void LIAnalysis::CheckData ( Int_t  rt = -1  ) 

Definition at line 7213 of file LIAnalysis.cxx.

References ashtray, bfld::AsString(), calibPoint, calibType, chAdd, channel, chip, correlatedHit, crate, eastWest, elecType, farLed, farPulserBox, LILookup::FIRSTPULSERBOX, geoAdd, InitialiseLoopVariables(), inRack, Msg::kInfo, LILookup::LASTPULSERBOX, led, masterCh, mean, minderCh, MSG, nearLed, nearPulserBox, numEntries, numericMuxBox, numEvents, LILookup::NUMPULSERBOXES, 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.

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

void LIAnalysis::ClearFibres (  ) 

Definition at line 825 of file LIAnalysis.cxx.

References Msg::kInfo, led, and MSG.

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

void LIAnalysis::DebugPins (  ) 

Definition at line 1816 of file LIAnalysis.cxx.

References chAdd, chip, correlatedHit, crate, detectorType, eastWest, LILookup::FIRSTLED, LILookup::FIRSTPULSERBOX, Form(), geoAdd, GetElecString(), InitialiseLoopVariables(), inRack, MsgService::Instance(), Detector::kCalDet, Msg::kDebug, Msg::kInfo, ReadoutType::kPinDiode, Msg::kVerbose, LILookup::LASTLED, LILookup::LASTPULSERBOX, led, lowRunNumber, masterCh, mean, MSG, nearLed, numEntries, numEvents, LILookup::NUMLEDS, LILookup::NUMPULSERBOXES, pinGain, pinInBox, plane, PrintBigMessage(), pulserBox, pulses, rackBay, rackLevel, readoutType, rms, runNumber, SetLoopVariables(), varc, vfb, and vmm.

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

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

Definition at line 12259 of file LIAnalysis.cxx.

References LILookup::CalcGain(), calibPoint, calibType, chain, chip, correlatedHit, crate, detectorType, MuELoss::e, farPulserBox, LILookup::FIRSTCRATE, LILookup::FIRSTEND, LILookup::FIRSTLED, LILookup::FIRSTPLANE, LILookup::FIRSTPULSERBOX, LILookup::FIRSTSTRIP, Form(), GetElecString(), highRunNumber, InitialiseLoopVariables(), MsgService::Instance(), Detector::kCalDet, Msg::kDebug, Detector::kFar, LILookup::kFarSide, LIRun::kGainCurve, Msg::kInfo, Detector::kNear, LILookup::kNearSide, ReadoutType::kPinDiode, ReadoutType::kScintStrip, Msg::kVerbose, Msg::kWarning, LILookup::LASTCRATE, LILookup::LASTLED, LILookup::LASTPLANE, LILookup::LASTPULSERBOX, LILookup::LASTSTRIP, led, lookup, lowRunNumber, mean, MSG, LILookup::NearOrFar(), nearPulserBox, numEntries, numEvents, LILookup::NUMLEDS, LILookup::NUMPLANES, LILookup::NUMPULSERBOXES, LILookup::NUMSIDES, LILookup::NUMSTRIPS, period, pinGain, plane, print(), pulseHeight, pulserBox, pulses, pulseWidth, readoutType, rms, runNumber, LILookup::SECONDEND, SetLoopVariables(), strip, stripEnd, and TGraphVect().

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

void LIAnalysis::GainCurves_Led (  ) 

Definition at line 11679 of file LIAnalysis.cxx.

References calibPoint, calibType, chain, chip, correlatedHit, crate, detectorType, MuELoss::e, farLed, farPulserBox, LILookup::FIRSTCRATE, LILookup::FIRSTLED, LILookup::FIRSTPULSERBOX, Form(), GetElecString(), highRunNumber, InitialiseLoopVariables(), Detector::kCalDet, Msg::kDebug, Detector::kFar, Msg::kInfo, ReadoutType::kPinDiode, ReadoutType::kScintStrip, LILookup::LASTCRATE, LILookup::LASTLED, LILookup::LASTPULSERBOX, led, lowRunNumber, mean, MSG, nearLed, nearPulserBox, numEntries, numEvents, LILookup::NUMLEDS, LILookup::NUMPULSERBOXES, period, pinGain, pulseHeight, pulserBox, pulseWidth, readoutType, rms, runNumber, SetFillColor(), and SetLoopVariables().

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

void LIAnalysis::GainVsTime (  ) 

Definition at line 9250 of file LIAnalysis.cxx.

References calibPoint, calibType, chain, detectorType, Form(), Msg::kInfo, Detector::kNear, ReadoutType::kScintStrip, Msg::kWarning, lastCalibPoint, lastLed, lastPulserBox, led, liEvent, liRunNum, lowRunNumber, mean, MSG, numEntries, numEvents, LILookup::NUMPULSERBOXES, pulseHeight, pulserBox, pulses, readoutType, rms, runNumber, and timestamp.

09251 {
09252   MSG("LIAnalysis",Msg::kInfo) 
09253     <<endl<<" ** Running the GainVsTime method... ** "<<endl;
09254 
09255   const Float_t adcUpperCut=8000;
09256   const Float_t adcLowerCut=800;
09257   const Float_t pulsesCut=90;//in percent of pulses
09258   string sAdcUpper=Form("%d",static_cast<Int_t>(adcUpperCut));
09259   string sAdcLower=Form("%d",static_cast<Int_t>(adcLowerCut));
09260   string sPulsesCut=Form("%d",static_cast<Int_t>(pulsesCut));
09261 
09262   vector<Float_t> avGain;
09263   vector<Float_t> avGainFitted;
09264   vector<Float_t> avGainError;
09265   vector<Float_t> avGainNumEnt;
09266   vector<Float_t> avGainTimestamp;
09267   vector<Float_t> avGainRms;
09268   vector<Float_t> avGainRmsFitted;
09269 
09270   TH1F *hGain=new TH1F("hGain","PMT Gains",1000,-5,400); 
09271   hGain->GetXaxis()->SetTitle("PMT Gain"); 
09272   hGain->GetXaxis()->CenterTitle(); 
09273   hGain->GetYaxis()->SetTitle(""); 
09274   hGain->GetYaxis()->CenterTitle(); 
09275   hGain->SetFillColor(0); 
09276 
09280   
09281   liEvent=-1;//want first event to be 0 not 1
09282   liRunNum=-1;
09283   lastLed=1000;
09284   lastPulserBox=1000;
09285   lastCalibPoint=1000;
09286   chain->GetEvent(0); 
09287   lowRunNumber=runNumber;
09288 
09289   for(Int_t entry=0;entry<numEvents;entry++){
09290     if (ceil(((Float_t)entry)/50000.)==((Float_t)entry)/50000.){
09291       MSG("LIAnalysis",Msg::kInfo)
09292         <<"Fraction of loop complete: "<<entry
09293         <<"/"<<numEvents<<"  ("
09294         <<(Int_t)(100.*entry/numEvents)<<"%)"<<endl;
09295     }
09296     
09297     chain->GetEvent(entry); 
09298     if (runNumber<lowRunNumber) lowRunNumber=runNumber;
09299     //skip if gain curve file
09300     if (calibType!=1){
09301       MSG("LIAnalysis",Msg::kInfo)
09302         <<" *** WARNING, Gain Curve file ***"<<endl
09303         <<"Run number = "<<runNumber<<endl;
09304     }
09305     
09306     //calculate which set of pulses is currently being looped through
09307     if (lastLed-led>0 && lastPulserBox-pulserBox>0){
09308       //check that the last file contained all pulser boxes
09309       if (lastPulserBox<NUMPULSERBOXES-3){
09310         MSG("LIAnalysis",Msg::kWarning)
09311           <<endl<<endl<<" *** WARNING, file doesn't contain all PBs ***"
09312           <<endl
09313           <<" *** Run number = "<<runNumber<<" ***"<<endl
09314           <<" *** Last Pulser Box = "<<lastPulserBox<<" ***"<<endl
09315           <<" *** NUMPULSERBOXES = "
09316           <<NUMPULSERBOXES<<" ***"<<endl        
09317           <<" *** Exiting loop now! ***"<<endl<<endl;
09318         //exit(0);
09319         break;
09320       }
09321       else if (lastPulserBox<NUMPULSERBOXES-1){
09322         MSG("LIAnalysis",Msg::kWarning)
09323           <<endl<<endl<<" *** WARNING, file does not contain all PBs ***"
09324           <<endl
09325           <<" *** Run number = "<<runNumber<<" ***"<<endl
09326           <<" *** Last Pulser Box = "<<lastPulserBox<<" ***"<<endl
09327           <<" *** NUMPULSERBOXES = "
09328           <<NUMPULSERBOXES<<" ***"<<endl;
09329       }
09330 
09331       //check number of pulses
09332       if (pulses<1000){
09333         MSG("LIAnalysis",Msg::kInfo)
09334           <<" *** WARNING, file doesn't contain enough pulses ***"<<endl
09335           <<" *** Run number = "<<runNumber<<" ***"<<endl
09336           <<" *** Number of pulses = "<<pulses<<" ***"<<endl;
09337           //<<" *** Exiting loop now! *** "<<endl;
09338           //break;
09339       }
09340 
09341       //check pulse height
09342       if (pulseHeight!=250){
09343         MSG("LIAnalysis",Msg::kInfo)
09344           <<" *** WARNING, file doesn't have pulse height 250 ***"<<endl
09345           <<" *** Run number = "<<runNumber<<" ***"<<endl
09346           <<" *** Pulse Height = "<<pulseHeight<<" ***"<<endl
09347           <<" *** Exiting loop now! *** "<<endl;
09348         break;
09349       }
09350 
09351       liRunNum++;
09352       MSG("LIAnalysis",Msg::kInfo)
09353         <<"liRunNum="<<liRunNum<<", Run Number="<<runNumber
09354         <<", PH="<<pulseHeight<<", PN="<<pulses
09355         <<endl;
09356       avGain.push_back(0);//expand vector and initialise with 0
09357       avGainFitted.push_back(0);
09358       avGainError.push_back(0);
09359       avGainNumEnt.push_back(0);
09360       avGainTimestamp.push_back(0);
09361       avGainRms.push_back(0);
09362       avGainRmsFitted.push_back(0);
09363       if (liRunNum>0){
09364         avGain[liRunNum-1]=hGain->GetMean();
09365         avGainRms[liRunNum-1]=hGain->GetRMS();
09366         hGain->Fit("gaus","q");
09367         TF1* func=hGain->GetFunction("gaus");
09368         avGainFitted[liRunNum-1]=func->GetParameter(1);
09369         avGainRmsFitted[liRunNum-1]=func->GetParameter(2);
09370         MSG("LIAnalysis",Msg::kInfo)
09371           <<"Fitted mean="<<avGainFitted[liRunNum-1]
09372           <<", mean="<<avGain[liRunNum-1]
09373           <<"    Fitted rms="<<avGainRmsFitted[liRunNum-1]
09374           <<", rms="<<avGainRms[liRunNum-1]<<endl;
09375         hGain->Reset();
09376       }
09377     }
09378     
09379     //calculate whether a new led is being flashed
09380     if (led!=lastLed) liEvent++;//defined as a new LED flashing
09381 
09382     lastLed=led;    
09383     lastPulserBox=pulserBox;
09384     lastCalibPoint=calibPoint;
09385     
09386     //ignore any zeros that slipped through
09387     if (mean==0 || rms==0 || numEntries==0) continue;
09388 
09389     //only look at scint strips
09390     if (readoutType!=ReadoutType::kScintStrip) continue;
09391 
09392     if (mean>adcLowerCut && mean<adcUpperCut && 
09393         numEntries>(pulsesCut/100.)*pulses){
09394       Float_t npe=mean*mean/(rms*rms);
09395       Float_t gain=0.8*mean/npe;
09396 
09397       // PMT fudge factor for M64 (near detector): 0.844
09398       if (detectorType==Detector::kNear) gain = 0.844*rms*rms/mean;
09399       
09400       hGain->Fill(gain);
09401       
09402       avGainNumEnt[liRunNum]++;
09403       avGainTimestamp[liRunNum]=timestamp;
09404     }
09405   }//end of for                                       
09406 
09410 
09411   MSG("LIAnalysis",Msg::kInfo)<<"Finished main loop"<<endl;
09412 
09413   string sRunNumber=Form("%d",runNumber);
09414   string sLowRunNumber=Form("%d",lowRunNumber); 
09415 
09416   //include the under and overflow counts
09417   gStyle->SetOptStat(1111111);
09418 
09419   avGain[liRunNum]=hGain->GetMean();
09420   avGainRms[liRunNum]=hGain->GetRMS();
09421   hGain->Fit("gaus","q");
09422   TF1* func=hGain->GetFunction("gaus");
09423   avGainFitted[liRunNum]=func->GetParameter(1);
09424   avGainRmsFitted[liRunNum]=func->GetParameter(2);
09425   MSG("LIAnalysis",Msg::kInfo)
09426     <<"Fitted mean="<<avGainFitted[liRunNum]
09427     <<", mean="<<avGain[liRunNum]
09428     <<"    Fitted rms="<<avGainRmsFitted[liRunNum]
09429     <<", rms="<<avGainRms[liRunNum]<<endl;
09430 
09431   MSG("LIAnalysis",Msg::kInfo) 
09432     <<"Number of drift points found = "<<avGain.size()<<endl;
09433   for(UInt_t i=0;i<avGain.size();i++){
09434     if (avGain.size()!=avGainNumEnt.size()){
09435       MSG("LIAnalysis",Msg::kWarning) 
09436         <<"Drift point arrays different sizes, aborted calculation"
09437         <<endl;
09438       break;
09439     }
09440     else if (avGain[i]==0 || avGainNumEnt[i]==0){
09441       MSG("LIAnalysis",Msg::kInfo)
09442         <<"Found zeros...   "
09443         <<"avGain["<<i<<"]="<<avGain[i]
09444         <<", numEnt["<<i<<"]="<<avGainNumEnt[i]
09445         <<endl;
09446       continue;
09447     }
09448     //avGain[i]=avGain[i]/avGainNumEnt[i];
09449     MSG("LIAnalysis",Msg::kInfo)
09450       <<"avGain["<<i<<"]="<<avGain[i]
09451       <<", avGainFitted["<<i<<"]="<<avGainFitted[i]<<endl;
09452   }
09453 
09454   Float_t maxGain=0;
09455   Float_t minGain=avGain[0];
09456 
09457   //allocate space for TGraph then loop and fill it
09458   TGraph *gAvGain=new TGraph(avGain.size());
09459   TGraph *gAvGainFitted=new TGraph(avGainFitted.size());
09460   for(UInt_t i=0;i<avGain.size();i++){
09461     if (avGain.size()!=avGainTimestamp.size()){
09462       MSG("LIAnalysis",Msg::kWarning) 
09463         <<"Drift point arrays different sizes, aborted graph plotting"
09464         <<endl;
09465       break;
09466     }
09467     if (avGain[i]>maxGain) maxGain=avGain[i];
09468     if (avGainFitted[i]>maxGain) maxGain=avGainFitted[i];
09469     if (avGain[i]<minGain) minGain=avGain[i];
09470     if (avGainFitted[i]<minGain) minGain=avGainFitted[i];
09471     gAvGainFitted->SetPoint(i,avGainTimestamp[i],avGainFitted[i]);
09472     gAvGain->SetPoint(i,avGainTimestamp[i],avGain[i]);
09473   }
09474 
09475   TCanvas *cGainBoth=new TCanvas("cGainBoth","Average Gain vs Time",
09476                              0,0,1200,600);
09477   cGainBoth->SetFillColor(0);
09478   cGainBoth->cd();
09479   gAvGain->Draw("AP");
09480   gAvGain->SetTitle("Average Gain vs Time");
09481   gAvGain->GetXaxis()->SetTitle("Time");
09482   gAvGain->GetYaxis()->SetTitle("Gain (mean/NPE)");
09483   gAvGain->GetXaxis()->CenterTitle();
09484   gAvGain->GetYaxis()->CenterTitle();   
09485   gAvGain->SetMarkerStyle(3);
09486   gAvGain->SetMarkerColor(4);
09487   gAvGain->SetMarkerSize(0.3);
09488   gAvGain->GetXaxis()->SetTimeFormat("%d/%m");
09489   gAvGain->GetXaxis()->SetTimeDisplay(1);
09490   gAvGain->GetXaxis()->SetNdivisions(10);
09491   gAvGain->SetMinimum(minGain-0.2*(maxGain-minGain));
09492   gAvGain->SetMaximum(maxGain+0.2*(maxGain-minGain));
09493 
09494   gAvGainFitted->Draw("P");
09495   gAvGainFitted->SetTitle("Average Gain vs Time");
09496   gAvGainFitted->SetMarkerStyle(3);
09497   gAvGainFitted->SetMarkerColor(2);
09498   gAvGainFitted->SetMarkerSize(0.3);
09499 
09500   s=sLowRunNumber+"-"+sRunNumber+"GainVsTimeBoth.eps";
09501   cGainBoth->Print(s.c_str());
09502 
09503   //draw the fitted one on its own
09504   TCanvas *cGain=new TCanvas("cGain","Average Gain vs Time", 
09505                              0,0,1200,600); 
09506   cGain->SetFillColor(0); 
09507   cGain->cd(); 
09508   gAvGainFitted->Draw("AP"); 
09509   gAvGainFitted->SetTitle("Average Gain vs Time"); 
09510   gAvGainFitted->GetXaxis()->SetTitle("Time"); 
09511   gAvGainFitted->GetYaxis()->SetTitle("Gain (mean/NPE)"); 
09512   gAvGainFitted->GetXaxis()->CenterTitle(); 
09513   gAvGainFitted->GetYaxis()->CenterTitle();    
09514   gAvGainFitted->SetMarkerStyle(3); 
09515   gAvGainFitted->SetMarkerColor(2); 
09516   gAvGainFitted->SetMarkerSize(0.3); 
09517   gAvGainFitted->GetXaxis()->SetTimeFormat("%d/%m"); 
09518   gAvGainFitted->GetXaxis()->SetTimeDisplay(1); 
09519   gAvGainFitted->GetXaxis()->SetNdivisions(10); 
09520   gAvGainFitted->SetMinimum(63.0);
09521   gAvGainFitted->SetMaximum(65.75);
09522 
09523   s=sLowRunNumber+"-"+sRunNumber+"GainVsTime.eps"; 
09524   cGain->Print(s.c_str()); 
09525 
09526   MSG("LIAnalysis",Msg::kInfo) 
09527     <<endl<<" ** Finished the GainVsTime method ** "<<endl;
09528 }

string LIAnalysis::GetElecString (  )  [private]

Definition at line 793 of file LIAnalysis.cxx.

References chip, crate, elecType, Form(), geoAdd, ElecType::kQIE, ElecType::kVA, Msg::kVerbose, masterCh, minderCh, MSG, varc, vfb, and vmm.

Referenced by AdcVsPin(), DebugPins(), GainCurves(), GainCurves_Led(), HighGainSearch(), IndividualChannels(), PmtGain(), PrintElec(), PrintPmt(), Reflectors(), ReflectorsGc(), TriggerPmt(), and WriteGainCurveTextFile().

00794 {
00795   MSG("LISummarySorter",Msg::kVerbose) 
00796     <<"Running GetElecString method..."<<endl;
00797 
00798   string elecString="";
00799   string sCrate=Form("%d",crate);
00800 
00801   if (elecType==ElecType::kVA){
00802     string sVarc=Form("%d",varc);
00803     string sVmm=Form("%d",vmm);
00804     string sVfb=Form("%d",vfb);
00805     string sChip=Form("%d",chip);
00806     string sElecType="VA";
00807     
00808     elecString=sElecType+
00809       "("+sCrate+","+sVarc+","+sVmm+","+sVfb+","+sChip+")";
00810   }     
00811   else if (elecType==ElecType::kQIE){
00812     string sGeoAdd=Form("%d",geoAdd);
00813     string sMasterCh=Form("%d",masterCh);
00814     string sMinderCh=Form("%d",minderCh);
00815     string sElecType="QIE";
00816     
00817     elecString=sElecType+
00818       "("+sCrate+","+sGeoAdd+","+sMasterCh+","+sMinderCh+")";
00819   }
00820   return elecString;
00821 }

void LIAnalysis::HighGainSearch ( Int_t  maxAdcThreshold,
Float_t  gainThreshold 
)

Definition at line 5358 of file LIAnalysis.cxx.

References channel, chip, correlatedHit, crate, detectorType, farPulserBox, GetElecString(), InitialiseLoopVariables(), Detector::kCalDet, Detector::kFar, Msg::kInfo, Detector::kNear, LILookup::kNearSide, ReadoutType::kScintStrip, led, lookup, mean, MSG, LILookup::NearOrFar(), nearPulserBox, numEntries, numEvents, plane, pulserBox, readoutType, rms, runNumber, and SetLoopVariables().

05360 {
05361   MSG("LIAnalysis",Msg::kInfo)
05362     <<endl<<" ** Running the HighGainSearch method... ** "<<endl;
05363 
05364   Int_t lastPb=-1;
05365   Int_t lastL=-1;
05366   Int_t lastPlane=-1;
05367   Int_t lastChip=-1;
05368 
05372   
05373   this->InitialiseLoopVariables();  
05374   
05375   for(Int_t entry=0;entry<numEvents;entry++){
05376     
05377     this->SetLoopVariables(entry,0);
05378     
05379     //avoid divide by zero errors and skip irrelevant data
05380     if (rms==0. || mean==0. || numEntries==0) continue;
05381     //only look at scintillator strips
05382     if (readoutType!=ReadoutType::kScintStrip) continue;
05383 
05384     Float_t gain=0.8*rms*rms/mean;
05385 
05386     // PMT fudge factor for M64 (near detector): 0.844
05387     if (detectorType==Detector::kNear) gain = 0.844*rms*rms/mean;
05388 
05389     if (lookup.NearOrFar(crate,pulserBox,nearPulserBox,farPulserBox,
05390                          led,detectorType,plane,runNumber)==
05391         LILookup::kNearSide &&
05392         detectorType==Detector::kCalDet){
05393       if (mean<maxAdcThreshold && gain>gainThreshold && 
05394           correlatedHit==1){
05395         if (plane==lastPlane && chip==lastChip){
05396           MSG("LIAnalysis",Msg::kInfo) 
05397             <<"  same pmt:"<<" chan="<<channel<<", mean="<<mean
05398             <<", gain="<<gain<<endl;
05399         }
05400         else{
05401           MSG("LIAnalysis",Msg::kInfo) 
05402             <<"High gain: pl="<<plane
05403             <<", "<<this->GetElecString()
05404             <<" mean="<<mean<<", gain="<<gain<<endl;
05405         }
05406         lastPlane=plane;
05407         lastChip=chip;
05408         lastL=led;
05409         lastPb=pulserBox;
05410       }
05411     }
05412     else if (detectorType==Detector::kFar){
05413       if (mean<maxAdcThreshold && gain>gainThreshold && 
05414           correlatedHit==1){
05415         if (plane==lastPlane && chip==lastChip){
05416           MSG("LIAnalysis",Msg::kInfo) 
05417             <<"  same pmt:"<<" chan="<<channel<<", mean="<<mean
05418             <<", gain="<<gain<<endl;
05419         }
05420         else{
05421           MSG("LIAnalysis",Msg::kInfo) 
05422             <<"High gain: pl="<<plane
05423             <<", "<<this->GetElecString()
05424             <<" mean="<<mean<<", gain="<<gain<<endl;
05425         }
05426         lastPlane=plane;
05427         lastChip=chip;
05428         lastL=led;
05429         lastPb=pulserBox;
05430       }
05431     }
05432 
05433   }//end of for
05434   
05438 
05439   MSG("LIAnalysis",Msg::kInfo)<<"Finished main loop"<<endl;
05440 
05441   MSG("LIAnalysis",Msg::kInfo)
05442     <<" ** Finished the HighGainSearch method ** "<<endl;
05443 }

void LIAnalysis::IndividualChannels (  ) 

Definition at line 5806 of file LIAnalysis.cxx.

References channel, correlatedHit, crate, farPulserBox, GetElecString(), histname, InitialiseLoopVariables(), Msg::kInfo, ReadoutType::kScintStrip, Msg::kVerbose, liRunNum, mean, MSG, nearPulserBox, LILookup::NUMCRATES, numEntries, numEvents, numLeds, numLiRuns, LILookup::NUMVACHANNELS, LILookup::NUMVARCS, LILookup::NUMVFBS, LILookup::NUMVMMS, plane, pulseHeight, pulserBox, readoutType, rms, SetLoopVariables(), strip, timestamp, varc, vfb, and vmm.

05807 {
05808 
05809   MSG("LIAnalysis",Msg::kInfo)
05810     <<endl<<" ** Running the IndividualChannels method... ** " 
05811     <<endl;
05812 
05813   const Int_t const_numLiRuns=numLiRuns;   
05814   const Int_t numDetChan=NUMCRATES*NUMVARCS*NUMVMMS*
05815     NUMVFBS*NUMVACHANNELS;
05816   MSG("LIAnalysis",Msg::kInfo)
05817     <<"Number of detector channels="<<numDetChan
05818     <<endl;
05819   
05820   Int_t *channelLed=new Int_t[numDetChan];
05821   //an array of arrays to hold gains for single channels
05822   Float_t **chanGain=0;
05823   Float_t **chanRms=0;
05824   Float_t **chanMean=0;
05825   Float_t **chanNpe=0;
05826   Float_t **chanNumEntries=0;
05827   Float_t **chanGainTime=0;
05828   Float_t **chanGainTemp=0;
05829 
05830   chanGain=new Float_t*[numDetChan];
05831   chanGainTime=new Float_t*[numDetChan];
05832   chanGainTemp=new Float_t*[numDetChan];
05833   chanRms=new Float_t*[numDetChan];
05834   chanMean=new Float_t*[numDetChan];
05835   chanNpe=new Float_t*[numDetChan];
05836   chanNumEntries=new Float_t*[numDetChan];
05837   for (int i=0; i<numDetChan; i++){
05838     chanGain[i]=new Float_t[const_numLiRuns];
05839     chanGainTime[i]=new Float_t[const_numLiRuns];
05840     chanGainTemp[i]=new Float_t[const_numLiRuns];
05841     chanRms[i]=new Float_t[const_numLiRuns];
05842     chanMean[i]=new Float_t[const_numLiRuns];
05843     chanNpe[i]=new Float_t[const_numLiRuns];
05844     chanNumEntries[i]=new Float_t[const_numLiRuns];
05845     for (int j=0; j<const_numLiRuns; j++){
05846       //initialise
05847       (chanGain[i])[j]=0.;
05848       (chanRms[i])[j]=0.;
05849       (chanMean[i])[j]=0.;
05850       (chanNpe[i])[j]=0.;
05851       (chanNumEntries[i])[j]=0.;
05852       (chanGainTime[i])[j]=0.;
05853       (chanGainTemp[i])[j]=0.;
05854     }
05855     channelLed[i]=-1;
05856   }
05857 
05861   
05862   this->InitialiseLoopVariables();  
05863   
05864   for(Int_t entry=0;entry<numEvents;entry++){
05865     
05866     this->SetLoopVariables(entry,0);
05867     
05868     //avoid divide by zero errors and skip irrelevant data
05869     if (rms==0. || mean==0. || numEntries==0){
05870       continue;
05871     }
05872 
05873     //only look at scintillator strips
05874     if (readoutType!=ReadoutType::kScintStrip){
05875       continue;
05876     }
05877 
05878     if (plane>=0 && plane<60 && strip<=24 && strip>=1){ 
05879       if (crate==0 && vmm==2 && varc==0){
05880         MSG("LIAnalysis",Msg::kVerbose)
05881           <<", chanNum="<<60*24*crate+24*plane+strip-1
05882           <<", mean="<<mean
05883           <<", "<<this->GetElecString()<<endl;
05884       }
05885     }
05886 
05887     //get gain for every channel
05888     if (pulseHeight==100){
05889       Int_t channelNum=crate*NUMVARCS*NUMVMMS*NUMVFBS*NUMVACHANNELS+
05890         varc*NUMVMMS*NUMVFBS*NUMVACHANNELS+
05891         vmm*NUMVFBS*NUMVACHANNELS+
05892         vfb*NUMVACHANNELS+
05893         channel;
05894       if (crate>=0 && crate<NUMCRATES &&
05895           varc>=0 && varc<NUMVARCS &&
05896           vmm>=0 && vmm<NUMVMMS &&
05897           vfb>=0 && vfb<NUMVFBS &&
05898           channel>=0 && channel<NUMVACHANNELS){ 
05899         //first check it is not already written to
05900         if ((chanGain[channelNum])[liRunNum]==0.){
05901           
05902           (chanGain[channelNum])[liRunNum]=mean/pow(mean/rms,2);
05903           
05904           (chanGainTime[channelNum])[liRunNum]=timestamp;
05905           
05906           (chanRms[channelNum])[liRunNum]=rms;
05907           
05908           (chanMean[channelNum])[liRunNum]=mean;
05909           
05910           (chanNpe[channelNum])[liRunNum]=pow(mean/rms,2);
05911           
05912           (chanNumEntries[channelNum])[liRunNum]=numEntries;
05913           
05914           if (correlatedHit && pulserBox==nearPulserBox){
05915             channelLed[channelNum]=1;
05916           }
05917           else if (correlatedHit && pulserBox==farPulserBox){
05918             channelLed[channelNum]=2;
05919           }
05920           else {
05921             channelLed[channelNum]=3;
05922           }
05923         }
05924         else {
05925           //MSG("LIAnalysis",Msg::kInfo)<<" ** WARNING ** "<<endl;
05926         }
05927       }
05928     }
05929   }//end of for
05930   
05934 
05935   MSG("LIAnalysis",Msg::kInfo)<<"Finished main loop"<<endl;
05936 
05937   MSG("LIAnalysis",Msg::kInfo)
05938     <<"Summing all gains, Rmss, means, etc"<<endl;
05939   MSG("LIAnalysis",Msg::kInfo)<<"Initialising..."<<endl;
05940   //declare and initialise array
05941   Float_t* numEnt=new Float_t[numDetChan];
05942   Float_t* chanGainAverage=new Float_t[numDetChan];
05943   Float_t* detChan=new Float_t[numDetChan];
05944   Float_t* chanAvResidualGain=new Float_t[numDetChan];
05945   Float_t* chanRmsAverage=new Float_t[numDetChan];
05946   Float_t* chanMeanAverage=new Float_t[numDetChan];
05947   Float_t* chanNpeAverage=new Float_t[numDetChan];
05948   Float_t* chanNumEntriesAverage=new Float_t[numDetChan];
05949 
05950   for (Int_t i=0;i<numDetChan;i++){
05951     chanGainAverage[i]=0.;
05952     numEnt[i]=0.;
05953     detChan[i]=static_cast<Float_t>(i);
05954     chanAvResidualGain[i]=0.;
05955     chanRmsAverage[i]=0.;
05956     chanMeanAverage[i]=0.;
05957     chanNpeAverage[i]=0.;
05958     chanNumEntriesAverage[i]=0.;
05959   }
05960 
05961   MSG("LIAnalysis",Msg::kInfo)<<"Summing..."<<endl;
05962   //sum all gains, Rmss, means, Npes in channel
05963   for (Int_t ch=0;ch<numDetChan;ch++){
05964     for (Int_t i=0;i<numLiRuns;i++){
05965       //don't include the zeros
05966       if ((chanGain[ch])[i]!=0){
05967         chanGainAverage[ch]+=(chanGain[ch])[i];
05968         chanRmsAverage[ch]+=(chanRms[ch])[i];
05969         chanMeanAverage[ch]+=(chanMean[ch])[i];
05970         chanNpeAverage[ch]+=(chanNpe[ch])[i];
05971         chanNumEntriesAverage[ch]+=(chanNumEntries[ch])[i];
05972         numEnt[ch]++;
05973       }
05974     }//end of for
05975 
05976     //calculate average from sum
05977     if (numEnt[ch]!=0 && chanGainAverage[ch]!=0){
05978       chanGainAverage[ch]=chanGainAverage[ch]/numEnt[ch];
05979       chanRmsAverage[ch]=chanRmsAverage[ch]/numEnt[ch];
05980       chanMeanAverage[ch]=chanMeanAverage[ch]/numEnt[ch];
05981       chanNpeAverage[ch]=chanNpeAverage[ch]/numEnt[ch];
05982       chanNumEntriesAverage[ch]=chanNumEntriesAverage[ch]/numEnt[ch];
05983     }
05984     else {
05985       MSG("LIAnalysis",Msg::kVerbose) 
05986         <<"ch="<<ch  
05987         <<", numEnt[ch]="<<numEnt[ch]
05988         <<      ", chanGainAverage[ch]="<<chanGainAverage[ch]
05989         <<endl;
05990     }
05991   }
05992 
05993   MSG("LIAnalysis",Msg::kInfo)<<"Calculating residuals..."<<endl;
05994   //calculate average residuals (Rms)
05995   for (Int_t ch=0;ch<numDetChan;ch++){
05996     for (Int_t i=0;i<numLiRuns;i++){
05997       if ((chanGain[ch])[i]!=0){
05998         chanAvResidualGain[ch]+=pow(chanGainAverage[ch]-
05999                                     (chanGain[ch])[i],2);
06000       }
06001     }
06002     if (numEnt[ch]>1 && chanAvResidualGain[ch]!=0){
06003       chanAvResidualGain[ch]=sqrt(chanAvResidualGain[ch]/
06004                                   (numEnt[ch]-1));
06005     }
06006     else if (numEnt[ch]==1){
06007       chanAvResidualGain[ch]=sqrt(chanAvResidualGain[ch]);
06008       //MSG("LIAnalysis",Msg::kInfo)<<"ch="<<ch 
06009       //  <<", numEnt[ch]="<<numEnt[ch] 
06010       //  <<", chanAvResidualGain[ch]="<<chanAvResidualGain[ch]
06011       //  <<endl; 
06012     }
06013   }
06014 
06015   MSG("LIAnalysis",Msg::kInfo)<<"Plotting..."<<endl;
06016 
06017   /*  
06018       TCanvas *c106=new TCanvas("c106","c106",100,1,700,820);
06019       c106->SetFillColor(0);
06020       c106->Divide(1,3);
06021 
06022       TGraph *gGain6= new TGraph(numDetChan,detChan,chanGainAverage);
06023       gGain6->SetTitle("Average Gain Vs Channel");
06024       gGain6->SetMarkerStyle(3);
06025       gGain6->SetMarkerColor(2);
06026       gGain6->SetMarkerSize(0.2);
06027       c106->cd(1);
06028       gGain6->Draw("AP");
06029       gGain6->GetXaxis()->SetTitle("Channel");
06030       gGain6->GetYaxis()->SetTitle("Average Gain (mean/npe)");
06031       gGain6->GetXaxis()->CenterTitle();
06032       gGain6->GetYaxis()->CenterTitle();   
06033 
06034       TGraph *gGain6b= new TGraph(numDetChan,detChan,chanAvResidualGain);
06035       gGain6b->SetTitle("Average Gain Residual Vs Channel");
06036       gGain6b->SetMarkerStyle(3);
06037       gGain6b->SetMarkerColor(2);
06038       gGain6b->SetMarkerSize(0.2);
06039       c106->cd(2);
06040       gGain6b->Draw("AP");
06041       gGain6b->GetXaxis()->SetTitle("Channel");
06042       gGain6b->GetYaxis()->SetTitle("Average Residual Gain (mean/npe)");
06043       gGain6b->GetXaxis()->CenterTitle();
06044       gGain6b->GetYaxis()->CenterTitle();   
06045       c106->Modified();
06046 
06047       TGraph *gGain6c= new TGraph(numDetChan,detChan,chanNumEntriesAverage);
06048       gGain6c->SetTitle("Average Number of Entries Vs Channel");
06049       gGain6c->SetMarkerStyle(3);
06050       gGain6c->SetMarkerColor(2);
06051       gGain6c->SetMarkerSize(0.2);
06052       c106->cd(3);
06053       gGain6c->Draw("AP");
06054       gGain6c->GetXaxis()->SetTitle("Channel");
06055       gGain6c->GetYaxis()->SetTitle("Average Number of Entries");
06056       gGain6c->GetXaxis()->CenterTitle();
06057       gGain6c->GetYaxis()->CenterTitle();   
06058       c106->Modified();
06059   */
06060 
06061   TCanvas *c107=new TCanvas("c107","c107",100,1,700,820);
06062   c107->SetFillColor(0);
06063   c107->Divide(1,3);
06064 
06065   TGraph *gGain7= new TGraph(numDetChan,detChan,chanMeanAverage);
06066   gGain7->SetTitle("Average Mean Vs Channel");
06067   gGain7->SetMarkerStyle(3);
06068   gGain7->SetMarkerColor(1);
06069   gGain7->SetMarkerSize(0.2);
06070   c107->cd(1);
06071   gGain7->Draw("AP");
06072   gGain7->GetXaxis()->SetTitle("Channel");
06073   gGain7->GetYaxis()->SetTitle("Average Mean");
06074   gGain7->GetXaxis()->CenterTitle();
06075   gGain7->GetYaxis()->CenterTitle();   
06076 
06077   /*
06078     TGraph *gGain7b= new TGraph(numDetChan,detChan,chanRmsAverage);
06079     gGain7b->SetTitle("Average Rms Vs Channel");
06080     gGain7b->SetMarkerStyle(3);
06081     gGain7b->SetMarkerColor(2);
06082     gGain7b->SetMarkerSize(0.2);
06083     c107->cd(2);
06084     gGain7b->Draw("AP");
06085     gGain7b->GetXaxis()->SetTitle("Channel");
06086     gGain7b->GetYaxis()->SetTitle("Average Rms");
06087     gGain7b->GetXaxis()->CenterTitle();
06088     gGain7b->GetYaxis()->CenterTitle();   
06089 
06090     TGraph *gGain7c= new TGraph(numDetChan,detChan,chanNpeAverage);
06091     gGain7c->SetTitle("Average NPE Vs Channel");
06092     gGain7c->SetMarkerStyle(3);
06093     gGain7c->SetMarkerColor(2);
06094     gGain7c->SetMarkerSize(0.2);
06095     c107->cd(3);
06096     gGain7c->Draw("AP");
06097     gGain7c->GetXaxis()->SetTitle("Channel");
06098     gGain7c->GetYaxis()->SetTitle("Average NPE");
06099     gGain7c->GetXaxis()->CenterTitle();
06100     gGain7c->GetYaxis()->CenterTitle();   
06101   */
06102 
06103   c107->Modified();
06104 
06106   //create arrays for each LED separately
06107   
06108   const Int_t const_numLeds=numLeds;
06109 
06110   Float_t *counterL=new Float_t[numLeds];
06111 
06112   Float_t **chanGainAverageL=0;
06113   Float_t **chanAvResidualGainL=0;
06114   Float_t **chanMeanAverageL=0;
06115   Float_t **chanRmsAverageL=0;
06116   Float_t **chanNpeAverageL=0;
06117   Float_t **chanNumEntriesAverageL=0;
06118 
06119   //create arrays to hold the channel number assiciated with the above
06120   //separate LED arrays
06121   Float_t **chanGainAverageC=0;
06122   Float_t **chanAvResidualGainC=0;
06123   Float_t **chanMeanAverageC=0;
06124   Float_t **chanRmsAverageC=0;
06125   Float_t **chanNpeAverageC=0;
06126   Float_t **chanNumEntriesAverageC=0;
06127 
06128   chanGainAverageL=new Float_t*[const_numLeds];
06129   chanAvResidualGainL=new Float_t*[const_numLeds];
06130   chanMeanAverageL=new Float_t*[const_numLeds];
06131   chanRmsAverageL=new Float_t*[const_numLeds];
06132   chanNpeAverageL=new Float_t*[const_numLeds];
06133   chanNumEntriesAverageL=new Float_t*[const_numLeds];
06134 
06135   chanGainAverageC=new Float_t*[const_numLeds];
06136   chanAvResidualGainC=new Float_t*[const_numLeds];
06137   chanMeanAverageC=new Float_t*[const_numLeds];
06138   chanRmsAverageC=new Float_t*[const_numLeds];
06139   chanNpeAverageC=new Float_t*[const_numLeds];
06140   chanNumEntriesAverageC=new Float_t*[const_numLeds];
06141 
06142   for (Int_t i=0; i<const_numLeds; i++){
06143     chanGainAverageL[i]=new Float_t[numDetChan];
06144     chanAvResidualGainL[i]=new Float_t[numDetChan];
06145     chanMeanAverageL[i]=new Float_t[numDetChan];
06146     chanRmsAverageL[i]=new Float_t[numDetChan];
06147     chanNpeAverageL[i]=new Float_t[numDetChan];
06148     chanNumEntriesAverageL[i]=new Float_t[numDetChan];
06149 
06150     chanGainAverageC[i]=new Float_t[numDetChan];
06151     chanAvResidualGainC[i]=new Float_t[numDetChan];
06152     chanMeanAverageC[i]=new Float_t[numDetChan];
06153     chanRmsAverageC[i]=new Float_t[numDetChan];
06154     chanNpeAverageC[i]=new Float_t[numDetChan];
06155     chanNumEntriesAverageC[i]=new Float_t[numDetChan];
06156   }
06157 
06158   for (Int_t i=0; i<const_numLeds; i++){
06159     counterL[i]=0;
06160     for (Int_t j=0; j<numDetChan; j++){
06161       //initialise
06162       (chanGainAverageL[i])[j]=0.;
06163       (chanAvResidualGainL[i])[j]=0.;
06164       (chanMeanAverageL[i])[j]=0.;
06165       (chanRmsAverageL[i])[j]=0.;
06166       (chanNpeAverageL[i])[j]=0.;
06167       (chanNumEntriesAverageL[i])[j]=0.;
06168 
06169       (chanGainAverageC[i])[j]=0.;
06170       (chanAvResidualGainC[i])[j]=0.;
06171       (chanMeanAverageC[i])[j]=0.;
06172       (chanRmsAverageC[i])[j]=0.;
06173       (chanNpeAverageC[i])[j]=0.;
06174       (chanNumEntriesAverageC[i])[j]=0.;
06175     }
06176   }
06177 
06178   for (Int_t ch=0;ch<numDetChan; ch++){
06179     //check that the LED numbers are right to prevent segv
06180     //note channelLed is initialised to -1
06181     if (channelLed[ch]-1<numLeds && channelLed[ch]-1>=0){
06182 
06183       (chanGainAverageL[ channelLed[ch]-1 ])
06184         [static_cast<Int_t>(counterL[ channelLed[ch]-1 ])] = 
06185         chanGainAverage[ch];
06186 
06187       (chanAvResidualGainL[ channelLed[ch]-1 ])
06188         [static_cast<Int_t>(counterL[ channelLed[ch]-1 ])] = 
06189         chanAvResidualGain[ch];
06190 
06191       (chanMeanAverageL[ channelLed[ch]-1 ])
06192         [static_cast<Int_t>(counterL[ channelLed[ch]-1 ])] = 
06193         chanMeanAverage[ch];
06194 
06195       (chanRmsAverageL[ channelLed[ch]-1 ])
06196         [static_cast<Int_t>(counterL[ channelLed[ch]-1 ])] = 
06197         chanRmsAverage[ch];
06198 
06199       (chanNpeAverageL[ channelLed[ch]-1 ])
06200         [static_cast<Int_t>(counterL[ channelLed[ch]-1 ])] = 
06201         chanNpeAverage[ch];
06202 
06203       (chanNumEntriesAverageL[ channelLed[ch]-1 ])
06204         [static_cast<Int_t>(counterL[ channelLed[ch]-1 ])] = 
06205         chanNumEntriesAverage[ch];
06206 
06207 
06208       (chanGainAverageC[ channelLed[ch]-1 ])
06209         [static_cast<Int_t>(counterL[ channelLed[ch]-1 ])] = 
06210         static_cast<Float_t>(ch);
06211 
06212       (chanAvResidualGainC[ channelLed[ch]-1 ])
06213         [static_cast<Int_t>(counterL[ channelLed[ch]-1 ])] = 
06214         static_cast<Float_t>(ch);
06215 
06216       (chanMeanAverageC[ channelLed[ch]-1 ])
06217         [static_cast<Int_t>(counterL[ channelLed[ch]-1 ])] = 
06218         static_cast<Float_t>(ch);
06219 
06220       (chanRmsAverageC[ channelLed[ch]-1 ])
06221         [static_cast<Int_t>(counterL[ channelLed[ch]-1 ])] = 
06222         static_cast<Float_t>(ch);
06223 
06224       (chanNpeAverageC[ channelLed[ch]-1 ])
06225         [static_cast<Int_t>(counterL[ channelLed[ch]-1 ])] = 
06226         static_cast<Float_t>(ch);
06227 
06228       (chanNumEntriesAverageC[ channelLed[ch]-1 ])
06229         [static_cast<Int_t>(counterL[ channelLed[ch]-1 ])] = 
06230         static_cast<Float_t>(ch);
06231 
06232       //count the number of each led
06233       counterL[(channelLed[ch]-1)]++;
06234       //MSG("LIAnalysis",Msg::kInfo)<<"counterL[(channelLed[ch]-1)]=" 
06235       //    <<counterL[(channelLed[ch]-1)]
06236       //    <<", channelLed[ch]-1="<<channelLed[ch]-1
06237       //   <<endl;
06238     }
06239   }
06240 
06241   TLegend *legend2 = new TLegend(0.85, 0.7, 0.9, 0.9);
06242   legend2->SetBorderSize(0);
06243   legend2->SetFillColor(0);
06244   legend2->SetTextSize(0.035);
06245 
06246   TGraph **gGainL=0;
06247   gGainL= new TGraph*[numLeds];
06248   TGraph **gResidualL=0;
06249   gResidualL= new TGraph*[numLeds];
06250   TGraph **gMeanL=0;
06251   gMeanL= new TGraph*[numLeds];
06252   TGraph **gRmsL=0;
06253   gRmsL= new TGraph*[numLeds];
06254   TGraph **gNpeL=0;
06255   gNpeL= new TGraph*[numLeds];
06256   TGraph **gNumEntriesL=0;
06257   gNumEntriesL= new TGraph*[numLeds];
06258     
06259   for (Int_t i=0;i<3;i++){
06260     gGainL[i]=new TGraph(static_cast<Int_t>(counterL[i]),
06261                          chanGainAverageC[i],
06262                          chanGainAverageL[i]);
06263     gGainL[i]->SetMarkerStyle(3);
06264     gGainL[i]->SetMarkerColor(i+2);
06265     gGainL[i]->SetMarkerSize(0.2);
06266 
06267     gResidualL[i]=new TGraph(static_cast<Int_t>(counterL[i]),
06268                              chanAvResidualGainC[i],
06269                              chanAvResidualGainL[i]);
06270     gResidualL[i]->SetMarkerStyle(3);
06271     gResidualL[i]->SetMarkerColor(i+2);
06272     gResidualL[i]->SetMarkerSize(0.2);
06273 
06274     gMeanL[i]=new TGraph(static_cast<Int_t>(counterL[i]),
06275                          chanMeanAverageC[i],
06276                          chanMeanAverageL[i]);
06277     gMeanL[i]->SetMarkerStyle(3);
06278     gMeanL[i]->SetMarkerColor(i+2);
06279     gMeanL[i]->SetMarkerSize(0.2);
06280 
06281     gRmsL[i]=new TGraph(static_cast<Int_t>(counterL[i]),
06282                         chanRmsAverageC[i],
06283                         chanRmsAverageL[i]);
06284     gRmsL[i]->SetMarkerStyle(3);
06285     gRmsL[i]->SetMarkerColor(i+2);
06286     gRmsL[i]->SetMarkerSize(0.2);
06287 
06288     gNpeL[i]=new TGraph(static_cast<Int_t>(counterL[i]),
06289                         chanNpeAverageC[i],
06290                         chanNpeAverageL[i]);
06291     gNpeL[i]->SetMarkerStyle(3);
06292     gNpeL[i]->SetMarkerColor(i+2);
06293     gNpeL[i]->SetMarkerSize(0.2);
06294 
06295     gNumEntriesL[i]=new TGraph(static_cast<Int_t>(counterL[i]),
06296                                chanNumEntriesAverageC[i],
06297                                chanNumEntriesAverageL[i]);
06298     gNumEntriesL[i]->SetMarkerStyle(3);
06299     gNumEntriesL[i]->SetMarkerColor(i+2);
06300     gNumEntriesL[i]->SetMarkerSize(0.2);
06301 
06302 
06303     //c106->cd(1);
06304     //gGainL[i]->Draw("P");
06305     //c106->cd(2);
06306     //gResidualL[i]->Draw("P");
06307     //c106->cd(3);
06308     //gNumEntriesL[i]->Draw("P");
06309     
06310 
06311     c107->cd(1);
06312     gMeanL[i]->Draw("P");
06313 
06314     
06315     //c107->cd(2);
06316     //gRmsL[i]->Draw("P");
06317     //c107->cd(3);
06318     //gNpeL[i]->Draw("P");
06319     
06320     sprintf(histname," LED %i",i+1);
06321     legend2->AddEntry(gResidualL[i],histname,"p");
06322   }
06323 
06324   
06325   //draw the legends
06326   //c106->cd(1);
06327   //legend2->Draw();
06328   //c106->cd(2);
06329   //legend2->Draw();
06330   //c106->cd(3);
06331   //legend2->Draw();
06332   //c106->Modified(); 
06333   //draw the legends on other canvas
06334   
06335   
06336   c107->cd(1);
06337   legend2->Draw();
06338   
06339   //c107->cd(2);
06340   //legend2->Draw();
06341   //c107->cd(3);
06342   //legend2->Draw();
06343   //c107->Modified();
06344   
06345   MSG("LIAnalysis",Msg::kInfo) 
06346     <<" ** Finished the IndividualChannels method ** "<<endl;
06347 }

void LIAnalysis::InitialiseLoopVariables (  )  [private]
void LIAnalysis::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 
)

LITuning tune(gCurveData,idealAdc,numGcPoints, firstGcPoint,lastGcPoint,numCalibPoints);

This function is used to tune the led pulse heights and produce a list in the required format for the li.config file. It also outputs a number of postscript files with various histograms and graphs, see below.

Currently a linear interpolation is done between the two gain curve points on either side of the idealAdc value. The code also works out the point which is closest to the idealAdc

INPUT VARIABLES: 1.) numCalibPoints - this is a nasty way of controlling multiple files 2.) pNum - number of pulses that a gain curve point must contain 3.) pWidth - the pulse width that the data must have been taken at 4.) idealAdc - the adc value that the tuning aims for 5.) numGcPoints - number of GC points to output 6.) firstGcPoint - required pmt adc of the first GC point 7.) lastGcPoint - required pmt adc of the last GC point

OUTPUT FILES: 1.) 9526-12200AdcPhHisto.ps 2.) 9526-12200AdcErrVsPh.ps 3.) 9526-12200AdcVsPh.ps 4.) 9526-12200TunedAdcVsLed.ps 5.) 9526-12200TunedPhVsLed.ps 6.) 9526-12200TunedGc.ps 7.) 9526-12200PinVsPh.ps

The run numbers are those of the first and last file used in the calculation

DESCRIPTION OF OUTPUT FILES: No. 1 has histograms of the adc values for each led and for each calibration point (i.e. pulse height) on different pages

No. 2 has graphs of adc vs pulse height for each led. The errors show where 90% of the hits lie

No. 3 Is the same as number 2 but with no errors

No. 4 has several pages of graphs showing the tuned adc value vs pulse height with and without errors. The errors show where 90% of the hits lie. The adc value is that of the point closest to the idealAdc.

No. 5 shows the tuned pulse height value vs led

Definition at line 10703 of file LIAnalysis.cxx.

References LITuning::CalculateDriftPoints(), LITuning::CalculateGainCurve(), calibPoint, calibType, chain, chip, correlatedHit, crate, detectorType, Draw(), exit(), farLed, farPulserBox, LITuning::FindLowerFraction(), LITuning::FindMidFractionAv(), LITuning::FindUpperFraction(), LILookup::FIRSTCRATE, LILookup::FIRSTLED, LILookup::FIRSTPULSERBOX, Form(), fS, LITuning::GetDataGcGraphs(), LITuning::GetTunedDpGraphs(), LITuning::GetTunedGcPlots(), highRunNumber, InitialiseLoopVariables(), LITuning::InputDataGc(), MsgService::Instance(), MsgService::IsActive(), Detector::kCalDet, Msg::kDebug, LIRun::kDriftPoint, Detector::kFar, Msg::kFatal, LIRun::kGainCurve, LITuning::kGcLinearInPinAdc, Msg::kInfo, Detector::kNear, ReadoutType::kPinDiode, ReadoutType::kScintStrip, Msg::kVerbose, Msg::kWarning, LILookup::LASTCRATE, LILookup::LASTLED, LILookup::LASTPULSERBOX, led, lowRunNumber, masterCh, mean, MSG, nearLed, nearPulserBox, numEntries, numEvents, LILookup::NUMLEDS, LILookup::NUMPULSERBOXES, LITuning::PrintAll(), LITuning::PrintConfig(), LITuning::PrintLedCheckGrid(), LITuning::PrintLIConfig(), pulseHeight, pulserBox, pulses, pulseWidth, readoutType, rms, runNumber, LITuning::SetdADCdPHAtSat(), SetFillColor(), LITuning::SetFirstGcPointAdc(), LITuning::SetIdealAdc(), LITuning::SetLastGcPointAdc(), SetLoopVariables(), LITuning::SetNumCalibPoints(), and LITuning::SetNumGainPoints().

10709 { 
10763   MSG("LIAnalysis",Msg::kInfo)  
10764     <<endl<<" ** Running the LedTuning method... ** "<<endl; 
10765 
10766   chain->GetEvent(0);
10767   
10768   //if no number of calib points was set then get it from file
10769   if (numCalibPoints==-1){
10770     numCalibPoints=calibType;
10771   }
10772   
10773   //check number of pulses
10774   if (pulses<pNum){
10775     MSG("LIAnalysis",Msg::kInfo)
10776       <<" *** WARNING, file doesn't contain requested "
10777       <<"number of pulses ("
10778       <<pNum<<") ***"<<endl
10779       <<" *** Run number = "<<runNumber<<" ***"<<endl
10780       <<" *** Number of pulses = "<<pulses<<" ***"<<endl;
10781   }
10782 
10783   Int_t hack=pWidth;
10784   hack++;
10785 
10786   Int_t numAdcBins=300;
10787   const Int_t const_numCalibPoints=numCalibPoints;   
10788 
10789   MSG("LIAnalysis",Msg::kInfo) 
10790     <<"Using "<<const_numCalibPoints<<" calibPoints"<<endl;
10791   MSG("LIAnalysis",Msg::kInfo) 
10792     <<"Number of pulser boxes = "<<NUMPULSERBOXES
10793     <<", leds = "<<NUMLEDS
10794     <<endl<<endl;
10795 
10796   Float_t *ledFlashed=new Float_t[NUMLEDS*NUMPULSERBOXES];
10797   
10798   //initialise arrays
10799   TH1F ***hAdcPh=0;
10800   hAdcPh=new TH1F**[NUMLEDS*NUMPULSERBOXES];
10801   for (Int_t i=0;i<NUMPULSERBOXES;i++){
10802     for (Int_t j=0;j<NUMLEDS;j++){
10803       Int_t l=i*NUMLEDS+j;
10804       
10805       //set all leds to be not flashed
10806       ledFlashed[l]=0;
10807         
10808       hAdcPh[l]=new TH1F*[const_numCalibPoints];
10809 
10810       for (Int_t k=0;k<const_numCalibPoints;k++){
10811         string sCalibPoint=Form("%d",k);
10812         string sPulserBox=Form("%d",i);
10813         string sLed=Form("%d",j+1);
10814         s="ADC Near&Far, PB "+sPulserBox+", LED "+sLed+
10815           ", calibPoint "+sCalibPoint;
10816         (hAdcPh[l])[k]=new TH1F(s.c_str(),s.c_str(),
10817                                    numAdcBins,0,15000);
10818         (hAdcPh[l])[k]->GetXaxis()->SetTitle("ADC");
10819         (hAdcPh[l])[k]->GetXaxis()->CenterTitle();
10820         (hAdcPh[l])[k]->GetYaxis()->SetTitle("Number of Entries");
10821         (hAdcPh[l])[k]->GetYaxis()->CenterTitle();
10822         (hAdcPh[l])[k]->SetFillColor(0);
10823         (hAdcPh[l])[k]->SetLineColor(1);
10824         (hAdcPh[l])[k]->Fill(1,0.0001);
10825         (hAdcPh[l])[k]->SetBit(TH1::kCanRebin);
10826       }
10827     }
10828   }
10829 
10830   TH1F ***hAdcPhNear=0;
10831   hAdcPhNear=new TH1F**[NUMLEDS*NUMPULSERBOXES];
10832   for (Int_t i=0;i<NUMPULSERBOXES;i++){
10833     for (Int_t j=0;j<NUMLEDS;j++){
10834       Int_t l=i*NUMLEDS+j;
10835       hAdcPhNear[l]=new TH1F*[const_numCalibPoints];
10836       for (Int_t k=0;k<const_numCalibPoints;k++){
10837         string sCalibPoint=Form("%d",k);
10838         string sPulserBox=Form("%d",i);
10839         string sLed=Form("%d",j+1);
10840         s="ADC Near Side, PB "+sPulserBox+", LED "+sLed+
10841           ", calibPoint "+sCalibPoint;
10842         Int_t l=i*NUMLEDS+j;
10843         hAdcPhNear[l][k]=new TH1F(s.c_str(),s.c_str(),
10844                                    numAdcBins,0,15000);
10845         (hAdcPhNear[l])[k]->GetXaxis()->SetTitle("ADC");
10846         (hAdcPhNear[l])[k]->GetXaxis()->CenterTitle();
10847         (hAdcPhNear[l])[k]->GetYaxis()->SetTitle("Number of Entries");
10848         (hAdcPhNear[l])[k]->GetYaxis()->CenterTitle();
10849         (hAdcPhNear[l])[k]->SetFillColor(0);
10850         (hAdcPhNear[l])[k]->SetLineColor(2);
10851         (hAdcPhNear[l])[k]->Fill(1,0.0001);
10852         (hAdcPhNear[l])[k]->SetBit(TH1::kCanRebin);
10853       }
10854     }
10855   }
10856 
10857   TH1F ***hAdcPhFar=0;
10858   hAdcPhFar=new TH1F**[NUMLEDS*NUMPULSERBOXES];
10859   for (Int_t i=0;i<NUMPULSERBOXES;i++){
10860     for (Int_t j=0;j<NUMLEDS;j++){
10861       Int_t l=i*NUMLEDS+j;
10862       hAdcPhFar[l]=new TH1F*[const_numCalibPoints];
10863       for (Int_t k=0;k<const_numCalibPoints;k++){
10864         string sCalibPoint=Form("%d",k);
10865         string sPulserBox=Form("%d",i);
10866         string sLed=Form("%d",j+1);
10867         s="ADC Far Side, PB "+sPulserBox+", LED "+sLed+
10868           ", calibPoint "+sCalibPoint;
10869         (hAdcPhFar[l])[k]=new TH1F(s.c_str(),s.c_str(),
10870                                    numAdcBins,0,15000);
10871         (hAdcPhFar[l])[k]->GetXaxis()->SetTitle("ADC");
10872         (hAdcPhFar[l])[k]->GetXaxis()->CenterTitle();
10873         (hAdcPhFar[l])[k]->GetYaxis()->SetTitle("Number of Entries");
10874         (hAdcPhFar[l])[k]->GetYaxis()->CenterTitle();
10875         (hAdcPhFar[l])[k]->SetFillColor(0);
10876         (hAdcPhFar[l])[k]->SetLineColor(3);
10877         (hAdcPhFar[l])[k]->Fill(1,0.0001);
10878         (hAdcPhFar[l])[k]->SetBit(TH1::kCanRebin);
10879       }
10880     }
10881   }
10882 
10883   map<Int_t,LIHits> nearPmt;
10884   map<Int_t,LIHits> farPmt;
10885   map<Int_t,Double_t> nearPmtAv;
10886   map<Int_t,Double_t> farPmtAv;
10887   map<Int_t,Double_t> adcHighPin; 
10888   map<Int_t,Double_t> adcLowPin;
10889   map<Int_t,Int_t> nearPmtNum;
10890   map<Int_t,Int_t> farPmtNum;
10891   map<Int_t,Int_t> ph;
10892 
10893   Int_t secondFile=0;
10894   Int_t c=0;//variable for calibration point  
10895   Int_t lastCp=999999;//last calibration point used
10896 
10897   Bool_t usePinPlex=true;
10898 
10902      
10903   this->InitialiseLoopVariables();   
10904    
10905   for(Int_t entry=0;entry<numEvents;entry++){ 
10906 
10907     this->SetLoopVariables(entry,1); 
10908 
10909     //ignore any zeros that slipped through 
10910     if (mean==0 || rms==0 || numEntries==0) continue; 
10911 
10912     //protect against drift point runs
10913     if (calibType==1){
10914       MSG("LIAnalysis",Msg::kFatal)
10915         <<"Drift point run used for tuning!"
10916         <<" Exiting here..."<<endl; 
10917       exit(1);
10918     }
10919 
10920     //set the index for the calibration point    
10921     c=calibPoint-1+secondFile;
10922     Int_t index=pulserBox*NUMLEDS*const_numCalibPoints+
10923       (led-1)*const_numCalibPoints+c;
10924 
10925     //calculate whether a new gain curve is being looked at
10926     //reset the second file variable
10927     if (lastCp-calibPoint>0){
10928       //print out which pb is being analysed
10929       MSG("LIAnalysis",Msg::kDebug) 
10930         <<"pulser box="<<pulserBox
10931         <<", led="<<led<<", PH="<<pulseHeight<<endl;
10932       //reset second file variable
10933       secondFile=0;
10934     }
10935     lastCp=calibPoint;
10936 
10937     //nasty fudge to detect second file on same pulser box
10938     if (calibPoint==1 && pulseHeight<200){
10939       if (secondFile!=10){
10940         MSG("LIAnalysis",Msg::kDebug) 
10941           <<"Changing second file="<<secondFile
10942           <<", led="<<led<<", PH="<<pulseHeight
10943           <<", CP="<<calibPoint
10944           <<endl;
10945       }
10946       secondFile=numSecondFile;
10947     }
10948 
10949     //look at pins 
10950     if (readoutType==ReadoutType::kPinDiode){
10951 
10952       if (pulserBox>=FIRSTPULSERBOX && pulserBox<=LASTPULSERBOX &&
10953           led>=FIRSTLED && led<=LASTLED){
10954         
10955         if (detectorType==Detector::kNear) {
10956           // store pin diode gain in corresponding adcHighPin and 
10957           // adcLowPin vectors
10958           //
10959           // for the spectrometer there is only one pin diode per led
10960           // store identical values in both arrays
10961           //
10962           // make selection based on master channel
10963 
10964           if (correlatedHit) {
10965             if (masterCh==1||masterCh==2||masterCh==3||masterCh==5){
10966               //store high gain pin
10967               if (adcHighPin[index]>0){
10968                 MSG("LIAnalysis",Msg::kWarning)
10969                   <<"Overwritten high pin - already found value="
10970                   <<adcHighPin[index]<<", new value="<<mean<<endl;
10971               }
10972               adcHighPin[index]=mean;
10973             }
10974 
10975             if (masterCh==1||masterCh==2||masterCh==4||masterCh==6){
10976               //store low gain pin
10977               if (adcLowPin[index]>0){
10978                 MSG("LIAnalysis",Msg::kWarning)
10979                   <<"Overwritten low pin - already found value="
10980                   <<adcLowPin[index]<<", new value="<<mean<<endl;
10981               }
10982               adcLowPin[index]=mean;
10983             }
10984           }
10985  
10986         }
10987         else {
10988         
10989           if (usePinPlex){
10990 
10991             if (correlatedHit){
10992               if (chip==1){//high gain (chip 1)
10993                 //store high gain pin
10994                 if (adcHighPin[index]>0){
10995                   MSG("LIAnalysis",Msg::kWarning)
10996                     <<"Overwritten high pin - already found value="
10997                     <<adcHighPin[index]<<", new value="<<mean<<endl;
10998                 }
10999                 adcHighPin[index]=mean;
11000               }
11001               else if (chip==0){//low gain (chip 0)
11002                 //store low gain pin
11003                 if (adcLowPin[index]>0){
11004                   MSG("LIAnalysis",Msg::kWarning)
11005                     <<"Overwritten low pin - already found value="
11006                     <<adcLowPin[index]<<", new value="<<mean<<endl;
11007                 }
11008                 adcLowPin[index]=mean;
11009               }
11010             }
11011           }
11012           else {
11013             //will require a correlated hit when plex is working
11014             //fill histo for appropriate pin
11015             if (chip==1){//high gain (chip 1)
11016               //find max value for high gain pin
11017               if (mean>adcHighPin[index]){
11018                 adcHighPin[index]=mean;
11019               }
11020               
11021             }
11022             else if (chip==0){//low gain (chip 0)
11023               //find max value for low gain pin
11024               if (mean>adcLowPin[index]>0) {
11025                 adcLowPin[index]=mean;
11026               }
11027             }   
11028           }
11029         }
11030       }
11031     }
11032 
11033     //only look at scint strips 
11034     if (readoutType!=ReadoutType::kScintStrip) continue; 
11035 
11036     //fill histograms
11037     if (correlatedHit==1){
11038       Int_t l=pulserBox*NUMLEDS+led-1;
11039       //record which leds are flashed
11040       ledFlashed[l]=1;
11041       
11042       if (detectorType==Detector::kFar || detectorType==Detector::kNear){
11043         // Tobi added kNear
11044  
11045         if (pulserBox>=FIRSTPULSERBOX && pulserBox<=LASTPULSERBOX &&
11046             led>=FIRSTLED && led<=LASTLED &&
11047             calibPoint>=1 && calibPoint<=const_numCalibPoints){
11048           
11049           ph[index]=pulseHeight;
11050           
11051           //fill histo for appropriate led
11052           hAdcPh[l][c]->Fill(mean);
11053           //fill histos with when pulser box is near pulser box
11054           if (nearPulserBox==pulserBox){
11055             hAdcPhNear[l][c]->Fill(mean);
11056             nearPmt[index].hits[mean]++;
11057             nearPmtAv[index]+=mean;
11058             nearPmtNum[index]++;
11059           }
11060           //fill histos with when pulser box is far pulser box
11061           else if (farPulserBox==pulserBox) {
11062             hAdcPhFar[l][c]->Fill(mean);
11063             farPmt[index].hits[mean]++;
11064             farPmtAv[index]+=mean;
11065             farPmtNum[index]++;
11066           }
11067         }
11068       }
11069       //change the farPb to farLed for calDet
11070       else if (detectorType==Detector::kCalDet){
11071 
11072         if (pulserBox>=FIRSTPULSERBOX && pulserBox<=LASTPULSERBOX &&
11073             crate>=FIRSTCRATE && crate<=LASTCRATE &&
11074             led>=FIRSTLED && led<=LASTLED &&
11075             calibPoint>=1 && calibPoint<=const_numCalibPoints){
11076           
11077           //fill histo for appropriate led
11078           hAdcPh[l][c]->Fill(mean);
11079           //fill histos with when pulser box is near pulser box
11080           if (nearLed==led){
11081             hAdcPhNear[l][c]->Fill(mean);
11082             nearPmt[index].hits[mean]++;
11083             nearPmtAv[index]+=mean;
11084             nearPmtNum[index]++;
11085           }
11086           //fill histos with when pulser box is far pulser box
11087           else if (farLed==led) {
11088             hAdcPhFar[l][c]->Fill(mean);
11089             farPmt[index].hits[mean]++;
11090             farPmtAv[index]+=mean;
11091             farPmtNum[index]++;
11092           }
11093         }
11094       }
11095     }
11096   }//end of for       
11097    
11101  
11102   MSG("LIAnalysis",Msg::kInfo)<<"Finished main loop"<<endl;
11103 
11104   //create tuning object
11105   LITuning tune;
11106 
11107   //include the under and overflow counts 
11108   gStyle->SetOptStat(1111111); 
11109   //set up useful string 
11110   string sRunNumber=Form("%d",runNumber); 
11111   string sLowRunNumber=Form("%d",lowRunNumber);
11112   string sHighRunNumber=Form("%d",highRunNumber);
11113   s="";
11114 
11116   //look at the pmt hits
11118 
11119   map<Int_t,LIHits>::iterator nearPmtIter;
11120   nearPmtIter=nearPmt.begin();
11121   map<Int_t,LIHits>::iterator farPmtIter;
11122   farPmtIter=farPmt.begin();
11123   map<Int_t,Double_t>::iterator nearPmtAvIter;
11124   nearPmtAvIter=nearPmtAv.begin();
11125   map<Int_t,Double_t>::iterator farPmtAvIter;
11126   farPmtAvIter=farPmtAv.begin();
11127   map<Int_t,Int_t>::iterator nearPmtNumIter;
11128   nearPmtNumIter=nearPmtNum.begin();
11129   map<Int_t,Int_t>::iterator farPmtNumIter;
11130   farPmtNumIter=farPmtNum.begin();
11131   map<Int_t,Int_t>::iterator phIter;
11132   phIter=ph.begin();
11133 
11134   //maps to hold the X% ranges, e.g. top 5% and bottom 5%
11135   map<Int_t,Double_t> mAdcHigh;
11136   map<Int_t,Double_t> mAdcLow;
11137   map<Int_t,Double_t> mAdcHighF;
11138   map<Int_t,Double_t> mAdcLowF;
11139 
11140   //maps to hold the mid 100%-2*X% average pmt adc
11141   map<Int_t,Double_t> nearPmtMidAv;
11142   map<Int_t,Double_t> farPmtMidAv;
11143 
11144   while(nearPmtIter!=nearPmt.end()){
11145     //calculate the averages
11146     //this is done using the middle 90% as well, see below
11147     nearPmtAvIter->second/=nearPmtNumIter->second;
11148 
11149     Int_t index=nearPmtAvIter->first;
11150     Int_t pb=nearPmtAvIter->first/(NUMLEDS*const_numCalibPoints);
11151     Int_t l=(nearPmtAvIter->first%(NUMLEDS*const_numCalibPoints))/
11152       const_numCalibPoints+1;
11153     Int_t c=nearPmtAvIter->first%const_numCalibPoints+1;
11154 
11155     MSG("LIAnalysis",Msg::kDebug)
11156       <<"index="<<index
11157       <<" ("<<pb<<":"<<l<<") c="<<c<<", ph="<<phIter->second
11158       <<", avMeanN="<<nearPmtAvIter->second
11159       <<" tHits="<<nearPmtNumIter->second
11160       <<", 5%="<<nearPmtNumIter->second/20
11161       <<endl;
11162 
11163     if (nearPmtNumIter->second<=0){
11164       MSG("LIAnalysis",Msg::kWarning)
11165         <<endl<<"index="<<index
11166         <<" ("<<pb<<":"<<l<<") c="<<c<<", ph="<<phIter->second
11167         <<", mean="<<nearPmtAvIter->second
11168         <<", num="<<nearPmtNumIter->second<<endl;
11169     }
11170 
11171     mAdcLow[index]=tune.FindLowerFraction(nearPmtIter->second.hits,0.05,
11172                                           nearPmtNumIter->second);
11173     mAdcHigh[index]=tune.FindUpperFraction(nearPmtIter->second.hits,
11174                                            0.05,nearPmtNumIter->second);
11175     nearPmtMidAv[index]=tune.FindMidFractionAv(nearPmtIter->second.hits,
11176                                                0.05,0.05,
11177                                                nearPmtNumIter->second);
11178     
11179     MSG("LIAnalysis",Msg::kDebug)
11180       <<"  Near end: Lower fract="<<mAdcLow[index]
11181       <<", Upper fract="<<mAdcHigh[index]
11182       <<", mid fract av="<<nearPmtMidAv[index]
11183       <<", avMeanN="<<nearPmtAvIter->second
11184       <<endl;
11185 
11186     nearPmtIter++;
11187     nearPmtAvIter++;
11188     nearPmtNumIter++;
11189     phIter++;
11190   }
11191 
11192   //reset the phIter
11193   phIter=ph.begin();
11194 
11195   while(farPmtIter!=farPmt.end()){
11196 
11197     //calculate the averages
11198     farPmtAvIter->second/=farPmtNumIter->second;
11199 
11200     Int_t index=farPmtAvIter->first;
11201     Int_t pb=farPmtAvIter->first/(NUMLEDS*const_numCalibPoints);
11202     Int_t l=(farPmtAvIter->first%(NUMLEDS*const_numCalibPoints))/
11203       const_numCalibPoints+1;
11204     Int_t c=farPmtAvIter->first%const_numCalibPoints+1;
11205 
11206     MSG("LIAnalysis",Msg::kDebug)
11207       <<"index="<<index
11208       <<" ("<<pb<<":"<<l<<") c="<<c<<", ph="<<phIter->second
11209       <<", avMeanF="<<farPmtAvIter->second
11210       <<endl;
11211 
11212     mAdcHighF[index]=tune.FindUpperFraction(farPmtIter->second.hits,
11213                                             0.05,farPmtNumIter->second);
11214     mAdcLowF[index]=tune.FindLowerFraction(farPmtIter->second.hits,0.05,
11215                                            farPmtNumIter->second);
11216     farPmtMidAv[index]=tune.FindMidFractionAv(farPmtIter->second.hits,
11217                                               0.05,0.05,
11218                                               farPmtNumIter->second);
11219     
11220     MSG("LIAnalysis",Msg::kDebug)
11221       <<"  Far end: Lower fract="<<mAdcLowF[index]
11222       <<", Upper fract="<<mAdcHighF[index]
11223       <<", mid fract av="<<farPmtMidAv[index]
11224       <<", avMeanF="<<farPmtAvIter->second
11225       <<endl;
11226 
11227     farPmtIter++;
11228     farPmtAvIter++;
11229     farPmtNumIter++;
11230     phIter++;
11231   }
11232 
11233   //clear the vectors so that you free up the memory
11234   nearPmt.clear();
11235   farPmt.clear();
11236   
11238   //Make plots
11240   MSG("LIAnalysis",Msg::kInfo)<<"Plotting histograms..."<<endl;
11241   //create the canvas
11242   TCanvas *cAdcPh=new TCanvas("cAdcPh","cAdcPh",0,0,1000,600);
11243   cAdcPh->SetFillColor(0);
11244   cAdcPh->cd();
11245 
11246   //get the maximum on histos in order to scale all plots
11247   Int_t maxNumEnt=0;
11248   for (Int_t i=0;i<NUMPULSERBOXES*NUMLEDS;i++){
11249     //check whether led was flashed
11250     if (ledFlashed[i]!=1) continue;
11251     for (Int_t k=0;k<const_numCalibPoints;k++){
11252       if ((hAdcPh[i])[k]->GetMaximum()>maxNumEnt){
11253         if ((hAdcPh[i])[k]->GetMean()>500){
11254           maxNumEnt=static_cast<Int_t>((hAdcPh[i])[k]->GetMaximum());
11255           MSG("LIAnalysis",Msg::kDebug)
11256             <<"Calculating max number of entries on histo"
11257             <<", current highest="
11258             <<maxNumEnt<<", l="<<i<<" k="<<k<<endl;
11259         }
11260       }
11261     }
11262   }
11263 
11264   //open the file for printing to
11265   string sAdcPh="default.ps";
11266   if (sLowRunNumber==sHighRunNumber) sAdcPh=sHighRunNumber+
11267                                        "AdcPhHisto.ps";
11268   else sAdcPh=sLowRunNumber+"-"+sHighRunNumber+"AdcPhHisto.ps";
11269   cAdcPh->Print((sAdcPh+"[").c_str());
11270   gErrorIgnoreLevel=1;
11271 
11272   //loop over all calibpoints and leds
11273   for (Int_t i=0;i<NUMPULSERBOXES;i++){
11274     for (Int_t j=0;j<NUMLEDS;j++){
11275       Int_t l=i*NUMLEDS+j;
11276       //check whether led was flashed
11277       if (ledFlashed[l]!=1) continue;
11278       for (Int_t k=0;k<const_numCalibPoints;k++){
11279 
11280         //calculate the index   
11281         Int_t index=i*NUMLEDS*const_numCalibPoints+
11282           j*const_numCalibPoints+k;
11283 
11284         //plot histograms
11285         cAdcPh->Clear();
11286         (hAdcPh[l])[k]->SetMaximum(maxNumEnt);
11287         string sPulserBox=Form("%d",i);
11288         string sLed=Form("%d",j+1);
11289         string sPulseWidth=Form("%d",pulseWidth);
11290         string sPulseHeight=Form("%d",ph[index]);
11291 
11292         MSG("LIAnalysis",Msg::kDebug)
11293           <<"LI printing parameters: "
11294           <<", PB="<<sPulserBox
11295           <<", LED="<<sLed
11296           <<", PH="<<sPulseHeight
11297           <<", PW="<<sPulseWidth
11298           <<endl;
11299         s="ADC Distribution, Near&Far side, PB="+sPulserBox+
11300           ", LED="+sLed+", PH="+sPulseHeight+", PW="+sPulseWidth;
11301         (hAdcPh[l])[k]->SetTitle(s.c_str());
11302         
11303         (hAdcPh[l])[k]->Draw();
11304         (hAdcPhNear[l])[k]->Draw("same");
11305         (hAdcPhFar[l])[k]->Draw("same");
11306 
11307         //print to file
11308         cAdcPh->Print(sAdcPh.c_str());
11309       }
11310     }
11311   }
11312   //close the file printed to
11313   gErrorIgnoreLevel=0;
11314   cAdcPh->Print((sAdcPh+"]").c_str());
11315 
11319 
11320   MSG("LIAnalysis",Msg::kInfo)
11321     <<"Creating vector of gain curve data objects..."<<endl;
11322   vector<LIRun> gCurveData;
11323   
11324   //Now loop over maps and create LIRuns
11325   for (Int_t i=0;i<NUMPULSERBOXES;i++){
11326     for (Int_t j=0;j<NUMLEDS;j++){
11327       Int_t l=i*NUMLEDS+j;
11328 
11329       //check whether led was flashed
11330       if (ledFlashed[l]!=1) continue;
11331       else{
11332         //add another GC
11333         gCurveData.push_back(LIRun(i,j+1,LIRun::kGainCurve,
11334                                    static_cast<Detector::
11335                                    Detector_t>(detectorType)));
11336         MSG("LIAnalysis",Msg::kDebug)
11337           <<endl<<" ** Analysing PB "<<i<<", LED "<<j+1<<" **"<<endl;
11338       }
11339 
11340       vector<LIRun>::iterator gCurveDataIter=gCurveData.end()-1;
11341 
11342       for (Int_t k=0;k<const_numCalibPoints;k++){
11343         //calculate the index   
11344         Int_t index=i*NUMLEDS*const_numCalibPoints+
11345           j*const_numCalibPoints+k;
11346 
11347         //add a point to the gain curve
11348         gCurveDataIter->AddPoint(ph[index],nearPmtMidAv[index],
11349                                  adcHighPin[index],adcLowPin[index],
11350                                  farPmtMidAv[index],
11351                                  mAdcLow[index],mAdcHigh[index],
11352                                  mAdcLowF[index],mAdcHighF[index]);
11353         
11354         MSG("LIAnalysis",Msg::kVerbose) 
11355           <<"ph="<<ph[index]
11356           <<", av="<<static_cast<Int_t>(nearPmtMidAv[index])
11357           <<", HG="<<static_cast<Int_t>(adcHighPin[index])
11358           <<", LG="<<static_cast<Int_t>(adcLowPin[index])
11359           <<", avF="<<static_cast<Int_t>(farPmtMidAv[index])
11360           <<", lo="<<static_cast<Int_t>(mAdcLow[index])
11361           <<", hi="<<static_cast<Int_t>(mAdcHigh[index])
11362           <<", loF="<<static_cast<Int_t>(mAdcLowF[index])
11363           <<", hiF="<<static_cast<Int_t>(mAdcHighF[index])<<endl;
11364       }
11365     }
11366   }
11367   
11368   //input the data to the tuning object
11369   tune.InputDataGc(gCurveData);
11370 
11371   //configure tuning object
11372   tune.SetIdealAdc(idealAdc);
11373   tune.SetdADCdPHAtSat(dADCdPHAtSat);
11374   tune.SetFirstGcPointAdc(firstGcPointAdc);
11375   tune.SetLastGcPointAdc(lastGcPointAdc);
11376   tune.SetNumCalibPoints(numCalibPoints);
11377   tune.SetNumGainPoints(numGcPoints);
11378 
11379   //print the data given to the tuning object
11380   if (MsgService::Instance()->IsActive("LITuning",Msg::kDebug) ||
11381       MsgService::Instance()->IsActive("LITuning_TuneGc",Msg::kDebug) ||
11382       MsgService::Instance()->IsActive("LITuning_TuneDp",Msg::kDebug)){
11383     tune.PrintAll();
11384   }
11385 
11386   //tune the DPs
11387   tune.CalculateDriftPoints();
11388   
11389   //tune the GCs
11390   //tune.CalculateGainCurve(LITuning::kGcLinearInPmtAdc);
11391   tune.CalculateGainCurve(LITuning::kGcLinearInPinAdc);
11392 
11394   //Make the plots:
11396 
11397   vector<TH2F*> hGcAdc;
11398   vector<TH2F*> hGcPin;
11399   vector<TH2F*> hGcPh;
11400 
11401   if (tune.GetTunedGcPlots(hGcAdc,hGcPin,hGcPh,FIRSTLED,LASTLED)){
11402 
11403     vector<TH2F*>::iterator hGcAdcIter=hGcAdc.begin();
11404     vector<TH2F*>::iterator hGcPinIter=hGcPin.begin();
11405     vector<TH2F*>::iterator hGcPhIter=hGcPh.begin();
11406     
11407     //create canvas
11408     TCanvas *cTunedGc=new TCanvas("cTunedGc","cTunedGc",0,0,1200,600);
11409     cTunedGc->SetFillColor(0);
11410     //turn the stats off  
11411     gStyle->SetOptStat(0);
11412     
11413     //set file name
11414     string sName="TunedGc.ps";
11415     if (sLowRunNumber==sHighRunNumber) fS=sHighRunNumber+sName;
11416     else fS=sLowRunNumber+"-"+sHighRunNumber+sName;
11417     
11418     //open the file
11419     cTunedGc->Print((fS+"[").c_str());
11420     gErrorIgnoreLevel=1;
11421     
11422     //loop over all the histos
11423     while(hGcAdcIter!=hGcAdc.end()){    
11424       MSG("LIAnalysis",Msg::kDebug)
11425         <<"Printing to postscript..."<<endl;    
11426       
11427       cTunedGc->Clear();
11428       (*hGcPinIter)->Draw("colz");
11429       cTunedGc->Print(fS.c_str());
11430       
11431       cTunedGc->Clear();
11432       (*hGcAdcIter)->Draw("colz");
11433       cTunedGc->Print(fS.c_str());
11434       
11435       cTunedGc->Clear();
11436       (*hGcPhIter)->Draw("colz");
11437       cTunedGc->Print(fS.c_str());
11438       
11439       hGcAdcIter++;
11440       hGcPinIter++;
11441       hGcPhIter++;
11442     }
11443     
11444     //close the file 
11445     if (MsgService::Instance()->IsActive("LIAnalysis",Msg::kDebug)){
11446       gErrorIgnoreLevel=0;
11447     }
11448     cTunedGc->Print((fS+"]").c_str()); 
11449     gErrorIgnoreLevel=0;
11450   }
11451 
11452   vector<TGraph*> gAdcVsPh;
11453   vector<TGraph*> gAdcFVsPh;
11454   vector<TGraph*> gPinVsPh;
11455   vector<TGraph*> gPin2VsPh;
11456   vector<TGraphAsymmErrors*> gAdcErrVsPh;
11457   vector<TGraphAsymmErrors*> gAdcFErrVsPh;
11458   
11459   if (tune.GetDataGcGraphs(gAdcVsPh,gAdcFVsPh,gPinVsPh,gPin2VsPh,
11460                            gAdcErrVsPh,gAdcFErrVsPh)){
11461     vector<TGraph*>::iterator gAdcVsPhIter=gAdcVsPh.begin();
11462     vector<TGraph*>::iterator gAdcFVsPhIter=gAdcFVsPh.begin();
11463     vector<TGraph*>::iterator gPinVsPhIter=gPinVsPh.begin();
11464     vector<TGraph*>::iterator gPin2VsPhIter=gPin2VsPh.begin();
11465     vector<TGraphAsymmErrors*>::iterator gAdcErrVsPhIter=
11466       gAdcErrVsPh.begin();
11467     vector<TGraphAsymmErrors*>::iterator gAdcFErrVsPhIter=
11468       gAdcFErrVsPh.begin();
11469     
11470     //create canvas
11471     TCanvas *cGcData=new TCanvas("cGcData","cGcData",0,0,1200,600);
11472     cGcData->SetFillColor(0);
11473     //turn the stats off  
11474     gStyle->SetOptStat(0);
11475     
11476     //set file name
11477     string sPrefix="";
11478     if (sLowRunNumber==sHighRunNumber) sPrefix=sHighRunNumber;
11479     else sPrefix=sLowRunNumber+"-"+sHighRunNumber;
11480     string sAdcVsPh=sPrefix+"AdcVsPh.ps";
11481     string sAdcFVsPh=sPrefix+"AdcFVsPh.ps";
11482     string sPinVsPh=sPrefix+"PinVsPh.ps";
11483     string sAdcErrVsPh=sPrefix+"AdcErrVsPh.ps";
11484     string sAdcFErrVsPh=sPrefix+"AdcFErrVsPh.ps";
11485 
11486     //open the files
11487     cGcData->Print((sAdcVsPh+"[").c_str());
11488     cGcData->Print((sAdcFVsPh+"[").c_str());
11489     cGcData->Print((sPinVsPh+"[").c_str());
11490     cGcData->Print((sAdcErrVsPh+"[").c_str());
11491     cGcData->Print((sAdcFErrVsPh+"[").c_str());
11492     gErrorIgnoreLevel=1;
11493     
11494     //loop over all the histos
11495     while(gAdcVsPhIter!=gAdcVsPh.end()){    
11496       MSG("LIAnalysis",Msg::kDebug)
11497         <<"Printing to postscript..."<<endl;    
11498       
11499       cGcData->Clear();
11500       (*gAdcVsPhIter)->Draw("AP");
11501       (*gAdcVsPhIter)->GetXaxis()->SetTitle("Pulse Height");
11502       (*gAdcVsPhIter)->GetYaxis()->SetTitle("PMT ADC");
11503       (*gAdcVsPhIter)->GetXaxis()->CenterTitle();
11504       (*gAdcVsPhIter)->GetYaxis()->CenterTitle();
11505       (*gAdcVsPhIter)->SetMarkerStyle(3);
11506       (*gAdcVsPhIter)->SetMarkerColor(2);
11507       (*gAdcVsPhIter)->SetMarkerSize(0.55);
11508       (*gAdcVsPhIter)->SetLineColor(46);
11509       cGcData->Print(sAdcVsPh.c_str());
11510 
11511       cGcData->Clear();
11512       (*gAdcFVsPhIter)->Draw("AP");
11513       (*gAdcFVsPhIter)->GetXaxis()->SetTitle("Pulse Height");
11514       (*gAdcFVsPhIter)->GetYaxis()->SetTitle("PMT ADC");
11515       (*gAdcFVsPhIter)->GetXaxis()->CenterTitle();
11516       (*gAdcFVsPhIter)->GetYaxis()->CenterTitle();
11517       (*gAdcFVsPhIter)->SetMarkerStyle(3);
11518       (*gAdcFVsPhIter)->SetMarkerColor(3);
11519       (*gAdcFVsPhIter)->SetMarkerSize(0.55);
11520       (*gAdcFVsPhIter)->SetLineColor(30);
11521       cGcData->Print(sAdcFVsPh.c_str());
11522       
11523       cGcData->Clear();
11524       (*gPinVsPhIter)->Draw("AP");
11525       (*gPinVsPhIter)->GetXaxis()->SetTitle("Pulse Height");
11526       (*gPinVsPhIter)->GetYaxis()->SetTitle("PIN ADC");
11527       (*gPinVsPhIter)->GetXaxis()->CenterTitle();
11528       (*gPinVsPhIter)->GetYaxis()->CenterTitle();
11529       (*gPinVsPhIter)->SetMarkerStyle(3);
11530       (*gPinVsPhIter)->SetMarkerColor(2);
11531       (*gPinVsPhIter)->SetMarkerSize(0.55);
11532       (*gPinVsPhIter)->SetLineColor(46);
11533       //draw the second pin too
11534       (*gPin2VsPhIter)->Draw("P");
11535       (*gPin2VsPhIter)->SetMarkerStyle(3);
11536       (*gPin2VsPhIter)->SetMarkerColor(3);
11537       (*gPin2VsPhIter)->SetMarkerSize(0.55);
11538       (*gPin2VsPhIter)->SetLineColor(30);
11539       cGcData->Print(sPinVsPh.c_str());
11540 
11541       cGcData->Clear();
11542       (*gAdcErrVsPhIter)->Draw("AP");
11543       (*gAdcErrVsPhIter)->GetXaxis()->SetTitle("Pulse Height");
11544       (*gAdcErrVsPhIter)->GetYaxis()->SetTitle("PMT ADC");
11545       (*gAdcErrVsPhIter)->GetXaxis()->CenterTitle();
11546       (*gAdcErrVsPhIter)->GetYaxis()->CenterTitle();
11547       (*gAdcErrVsPhIter)->SetMarkerStyle(3);
11548       (*gAdcErrVsPhIter)->SetMarkerColor(2);
11549       (*gAdcErrVsPhIter)->SetMarkerSize(0.55);
11550       (*gAdcErrVsPhIter)->SetLineColor(46);
11551       cGcData->Print(sAdcErrVsPh.c_str());
11552 
11553       cGcData->Clear();
11554       (*gAdcFErrVsPhIter)->Draw("AP");
11555       (*gAdcFErrVsPhIter)->GetXaxis()->SetTitle("Pulse Height");
11556       (*gAdcFErrVsPhIter)->GetYaxis()->SetTitle("PMT ADC");
11557       (*gAdcFErrVsPhIter)->GetXaxis()->CenterTitle();
11558       (*gAdcFErrVsPhIter)->GetYaxis()->CenterTitle();
11559       (*gAdcFErrVsPhIter)->SetMarkerStyle(3);
11560       (*gAdcFErrVsPhIter)->SetMarkerColor(3);
11561       (*gAdcFErrVsPhIter)->SetMarkerSize(0.75);
11562       (*gAdcFErrVsPhIter)->SetLineColor(30);
11563       cGcData->Print(sAdcFErrVsPh.c_str());
11564       
11565       gAdcVsPhIter++;
11566       gAdcFVsPhIter++;
11567       gPinVsPhIter++;
11568       gPin2VsPhIter++;
11569       gAdcErrVsPhIter++;
11570       gAdcFErrVsPhIter++;
11571     }
11572     
11573     //close the files 
11574     if (MsgService::Instance()->IsActive("LIAnalysis",Msg::kDebug)){
11575       gErrorIgnoreLevel=0;
11576     }
11577     cGcData->Print((sAdcVsPh+"]").c_str());
11578     cGcData->Print((sAdcFVsPh+"]").c_str());
11579     cGcData->Print((sPinVsPh+"]").c_str());
11580     cGcData->Print((sAdcErrVsPh+"]").c_str());
11581     cGcData->Print((sAdcFErrVsPh+"]").c_str());
11582     gErrorIgnoreLevel=0;
11583   }
11584 
11585   //create the DP graphs
11586   TGraph* gAdcVsLed=0;
11587   TGraph* gPhVsLed=0;
11588   TGraph* gPinVsLed=0;
11589 
11590   if (tune.GetTunedDpGraphs(gAdcVsLed,gPhVsLed,gPinVsLed,NUMLEDS)){
11591     
11592     //create canvas
11593     TCanvas *cTunedDp=new TCanvas("cTunedDp","cTunedDp",0,0,1200,600);
11594     cTunedDp->SetFillColor(0);
11595     //turn the stats off  
11596     gStyle->SetOptStat(0);
11597     
11598     //set file name
11599     string sPrefix="";
11600     if (sLowRunNumber==sHighRunNumber) sPrefix=sHighRunNumber;
11601     else sPrefix=sLowRunNumber+"-"+sHighRunNumber;
11602     string sTunedDp=sPrefix+"TunedDp.ps";
11603 
11604     //open the files
11605     cTunedDp->Print((sTunedDp+"[").c_str());
11606     gErrorIgnoreLevel=1;
11607     
11608     cTunedDp->Clear();
11609     gAdcVsLed->Draw("AP");
11610     gAdcVsLed->GetXaxis()->SetTitle("Led Index (PB*NUMLEDS+LED)");
11611     gAdcVsLed->GetYaxis()->SetTitle("PMT ADC");
11612     gAdcVsLed->GetXaxis()->CenterTitle();
11613     gAdcVsLed->GetYaxis()->CenterTitle();
11614     gAdcVsLed->SetMarkerStyle(3);
11615     gAdcVsLed->SetMarkerColor(2);
11616     gAdcVsLed->SetMarkerSize(0.55);
11617     gAdcVsLed->SetLineColor(46);
11618     cTunedDp->Print(sTunedDp.c_str());
11619 
11620     cTunedDp->Clear();
11621     gPhVsLed->Draw("AP");
11622     gPhVsLed->GetXaxis()->SetTitle("Led Index (PB*NUMLEDS+LED)");
11623     gPhVsLed->GetYaxis()->SetTitle("Pulse Height");
11624     gPhVsLed->GetXaxis()->CenterTitle();
11625     gPhVsLed->GetYaxis()->CenterTitle();
11626     gPhVsLed->SetMarkerStyle(3);
11627     gPhVsLed->SetMarkerColor(3);
11628     gPhVsLed->SetMarkerSize(0.55);
11629     gPhVsLed->SetLineColor(30);
11630     cTunedDp->Print(sTunedDp.c_str());
11631 
11632     cTunedDp->Clear();
11633     gPinVsLed->Draw("AP");
11634     gPinVsLed->GetXaxis()->SetTitle("Led Index (PB*NUMLEDS+LED)");
11635     gPinVsLed->GetYaxis()->SetTitle("PIN ADC");
11636     gPinVsLed->GetXaxis()->CenterTitle();
11637     gPinVsLed->GetYaxis()->CenterTitle();
11638     gPinVsLed->SetMarkerStyle(3);
11639     gPinVsLed->SetMarkerColor(2);
11640     gPinVsLed->SetMarkerSize(0.55);
11641     gPinVsLed->SetLineColor(46);
11642     //draw the second pin too
11643     //gPin2VsLed->Draw("P");
11644     //gPin2VsLed->SetMarkerStyle(3);
11645     //gPin2VsLed->SetMarkerColor(3);
11646     //gPin2VsLed->SetMarkerSize(0.55);
11647     //gPin2VsLed->SetLineColor(30);
11648     cTunedDp->Print(sTunedDp.c_str());
11649 
11650     //close the files 
11651     if (MsgService::Instance()->IsActive("LIAnalysis",Msg::kDebug)){
11652       gErrorIgnoreLevel=0;
11653     }
11654     cTunedDp->Print((sTunedDp+"]").c_str());
11655     gErrorIgnoreLevel=0;
11656   }
11657 
11658   //check which leds were tuned
11659   tune.PrintLedCheckGrid(LIRun::kDriftPoint,
11660                          FIRSTPULSERBOX,LASTPULSERBOX,
11661                          FIRSTLED,LASTLED);
11662   tune.PrintLedCheckGrid(LIRun::kGainCurve,
11663                          FIRSTPULSERBOX,LASTPULSERBOX,
11664                          FIRSTLED,LASTLED);
11665 
11666   //print the tuned values for li.config
11667   tune.PrintLIConfig(LIRun::kDriftPoint);
11668   tune.PrintLIConfig(LIRun::kGainCurve);
11669 
11670   //print all the parameters used in the tuning
11671   tune.PrintConfig();
11672 
11673   MSG("LIAnalysis",Msg::kInfo)  
11674     <<endl<<" ** Finished the LedTuning method ** "<<endl; 
11675 } 

void LIAnalysis::LISnarlProblem (  ) 

Definition at line 9532 of file LIAnalysis.cxx.

References chip, correlatedHit, farPulserBox, Form(), InitialiseLoopVariables(), Msg::kInfo, ReadoutType::kScintStrip, led, mean, MSG, nearPulserBox, numEntries, numEvents, pulserBox, readoutType, rms, runNumber, SetLoopVariables(), and vfb.

09533 {
09534   MSG("LIAnalysis",Msg::kInfo) 
09535     <<endl<<" ** Running the LISnarlProblem method... ** "<<endl;
09536 
09537   TH1F *hChipNum=new TH1F("hChipNum","VA ChipNums hit",50,-1,7);
09538   hChipNum->GetXaxis()->SetTitle("ChipNum");
09539   hChipNum->GetXaxis()->CenterTitle();
09540   hChipNum->GetYaxis()->SetTitle("Total number of entries");
09541   hChipNum->GetYaxis()->CenterTitle();
09542   hChipNum->SetFillColor(0);
09543   hChipNum->SetBit(TH1::kCanRebin);
09544 
09545   TH1F *hChipNumF=new TH1F("hChipNumF","VA ChipNums hit (far)",50,-1,7);
09546   hChipNumF->GetXaxis()->SetTitle("ChipNum");
09547   hChipNumF->GetXaxis()->CenterTitle();
09548   hChipNumF->GetYaxis()->SetTitle("Total number of entries");
09549   hChipNumF->GetYaxis()->CenterTitle();
09550   hChipNumF->SetFillColor(0);
09551   hChipNumF->SetBit(TH1::kCanRebin);
09552 
09556   
09557   this->InitialiseLoopVariables();  
09558   
09559   for(Int_t entry=0;entry<numEvents;entry++){
09560     
09561     this->SetLoopVariables(entry,0);
09562     
09563     //ignore any zeros that slipped through
09564     if (mean==0 || rms==0 || numEntries==0) continue;
09565 
09566     //only look at scint strips
09567     if (readoutType!=ReadoutType::kScintStrip) continue;
09568 
09569     Int_t chipNum=vfb*3+chip;
09570 
09571     if (pulserBox==nearPulserBox){
09572       hChipNum->Fill(chipNum,numEntries);
09573     }
09574     
09575     if (pulserBox==farPulserBox){
09576       hChipNumF->Fill(chipNum,numEntries);
09577     }
09578   
09579     if (pulserBox==0 && led<11 && correlatedHit==1 && 
09580         pulserBox==nearPulserBox){
09581 
09582       if (chipNum==0 || chipNum==5){
09583         MSG("LIAnalysis",Msg::kInfo) 
09584           <<"led="<<led
09585           <<", pulser box="<<pulserBox
09586           <<", chipNum="<<chipNum
09587           <<", numEntries="<<numEntries
09588           <<endl;
09589       }
09590     }
09591   }//end of for                                       
09592   
09596 
09597   MSG("LIAnalysis",Msg::kInfo)<<"Finished main loop"<<endl;
09598 
09599   //include the under and overflow counts
09600   gStyle->SetOptStat(1111111);
09601   //set up useful string
09602   string sRunNumber=Form("%d",runNumber);
09603 
09604   TCanvas *cChipNum=new TCanvas("cChipNum","ChipNum",0,0,1200,800);
09605   cChipNum->SetFillColor(0);
09606   cChipNum->cd();
09607   hChipNum->Draw();
09608 
09609   TCanvas *cChipNumF=new TCanvas("cChipNumF","ChipNumF",0,0,1200,800);
09610   cChipNumF->SetFillColor(0);
09611   cChipNumF->cd();
09612   hChipNumF->Draw();
09613 
09614   MSG("LIAnalysis",Msg::kInfo) 
09615     <<endl<<" ** Finished the LISnarlProblem method ** "<<endl;
09616 }

void LIAnalysis::MakeChain (  )  [private]

Definition at line 211 of file LIAnalysis.cxx.

References chain, exit(), Msg::kDebug, Msg::kFatal, Msg::kInfo, and MSG.

Referenced by LIAnalysis().

00212 {
00213   MSG("LIAnalysis", Msg::kDebug)<<"Running MakeChain method..."<<endl;
00214 
00215   //LI data files to read in
00216   char* envVariable=getenv("LIDATA");
00217   if (envVariable==NULL){
00218     MSG("LIAnalysis",Msg::kFatal)
00219       <<endl<<endl
00220       <<"*************************************************************"
00221       <<endl<<"Environmental variable LIDATA not set!"<<endl
00222       <<"Please set LIDATA to the directory containing the"
00223       <<" LIData*.root files"<<endl
00224       <<"Note: If more than one file is found they will be"
00225       <<" concatenated and treated as one"<<endl
00226       <<"*************************************************************"
00227       <<endl<<endl<<"Program will exit here"<<endl;
00228     exit(0);
00229   }
00230   string sEnv=envVariable;
00231   MSG("LIAnalysis",Msg::kInfo)
00232     <<"Looking for LIData*.root files using the env variable"<<endl
00233     <<"LIDATA="<<sEnv<<endl;
00234   
00235   string sFileName=sEnv+"/LIData*.root";
00236 
00237   // create a chain with li_tree
00238   chain=new TChain("li_tree");  
00239   //add the files to the chain
00240   Int_t nf=chain->Add(sFileName.c_str());
00241 
00242   if(nf==0){
00243     MSG("LIAnalysis",Msg::kFatal)
00244       <<endl<<endl
00245       <<"*************************************************************"
00246       <<endl<<"No LIData*.root files found in "<<sEnv<<endl
00247       <<"Please set LIDATA to the directory containing the"
00248       <<" LIData*.root files"<<endl
00249       <<"Note: If more than one file is found they will be"
00250       <<" concatenated and treated as one"<<endl
00251       <<"*************************************************************"
00252       <<endl<<endl<<"Program will exit here"<<endl;
00253     exit(0);
00254   }
00255     
00256   MSG("LIAnalysis",Msg::kInfo) 
00257     <<"Printing tree information:"<<endl;
00258   chain->Show(1);
00259   //chain->Print()
00260   
00261   if (nf==1){
00262     MSG("LIAnalysis",Msg::kInfo) 
00263       <<endl<<"Analysing "<<nf<<" file of the form LIData*.root in"
00264       <<endl<<"LIDATA="<<sEnv<<endl<<endl;
00265   }
00266   else