00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00013
00014 #include <fstream>
00015 #include <cmath>
00016 #include <string>
00017
00018 #include "TStyle.h"
00019 #include "TFile.h"
00020 #include "TTree.h"
00021 #include "TH1.h"
00022 #include "TH2.h"
00023 #include "TF1.h"
00024 #include "TCanvas.h"
00025 #include "TAxis.h"
00026 #include "TDatime.h"
00027 #include "TGraph.h"
00028 #include "TGraphAsymmErrors.h"
00029 #include "TGraphErrors.h"
00030 #include "TLegend.h"
00031 #include "TPad.h"
00032 #include "TPaveText.h"
00033 #include "TText.h"
00034 #include "TError.h"
00035
00036 #include "Plex/PlexHandle.h"
00037 #include "MessageService/MsgService.h"
00038
00039 #include "LISummary/LIAnalysis.h"
00040 #include "LISummary/LIChannel.h"
00041 #include "LISummary/LIPlane.h"
00042 #include "LISummary/LIRun.h"
00043 #include "LISummary/LITuning.h"
00044 #include "Validity/VldContext.h"
00045 #include "Validity/VldTimeStamp.h"
00046 #include "Calibrator/Calibrator.h"
00047 #include "Calibrator/CalScheme.h"
00048
00049 ClassImp(LIAnalysis)
00050
00051 CVSID("$Id: LIAnalysis.cxx,v 1.74 2009/06/02 21:29:38 nickd Exp $");
00052
00053
00054
00055 class LIHits
00056 {
00057
00058
00059 public:
00060
00061 map<Float_t,Int_t> hits;
00062 };
00063
00064
00065
00066 LIAnalysis::LIAnalysis(Int_t analyseChainFlag)
00067 {
00068 MSG("LIAnalysis", Msg::kDebug)
00069 <<"Running LIAnalysis constructor..."<<endl;
00070
00071
00072 gStyle->SetPalette(1);
00073
00074 gStyle->SetOptStat(1111111);
00075 gStyle->SetOptFit(1111);
00076
00077
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;
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;
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;
00131 pinInBox=-1;
00132 plane=-1;
00133 previousRunNumber=-1;
00134 pulseHeight=-1;
00135 pulserBox=-1;
00136 pulses=-1;
00137 pulseWidth=-1;
00138 rackBay=-1;
00139 rackLevel=-1;
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
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
00168 chain->GetEvent(numEvents-1);
00169 lastRunNumber=runNumber;
00170
00171
00172 chain->GetEvent(0);
00173 firstRunNumber=runNumber;
00174
00175
00176 this->SetDetector(detectorType);
00177
00178
00179
00180
00181 highRunNumber=firstRunNumber;
00182 if (lastRunNumber>firstRunNumber) highRunNumber=lastRunNumber;
00183
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 }
00196
00197
00198
00199 LIAnalysis::~LIAnalysis()
00200 {
00201 MSG("LIAnalysis", Msg::kDebug)
00202 <<"Running LIAnalysis destructor..."<<endl;
00203
00204
00205 MSG("LIAnalysis", Msg::kDebug)
00206 <<"Finished LIAnalysis destructor"<<endl;
00207 }
00208
00209
00210
00211 void LIAnalysis::MakeChain()
00212 {
00213 MSG("LIAnalysis", Msg::kDebug)<<"Running MakeChain method..."<<endl;
00214
00215
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
00238 chain=new TChain("li_tree");
00239
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
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{
00267 MSG("LIAnalysis",Msg::kInfo)
00268 <<endl<<"Analysing "<<nf
00269 <<" files of the form LIData*.root in directory"
00270 <<endl<<"LIDATA="<<sEnv<<endl<<endl;
00271 MSG("LIAnalysis",Msg::kInfo)
00272 <<"Reading in files..."<<endl;
00273 }
00274
00275 MSG("LIAnalysis", Msg::kDebug)<<"Finished the MakeChain method"<<endl;
00276 }
00277
00278
00279
00280 void LIAnalysis::SetChainBranches()
00281 {
00282 chain->SetBranchAddress("ashtray",&ashtray);
00283 chain->SetBranchAddress("calibPoint",&calibPoint);
00284 chain->SetBranchAddress("calibType",&calibType);
00285 chain->SetBranchAddress("chAdd",&chAdd);
00286 chain->SetBranchAddress("channel",&channel);
00287 chain->SetBranchAddress("chip",&chip);
00288 chain->SetBranchAddress("correlatedHit",&correlatedHit);
00289 chain->SetBranchAddress("crate",&crate);
00290 chain->SetBranchAddress("detectorType",&detectorType);
00291 chain->SetBranchAddress("eastWest",&eastWest);
00292 chain->SetBranchAddress("elecType",&elecType);
00293 chain->SetBranchAddress("farLed",&farLed);
00294 chain->SetBranchAddress("farPulserBox",&farPulserBox);
00295 chain->SetBranchAddress("geoAdd",&geoAdd);
00296 chain->SetBranchAddress("inRack",&inRack);
00297 chain->SetBranchAddress("led",&led);
00298 chain->SetBranchAddress("masterCh",&masterCh);
00299 chain->SetBranchAddress("mean",&mean);
00300 chain->SetBranchAddress("minderCh",&minderCh);
00301 chain->SetBranchAddress("nearLed",&nearLed);
00302 chain->SetBranchAddress("nearPulserBox",&nearPulserBox);
00303 chain->SetBranchAddress("numEntries",&numEntries);
00304 chain->SetBranchAddress("numericMuxBox",&numericMuxBox);
00305 chain->SetBranchAddress("period",&period);
00306 chain->SetBranchAddress("pinGain",&pinGain);
00307 chain->SetBranchAddress("pinInBox",&pinInBox);
00308 chain->SetBranchAddress("pixel",&pixel);
00309 chain->SetBranchAddress("plane",&plane);
00310 chain->SetBranchAddress("pulseHeight",&pulseHeight);
00311 chain->SetBranchAddress("pulserBox",&pulserBox);
00312 chain->SetBranchAddress("pulses",&pulses);
00313 chain->SetBranchAddress("pulseWidth",&pulseWidth);
00314 chain->SetBranchAddress("rackBay",&rackBay);
00315 chain->SetBranchAddress("rackLevel",&rackLevel);
00316 chain->SetBranchAddress("readoutType",&readoutType);
00317 chain->SetBranchAddress("rms",&rms);
00318 chain->SetBranchAddress("runNumber",&runNumber);
00319 chain->SetBranchAddress("runNumberSub",&runNumberSub);
00320 chain->SetBranchAddress("runType",&runType);
00321 chain->SetBranchAddress("strip",&strip);
00322 chain->SetBranchAddress("stripEnd",&stripEnd);
00323 chain->SetBranchAddress("summaryCounter",&summaryCounter);
00324 chain->SetBranchAddress("timestamp",×tamp);
00325 chain->SetBranchAddress("varc",&varc);
00326 chain->SetBranchAddress("vfb",&vfb);
00327 chain->SetBranchAddress("vmm",&vmm);
00328 }
00329
00330
00331
00332 void LIAnalysis::AnalyseChain()
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
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
00392
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 }
00436
00437
00438
00439 void LIAnalysis::InitialiseLoopVariables()
00440 {
00441 MSG("LIAnalysis",Msg::kInfo)<<"Initialising loop variables..."<<endl;
00442
00443 liEvent=-1;
00444 lastLed=-1;
00445 lastPulserBox=-1;
00446 lastCalibPoint=-1;
00447 liRunNum=0;
00448 run=0;
00449
00450
00451 chain->GetEvent(0);
00452 previousRunNumber=runNumber;
00453
00454 MSG("LIAnalysis",Msg::kInfo)<<"Initialisation complete"<<endl;
00455 }
00456
00457
00458
00459 void LIAnalysis::SetLoopVariables(Int_t entry,Int_t printOnNewLed,
00460 Bool_t doInfoPrint)
00461 {
00462
00463 Float_t fract=ceil(numEvents/10.);
00464
00465 if (entry==10 && doInfoPrint) {
00466 TDatime datime;
00467 datime.Set(timestamp);
00468 MSG("LIAnalysis",Msg::kInfo)<<" Timestamp1"<<setw(3)<<(Int_t)(100.*(entry+1)/numEvents)<<" %: "<<datime.GetDate()<<" "
00469 <<datime.GetYear()<<" "<<setw(2)<<datime.GetMonth()<<" "<<setw(2)<<datime.GetDay()<<" "
00470 <<setw(2)<<datime.GetHour()<<" "<<setw(2)<<datime.GetMinute()<<" "<<setw(2)<<datime.GetSecond()<<endl;
00471 }
00472 if ((entry==numEvents-1 || ceil(((Float_t)entry)/fract)==((Float_t)entry)/fract) &&doInfoPrint){
00473 MSG("LIAnalysis",Msg::kInfo)
00474 <<"Fraction of loop complete: "<<entry+1
00475 <<"/"<<numEvents<<" ("
00476 <<(Int_t)(100.*(entry+1)/numEvents)<<"%)"<<endl;
00477
00478 TDatime datime;
00479 datime.Set(timestamp);
00480 MSG("LIAnalysis",Msg::kInfo)<<" Timestamp "<<setw(3)<<(Int_t)(100.*(entry+1)/numEvents)<<" %: "<<datime.GetDate()<<" "
00481 <<datime.GetYear()<<" "<<setw(2)<<datime.GetMonth()<<" "<<setw(2)<<datime.GetDay()<<" "
00482 <<setw(2)<<datime.GetHour()<<" "<<setw(2)<<datime.GetMinute()<<" "<<setw(2)<<datime.GetSecond()<<endl;
00483 }
00484
00485 chain->GetEvent(entry);
00486
00487 if (runNumber<lowRunNumber) lowRunNumber=runNumber;
00488 if (runNumber>highRunNumber) highRunNumber=runNumber;
00489
00490 if (runNumber!=previousRunNumber) {
00491 run++;
00492 if(doInfoPrint) MSG("LIAnalysis",Msg::kInfo)
00493 << " ** Found new run number = "
00494 <<runNumber
00495 <<" (previous run number = "
00496 <<previousRunNumber<<")"
00497 <<", run="<<run<<endl;
00498 }
00499 previousRunNumber=runNumber;
00500
00501
00502 if (lastLed-led>0 && lastPulserBox-pulserBox>0){
00503 liRunNum++;
00504 }
00505
00506 if (lastPulserBox-pulserBox>0 ||
00507 (lastLed-led>0 && lastCalibPoint-calibPoint>0)){
00508 TDatime datime;
00509 datime.Set(timestamp);
00510 if(doInfoPrint) MSG("LIAnalysis",Msg::kInfo) <<"Next set: "
00511 <<"Pulser Box="<<pulserBox
00512 <<", first led in set="<<led
00513 <<", calibType="
00514 <<calibType<<endl;
00515
00516 MSG("LIAnalysis",Msg::kDebug)
00517 <<"PH="<<pulseHeight
00518 <<", PW="<<pulseWidth
00519 <<", tstamp="<<timestamp
00520 <<", time="<<datime.GetTime()
00521 <<", date="<<datime.GetDate()
00522 <<endl;
00523 }
00524
00525
00526 if (led!=lastLed){
00527 liEvent++;
00528
00529 if (printOnNewLed==1&&doInfoPrint){
00530 this->PrintBlockInfo(" ** New point: ");
00531 }
00532 }
00533
00534 lastLed=led;
00535 lastPulserBox=pulserBox;
00536 lastCalibPoint=calibPoint;
00537 }
00538
00539
00540
00541 TGraph* LIAnalysis::TGraphVect(vector<Double_t>& vX,
00542 vector<Double_t>& vY)
00543 {
00544 MSG("LIPlexMaps",Msg::kDebug)
00545 <<" ** Running TGraphVect method... **"<<endl;
00546
00547 TGraph* g=new TGraph(vX.size());
00548
00549 for (UInt_t i=0;i<vX.size();i++){
00550 g->SetPoint(i,vX[i],vY[i]);
00551 }
00552
00553 MSG("LIPlexMaps",Msg::kDebug)
00554 <<" ** Finished TGraphVect method **"<<endl;
00555 return g;
00556 }
00557
00558
00559
00560 void LIAnalysis::AppendVect(vector<Double_t>& trunk,
00561 vector<Double_t> appendix)
00562 {
00563 MSG("LIAnalysis",Msg::kDebug)
00564 <<" ** Running AppendVect method... **"<<endl;
00565
00566
00567
00568
00569 for (UInt_t i=0;i<appendix.size();i++){
00570 trunk.push_back(appendix[i]);
00571 }
00572
00573 MSG("LIAnalysis",Msg::kDebug)
00574 <<" ** Finished AppendVect method **"<<endl;
00575 }
00576
00577
00578
00579 void LIAnalysis::PrintBlockInfo(string preString)
00580 {
00581 MSG("LIAnalysis",Msg::kVerbose)<<"PrintBlockInfo..."<<endl;
00582
00583 MSG("LIAnalysis",Msg::kVerbose)
00584 <<"Number of seconds="<<timestamp<<endl;
00585
00586 TDatime datime;
00587 datime.Set(timestamp);
00588
00589
00590 string sHour=Form("%d",datime.GetHour());
00591 string sMinute=Form("%d",datime.GetMinute());
00592 string sSecond=Form("%d",datime.GetSecond());
00593 string sMonth=Form("%d",datime.GetMonth());
00594 string sDay=Form("%d",datime.GetDay());
00595 if (datime.GetHour()<10) sHour="0"+sHour;
00596 if (datime.GetMinute()<10) sMinute="0"+sMinute;
00597 if (datime.GetSecond()<10) sSecond="0"+sSecond;
00598 if (datime.GetMonth()<10) sMonth="0"+sMonth;
00599 if (datime.GetDay()<10) sDay="0"+sDay;
00600
00601
00602 Double_t pulseFreq=-1;
00603 if (period!=0) pulseFreq=ceil(1.0/(period*1.0e-5));
00604 string sPulseFreq=Form("%d",static_cast<Int_t>(pulseFreq));
00605 string sPeriod=Form("%d",static_cast<Int_t>(period));
00606 if (pulseFreq<0) sPulseFreq="??? (period="+sPeriod+")";
00607
00608 MSG("LIAnalysis",Msg::kInfo)
00609 <<preString
00610 <<"PB="<<pulserBox
00611 <<" Led="<<led
00612 <<" CP="<<calibPoint
00613 <<"/"<<calibType
00614 <<" PH="<<pulseHeight
00615 <<" PW="<<pulseWidth
00616 <<" PF="<<sPulseFreq
00617 <<" PN="<<pulses
00618 <<" at "<<sHour
00619 <<":"<<sMinute
00620 <<":"<<sSecond
00621 <<" on "<<datime.GetYear()
00622 <<"/"<<sMonth
00623 <<"/"<<sDay
00624 <<endl;
00625
00626 MSG("LIAnalysis",Msg::kVerbose)
00627 <<"PrintBlockInfo method finished"<<endl;
00628 }
00629
00630
00631
00632 void LIAnalysis::PrintBigMessage()
00633 {
00634 MSG("LIAnalysis",Msg::kInfo)
00635 <<"("<<pulserBox<<":"<<led<<")";
00636
00637 if (elecType==ElecType::kVA){
00638 MSG("LIAnalysis",Msg::kInfo)
00639 <<"VA("<<crate<<","<<varc<<","<<vmm<<","<<vfb
00640 <<","<<chip<<","<<channel<<")";
00641 }
00642 else if (elecType==ElecType::kQIE){
00643 MSG("LIAnalysis",Msg::kInfo)
00644 <<"QIE("<<crate<<","<<geoAdd<<","<<masterCh<<","<<minderCh<<")";
00645 }
00646
00647 MSG("LIAnalysis",Msg::kInfo)
00648 <<", (m,r,n)=("<<mean<<","<<rms
00649 <<","<<numEntries<<"), cHit="<<correlatedHit
00650 <<", e/w="<<eastWest<<", rt="<<readoutType
00651 <<" (Pl;St)=("<<plane<<";"<<strip<<")"<<endl;
00652 }
00653
00654
00655
00656 void LIAnalysis::PrintElec()
00657 {
00658 MSG("LIAnalysis",Msg::kInfo)
00659 <<endl<<" ** Running the PrintElec method... ** "<<endl;
00660
00664
00665 this->InitialiseLoopVariables();
00666
00667 for(Int_t entry=0;entry<5000;entry++){
00668
00669
00670 this->SetLoopVariables(entry,0);
00671
00672 MSG("LIAnalysis",Msg::kDebug)
00673 <<"QIE("<<crate<<","<<geoAdd<<","<<masterCh<<","<<minderCh<<")"
00674 <<", VA("<<crate<<","<<varc<<","<<vmm<<","<<vfb<<","<<chip
00675 <<","<<channel<<")"
00676 <<" mean="<<mean<<endl;
00677
00678 if (crate>0 && correlatedHit==1 && numEntries<0.999*pulses &&
00679 lookup.NearOrFar(crate,pulserBox,nearPulserBox,
00680 farPulserBox,led,detectorType,
00681 plane,runNumber)==LILookup::kNearSide){
00682 MSG("LIAnalysis",Msg::kInfo)
00683 <<endl<<"******************************"<<endl
00684 <<this->GetElecString()<<", CH="<<correlatedHit
00685 <<" (P;S)=("<<plane<<";"<<strip<<")"
00686 <<" (m,r,n)=("<<static_cast<Int_t>(mean)
00687 <<","<<static_cast<Int_t>(rms)<<","<<numEntries<<")"
00688 <<endl<<"******************************"<<endl;
00689 }
00690 else if (crate>0 &&
00691 lookup.NearOrFar(crate,pulserBox,nearPulserBox,
00692 farPulserBox,led,detectorType,
00693 plane,runNumber)==LILookup::kNearSide){
00694 MSG("LIAnalysis",Msg::kInfo)
00695 <<this->GetElecString()<<", CH="<<correlatedHit
00696 <<" (P;S)=("<<plane<<";"<<strip<<")"
00697 <<" (m,r,n)=("<<static_cast<Int_t>(mean)
00698 <<","<<static_cast<Int_t>(rms)<<","<<numEntries<<")"
00699 <<endl;
00700 }
00701
00702 }
00703
00707
00708 MSG("LIAnalysis",Msg::kInfo)<<"Finished main loop"<<endl;
00709
00710 MSG("LIAnalysis",Msg::kInfo)
00711 <<endl<<" ** Finished the PrintElec method ** "<<endl;
00712 }
00713
00714
00715
00716 void LIAnalysis::PrintPmt()
00717 {
00718 MSG("LIAnalysis",Msg::kInfo)
00719 <<endl<<" ** Running the PrintPmt method... ** "<<endl;
00720
00721
00722
00724
00725
00726
00730
00731 this->InitialiseLoopVariables();
00732
00733 for(Int_t entry=0;entry<numEvents;entry++){
00734
00735 this->SetLoopVariables(entry,1);
00736
00737
00738 if (readoutType!=ReadoutType::kScintStrip) continue;
00739
00740 MSG("LIAnalysis",Msg::kInfo)
00741 <<this->GetElecString()
00742 <<"E/W="<<eastWest<<", rLevel="<<rackLevel<<", rBay="<<rackBay
00743 <<", inRack="<<inRack<<", muxBox="<<numericMuxBox<<endl;
00744
00745 }
00746
00750
00751 MSG("LIAnalysis",Msg::kInfo)<<"Finished main loop"<<endl;
00752
00753 MSG("LIAnalysis",Msg::kInfo)
00754 <<endl<<" ** Finished the PrintPmt method ** "<<endl;
00755 }
00756
00757
00758
00759 void LIAnalysis::PrintGainTableRow(Int_t pl,Int_t st,Int_t end,
00760 string sPrefix,
00761 string sAdcN,string sGainN,
00762 string sGainErrN,string sNumN,
00763 string sAdcF,string sGainF,
00764 string sGainErrF,string sNumF,
00765 string sLogLevel)
00766 {
00767 MSG("LIAnalysis",Msg::kVerbose)
00768 <<endl<<" ** Running the PrintGainTableRow method... ** "<<endl;
00769
00770
00771
00772 Msg::LogLevel_t logLevel=Msg::GetLevelCode(sLogLevel.c_str());
00773
00774 MSG("LIAnalysis",logLevel)
00775 <<"("<<pl<<";"<<st<<";"<<end<<")"
00776 <<sPrefix
00777 <<" Near(m,g,ge,n)=("<<sAdcN
00778 <<","<<sGainN
00779 <<","<<sGainErrN
00780 <<","<<sNumN<<")"
00781 <<", Far=("<<sAdcF
00782 <<","<<sGainF
00783 <<","<<sGainErrF
00784 <<","<<sNumF<<")"
00785 <<endl;
00786
00787 MSG("LIAnalysis",Msg::kVerbose)
00788 <<endl<<" ** Finished the PrintGainTableRow method ** "<<endl;
00789 }
00790
00791
00792
00793 string LIAnalysis::GetElecString()
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 }
00822
00823
00824
00825 void LIAnalysis::ClearFibres()
00826 {
00827 MSG("LIAnalysis",Msg::kInfo)
00828 <<endl<<" ** Running the ClearFibres method... ** "<<endl;
00829
00830
00831
00832
00833
00834
00835
00836
00837
00838
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 }
00868
00869
00870
00871 void LIAnalysis::SearchForBadLeds(Int_t minNumHits)
00872 {
00873 MSG("LIAnalysis",Msg::kInfo)
00874 <<endl<<" ** Running the SearchForBadLeds method... ** "<<endl;
00875
00876 vector<Int_t> numHits(NUMLEDS*NUMPULSERBOXES,0);
00877
00881
00882 this->InitialiseLoopVariables();
00883
00884 for(Int_t entry=0;entry<numEvents;entry++){
00885
00886 this->SetLoopVariables(entry,0);
00887
00888
00889 if (readoutType!=ReadoutType::kScintStrip) continue;
00890
00891
00892 if (rms==0. || mean==0. || numEntries==0) continue;
00893
00894 Int_t l=pulserBox*NUMLEDS+led-1;
00895
00896
00897
00898
00899
00900
00901
00902
00903
00904
00905
00906
00907
00908
00909
00910
00911 if (true==false && ((pulserBox==5 && led==2) ||
00912 (pulserBox==5 && led==5) ||
00913 (pulserBox==5 && led==10) ||
00914
00915 (pulserBox==8 && led==11) ||
00916 (pulserBox==8 && led==12) ||
00917 (pulserBox==8 && led==15) ||
00918 (pulserBox==8 && led==18) ||
00919 (pulserBox==8 && led==19) ||
00920 (pulserBox==8 && led==20) ||
00921
00922 (pulserBox==12 && led==15) ||
00923 (pulserBox==12 && led==16) ||
00924
00925 (pulserBox==14 && led==10) ||
00926 (pulserBox==14 && led==13))){
00927
00928 this->PrintBigMessage();
00929 }
00930
00931 if (pulserBox>=FIRSTPULSERBOX && pulserBox<=LASTPULSERBOX &&
00932 correlatedHit==1 &&
00933 led>=FIRSTLED && led<=LASTLED){
00934 numHits[l]++;
00935 }
00936 }
00937
00941
00942 MSG("LIAnalysis",Msg::kInfo)<<"Finished main loop"<<endl;
00943
00944 Int_t counter=0;
00945
00946
00947 MSG("LIAnalysis",Msg::kInfo)
00948 <<endl<<"Printing number of hits on all leds..."<<endl;
00949 for (Int_t i=0;i<NUMPULSERBOXES;i++){
00950 for (Int_t j=0;j<NUMLEDS;j++){
00951 Int_t l=i*NUMLEDS+j;
00952 MSG("LIAnalysis",Msg::kInfo)
00953 <<"("<<i<<":"<<j+1<<") has "<<numHits[l]<<" hits"<<endl;
00954 if (numHits[l]<minNumHits) counter++;
00955 }
00956 }
00957
00958 MSG("LIAnalysis",Msg::kInfo)
00959 <<endl<<counter<<" leds have a low number of hits:"<<endl;
00960 for (Int_t i=0;i<NUMPULSERBOXES;i++){
00961 for (Int_t j=0;j<NUMLEDS;j++){
00962 Int_t l=i*NUMLEDS+j;
00963 if (numHits[l]<minNumHits){
00964 MSG("LIAnalysis",Msg::kInfo)
00965 <<"("<<i<<":"<<j+1<<") only has "<<numHits[l]<<" hits"<<endl;
00966 }
00967 }
00968 }
00969
00970 MSG("LIAnalysis",Msg::kInfo)
00971 <<" ** Finished the SearchForBadLeds method ** "<<endl;
00972 }
00973
00974
00975
00976 void LIAnalysis::PinDiodeChips()
00977 {
00978 MSG("LIAnalysis",Msg::kInfo)
00979 <<endl<<" ** Running the PinDiodeChips method... ** "<<endl;
00980
00981 TH1F *hChipHigh=new TH1F("hChipHigh","Pin Diode Chips",5,-1.,4.);
00982 hChipHigh->GetXaxis()->SetTitle("chip");
00983 hChipHigh->GetXaxis()->CenterTitle();
00984 hChipHigh->GetYaxis()->SetTitle("Num Entries");
00985 hChipHigh->GetYaxis()->CenterTitle();
00986 hChipHigh->SetFillColor(0);
00987 hChipHigh->SetLineColor(2);
00988 hChipHigh->SetBit(TH1::kCanRebin);
00989
00990 TH1F *hChipLow=new TH1F("hChipLow","Pin Diode Chips",
00991 5,-1.,4.);
00992 hChipLow->GetXaxis()->SetTitle("chip");
00993 hChipLow->GetXaxis()->CenterTitle();
00994 hChipLow->GetYaxis()->SetTitle("Num Entries");
00995 hChipLow->GetYaxis()->CenterTitle();
00996 hChipLow->SetFillColor(0);
00997 hChipLow->SetLineColor(3);
00998 hChipLow->SetBit(TH1::kCanRebin);
00999
01000 Int_t pinsOnPulserBox=0;
01001 Int_t totalPins=0;
01002 Int_t correlatedPins=0;
01003 Int_t zeroRmsPins=0;
01004
01008
01009 this->InitialiseLoopVariables();
01010
01011 for(Int_t entry=0;entry<numEvents;entry++){
01012
01013 this->SetLoopVariables(entry,0);
01014
01015
01016 if (readoutType!=ReadoutType::kPinDiode) continue;
01017
01018
01019 if (rms==0. || mean==0. || numEntries==0){
01020
01021 MSG("LIAnalysis",Msg::kVerbose)
01022 <<"led="<<led<<", pb="<<pulserBox
01023 <<", mean="<<mean
01024 <<", rms="<<rms
01025 <<", numEntries="<<numEntries
01026 <<endl;
01027 zeroRmsPins++;
01028 if (pulserBox==nearPulserBox) pinsOnPulserBox++;
01029 if (correlatedHit==1) correlatedPins++;
01030 totalPins++;
01031 continue;
01032 }
01033
01034 if (pulserBox==nearPulserBox) pinsOnPulserBox++;
01035 if (correlatedHit==1) correlatedPins++;
01036 totalPins++;
01037
01038 if (pinGain==0) hChipHigh->Fill(chip);
01039 else if (pinGain==1) hChipLow->Fill(chip);
01040 else MSG("LIAnalysis",Msg::kInfo)<<"Pin gain="<<pinGain<<endl;
01041
01042 }
01043
01047
01048 MSG("LIAnalysis",Msg::kInfo)<<"Finished main loop"<<endl;
01049
01050 MSG("LIAnalysis",Msg::kInfo)
01051 <<endl
01052 <<"pinsOnPulserBox = "<<pinsOnPulserBox<<" of "<<totalPins
01053 <<" ("<<100.*pinsOnPulserBox/totalPins<<"%)"
01054 <<endl
01055 <<"correlatedPins = "<<correlatedPins<<" of "<<totalPins
01056 <<" ("<<100.*correlatedPins/totalPins<<"%)"
01057 <<endl
01058 <<"zeroRmsPins = "<<zeroRmsPins<<" of "<<totalPins
01059 <<" ("<<100.*zeroRmsPins/totalPins<<"%)"
01060 <<endl
01061
01062
01063 <<endl;
01064
01065
01066
01067
01068
01069
01070
01071
01072
01073 TCanvas *cPinChip=new TCanvas("cPinChip","cPinChip",1,1,800,600);
01074 cPinChip->SetFillColor(0);
01075 hChipHigh->Draw();
01076 hChipLow->Draw("same");
01077
01078 MSG("LIAnalysis",Msg::kInfo)
01079 <<" ** Finished the PinDiodeChips method ** "<<endl;
01080 }
01081
01082
01083
01084 void LIAnalysis::AdcVsPin()
01085 {
01086 MSG("LIAnalysis",Msg::kInfo)
01087 <<endl<<" ** Running the AdcVsPin method... ** "<<endl;
01088
01089 Int_t numAdcBins=150;
01090
01091
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
01097 Int_t l=i*NUMLEDS+j;
01098
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
01110 }
01111 }
01112
01113
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
01119 Int_t l=i*NUMLEDS+j;
01120
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
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
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
01167 if (mean==0 || rms==0 || numEntries==0) continue;
01168
01169
01170 if (readoutType!=ReadoutType::kPinDiode) continue;
01171
01172
01173 if (numEntries<0.8*pulses) continue;
01174
01175 if (pulserBox>=FIRSTPULSERBOX && pulserBox<=LASTPULSERBOX &&
01176 led>=FIRSTLED && led<=LASTLED){
01177
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
01190
01191 if (chip==1){
01192 hAdcHighPin[l]->Fill(mean);
01193
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){
01208 hAdcLowPin[l]->Fill(mean);
01209
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
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 }
01234
01238
01239 MSG("LIAnalysis",Msg::kInfo)<<"Finished main loop"<<endl;
01240
01241
01242 gStyle->SetOptStat(1111111);
01243
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
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
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
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
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
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
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){
01423 Int_t fph=pulseHeight;
01424 chain->GetEvent(numEvents-1);
01425 Int_t lph=-10;
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
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
01470 if (sLowRunNumber==sRunNumber) s=sRunNumber+"PinAdcVsLed.ps(";
01471 else s=sLowRunNumber+"-"+sRunNumber+"PinAdcVsLed.ps(";
01472
01473 gAdcHighPin->SetMinimum(0);
01474 cAdcPinGraph->Print(s.c_str());
01475
01476
01477 cAdcPinGraph->Clear();
01478 cAdcPinGraph->cd();
01479
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
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
01498 cAdcPinGraph->Clear();
01499 cAdcPinGraph->cd();
01500
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
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
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
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
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
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
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
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
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
01617 if (sLowRunNumber==sRunNumber) s=sRunNumber+"PinRms2VsLed.ps(";
01618 else s=sLowRunNumber+"-"+sRunNumber+"PinRms2VsLed.ps(";
01619 cRms2PinGraph->Print(s.c_str());
01620
01621
01622 cRms2PinGraph->Clear();
01623 cRms2PinGraph->cd();
01624
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
01637 if (sLowRunNumber==sRunNumber) s=sRunNumber+"PinRms2VsLed.ps";
01638 else s=sLowRunNumber+"-"+sRunNumber+"PinRms2VsLed.ps";
01639 cRms2PinGraph->Print(s.c_str());
01640
01641
01642 cRms2PinGraph->Clear();
01643 cRms2PinGraph->cd();
01644
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
01657 if (sLowRunNumber==sRunNumber) s=sRunNumber+"PinRms2VsLed.ps)";
01658 else s=sLowRunNumber+"-"+sRunNumber+"PinRms2VsLed.ps)";
01659 cRms2PinGraph->Print(s.c_str());
01660
01662
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
01691 if (sLowRunNumber==sRunNumber) s=sRunNumber+"PinNumVsLed.ps(";
01692 else s=sLowRunNumber+"-"+sRunNumber+"PinNumVsLed.ps(";
01693 cNumPinGraph->Print(s.c_str());
01694
01695
01696 cNumPinGraph->Clear();
01697 cNumPinGraph->cd();
01698
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
01711 if (sLowRunNumber==sRunNumber) s=sRunNumber+"PinNumVsLed.ps";
01712 else s=sLowRunNumber+"-"+sRunNumber+"PinNumVsLed.ps";
01713 cNumPinGraph->Print(s.c_str());
01714
01715
01716 cNumPinGraph->Clear();
01717 cNumPinGraph->cd();
01718
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
01731 if (sLowRunNumber==sRunNumber) s=sRunNumber+"PinNumVsLed.ps)";
01732 else s=sLowRunNumber+"-"+sRunNumber+"PinNumVsLed.ps)";
01733 cNumPinGraph->Print(s.c_str());
01734
01735
01737
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
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
01766 if (sLowRunNumber==sRunNumber) s=sRunNumber+"PinResVsLed.ps(";
01767 else s=sLowRunNumber+"-"+sRunNumber+"PinResVsLed.ps(";
01768 cResPinGraph->Print(s.c_str());
01769
01770
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
01786 if (sLowRunNumber==sRunNumber) s=sRunNumber+"PinResVsLed.ps";
01787 else s=sLowRunNumber+"-"+sRunNumber+"PinResVsLed.ps";
01788 cResPinGraph->Print(s.c_str());
01789
01790
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
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 }
01813
01814
01815
01816 void LIAnalysis::DebugPins()
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
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
01911 if (crate==1 && geoAdd==19 && masterCh==4 &&
01912 detectorType==Detector::kCalDet){
01913 this->PrintBigMessage();
01914 }
01915
01916
01917 if (mean==0 || rms==0 || numEntries==0) continue;
01918
01919
01920 if (readoutType!=ReadoutType::kPinDiode) continue;
01921
01922
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
01944 if (numEntries<0.8*pulses) continue;
01945
01946 if (pulserBox>=FIRSTPULSERBOX && pulserBox<=LASTPULSERBOX &&
01947 led>=FIRSTLED && led<=LASTLED){
01948
01949 Int_t l=pulserBox*NUMLEDS+led-1;
01950
01951
01952
01953 if (chip==1){
01954
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){
01979
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
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 }
02014
02018
02019 MSG("LIAnalysis",Msg::kInfo)<<"Finished main loop"<<endl;
02020
02021
02022 gStyle->SetOptStat(1111111);
02023
02024 string sRunNumber=Form("%d",runNumber);
02025 string sLowRunNumber=Form("%d",lowRunNumber);
02026
02027
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
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
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
02187 MSG("LIAnalysis",Msg::kInfo)<<endl;
02188 for (Int_t j=0;j<NUMLEDS;j++){
02189
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
02236 MSG("LIAnalysis",Msg::kInfo)<<endl;
02237 for (Int_t j=0;j<NUMLEDS;j++){
02238
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
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
02301
02302
02303
02304
02305
02306
02307
02308
02309
02310
02311
02312 MSG("LIAnalysis",Msg::kInfo)
02313 <<" ** Finished the DebugPins method ** "<<endl;
02314 }
02315
02316
02317
02318 void LIAnalysis::PinMap()
02319 {
02320 MSG("LIAnalysis",Msg::kInfo)
02321 <<endl<<" ** Running the PinMap method... ** "<<endl;
02322
02323 Float_t numMux=NUMMUX;
02324 Float_t numRacks=NUMRACKS;
02325 const Int_t const_numCrates=static_cast<Int_t>(NUMRACKS/2.);
02326 const Int_t const_numRacks=static_cast<Int_t>(numRacks);
02327 const Int_t const_numMux=static_cast<Int_t>(numMux);
02328
02329 TCanvas *cEast=new TCanvas("cEast","cEast",0,0,1200,800);
02330 cEast->SetFillColor(0);
02331
02332 TCanvas *cWest=new TCanvas("cWest","cWest",0,0,1200,800);
02333 cWest->SetFillColor(0);
02334 cWest->cd();
02335
02336 TText *titleE = new TText(0.28,0.955,
02337 "Plex PIN Diode Map (East Side)");
02338 titleE->SetTextSize(0.045);
02339 TText *titleW = new TText(0.28,0.955,
02340 "Plex PIN Diode Map (West Side)");
02341 titleW->SetTextSize(0.045);
02342 cEast->cd();
02343 titleE->Draw();
02344 cWest->cd();
02345 titleW->Draw();
02346
02347 TPaveText *info=new TPaveText(0.75,0.94,1.0,1.0);
02348 info->SetBorderSize(0);
02349 info->SetFillColor(0);
02350 info->SetTextSize(0.018);
02351 info->SetTextColor(4);
02352 info->AddText("Numbers in mux boxes are LED numbers");
02353 info->AddText("Dark colour number is high gain pin");
02354 info->AddText("Mux box shading indicates Pulser Box");
02355 cEast->cd();
02356 info->Draw();
02357 cWest->cd();
02358 info->Draw();
02359
02360 TPad *levelUE= new TPad("levelUE","pad for mux boxes",
02361 0.01,0.59,0.99,0.94);
02362 TPad *levelME= new TPad("levelME","pad for crates",
02363 0.01,0.39,0.99,0.56);
02364 TPad *levelLE= new TPad("levelLE","pad for mux boxes",
02365 0.01,0.01,0.99,0.36);
02366 TPad *levelUW= new TPad("levelUW","pad for mux boxes",
02367 0.01,0.59,0.99,0.94);
02368 TPad *levelMW= new TPad("levelMW","pad for crates",
02369 0.01,0.39,0.99,0.56);
02370 TPad *levelLW= new TPad("levelLW","pad for mux boxes",
02371 0.01,0.01,0.99,0.36);
02372
02373 levelUE->SetFillColor(11);
02374 levelUE->SetBorderSize(3);
02375 levelUW->SetFillColor(11);
02376 levelUW->SetBorderSize(3);
02377
02378 levelME->SetFillColor(11);
02379 levelME->SetBorderSize(2);
02380 levelMW->SetFillColor(11);
02381 levelMW->SetBorderSize(2);
02382
02383 levelLE->SetFillColor(11);
02384 levelLE->SetBorderSize(1);
02385 levelLE->SetBorderMode(0);
02386 levelLW->SetFillColor(11);
02387 levelLW->SetBorderSize(1);
02388 levelLW->SetBorderMode(0);
02389
02390 cEast->cd();
02391 levelUE->Draw();
02392 levelME->Draw();
02393 levelLE->Draw();
02394 cWest->cd();
02395 levelUW->Draw();
02396 levelMW->Draw();
02397 levelLW->Draw();
02398
02399 TText *tLevelUE = new TText(0.01,0.89,
02400 "Mux Box Racks (East Side, Upper Level)");
02401 TText *tLevelUW = new TText(0.01,0.89,
02402 "Mux Box Racks (West Side, Upper Level)");
02403 TText *tLevelME = new TText
02404 (0.01,0.89,"Electronics Crates (East Side, Middle Level)");
02405 TText *tLevelMW = new TText
02406 (0.01,0.89,"Electronics Crates (West Side, Middle Level)");
02407 TText *tLevelLE = new TText(0.01,0.89,
02408 "Mux Box Racks (East Side, Lower Level)");
02409 TText *tLevelLW = new TText(0.01,0.89,
02410 "Mux Box Racks (West Side, Lower Level)");
02411
02412 tLevelUE->SetTextSize(0.1);
02413 tLevelUW->SetTextSize(0.1);
02414 tLevelME->SetTextSize(0.08);
02415 tLevelMW->SetTextSize(0.08);
02416 tLevelLE->SetTextSize(0.1);
02417 tLevelLW->SetTextSize(0.1);
02418
02419 levelUE->cd();
02420 tLevelUE->Draw();
02421 levelUW->cd();
02422 tLevelUW->Draw();
02423
02424 levelME->cd();
02425 tLevelME->Draw();
02426 levelMW->cd();
02427 tLevelMW->Draw();
02428
02429 levelLE->cd();
02430 tLevelLE->Draw();
02431 levelLW->cd();
02432 tLevelLW->Draw();
02433
02434 Float_t rackSpace=0.07/(numRacks+1.);
02435 Float_t crateSpace=3.0*rackSpace;
02436 Float_t rackWidth=(1.-((numRacks/2)+2)*rackSpace-
02437 ((numRacks/2)-1)*crateSpace)/numRacks;
02438 Float_t xMin=-1.;
02439 MSG("LIAnalysis",Msg::kDebug)
02440 <<"rackSpace="<<rackSpace<<", crateSpace="<<crateSpace
02441 <<", rackWidth="<<rackWidth<<endl;
02442
02443 TPad **rackUE=0;
02444 TPad **rackUW=0;
02445 TPad **rackLE=0;
02446 TPad **rackLW=0;
02447
02448 rackUE=new TPad*[const_numRacks];
02449 rackUW=new TPad*[const_numRacks];
02450 rackLE=new TPad*[const_numRacks];
02451 rackLW=new TPad*[const_numRacks];
02452
02453 for (Int_t rack=0;rack<const_numRacks;rack++){
02454 Float_t crate=floor(static_cast<Float_t>(rack)/2.);
02455
02456 xMin=rackSpace
02457 +floor((static_cast<Float_t>(rack)+1)/2)*rackSpace
02458 +crate*crateSpace
02459 +static_cast<Float_t>(rack)*rackWidth;
02460
02461 rackUE[rack]= new TPad("rackUE","Upper East Racks",
02462 xMin,0.,xMin+rackWidth,0.87,17,3);
02463 rackUW[rack]= new TPad("rackUW","Upper West Racks",
02464 xMin,0.,xMin+rackWidth,0.87,17,3);
02465 rackLE[rack]= new TPad("rackLE","Lower East Racks",
02466 xMin,0.,xMin+rackWidth,0.87,17,3);
02467 rackLW[rack]= new TPad("rackLW","Lower West Racks",
02468 xMin,0.,xMin+rackWidth,0.87,17,3);
02469
02470
02471 rackUE[rack]->SetFillColor(5);
02472 rackUW[rack]->SetFillColor(5);
02473 rackLE[rack]->SetFillColor(5);
02474 rackLW[rack]->SetFillColor(5);
02475
02476 rackUE[rack]->SetBorderSize(0);
02477 rackUW[rack]->SetBorderSize(0);
02478 rackLE[rack]->SetBorderSize(0);
02479 rackLW[rack]->SetBorderSize(0);
02480
02481 rackUE[rack]->SetBorderMode(0);
02482 rackUW[rack]->SetBorderMode(0);
02483 rackLE[rack]->SetBorderMode(0);
02484 rackLW[rack]->SetBorderMode(0);
02485
02486 levelUE->cd();
02487 rackUE[rack]->Draw();
02488 levelUW->cd();
02489 rackUW[rack]->Draw();
02490 levelLE->cd();
02491 rackLE[rack]->Draw();
02492 levelLW->cd();
02493 rackLW[rack]->Draw();
02494 }
02495
02496
02497 TPaveText **muxBoxBg=0;
02498 muxBoxBg=new TPaveText*[const_numRacks];
02499
02500 for (Int_t rack=0;rack<const_numRacks;rack++){
02501
02502 muxBoxBg[rack]=new TPaveText(0.06,0.01,0.94,0.97);
02503 muxBoxBg[rack]->SetBorderSize(0);
02504 muxBoxBg[rack]->SetFillColor(0);
02505
02506 rackUE[rack]->cd();
02507 muxBoxBg[rack]->Draw();
02508 rackUW[rack]->cd();
02509 muxBoxBg[rack]->Draw();
02510 rackLE[rack]->cd();
02511 muxBoxBg[rack]->Draw();
02512 rackLW[rack]->cd();
02513 muxBoxBg[rack]->Draw();
02514 }
02515
02516
02517 TPaveText ***muxTextUE=0;
02518 muxTextUE=new TPaveText**[const_numRacks];
02519 TPaveText ***muxTextUW=0;
02520 muxTextUW=new TPaveText**[const_numRacks];
02521 TPaveText ***muxTextLE=0;
02522 muxTextLE=new TPaveText**[const_numRacks];
02523 TPaveText ***muxTextLW=0;
02524 muxTextLW=new TPaveText**[const_numRacks];
02525 for (Int_t rack=0;rack<const_numRacks;rack++){
02526 muxTextUE[rack]=new TPaveText*[2*const_numMux];
02527 muxTextUW[rack]=new TPaveText*[2*const_numMux];
02528 muxTextLE[rack]=new TPaveText*[2*const_numMux];
02529 muxTextLW[rack]=new TPaveText*[2*const_numMux];
02530 for (Int_t pin=0;pin<2*const_numMux;pin++){
02531 (muxTextUE[rack])[pin]=new TPaveText
02532 (0.09,
02533 0.015+static_cast<Int_t>(pin)*0.06,
02534 0.93,
02535 0.015+static_cast<Int_t>(pin+1)*0.06-0.010*(pin%2));
02536 (muxTextUW[rack])[pin]=new TPaveText
02537 (0.09,
02538 0.015+static_cast<Int_t>(pin)*0.06,
02539 0.93,
02540 0.015+static_cast<Int_t>(pin+1)*0.06-0.010*(pin%2));
02541 (muxTextLE[rack])[pin]=new TPaveText
02542 (0.09,
02543 0.015+static_cast<Int_t>(pin)*0.06,
02544 0.93,
02545 0.015+static_cast<Int_t>(pin+1)*0.06-0.010*(pin%2));
02546 (muxTextLW[rack])[pin]=new TPaveText
02547 (0.09,
02548 0.015+static_cast<Int_t>(pin)*0.06,
02549 0.93,
02550 0.015+static_cast<Int_t>(pin+1)*0.06-0.010*(pin%2));
02551 (muxTextUE[rack])[pin]->SetBorderSize(0);
02552 (muxTextUW[rack])[pin]->SetBorderSize(0);
02553 (muxTextLE[rack])[pin]->SetBorderSize(0);
02554 (muxTextLW[rack])[pin]->SetBorderSize(0);
02555
02556 (muxTextUE[rack])[pin]->SetTextSize(0.2);
02557 (muxTextUW[rack])[pin]->SetTextSize(0.2);
02558 (muxTextLE[rack])[pin]->SetTextSize(0.2);
02559 (muxTextLW[rack])[pin]->SetTextSize(0.2);
02560
02561 (muxTextUE[rack])[pin]->SetTextColor(5);
02562 (muxTextUW[rack])[pin]->SetTextColor(5);
02563 (muxTextLE[rack])[pin]->SetTextColor(5);
02564 (muxTextLW[rack])[pin]->SetTextColor(5);
02565
02566 (muxTextUE[rack])[pin]->SetTextFont(2);
02567 (muxTextUW[rack])[pin]->SetTextFont(2);
02568 (muxTextLE[rack])[pin]->SetTextFont(2);
02569 (muxTextLW[rack])[pin]->SetTextFont(2);
02570
02571 (muxTextUE[rack])[pin]->SetFillColor(20);
02572 (muxTextUW[rack])[pin]->SetFillColor(20);
02573 (muxTextLE[rack])[pin]->SetFillColor(20);
02574 (muxTextLW[rack])[pin]->SetFillColor(20);
02575 }
02576 }
02577
02578
02579 MSG("LIAnalysis",Msg::kInfo)<<"Drawing crates..."<<endl;
02580 TPad **cratesE=0;
02581 cratesE=new TPad*[const_numCrates];
02582 TPad **cratesW=0;
02583 cratesW=new TPad*[const_numCrates];
02584
02585 TPaveText **crateLabelE=0;
02586 crateLabelE=new TPaveText*[const_numCrates];
02587 TPaveText **crateLabelW=0;
02588 crateLabelW=new TPaveText*[const_numCrates];
02589
02590
02591 crateSpace=(1
02592 -(numRacks/2)*rackWidth
02593 -2*(1.5*rackSpace+(rackWidth/2))
02594 )/((numRacks/2)-1);
02595
02596
02597 for (Int_t cra=0;cra<static_cast<Int_t>(numRacks/2);cra++){
02598
02599 xMin=1.5*rackSpace+(rackWidth/2)
02600 +static_cast<Float_t>(cra)*crateSpace
02601 +static_cast<Float_t>(cra)*rackWidth;
02602
02603 cratesE[cra]=new TPad("crates","Crates",
02604 xMin,0.,xMin+rackWidth,0.85,17,3);
02605 cratesE[cra]->SetFillColor(5);
02606 cratesE[cra]->SetBorderSize(0);
02607 cratesE[cra]->SetBorderMode(0);
02608 levelME->cd();
02609 cratesE[cra]->Draw();
02610
02611 cratesW[cra]=new TPad("crates","Crates",
02612 xMin,0.,xMin+rackWidth,0.85,17,3);
02613 cratesW[cra]->SetFillColor(5);
02614 cratesW[cra]->SetBorderSize(0);
02615 cratesW[cra]->SetBorderMode(0);
02616 levelMW->cd();
02617 cratesW[cra]->Draw();
02618
02619 crateLabelE[cra]=new TPaveText(0.1,0.01,0.9,0.95);
02620 crateLabelE[cra]->SetBorderSize(0);
02621 crateLabelW[cra]=new TPaveText(0.1,0.01,0.9,0.95);
02622 crateLabelW[cra]->SetBorderSize(0);
02623
02624 string s=Form("%d",2*cra);
02625 crateLabelE[cra]->AddText(0.5,0.95,"Pulser");
02626 crateLabelE[cra]->AddText(0.5,0.8,"Box");
02627 crateLabelE[cra]->AddText(0.5,0.65,s.c_str());
02628 crateLabelE[cra]->SetTextSize(0.25);
02629
02630 crateLabelE[cra]->SetFillColor(19-cra);
02631
02632 cratesE[cra]->cd();
02633 crateLabelE[cra]->Draw();
02634
02635 string sW=Form("%d",15-(2*cra));
02636 crateLabelW[cra]->AddText(0.5,0.95,"Pulser");
02637 crateLabelW[cra]->AddText(0.5,0.8,"Box");
02638 crateLabelW[cra]->AddText(0.5,0.65,sW.c_str());
02639 crateLabelW[cra]->SetTextSize(0.25);
02640
02641 crateLabelW[cra]->SetFillColor(12+cra);
02642
02643 cratesW[cra]->cd();
02644 crateLabelW[cra]->Draw();
02645 }
02646 MSG("LIAnalysis",Msg::kInfo)<<"... OK"<<endl;
02647
02648
02649
02650
02651
02652
02653
02654
02655
02656
02657
02661
02662 MSG("LIAnalysis",Msg::kInfo)
02663 <<"Looping through tree and drawing mux box labels..."<<endl;
02664
02665 this->InitialiseLoopVariables();
02666
02667 for(Int_t entry=0;entry<numEvents;entry++){
02668
02669 this->SetLoopVariables(entry,0);
02670
02671
02672 if (rms==0. || mean==0. || numEntries==0) continue;
02673
02674 if (readoutType!=ReadoutType::kPinDiode) continue;
02675
02676 if (pulserBox!=1) continue;
02677
02678
02679 if (rackLevel==0){
02680 if (eastWest==0){
02681 rackLE[rackBay]->cd();
02682 MSG("LIAnalysis",Msg::kVerbose)<<"Lower East:"<<endl;
02683 }
02684 else if (eastWest==1){
02685 rackLW[const_numRacks-1-rackBay]->cd();
02686 MSG("LIAnalysis",Msg::kVerbose)<<"Lower West:"<<endl;
02687 }
02688 }
02689 else if (rackLevel==1){
02690 if (eastWest==0){
02691 rackUE[rackBay]->cd();
02692 MSG("LIAnalysis",Msg::kVerbose)<<"Upper East:"<<endl;
02693 }
02694 else if (eastWest==1){
02695 rackUW[const_numRacks-1-rackBay]->cd();
02696 MSG("LIAnalysis",Msg::kVerbose)<<"Upper West:"<<endl;
02697 }
02698 }
02699
02700
02701
02702
02703
02704 Int_t pin=-1;
02705
02706
02707 if (eastWest==0){
02708
02709 if (pinInBox==0){
02710 pin=2*inRack+1;
02711 }
02712 else if (pinInBox==1){
02713 pin=2*inRack+0;
02714 }
02715 }
02716
02717
02718 else if (eastWest==1){
02719 pin=2*inRack+pinInBox;
02720 }
02721
02722 MSG("LIAnalysis",Msg::kInfo)
02723 <<"E/W="<<eastWest
02724 <<", U/L="<<rackLevel
02725 <<", rack="<<rackBay
02726 <<", mux="<<inRack
02727 <<", pinInBox="<<pinInBox
02728 <<", gain="<<pinGain
02729 <<", pb="<<pulserBox
02730 <<endl;
02731
02732 }
02733
02737
02738 MSG("LIAnalysis",Msg::kInfo)<<"Finished main loop"<<endl;
02739
02740 MSG("LIAnalysis",Msg::kInfo)
02741 <<" ** Finished the PinMap method ** "<<endl;
02742 }
02743
02744
02745
02746 void LIAnalysis::StripVsPlane(Int_t nearPb,Int_t farPb,Int_t ledCut)
02747 {
02748 MSG("LIAnalysis",Msg::kInfo)
02749 <<endl<<" ** Running the StripVsPlane method... ** "<<endl;
02750
02751 chain->GetEvent(0);
02752
02753 if (calibType>1){
02754 MSG("LIAnalysis",Msg::kWarning)
02755 <<endl<<"Gain curve file detected with "<<calibType<<" points"
02756 <<endl<<"Only the last gain curve point will be used"<<endl;
02757 }
02758
02759 Int_t* planeMax=new Int_t[NUMCRATES];
02760 Int_t* planeMin=new Int_t[NUMCRATES];
02761 lookup.SetPbPlanes(planeMin,planeMax,detectorType);
02762
02763 const Int_t firstStripBin=FIRSTSTRIP-8;
02764 const Int_t lastStripBin=LASTSTRIP+9;
02765 const Int_t bins=lastStripBin-firstStripBin;
02766
02767 chain->GetEvent(0);
02768 string sPulseWidth=Form("%d",pulseWidth);
02769 string sPulseHeight=Form("%d",pulseHeight);
02770 string sPulseFreq=Form("%d",static_cast<Int_t>
02771 (ceil(1.0/(period*1.0e-5))));
02772 string sPulses=Form("%d",pulses);
02773 string sConstantBit="";
02774
02775 if (detectorType==Detector::kFar){
02776 MSG("LIAnalysis",Msg::kInfo)
02777 <<"Setting histo titles according to detector type kFar"<<endl;
02778
02779 if (runNumber>=13123){
02780 Int_t fph=pulseHeight;
02781
02782
02783 Int_t lph=-10;
02784
02785 MSG("LIAnalysis",Msg::kInfo)
02786 <<"first ph="<<fph<<", last ph="<<lph<<endl;
02787
02788 if (lph==fph){
02789 sConstantBit=+", PH="+sPulseHeight+", PW="+sPulseWidth+
02790 ", PF="+sPulseFreq+" Hz, PN="+sPulses+")";
02791 }
02792 else if (lph!=fph){
02793 sConstantBit=+", PW="+sPulseWidth+
02794 ", PF="+sPulseFreq+" Hz, PN="+sPulses+")";
02795 }
02796 }
02797 else{
02798 sConstantBit=+", PH="+sPulseHeight+", PW="+sPulseWidth+
02799 ", PF="+sPulseFreq+" Hz, PN="+sPulses+")";
02800 }
02801 }
02802 else if (detectorType==Detector::kCalDet){
02803 MSG("LIAnalysis",Msg::kInfo)
02804 <<"Setting histo titles according to detector type kCalDet"<<endl;
02805
02806 Int_t fph=pulseHeight;
02807
02808 Int_t lph=-10;
02809
02810 MSG("LIAnalysis",Msg::kInfo)
02811 <<"first ph="<<fph<<", last ph="<<lph<<endl;
02812
02813 if (lph==fph){
02814 sConstantBit=+", PH="+sPulseHeight+", PW="+sPulseWidth+
02815 ", PF="+sPulseFreq+" Hz, PN="+sPulses+")";
02816 }
02817 else if (lph!=fph){
02818 sConstantBit=+", PW="+sPulseWidth+
02819 ", PF="+sPulseFreq+" Hz, PN="+sPulses+")";
02820 }
02821 }
02822
02823 MSG("LIAnalysis",Msg::kInfo)
02824 <<"sConstantBit="<<sConstantBit<<endl;
02825
02826 TH2F *hStripVsPlaneLedB=new TH2F(" "," ",
02827 LASTSCINTPLANE-FIRSTSCINTPLANE+2,
02828 FIRSTSCINTPLANE,LASTSCINTPLANE+1,
02829 bins,firstStripBin,lastStripBin);
02830
02831 TH2F **hStripVsPlaneLed=0;
02832 hStripVsPlaneLed= new TH2F*[NUMCRATES];
02833 for (Int_t i=0;i<NUMCRATES;i++){
02834 string sPulserBox=Form("%d",i);
02835 s="LED (PB="+sPulserBox+sConstantBit;
02836 if (detectorType==Detector::kCalDet){
02837 s="LED (Crate="+sPulserBox+sConstantBit;
02838 }
02839 hStripVsPlaneLed[i]=new TH2F(s.c_str(),s.c_str(),
02840 planeMax[i]-planeMin[i],
02841 planeMin[i],planeMax[i]
02842 ,bins,firstStripBin,lastStripBin);
02843 hStripVsPlaneLed[i]->GetXaxis()->SetTitle("Plane");
02844 hStripVsPlaneLed[i]->GetXaxis()->CenterTitle();
02845 hStripVsPlaneLed[i]->GetYaxis()->SetTitle("Num Entries");
02846 hStripVsPlaneLed[i]->GetYaxis()->CenterTitle();
02847 hStripVsPlaneLed[i]->SetFillColor(0);
02848
02849 }
02850
02851 TH2F **hStripVsPlaneMean=0;
02852 hStripVsPlaneMean= new TH2F*[NUMCRATES];
02853 for (Int_t i=0;i<NUMCRATES;i++){
02854 string sPulserBox=Form("%d",i);
02855 s="ADC (Near End, PB="+sPulserBox+sConstantBit;
02856 if (detectorType==Detector::kCalDet){
02857 s="ADC (Near End of Strip, Crate="+sPulserBox+sConstantBit;
02858 }
02859 hStripVsPlaneMean[i]=new TH2F(s.c_str(),s.c_str(),
02860 planeMax[i]-planeMin[i],planeMin[i],planeMax[i]
02861 ,bins,firstStripBin,lastStripBin);
02862 hStripVsPlaneMean[i]->GetXaxis()->SetTitle("Plane");
02863 hStripVsPlaneMean[i]->GetXaxis()->CenterTitle();
02864 hStripVsPlaneMean[i]->GetYaxis()->SetTitle("Strip");
02865 hStripVsPlaneMean[i]->GetYaxis()->CenterTitle();
02866 hStripVsPlaneMean[i]->SetFillColor(0);
02867 hStripVsPlaneMean[i]->SetMaximum(14000);
02868
02869 }
02870
02871 TH2F **hStripVsPlaneMeanF=0;
02872 hStripVsPlaneMeanF= new TH2F*[NUMCRATES];
02873 for (Int_t i=0;i<NUMCRATES;i++){
02874 string sPulserBox=Form("%d",i);
02875 s="ADC (Far End, PB="+sPulserBox+sConstantBit;
02876 if (detectorType==Detector::kCalDet){
02877 s="ADC (Far End of Strip, Crate="+sPulserBox+sConstantBit;
02878 }
02879 hStripVsPlaneMeanF[i]=new TH2F(s.c_str(),s.c_str(),
02880 planeMax[i]-planeMin[i],planeMin[i],planeMax[i]
02881 ,bins,firstStripBin,lastStripBin);
02882 hStripVsPlaneMeanF[i]->GetXaxis()->SetTitle("Plane");
02883 hStripVsPlaneMeanF[i]->GetXaxis()->CenterTitle();
02884 hStripVsPlaneMeanF[i]->GetYaxis()->SetTitle("Strip");
02885 hStripVsPlaneMeanF[i]->GetYaxis()->CenterTitle();
02886 hStripVsPlaneMeanF[i]->SetFillColor(0);
02887 hStripVsPlaneMeanF[i]->SetMaximum(14000);
02888
02889 }
02890
02891 TH2F **hStripVsPlaneRms=0;
02892 hStripVsPlaneRms= new TH2F*[NUMCRATES];
02893 for (Int_t i=0;i<NUMCRATES;i++){
02894 string sPulserBox=Form("%d",i);
02895 s="RMS (Near End, PB="+sPulserBox+sConstantBit;
02896 if (detectorType==Detector::kCalDet){
02897 s="RMS (Near End of Strip, Crate="+sPulserBox+sConstantBit;
02898 }
02899 hStripVsPlaneRms[i]=new TH2F(s.c_str(),s.c_str(),
02900 planeMax[i]-planeMin[i],planeMin[i],planeMax[i]
02901 ,bins,firstStripBin,lastStripBin);
02902 hStripVsPlaneRms[i]->GetXaxis()->SetTitle("Plane");
02903 hStripVsPlaneRms[i]->GetXaxis()->CenterTitle();
02904 hStripVsPlaneRms[i]->GetYaxis()->SetTitle("Strip");
02905 hStripVsPlaneRms[i]->GetYaxis()->CenterTitle();
02906 hStripVsPlaneRms[i]->SetFillColor(0);
02907
02908 }
02909
02910 TH2F **hStripVsPlaneRmsF=0;
02911 hStripVsPlaneRmsF= new TH2F*[NUMCRATES];
02912 for (Int_t i=0;i<NUMCRATES;i++){
02913 string sPulserBox=Form("%d",i);
02914 s="RMS (Far End, PB="+sPulserBox+sConstantBit;
02915 if (detectorType==Detector::kCalDet){
02916 s="RMS (Far End of Strip, Crate="+sPulserBox+sConstantBit;
02917 }
02918 hStripVsPlaneRmsF[i]=new TH2F(s.c_str(),s.c_str(),
02919 planeMax[i]-planeMin[i],planeMin[i],planeMax[i]
02920 ,bins,firstStripBin,lastStripBin);
02921 hStripVsPlaneRmsF[i]->GetXaxis()->SetTitle("Plane");
02922 hStripVsPlaneRmsF[i]->GetXaxis()->CenterTitle();
02923 hStripVsPlaneRmsF[i]->GetYaxis()->SetTitle("Strip");
02924 hStripVsPlaneRmsF[i]->GetYaxis()->CenterTitle();
02925 hStripVsPlaneRmsF[i]->SetFillColor(0);
02926
02927 }
02928
02929 TH2F **hStripVsPlaneNpe=0;
02930 hStripVsPlaneNpe= new TH2F*[NUMCRATES];
02931 for (Int_t i=0;i<NUMCRATES;i++){
02932 string sPulserBox=Form("%d",i);
02933 s="NPE, PB="+sPulserBox+sConstantBit;
02934 if (detectorType==Detector::kCalDet){
02935 s="NPE, Crate="+sPulserBox+sConstantBit;
02936 }
02937 hStripVsPlaneNpe[i]=new TH2F(s.c_str(),s.c_str(),
02938 planeMax[i]-planeMin[i],planeMin[i],planeMax[i]
02939 ,bins,firstStripBin,lastStripBin);
02940 hStripVsPlaneNpe[i]->GetXaxis()->SetTitle("Plane");
02941 hStripVsPlaneNpe[i]->GetXaxis()->CenterTitle();
02942 hStripVsPlaneNpe[i]->GetYaxis()->SetTitle("Strip");
02943 hStripVsPlaneNpe[i]->GetYaxis()->CenterTitle();
02944 hStripVsPlaneNpe[i]->SetFillColor(0);
02945
02946 }
02947
02948 const Float_t adcUpperCut=8000;
02949 const Float_t adcLowerCut=800;
02950 const Float_t pulsesCut=20;
02951 string sAdcUpper=Form("%d",static_cast<Int_t>(adcUpperCut));
02952 string sAdcLower=Form("%d",static_cast<Int_t>(adcLowerCut));
02953 string sPulsesCut=Form("%d",static_cast<Int_t>(pulsesCut));
02954
02955 s="Gain Differences (Near-Far, Cut: ADC<"+sAdcUpper+" & >"+
02956 sAdcLower+" & NP>"+sPulsesCut+"%)";
02957 TH1F *hGainDiff=new TH1F("hGainDiff",s.c_str(),100,-50,50);
02958 hGainDiff->GetXaxis()->SetTitle("Gain Difference");
02959 hGainDiff->GetXaxis()->CenterTitle();
02960 hGainDiff->GetYaxis()->SetTitle("Number of entries");
02961 hGainDiff->GetYaxis()->CenterTitle();
02962 hGainDiff->SetFillColor(0);
02963
02964 s="ADC (Near&Far where both sides have ADC<"+sAdcUpper+" & >"+
02965 sAdcLower+" & NP>"+sPulsesCut+"%)";
02966 TH1F *hMeanDiffNear=new TH1F("hMeanDiffNear",s.c_str(),100,0,15000);
02967 hMeanDiffNear->GetXaxis()->SetTitle("ADC");
02968 hMeanDiffNear->GetXaxis()->CenterTitle();
02969 hMeanDiffNear->GetYaxis()->SetTitle("Number of entries");
02970 hMeanDiffNear->GetYaxis()->CenterTitle();
02971 hMeanDiffNear->SetLineColor(2);
02972 hMeanDiffNear->SetFillColor(0);
02973
02974 s="ADC (Near&Far where both sides have ADC<"+sAdcUpper+" & >"+
02975 sAdcLower+" & NP>"+sPulsesCut+"%)";
02976 TH1F *hMeanDiffFar=new TH1F("hMeanDiffFar",s.c_str(),100,0,15000);
02977 hMeanDiffFar->GetXaxis()->SetTitle("ADC");
02978 hMeanDiffFar->GetXaxis()->CenterTitle();
02979 hMeanDiffFar->GetYaxis()->SetTitle("Number of entries");
02980 hMeanDiffFar->GetYaxis()->CenterTitle();
02981 hMeanDiffFar->SetLineColor(3);
02982 hMeanDiffFar->SetFillColor(0);
02983
02984 TH2F **hStripVsPlaneGain=0;
02985 hStripVsPlaneGain= new TH2F*[NUMCRATES];
02986 for (Int_t i=0;i<NUMCRATES;i++){
02987 string sPb=Form("%d",i);
02988 s="Gain (Crate "+sPb+", Cut: ADC<"+sAdcUpper+" & >"+
02989 sAdcLower+" & NP>"+sPulsesCut+"%)";
02990 hStripVsPlaneGain[i]=new TH2F
02991 (s.c_str(),s.c_str(),
02992 planeMax[i]-planeMin[i],planeMin[i],planeMax[i],
02993 bins,firstStripBin,lastStripBin);
02994 hStripVsPlaneGain[i]->GetXaxis()->SetTitle("Plane");
02995 hStripVsPlaneGain[i]->GetXaxis()->CenterTitle();
02996 hStripVsPlaneGain[i]->GetYaxis()->SetTitle("Strip");
02997 hStripVsPlaneGain[i]->GetYaxis()->CenterTitle();
02998 hStripVsPlaneGain[i]->SetFillColor(0);
02999
03000 }
03001
03002 TH2F **hStripVsPlaneGainN=0;
03003 hStripVsPlaneGainN= new TH2F*[NUMCRATES];
03004 for (Int_t i=0;i<NUMCRATES;i++){
03005 string sPulserBox=Form("%d",i);
03006 s="Gain (Near End, PB="+sPulserBox+sConstantBit;
03007 if (detectorType==Detector::kCalDet){
03008 s="Gain (Near End of Strip, Crate="+sPulserBox+sConstantBit;
03009 }
03010 hStripVsPlaneGainN[i]=new TH2F
03011 (s.c_str(),s.c_str(),
03012 planeMax[i]-planeMin[i],planeMin[i],planeMax[i],
03013 bins,firstStripBin,lastStripBin);
03014 hStripVsPlaneGainN[i]->GetXaxis()->SetTitle("Plane");
03015 hStripVsPlaneGainN[i]->GetXaxis()->CenterTitle();
03016 hStripVsPlaneGainN[i]->GetYaxis()->SetTitle("Strip");
03017 hStripVsPlaneGainN[i]->GetYaxis()->CenterTitle();
03018 hStripVsPlaneGainN[i]->SetFillColor(0);
03019
03020 }
03021
03022 TH2F **hStripVsPlaneGainAll=0;
03023 hStripVsPlaneGainAll= new TH2F*[NUMSIDES];
03024 for (Int_t i=0;i<NUMSIDES;i++){
03025 if (i==0) s="Gain (East Side"+sConstantBit;
03026 else if (i==1) s="Gain (West Side"+sConstantBit;
03027 else {
03028 s="What?";
03029 }
03030
03031 MSG("LIAnalysis",Msg::kDebug)
03032 <<"NUMSIDES="<<NUMSIDES<<", s="<<s<<endl;
03033 hStripVsPlaneGainAll[i]=new TH2F
03034 (s.c_str(),s.c_str(),FIRSTPLANE,LASTPLANE,NUMPLANES,
03035 bins,firstStripBin,lastStripBin);
03036 MSG("LIAnalysis",Msg::kDebug)
03037 <<"NUMSIDES="<<NUMSIDES<<", s="<<s<<endl;
03038 hStripVsPlaneGainAll[i]->GetXaxis()->SetTitle("Plane");
03039 hStripVsPlaneGainAll[i]->GetXaxis()->CenterTitle();
03040 hStripVsPlaneGainAll[i]->GetYaxis()->SetTitle("Strip");
03041 hStripVsPlaneGainAll[i]->GetYaxis()->CenterTitle();
03042 hStripVsPlaneGainAll[i]->SetFillColor(0);
03043 MSG("LIAnalysis",Msg::kDebug)
03044 <<"NUMSIDES="<<NUMSIDES<<", s="<<s<<endl;
03045
03046 }
03047
03048 hStripVsPlaneGainAll[1]->SetBit(TH1::kCanRebin);
03049 hStripVsPlaneGainAll[1]->Fill(100,600,1000);
03050
03051 TH2F **hStripVsPlaneGainF=0;
03052 hStripVsPlaneGainF= new TH2F*[NUMCRATES];
03053 for (Int_t i=0;i<NUMCRATES;i++){
03054 string sPulserBox=Form("%d",i);
03055 s="Gain (Far End, PB="+sPulserBox+sConstantBit;
03056 if (detectorType==Detector::kCalDet){
03057 s="Gain (Far End of Strip, Crate="+sPulserBox+sConstantBit;
03058 }
03059 hStripVsPlaneGainF[i]=new TH2F
03060 (s.c_str(),s.c_str(),
03061 planeMax[i]-planeMin[i],planeMin[i],planeMax[i]
03062 ,bins,firstStripBin,lastStripBin);
03063 hStripVsPlaneGainF[i]->GetXaxis()->SetTitle("Plane");
03064 hStripVsPlaneGainF[i]->GetXaxis()->CenterTitle();
03065 hStripVsPlaneGainF[i]->GetYaxis()->SetTitle("Strip");
03066 hStripVsPlaneGainF[i]->GetYaxis()->CenterTitle();
03067 hStripVsPlaneGainF[i]->SetFillColor(0);
03068 }
03069
03070 TH2F **hStripVsPlaneGainDiff=0;
03071 hStripVsPlaneGainDiff= new TH2F*[NUMCRATES];
03072 for (Int_t i=0;i<NUMCRATES;i++){
03073 string sPb=Form("%d",i);
03074 s="Gain Difference: Near-Far (Crate "+sPb+", Cut: ADC<"+
03075 sAdcUpper+" & >"+sAdcLower+" & NP>"+sPulsesCut+"%)";
03076 hStripVsPlaneGainDiff[i]=new TH2F
03077 (s.c_str(),s.c_str(),
03078 planeMax[i]-planeMin[i],planeMin[i],planeMax[i],
03079 bins,firstStripBin,lastStripBin);
03080 hStripVsPlaneGainDiff[i]->GetXaxis()->SetTitle("Plane");
03081 hStripVsPlaneGainDiff[i]->GetXaxis()->CenterTitle();
03082 hStripVsPlaneGainDiff[i]->GetYaxis()->SetTitle("Strip");
03083 hStripVsPlaneGainDiff[i]->GetYaxis()->CenterTitle();
03084 hStripVsPlaneGainDiff[i]->SetFillColor(0);
03085
03086 }
03087
03088 TH2F **hStripVsPlaneNum=0;
03089 hStripVsPlaneNum= new TH2F*[NUMCRATES];
03090 for (Int_t i=0;i<NUMCRATES;i++){
03091 string sPulserBox=Form("%d",i);
03092 s="Num Entries (Near End, PB="+sPulserBox+sConstantBit;
03093 if (detectorType==Detector::kCalDet){
03094 s="Num Entries (Near End of Strip, Crate="+
03095 sPulserBox+sConstantBit;
03096 }
03097 hStripVsPlaneNum[i]=new TH2F
03098 (s.c_str(),s.c_str(),
03099 planeMax[i]-planeMin[i],planeMin[i],planeMax[i]
03100 ,bins,firstStripBin,lastStripBin);
03101 hStripVsPlaneNum[i]->GetXaxis()->SetTitle("Plane");
03102 hStripVsPlaneNum[i]->GetXaxis()->CenterTitle();
03103 hStripVsPlaneNum[i]->GetYaxis()->SetTitle("Strip");
03104 hStripVsPlaneNum[i]->GetYaxis()->CenterTitle();
03105 hStripVsPlaneNum[i]->SetFillColor(0);
03106
03107 }
03108
03109 TH2F **hStripVsPlaneNumF=0;
03110 hStripVsPlaneNumF= new TH2F*[NUMCRATES];
03111 for (Int_t i=0;i<NUMCRATES;i++){
03112 string sPulserBox=Form("%d",i);
03113 s="Num Entries (Far End, PB="+sPulserBox+sConstantBit;
03114 if (detectorType==Detector::kCalDet){
03115 s="Num Entries (Far End of Strip, Crate="+sPulserBox+
03116 sConstantBit;
03117 }
03118 hStripVsPlaneNumF[i]=new TH2F
03119 (s.c_str(),s.c_str(),
03120 planeMax[i]-planeMin[i],planeMin[i],planeMax[i]
03121 ,bins,firstStripBin,lastStripBin);
03122 hStripVsPlaneNumF[i]->GetXaxis()->SetTitle("Plane");
03123 hStripVsPlaneNumF[i]->GetXaxis()->CenterTitle();
03124 hStripVsPlaneNumF[i]->GetYaxis()->SetTitle("Strip");
03125 hStripVsPlaneNumF[i]->GetYaxis()->CenterTitle();
03126 hStripVsPlaneNumF[i]->SetFillColor(0);
03127
03128 }
03129
03130 TH2F **hStripVsPlanePix=0;
03131 hStripVsPlanePix= new TH2F*[NUMCRATES];
03132 for (Int_t i=0;i<NUMCRATES;i++){
03133 string sPulserBox=Form("%d",i);
03134 s="Pixel (Near End, PB="+sPulserBox+sConstantBit;
03135 if (detectorType==Detector::kCalDet){
03136 s="Pixel (Near End of Strip, Crate="+sPulserBox+sConstantBit;
03137 }
03138 hStripVsPlanePix[i]=new TH2F
03139 (s.c_str(),s.c_str(),
03140 planeMax[i]-planeMin[i],planeMin[i],planeMax[i]
03141 ,bins,firstStripBin,lastStripBin);
03142 hStripVsPlanePix[i]->GetXaxis()->SetTitle("Plane");
03143 hStripVsPlanePix[i]->GetXaxis()->CenterTitle();
03144 hStripVsPlanePix[i]->GetYaxis()->SetTitle("Strip");
03145 hStripVsPlanePix[i]->GetYaxis()->CenterTitle();
03146 hStripVsPlanePix[i]->SetFillColor(0);
03147
03148 }
03149
03150 TH2F **hStripVsPlanePixF=0;
03151 hStripVsPlanePixF= new TH2F*[NUMCRATES];
03152 for (Int_t i=0;i<NUMCRATES;i++){
03153 string sPulserBox=Form("%d",i);
03154 s="Pixel (Far End, PB="+sPulserBox+sConstantBit;
03155 if (detectorType==Detector::kCalDet){
03156 s="Pixel (Far End of Strip, Crate="+sPulserBox+sConstantBit;
03157 }
03158 hStripVsPlanePixF[i]=new TH2F
03159 (s.c_str(),s.c_str(),
03160 planeMax[i]-planeMin[i],planeMin[i],planeMax[i]
03161 ,bins,firstStripBin,lastStripBin);
03162 hStripVsPlanePixF[i]->GetXaxis()->SetTitle("Plane");
03163 hStripVsPlanePixF[i]->GetXaxis()->CenterTitle();
03164 hStripVsPlanePixF[i]->GetYaxis()->SetTitle("Strip");
03165 hStripVsPlanePixF[i]->GetYaxis()->CenterTitle();
03166 hStripVsPlanePixF[i]->SetFillColor(0);
03167
03168 }
03169
03170 TH2F **hStripVsPlaneEnt=0;
03171 hStripVsPlaneEnt= new TH2F*[NUMCRATES];
03172 for (Int_t i=0;i<NUMCRATES;i++){
03173 string sPulserBox=Form("%d",i);
03174 s="Entries (Near End, PB="+sPulserBox+sConstantBit;
03175 if (detectorType==Detector::kCalDet){
03176 s="Entries (Near End of Strip, Crate="+sPulserBox+sConstantBit;
03177 }
03178 hStripVsPlaneEnt[i]=new TH2F
03179 (s.c_str(),s.c_str(),
03180 planeMax[i]-planeMin[i],planeMin[i],planeMax[i]
03181 ,bins,firstStripBin,lastStripBin);
03182 hStripVsPlaneEnt[i]->GetXaxis()->SetTitle("Plane");
03183 hStripVsPlaneEnt[i]->GetXaxis()->CenterTitle();
03184 hStripVsPlaneEnt[i]->GetYaxis()->SetTitle("Strip");
03185 hStripVsPlaneEnt[i]->GetYaxis()->CenterTitle();
03186 hStripVsPlaneEnt[i]->SetFillColor(0);
03187
03188 }
03189
03190 TH2F **hStripVsPlaneEntF=0;
03191 hStripVsPlaneEntF= new TH2F*[NUMCRATES];
03192 for (Int_t i=0;i<NUMCRATES;i++){
03193 string sPulserBox=Form("%d",i);
03194 s="Entries (Far End, PB="+sPulserBox+sConstantBit;
03195 hStripVsPlaneEntF[i]=new TH2F
03196 (s.c_str(),s.c_str(),
03197 planeMax[i]-planeMin[i],planeMin[i],planeMax[i]
03198 ,bins,firstStripBin,lastStripBin);
03199 hStripVsPlaneEntF[i]->GetXaxis()->SetTitle("Plane");
03200 hStripVsPlaneEntF[i]->GetXaxis()->CenterTitle();
03201 hStripVsPlaneEntF[i]->GetYaxis()->SetTitle("Strip");
03202 hStripVsPlaneEntF[i]->GetYaxis()->CenterTitle();
03203 hStripVsPlaneEntF[i]->SetFillColor(0);
03204
03205 }
03206
03207 TH2F **hStripVsPlaneXTalk=0;
03208 hStripVsPlaneXTalk= new TH2F*[NUMCRATES];
03209 for (Int_t i=0;i<NUMCRATES;i++){
03210 string sPulserBox=Form("%d",i);
03211 s="XTalk (Near End, PB="+sPulserBox+sConstantBit;
03212 if (detectorType==Detector::kCalDet){
03213 s="XTalk (Near End of Strip, Crate="+sPulserBox+sConstantBit;
03214 }
03215 hStripVsPlaneXTalk[i]=new TH2F
03216 (s.c_str(),s.c_str(),
03217 planeMax[i]-planeMin[i],planeMin[i],planeMax[i]
03218 ,bins,firstStripBin,lastStripBin);
03219 hStripVsPlaneXTalk[i]->GetXaxis()->SetTitle("Plane");
03220 hStripVsPlaneXTalk[i]->GetXaxis()->CenterTitle();
03221 hStripVsPlaneXTalk[i]->GetYaxis()->SetTitle("Strip");
03222 hStripVsPlaneXTalk[i]->GetYaxis()->CenterTitle();
03223 hStripVsPlaneXTalk[i]->SetFillColor(0);
03224
03225 }
03226
03227 TH2F **hStripVsPlaneAll=0;
03228 hStripVsPlaneAll= new TH2F*[NUMCRATES];
03229 for (Int_t i=0;i<NUMCRATES;i++){
03230 string sPulserBox=Form("%d",i);
03231 s="All (PB="+sPulserBox+sConstantBit;
03232 if (detectorType==Detector::kCalDet){
03233 s="All (Crate="+sPulserBox+sConstantBit;
03234 }
03235 hStripVsPlaneAll[i]=new TH2F
03236 (s.c_str(),s.c_str(),
03237 planeMax[i]-planeMin[i],planeMin[i],planeMax[i]
03238 ,bins,firstStripBin,lastStripBin);
03239 hStripVsPlaneAll[i]->GetXaxis()->SetTitle("Plane");
03240 hStripVsPlaneAll[i]->GetXaxis()->CenterTitle();
03241 hStripVsPlaneAll[i]->GetYaxis()->SetTitle("Strip");
03242 hStripVsPlaneAll[i]->GetYaxis()->CenterTitle();
03243 hStripVsPlaneAll[i]->SetFillColor(0);
03244
03245 }
03246
03247 Int_t maxPlane=0;
03248
03249 MSG("LIAnalysis",Msg::kInfo)
03250 <<"Starting main loop..."<<endl;
03251
03255
03256 this->InitialiseLoopVariables();
03257
03258 for(Int_t entry=0;entry<numEvents;entry++){
03259
03260 this->SetLoopVariables(entry,1);
03261
03262
03263 if (rms==0. || mean==0. || numEntries==0) continue;
03264
03265 if (readoutType!=ReadoutType::kScintStrip) continue;
03266
03267
03268 if (calibType>1){
03269
03270 if (calibPoint!=calibType/2) continue;
03271 }
03272
03273
03274 if (plane>maxPlane && mean>2000) maxPlane=plane;
03275
03276
03277 Float_t npe=mean*mean/(rms*rms);
03278
03279 Float_t gain=0.8*mean/npe;
03280
03281
03282 if (detectorType==Detector::kNear) gain = 0.844*rms*rms/mean;
03283
03284
03286
03288 if (detectorType==Detector::kFar
03289 || detectorType==Detector::kNear){
03290
03291 if (pulserBox>=0 && pulserBox<NUMPULSERBOXES &&
03292 correlatedHit==1 &&
03293 strip<=LASTSTRIP && strip>=FIRSTSTRIP &&
03294 pulserBox==farPulserBox){
03295 hStripVsPlaneMeanF[pulserBox]->Fill(plane,strip,mean);
03296 hStripVsPlaneRmsF[pulserBox]->Fill(plane,strip,rms);
03297 hStripVsPlaneEntF[pulserBox]->Fill(plane,strip,1);
03298 hStripVsPlaneNumF[pulserBox]->Fill(plane,strip,numEntries);
03299 hStripVsPlanePixF[pulserBox]->Fill(plane,strip,pixel+1);
03300
03301
03302 if (mean>adcLowerCut && mean<adcUpperCut &&
03303 numEntries>(pulsesCut/100.)*pulses){
03304 hStripVsPlaneGainF[pulserBox]->Fill(plane,strip,gain);
03305 }
03306 }
03307
03308 if (pulserBox>=0 && pulserBox<NUMPULSERBOXES &&
03309 correlatedHit==1 &&
03310 strip<=LASTSTRIP && strip>=FIRSTSTRIP &&
03311 pulserBox==nearPulserBox){
03312 hStripVsPlaneLed[pulserBox]->Fill(plane,strip,nearLed);
03313 hStripVsPlaneMean[pulserBox]->Fill(plane,strip,mean);
03314 hStripVsPlaneRms[pulserBox]->Fill(plane,strip,rms);
03315 hStripVsPlaneNum[pulserBox]->Fill(plane,strip,numEntries);
03316 hStripVsPlanePix[pulserBox]->Fill(plane,strip,pixel+1);
03317 hStripVsPlaneEnt[pulserBox]->Fill(plane,strip,1);
03318
03319
03320 if (mean>adcLowerCut && mean<adcUpperCut &&
03321 numEntries>(pulsesCut/100.)*pulses){
03322 hStripVsPlaneNpe[pulserBox]->Fill(plane,strip,npe);
03323 hStripVsPlaneGainN[pulserBox]->Fill(plane,strip,gain);
03324 }
03325
03326 MSG("LIAnalysis",Msg::kVerbose)
03327 <<"mean="<<mean
03328 <<", rms="<<rms
03329 <<", npe="<<pow(mean/rms,2)
03330 <<", gain="<<gain
03331 <<endl;
03332 }
03333 }
03334
03336
03338 else if (detectorType==Detector::kCalDet){
03339
03340
03341
03342 if (ledCut==-1 || led==ledCut){
03343
03344
03345 if (eastWest==1 || eastWest==2){
03346 hStripVsPlaneAll[eastWest-1]->Fill(plane,strip,mean);
03347 }
03348
03349
03350 if ((eastWest==1 || eastWest==2) && correlatedHit==1 &&
03351 strip<=LASTSTRIP && strip>=FIRSTSTRIP &&
03352 lookup.NearOrFar(crate,pulserBox,nearPulserBox,
03353 farPulserBox,led,detectorType,
03354 plane,runNumber)==
03355 LILookup::kFarSide &&
03356 led>=FIRSTLED && led<=LASTLED){
03357
03358 hStripVsPlaneMeanF[eastWest-1]->Fill(plane,strip,mean);
03359 hStripVsPlaneRmsF[eastWest-1]->Fill(plane,strip,rms);
03360 hStripVsPlaneEntF[eastWest-1]->Fill(plane,strip,1);
03361 hStripVsPlaneNumF[eastWest-1]->Fill(plane,strip,numEntries);
03362 hStripVsPlanePixF[eastWest-1]->Fill(plane,strip,pixel+1);
03363
03364
03365 if (mean>adcLowerCut && mean<adcUpperCut &&
03366 numEntries>(pulsesCut/100.)*pulses){
03367 hStripVsPlaneGainF[eastWest-1]->Fill(plane,strip,gain);
03368 }
03369 }
03370
03371
03372 if ((eastWest==1 || eastWest==2) && correlatedHit==0 &&
03373 strip>=FIRSTSTRIP && strip<=LASTSTRIP &&
03374 lookup.NearOrFar(crate,pulserBox,nearPulserBox,
03375 farPulserBox,led,detectorType,
03376 plane,runNumber)==
03377 LILookup::kNearSide &&
03378 led>=FIRSTLED && led<=LASTLED){
03379 hStripVsPlaneXTalk[eastWest-1]->Fill(plane,strip,mean);
03380
03381 }
03382
03383
03384 if ((eastWest==1 || eastWest==2) && correlatedHit==1 &&
03385 strip>=FIRSTSTRIP && strip<=LASTSTRIP &&
03386 lookup.NearOrFar(crate,pulserBox,nearPulserBox,
03387 farPulserBox,led,detectorType,
03388 plane,runNumber)==
03389 LILookup::kNearSide &&
03390 led>=FIRSTLED && led<=LASTLED){
03391
03392 if (strip==20 && plane==20){
03393 this->PrintBigMessage();
03394 }
03395
03396 hStripVsPlaneLed[eastWest-1]->Fill(plane,strip,nearLed);
03397 hStripVsPlaneMean[eastWest-1]->Fill(plane,strip,mean);
03398 hStripVsPlaneRms[eastWest-1]->Fill(plane,strip,rms);
03399 hStripVsPlaneNum[eastWest-1]->Fill(plane,strip,numEntries);
03400 hStripVsPlanePix[eastWest-1]->Fill(plane,strip,pixel+1);
03401 hStripVsPlaneEnt[eastWest-1]->Fill(plane,strip,1);
03402
03403
03404 if (mean>adcLowerCut && mean<adcUpperCut &&
03405 numEntries>(pulsesCut/100.)*pulses){
03406 hStripVsPlaneNpe[eastWest-1]->Fill(plane,strip,npe);
03407 hStripVsPlaneGainN[eastWest-1]->Fill(plane,strip,gain);
03408
03409 MSG("LIAnalysis",Msg::kVerbose)
03410 <<"mean="<<mean
03411 <<", rms="<<rms
03412 <<", npe="<<pow(mean/rms,2)
03413 <<", gain="<<gain
03414 <<endl;
03415 }
03416 }
03417 }
03418 }
03419 else{
03420 MSG("LIAnalysis",Msg::kWarning)<<"Detector not defined"<<endl;
03421 }
03422 }
03423
03427
03428 MSG("LIAnalysis",Msg::kInfo)<<"Finished main loop"<<endl;
03429 MSG("LIAnalysis",Msg::kInfo)<<"Max plane="<<maxPlane<<endl;
03430
03431
03432 gStyle->SetOptStat(0);
03433 string sRunNumber=Form("%d",runNumber);
03434
03435
03436
03437
03438
03439
03440
03441
03442
03443
03444
03445
03446
03447
03448
03449
03450
03451
03452
03453
03454
03455
03456
03457 MSG("LIAnalysis",Msg::kInfo)<<"Filling gain histos"<<endl;
03458
03459
03460 for (Int_t i=0;i<NUMCRATES;i++){
03461 for (Int_t pl=0;pl<planeMax[i]-planeMin[i]+1;pl++){
03462 for (Int_t st=0;st<210;st++){
03463
03464 Int_t oppPb=lookup.GetOppPb(i,detectorType);
03465
03466
03467 if (static_cast<Float_t>
03468 (hStripVsPlaneGainN[i]->
03469 GetBinContent(pl,st))>0){
03470 hStripVsPlaneGain[i]->Fill(pl+planeMin[i]-1,st+firstStripBin,
03471 static_cast<Float_t>
03472 (hStripVsPlaneGainN[i]->
03473 GetBinContent(pl,st)));
03474 }
03475
03476 else if (static_cast<Float_t>
03477 (hStripVsPlaneGainF[oppPb]->
03478 GetBinContent(pl,st))>0){
03479 hStripVsPlaneGain[i]->Fill(pl+planeMin[i]-1,st+firstStripBin,
03480 static_cast<Float_t>
03481 (hStripVsPlaneGainF[oppPb]->
03482 GetBinContent(pl,st)));
03483 }
03484
03485
03486 if (static_cast<Float_t>
03487 (hStripVsPlaneGainN[i]->
03488 GetBinContent(pl,st))>0.1 &&
03489 static_cast<Float_t>
03490 (hStripVsPlaneGainF[oppPb]->
03491 GetBinContent(pl,st))>0.1){
03492
03493
03494 Float_t gainDifference=static_cast<Float_t>
03495 (hStripVsPlaneGainN[i]->
03496 GetBinContent(pl,st))-
03497 static_cast<Float_t>
03498 (hStripVsPlaneGainF[oppPb]->
03499 GetBinContent(pl,st));
03500
03501
03502 hStripVsPlaneGainDiff[i]->Fill(pl+planeMin[i]-1,
03503 st+firstStripBin,
03504 gainDifference);
03505 hGainDiff->Fill(gainDifference);
03506 }
03507 }
03508 }
03509
03510 Float_t gainMax=84+2.33*20.7;
03511 hStripVsPlaneGain[i]->SetMaximum(gainMax);
03512
03513
03514 Float_t diffMax=-5.3+2.33*7.3;
03515 hStripVsPlaneGainDiff[i]->SetMaximum(diffMax);
03516
03517 Float_t diffMin=-5.3-2.33*7.3;
03518 hStripVsPlaneGainDiff[i]->SetMinimum(diffMin);
03519 }
03520
03521 MSG("LIAnalysis",Msg::kInfo)<<"Drawing histos"<<endl;
03522
03523 TCanvas *cStripVsPlaneMean=new TCanvas
03524 ("cStripVsPlaneMean","StripVsPlane: Mean",0,0,1000,800);
03525 cStripVsPlaneMean->SetFillColor(0);
03526 cStripVsPlaneMean->cd();
03527 for (Int_t i=0;i<NUMCRATES;i++){
03528 cStripVsPlaneMean->Clear();
03529 hStripVsPlaneMean[i]->Draw("colz");
03530 if (i==0){
03531 s=sRunNumber+"AdcNear.ps(";
03532 cStripVsPlaneMean->Print(s.c_str());
03533 }
03534 else if(i==NUMCRATES-1){
03535 s=sRunNumber+"AdcNear.ps)";
03536 cStripVsPlaneMean->Print(s.c_str());
03537 MSG("LIAnalysis",Msg::kInfo)<<"Printed last page of "<<s<<endl;
03538 }
03539 else{
03540 s=sRunNumber+"AdcNear.ps";
03541 cStripVsPlaneMean->Print(s.c_str());
03542 }
03543 }
03544
03545 cStripVsPlaneMean->Clear();
03546 hStripVsPlaneMean[nearPb]->Draw("colz");
03547 delete cStripVsPlaneMean;
03548
03549 TCanvas *cStripVsPlaneMeanF=new TCanvas
03550 ("cStripVsPlaneMeanF","StripVsPlane: Mean (Far)",0,0,1000,800);
03551 cStripVsPlaneMeanF->SetFillColor(0);
03552 cStripVsPlaneMeanF->cd();
03553 for (Int_t i=0;i<NUMCRATES;i++){
03554 cStripVsPlaneMeanF->Clear();
03555 hStripVsPlaneMeanF[i]->Draw("colz");
03556 if (i==0){
03557 s=sRunNumber+"AdcFar.ps(";
03558 cStripVsPlaneMeanF->Print(s.c_str());
03559 }
03560 else if(i==NUMCRATES-1){
03561 s=sRunNumber+"AdcFar.ps)";
03562 cStripVsPlaneMeanF->Print(s.c_str());
03563 MSG("LIAnalysis",Msg::kInfo)<<"Printed last page of "<<s<<endl;
03564 }
03565 else{
03566 s=sRunNumber+"AdcFar.ps";
03567 cStripVsPlaneMeanF->Print(s.c_str());
03568 }
03569 }
03570
03571 cStripVsPlaneMeanF->Clear();
03572 hStripVsPlaneMeanF[farPb]->Draw("colz");
03573 delete cStripVsPlaneMeanF;
03574
03575 MSG("LIAnalysis",Msg::kInfo)<<"Drawing rms histos"<<endl;
03576
03577 TCanvas *cStripVsPlaneRms=new TCanvas
03578 ("cStripVsPlaneRms","StripVsPlane: Rms",0,0,1000,800);
03579 cStripVsPlaneRms->SetFillColor(0);
03580 cStripVsPlaneRms->cd();
03581 for (Int_t i=0;i<NUMCRATES;i++){
03582 cStripVsPlaneRms->Clear();
03583 hStripVsPlaneRms[i]->Draw("colz");
03584 if (i==0){
03585 s=sRunNumber+"RmsNear.ps(";
03586 cStripVsPlaneRms->Print(s.c_str());
03587 }
03588 else if(i==NUMCRATES-1){
03589 s=sRunNumber+"RmsNear.ps)";
03590 cStripVsPlaneRms->Print(s.c_str());
03591 MSG("LIAnalysis",Msg::kInfo)<<"Printed last page of "<<s<<endl;
03592 }
03593 else{
03594 s=sRunNumber+"RmsNear.ps";
03595 cStripVsPlaneRms->Print(s.c_str());
03596 }
03597 }
03598
03599 cStripVsPlaneRms->Clear();
03600 hStripVsPlaneRms[nearPb]->Draw("colz");
03601 delete cStripVsPlaneRms;
03602
03603 TCanvas *cStripVsPlaneRmsF=new TCanvas
03604 ("cStripVsPlaneRmsF","StripVsPlane: Rms (Far)",0,0,1000,800);
03605 cStripVsPlaneRmsF->SetFillColor(0);
03606 cStripVsPlaneRmsF->cd();
03607 for (Int_t i=0;i<NUMCRATES;i++){
03608 cStripVsPlaneRmsF->Clear();
03609 hStripVsPlaneRmsF[i]->Draw("colz");
03610 if (i==0){
03611 s=sRunNumber+"RmsFar.ps(";
03612 cStripVsPlaneRmsF->Print(s.c_str());
03613 }
03614 else if(i==NUMCRATES-1){
03615 s=sRunNumber+"RmsFar.ps)";
03616 cStripVsPlaneRmsF->Print(s.c_str());
03617 MSG("LIAnalysis",Msg::kInfo)<<"Printed last page of "<<s<<endl;
03618 }
03619 else{
03620 s=sRunNumber+"RmsFar.ps";
03621 cStripVsPlaneRmsF->Print(s.c_str());
03622 }
03623 }
03624
03625 cStripVsPlaneRmsF->Clear();
03626 hStripVsPlaneRmsF[farPb]->Draw("colz");
03627 delete cStripVsPlaneRmsF;
03628
03629 MSG("LIAnalysis",Msg::kInfo)<<"Drawing num ent histos"<<endl;
03630
03631 TCanvas *cStripVsPlaneNum=new TCanvas
03632 ("cStripVsPlaneNum","StripVsPlane: Num",0,0,1000,800);
03633 cStripVsPlaneNum->SetFillColor(0);
03634 cStripVsPlaneNum->cd();
03635 for (Int_t i=0;i<NUMCRATES;i++){
03636 cStripVsPlaneNum->Clear();
03637 hStripVsPlaneNum[i]->Draw("colz");
03638 if (i==0){
03639 s=sRunNumber+"NumEntriesNear.ps(";
03640 cStripVsPlaneNum->Print(s.c_str());
03641 }
03642 else if(i==NUMCRATES-1){
03643 s=sRunNumber+"NumEntriesNear.ps)";
03644 cStripVsPlaneNum->Print(s.c_str());
03645 MSG("LIAnalysis",Msg::kInfo)<<"Printed last page of "<<s<<endl;
03646 }
03647 else{
03648 s=sRunNumber+"NumEntriesNear.ps";
03649 cStripVsPlaneNum->Print(s.c_str());
03650 }
03651 }
03652
03653 cStripVsPlaneNum->Clear();
03654 hStripVsPlaneNum[nearPb]->Draw("colz");
03655 delete cStripVsPlaneNum;
03656
03657 TCanvas *cStripVsPlaneNumF=new TCanvas
03658 ("cStripVsPlaneNumF","StripVsPlane: Num (Far)",0,0,1000,800);
03659 cStripVsPlaneNumF->SetFillColor(0);
03660 cStripVsPlaneNumF->cd();
03661 for (Int_t i=0;i<NUMCRATES;i++){
03662 cStripVsPlaneNumF->Clear();
03663 hStripVsPlaneNumF[i]->Draw("colz");
03664 if (i==0){
03665 s=sRunNumber+"NumEntriesFar.ps(";
03666 cStripVsPlaneNumF->Print(s.c_str());
03667 }
03668 else if(i==NUMCRATES-1){
03669 s=sRunNumber+"NumEntriesFar.ps)";
03670 cStripVsPlaneNumF->Print(s.c_str());
03671 MSG("LIAnalysis",Msg::kInfo)<<"Printed last page of "<<s<<endl;
03672 }
03673 else{
03674 s=sRunNumber+"NumEntriesFar.ps";
03675 cStripVsPlaneNumF->Print(s.c_str());
03676 }
03677 }
03678
03679 cStripVsPlaneNumF->Clear();
03680 hStripVsPlaneNumF[farPb]->Draw("colz");
03681 delete cStripVsPlaneNumF;
03682
03683
03684 gStyle->SetOptStat(1111111);
03685
03686 TCanvas *cGainDiff=new TCanvas
03687 ("cGainDiff","Gain Differences",0,0,1200,800);
03688 cGainDiff->SetFillColor(0);
03689 cGainDiff->cd();
03690 hGainDiff->Draw();
03691 s=sRunNumber+"GainDiffHisto.ps";
03692 cGainDiff->Print(s.c_str());
03693
03694
03695 gStyle->SetOptStat(0);
03696
03697 TCanvas *cStripVsPlaneGain=new TCanvas
03698 ("cStripVsPlaneGain","StripVsPlane: Gain",0,0,1000,800);
03699 cStripVsPlaneGain->SetFillColor(0);
03700 cStripVsPlaneGain->cd();
03701 for (Int_t i=0;i<NUMCRATES;i++){
03702 cStripVsPlaneGain->Clear();
03703 hStripVsPlaneGain[i]->Draw("colz");
03704 if (i==0){
03705 s=sRunNumber+"Gain.ps(";
03706 cStripVsPlaneGain->Print(s.c_str());
03707 }
03708 else if(i==NUMCRATES-1){
03709 s=sRunNumber+"Gain.ps)";
03710 cStripVsPlaneGain->Print(s.c_str());
03711 MSG("LIAnalysis",Msg::kInfo)<<"Printed last page of "<<s<<endl;
03712 }
03713 else{
03714 s=sRunNumber+"Gain.ps";
03715 cStripVsPlaneGain->Print(s.c_str());
03716 }
03717 }
03718
03719 cStripVsPlaneGain->Clear();
03720
03721
03722
03723 TCanvas *cStripVsPlaneGainN=new TCanvas
03724 ("cStripVsPlaneGainN","StripVsPlane: Gain (Near)",0,0,1000,800);
03725 cStripVsPlaneGainN->SetFillColor(0);
03726 cStripVsPlaneGainN->cd();
03727 for (Int_t i=0;i<NUMCRATES;i++){
03728 cStripVsPlaneGainN->Clear();
03729 hStripVsPlaneGainN[i]->Draw("colz");
03730 if (i==0){
03731 s=sRunNumber+"GainNear.ps(";
03732 cStripVsPlaneGainN->Print(s.c_str());
03733 }
03734 else if(i==NUMCRATES-1){
03735 s=sRunNumber+"GainNear.ps)";
03736 cStripVsPlaneGainN->Print(s.c_str());
03737 MSG("LIAnalysis",Msg::kInfo)<<"Printed last page of "<<s<<endl;
03738 }
03739 else{
03740 s=sRunNumber+"GainNear.ps";
03741 cStripVsPlaneGainN->Print(s.c_str());
03742 }
03743 }
03744
03745
03746 cStripVsPlaneGainN->Clear();
03747
03748
03749 cStripVsPlaneGainN->cd();
03750 for (Int_t i=0;i<NUMCRATES;i++){
03751 cStripVsPlaneGainN->Clear();
03752 hStripVsPlaneGainN[i]->SetMaximum(90);
03753 hStripVsPlaneGainN[i]->Draw("colz");
03754 if (i==0){
03755 s=sRunNumber+"Max90GainNear.ps(";
03756 cStripVsPlaneGainN->Print(s.c_str());
03757 }
03758 else if(i==NUMCRATES-1){
03759 s=sRunNumber+"Max90GainNear.ps)";
03760 cStripVsPlaneGainN->Print(s.c_str());
03761 MSG("LIAnalysis",Msg::kInfo)<<"Printed last page of "<<s<<endl;
03762 }
03763 else{
03764 s=sRunNumber+"Max90GainNear.ps";
03765 cStripVsPlaneGainN->Print(s.c_str());
03766 }
03767 }
03768
03769
03770 cStripVsPlaneGainN->Clear();
03771 cStripVsPlaneGainN->cd();
03772 for (Int_t i=0;i<NUMSIDES;i++){
03773 cStripVsPlaneGainN->Clear();
03774 hStripVsPlaneGainAll[i]->SetMaximum(90);
03775 hStripVsPlaneGainAll[i]->Draw("colz");
03776 if (i==0){
03777 s=sRunNumber+"AllGainNear.ps(";
03778 cStripVsPlaneGainN->Print(s.c_str());
03779 }
03780 else if(i==NUMSIDES-1){
03781 s=sRunNumber+"AllGainNear.ps)";
03782 cStripVsPlaneGainN->Print(s.c_str());
03783 MSG("LIAnalysis",Msg::kInfo)<<"Printed last page of "<<s<<endl;
03784 }
03785 else{
03786 s=sRunNumber+"AllGainNear.ps";
03787 cStripVsPlaneGainN->Print(s.c_str());
03788 }
03789 }
03790
03791 TCanvas *cStripVsPlaneGainF=new TCanvas
03792 ("cStripVsPlaneGainF","StripVsPlane: Gain (Far)",0,0,1000,800);
03793 cStripVsPlaneGainF->SetFillColor(0);
03794 cStripVsPlaneGainF->cd();
03795 for (Int_t i=0;i<NUMCRATES;i++){
03796 cStripVsPlaneGainF->Clear();
03797 hStripVsPlaneGainF[i]->Draw("colz");
03798 if (i==0){
03799 s=sRunNumber+"GainFar.ps(";
03800 cStripVsPlaneGainF->Print(s.c_str());
03801 }
03802 else if(i==NUMCRATES-1){
03803 s=sRunNumber+"GainFar.ps)";
03804 cStripVsPlaneGainF->Print(s.c_str());
03805 MSG("LIAnalysis",Msg::kInfo)<<"Printed last page of "<<s<<endl;
03806 }
03807 else{
03808 s=sRunNumber+"GainFar.ps";
03809 cStripVsPlaneGainF->Print(s.c_str());
03810 }
03811 }
03812
03813 cStripVsPlaneGainF->Clear();
03814 hStripVsPlaneGainF[farPb]->Draw("colz");
03815 delete cStripVsPlaneGainF;
03816
03817 TCanvas *cStripVsPlaneGainDiff=new TCanvas
03818 ("cStripVsPlaneGainDiff","StripVsPlane: GainDiff",0,0,1000,800);
03819 cStripVsPlaneGainDiff->SetFillColor(0);
03820 cStripVsPlaneGainDiff->cd();
03821 for (Int_t i=0;i<NUMCRATES;i++){
03822 cStripVsPlaneGainDiff->Clear();
03823 hStripVsPlaneGainDiff[i]->Draw("colz");
03824 if (i==0){
03825 s=sRunNumber+"GainDiff.ps(";
03826 cStripVsPlaneGainDiff->Print(s.c_str());
03827 }
03828 else if(i==NUMCRATES-1){
03829 s=sRunNumber+"GainDiff.ps)";
03830 cStripVsPlaneGainDiff->Print(s.c_str());
03831 MSG("LIAnalysis",Msg::kInfo)<<"Printed last page of "<<s<<endl;
03832 }
03833 else{
03834 s=sRunNumber+"GainDiff.ps";
03835 cStripVsPlaneGainDiff->Print(s.c_str());
03836 }
03837 }
03838
03839 cStripVsPlaneGainDiff->Clear();
03840 hStripVsPlaneGainDiff[farPb]->Draw("colz");
03841 delete cStripVsPlaneGainDiff;
03842
03843 TCanvas *cStripVsPlaneEntEast=new TCanvas
03844 ("cStripVsPlaneEntEast","StripVsPlane: East Side (Near)"
03845 ,0,0,1200,800);
03846 cStripVsPlaneEntEast->SetFillColor(0);
03847 cStripVsPlaneEntEast->cd();
03848 hStripVsPlaneLedB->SetTitle("East Side (Near)");
03849 hStripVsPlaneLedB->Draw();
03850 for (Int_t i=0;i<NUMCRATES;i+=2){
03851 hStripVsPlaneEnt[i]->Draw("samecolz");
03852 }
03853 s=sRunNumber+"NumberEntries.ps(";
03854 cStripVsPlaneEntEast->Print(s.c_str());
03855 delete cStripVsPlaneEntEast;
03856
03857 TCanvas *cStripVsPlaneEntWest=new TCanvas
03858 ("cStripVsPlaneEntWest","StripVsPlane: West Side (Near)"
03859 ,0,0,1200,800);
03860 cStripVsPlaneEntWest->SetFillColor(0);
03861 cStripVsPlaneEntWest->cd();
03862 hStripVsPlaneLedB->SetTitle("West Side (Near)");
03863 hStripVsPlaneLedB->Draw();
03864 for (Int_t i=1;i<NUMCRATES;i+=2){
03865 hStripVsPlaneEnt[i]->Draw("samecolz");
03866 }
03867 s=sRunNumber+"NumberEntries.ps";
03868 cStripVsPlaneEntWest->Print(s.c_str());
03869 delete cStripVsPlaneEntWest;
03870
03871 TCanvas *cStripVsPlaneEntWestF=new TCanvas
03872 ("cStripVsPlaneEntWestF","StripVsPlane: West Side (Far)"
03873 ,0,0,1200,800);
03874 cStripVsPlaneEntWestF->SetFillColor(0);
03875 cStripVsPlaneEntWestF->cd();
03876 hStripVsPlaneLedB->SetTitle("West Side (Far)");
03877 hStripVsPlaneLedB->Draw();
03878 for (Int_t i=0;i<NUMCRATES;i+=2){
03879 hStripVsPlaneEntF[i]->Draw("samecolz");
03880 }
03881 s=sRunNumber+"NumberEntries.ps";
03882 cStripVsPlaneEntWestF->Print(s.c_str());
03883 delete cStripVsPlaneEntWestF;
03884
03885 TCanvas *cStripVsPlaneEntEastF=new TCanvas
03886 ("cStripVsPlaneEntEastF","StripVsPlane: East Side (Far)"
03887 ,0,0,1200,800);
03888 cStripVsPlaneEntEastF->SetFillColor(0);
03889 cStripVsPlaneEntEastF->cd();
03890 hStripVsPlaneLedB->SetTitle("East Side (Far)");
03891 hStripVsPlaneLedB->Draw();
03892 for (Int_t i=1;i<NUMCRATES;i+=2){
03893 hStripVsPlaneEntF[i]->Draw("samecolz");
03894 }
03895 s=sRunNumber+"NumberEntries.ps)";
03896 cStripVsPlaneEntEastF->Print(s.c_str());
03897 MSG("LIAnalysis",Msg::kInfo)<<"Printed last page of "<<s<<endl;
03898 delete cStripVsPlaneEntEastF;
03899
03900 TCanvas *cStripVsPlaneXTalk=new TCanvas
03901 ("cStripVsPlaneXTalk","StripVsPlane: XTalk",0,0,1000,800);
03902 cStripVsPlaneXTalk->SetFillColor(0);
03903 cStripVsPlaneXTalk->cd();
03904 for (Int_t i=0;i<NUMCRATES;i++){
03905 cStripVsPlaneXTalk->Clear();
03906 hStripVsPlaneXTalk[i]->Draw("colz");
03907 if (i==0){
03908 s=sRunNumber+"XTalkNear.ps(";
03909 cStripVsPlaneXTalk->Print(s.c_str());
03910 }
03911 else if(i==NUMCRATES-1){
03912 s=sRunNumber+"XTalkNear.ps)";
03913 cStripVsPlaneXTalk->Print(s.c_str());
03914 MSG("LIAnalysis",Msg::kInfo)<<"Printed last page of "<<s<<endl;
03915 }
03916 else{
03917 s=sRunNumber+"XTalkNear.ps";
03918 cStripVsPlaneXTalk->Print(s.c_str());
03919 }
03920 }
03921
03922 TCanvas *cStripVsPlaneAll=new TCanvas
03923 ("cStripVsPlaneAll","StripVsPlane: All",0,0,1000,800);
03924 cStripVsPlaneAll->SetFillColor(0);
03925 cStripVsPlaneAll->cd();
03926 for (Int_t i=0;i<NUMCRATES;i++){
03927 cStripVsPlaneAll->Clear();
03928 MSG("LIAnalysis",Msg::kInfo)
03929 <<"Drawing StripVsPlane: All"<<endl;
03930 hStripVsPlaneAll[i]->Draw("colz");
03931 if (i==0){
03932 s=sRunNumber+"All.ps(";
03933 cStripVsPlaneAll->Print(s.c_str());
03934 }
03935 else if(i==NUMCRATES-1){
03936 s=sRunNumber+"All.ps)";
03937 cStripVsPlaneAll->Print(s.c_str());
03938 MSG("LIAnalysis",Msg::kInfo)<<"Printed last page of "<<s<<endl;
03939 }
03940 else{
03941 s=sRunNumber+"All.ps";
03942 cStripVsPlaneAll->Print(s.c_str());
03943 }
03944 }
03945
03946 TCanvas *cStripVsPlaneLed=new TCanvas
03947 ("cStripVsPlaneLed","StripVsPlane: Led",0,0,1000,800);
03948 cStripVsPlaneLed->SetFillColor(0);
03949 cStripVsPlaneLed->cd();
03950 for (Int_t i=0;i<NUMCRATES;i++){
03951 cStripVsPlaneLed->Clear();
03952 hStripVsPlaneLed[i]->Draw("colz");
03953 if (i==0){
03954 s=sRunNumber+"LedNear.ps(";
03955 cStripVsPlaneLed->Print(s.c_str());
03956 }
03957 else if(i==NUMCRATES-1){
03958 s=sRunNumber+"LedNear.ps)";
03959 cStripVsPlaneLed->Print(s.c_str());
03960 MSG("LIAnalysis",Msg::kInfo)<<"Printed last page of "<<s<<endl;
03961 }
03962 else{
03963 s=sRunNumber+"LedNear.ps";
03964 cStripVsPlaneLed->Print(s.c_str());
03965 }
03966 }
03967
03968 MSG("LIAnalysis",Msg::kInfo)
03969 <<" ** Finished the StripVsPlane method ** "<<endl;
03970 }
03971
03972
03973 void LIAnalysis::StripVsPlaneWholeDet()
03974 {
03975 MSG("LIAnalysis",Msg::kInfo)
03976 <<endl<<" ** Running the StripVsPlaneWholeDet method... ** "<<endl;
03977
03978 chain->GetEvent(0);
03979
03980 if (calibType>1){
03981 MSG("LIAnalysis",Msg::kWarning)
03982 <<endl<<"Gain curve file detected with "<<calibType<<" points"
03983 <<endl<<"Only the last gain curve point will be used"<<endl;
03984 }
03985
03986 const Int_t firstStripBin=FIRSTSTRIP-8;
03987 const Int_t lastStripBin=LASTSTRIP+9;
03988 const Int_t bins=lastStripBin-firstStripBin;
03989
03990 string sPulseWidth=Form("%d",pulseWidth);
03991 string sPulseHeight=Form("%d",pulseHeight);
03992 string sPulseFreq=Form("%d",static_cast<Int_t>
03993 (ceil(1.0/(period*1.0e-5))));
03994 string sPulses=Form("%d",pulses);
03995 string sConstantBit="";
03996
03997 if (detectorType==Detector::kFar){
03998 MSG("LIAnalysis",Msg::kInfo)
03999 <<"Setting histo titles according to detector type kFar"<<endl;
04000
04001 if (runNumber>=13123){
04002 Int_t fph=pulseHeight;
04003
04004
04005 Int_t lph=-10;
04006
04007 MSG("LIAnalysis",Msg::kInfo)
04008 <<"first ph="<<fph<<", last ph="<<lph<<endl;
04009
04010 if (lph==fph){
04011 sConstantBit=+", PH="+sPulseHeight+", PW="+sPulseWidth+
04012 ", PF="+sPulseFreq+" Hz, PN="+sPulses+")";
04013 }
04014 else if (lph!=fph){
04015 sConstantBit=+", PW="+sPulseWidth+
04016 ", PF="+sPulseFreq+" Hz, PN="+sPulses+")";
04017 }
04018 }
04019 else{
04020 sConstantBit=+", PH="+sPulseHeight+", PW="+sPulseWidth+
04021 ", PF="+sPulseFreq+" Hz, PN="+sPulses+")";
04022 }
04023 }
04024 else if (detectorType==Detector::kCalDet){
04025 MSG("LIAnalysis",Msg::kInfo)
04026 <<"Setting histo titles according to detector type kCalDet"<<endl;
04027
04028 Int_t fph=pulseHeight;
04029
04030 Int_t lph=-10;
04031
04032 MSG("LIAnalysis",Msg::kInfo)
04033 <<"first ph="<<fph<<", last ph="<<lph<<endl;
04034
04035 if (lph==fph){
04036 sConstantBit=+", PH="+sPulseHeight+", PW="+sPulseWidth+
04037 ", PF="+sPulseFreq+" Hz, PN="+sPulses+")";
04038 }
04039 else if (lph!=fph){
04040 sConstantBit=+", PW="+sPulseWidth+
04041 ", PF="+sPulseFreq+" Hz, PN="+sPulses+")";
04042 }
04043 }
04044
04045 MSG("LIAnalysis",Msg::kInfo)
04046 <<"sConstantBit="<<sConstantBit<<endl;
04047
04048 s="Strip Vs Plane Adc Map (East side"+sConstantBit;
04049 TH2F *hStripVsPlaneAdcEast=new TH2F(s.c_str(),s.c_str(),
04050 LASTSCINTPLANE-FIRSTSCINTPLANE+2,
04051 0,LASTSCINTPLANE+1,
04052 bins,firstStripBin,lastStripBin);
04053 hStripVsPlaneAdcEast->GetXaxis()->SetTitle("Plane");
04054 hStripVsPlaneAdcEast->GetXaxis()->CenterTitle();
04055 hStripVsPlaneAdcEast->GetYaxis()->SetTitle("Strip");
04056 hStripVsPlaneAdcEast->GetYaxis()->CenterTitle();
04057 hStripVsPlaneAdcEast->SetFillColor(0);
04058 hStripVsPlaneAdcEast->SetMaximum(15000);
04059
04060 s="Strip Vs Plane Adc Map (West side"+sConstantBit;
04061 TH2F *hStripVsPlaneAdcWest=new TH2F(s.c_str(),s.c_str(),
04062 LASTSCINTPLANE-FIRSTSCINTPLANE+2,
04063 0,LASTSCINTPLANE+1,
04064 bins,firstStripBin,lastStripBin);
04065 hStripVsPlaneAdcWest->GetXaxis()->SetTitle("Plane");
04066 hStripVsPlaneAdcWest->GetXaxis()->CenterTitle();
04067 hStripVsPlaneAdcWest->GetYaxis()->SetTitle("Strip");
04068 hStripVsPlaneAdcWest->GetYaxis()->CenterTitle();
04069 hStripVsPlaneAdcWest->SetFillColor(0);
04070 hStripVsPlaneAdcWest->SetMaximum(15000);
04071
04072 s="Strip Vs Plane Pulses Map (East side"+sConstantBit;
04073 TH2F *hStripVsPlanePulsesEast=new TH2F(s.c_str(),s.c_str(),
04074 LASTSCINTPLANE-FIRSTSCINTPLANE+2,
04075 0,LASTSCINTPLANE+1,
04076 bins,firstStripBin,lastStripBin);
04077 hStripVsPlanePulsesEast->GetXaxis()->SetTitle("Plane");
04078 hStripVsPlanePulsesEast->GetXaxis()->CenterTitle();
04079 hStripVsPlanePulsesEast->GetYaxis()->SetTitle("Strip");
04080 hStripVsPlanePulsesEast->GetYaxis()->CenterTitle();
04081 hStripVsPlanePulsesEast->SetFillColor(0);
04082
04083
04084 s="Strip Vs Plane Pulses Map (West side"+sConstantBit;
04085 TH2F *hStripVsPlanePulsesWest=new TH2F(s.c_str(),s.c_str(),
04086 LASTSCINTPLANE-FIRSTSCINTPLANE+2,
04087 0,LASTSCINTPLANE+1,
04088 bins,firstStripBin,lastStripBin);
04089 hStripVsPlanePulsesWest->GetXaxis()->SetTitle("Plane");
04090 hStripVsPlanePulsesWest->GetXaxis()->CenterTitle();
04091 hStripVsPlanePulsesWest->GetYaxis()->SetTitle("Strip");
04092 hStripVsPlanePulsesWest->GetYaxis()->CenterTitle();
04093 hStripVsPlanePulsesWest->SetFillColor(0);
04094
04095
04096 s="Strip Vs Plane Gain Map (East side, max of 120"+sConstantBit;
04097 TH2F *hStripVsPlaneGainEast=new TH2F(s.c_str(),s.c_str(),
04098 LASTSCINTPLANE-FIRSTSCINTPLANE+2,
04099 0,LASTSCINTPLANE+1,
04100 bins,firstStripBin,lastStripBin);
04101 hStripVsPlaneGainEast->GetXaxis()->SetTitle("Plane");
04102 hStripVsPlaneGainEast->GetXaxis()->CenterTitle();
04103 hStripVsPlaneGainEast->GetYaxis()->SetTitle("Strip");
04104 hStripVsPlaneGainEast->GetYaxis()->CenterTitle();
04105 hStripVsPlaneGainEast->SetFillColor(0);
04106 hStripVsPlaneGainEast->SetMaximum(120);
04107
04108 s="Strip Vs Plane Gain Map (West side, max of 120"+sConstantBit;
04109 TH2F *hStripVsPlaneGainWest=new TH2F(s.c_str(),s.c_str(),
04110 LASTSCINTPLANE-FIRSTSCINTPLANE+2,
04111 0,LASTSCINTPLANE+1,
04112 bins,firstStripBin,lastStripBin);
04113 hStripVsPlaneGainWest->GetXaxis()->SetTitle("Plane");
04114 hStripVsPlaneGainWest->GetXaxis()->CenterTitle();
04115 hStripVsPlaneGainWest->GetYaxis()->SetTitle("Strip");
04116 hStripVsPlaneGainWest->GetYaxis()->CenterTitle();
04117 hStripVsPlaneGainWest->SetFillColor(0);
04118 hStripVsPlaneGainWest->SetMaximum(120);
04119
04120 Int_t maxPlane=0;
04121
04122 MSG("LIAnalysis",Msg::kInfo)
04123 <<"Starting main loop..."<<endl;
04124
04128
04129 this->InitialiseLoopVariables();
04130
04131 for(Int_t entry=0;entry<numEvents;entry++){
04132
04133 this->SetLoopVariables(entry,0);
04134
04135
04136 if (rms==0. || mean==0. || numEntries==0) continue;
04137
04138 if (readoutType!=ReadoutType::kScintStrip) continue;
04139
04140 if (calibType>1){
04141
04142 if (calibPoint!=calibType) continue;
04143 }
04144
04145
04146 if (plane>maxPlane && mean>2000) maxPlane=plane;
04147
04148
04149 Float_t npe=mean*mean/(rms*rms);
04150 Float_t gain=0.8*mean/npe;
04151
04152
04153 if (detectorType==Detector::kNear) gain = 0.844*rms*rms/mean;
04154
04156
04158 if (detectorType==Detector::kFar
04159 || detectorType==Detector::kNear){
04160
04161 if (pulserBox>=0 && pulserBox<NUMPULSERBOXES &&
04162 correlatedHit==1 &&
04163 strip<=LASTSTRIP && strip>=FIRSTSTRIP &&
04164 pulserBox==farPulserBox){
04165
04166 }
04167
04168 if (pulserBox>=0 && pulserBox<NUMPULSERBOXES &&
04169 correlatedHit==1 &&
04170 strip<=LASTSTRIP && strip>=FIRSTSTRIP &&
04171 pulserBox==nearPulserBox){
04172
04173 if (stripEnd==StripEnd::kEast){
04174 hStripVsPlaneAdcEast->Fill(plane,strip,mean);
04175 hStripVsPlanePulsesEast->Fill(plane,strip,numEntries);
04176 if (mean<8000 && mean>500){
04177 hStripVsPlaneGainEast->Fill(plane,strip,gain);
04178 }
04179 }
04180 else if (stripEnd==StripEnd::kWest){
04181 hStripVsPlaneAdcWest->Fill(plane,strip,mean);
04182 hStripVsPlanePulsesWest->Fill(plane,strip,numEntries);
04183 if (mean<8000 && mean>500){
04184 hStripVsPlaneGainWest->Fill(plane,strip,gain);
04185 }
04186 }
04187 }
04188 }
04189
04190 else{
04191 MSG("LIAnalysis",Msg::kWarning)<<"Detector not defined"<<endl;
04192 }
04193 }
04194
04198
04199 MSG("LIAnalysis",Msg::kInfo)<<"Finished main loop"<<endl;
04200 MSG("LIAnalysis",Msg::kInfo)<<"Max plane="<<maxPlane<<endl;
04201
04202
04203 gStyle->SetOptStat(0);
04204 string sRunNumber=Form("%d",runNumber);
04205
04206 TCanvas *cStripVsPlaneMean=new TCanvas
04207 ("cStripVsPlaneMean","StripVsPlane: Mean",0,0,1100,800);
04208 cStripVsPlaneMean->SetFillColor(0);
04209 cStripVsPlaneMean->Divide(1,2);
04210 cStripVsPlaneMean->cd(1);
04211 hStripVsPlaneAdcEast->Draw("colz");
04212 cStripVsPlaneMean->cd(2);
04213 hStripVsPlaneAdcWest->Draw("colz");
04214 s=sRunNumber;
04215 s+="AdcNearWhole.ps";
04216 cStripVsPlaneMean->Print(s.c_str());
04217
04218 TCanvas *cStripVsPlanePulses=new TCanvas
04219 ("cStripVsPlanePulses","StripVsPlane: Pulses",0,0,1100,800);
04220 cStripVsPlanePulses->SetFillColor(0);
04221 cStripVsPlanePulses->Divide(1,2);
04222 cStripVsPlanePulses->cd(1);
04223 hStripVsPlanePulsesEast->Draw("colz");
04224 cStripVsPlanePulses->cd(2);
04225 hStripVsPlanePulsesWest->Draw("colz");
04226 s=sRunNumber;
04227 s+="NumNearWhole.ps";
04228 cStripVsPlanePulses->Print(s.c_str());
04229
04230 TCanvas *cStripVsPlaneGain=new TCanvas
04231 ("cStripVsPlaneGain","StripVsPlane: Gain",0,0,1100,800);
04232 cStripVsPlaneGain->SetFillColor(0);
04233 cStripVsPlaneGain->Divide(1,2);
04234 cStripVsPlaneGain->cd(1);
04235 hStripVsPlaneGainEast->Draw("colz");
04236 cStripVsPlaneGain->cd(2);
04237 hStripVsPlaneGainWest->Draw("colz");
04238 s=sRunNumber;
04239 s+="GainNearWhole.ps";
04240 cStripVsPlaneGain->Print(s.c_str());
04241
04242 MSG("LIAnalysis",Msg::kInfo)
04243 <<" ** Finished the StripVsPlaneWholeDet method ** "<<endl;
04244 }
04245
04246
04247
04248 void LIAnalysis::PixelVsPlane(Int_t nearPb,Int_t farPb)
04249 {
04250 MSG("LIAnalysis",Msg::kInfo)
04251 <<endl<<" ** Running the PixelVsPlane method... ** "<<endl;
04252
04253
04254 gStyle->SetOptStat(0);
04255 chain->GetEvent(0);
04256
04257 Int_t* planeMax=new Int_t[NUMPULSERBOXES];
04258 Int_t* planeMin=new Int_t[NUMPULSERBOXES];
04259 lookup.SetPbPlanes(planeMin,planeMax,detectorType);
04260
04261 Int_t minBinPix=FIRSTPIXEL-1;
04262 Int_t maxBinPix=3*NUMPIXELS+1;
04263 Int_t numBinPix=maxBinPix-minBinPix;
04264 Int_t maxPixel=NUMPMTS*NUMPIXELS;
04265
04266 MSG("LIAnalysis",Msg::kInfo)
04267 <<"Using the following settings:"<<endl
04268 <<"maxPixel="<<maxPixel
04269 <<", maxBinPix="<<maxBinPix
04270 <<", minBinPix="<<minBinPix
04271 <<", numBinPix="<<numBinPix
04272 <<", NUMPMTS="<<NUMPMTS
04273 <<", NUMPIXELS="<<NUMPIXELS
04274 <<endl;
04275
04276 TH2F *hPixelVsPlaneLedB=new TH2F(" "," ",
04277 LASTSCINTPLANE-FIRSTSCINTPLANE+2,
04278 FIRSTSCINTPLANE,LASTSCINTPLANE+1,
04279 numBinPix,minBinPix,maxBinPix);
04280
04281 TH2F **hPixelVsPlaneLed=0;
04282 hPixelVsPlaneLed= new TH2F*[NUMPULSERBOXES];
04283 for (Int_t i=0;i<NUMPULSERBOXES;i++){
04284 sprintf(histname,"Led (Pulser Box %i)",i);
04285 hPixelVsPlaneLed[i]=new TH2F
04286 (histname,histname,
04287 planeMax[i]-planeMin[i],planeMin[i],planeMax[i]
04288 ,numBinPix,minBinPix,maxBinPix);
04289 hPixelVsPlaneLed[i]->GetXaxis()->SetTitle("Plane");
04290 hPixelVsPlaneLed[i]->GetXaxis()->CenterTitle();
04291 hPixelVsPlaneLed[i]->GetYaxis()->SetTitle("Num Entries");
04292 hPixelVsPlaneLed[i]->GetYaxis()->CenterTitle();
04293 hPixelVsPlaneLed[i]->SetFillColor(0);
04294 hPixelVsPlaneLed[i]->SetBit(TH1::kCanRebin);
04295 }
04296
04297 TH2F **hPixelVsPlaneMean=0;
04298 hPixelVsPlaneMean= new TH2F*[NUMPULSERBOXES];
04299 for (Int_t i=0;i<NUMPULSERBOXES;i++){
04300 sprintf(histname,"ADC Value (Near Side, Pulser Box %i)",i);
04301 hPixelVsPlaneMean[i]=new TH2F
04302 (histname,histname,
04303 planeMax[i]-planeMin[i],planeMin[i],planeMax[i]
04304 ,numBinPix,minBinPix,maxBinPix);
04305 hPixelVsPlaneMean[i]->GetXaxis()->SetTitle("Plane");
04306 hPixelVsPlaneMean[i]->GetXaxis()->CenterTitle();
04307 hPixelVsPlaneMean[i]->GetYaxis()->SetTitle("Pixel");
04308 hPixelVsPlaneMean[i]->GetYaxis()->CenterTitle();
04309 hPixelVsPlaneMean[i]->SetFillColor(0);
04310 hPixelVsPlaneMean[i]->SetBit(TH1::kCanRebin);
04311 }
04312
04313 TH2F **hPixelVsPlaneMeanF=0;
04314 hPixelVsPlaneMeanF= new TH2F*[NUMPULSERBOXES];
04315 for (Int_t i=0;i<NUMPULSERBOXES;i++){
04316 sprintf(histname,"ADC Value (Far Side, Pulser Box %i)",i);
04317 hPixelVsPlaneMeanF[i]=new TH2F
04318 (histname,histname,
04319 planeMax[i]-planeMin[i],planeMin[i],planeMax[i]
04320 ,numBinPix,minBinPix,maxBinPix);
04321 hPixelVsPlaneMeanF[i]->GetXaxis()->SetTitle("Plane");
04322 hPixelVsPlaneMeanF[i]->GetXaxis()->CenterTitle();
04323 hPixelVsPlaneMeanF[i]->GetYaxis()->SetTitle("Pixel");
04324 hPixelVsPlaneMeanF[i]->GetYaxis()->CenterTitle();
04325 hPixelVsPlaneMeanF[i]->SetFillColor(0);
04326 hPixelVsPlaneMeanF[i]->SetBit(TH1::kCanRebin);
04327 }
04328
04329 TH2F **hPixelVsPlaneNum=0;
04330 hPixelVsPlaneNum= new TH2F*[NUMPULSERBOXES];
04331 for (Int_t i=0;i<NUMPULSERBOXES;i++){
04332 sprintf(histname,"Num (Pulser Box %i)",i);
04333 hPixelVsPlaneNum[i]=new TH2F
04334 (histname,histname,
04335 planeMax[i]-planeMin[i],planeMin[i],planeMax[i]
04336 ,numBinPix,minBinPix,maxBinPix);
04337 hPixelVsPlaneNum[i]->GetXaxis()->SetTitle("Plane");
04338 hPixelVsPlaneNum[i]->GetXaxis()->CenterTitle();
04339 hPixelVsPlaneNum[i]->GetYaxis()->SetTitle("Pixel");
04340 hPixelVsPlaneNum[i]->GetYaxis()->CenterTitle();
04341 hPixelVsPlaneNum[i]->SetFillColor(0);
04342 hPixelVsPlaneNum[i]->SetBit(TH1::kCanRebin);
04343 }
04344
04345 TH2F **hPixelVsPlanePix=0;
04346 hPixelVsPlanePix= new TH2F*[NUMPULSERBOXES];
04347 for (Int_t i=0;i<NUMPULSERBOXES;i++){
04348 sprintf(histname,"Pix (Pulser Box %i)",i);
04349 hPixelVsPlanePix[i]=new TH2F
04350 (histname,histname,
04351 planeMax[i]-planeMin[i],planeMin[i],planeMax[i]
04352 ,numBinPix,minBinPix,maxBinPix);
04353 hPixelVsPlanePix[i]->GetXaxis()->SetTitle("Plane");
04354 hPixelVsPlanePix[i]->GetXaxis()->CenterTitle();
04355 hPixelVsPlanePix[i]->GetYaxis()->SetTitle("Pixel");
04356 hPixelVsPlanePix[i]->GetYaxis()->CenterTitle();
04357 hPixelVsPlanePix[i]->SetFillColor(0);
04358 hPixelVsPlanePix[i]->SetBit(TH1::kCanRebin);
04359 }
04360
04361 TH2F **hPixelVsPlanePixF=0;
04362 hPixelVsPlanePixF= new TH2F*[NUMPULSERBOXES];
04363 for (Int_t i=0;i<NUMPULSERBOXES;i++){
04364 sprintf(histname,"PixF (Pulser Box %i)",i);
04365 hPixelVsPlanePixF[i]=new TH2F
04366 (histname,histname,
04367 planeMax[i]-planeMin[i],planeMin[i],planeMax[i]
04368 ,numBinPix,minBinPix,maxBinPix);
04369 hPixelVsPlanePixF[i]->GetXaxis()->SetTitle("Plane");
04370 hPixelVsPlanePixF[i]->GetXaxis()->CenterTitle();
04371 hPixelVsPlanePixF[i]->GetYaxis()->SetTitle("Pixel");
04372 hPixelVsPlanePixF[i]->GetYaxis()->CenterTitle();
04373 hPixelVsPlanePixF[i]->SetFillColor(0);
04374 hPixelVsPlanePixF[i]->SetBit(TH1::kCanRebin);
04375 }
04376
04377 TH2F **hPixelVsPlaneEnt=0;
04378 hPixelVsPlaneEnt= new TH2F*[NUMPULSERBOXES];
04379 for (Int_t i=0;i<NUMPULSERBOXES;i++){
04380 sprintf(histname,"Ent (Pulser Box %i, Near)",i);
04381 hPixelVsPlaneEnt[i]=new TH2F
04382 (histname,histname,
04383 planeMax[i]-planeMin[i],planeMin[i],planeMax[i]
04384 ,numBinPix,minBinPix,maxBinPix);
04385 hPixelVsPlaneEnt[i]->GetXaxis()->SetTitle("Plane");
04386 hPixelVsPlaneEnt[i]->GetXaxis()->CenterTitle();
04387 hPixelVsPlaneEnt[i]->GetYaxis()->SetTitle("Pixel");
04388 hPixelVsPlaneEnt[i]->GetYaxis()->CenterTitle();
04389 hPixelVsPlaneEnt[i]->SetFillColor(0);
04390 hPixelVsPlaneEnt[i]->SetBit(TH1::kCanRebin);
04391 }
04392
04393 TH2F **hPixelVsPlaneEntF=0;
04394 hPixelVsPlaneEntF= new TH2F*[NUMPULSERBOXES];
04395 for (Int_t i=0;i<NUMPULSERBOXES;i++){
04396 sprintf(histname,"EntF (Pulser Box %i, Far)",i);
04397 hPixelVsPlaneEntF[i]=new TH2F
04398 (histname,histname,
04399 planeMax[i]-planeMin[i],planeMin[i],planeMax[i]
04400 ,numBinPix,minBinPix,maxBinPix);
04401 hPixelVsPlaneEntF[i]->GetXaxis()->SetTitle("Plane");
04402 hPixelVsPlaneEntF[i]->GetXaxis()->CenterTitle();
04403 hPixelVsPlaneEntF[i]->GetYaxis()->SetTitle("Pixel");
04404 hPixelVsPlaneEntF[i]->GetYaxis()->CenterTitle();
04405 hPixelVsPlaneEntF[i]->SetFillColor(0);
04406 hPixelVsPlaneEntF[i]->SetBit(TH1::kCanRebin);
04407 }
04408
04409
04411 TH2F **hPixelVsPlaneMeanNoise=0;
04412 hPixelVsPlaneMeanNoise= new TH2F*[NUMPULSERBOXES];
04413 for (Int_t i=0;i<NUMPULSERBOXES;i++){
04414 sprintf(histname,"ADC (Noise, Pulser Box %i flashing)",i);
04415 hPixelVsPlaneMeanNoise[i]=new TH2F
04416 (histname,histname,
04417 LASTSCINTPLANE-FIRSTSCINTPLANE,FIRSTSCINTPLANE,LASTSCINTPLANE
04418 ,numBinPix,minBinPix,maxBinPix);
04419 hPixelVsPlaneMeanNoise[i]->GetXaxis()->SetTitle("Plane");
04420 hPixelVsPlaneMeanNoise[i]->GetXaxis()->CenterTitle();
04421 hPixelVsPlaneMeanNoise[i]->GetYaxis()->SetTitle("Pixel");
04422 hPixelVsPlaneMeanNoise[i]->GetYaxis()->CenterTitle();
04423 hPixelVsPlaneMeanNoise[i]->SetFillColor(0);
04424 hPixelVsPlaneMeanNoise[i]->SetBit(TH1::kCanRebin);
04425 }
04426
04427 TH2F **hPixelVsPlaneEntNoise=0;
04428 hPixelVsPlaneEntNoise= new TH2F*[NUMPULSERBOXES];
04429 for (Int_t i=0;i<NUMPULSERBOXES;i++){
04430 sprintf(histname,"Ent (Noise, Pulser Box %i, Near)",i);
04431 hPixelVsPlaneEntNoise[i]=new TH2F
04432 (histname,histname,
04433 LASTSCINTPLANE-FIRSTSCINTPLANE,FIRSTSCINTPLANE,LASTSCINTPLANE
04434 ,numBinPix,minBinPix,maxBinPix);
04435 hPixelVsPlaneEntNoise[i]->GetXaxis()->SetTitle("Plane");
04436 hPixelVsPlaneEntNoise[i]->GetXaxis()->CenterTitle();
04437 hPixelVsPlaneEntNoise[i]->GetYaxis()->SetTitle("Pixel");
04438 hPixelVsPlaneEntNoise[i]->GetYaxis()->CenterTitle();
04439 hPixelVsPlaneEntNoise[i]->SetFillColor(0);
04440 hPixelVsPlaneEntNoise[i]->SetBit(TH1::kCanRebin);
04441 }
04442
04443 TH2F **hPixelVsPlaneMeanNoiseE=0;
04444 hPixelVsPlaneMeanNoiseE= new TH2F*[NUMPULSERBOXES];
04445 for (Int_t i=0;i<NUMPULSERBOXES;i++){
04446 sprintf(histname,"ADC (Noise East Side, Pulser Box %i flashing)",i);
04447 hPixelVsPlaneMeanNoiseE[i]=new TH2F
04448 (histname,histname,
04449 LASTSCINTPLANE-FIRSTSCINTPLANE,FIRSTSCINTPLANE,LASTSCINTPLANE
04450 ,numBinPix,minBinPix,maxBinPix);
04451 hPixelVsPlaneMeanNoiseE[i]->GetXaxis()->SetTitle("Plane");
04452 hPixelVsPlaneMeanNoiseE[i]->GetXaxis()->CenterTitle();
04453 hPixelVsPlaneMeanNoiseE[i]->GetYaxis()->SetTitle("Pixel");
04454 hPixelVsPlaneMeanNoiseE[i]->GetYaxis()->CenterTitle();
04455 hPixelVsPlaneMeanNoiseE[i]->SetFillColor(0);
04456 hPixelVsPlaneMeanNoiseE[i]->SetBit(TH1::kCanRebin);
04457 }
04458
04459 TH2F **hPixelVsPlaneEntNoiseE=0;
04460 hPixelVsPlaneEntNoiseE= new TH2F*[NUMPULSERBOXES];
04461 for (Int_t i=0;i<NUMPULSERBOXES;i++){
04462 sprintf(histname,"Ent (Noise East Side, Pulser Box %i, Near)",i);
04463 hPixelVsPlaneEntNoiseE[i]=new TH2F
04464 (histname,histname,
04465 LASTSCINTPLANE-FIRSTSCINTPLANE,FIRSTSCINTPLANE,LASTSCINTPLANE
04466 ,numBinPix,minBinPix,maxBinPix);
04467 hPixelVsPlaneEntNoiseE[i]->GetXaxis()->SetTitle("Plane");
04468 hPixelVsPlaneEntNoiseE[i]->GetXaxis()->CenterTitle();
04469 hPixelVsPlaneEntNoiseE[i]->GetYaxis()->SetTitle("Pixel");
04470 hPixelVsPlaneEntNoiseE[i]->GetYaxis()->CenterTitle();
04471 hPixelVsPlaneEntNoiseE[i]->SetFillColor(0);
04472 hPixelVsPlaneEntNoiseE[i]->SetBit(TH1::kCanRebin);
04473 }
04474
04475 TH2F **hPixelVsPlaneMeanNoiseW=0;
04476 hPixelVsPlaneMeanNoiseW= new TH2F*[NUMPULSERBOXES];
04477 for (Int_t i=0;i<NUMPULSERBOXES;i++){
04478 sprintf(histname,"ADC (Noise West Side, Pulser Box %i flashing)",i);
04479 hPixelVsPlaneMeanNoiseW[i]=new TH2F
04480 (histname,histname,
04481 LASTSCINTPLANE-FIRSTSCINTPLANE,FIRSTSCINTPLANE,LASTSCINTPLANE
04482 ,numBinPix,minBinPix,maxBinPix);
04483 hPixelVsPlaneMeanNoiseW[i]->GetXaxis()->SetTitle("Plane");
04484 hPixelVsPlaneMeanNoiseW[i]->GetXaxis()->CenterTitle();
04485 hPixelVsPlaneMeanNoiseW[i]->GetYaxis()->SetTitle("Pixel");
04486 hPixelVsPlaneMeanNoiseW[i]->GetYaxis()->CenterTitle();
04487 hPixelVsPlaneMeanNoiseW[i]->SetFillColor(0);
04488 hPixelVsPlaneMeanNoiseW[i]->SetBit(TH1::kCanRebin);
04489 }
04490
04491 TH2F **hPixelVsPlaneEntNoiseW=0;
04492 hPixelVsPlaneEntNoiseW= new TH2F*[NUMPULSERBOXES];
04493 for (Int_t i=0;i<NUMPULSERBOXES;i++){
04494 sprintf(histname,"Ent (Noise West Side, Pulser Box %i, Near)",i);
04495 hPixelVsPlaneEntNoiseW[i]=new TH2F
04496 (histname,histname,
04497 LASTSCINTPLANE-FIRSTSCINTPLANE,FIRSTSCINTPLANE,LASTSCINTPLANE
04498 ,numBinPix,minBinPix,maxBinPix);
04499 hPixelVsPlaneEntNoiseW[i]->GetXaxis()->SetTitle("Plane");
04500 hPixelVsPlaneEntNoiseW[i]->GetXaxis()->CenterTitle();
04501 hPixelVsPlaneEntNoiseW[i]->GetYaxis()->SetTitle("Pixel");
04502 hPixelVsPlaneEntNoiseW[i]->GetYaxis()->CenterTitle();
04503 hPixelVsPlaneEntNoiseW[i]->SetFillColor(0);
04504 hPixelVsPlaneEntNoiseW[i]->SetBit(TH1::kCanRebin);
04505 }
04507
04508 Float_t* noiseCharge=new Float_t[NUMPULSERBOXES];
04509 for (Int_t i=0;i<NUMPULSERBOXES;i++){
04510 noiseCharge[i]=0;
04511 }
04512
04516
04517 this->InitialiseLoopVariables();
04518
04519 for(Int_t entry=0;entry<numEvents;entry++){
04520
04521 this->SetLoopVariables(entry,0);
04522
04523
04524 if (rms==0. || mean==0. || numEntries==0) continue;
04525
04526 if (readoutType!=ReadoutType::kScintStrip) continue;
04527
04528
04529 Int_t pmt=lookup.Chip2Pmt(chip,detectorType);
04530 pixel=pmt*NUMPIXELS+pixel;
04531
04532
04533 if (pulserBox>=FIRSTPULSERBOX && pulserBox<=LASTPULSERBOX &&
04534 correlatedHit!=1 && ashtray<1 &&
04535 pulserBox!=nearPulserBox && pulserBox!=farPulserBox &&
04536 pixel<maxPixel && pixel>=FIRSTPIXEL &&
04537 plane>=FIRSTSCINTPLANE && plane<=LASTSCINTPLANE
04538 ){
04539 MSG("LIAnalysis",Msg::kVerbose)
04540 <<"mean="<<mean<<", pl="<<plane<<", pix="<<pixel<<endl;
04541
04542 hPixelVsPlaneMeanNoise[pulserBox]->Fill(plane,pixel,mean);
04543 hPixelVsPlaneEntNoise[pulserBox]->Fill(plane,pixel,1);
04544
04545
04546 noiseCharge[pulserBox]+=mean;
04547
04548 if (crate%2==0){
04549 hPixelVsPlaneMeanNoiseE[pulserBox]->Fill(plane,pixel,mean);
04550 hPixelVsPlaneEntNoiseE[pulserBox]->Fill(plane,pixel,1);
04551 }
04552
04553 else{
04554 hPixelVsPlaneMeanNoiseW[pulserBox]->Fill(plane,pixel,mean);
04555 hPixelVsPlaneEntNoiseW[pulserBox]->Fill(plane,pixel,1);
04556 }
04557 }
04558
04559
04560 if (pulserBox>=FIRSTPULSERBOX && pulserBox<=LASTPULSERBOX &&
04561 correlatedHit!=1 && pulserBox!=crate &&
04562 pulserBox==farPulserBox &&
04563 pixel<maxPixel && pixel>=FIRSTPIXEL &&
04564 plane>=FIRSTSCINTPLANE && plane<=LASTSCINTPLANE
04565 ){
04566 hPixelVsPlaneMeanF[pulserBox]->Fill(plane,pixel,mean);
04567 hPixelVsPlaneEntF[pulserBox]->Fill(plane,pixel,1);
04568 hPixelVsPlanePixF[pulserBox]->Fill(plane,pixel,pixel+1);
04569 }
04570
04571
04572 if (pulserBox>=FIRSTPULSERBOX && pulserBox<=LASTPULSERBOX &&
04573 correlatedHit!=1 && pulserBox==crate &&
04574 pixel<maxPixel && pixel>=FIRSTPIXEL &&
04575 plane>=FIRSTSCINTPLANE && plane<=LASTSCINTPLANE &&
04576 pulserBox==nearPulserBox
04577 ){
04578 hPixelVsPlaneLed[pulserBox]->Fill(plane,pixel,nearLed);
04579 hPixelVsPlaneMean[pulserBox]->Fill(plane,pixel,mean);
04580 hPixelVsPlaneNum[pulserBox]->Fill(plane,pixel,numEntries);
04581 hPixelVsPlanePix[pulserBox]->Fill(plane,pixel,pixel+1);
04582 hPixelVsPlaneEnt[pulserBox]->Fill(plane,pixel,1);
04583
04584 MSG("LIAnalysis",Msg::kVerbose)
04585 <<"mean="<<mean
04586 <<", rms="<<rms
04587 <<", npe="<<pow(mean/rms,2)
04588 <<", gain="<<mean/pow(mean/rms,2)
04589 <<endl;
04590 }
04591 }
04592
04596
04597 MSG("LIAnalysis",Msg::kInfo)<<"Finished main loop"<<endl;
04598
04599 string sRunNumber=Form("%d",runNumber);
04600
04601 Float_t maxMean=0;
04602 Float_t maxMeanF=0;
04603 Float_t maxMeanNoise=0;
04604
04605
04606 for (Int_t pb=FIRSTPULSERBOX;pb<=LASTPULSERBOX;pb++){
04607 for (Int_t pl=FIRSTSCINTPLANE;pl<=LASTSCINTPLANE;pl++){
04608 for (Int_t pix=minBinPix;pix<=maxBinPix;pix++){
04609
04610 if (hPixelVsPlaneEntNoise[pb]->GetBinContent(pl,pix)>0){
04611 MSG("LIAnalysis",Msg::kVerbose)
04612 <<"Weighting before"<<", pl="<<pl<<", pix="<<pix
04613 <<", mean="
04614 <<hPixelVsPlaneEntNoise[pb]->GetBinContent(pl,pix)
04615 <<", ent="
04616 <<hPixelVsPlaneEntNoise[pb]->GetBinContent(pl,pix)
04617 <<endl;
04618
04619 hPixelVsPlaneMeanNoise[pb]->SetBinContent
04620 (pl,pix,hPixelVsPlaneMeanNoise[pb]->GetBinContent(pl,pix)/
04621 hPixelVsPlaneEntNoise[pb]->GetBinContent(pl,pix));
04622
04623 MSG("LIAnalysis",Msg::kVerbose)
04624 <<"Weighting after"<<", pl="<<pl<<", pix="<<pix
04625 <<", mean="
04626 <<hPixelVsPlaneEntNoise[pb]->GetBinContent(pl,pix)
04627 <<", ent="
04628 <<hPixelVsPlaneEntNoise[pb]->GetBinContent(pl,pix)
04629 <<endl;
04630
04631 if (hPixelVsPlaneMeanNoise[pb]->
04632 GetBinContent(pl,pix)>maxMeanNoise){
04633 maxMeanNoise=static_cast<Float_t>
04634 (hPixelVsPlaneMeanNoise[pb]->GetBinContent(pl,pix));
04635 }
04636 }
04637
04638 if (hPixelVsPlaneEntNoiseE[pb]->GetBinContent(pl,pix)>0){
04639
04640 hPixelVsPlaneMeanNoiseE[pb]->SetBinContent
04641 (pl,pix,hPixelVsPlaneMeanNoiseE[pb]->GetBinContent(pl,pix)/
04642 hPixelVsPlaneEntNoiseE[pb]->GetBinContent(pl,pix));
04643 }
04644
04645 if (hPixelVsPlaneEntNoiseW[pb]->GetBinContent(pl,pix)>0){
04646
04647 hPixelVsPlaneMeanNoiseW[pb]->SetBinContent
04648 (pl,pix,hPixelVsPlaneMeanNoiseW[pb]->GetBinContent(pl,pix)/
04649 hPixelVsPlaneEntNoiseW[pb]->GetBinContent(pl,pix));
04650 }
04651 }
04652 }
04653 }
04654
04655
04656 for (Int_t pb=FIRSTPULSERBOX;pb<=LASTPULSERBOX;pb++){
04657 for (Int_t pl=planeMin[pb];pl<=planeMax[pb];pl++){
04658 for (Int_t pix=minBinPix;pix<=maxBinPix;pix++){
04659
04660 if (hPixelVsPlaneEnt[pb]->GetBinContent(pl,pix)>0){
04661
04662 hPixelVsPlaneMean[pb]->SetBinContent
04663 (pl,pix,hPixelVsPlaneMean[pb]->GetBinContent(pl,pix)/
04664 hPixelVsPlaneEnt[pb]->GetBinContent(pl,pix));
04665
04666 if (hPixelVsPlaneMean[pb]->GetBinContent(pl,pix)>maxMean){
04667 maxMean=static_cast<Float_t>
04668 (hPixelVsPlaneMean[pb]->GetBinContent(pl,pix));
04669 }
04670 }
04671
04672 if (hPixelVsPlaneEntF[pb]->GetBinContent(pl,pix)>0){
04673
04674 hPixelVsPlaneMeanF[pb]->SetBinContent
04675 (pl,pix,hPixelVsPlaneMeanF[pb]->GetBinContent(pl,pix)/
04676 hPixelVsPlaneEntF[pb]->GetBinContent(pl,pix));
04677
04678 if (hPixelVsPlaneMeanF[pb]->GetBinContent(pl,pix)>maxMeanF){
04679 maxMeanF=static_cast<Float_t>
04680 (hPixelVsPlaneMeanF[pb]->GetBinContent(pl,pix));
04681 }
04682 }
04683 }
04684 }
04685 }
04686
04687 MSG("LIAnalysis",Msg::kInfo)
04688 <<"Before setting ceiling, maxMean="<<maxMean
04689 <<", maxMeanF="<<maxMeanF
04690 <<", maxMeanNoise="<<maxMeanNoise
04691 <<endl;
04692
04693 if (maxMean>6000) maxMean=6000;
04694 if (maxMeanF>2000) maxMeanF=2000;
04695 if (maxMeanNoise>15000) maxMeanNoise=15000;
04696
04697 for (Int_t pb=FIRSTPULSERBOX;pb<=LASTPULSERBOX;pb++){
04698 hPixelVsPlaneMean[pb]->SetMaximum(maxMean);
04699 hPixelVsPlaneMeanF[pb]->SetMaximum(maxMeanF);
04700 hPixelVsPlaneMeanNoise[pb]->SetMaximum(maxMeanNoise);
04701
04702 hPixelVsPlaneMeanNoiseE[pb]->SetMaximum(maxMeanNoise);
04703 hPixelVsPlaneMeanNoiseW[pb]->SetMaximum(maxMeanNoise);
04704 }
04705 MSG("LIAnalysis",Msg::kInfo)
04706 <<"After setting ceiling, maxMean="<<maxMean
04707 <<", maxMeanF="<<maxMeanF
04708 <<", maxMeanNoise="<<maxMeanNoise
04709 <<endl;
04710
04711 TCanvas *cPixelVsPlaneMean=new TCanvas
04712 ("cPixelVsPlaneMean","PixelVsPlane: Mean",0,0,1000,800);
04713 cPixelVsPlaneMean->SetFillColor(0);
04714 cPixelVsPlaneMean->cd();
04715 for (Int_t i=0;i<NUMPULSERBOXES;i++){
04716 cPixelVsPlaneMean->Clear();
04717 hPixelVsPlaneMean[i]->Draw("colz");
04718 if (i==0){
04719 s=sRunNumber+"AdcNearPixel.ps(";
04720 cPixelVsPlaneMean->Print(s.c_str());
04721 }
04722 else if(i==NUMPULSERBOXES-1){
04723 s=sRunNumber+"AdcNearPixel.ps)";
04724 cPixelVsPlaneMean->Print(s.c_str());
04725 }
04726 else{
04727 s=sRunNumber+"AdcNearPixel.ps";
04728 cPixelVsPlaneMean->Print(s.c_str());
04729 }
04730 }
04731
04732 cPixelVsPlaneMean->Clear();
04733 hPixelVsPlaneMean[nearPb]->Draw("colz");
04734
04735
04736 TCanvas *cPixelVsPlaneMeanF=new TCanvas
04737 ("cPixelVsPlaneMeanF","PixelVsPlane: MeanF",0,0,1000,800);
04738 cPixelVsPlaneMeanF->SetFillColor(0);
04739 cPixelVsPlaneMeanF->cd();
04740 for (Int_t i=0;i<NUMPULSERBOXES;i++){
04741 cPixelVsPlaneMeanF->Clear();
04742 hPixelVsPlaneMeanF[i]->Draw("colz");
04743 if (i==0){
04744 s=sRunNumber+"AdcFarPixel.ps(";
04745 cPixelVsPlaneMeanF->Print(s.c_str());
04746 }
04747 else if(i==NUMPULSERBOXES-1){
04748 s=sRunNumber+"AdcFarPixel.ps)";
04749 cPixelVsPlaneMeanF->Print(s.c_str());
04750 }
04751 else{
04752 s=sRunNumber+"AdcFarPixel.ps";
04753 cPixelVsPlaneMeanF->Print(s.c_str());
04754 }
04755 }
04756
04757 cPixelVsPlaneMeanF->Clear();
04758 hPixelVsPlaneMeanF[farPb]->Draw("colz");
04759
04760
04761
04762 TCanvas *cPixelVsPlaneMeanNoise=new TCanvas
04763 ("cPixelVsPlaneMeanNoise","PixelVsPlane: Mean (Noise)",
04764 0,0,1000,800);
04765 cPixelVsPlaneMeanNoise->SetFillColor(0);
04766 cPixelVsPlaneMeanNoise->cd();
04767 for (Int_t i=0;i<NUMPULSERBOXES;i++){
04768 cPixelVsPlaneMeanNoise->Clear();
04769 hPixelVsPlaneMeanNoise[i]->Draw("colz");
04770 if (i==0){
04771 s=sRunNumber+"AdcPixelNoise.ps(";
04772 cPixelVsPlaneMeanNoise->Print(s.c_str());
04773 }
04774 else if(i==NUMPULSERBOXES-1){
04775 s=sRunNumber+"AdcPixelNoise.ps)";
04776 cPixelVsPlaneMeanNoise->Print(s.c_str());
04777 }
04778 else{
04779 s=sRunNumber+"AdcPixelNoise.ps";
04780 cPixelVsPlaneMeanNoise->Print(s.c_str());
04781 }
04782 }
04783
04784 cPixelVsPlaneMeanNoise->Clear();
04785 hPixelVsPlaneMeanNoise[nearPb]->Draw("colz");
04786
04787
04788
04789 TCanvas *cPixelVsPlaneMeanNoiseE=new TCanvas
04790 ("cPixelVsPlaneMeanNoiseE","PixelVsPlane: Mean (NoiseE)",
04791 0,0,1000,800);
04792 cPixelVsPlaneMeanNoiseE->SetFillColor(0);
04793 cPixelVsPlaneMeanNoiseE->cd();
04794 for (Int_t i=0;i<NUMPULSERBOXES;i++){
04795 cPixelVsPlaneMeanNoiseE->Clear();
04796 hPixelVsPlaneMeanNoiseE[i]->Draw("colz");
04797 if (i==0){
04798 s=sRunNumber+"AdcPixelNoiseE.ps(";
04799 cPixelVsPlaneMeanNoiseE->Print(s.c_str());
04800 }
04801 else if(i==NUMPULSERBOXES-1){
04802 s=sRunNumber+"AdcPixelNoiseE.ps)";
04803 cPixelVsPlaneMeanNoiseE->Print(s.c_str());
04804 }
04805 else{
04806 s=sRunNumber+"AdcPixelNoiseE.ps";
04807 cPixelVsPlaneMeanNoiseE->Print(s.c_str());
04808 }
04809 }
04810
04811 cPixelVsPlaneMeanNoiseE->Clear();
04812 hPixelVsPlaneMeanNoiseE[nearPb]->Draw("colz");
04813
04814
04815
04816 TCanvas *cPixelVsPlaneMeanNoiseW=new TCanvas
04817 ("cPixelVsPlaneMeanNoiseW","PixelVsPlane: Mean (NoiseW)",
04818 0,0,1000,800);
04819 cPixelVsPlaneMeanNoiseW->SetFillColor(0);
04820 cPixelVsPlaneMeanNoiseW->cd();
04821 for (Int_t i=0;i<NUMPULSERBOXES;i++){
04822 cPixelVsPlaneMeanNoiseW->Clear();
04823 hPixelVsPlaneMeanNoiseW[i]->Draw("colz");
04824 if (i==0){
04825 s=sRunNumber+"AdcPixelNoiseW.ps(";
04826 cPixelVsPlaneMeanNoiseW->Print(s.c_str());
04827 }
04828 else if(i==NUMPULSERBOXES-1){
04829 s=sRunNumber+"AdcPixelNoiseW.ps)";
04830 cPixelVsPlaneMeanNoiseW->Print(s.c_str());
04831 }
04832 else{
04833 s=sRunNumber+"AdcPixelNoiseW.ps";
04834 cPixelVsPlaneMeanNoiseW->Print(s.c_str());
04835 }
04836 }
04837
04838 cPixelVsPlaneMeanNoiseW->Clear();
04839 hPixelVsPlaneMeanNoiseW[nearPb]->Draw("colz");
04840
04841
04842 TCanvas *cPixelVsPlaneEntEast=new TCanvas
04843 ("cPixelVsPlaneEntEast","PixelVsPlane: East Side (Near)"
04844 ,0,0,1200,800);
04845 cPixelVsPlaneEntEast->SetFillColor(0);
04846 cPixelVsPlaneEntEast->cd();
04847 hPixelVsPlaneLedB->SetTitle("East Side (Near)");
04848 hPixelVsPlaneLedB->Draw();
04849 for (Int_t i=0;i<NUMPULSERBOXES;i+=2){
04850 hPixelVsPlaneEnt[i]->Draw("samecolz");
04851 }
04852 s=sRunNumber+"EastNearPixel.eps";
04853 cPixelVsPlaneEntEast->Print(s.c_str());
04854 delete cPixelVsPlaneEntEast;
04855
04856 TCanvas *cPixelVsPlaneEntWest=new TCanvas
04857 ("cPixelVsPlaneEntWest","PixelVsPlane: West Side (Near)"
04858 ,0,0,1200,800);
04859 cPixelVsPlaneEntWest->SetFillColor(0);
04860 cPixelVsPlaneEntWest->cd();
04861 hPixelVsPlaneLedB->SetTitle("West Side (Near)");
04862 hPixelVsPlaneLedB->Draw();
04863 for (Int_t i=1;i<NUMPULSERBOXES;i+=2){
04864 hPixelVsPlaneEnt[i]->Draw("samecolz");
04865 }
04866 s=sRunNumber+"WestNearPixel.eps";
04867 cPixelVsPlaneEntWest->Print(s.c_str());
04868 delete cPixelVsPlaneEntWest;
04869
04870 TCanvas *cPixelVsPlaneEntWestF=new TCanvas
04871 ("cPixelVsPlaneEntWestF","PixelVsPlane: West Side (Far)"
04872 ,0,0,1200,800);
04873 cPixelVsPlaneEntWestF->SetFillColor(0);
04874 cPixelVsPlaneEntWestF->cd();
04875 hPixelVsPlaneLedB->SetTitle("West Side (Far)");
04876 hPixelVsPlaneLedB->Draw();
04877 for (Int_t i=0;i<NUMPULSERBOXES;i+=2){
04878 hPixelVsPlaneEntF[i]->Draw("samecolz");
04879 }
04880 s=sRunNumber+"WestFarPixel.eps";
04881 cPixelVsPlaneEntWestF->Print(s.c_str());
04882 delete cPixelVsPlaneEntWestF;
04883
04884 TCanvas *cPixelVsPlaneEntEastF=new TCanvas
04885 ("cPixelVsPlaneEntEastF","PixelVsPlane: East Side (Far)"
04886 ,0,0,1200,800);
04887 cPixelVsPlaneEntEastF->SetFillColor(0);
04888 cPixelVsPlaneEntEastF->cd();
04889 hPixelVsPlaneLedB->SetTitle("East Side (Far)");
04890 hPixelVsPlaneLedB->Draw();
04891 for (Int_t i=1;i<NUMPULSERBOXES;i+=2){
04892 hPixelVsPlaneEntF[i]->Draw("samecolz");
04893 }
04894 s=sRunNumber+"EastFarPixel.eps";
04895 cPixelVsPlaneEntEastF->Print(s.c_str());
04896 delete cPixelVsPlaneEntEastF;
04897
04898
04899 MSG("LIAnalysis",Msg::kInfo)
04900 <<endl
04901 <<" ** Summed charge in crates away from pulser box that "
04902 <<"was flashing **"<<endl;
04903 for (Int_t i=0;i<NUMPULSERBOXES;i++){
04904 MSG("LIAnalysis",Msg::kInfo)
04905 <<"Pulser Box "<<i<<" has charge "<<noiseCharge[i]<<endl;
04906 }
04907 MSG("LIAnalysis",Msg::kInfo)
04908 <<" ** End of summed charge **"<<endl;
04909
04910 MSG("LIAnalysis",Msg::kInfo)
04911 <<" ** Finished the PixelVsPlane method ** "<<endl;
04912 }
04913
04914
04915
04916 void LIAnalysis::AshtrayVsPlane(Int_t nearPb,Int_t farPb)
04917 {
04918
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
05073 if (rms==0. || mean==0. || numEntries==0) continue;
05074
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 }
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
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
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
05152 for (Int_t pb=FIRSTPULSERBOX;pb<=LASTPULSERBOX;pb++){
05153
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
05161
05162
05163
05164
05165
05166
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
05189 cAshtrayVsPlaneMean->Clear();
05190 hAshtrayVsPlaneMean[nearPb]->Draw("colz");
05191
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
05214 cAshtrayVsPlaneMeanF->Clear();
05215 hAshtrayVsPlaneMeanF[farPb]->Draw("colz");
05216
05217
05218
05219
05220
05221
05222
05223
05224
05225
05226
05227
05228
05229
05230
05231
05232
05233
05234
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 }
05291
05292
05293
05294 void LIAnalysis::MiswiringSearch(Int_t adcThreshold)
05295 {
05296 MSG("LIAnalysis",Msg::kInfo)
05297 <<endl<<" ** Running the MiswiringSearch method... ** "<<endl;
05298
05299 Int_t lastPb=-1;
05300 Int_t lastL=-1;
05301
05305
05306 this->InitialiseLoopVariables();
05307
05308 for(Int_t entry=0;entry<numEvents;entry++){
05309
05310 this->SetLoopVariables(entry,0);
05311
05312
05313 if (rms==0. || mean==0. || numEntries==0) continue;
05314
05315 if (readoutType!=ReadoutType::kScintStrip) continue;
05316
05317 if (mean>adcThreshold && correlatedHit==0){
05318 if (pulserBox==lastPb && led==lastL){
05319 MSG("LIAnalysis",Msg::kInfo)
05320 <<" Same PB and LED"
05321 <<", pix="<<pixel
05322 <<", chip="<<chip
05323 <<", numEnt="<<numEntries
05324 <<", mean="<<mean<<endl;
05325 }
05326 else{
05327 MSG("LIAnalysis",Msg::kInfo)
05328 <<"Potential mis-wiring:"
05329 <<" cr="<<crate
05330 <<", pl="<<plane
05331 <<", pb="<<pulserBox
05332 <<", led="<<led
05333 <<", ash="<<lookup.Led2Ashtray(led,plane,detectorType)
05334 <<", pix="<<pixel
05335 <<", chip="<<chip
05336 <<", numEnt="<<numEntries
05337 <<", mean="<<mean
05338 <<endl;
05339 }
05340 lastL=led;
05341 lastPb=pulserBox;
05342 }
05343 }
05344
05348
05349 MSG("LIAnalysis",Msg::kInfo)<<"Finished main loop"<<endl;
05350
05351 MSG("LIAnalysis",Msg::kInfo)
05352 <<" ** Finished the MiswiringSearch method ** "<<endl;
05353
05354 }
05355
05356
05357
05358 void LIAnalysis::HighGainSearch(Int_t maxAdcThreshold,
05359 Float_t gainThreshold)
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
05380 if (rms==0. || mean==0. || numEntries==0) continue;
05381
05382 if (readoutType!=ReadoutType::kScintStrip) continue;
05383
05384 Float_t gain=0.8*rms*rms/mean;
05385
05386
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 }
05434
05438
05439 MSG("LIAnalysis",Msg::kInfo)<<"Finished main loop"<<endl;
05440
05441 MSG("LIAnalysis",Msg::kInfo)
05442 <<" ** Finished the HighGainSearch method ** "<<endl;
05443 }
05444
05445
05446
05447 void LIAnalysis::AdcVsPixel(Int_t pl,Int_t ashtrayMin,
05448 Int_t ashtrayMax,Int_t l)
05449 {
05450 MSG("LIAnalysis",Msg::kInfo)
05451 <<endl<<" ** Running the AdcVsPixel method... ** "<<endl;
05452
05453
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
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
05513 if (rms==0 || mean==0 || numEntries==0) continue;
05514
05515 if (readoutType!=ReadoutType::kScintStrip) continue;
05516
05517 if (plane==pl && (crate==cr || crate==crOpp)){
05518
05519
05520 if (ashtray>=ashtrayMin && ashtray<=ashtrayMax){
05521 if (correlatedHit==1){
05522
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
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){
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){
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
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
05572
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
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){
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){
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 }
05631
05635
05636 MSG("LIAnalysis",Msg::kInfo)<<"Finished main loop"<<endl;
05637
05638
05639 gStyle->SetOptStat(0);
05640
05641
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
05669
05670
05671
05672 for (Int_t i=0;i<NUMCHIPS;i++){
05673 cAdcVsPixel->cd(i+6+1);
05674 (hAdcVsPixel[crOpp])[i]->Draw("colz");
05675 }
05676
05677
05678
05679
05680
05681
05682
05683
05684
05685
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 }
05706
05707
05708
05709 void LIAnalysis::AdcVsChannel(Int_t pl, Int_t cr)
05710 {
05711
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
05742 if (rms==0. || mean==0. || numEntries==0) continue;
05743
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 }
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 }
05803
05804
05805
05806 void LIAnalysis::IndividualChannels()
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
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
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
05869 if (rms==0. || mean==0. || numEntries==0){
05870 continue;
05871 }
05872
05873
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
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
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
05926 }
05927 }
05928 }
05929 }
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
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
05963 for (Int_t ch=0;ch<numDetChan;ch++){
05964 for (Int_t i=0;i<numLiRuns;i++){
05965
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 }
05975
05976
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
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
06009
06010
06011
06012 }
06013 }
06014
06015 MSG("LIAnalysis",Msg::kInfo)<<"Plotting..."<<endl;
06016
06017
06018
06019
06020
06021
06022
06023
06024
06025
06026
06027
06028
06029
06030
06031
06032
06033
06034
06035
06036
06037
06038
06039
06040
06041
06042
06043
06044
06045
06046
06047
06048
06049
06050
06051
06052
06053
06054
06055
06056
06057
06058
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
06079
06080
06081
06082
06083
06084
06085
06086
06087
06088
06089
06090
06091
06092
06093
06094
06095
06096
06097
06098
06099
06100
06101
06102
06103 c107->Modified();
06104
06106
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
06120
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
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
06180
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
06233 counterL[(channelLed[ch]-1)]++;
06234
06235
06236
06237
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
06304
06305
06306
06307
06308
06309
06310
06311 c107->cd(1);
06312 gMeanL[i]->Draw("P");
06313
06314
06315
06316
06317
06318
06319
06320 sprintf(histname," LED %i",i+1);
06321 legend2->AddEntry(gResidualL[i],histname,"p");
06322 }
06323
06324
06325
06326
06327
06328
06329
06330
06331
06332
06333
06334
06335
06336 c107->cd(1);
06337 legend2->Draw();
06338
06339
06340
06341
06342
06343
06344
06345 MSG("LIAnalysis",Msg::kInfo)
06346 <<" ** Finished the IndividualChannels method ** "<<endl;
06347 }
06348
06349
06350
06351 void LIAnalysis::AdcDistribution()
06352 {
06353 MSG("LIAnalysis",Msg::kInfo)
06354 <<endl<<" ** Running the AdcDistribution method... ** "<<endl;
06355
06356
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
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
06428 pulseHeights[i]=-1;
06429
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
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
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
06471 }
06472
06473
06474 TH1F **hAdcPb=0;
06475 hAdcPb= new TH1F*[NUMPULSERBOXES];
06476 for (Int_t i=0;i<NUMPULSERBOXES;i++){
06477
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
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
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
06519 }
06520
06521
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
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
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
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
06568 }
06569
06573
06574 this->InitialiseLoopVariables();
06575
06576 for(Int_t entry=0;entry<numEvents;entry++){
06577
06578 this->SetLoopVariables(entry,0);
06579
06580
06581 if (rms==0. || mean==0. || numEntries==0) continue;
06582
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
06601 if (calibPoint>0 && calibPoint<=const_numCalibPoints){
06602 pulseHeights[calibPoint-1]=pulseHeight;
06603 hAdcPh[calibPoint-1]->Fill(mean);
06604 }
06605
06606
06607 if (pulserBox>=FIRSTPULSERBOX && pulserBox<=LASTPULSERBOX){
06608 hAdcPb[pulserBox]->Fill(mean);
06609 }
06610
06611
06612 if (pulseWidth>=1 && pulseWidth<=const_numPulseWidths){
06613 hAdcPw[pulseWidth-1]->Fill(mean);
06614 }
06615
06616
06617 hMeanCorrelated->Fill(mean);
06618
06619
06620 if (nearPulserBox==pulserBox) {
06621
06622 if (calibPoint>0 && calibPoint<=const_numCalibPoints){
06623 hAdcPhNearPb[calibPoint-1]->Fill(mean);
06624 }
06625
06626
06627 if (pulserBox>=FIRSTPULSERBOX && pulserBox<=LASTPULSERBOX){
06628 hAdcPbNearPb[pulserBox]->Fill(mean);
06629 }
06630
06631
06632 if (pulseWidth>=1 && pulseWidth<=const_numPulseWidths){
06633 hAdcPwNearPb[pulseWidth-1]->Fill(mean);
06634 }
06635
06636 hMeanNearPb->Fill(mean);
06637 }
06638
06639 else if (farPulserBox==pulserBox) {
06640
06641 if (calibPoint>0 && calibPoint<=const_numCalibPoints){
06642 hAdcPhFarPb[calibPoint-1]->Fill(mean);
06643 }
06644
06645
06646 if (pulserBox>=FIRSTPULSERBOX && pulserBox<=LASTPULSERBOX){
06647 hAdcPbFarPb[pulserBox]->Fill(mean);
06648 }
06649
06650
06651 if (pulseWidth>=1 && pulseWidth<=const_numPulseWidths){
06652 hAdcPwFarPb[pulseWidth-1]->Fill(mean);
06653 }
06654
06655 hMeanFarPb->Fill(mean);
06656 }
06657 else {
06658 MSG("LIAnalysis",Msg::kWarning)
06659 <<" ** Wrong Pb **"<<endl;
06660 }
06661 }
06662 }
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
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
06690
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
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
06750
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
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
06811
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
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 }
06870
06871
06872
06873 void LIAnalysis::CalcAdcAv()
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
06885 Int_t *pbPulseHeight=new Int_t[const_numCalibPoints];
06886
06887
06888
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
06898 (pbMean[i])[j]=0.;
06899 (pbNumEntries[i])[j]=0.;
06900 }
06901 pbPulseHeight[i]=0;
06902 }
06903
06904
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
06917 }
06918
06919
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
06933 }
06934
06935
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
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
06965 if (rms==0. || mean==0. || numEntries==0) continue;
06966
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 }
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
06999 Float_t averageMean=0.;
07000 if ((pbNumEntries[calPoint])[pb]>0){
07001
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
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
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 }
07088
07089
07090
07091 void LIAnalysis::ChannelAdc(Int_t chan,Int_t chan2)
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 }
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 }
07210
07211
07212
07213 void LIAnalysis::CheckData(Int_t rt)
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
07735 if (rt==-1);
07736 else if (readoutType!=rt) continue;
07737
07738
07739
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
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 }
07829
07833
07834 MSG("LIAnalysis",Msg::kInfo)<<"Finished main loop"<<endl;
07835
07836
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
07878
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
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 }
08005
08006
08007
08008 void LIAnalysis::TriggerPmt()
08009 {
08010 MSG("LIAnalysis",Msg::kInfo)
08011 <<endl<<" ** Running the TriggerPmt method... ** "<<endl;
08012
08013 TH1F *hChannel=new TH1F("hChannel","VA Channels hit",40,-5,35);
08014 hChannel->GetXaxis()->SetTitle("VA Channel");
08015 hChannel->GetXaxis()->CenterTitle();
08016 hChannel->GetYaxis()->SetTitle("Number of times hit");
08017 hChannel->GetYaxis()->CenterTitle();
08018 hChannel->SetFillColor(0);
08019 hChannel->SetBit(TH1::kCanRebin);
08020
08021 TH1F *hChannelCorrelated=new TH1F
08022 ("hChannelCorrelated","VA Channels hit",40,-5,35);
08023 hChannelCorrelated->GetXaxis()->SetTitle("VA Channel");
08024 hChannelCorrelated->GetXaxis()->CenterTitle();
08025 hChannelCorrelated->GetYaxis()->SetTitle("Number of times hit");
08026 hChannelCorrelated->GetYaxis()->CenterTitle();
08027 hChannelCorrelated->SetFillColor(0);
08028 hChannelCorrelated->SetLineColor(2);
08029 hChannelCorrelated->SetBit(TH1::kCanRebin);
08030
08031 TH1F **hMeanPb=0;
08032 TH1F **hMeanCorrelatedPb=0;
08033 hMeanPb=new TH1F*[NUMPULSERBOXES];
08034 hMeanCorrelatedPb=new TH1F*[NUMPULSERBOXES];
08035 for (Int_t i=0;i<NUMPULSERBOXES;i++){
08036 s="Trigger PMT Mean ADC (Pb ";
08037 string pB=Form("%d",i);
08038 s=s+pB+")";
08039 hMeanPb[i]=new TH1F(s.c_str(),s.c_str(),20000,-5,17005);
08040 hMeanPb[i]->GetXaxis()->SetTitle("Mean");
08041 hMeanPb[i]->GetXaxis()->CenterTitle();
08042 hMeanPb[i]->GetYaxis()->SetTitle("Num Entries");
08043 hMeanPb[i]->GetYaxis()->CenterTitle();
08044 hMeanPb[i]->SetFillColor(0);
08045 hMeanPb[i]->SetBit(TH1::kCanRebin);
08046
08047 s="Trigger PMT Mean ADC (Correlated, Pb ";
08048 s=s+pB+")";
08049 hMeanCorrelatedPb[i]=new TH1F(s.c_str(),s.c_str(),150,-5,17005);
08050 hMeanCorrelatedPb[i]->GetXaxis()->SetTitle("Mean");
08051 hMeanCorrelatedPb[i]->GetXaxis()->CenterTitle();
08052 hMeanCorrelatedPb[i]->GetYaxis()->SetTitle("Num Entries");
08053 hMeanCorrelatedPb[i]->GetYaxis()->CenterTitle();
08054 hMeanCorrelatedPb[i]->SetFillColor(0);
08055 hMeanCorrelatedPb[i]->SetLineColor(2);
08056 hMeanCorrelatedPb[i]->SetBit(TH1::kCanRebin);
08057 }
08058
08059 TH1F *hMean=new TH1F("hMean","Mean",150,-5,15005);
08060 hMean->GetXaxis()->SetTitle("Mean");
08061 hMean->GetXaxis()->CenterTitle();
08062 hMean->GetYaxis()->SetTitle("Num Entries");
08063 hMean->GetYaxis()->CenterTitle();
08064 hMean->SetFillColor(0);
08065 hMean->SetBit(TH1::kCanRebin);
08066
08067 TH1F *hMeanCorrelated=new TH1F("hMeanCorrelated","MeanCorrelated",
08068 150,-5,15005);
08069 hMeanCorrelated->GetXaxis()->SetTitle("Mean");
08070 hMeanCorrelated->GetXaxis()->CenterTitle();
08071 hMeanCorrelated->GetYaxis()->SetTitle("Num Entries");
08072 hMeanCorrelated->GetYaxis()->CenterTitle();
08073 hMeanCorrelated->SetFillColor(0);
08074 hMeanCorrelated->SetLineColor(2);
08075 hMeanCorrelated->SetBit(TH1::kCanRebin);
08076
08077 TH1F *hNumEnt=new TH1F("hNumEnt","NumEnt",10000,-5,5000);
08078 hNumEnt->GetXaxis()->SetTitle("NumEnt");
08079 hNumEnt->GetXaxis()->CenterTitle();
08080 hNumEnt->GetYaxis()->SetTitle("Num Entries");
08081 hNumEnt->GetYaxis()->CenterTitle();
08082 hNumEnt->SetFillColor(0);
08083 hNumEnt->SetBit(TH1::kCanRebin);
08084
08085 TH1F *hNumEntCorrelated=new TH1F("hNumEntCorrelated",
08086 "NumEntCorrelated",
08087 10000,-5,5000);
08088 hNumEntCorrelated->GetXaxis()->SetTitle("NumEnt");
08089 hNumEntCorrelated->GetXaxis()->CenterTitle();
08090 hNumEntCorrelated->GetYaxis()->SetTitle("Num Entries");
08091 hNumEntCorrelated->GetYaxis()->CenterTitle();
08092 hNumEntCorrelated->SetFillColor(0);
08093 hNumEntCorrelated->SetLineColor(2);
08094 hNumEntCorrelated->SetBit(TH1::kCanRebin);
08095
08096 TH2F *hNumEntVsPb=new TH2F("hNumEntVsPb",
08097 "Number of Pulses Detected Vs Pulser Box (tPMT only)",
08098 NUMPULSERBOXES,FIRSTPULSERBOX,
08099 LASTPULSERBOX+1,
08100 10000,-5,1600);
08101 hNumEntVsPb->GetXaxis()->SetTitle("Pulser box");
08102 hNumEntVsPb->GetXaxis()->CenterTitle();
08103 hNumEntVsPb->GetYaxis()->SetTitle("Number of Pulses detected");
08104 hNumEntVsPb->GetYaxis()->CenterTitle();
08105 hNumEntVsPb->SetFillColor(0);
08106 hNumEntVsPb->SetBit(TH1::kCanRebin);
08107
08108 TH1F *hTimestamp=new TH1F("hTimestamp","Timestamp",
08109 1000000,1.0348e9,1.0349e9);
08110 hTimestamp->GetXaxis()->SetTitle("Timestamp");
08111 hTimestamp->GetXaxis()->CenterTitle();
08112 hTimestamp->GetYaxis()->SetTitle("");
08113 hTimestamp->GetYaxis()->CenterTitle();
08114 hTimestamp->SetFillColor(0);
08115 hTimestamp->SetBit(TH1::kCanRebin);
08116
08117 TH1F *hTimestampCorrelated=new TH1F("hTimestampCorrelated",
08118 "TimestampCorrelated",
08119 1000000,1.0348e9,1.0349e9);
08120 hTimestampCorrelated->GetXaxis()->SetTitle("TimestampCorrelated");
08121 hTimestampCorrelated->GetXaxis()->CenterTitle();
08122 hTimestampCorrelated->GetYaxis()->SetTitle("");
08123 hTimestampCorrelated->GetYaxis()->CenterTitle();
08124 hTimestampCorrelated->SetFillColor(0);
08125 hTimestampCorrelated->SetLineColor(2);
08126 hTimestampCorrelated->SetBit(TH1::kCanRebin);
08127
08128 TH1F *hVarc=new TH1F("hVarc","Varcs hit",10,-5,5);
08129 hVarc->GetXaxis()->SetTitle("Varc");
08130 hVarc->GetXaxis()->CenterTitle();
08131 hVarc->GetYaxis()->SetTitle("Number of times hit");
08132 hVarc->GetYaxis()->CenterTitle();
08133 hVarc->SetFillColor(0);
08134
08135 TH1F *hVfb=new TH1F("hVfb","Vfbs hit",10,-5,5);
08136 hVfb->GetXaxis()->SetTitle("Vfb");
08137 hVfb->GetXaxis()->CenterTitle();
08138 hVfb->GetYaxis()->SetTitle("Number of times hit");
08139 hVfb->GetYaxis()->CenterTitle();
08140 hVfb->SetFillColor(0);
08141
08142 TH1F *hVmm=new TH1F("hVmm","Vmms hit",15,-5,10);
08143 hVmm->GetXaxis()->SetTitle("Vmm");
08144 hVmm->GetXaxis()->CenterTitle();
08145 hVmm->GetYaxis()->SetTitle("Number of times hit");
08146 hVmm->GetYaxis()->CenterTitle();
08147 hVmm->SetFillColor(0);
08148
08149 TH1F *hChip=new TH1F("hChip","Chips hit",10,-5,5);
08150 hChip->GetXaxis()->SetTitle("Chip");
08151 hChip->GetXaxis()->CenterTitle();
08152 hChip->GetYaxis()->SetTitle("Number of times hit");
08153 hChip->GetYaxis()->CenterTitle();
08154 hChip->SetFillColor(0);
08155
08156
08157 chain->GetEvent(0);
08158 Int_t numBins=pulses+300;
08159 Float_t maxBin=pulses+300.;
08160
08161 TH1F **hNumEntries=0;
08162 hNumEntries=new TH1F*[NUMPULSERBOXES];
08163 for (Int_t i=0;i<NUMPULSERBOXES;i++){
08164 string sPb=Form("%d",i);
08165 s="tPMT Pulses detected (all hits), Pulser Box "+sPb;
08166 hNumEntries[i]=new TH1F(s.c_str(),s.c_str(),numBins,0,maxBin);
08167 hNumEntries[i]->GetXaxis()->SetTitle("Number of Pulses");
08168 hNumEntries[i]->GetXaxis()->CenterTitle();
08169 hNumEntries[i]->GetYaxis()->SetTitle("Number of Entries");
08170 hNumEntries[i]->GetYaxis()->CenterTitle();
08171 hNumEntries[i]->SetFillColor(0);
08172 hNumEntries[i]->SetBit(TH1::kCanRebin);
08173 }
08174
08175 TH1F **hNumEntriesCor=0;
08176 hNumEntriesCor=new TH1F*[NUMPULSERBOXES];
08177 for (Int_t i=0;i<NUMPULSERBOXES;i++){
08178 string sPb=Form("%d",i);
08179 s="tPMT Pulses Detected (correlated hits), Pulser Box "+sPb;
08180 hNumEntriesCor[i]=new TH1F(s.c_str(),s.c_str(),numBins,0,maxBin);
08181 hNumEntriesCor[i]->GetXaxis()->SetTitle("Number of Pulses");
08182 hNumEntriesCor[i]->GetXaxis()->CenterTitle();
08183 hNumEntriesCor[i]->GetYaxis()->SetTitle("Number of Entries");
08184 hNumEntriesCor[i]->GetYaxis()->CenterTitle();
08185 hNumEntriesCor[i]->SetFillColor(0);
08186 hNumEntriesCor[i]->SetLineColor(2);
08187 hNumEntriesCor[i]->SetBit(TH1::kCanRebin);
08188 }
08189
08190 MSG("LIAnalysis",Msg::kInfo)
08191 <<"Format of any printout below is:"<<endl
08192 <<"(pulser box : led) Correlated Hit=1,"<<endl
08193 <<"(mean,rms,fraction of pulses detected),"<<endl
08194 <<"elec=(crate,varc,vmm,vfb,channel)"<<endl;
08195
08199
08200 this->InitialiseLoopVariables();
08201
08202 for(Int_t entry=0;entry<numEvents;entry++){
08203
08204 this->SetLoopVariables(entry,0);
08205
08206
08207 if (readoutType!=ReadoutType::kFlashTrigPMT) continue;
08208
08209
08210 if (MsgService::Instance()->IsActive("LIAnalysis",Msg::kDebug) &&
08211 numEntries==pulses && correlatedHit==1){
08212
08213 MSG("LIAnalysis",Msg::kInfo)
08214 <<"("<<pulserBox
08215 <<":"<<led
08216 <<") CH="<<correlatedHit
08217 <<" ("<<static_cast<Int_t>(mean)
08218 <<","<<static_cast<Int_t>(rms)
08219 <<","<<numEntries
08220 <<"/"<<pulses
08221 <<"), "<<this->GetElecString()<<endl;
08222 }
08223 else if (numEntries!=pulses){
08224
08225
08226 if (correlatedHit==1){
08227 MSG("LIAnalysis",Msg::kInfo)
08228 <<" ** Warning missing trigger pmt hits:"<<endl;
08229 }
08230 else{
08231 MSG("LIAnalysis",Msg::kInfo)
08232 <<"xtalk hit: "<<endl;
08233 }
08234
08235 MSG("LIAnalysis",Msg::kInfo)
08236 <<"("<<pulserBox
08237 <<":"<<led
08238 <<") CH="<<correlatedHit
08239 <<" ("<<static_cast<Int_t>(mean)
08240 <<","<<static_cast<Int_t>(rms)
08241 <<","<<numEntries
08242 <<"/"<<pulses
08243 <<"), "<<this->GetElecString()<<endl;
08244 }
08245
08246 if (pulserBox>=FIRSTPULSERBOX && pulserBox<=LASTPULSERBOX){
08247 hNumEntries[pulserBox]->Fill(numEntries);
08248 if (correlatedHit==1){
08249 hMeanCorrelatedPb[pulserBox]->Fill(mean);
08250 hNumEntriesCor[pulserBox]->Fill(numEntries);
08251 }
08252 else{
08253 hMeanPb[pulserBox]->Fill(mean);
08254 }
08255 }
08256
08257 hMean->Fill(mean);
08258 hChannel->Fill(channel);
08259 hTimestamp->Fill(timestamp);
08260 hNumEnt->Fill(numEntries);
08261 if (correlatedHit==1){
08262 hMeanCorrelated->Fill(mean);
08263 hChannelCorrelated->Fill(channel);
08264 hTimestampCorrelated->Fill(timestamp);
08265 hNumEntCorrelated->Fill(numEntries);
08266 hNumEntVsPb->Fill(pulserBox,numEntries,100);
08267 }
08268 else{
08269 hNumEntVsPb->Fill(pulserBox,numEntries);
08270 }
08271
08272 hVarc->Fill(varc);
08273 hVfb->Fill(vfb);
08274 hVmm->Fill(vmm);
08275 hChip->Fill(chip);
08276 }
08277
08281
08282 MSG("LIAnalysis",Msg::kInfo)<<"Finished main loop"<<endl;
08283
08284 string sRunNumber=Form("%d",runNumber);
08285
08286 TCanvas *cMean=new TCanvas("cMean","Mean adc",0,0,1000,800);
08287 cMean->SetFillColor(0);
08288 cMean->Divide(1,2);
08289 cMean->cd(1);
08290 hMean->Draw();
08291 hMeanCorrelated->Draw("same");
08292 cMean->cd(2);
08293 hChannel->Draw();
08294 hChannelCorrelated->Draw("same");
08295
08296 TCanvas *cTimestamp=new TCanvas("cTimestamp","Timestamp",
08297 0,0,1000,800);
08298 cTimestamp->SetFillColor(0);
08299 cTimestamp->Divide(1,2);
08300 cTimestamp->cd(1);
08301 hTimestamp->Draw();
08302 hTimestampCorrelated->Draw("same");
08303 cTimestamp->cd(2);
08304 hNumEnt->Draw();
08305 hNumEntCorrelated->Draw("same");
08306
08307 TCanvas *cNumEntVsPb=new TCanvas("cNumEntVsPb","NumEntVsPb",
08308 0,0,1100,600);
08309 cNumEntVsPb->cd();
08310 cNumEntVsPb->SetFillColor(0);
08311 hNumEntVsPb->Draw("colz");
08312 s=sRunNumber+"PulsesVsPb.eps";
08313 cNumEntVsPb->Print(s.c_str());
08314
08315 TCanvas *cMeanPb=new TCanvas("cMeanPb","Mean Pb",0,0,1100,600);
08316 cMeanPb->cd();
08317 cMeanPb->SetFillColor(0);
08318 for (Int_t i=0;i<NUMPULSERBOXES;i++){
08319 cMeanPb->Clear();
08320 if (hMeanPb[i]->GetMaximum()<25 ||
08321 hMeanCorrelatedPb[i]->GetMaximum()<25){
08322 hMeanPb[i]->SetMaximum(25);
08323 }
08324 hMeanPb[i]->Draw();
08325 hMeanCorrelatedPb[i]->Draw("same");
08326 if (i==0){
08327 s=sRunNumber+"TrigPmtMean.ps(";
08328 cMeanPb->Print(s.c_str());
08329 }
08330 else if(i==NUMPULSERBOXES-1){
08331 s=sRunNumber+"TrigPmtMean.ps)";
08332 cMeanPb->Print(s.c_str());
08333 }
08334 else{
08335 s=sRunNumber+"TrigPmtMean.ps";
08336 cMeanPb->Print(s.c_str());
08337 }
08338 }
08339
08340 cMeanPb->Clear();
08341 hMeanPb[0]->Draw();
08342 hMeanCorrelatedPb[0]->Draw("same");
08343
08344
08345 TCanvas *cElectronics=new TCanvas("cElectronics","Electronics",
08346 0,0,1100,600);
08347 cElectronics->SetFillColor(0);
08348 cElectronics->Divide(2,2);
08349 cElectronics->cd(1);
08350 hVarc->Draw();
08351 cElectronics->cd(2);
08352 hVfb->Draw();
08353 cElectronics->cd(3);
08354 hVmm->Draw();
08355 cElectronics->cd(4);
08356 hChip->Draw();
08357
08358 TCanvas *cNumPulses=new TCanvas("cNumPulses","NumPulses adc",
08359 0,0,1200,800);
08360 cNumPulses->SetFillColor(0);
08361 cNumPulses->Divide(1,2);
08362 for (Int_t i=0;i<NUMPULSERBOXES;i++){
08363 cNumPulses->Clear();
08364 cNumPulses->Divide(1,2);
08365 cNumPulses->cd(1);
08366 hNumEntriesCor[i]->Draw();
08367 cNumPulses->cd(2);
08368 hNumEntries[i]->Draw();
08369 if (i==0){
08370 s=sRunNumber+"NumPulsesTrigPmt.ps(";
08371 cNumPulses->Print(s.c_str());
08372 }
08373 else if(i==NUMPULSERBOXES-1){
08374 s=sRunNumber+"NumPulsesTrigPmt.ps)";
08375 cNumPulses->Print(s.c_str());
08376 }
08377 else{
08378 s=sRunNumber+"NumPulsesTrigPmt.ps";
08379 cNumPulses->Print(s.c_str());
08380 }
08381 }
08382
08383 cNumPulses->Clear();
08384 cNumPulses->Divide(1,2);
08385 cNumPulses->cd(1);
08386 hNumEntriesCor[0]->Draw();
08387 cNumPulses->cd(2);
08388 hNumEntries[0]->Draw();
08389
08390
08391 MSG("LIAnalysis",Msg::kInfo)
08392 <<endl<<" ** Finished the TriggerPmt method ** "<<endl;
08393 }
08394
08395
08396
08397 void LIAnalysis::PinDiode()
08398 {
08399 MSG("LIAnalysis",Msg::kInfo)
08400 <<endl<<" ** Running the PinDiode method... ** "<<endl;
08401
08402 TH1F *hChannel=new TH1F("hChannel","VA Channels hit",40,-5,35);
08403 hChannel->GetXaxis()->SetTitle("VA Channel");
08404 hChannel->GetXaxis()->CenterTitle();
08405 hChannel->GetYaxis()->SetTitle("Number of times hit");
08406 hChannel->GetYaxis()->CenterTitle();
08407 hChannel->SetFillColor(0);
08408 hChannel->SetBit(TH1::kCanRebin);
08409
08410 TH1F *hChannelCorrelated=new TH1F
08411 ("hChannelCorrelated","VA Channels hit",40,-5,35);
08412 hChannelCorrelated->GetXaxis()->SetTitle("VA Channel");
08413 hChannelCorrelated->GetXaxis()->CenterTitle();
08414 hChannelCorrelated->GetYaxis()->SetTitle("Number of times hit");
08415 hChannelCorrelated->GetYaxis()->CenterTitle();
08416 hChannelCorrelated->SetFillColor(0);
08417 hChannelCorrelated->SetLineColor(2);
08418 hChannelCorrelated->SetBit(TH1::kCanRebin);
08419
08420 TH1F **hMeanPb=0;
08421 TH1F **hMeanCorrelatedPb=0;
08422 hMeanPb=new TH1F*[NUMPULSERBOXES];
08423 hMeanCorrelatedPb=new TH1F*[NUMPULSERBOXES];
08424 for (Int_t i=0;i<NUMPULSERBOXES;i++){
08425 s="PIN Diode Mean ADC (Pb ";
08426 string pB=Form("%d",i);
08427 s=s+pB+")";
08428 hMeanPb[i]=new TH1F(s.c_str(),s.c_str(),20000,-5,17005);
08429 hMeanPb[i]->GetXaxis()->SetTitle("Mean");
08430 hMeanPb[i]->GetXaxis()->CenterTitle();
08431 hMeanPb[i]->GetYaxis()->SetTitle("Num Entries");
08432 hMeanPb[i]->GetYaxis()->CenterTitle();
08433 hMeanPb[i]->SetFillColor(0);
08434 hMeanPb[i]->SetBit(TH1::kCanRebin);
08435
08436 s="PIN Diodes Mean ADC (Correlated, Pb ";
08437 s=s+pB+")";
08438 hMeanCorrelatedPb[i]=new TH1F(s.c_str(),s.c_str(),150,-5,17005);
08439 hMeanCorrelatedPb[i]->GetXaxis()->SetTitle("Mean");
08440 hMeanCorrelatedPb[i]->GetXaxis()->CenterTitle();
08441 hMeanCorrelatedPb[i]->GetYaxis()->SetTitle("Num Entries");
08442 hMeanCorrelatedPb[i]->GetYaxis()->CenterTitle();
08443 hMeanCorrelatedPb[i]->SetFillColor(0);
08444 hMeanCorrelatedPb[i]->SetLineColor(2);
08445 hMeanCorrelatedPb[i]->SetBit(TH1::kCanRebin);
08446 }
08447
08448 TH1F *hMean=new TH1F("hMean","Mean",150,-5,15005);
08449 hMean->GetXaxis()->SetTitle("Mean");
08450 hMean->GetXaxis()->CenterTitle();
08451 hMean->GetYaxis()->SetTitle("Num Entries");
08452 hMean->GetYaxis()->CenterTitle();
08453 hMean->SetFillColor(0);
08454 hMean->SetBit(TH1::kCanRebin);
08455
08456 TH1F *hMeanCorrelated=new TH1F("hMeanCorrelated","MeanCorrelated",
08457 150,-5,15005);
08458 hMeanCorrelated->GetXaxis()->SetTitle("Mean");
08459 hMeanCorrelated->GetXaxis()->CenterTitle();
08460 hMeanCorrelated->GetYaxis()->SetTitle("Num Entries");
08461 hMeanCorrelated->GetYaxis()->CenterTitle();
08462 hMeanCorrelated->SetFillColor(0);
08463 hMeanCorrelated->SetLineColor(2);
08464 hMeanCorrelated->SetBit(TH1::kCanRebin);
08465
08466 TH1F *hNumEnt=new TH1F("hNumEnt","NumEnt",10000,-5,5000);
08467 hNumEnt->GetXaxis()->SetTitle("NumEnt");
08468 hNumEnt->GetXaxis()->CenterTitle();
08469 hNumEnt->GetYaxis()->SetTitle("Num Entries");
08470 hNumEnt->GetYaxis()->CenterTitle();
08471 hNumEnt->SetFillColor(0);
08472 hNumEnt->SetBit(TH1::kCanRebin);
08473
08474 TH1F *hNumEntCorrelated=new TH1F("hNumEntCorrelated",
08475 "NumEntCorrelated",
08476 10000,-5,5000);
08477 hNumEntCorrelated->GetXaxis()->SetTitle("NumEnt");
08478 hNumEntCorrelated->GetXaxis()->CenterTitle();
08479 hNumEntCorrelated->GetYaxis()->SetTitle("Num Entries");
08480 hNumEntCorrelated->GetYaxis()->CenterTitle();
08481 hNumEntCorrelated->SetFillColor(0);
08482 hNumEntCorrelated->SetLineColor(2);
08483 hNumEntCorrelated->SetBit(TH1::kCanRebin);
08484
08485 TH2F *hNumEntVsPb=new TH2F("hNumEntVsPb",
08486 "Num Pulses Detected Vs Pulser Box (PINs)",
08487 NUMPULSERBOXES,FIRSTPULSERBOX,
08488 LASTPULSERBOX+1,
08489 10000,-5,1600);
08490 hNumEntVsPb->GetXaxis()->SetTitle("Pulser box");
08491 hNumEntVsPb->GetXaxis()->CenterTitle();
08492 hNumEntVsPb->GetYaxis()->SetTitle("Number of Pulses detected");
08493 hNumEntVsPb->GetYaxis()->CenterTitle();
08494 hNumEntVsPb->SetFillColor(0);
08495 hNumEntVsPb->SetBit(TH1::kCanRebin);
08496
08497 TH1F *hTimestamp=new TH1F("hTimestamp","Timestamp",
08498 1000000,1.0348e9,1.0349e9);
08499 hTimestamp->GetXaxis()->SetTitle("Timestamp");
08500 hTimestamp->GetXaxis()->CenterTitle();
08501 hTimestamp->GetYaxis()->SetTitle("");
08502 hTimestamp->GetYaxis()->CenterTitle();
08503 hTimestamp->SetFillColor(0);
08504 hTimestamp->SetBit(TH1::kCanRebin);
08505
08506 TH1F *hTimestampCorrelated=new TH1F("hTimestampCorrelated",
08507 "TimestampCorrelated",
08508 1000000,1.0348e9,1.0349e9);
08509 hTimestampCorrelated->GetXaxis()->SetTitle("TimestampCorrelated");
08510 hTimestampCorrelated->GetXaxis()->CenterTitle();
08511 hTimestampCorrelated->GetYaxis()->SetTitle("");
08512 hTimestampCorrelated->GetYaxis()->CenterTitle();
08513 hTimestampCorrelated->SetFillColor(0);
08514 hTimestampCorrelated->SetLineColor(2);
08515 hTimestampCorrelated->SetBit(TH1::kCanRebin);
08516
08517 TH1F *hVarc=new TH1F("hVarc","Varcs hit",10,-5,5);
08518 hVarc->GetXaxis()->SetTitle("Varc");
08519 hVarc->GetXaxis()->CenterTitle();
08520 hVarc->GetYaxis()->SetTitle("Number of times hit");
08521 hVarc->GetYaxis()->CenterTitle();
08522 hVarc->SetFillColor(0);
08523
08524 TH1F *hVfb=new TH1F("hVfb","Vfbs hit",10,-5,5);
08525 hVfb->GetXaxis()->SetTitle("Vfb");
08526 hVfb->GetXaxis()->CenterTitle();
08527 hVfb->GetYaxis()->SetTitle("Number of times hit");
08528 hVfb->GetYaxis()->CenterTitle();
08529 hVfb->SetFillColor(0);
08530
08531 TH1F *hVmm=new TH1F("hVmm","Vmms hit",15,-5,10);
08532 hVmm->GetXaxis()->SetTitle("Vmm");
08533 hVmm->GetXaxis()->CenterTitle();
08534 hVmm->GetYaxis()->SetTitle("Number of times hit");
08535 hVmm->GetYaxis()->CenterTitle();
08536 hVmm->SetFillColor(0);
08537
08538 TH1F *hChip=new TH1F("hChip","Chips hit",10,-5,5);
08539 hChip->GetXaxis()->SetTitle("Chip");
08540 hChip->GetXaxis()->CenterTitle();
08541 hChip->GetYaxis()->SetTitle("Number of times hit");
08542 hChip->GetYaxis()->CenterTitle();
08543 hChip->SetFillColor(0);
08544
08545
08546 chain->GetEvent(0);
08547 Int_t numBins=pulses+300;
08548 Float_t maxBin=pulses+300.;
08549
08550 TH1F **hNumEntries=0;
08551 hNumEntries=new TH1F*[NUMPULSERBOXES];
08552 for (Int_t i=0;i<NUMPULSERBOXES;i++){
08553 string sPb=Form("%d",i);
08554 s="PIN Diode Pulses Detected (all hits), Pulser Box "+sPb;
08555 hNumEntries[i]=new TH1F(s.c_str(),s.c_str(),numBins,0,maxBin);
08556 hNumEntries[i]->GetXaxis()->SetTitle("Number of Pulses");
08557 hNumEntries[i]->GetXaxis()->CenterTitle();
08558 hNumEntries[i]->GetYaxis()->SetTitle("Number of Entries");
08559 hNumEntries[i]->GetYaxis()->CenterTitle();
08560 hNumEntries[i]->SetFillColor(0);
08561 hNumEntries[i]->SetBit(TH1::kCanRebin);
08562 }
08563
08564 TH1F **hNumEntriesCor=0;
08565 hNumEntriesCor=new TH1F*[NUMPULSERBOXES];
08566 for (Int_t i=0;i<NUMPULSERBOXES;i++){
08567 string sPb=Form("%d",i);
08568 s="PIN Diode Pulses Detected (correlated hits), Pulser Box "
08569 +sPb;
08570 hNumEntriesCor[i]=new TH1F(s.c_str(),s.c_str(),numBins,0,maxBin);
08571 hNumEntriesCor[i]->GetXaxis()->SetTitle("Number of Pulses");
08572 hNumEntriesCor[i]->GetXaxis()->CenterTitle();
08573 hNumEntriesCor[i]->GetYaxis()->SetTitle("Number of Entries");
08574 hNumEntriesCor[i]->GetYaxis()->CenterTitle();
08575 hNumEntriesCor[i]->SetFillColor(0);
08576 hNumEntriesCor[i]->SetLineColor(2);
08577 hNumEntriesCor[i]->SetBit(TH1::kCanRebin);
08578 }
08579
08583
08584 this->InitialiseLoopVariables();
08585
08586 for(Int_t entry=0;entry<numEvents;entry++){
08587
08588 this->SetLoopVariables(entry,0);
08589
08590
08591 if (readoutType!=ReadoutType::kPinDiode) continue;
08592
08593 MSG("LIAnalysis",Msg::kVerbose)
08594 <<"led="<<led
08595 <<", pulser box="<<pulserBox
08596 <<", channel="<<channel
08597 <<", mean="<<mean
08598 <<endl;
08599
08600 if (pulserBox>=FIRSTPULSERBOX && pulserBox<=LASTPULSERBOX){
08601 hNumEntries[pulserBox]->Fill(numEntries);
08602 if (correlatedHit==1){
08603 hMeanCorrelatedPb[pulserBox]->Fill(mean);
08604 hNumEntriesCor[pulserBox]->Fill(numEntries);
08605 }
08606 else{
08607 hMeanPb[pulserBox]->Fill(mean);
08608 }
08609 }
08610
08611 hMean->Fill(mean);
08612 hChannel->Fill(channel);
08613 hTimestamp->Fill(timestamp);
08614 hNumEnt->Fill(numEntries);
08615 if (correlatedHit==1){
08616 hMeanCorrelated->Fill(mean);
08617 hChannelCorrelated->Fill(channel);
08618 hTimestampCorrelated->Fill(timestamp);
08619 hNumEntCorrelated->Fill(numEntries);
08620 hNumEntVsPb->Fill(pulserBox,numEntries,100);
08621 }
08622 else{
08623 hNumEntVsPb->Fill(pulserBox,numEntries);
08624 }
08625
08626 hVarc->Fill(varc);
08627 hVfb->Fill(vfb);
08628 hVmm->Fill(vmm);
08629 hChip->Fill(chip);
08630 }
08631
08635
08636 MSG("LIAnalysis",Msg::kInfo)<<"Finished main loop"<<endl;
08637
08638 string sRunNumber=Form("%d",runNumber);
08639
08640 TCanvas *cMean=new TCanvas("cMean","Mean adc",0,0,1000,800);
08641 cMean->SetFillColor(0);
08642 cMean->Divide(1,2);
08643 cMean->cd(1);
08644 hMean->Draw();
08645 hMeanCorrelated->Draw("same");
08646 cMean->cd(2);
08647 hChannel->Draw();
08648 hChannelCorrelated->Draw("same");
08649
08650 TCanvas *cTimestamp=new TCanvas("cTimestamp","Timestamp",
08651 0,0,1000,800);
08652 cTimestamp->SetFillColor(0);
08653 cTimestamp->Divide(1,2);
08654 cTimestamp->cd(1);
08655 hTimestamp->Draw();
08656 hTimestampCorrelated->Draw("same");
08657 cTimestamp->cd(2);
08658 hNumEnt->Draw();
08659 hNumEntCorrelated->Draw("same");
08660
08661 TCanvas *cNumEntVsPb=new TCanvas("cNumEntVsPb","NumEntVsPb",
08662 0,0,1100,600);
08663 cNumEntVsPb->cd();
08664 cNumEntVsPb->SetFillColor(0);
08665 hNumEntVsPb->Draw("colz");
08666 s=sRunNumber+"PinPulsesVsPb.eps";
08667 cNumEntVsPb->Print(s.c_str());
08668
08669 TCanvas *cMeanPb=new TCanvas("cMeanPb","Mean Pb",0,0,1100,600);
08670 cMeanPb->cd();
08671 cMeanPb->SetFillColor(0);
08672 for (Int_t i=0;i<NUMPULSERBOXES;i++){
08673 cMeanPb->Clear();
08674 if (hMeanPb[i]->GetMaximum()<25 ||
08675 hMeanCorrelatedPb[i]->GetMaximum()<25){
08676 hMeanPb[i]->SetMaximum(25);
08677 }
08678 hMeanPb[i]->Draw();
08679 hMeanCorrelatedPb[i]->Draw("same");
08680 if (i==0){
08681 s=sRunNumber+"PinMean.ps(";
08682 cMeanPb->Print(s.c_str());
08683 }
08684 else if(i==NUMPULSERBOXES-1){
08685 s=sRunNumber+"PinMean.ps)";
08686 cMeanPb->Print(s.c_str());
08687 }
08688 else{
08689 s=sRunNumber+"PinMean.ps";
08690 cMeanPb->Print(s.c_str());
08691 }
08692 }
08693
08694 cMeanPb->Clear();
08695 hMeanPb[0]->Draw();
08696 hMeanCorrelatedPb[0]->Draw("same");
08697
08698
08699 TCanvas *cElectronics=new TCanvas("cElectronics","Electronics",
08700 0,0,1100,600);
08701 cElectronics->SetFillColor(0);
08702 cElectronics->Divide(2,2);
08703 cElectronics->cd(1);
08704 hVarc->Draw();
08705 cElectronics->cd(2);
08706 hVfb->Draw();
08707 cElectronics->cd(3);
08708 hVmm->Draw();
08709 cElectronics->cd(4);
08710 hChip->Draw();
08711
08712 TCanvas *cNumPulses=new TCanvas("cNumPulses","NumPulses adc",
08713 0,0,1200,800);
08714 cNumPulses->SetFillColor(0);
08715 cNumPulses->Divide(1,2);
08716 for (Int_t i=0;i<NUMPULSERBOXES;i++){
08717 cNumPulses->Clear();
08718 cNumPulses->Divide(1,2);
08719 cNumPulses->cd(1);
08720 hNumEntriesCor[i]->Draw();
08721 cNumPulses->cd(2);
08722 hNumEntries[i]->Draw();
08723 if (i==0){
08724 s=sRunNumber+"PinPulses.ps(";
08725 cNumPulses->Print(s.c_str());
08726 }
08727 else if(i==NUMPULSERBOXES-1){
08728 s=sRunNumber+"PinPulses.ps)";
08729 cNumPulses->Print(s.c_str());
08730 }
08731 else{
08732 s=sRunNumber+"PinPulses.ps";
08733 cNumPulses->Print(s.c_str());
08734 }
08735 }
08736
08737 cNumPulses->Clear();
08738 cNumPulses->Divide(1,2);
08739 cNumPulses->cd(1);
08740 hNumEntriesCor[0]->Draw();
08741 cNumPulses->cd(2);
08742 hNumEntries[0]->Draw();
08743
08744
08745 MSG("LIAnalysis",Msg::kInfo)
08746 <<endl<<" ** Finished the PinDiode method ** "<<endl;
08747 }
08748
08749
08750
08751 void LIAnalysis::PmtGain(Int_t pl,Int_t cr,Int_t printGain)
08752 {
08753 MSG("LIAnalysis",Msg::kInfo)
08754 <<endl<<" ** Running the PmtGain method... ** "<<endl;
08755
08756
08757 gStyle->SetOptStat(1111111);
08758
08759 Int_t numBins1D=100;
08760 Int_t maxGainBin=300;
08761 Int_t minGainBin=-5;
08762
08763 TH2F *hNpeVsMean=new TH2F("hNpeVsMean","NPE vs ADC",
08764 500,0,15000,400,0,1000);
08765 hNpeVsMean->GetXaxis()->SetTitle("ADC");
08766 hNpeVsMean->GetXaxis()->CenterTitle();
08767 hNpeVsMean->GetYaxis()->SetTitle("NPE (Mean^2/RMS^2)");
08768 hNpeVsMean->GetYaxis()->CenterTitle();
08769 hNpeVsMean->SetFillColor(0);
08770
08771
08772 TH2F *hGainVsMean=new TH2F("hGainVsMean","Gain vs ADC",
08773 500,0,15000,200,0,250);
08774 hGainVsMean->GetXaxis()->SetTitle("ADC");
08775 hGainVsMean->GetXaxis()->CenterTitle();
08776 hGainVsMean->GetYaxis()->SetTitle("Gain (mean/NPE)");
08777 hGainVsMean->GetYaxis()->CenterTitle();
08778 hGainVsMean->SetFillColor(0);
08779
08780
08781 TH2F *hGainVsMeanN=new TH2F("hGainVsMeanN","Gain vs ADC",
08782 500,0,15000,200,0,250);
08783 hGainVsMeanN->GetXaxis()->SetTitle("ADC");
08784 hGainVsMeanN->GetXaxis()->CenterTitle();
08785 hGainVsMeanN->GetYaxis()->SetTitle("Gain (mean/NPE)");
08786 hGainVsMeanN->GetYaxis()->CenterTitle();
08787 hGainVsMeanN->SetFillColor(2);
08788
08789
08790 TH1F *hGain=new TH1F("hGain","PMT Gains",
08791 numBins1D,minGainBin,maxGainBin);
08792 hGain->GetXaxis()->SetTitle("PMT Gain");
08793 hGain->GetXaxis()->CenterTitle();
08794 hGain->GetYaxis()->SetTitle("");
08795 hGain->GetYaxis()->CenterTitle();
08796 hGain->SetFillColor(0);
08797
08798
08799 TH1F *hGainCut=new TH1F("hGainCut","PMT Gains",
08800 numBins1D,minGainBin,maxGainBin);
08801 hGainCut->GetXaxis()->SetTitle("PMT Gain");
08802 hGainCut->GetXaxis()->CenterTitle();
08803 hGainCut->GetYaxis()->SetTitle("");
08804 hGainCut->GetYaxis()->CenterTitle();
08805 hGainCut->SetFillColor(0);
08806 hGainCut->SetLineColor(2);
08807
08808
08809 TH1F *hGainCut2=new TH1F("hGainCut2","PMT Gains",
08810 numBins1D,minGainBin,maxGainBin);
08811 hGainCut2->GetXaxis()->SetTitle("PMT Gain (mean/NPE)");
08812 hGainCut2->GetXaxis()->CenterTitle();
08813 hGainCut2->GetYaxis()->SetTitle("");
08814 hGainCut2->GetYaxis()->CenterTitle();
08815 hGainCut2->SetFillColor(0);
08816 hGainCut2->SetLineColor(3);
08817
08818
08819 TH1F *hGainFD=new TH1F("hGainFD","PMT Gains",
08820 numBins1D,minGainBin,maxGainBin);
08821 hGainFD->GetXaxis()->SetTitle("PMT Gain");
08822 hGainFD->GetXaxis()->CenterTitle();
08823 hGainFD->GetYaxis()->SetTitle("");
08824 hGainFD->GetYaxis()->CenterTitle();
08825 hGainFD->SetFillColor(0);
08826 hGainFD->SetLineColor(4);
08827 hGainFD->SetFillStyle(3015);
08828 hGainFD->SetFillColor(4);
08829 hGainFD->SetLineWidth(6);
08830
08831
08832 TH1F *hGainND=new TH1F("hGainND","PMT Gains",
08833 numBins1D,minGainBin,maxGainBin);
08834 hGainND->GetXaxis()->SetTitle("PMT Gain");
08835 hGainND->GetXaxis()->CenterTitle();
08836 hGainND->GetYaxis()->SetTitle("");
08837 hGainND->GetYaxis()->CenterTitle();
08838 hGainND->SetLineColor(2);
08839 hGainND->SetFillStyle(3015);
08840 hGainND->SetFillColor(2);
08841 hGainND->SetLineWidth(6);
08842
08843
08844 map<Int_t,LIRun> mPmt;
08845
08849
08850 this->InitialiseLoopVariables();
08851
08852 for(Int_t entry=0;entry<numEvents;entry++){
08853
08854 this->SetLoopVariables(entry,0);
08855
08856
08857 if (mean==0 || rms==0 || numEntries==0) continue;
08858
08859 if (readoutType!=ReadoutType::kScintStrip) continue;
08860
08861 if (correlatedHit==1){
08862
08863 Float_t npe=mean*mean/(rms*rms);
08864 Float_t gain=0.8*mean/npe;
08865
08866
08867 if (detectorType==Detector::kNear) gain = 0.844*rms*rms/mean;
08868
08869 hNpeVsMean->Fill(mean,npe);
08870 if (stripEnd==1){
08871 hGainVsMean->Fill(mean,gain);
08872 }
08873 else if (stripEnd==2){
08874 hGainVsMeanN->Fill(mean,gain);
08875 }
08876
08877 if (plane==pl && crate==cr && printGain==1){
08878 MSG("LIAnalysis",Msg::kInfo)
08879 <<"pl="<<plane
08880 <<", cr="<<crate
08881 <<", chip="<<chip
08882 <<", pb="<<pulserBox
08883 <<", chan="<<channel
08884 <<", mean="<<mean
08885 <<", gain="<<gain
08886 <<endl;
08887 }
08888
08889
08890 if (mean<8000 && mean>200 && numEntries>0.9*pulses){
08891
08892 if (lookup.NearOrFar(crate,pulserBox,nearPulserBox,
08893 farPulserBox,led,detectorType,
08894 plane,runNumber)==LILookup::kNearSide){
08895
08896 if (numericMuxBox>0){
08897 mPmt[numericMuxBox].AddPoint(gain,mean,pixel);
08898 }
08899
08900 if (crate==1 || crate==2){
08901 hGainND->Fill(gain);
08902 }
08903 else if (crate==0){
08904 hGainFD->Fill(gain);
08905 }
08906 }
08907 }
08908 else{
08909
08910 MSG("LIAnalysis",Msg::kInfo)
08911 <<"AB="<<numericMuxBox<<", "<<this->GetElecString()
08912 <<", (m,r,n)=("<<static_cast<Int_t>(mean)
08913 <<","<<static_cast<Int_t>(rms)<<","<<numEntries<<")"
08914 <<", pixel="<<pixel<<", gain="<<gain<<endl;
08915 }
08916
08917 if (mean<8000 && mean>200 && numEntries>0.9*pulses){
08918
08919 if (chip==0){
08920 hGain->Fill(gain);
08921 }
08922 if (chip==1){
08923 hGainCut->Fill(gain);
08924 }
08925 }
08926 if (mean<8000 && mean>800 && numEntries>0.9*pulses){
08927 if (chip==2){
08928 hGainCut2->Fill(gain);
08929 }
08930 if (gain>150){
08931 MSG("LIAnalysis",Msg::kInfo)
08932 <<"High gain: pl="<<plane
08933 <<", "<<this->GetElecString()
08934 <<" mean="<<mean<<", gain="<<gain<<endl;
08935 }
08936 }
08937 }
08938 }
08939
08943
08944 MSG("LIAnalysis",Msg::kInfo)<<"Finished main loop"<<endl;
08945
08946 string sRunNumber=Form("%d",runNumber);
08947
08948 TCanvas *cGain=new TCanvas("cGain","PMT Gain",0,0,1000,600);
08949 cGain->SetFillColor(0);
08950 cGain->cd();
08951 cGain->SetLogy();
08952 hGain->Draw();
08953 hGainCut->Draw("same");
08954 hGainCut2->Draw("same");
08955 s=sRunNumber+"GainHisto.eps";
08956 cGain->Print(s.c_str());
08957
08958 TCanvas *cG=new TCanvas("cG","Gain",0,0,1000,600);
08959 cG->SetFillColor(0);
08960 cG->Divide(2,2);
08961 cG->cd(1);
08962 hGain->Draw();
08963 cG->cd(2);
08964 hGainCut->Draw();
08965 cG->cd(3);
08966 hGainCut2->Draw();
08967
08968 TCanvas *cGain2=new TCanvas("cGain2","PMT Gain2",0,0,1000,600);
08969 cGain2->SetFillColor(0);
08970 cGain2->cd();
08971 hGainCut2->Draw();
08972 s=sRunNumber+"GainHisto8000.eps";
08973 cGain2->Print(s.c_str());
08974
08975 TCanvas *cNpeVsMean=new TCanvas("cNpeVsMean","NPE vs ADC",
08976 0,0,800,500);
08977 cNpeVsMean->SetFillColor(0);
08978 cNpeVsMean->cd();
08979 hNpeVsMean->Draw("box");
08980 s=sRunNumber+"NpeVsADC.eps";
08981 cNpeVsMean->Print(s.c_str());
08982
08983 TCanvas *cGainVsMean=new TCanvas("cGainVsMean","NPE vs ADC",
08984 0,0,800,500);
08985 cGainVsMean->SetFillColor(0);
08986 cGainVsMean->cd();
08987 hGainVsMean->Draw("box");
08988 s=sRunNumber+"GainVsADC.eps";
08989 cGainVsMean->Print(s.c_str());
08990
08991 TCanvas *cGainNF=new TCanvas("cGainNF","PMT Gain NF",0,0,1000,600);
08992 cGainNF->SetFillColor(0);
08993 cGainNF->cd();
08994 hGainFD->Draw();
08995 hGainND->Draw("sames");
08996 s=sRunNumber+"GainNF.eps";
08997 cGainNF->Print(s.c_str());
08998
08999 map<Int_t,LIRun>::iterator pmtIt;
09000 if (!mPmt.empty()){
09001 pmtIt=mPmt.begin();
09002 }
09003 else{
09004 MSG("LIAnalysis",Msg::kWarning)
09005 <<"PMT map is empty!"<<endl;
09006 }
09007
09008 vector<Double_t> vGain;
09009 vector<Double_t> vNumericMux;
09010
09011 while (pmtIt!=mPmt.end()){
09012
09013 MSG("LIAnalysis",Msg::kInfo)
09014 <<pmtIt->first<<endl;
09015 pmtIt->second.PrintAll();
09016
09017 vector<Double_t> vTempGain=pmtIt->second.GetPh();
09018 vector<Double_t> vTempMux(vTempGain.size(),pmtIt->first);
09019 this->AppendVect(vGain,vTempGain);
09020 this->AppendVect(vNumericMux,vTempMux);
09021
09022 MSG("LIAnalysis",Msg::kInfo)
09023 <<"s1="<<vGain.size()<<", s2="<<vNumericMux.size()<<endl;
09024 pmtIt++;
09025 }
09026
09027 TGraph* gGainVsMux=this->TGraphVect(vNumericMux,vGain);
09028
09029 TCanvas *cGainVsMux=new TCanvas("cGainVsMux","GainVsMux adc",
09030 0,0,1200,800);
09031 cGainVsMux->SetFillColor(0);
09032 fS="Gain vs ND Mux box";
09033 gGainVsMux->Draw("AP");
09034 gGainVsMux->SetTitle(fS.c_str());
09035 gGainVsMux->GetXaxis()->SetTitle("ND Mux box");
09036 gGainVsMux->GetYaxis()->SetTitle("Gain");
09037 gGainVsMux->GetXaxis()->CenterTitle();
09038 gGainVsMux->GetYaxis()->CenterTitle();
09039 gGainVsMux->SetMarkerStyle(3);
09040 gGainVsMux->SetMarkerColor(2);
09041 gGainVsMux->SetMarkerSize(0.35);
09042 gGainVsMux->SetLineColor(46);
09043
09044 MSG("LIAnalysis",Msg::kInfo)
09045 <<endl<<" ** Finished the PmtGain method ** "<<endl;
09046 }
09047
09048
09049
09050 void LIAnalysis::NumPulses()
09051 {
09052 MSG("LIAnalysis",Msg::kInfo)
09053 <<endl<<" ** Running the NumPulses method... ** "<<endl;
09054
09055
09056 gStyle->SetOptStat(1111111);
09057
09058
09059 chain->GetEvent(0);
09060 Int_t numBins=pulses+300;
09061 Float_t maxBin=pulses+300.;
09062
09063 TH1F **hNumEntries=0;
09064 hNumEntries=new TH1F*[NUMPULSERBOXES];
09065 for (Int_t i=0;i<NUMPULSERBOXES;i++){
09066 string sPb=Form("%d",i);
09067 s="Pulses detected (all hits), Pulser Box "+sPb;
09068 hNumEntries[i]=new TH1F(s.c_str(),s.c_str(),numBins,0,maxBin);
09069 hNumEntries[i]->GetXaxis()->SetTitle("Number of Pulses");
09070 hNumEntries[i]->GetXaxis()->CenterTitle();
09071 hNumEntries[i]->GetYaxis()->SetTitle("Number of Entries");
09072 hNumEntries[i]->GetYaxis()->CenterTitle();
09073 hNumEntries[i]->SetFillColor(0);
09074 hNumEntries[i]->SetBit(TH1::kCanRebin);
09075 }
09076
09077 TH1F **hNumEntriesCor=0;
09078 hNumEntriesCor=new TH1F*[NUMPULSERBOXES];
09079 for (Int_t i=0;i<NUMPULSERBOXES;i++){
09080 string sPb=Form("%d",i);
09081 s="Pulses Detected (correlated hits), Pulser Box "+sPb;
09082 hNumEntriesCor[i]=new TH1F(s.c_str(),s.c_str(),numBins,0,maxBin);
09083 hNumEntriesCor[i]->GetXaxis()->SetTitle("Number of Pulses");
09084 hNumEntriesCor[i]->GetXaxis()->CenterTitle();
09085 hNumEntriesCor[i]->GetYaxis()->SetTitle("Number of Entries");
09086 hNumEntriesCor[i]->GetYaxis()->CenterTitle();
09087 hNumEntriesCor[i]->SetFillColor(0);
09088 hNumEntriesCor[i]->SetLineColor(2);
09089 hNumEntriesCor[i]->SetBit(TH1::kCanRebin);
09090 }
09091
09092 numBins=(pulses+100)/3;
09093 maxBin=pulses+100.;
09094
09095 TH2F **hNumPulsesVsAdcN=0;
09096 hNumPulsesVsAdcN=new TH2F*[NUMPULSERBOXES];
09097 for (Int_t i=0;i<NUMPULSERBOXES;i++){
09098 string sPb=Form("%d",i);
09099 s="Pulses Detected Vs ADC (correlated hits), Pulser Box "+
09100 sPb;
09101 hNumPulsesVsAdcN[i]=new TH2F(s.c_str(),s.c_str(),
09102 5000,0,15000,numBins,0,maxBin);
09103 hNumPulsesVsAdcN[i]->GetXaxis()->SetTitle("ADC");
09104 hNumPulsesVsAdcN[i]->GetXaxis()->CenterTitle();
09105 hNumPulsesVsAdcN[i]->GetYaxis()->SetTitle("Number of Pulses");
09106 hNumPulsesVsAdcN[i]->GetYaxis()->CenterTitle();
09107 hNumPulsesVsAdcN[i]->SetFillColor(0);
09108 hNumPulsesVsAdcN[i]->SetLineColor(2);
09109 hNumPulsesVsAdcN[i]->SetBit(TH1::kCanRebin);
09110 }
09111
09112 TH2F **hNumPulsesVsAdcF=0;
09113 hNumPulsesVsAdcF=new TH2F*[NUMPULSERBOXES];
09114 for (Int_t i=0;i<NUMPULSERBOXES;i++){
09115 string sPb=Form("%d",i);
09116 s="Pulses Detected Vs ADC (correlated hits, F), Pulser Box "+
09117 sPb;
09118 hNumPulsesVsAdcF[i]=new TH2F(s.c_str(),s.c_str(),
09119 5000,0,15000,numBins,0,maxBin);
09120 hNumPulsesVsAdcF[i]->GetXaxis()->SetTitle("ADC");
09121 hNumPulsesVsAdcF[i]->GetXaxis()->CenterTitle();
09122 hNumPulsesVsAdcF[i]->GetYaxis()->SetTitle("Number of Pulses");
09123 hNumPulsesVsAdcF[i]->GetYaxis()->CenterTitle();
09124 hNumPulsesVsAdcF[i]->SetFillColor(0);
09125 hNumPulsesVsAdcF[i]->SetLineColor(3);
09126 hNumPulsesVsAdcF[i]->SetBit(TH1::kCanRebin);
09127 }
09128
09132
09133 this->InitialiseLoopVariables();
09134
09135 for(Int_t entry=0;entry<numEvents;entry++){
09136
09137 this->SetLoopVariables(entry,0);
09138
09139
09140 if (mean==0 || rms==0 || numEntries==0) continue;
09141
09142 if (readoutType!=ReadoutType::kScintStrip) continue;
09143
09144 if (pulserBox>=FIRSTPULSERBOX && pulserBox<=LASTPULSERBOX){
09145 hNumEntries[pulserBox]->Fill(numEntries);
09146 }
09147
09148
09149 if (correlatedHit==1 && mean>0){
09150 if (pulserBox>=FIRSTPULSERBOX && pulserBox<=LASTPULSERBOX){
09151 if (pulserBox==nearPulserBox){
09152 hNumPulsesVsAdcN[pulserBox]->Fill(mean,numEntries);
09153 }
09154 else if (pulserBox==farPulserBox){
09155 hNumPulsesVsAdcF[pulserBox]->Fill(mean,numEntries);
09156 }
09157 hNumEntriesCor[pulserBox]->Fill(numEntries);
09158 }
09159 MSG("LIAnalysis",Msg::kVerbose)
09160 <<"correlatedHit="<<correlatedHit
09161 <<", farPulserBox="<<farPulserBox
09162 <<", nearPulserBox="<<nearPulserBox
09163 <<", pulserBox="<<pulserBox
09164 <<endl;
09165 }
09166 }
09167
09171
09172 MSG("LIAnalysis",Msg::kInfo)<<"Finished main loop"<<endl;
09173
09174 string sRunNumber=Form("%d",runNumber);
09175
09176 for (Int_t i=0;i<NUMPULSERBOXES;i++){
09177 MSG("LIAnalysis",Msg::kInfo)
09178 <<"Pulser box "<<i
09179 <<", mean num pulses="<<hNumEntriesCor[i]->GetMean()
09180 <<", rms="<<hNumEntriesCor[i]->GetRMS()
09181 <<endl;
09182 }
09183
09184 TCanvas *cNumPulses=new TCanvas("cNumPulses","NumPulses adc",
09185 0,0,1200,800);
09186 cNumPulses->SetFillColor(0);
09187
09188 cNumPulses->Divide(1,2);
09189 for (Int_t i=0;i<NUMPULSERBOXES;i++){
09190 cNumPulses->Clear();
09191 cNumPulses->Divide(1,2);
09192 cNumPulses->cd(1);
09193 hNumEntriesCor[i]->Draw();
09194 cNumPulses->cd(2);
09195 hNumEntries[i]->Draw();
09196 if (i==0){
09197 s=sRunNumber+"NumPulses.ps(";
09198 cNumPulses->Print(s.c_str());
09199 }
09200 else if(i==NUMPULSERBOXES-1){
09201 s=sRunNumber+"NumPulses.ps)";
09202 cNumPulses->Print(s.c_str());
09203 }
09204 else{
09205 s=sRunNumber+"NumPulses.ps";
09206 cNumPulses->Print(s.c_str());
09207 }
09208 }
09209
09210 cNumPulses->Clear();
09211 cNumPulses->Divide(1,2);
09212 cNumPulses->cd(1);
09213 hNumEntriesCor[0]->Draw();
09214 cNumPulses->cd(2);
09215 hNumEntries[0]->Draw();
09216
09217
09218 gStyle->SetOptStat(0);
09219 TCanvas *cNumPulsesVsAdc=new TCanvas("cNumPulsesVsAdc",
09220 "NumPulsesVsAdc adc",
09221 0,0,1200,800);
09222 cNumPulsesVsAdc->SetFillColor(0);
09223 cNumPulsesVsAdc->cd();
09224 for (Int_t i=0;i<NUMPULSERBOXES;i++){
09225 cNumPulsesVsAdc->Clear();
09226 hNumPulsesVsAdcF[i]->Draw("box");
09227 hNumPulsesVsAdcN[i]->Draw("boxsame");
09228 if (i==0){
09229 s=sRunNumber+"NumPulsesVsAdc.ps(";
09230 cNumPulsesVsAdc->Print(s.c_str());
09231 }
09232 else if(i==NUMPULSERBOXES-1){
09233 s=sRunNumber+"NumPulsesVsAdc.ps)";
09234 cNumPulsesVsAdc->Print(s.c_str());
09235 }
09236 else{
09237 s=sRunNumber+"NumPulsesVsAdc.ps";
09238 cNumPulsesVsAdc->Print(s.c_str());
09239 }
09240 }
09241 cNumPulsesVsAdc->Clear();
09242 hNumPulsesVsAdcF[0]->Draw("box");
09243 hNumPulsesVsAdcN[0]->Draw("boxsame");
09244
09245 MSG("LIAnalysis",Msg::kInfo)
09246 <<endl<<" ** Finished the NumPulses method ** "<<endl;
09247 }
09248
09249
09250 void LIAnalysis::GainVsTime()
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;
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;
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
09300 if (calibType!=1){
09301 MSG("LIAnalysis",Msg::kInfo)
09302 <<" *** WARNING, Gain Curve file ***"<<endl
09303 <<"Run number = "<<runNumber<<endl;
09304 }
09305
09306
09307 if (lastLed-led>0 && lastPulserBox-pulserBox>0){
09308
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
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
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
09338
09339 }
09340
09341
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);
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
09380 if (led!=lastLed) liEvent++;
09381
09382 lastLed=led;
09383 lastPulserBox=pulserBox;
09384 lastCalibPoint=calibPoint;
09385
09386
09387 if (mean==0 || rms==0 || numEntries==0) continue;
09388
09389
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
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 }
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
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
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
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
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 }
09529
09530
09531
09532 void LIAnalysis::LISnarlProblem()
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
09564 if (mean==0 || rms==0 || numEntries==0) continue;
09565
09566
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 }
09592
09596
09597 MSG("LIAnalysis",Msg::kInfo)<<"Finished main loop"<<endl;
09598
09599
09600 gStyle->SetOptStat(1111111);
09601
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 }
09617
09618
09619
09620 void LIAnalysis::AdcVsLed()
09621 {
09622 MSG("LIAnalysis",Msg::kInfo)
09623 <<endl<<" ** Running the AdcVsLed method... ** "<<endl;
09624
09625 Int_t numAdcBins=150;
09626
09627
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
09633 Int_t l=i*NUMLEDS+j;
09634
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
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
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
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
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
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
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
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
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
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
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
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
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
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
09894 if (mean==0 || rms==0 || numEntries==0) continue;
09895
09896 if (readoutType!=ReadoutType::kScintStrip) continue;
09897
09898
09899 Float_t npe=mean*mean/(rms*rms);
09900 Float_t gain=0.8*mean/npe;
09901
09902
09903 if (detectorType==Detector::kNear) gain = 0.844*rms*rms/mean;
09904
09905
09906 Int_t l=pulserBox*NUMLEDS+led-1;
09907
09908 if (correlatedHit==1){
09909
09910 if (detectorType==Detector::kFar
09911 || detectorType==Detector::kNear){
09912 if (pulserBox>=FIRSTPULSERBOX && pulserBox<=LASTPULSERBOX &&
09913 led>=FIRSTLED && led<=LASTLED){
09914
09915
09916 ph[l]=pulseHeight;
09917
09918
09919 hAdcLed[l]->Fill(mean);
09920
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
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
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
09954 else if (detectorType==Detector::kCalDet){
09955 if (pulserBox>=FIRSTPULSERBOX && pulserBox<=LASTPULSERBOX &&
09956 crate>=FIRSTCRATE && crate<=LASTCRATE &&
09957 led>=FIRSTLED && led<=LASTLED){
09958
09959
09960 ph[l]=pulseHeight;
09961
09962
09963 hAdcLed[l]->Fill(mean);
09964
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
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 }
09991
09995
09996 MSG("LIAnalysis",Msg::kInfo)<<"Finished main loop"<<endl;
09997
09998
09999 gStyle->SetOptStat(1111111);
10000
10001 string sRunNumber=Form("%d",runNumber);
10002 string sLowRunNumber=Form("%d",lowRunNumber);
10003
10004
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
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
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);
10063 TGraph *gGainUW=new TGraph(7);
10064 TGraph *gGainLE=new TGraph(7);
10065 TGraph *gGainLW=new TGraph(7);
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
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
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
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
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
10238 if (nearAdc>nearAdcMax) nearAdcMax=nearAdc;
10239 if (farAdc>farAdcMax) farAdcMax=farAdc;
10240
10241
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
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
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
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
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
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
10453
10454 }
10455 }
10456 }
10457
10458
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
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
10485
10486
10487
10488
10489
10490
10491
10492
10493 if (sLowRunNumber==sRunNumber) s=sRunNumber+"AdcVsLed.ps(";
10494 else s=sLowRunNumber+"-"+sRunNumber+"AdcVsLed.ps(";
10495 cAdcLedGraph->Print(s.c_str());
10496
10497
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
10524 if (sLowRunNumber==sRunNumber) s=sRunNumber+"AdcVsLed.ps";
10525 else s=sLowRunNumber+"-"+sRunNumber+"AdcVsLed.ps";
10526 cErrorsAdcLedGraph->Print(s.c_str());
10527
10528
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
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();
10549 gErrorsAdcLedFar->SetMinimum();
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
10559 if (sLowRunNumber==sRunNumber) s=sRunNumber+"AdcVsLed.ps)";
10560 else s=sLowRunNumber+"-"+sRunNumber+"AdcVsLed.ps)";
10561 cErrorsAdcLedGraphFar->Print(s.c_str());
10562
10563
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
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
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
10626 if (sLowRunNumber==sRunNumber) s=sRunNumber+"GainVsLed.ps)";
10627 else s=sLowRunNumber+"-"+sRunNumber+"GainVsLed.ps)";
10628 cGain->Print(s.c_str());
10629
10630
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
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
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
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 }
10700
10701
10702
10703 void LIAnalysis::LedTuning(Int_t pNum,Int_t pWidth,
10704 Int_t idealAdc,const Int_t numGcPoints,
10705 Double_t firstGcPointAdc,
10706 Double_t lastGcPointAdc,
10707 Double_t dADCdPHAtSat,Int_t numCalibPoints,
10708 Int_t numSecondFile)
10709 {
10763 MSG("LIAnalysis",Msg::kInfo)
10764 <<endl<<" ** Running the LedTuning method... ** "<<endl;
10765
10766 chain->GetEvent(0);
10767
10768
10769 if (numCalibPoints==-1){
10770 numCalibPoints=calibType;
10771 }
10772
10773
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
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
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;
10895 Int_t lastCp=999999;
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
10910 if (mean==0 || rms==0 || numEntries==0) continue;
10911
10912
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
10921 c=calibPoint-1+secondFile;
10922 Int_t index=pulserBox*NUMLEDS*const_numCalibPoints+
10923 (led-1)*const_numCalibPoints+c;
10924
10925
10926
10927 if (lastCp-calibPoint>0){
10928
10929 MSG("LIAnalysis",Msg::kDebug)
10930 <<"pulser box="<<pulserBox
10931 <<", led="<<led<<", PH="<<pulseHeight<<endl;
10932
10933 secondFile=0;
10934 }
10935 lastCp=calibPoint;
10936
10937
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
10950 if (readoutType==ReadoutType::kPinDiode){
10951
10952 if (pulserBox>=FIRSTPULSERBOX && pulserBox<=LASTPULSERBOX &&
10953 led>=FIRSTLED && led<=LASTLED){
10954
10955 if (detectorType==Detector::kNear) {
10956
10957
10958
10959
10960
10961
10962
10963
10964 if (correlatedHit) {
10965 if (masterCh==1||masterCh==2||masterCh==3||masterCh==5){
10966
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
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){
10993
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){
11002
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
11014
11015 if (chip==1){
11016
11017 if (mean>adcHighPin[index]){
11018 adcHighPin[index]=mean;
11019 }
11020
11021 }
11022 else if (chip==0){
11023
11024 if (mean>adcLowPin[index]>0) {
11025 adcLowPin[index]=mean;
11026 }
11027 }
11028 }
11029 }
11030 }
11031 }
11032
11033
11034 if (readoutType!=ReadoutType::kScintStrip) continue;
11035
11036
11037 if (correlatedHit==1){
11038 Int_t l=pulserBox*NUMLEDS+led-1;
11039
11040 ledFlashed[l]=1;
11041
11042 if (detectorType==Detector::kFar || detectorType==Detector::kNear){
11043
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
11052 hAdcPh[l][c]->Fill(mean);
11053
11054 if (nearPulserBox==pulserBox){
11055 hAdcPhNear[l][c]->Fill(mean);
11056 nearPmt[index].hits[mean]++;
11057 nearPmtAv[index]+=mean;
11058 nearPmtNum[index]++;
11059 }
11060
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
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
11078 hAdcPh[l][c]->Fill(mean);
11079
11080 if (nearLed==led){
11081 hAdcPhNear[l][c]->Fill(mean);
11082 nearPmt[index].hits[mean]++;
11083 nearPmtAv[index]+=mean;
11084 nearPmtNum[index]++;
11085 }
11086
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 }
11097
11101
11102 MSG("LIAnalysis",Msg::kInfo)<<"Finished main loop"<<endl;
11103
11104
11105 LITuning tune;
11106
11107
11108 gStyle->SetOptStat(1111111);
11109
11110 string sRunNumber=Form("%d",runNumber);
11111 string sLowRunNumber=Form("%d",lowRunNumber);
11112 string sHighRunNumber=Form("%d",highRunNumber);
11113 s="";
11114
11116
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
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
11141 map<Int_t,Double_t> nearPmtMidAv;
11142 map<Int_t,Double_t> farPmtMidAv;
11143
11144 while(nearPmtIter!=nearPmt.end()){
11145
11146
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
11193 phIter=ph.begin();
11194
11195 while(farPmtIter!=farPmt.end()){
11196
11197
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
11234 nearPmt.clear();
11235 farPmt.clear();
11236
11238
11240 MSG("LIAnalysis",Msg::kInfo)<<"Plotting histograms..."<<endl;
11241
11242 TCanvas *cAdcPh=new TCanvas("cAdcPh","cAdcPh",0,0,1000,600);
11243 cAdcPh->SetFillColor(0);
11244 cAdcPh->cd();
11245
11246
11247 Int_t maxNumEnt=0;
11248 for (Int_t i=0;i<NUMPULSERBOXES*NUMLEDS;i++){
11249
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
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
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
11277 if (ledFlashed[l]!=1) continue;
11278 for (Int_t k=0;k<const_numCalibPoints;k++){
11279
11280
11281 Int_t index=i*NUMLEDS*const_numCalibPoints+
11282 j*const_numCalibPoints+k;
11283
11284
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
11308 cAdcPh->Print(sAdcPh.c_str());
11309 }
11310 }
11311 }
11312
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
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
11330 if (ledFlashed[l]!=1) continue;
11331 else{
11332
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
11344 Int_t index=i*NUMLEDS*const_numCalibPoints+
11345 j*const_numCalibPoints+k;
11346
11347
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
11369 tune.InputDataGc(gCurveData);
11370
11371
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
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
11387 tune.CalculateDriftPoints();
11388
11389
11390
11391 tune.CalculateGainCurve(LITuning::kGcLinearInPinAdc);
11392
11394
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
11408 TCanvas *cTunedGc=new TCanvas("cTunedGc","cTunedGc",0,0,1200,600);
11409 cTunedGc->SetFillColor(0);
11410
11411 gStyle->SetOptStat(0);
11412
11413
11414 string sName="TunedGc.ps";
11415 if (sLowRunNumber==sHighRunNumber) fS=sHighRunNumber+sName;
11416 else fS=sLowRunNumber+"-"+sHighRunNumber+sName;
11417
11418
11419 cTunedGc->Print((fS+"[").c_str());
11420 gErrorIgnoreLevel=1;
11421
11422
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
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
11471 TCanvas *cGcData=new TCanvas("cGcData","cGcData",0,0,1200,600);
11472 cGcData->SetFillColor(0);
11473
11474 gStyle->SetOptStat(0);
11475
11476
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
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
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
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
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
11586 TGraph* gAdcVsLed=0;
11587 TGraph* gPhVsLed=0;
11588 TGraph* gPinVsLed=0;
11589
11590 if (tune.GetTunedDpGraphs(gAdcVsLed,gPhVsLed,gPinVsLed,NUMLEDS)){
11591
11592
11593 TCanvas *cTunedDp=new TCanvas("cTunedDp","cTunedDp",0,0,1200,600);
11594 cTunedDp->SetFillColor(0);
11595
11596 gStyle->SetOptStat(0);
11597
11598
11599 string sPrefix="";
11600 if (sLowRunNumber==sHighRunNumber) sPrefix=sHighRunNumber;
11601 else sPrefix=sLowRunNumber+"-"+sHighRunNumber;
11602 string sTunedDp=sPrefix+"TunedDp.ps";
11603
11604
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
11643
11644
11645
11646
11647
11648 cTunedDp->Print(sTunedDp.c_str());
11649
11650
11651 if (MsgService::Instance()->IsActive("LIAnalysis",Msg::kDebug)){
11652 gErrorIgnoreLevel=0;
11653 }
11654 cTunedDp->Print((sTunedDp+"]").c_str());
11655 gErrorIgnoreLevel=0;
11656 }
11657
11658
11659 tune.PrintLedCheckGrid(LIRun::kDriftPoint,
11660 FIRSTPULSERBOX,LASTPULSERBOX,
11661 FIRSTLED,LASTLED);
11662 tune.PrintLedCheckGrid(LIRun::kGainCurve,
11663 FIRSTPULSERBOX,LASTPULSERBOX,
11664 FIRSTLED,LASTLED);
11665
11666
11667 tune.PrintLIConfig(LIRun::kDriftPoint);
11668 tune.PrintLIConfig(LIRun::kGainCurve);
11669
11670
11671 tune.PrintConfig();
11672
11673 MSG("LIAnalysis",Msg::kInfo)
11674 <<endl<<" ** Finished the LedTuning method ** "<<endl;
11675 }
11676
11677
11678
11679 void LIAnalysis::GainCurves_Led()
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
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
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
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
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
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
11851 if (mean==0 || rms==0 || numEntries==0) continue;
11852
11853 Int_t c=calibPoint-1;
11854
11855
11856 if (readoutType==ReadoutType::kPinDiode){
11857
11858 if (pulserBox>=FIRSTPULSERBOX && pulserBox<=LASTPULSERBOX &&
11859 led>=FIRSTLED && led<=LASTLED){
11860
11861 Int_t l=pulserBox*NUMLEDS+led-1;
11862
11863
11864
11865 if (chip==1){
11866
11867 if (mean>maxAdcHighPin[l][c]) {
11868 maxAdcHighPin[l][c]=mean;
11869 }
11870 }
11871 else if (chip==0){
11872
11873 if (mean>maxAdcLowPin[l][c]) {
11874 maxAdcLowPin[l][c]=mean;
11875 }
11876 }
11877
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
11889 if (readoutType!=ReadoutType::kScintStrip) continue;
11890
11891
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
11903 hAdcPh[l][c]->Fill(mean);
11904
11905 if (nearPulserBox==pulserBox){
11906 hAdcPhNear[l][c]->Fill(mean);
11907 }
11908
11909 else if (farPulserBox==pulserBox) {
11910 hAdcPhFar[l][c]->Fill(mean);
11911 }
11912 }
11913 }
11914
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
11926 hAdcPh[l][c]->Fill(mean);
11927
11928 if (nearLed==led){
11929 hAdcPhNear[l][c]->Fill(mean);
11930 }
11931
11932 else if (farLed==led) {
11933 hAdcPhFar[l][c]->Fill(mean);
11934 }
11935 }
11936 }
11937 }
11938 }
11939
11943
11944 MSG("LIAnalysis",Msg::kInfo)<<"Finished main loop"<<endl;
11945
11946
11947 gStyle->SetOptStat(1111111);
11948
11949 string sRunNumber=Form("%d",runNumber);
11950 string sLowRunNumber=Form("%d",lowRunNumber);
11951 string sHighRunNumber=Form("%d",highRunNumber);
11952 s="";
11953
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
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
11976 gAdcVsPinNear[l]->SetMinimum(-1);
11977 gAdcVsPinFar[l]->SetMinimum(-1);
11978
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
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
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
12010 gAdcVsPinNear[l]->SetPoint(k,maxAdcLowPin[l][k],
12011 hAdcPhNear[l][k]->GetMean());
12012
12013 gAdcVsPinFar[l]->SetPoint(k,maxAdcLowPin[l][k],
12014 hAdcPhFar[l][k]->GetMean());
12015 if (maxAdcLowPin[l][k]>0){
12016
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
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
12038
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
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
12070 Double_t fittedYval=funcM*actualX+funcC;
12071
12072
12073 Double_t resid=actualYval-fittedYval;
12074 resid/=fittedYval;
12075
12076
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
12099 TCanvas *c=new TCanvas("c","c",0,0,1200,600);
12100 c->SetFillColor(0);
12101
12102
12103 gStyle->SetOptFit(0000);
12104
12105
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
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
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
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
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
12179
12180
12181 s="GainCurvesNonLin_Led.ps";
12182
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
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
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
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 }
12256
12257
12258
12259 void LIAnalysis::GainCurves(Int_t pulserBoxToPlot,Int_t maxLedToPlot)
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
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
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
12320 if (mean==0 || rms==0 || numEntries==0) continue;
12321
12322
12323
12324 if (pulserBox!=pulserBoxToPlot) continue;
12325
12326
12327 if (led>maxLedToPlot) continue;
12328
12329
12330 if (numEntries<0.5*pulses) continue;
12331
12332 Int_t c=calibPoint-1;
12333
12334
12335 if (readoutType==ReadoutType::kPinDiode){
12336
12337 if (pulserBox>=FIRSTPULSERBOX && pulserBox<=LASTPULSERBOX &&
12338 led>=FIRSTLED && led<=LASTLED &&
12339 c<const_numCalibPoints){
12340
12341 Int_t l=pulserBox*NUMLEDS+led-1;
12342
12343 if (usePinPlex){
12344 if (correlatedHit==1){
12345 if (chip==1){
12346
12347 maxAdcHighPin[l][c]=mean;
12348 }
12349 else if (chip==0){
12350
12351 maxAdcLowPin[l][c]=mean;
12352 }
12353 }
12354 }
12355 else{
12356
12357 if (chip==1){
12358
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){
12370
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 }
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
12407 if (mean==0 || rms==0 || numEntries==0) continue;
12408
12409
12410 if (readoutType!=ReadoutType::kScintStrip) continue;
12411
12412
12413
12414 if (pulserBox!=pulserBoxToPlot) continue;
12415
12416
12417 if (led>maxLedToPlot) continue;
12418
12419
12420
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
12436 mean*=(numEntries/pulses);
12437 }
12438 }
12439
12440
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
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
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,
12460 numEntries);
12461 }
12462
12463 else if (farPulserBox==pulserBox) {
12464
12465 }
12466 }
12467 }
12468
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
12483 if (lookup.NearOrFar(crate,pulserBox,nearPulserBox,
12484 farPulserBox,led,detectorType,
12485 plane,runNumber)==
12486 LILookup::kNearSide){
12487
12488 gCurveData[se].SetLIInfo(pulserBox,led,LIRun::kGainCurve);
12489 gCurveData[se].AddPoint(pulseHeight,mean,
12490 maxAdcHighPin[l][c],
12491 maxAdcLowPin[l][c],
12492 rms,
12493 numEntries);
12494 }
12495
12496 else if (lookup.NearOrFar(crate,pulserBox,nearPulserBox,
12497 farPulserBox,led,detectorType,
12498 plane,runNumber)==
12499 LILookup::kFarSide) {
12500
12501
12502
12503 }
12504 }
12505 }
12506 }
12507 }
12508
12512
12513 MSG("LIAnalysis",Msg::kInfo)
12514 <<"Finished main loop"<<endl;
12515
12516
12517 gStyle->SetOptStat(1111111);
12518
12519
12520 gStyle->SetOptFit(0000);
12521
12522
12523 string sRunNumber=Form("%d",runNumber);
12524 string sLowRunNumber=Form("%d",lowRunNumber);
12525 string sHighRunNumber=Form("%d",highRunNumber);
12526 s="";
12527
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
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
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
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
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
12605 if (i==0 && detectorType==Detector::kCalDet) continue;
12606
12607
12608 if (i>=10 && detectorType==Detector::kCalDet) continue;
12609
12610
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
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
12632 vector<Double_t> numEntries;
12633 numEntries=gCurveData[se].GetAdcLow();
12634 vector<Double_t> rms;
12635 rms=gCurveData[se].GetAdcF();
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
12653 fitPoint=-1;
12654 firstGoodAdcPoint=-1;
12655 nonLinNormPoint=-1;
12656 maxRatio=-1;
12657
12658
12659 if (adc.size()>0){
12660
12661
12662 if (i%3==0 && j%6==0){
12663 MSG("LIAnalysis",Msg::kInfo)
12664 <<"Processing plane="<<sPlStEnd<<endl;
12665 }
12666
12667
12668 for (UInt_t p=0;p<adc.size();p++){
12669
12670
12671 Double_t ey=0;
12672 if (numEntries[p]>0){
12673 ey=rms[p]/sqrt(numEntries[p]);
12674 }
12675
12676
12677 gGc->SetPoint(p,pin[p],adc[p]);
12678 gGc->SetPointError(p,0.,ey);
12679
12680
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
12690 if (adc[p]>400 && firstGoodAdcPoint==-1){
12691 firstGoodAdcPoint=p;
12692 MSG("LIAnalysis",Msg::kDebug)
12693 <<sPlStEnd<<" firstGoodAdcPoint="<<firstGoodAdcPoint
12694 <<", adc="<<adc[firstGoodAdcPoint]
12695 <<", pin="<<pin[firstGoodAdcPoint]<<endl;
12696
12697
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
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
12725 if (fitPoint==-1) fitPoint=0;
12726 if (firstGoodAdcPoint==-1) firstGoodAdcPoint=0;
12727 if (nonLinNormPoint==-1) nonLinNormPoint=0;
12728
12729
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
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
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
12775 Double_t fittedYval=funcM*actualX+funcC;
12776
12777
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
12794
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
12801 Int_t resIndex=se-25;
12802 if (resIndex>=0 && resIndex<5){
12803 vResid[resIndex]->SetPoint(k,actualYval,resid);
12804 }
12805
12806
12807
12808
12809
12810
12811
12812
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
12869 for (UInt_t p=0;p<adc.size();p++){
12870
12871 if (pin[p]!=0 && pin[nonLinNormPoint]!=0 &&
12872 adc[nonLinNormPoint]!=0){
12873
12874 Double_t ratio=adc[p]/pin[p];
12875 Double_t normRatio=adc[nonLinNormPoint]/
12876 pin[nonLinNormPoint];
12877
12878 gNonLin->SetPoint(p,adc[p],ratio/normRatio);
12879 gNonLinPin->SetPoint(p,pin[p],ratio/normRatio);
12880
12881
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
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
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
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
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 }
13020
13021
13022
13023 void LIAnalysis::Reflectors(LILookup::ELINearOrFarSide nearOrFarSide)
13024 {
13025 MSG("LIAnalysis",Msg::kInfo)
13026 <<endl<<" ** Running the Reflectors method... ** "<<endl;
13027
13028 chain->GetEvent(0);
13029 const Int_t const_numCalibPoints=calibType;
13030
13031 MSG("LIAnalysis",Msg::kInfo)
13032 <<"Using "<<const_numCalibPoints<<" calibPoints"<<endl;
13033 MSG("LIAnalysis",Msg::kInfo)
13034 <<"Number of pulser boxes = "<<NUMPULSERBOXES
13035 <<", leds = "<<NUMLEDS
13036 <<endl<<endl;
13037
13038 MSG("LIAnalysis",Msg::kInfo)
13039 <<"Creating LIRun objects"<<endl;
13040 vector<LIRun> liData(NUMSIDES*NUMPLANES*NUMSTRIPS);
13041 vector<LIRun> liData2(NUMSIDES*NUMPLANES*NUMSTRIPS);
13042
13043 Float_t **maxAdcHighPin=0;
13044 maxAdcHighPin=new Float_t*[NUMLEDS*NUMPULSERBOXES];
13045 Float_t **maxAdcLowPin=0;
13046 maxAdcLowPin=new Float_t*[NUMLEDS*NUMPULSERBOXES];
13047 Float_t **maxAdcHighPin2=0;
13048 maxAdcHighPin2=new Float_t*[NUMLEDS*NUMPULSERBOXES];
13049 Float_t **maxAdcLowPin2=0;
13050 maxAdcLowPin2=new Float_t*[NUMLEDS*NUMPULSERBOXES];
13051
13052
13053 for (Int_t i=0;i<NUMPULSERBOXES;i++){
13054 for (Int_t j=0;j<NUMLEDS;j++){
13055 Int_t l=i*NUMLEDS+j;
13056
13057 maxAdcHighPin[l]=new Float_t[const_numCalibPoints];
13058 maxAdcLowPin[l]=new Float_t[const_numCalibPoints];
13059 maxAdcHighPin2[l]=new Float_t[const_numCalibPoints];
13060 maxAdcLowPin2[l]=new Float_t[const_numCalibPoints];
13061
13062 for (Int_t k=0;k<const_numCalibPoints;k++){
13063 maxAdcHighPin[l][k]=0;
13064 maxAdcLowPin[l][k]=0;
13065 maxAdcHighPin2[l][k]=0;
13066 maxAdcLowPin2[l][k]=0;
13067 }
13068 }
13069 }
13070
13071 MSG("LIAnalysis",Msg::kInfo)
13072 <<endl<<"Looping to find pins"<<endl;
13073
13077
13078 this->InitialiseLoopVariables();
13079
13080 for(Int_t entry=0;entry<numEvents;entry++){
13081
13082 this->SetLoopVariables(entry,1);
13083
13084
13085 if (mean==0 || rms==0 || numEntries==0) continue;
13086
13087
13088 if (numEntries<0.5*pulses) continue;
13089
13090 Int_t c=calibPoint-1;
13091
13092
13093 if (runNumber==61753 && calibPoint!=17) continue;
13094 else c=0;
13095 if (runNumber==highRunNumber) run=1;
13096 else run=0;
13097
13098
13099 if (readoutType==ReadoutType::kPinDiode){
13100
13101 if (pulserBox>=FIRSTPULSERBOX && pulserBox<=LASTPULSERBOX &&
13102 led>=FIRSTLED && led<=LASTLED &&
13103 c<const_numCalibPoints){
13104
13105 Int_t l=pulserBox*NUMLEDS+led-1;
13106
13107
13108 if (run==0){
13109 if (chip==1){
13110
13111 if (mean>maxAdcHighPin[l][c]) {
13112 maxAdcHighPin[l][c]=mean;
13113 MSG("LIAnalysis",Msg::kInfo)
13114 <<"("<<pulserBox<<":"<<led<<") High pin found ("
13115 <<", "<<this->GetElecString()
13116 <<", plex gain="<<pinGain
13117 <<", mean="<<mean<<", rms="<<rms
13118 <<", num="<<numEntries<<", cHit="<<correlatedHit<<endl;
13119 }
13120 }
13121 else if (chip==0){
13122
13123 if (mean>maxAdcLowPin[l][c]) {
13124 maxAdcLowPin[l][c]=mean;
13125 MSG("LIAnalysis",Msg::kInfo)
13126 <<"("<<pulserBox<<":"<<led<<") Low pin found ("
13127 <<", "<<this->GetElecString()
13128 <<", plex gain="<<pinGain
13129 <<", mean="<<mean<<", rms="<<rms
13130 <<", num="<<numEntries<<", cHit="<<correlatedHit<<endl;
13131 }
13132 }
13133 }
13134 else if (run==1){
13135 if (chip==1){
13136
13137 if (mean>maxAdcHighPin2[l][c]) {
13138 maxAdcHighPin2[l][c]=mean;
13139 MSG("LIAnalysis",Msg::kInfo)
13140 <<"("<<pulserBox<<":"<<led<<") High pin found ("
13141 <<", "<<this->GetElecString()
13142 <<", plex gain="<<pinGain
13143 <<", mean="<<mean<<", rms="<<rms
13144 <<", num="<<numEntries<<", cHit="<<correlatedHit<<endl;
13145 }
13146 }
13147 else if (chip==0){
13148
13149 if (mean>maxAdcLowPin2[l][c]) {
13150 maxAdcLowPin2[l][c]=mean;
13151 MSG("LIAnalysis",Msg::kInfo)
13152 <<"("<<pulserBox<<":"<<led<<") Low pin found ("
13153 <<", "<<this->GetElecString()
13154 <<", plex gain="<<pinGain
13155 <<", mean="<<mean<<", rms="<<rms
13156 <<", num="<<numEntries<<", cHit="<<correlatedHit<<endl;
13157 }
13158 }
13159 }
13160 else {
13161 MSG("LIAnalysis",Msg::kWarning)
13162 <<"Code only written for 2 different runs"<<endl;
13163 }
13164 }
13165 }
13166 }
13167
13171
13172 MSG("LIAnalysis",Msg::kInfo)
13173 <<"Finished loop to find pins"<<endl;
13174
13175 MSG("LIAnalysis",Msg::kInfo)
13176 <<endl<<"Starting main loop"<<endl;
13177
13181
13182 this->InitialiseLoopVariables();
13183
13184 for(Int_t entry=0;entry<numEvents;entry++){
13185
13186 this->SetLoopVariables(entry,1);
13187
13191 if (crate==1) continue;
13192
13193
13194 if (mean==0 || rms==0 || numEntries==0) continue;
13195
13196
13197 if (readoutType!=ReadoutType::kScintStrip) continue;
13198
13199 Int_t side=crate%2;
13200
13201
13202
13203
13204
13205
13206
13207
13208 Int_t c=calibPoint-1;
13209 Int_t l=pulserBox*NUMLEDS+led-1;
13210 Int_t se=side*NUMSTRIPS*NUMPLANES+plane*NUMSTRIPS+strip;
13211
13212
13213 if (runNumber==61753 && calibPoint!=17) continue;
13214 else c=0;
13215 if (runNumber==61626 && calibPoint!=17) continue;
13216 else c=0;
13217 if (runNumber==62078 && calibPoint!=17) continue;
13218 else c=0;
13219 if (runNumber==highRunNumber) run=1;
13220 else run=0;
13221
13222 if (runNumber==61626 || runNumber==62078){
13223 if (plane==20) continue;
13224 if (plane==36) continue;
13225 if (plane==44) continue;
13226 if (plane==55) continue;
13227 if (plane==56) continue;
13228 if (plane==58) continue;
13229 }
13230
13231
13232 if (correlatedHit==1){
13233 if (detectorType==Detector::kCalDet){
13234
13235 MSG("LIAnalysis",Msg::kVerbose)
13236 <<"("<<pulserBox<<":"<<led
13237 <<") caldet se="<<se<<endl;
13238
13239 if (pulserBox>=FIRSTPULSERBOX && pulserBox<=LASTPULSERBOX &&
13240 crate>=FIRSTCRATE && crate<=LASTCRATE &&
13241 led>=FIRSTLED && led<=LASTLED &&
13242 calibPoint>=1 && calibPoint<=const_numCalibPoints &&
13243 strip>=FIRSTSTRIP && strip<=LASTSTRIP &&
13244 plane>=FIRSTPLANE && plane<=LASTPLANE){
13245
13246
13247
13248
13249 if (lookup.NearOrFar(crate,pulserBox,nearPulserBox,
13250 farPulserBox,led,detectorType,
13251 plane,runNumber)==nearOrFarSide){
13252
13253
13254 if (run==0){
13255 liData[se].SetLIInfo(pulserBox,led,LIRun::kDriftPoint);
13256 liData[se].AddPoint(pulseHeight,mean,
13257 maxAdcHighPin[l][c],
13258 maxAdcLowPin[l][c],
13259 rms);
13260 }
13261 else if (run==1){
13262 liData2[se].SetLIInfo(pulserBox,led,LIRun::kDriftPoint);
13263 liData2[se].AddPoint(pulseHeight,mean,
13264 maxAdcHighPin2[l][c],
13265 maxAdcLowPin2[l][c],
13266 rms);
13267 }
13268 else {
13269 MSG("LIAnalysis",Msg::kWarning)
13270 <<"Code only written for 2 different runs"<<endl;
13271 }
13272 }
13273 }
13274 }
13275 }
13276 }
13277
13281
13282 MSG("LIAnalysis",Msg::kInfo)
13283 <<"Finished main loop"<<endl;
13284
13285
13286 gStyle->SetOptStat(1111111);
13287
13288 string sRunNumber=Form("%d",runNumber);
13289 string sLowRunNumber=Form("%d",lowRunNumber);
13290 string sHighRunNumber=Form("%d",highRunNumber);
13291 string sFirstRunNumber=Form("%d",firstRunNumber);
13292 string sLastRunNumber=Form("%d",lastRunNumber);
13293 s="";
13294
13295 string sPulseWidth=Form("%d",pulseWidth);
13296 string sPulseFreq=Form("%d",static_cast<Int_t>
13297 (ceil(1.0/(period*1.0e-5))));
13298
13299 if (MsgService::Instance()->IsActive("LIAnalysis",Msg::kDebug)){
13300 for (Int_t k=0;k<NUMSIDES;k++){
13301 MSG("LIAnalysis",Msg::kDebug)<<"Side="<<k<<endl;
13302 for (Int_t i=0;i<NUMPLANES;i++){
13303 MSG("LIAnalysis",Msg::kDebug)<<"Plane="<<i<<endl;
13304 for (Int_t j=0;j<NUMSTRIPS;j++){
13305 Int_t se=k*NUMPLANES*NUMSTRIPS+i*NUMSTRIPS+j;
13306 MSG("LIAnalysis",Msg::kVerbose)<<"se="<<se<<endl;
13307 liData[se].PrintAll();
13308 liData2[se].PrintAll();
13309 }
13310 }
13311 }
13312 }
13313
13314 vector<Double_t> vAdc;
13315 vector<Double_t> vRatio;
13316 vector<Double_t> vNormRatio;
13317 vector<Double_t> vAdc2;
13318 vector<Double_t> vRatio2;
13319 vector<Double_t> vNormRatio2;
13320 vector<Double_t> vNum;
13321
13322 Int_t numGoodStrips=0;
13323 Double_t maxAdc=0;
13324 Double_t maxRatio=0;
13325 Double_t maxNormRatio=0;
13326
13327
13328 for (Int_t k=0;k<NUMSIDES;k++){
13329 MSG("LIAnalysis",Msg::kInfo)<<"Side="<<k<<endl;
13330 for (Int_t i=0;i<NUMPLANES;i++){
13331 MSG("LIAnalysis",Msg::kInfo)<<"Plane="<<i<<endl;
13332
13333 vAdc.push_back(0);
13334 vRatio.push_back(0);
13335 vNormRatio.push_back(0);
13336 vAdc2.push_back(0);
13337 vRatio2.push_back(0);
13338 vNormRatio2.push_back(0);
13339 vNum.push_back(0.0000000001);
13340
13341 for (Int_t j=0;j<NUMSTRIPS;j++){
13342 Int_t se=k*NUMPLANES*NUMSTRIPS+i*NUMSTRIPS+j;
13343 MSG("LIAnalysis",Msg::kVerbose)<<"se="<<se<<endl;
13344 vector<Double_t> adcVector=liData[se].GetAdc();
13345 vector<Double_t> adcVector2=liData2[se].GetAdc();
13346 vector<Double_t> pinVector=liData[se].GetPin(2);
13347 vector<Double_t> pinVector2=liData2[se].GetPin(2);
13348 if (adcVector.size()>0 && adcVector2.size()>0){
13349 Double_t adc=liData[se].GetVectorPoint(adcVector,0);
13350 Double_t adc2=liData2[se].GetVectorPoint(adcVector2,0);
13351 Double_t pin=liData[se].GetVectorPoint(pinVector,0);
13352 Double_t pin2=liData2[se].GetVectorPoint(pinVector2,0);
13353
13354 Double_t ratio=adc/pin;
13355 Double_t ratio2=adc2/pin2;
13356
13357 MSG("LIAnalysis",Msg::kInfo)
13358 <<"se="<<se<<", adc="<<adc<<", adc2="<<adc2
13359 <<", ratio="<<ratio<<", ratio2="<<ratio2<<endl;
13360
13361 if (adc>maxAdc) maxAdc=adc;
13362 if (adc2>maxAdc) maxAdc=adc2;
13363
13364 if (ratio>maxRatio) maxRatio=ratio;
13365 if (ratio2>maxRatio) maxRatio=ratio2;
13366
13367
13368 numGoodStrips++;
13369
13371
13373 Int_t size=vAdc.size();
13374 vAdc[size-1]+=adc;
13375 vRatio[size-1]+=ratio;
13376 vAdc2[size-1]+=adc2;
13377 vRatio2[size-1]+=ratio2;
13378 vNum[size-1]++;
13379
13380
13381 ratio2/=ratio;
13382 ratio/=ratio;
13383
13384
13385 vNormRatio[size-1]+=ratio;
13386 vNormRatio2[size-1]+=ratio2;
13387 }
13388 }
13389 }
13390 }
13391
13392 MSG("LIAnalysis",Msg::kInfo)
13393 <<"numGoodStrips="<<numGoodStrips<<", maxAdc="<<maxAdc<<endl;
13394
13395
13396 TGraph *gAdcVsSe=new TGraph(numGoodStrips);
13397 TGraph *gAdcVsSe2=new TGraph(numGoodStrips);
13398 gAdcVsSe->SetMinimum(0);
13399 gAdcVsSe->SetMaximum(maxAdc+0.1*maxAdc);
13400
13401 TGraph *gRatioVsSe=new TGraph(numGoodStrips);
13402 TGraph *gRatioVsSe2=new TGraph(numGoodStrips);
13403 gRatioVsSe->SetMinimum(0);
13404 gRatioVsSe2->SetMinimum(0);
13405 gRatioVsSe->SetMaximum(maxRatio+0.1*maxRatio);
13406
13407 TGraph *gNormRatioVsSe=new TGraph(numGoodStrips);
13408 TGraph *gNormRatioVsSe2=new TGraph(numGoodStrips);
13409 gNormRatioVsSe->SetMinimum(0);
13410 gNormRatioVsSe2->SetMinimum(0);
13411
13412
13413 TGraph *gAdcVsPl=new TGraph(numGoodStrips);
13414 TGraph *gAdcVsPl2=new TGraph(numGoodStrips);
13415 gAdcVsPl->SetMinimum(0);
13416 gAdcVsPl->SetMaximum(maxAdc+0.1*maxAdc);
13417
13418 TGraph *gRatioVsPl=new TGraph(numGoodStrips);
13419 TGraph *gRatioVsPl2=new TGraph(numGoodStrips);
13420 gRatioVsPl->SetMinimum(0);
13421 gRatioVsPl2->SetMinimum(0);
13422 gRatioVsPl->SetMaximum(maxRatio+0.1*maxRatio);
13423
13424 TGraph *gNormRatioVsPl=new TGraph(numGoodStrips);
13425 TGraph *gNormRatioVsPl2=new TGraph(numGoodStrips);
13426 gNormRatioVsPl->SetMinimum(0);
13427 gNormRatioVsPl2->SetMinimum(0);
13428
13429 TGraph *gNumVsPl=new TGraph(numGoodStrips);
13430
13431
13432 TH1F* hRatioEven=new TH1F("Normalised Ratio PMT/PIN",
13433 "Normalised Ratio PMT/PIN",100,0.5,1.8);
13434 hRatioEven->GetXaxis()->SetTitle("Normalised Ratio PMT/PIN");
13435 hRatioEven->GetXaxis()->CenterTitle();
13436 hRatioEven->GetYaxis()->SetTitle("Number of Entries");
13437 hRatioEven->GetYaxis()->CenterTitle();
13438 hRatioEven->SetFillColor(0);
13439 hRatioEven->SetLineColor(1);
13440
13441
13442 TH1F* hRatioOdd=new TH1F("Normalised Ratio PMT/PIN",
13443 "Normalised Ratio PMT/PIN",100,0.5,1.8);
13444 hRatioOdd->GetXaxis()->SetTitle("Normalised Ratio PMT/PIN");
13445 hRatioOdd->GetXaxis()->CenterTitle();
13446 hRatioOdd->GetYaxis()->SetTitle("Number of Entries");
13447 hRatioOdd->GetYaxis()->CenterTitle();
13448 hRatioOdd->SetFillColor(0);
13449 hRatioOdd->SetLineColor(3);
13450
13451
13452 Int_t point=0;
13453
13454
13455 for (Int_t k=0;k<NUMSIDES;k++){
13456 MSG("LIAnalysis",Msg::kInfo)<<"Side="<<k<<endl;
13457 for (Int_t i=0;i<NUMPLANES;i++){
13458 MSG("LIAnalysis",Msg::kInfo)<<"Plane="<<i<<endl;
13459
13460 for (Int_t j=0;j<NUMSTRIPS;j++){
13461 Int_t se=k*NUMPLANES*NUMSTRIPS+i*NUMSTRIPS+j;
13462 MSG("LIAnalysis",Msg::kVerbose)<<"se="<<se<<endl;
13463
13464
13465 vector<Double_t> adcVector=liData[se].GetAdc();
13466 vector<Double_t> adcVector2=liData2[se].GetAdc();
13467 vector<Double_t> pinVector=liData[se].GetPin(2);
13468 vector<Double_t> pinVector2=liData2[se].GetPin(2);
13469
13470 if (adcVector.size()>0 && adcVector.size()>0){
13471 Double_t adc=liData[se].GetVectorPoint(adcVector,0);
13472 Double_t adc2=liData2[se].GetVectorPoint(adcVector2,0);
13473
13474 Double_t pin=liData[se].GetVectorPoint(pinVector,0);
13475 Double_t pin2=liData2[se].GetVectorPoint(pinVector2,0);
13476
13477 Double_t ratio=adc/pin;
13478 Double_t ratio2=adc2/pin2;
13479
13480 MSG("LIAnalysis",Msg::kVerbose)
13481 <<"Filling graph se="<<se
13482 <<", adc="<<adc<<"->"<<adc2
13483 <<", pin="<<pin<<"->"<<pin2
13484 <<", ratio="<<ratio<<"->"<<ratio2<<endl;
13485
13486 gAdcVsSe->SetPoint(point,static_cast<Double_t>(se),adc);
13487 gAdcVsSe2->SetPoint(point,static_cast<Double_t>(se),adc2);
13488 gRatioVsSe->SetPoint(point,static_cast<Double_t>(se),ratio);
13489 gRatioVsSe2->SetPoint(point,static_cast<Double_t>(se),ratio2);
13490
13491
13492 ratio2/=ratio;
13493 ratio/=ratio;
13494 if (ratio>maxNormRatio) maxNormRatio=ratio;
13495 if (ratio2>maxNormRatio) maxNormRatio=ratio2;
13496
13497 gNormRatioVsSe->SetPoint(point,
13498 static_cast<Double_t>(se),ratio);
13499 gNormRatioVsSe2->SetPoint(point,
13500 static_cast<Double_t>(se),ratio2);
13501
13502 MSG("LIAnalysis",Msg::kInfo)
13503 <<"Filling normalised graph se="<<se
13504 <<", adc="<<adc<<"->"<<adc2
13505 <<", pin="<<pin<<"->"<<pin2
13506 <<", ratio="<<ratio<<"->"<<ratio2<<endl;
13507
13508 if (i%2==0) hRatioEven->Fill(ratio2);
13509 else hRatioOdd->Fill(ratio2);
13510
13511
13512
13513 gAdcVsPl->SetPoint(i,static_cast<Double_t>(i),
13514 vAdc[i]/vNum[i]);
13515 gAdcVsPl2->SetPoint(i,static_cast<Double_t>(i),
13516 vAdc2[i]/vNum[i]);
13517 gRatioVsPl->SetPoint(i,static_cast<Double_t>(i),
13518 vRatio[i]/vNum[i]);
13519 gRatioVsPl2->SetPoint(i,static_cast<Double_t>(i),
13520 vRatio2[i]/vNum[i]);
13521 gNormRatioVsPl->SetPoint(i,static_cast<Double_t>(i),
13522 vNormRatio[i]/vNum[i]);
13523 gNormRatioVsPl2->SetPoint(i,static_cast<Double_t>(i),
13524 vNormRatio2[i]/vNum[i]);
13525 gNumVsPl->SetPoint(i,static_cast<Double_t>(i),vNum[i]);
13526
13527 point++;
13528 }
13529 }
13530 }
13531 }
13532
13533 MSG("LIAnalysis",Msg::kInfo)
13534 <<"MaxRatio="<<maxRatio<<", MaxNormRatio="<<maxNormRatio<<endl;
13535
13536
13537 string sName="";
13538 if (nearOrFarSide==LILookup::kFarSide){
13539 sName="ReflectorsF.ps";
13540 }
13541 else if (nearOrFarSide==LILookup::kNearSide){
13542 sName="ReflectorsN.ps";
13543 }
13544
13546
13548
13550 TCanvas *cHisto=new TCanvas("cHisto","cHisto",0,0,1200,600);
13551 cHisto->SetFillColor(0);
13552
13553
13554 cHisto->cd();
13555 cHisto->Clear();
13556 s="Normalised Ratio PMT/PIN (Green and Clear Cables)";
13557 hRatioOdd->Draw();
13558 hRatioOdd->SetTitle(s.c_str());
13559 hRatioEven->Draw("same");
13560 hRatioEven->SetTitle(s.c_str());
13561
13562
13563 TLegend *lNormRatioHisto = new TLegend(0.15, 0.7, 0.3, 0.8);
13564 lNormRatioHisto->SetBorderSize(0);
13565 lNormRatioHisto->SetFillColor(0);
13566 lNormRatioHisto->SetTextSize(0.035);
13567
13568
13569 s="Clear cables (even planes)";
13570 lNormRatioHisto->AddEntry(hRatioEven,s.c_str(),"l");
13571 s="Green cables (odd planes)";
13572 lNormRatioHisto->AddEntry(hRatioOdd,s.c_str(),"l");
13573 lNormRatioHisto->Draw();
13574
13575
13576 if (sLowRunNumber==sHighRunNumber) s=sRunNumber+sName;
13577 else s=sLowRunNumber+"-"+sHighRunNumber+sName+"(";
13578 cHisto->Print(s.c_str());
13579
13581
13583 TCanvas *cNormRatioPl=new TCanvas("cNormRatioPl","cNormRatioPl",
13584 0,0,1200,600);
13585 cNormRatioPl->SetFillColor(0);
13586
13587
13588 cNormRatioPl->cd();
13589 cNormRatioPl->Clear();
13590 s="Normalised Ratio PMT/PIN vs Plane";
13591 s+=" (Before and After Reflector Connectors)";
13592 gNormRatioVsPl->Draw("AP");
13593 gNormRatioVsPl->SetTitle(s.c_str());
13594 gNormRatioVsPl->GetXaxis()->SetTitle("Plane");
13595 gNormRatioVsPl->GetYaxis()->SetTitle("Normalised Ratio PMT/PIN");
13596 gNormRatioVsPl->GetXaxis()->CenterTitle();
13597 gNormRatioVsPl->GetYaxis()->CenterTitle();
13598 gNormRatioVsPl->SetMarkerStyle(3);
13599 gNormRatioVsPl->SetMarkerColor(2);
13600 gNormRatioVsPl->SetMarkerSize(0.55);
13601 gNormRatioVsPl->SetLineColor(46);
13602
13603 gNormRatioVsPl2->Draw("P");
13604 gNormRatioVsPl2->SetMarkerStyle(3);
13605 gNormRatioVsPl2->SetMarkerColor(3);
13606 gNormRatioVsPl2->SetMarkerSize(0.55);
13607 gNormRatioVsPl2->SetLineColor(30);
13608
13609 gNormRatioVsPl->SetMinimum(1-0.1*maxNormRatio);
13610 gNormRatioVsPl->SetMaximum(2);
13611 if (maxNormRatio<2) gNormRatioVsPl->
13612 SetMaximum(maxNormRatio+0.1*maxNormRatio);
13613
13614
13615 TLegend *lNormRatioPl = new TLegend(0.7, 0.7, 0.8, 0.8);
13616 lNormRatioPl->SetBorderSize(0);
13617 lNormRatioPl->SetFillColor(0);
13618 lNormRatioPl->SetTextSize(0.035);
13619
13620
13621 s="Run ";
13622 s+=sLowRunNumber;
13623 lNormRatioPl->AddEntry(gNormRatioVsPl,s.c_str(),"p");
13624 s="Run ";
13625 s+=sHighRunNumber;
13626 lNormRatioPl->AddEntry(gNormRatioVsPl2,s.c_str(),"p");
13627 lNormRatioPl->Draw();
13628
13629
13630 if (sLowRunNumber==sHighRunNumber) s=sRunNumber+sName;
13631 else s=sLowRunNumber+"-"+sHighRunNumber+sName;
13632 cNormRatioPl->Print(s.c_str());
13633
13635
13637 TCanvas *cRatioPl=new TCanvas("cRatioPl","cRatioPl",0,0,1200,600);
13638 cRatioPl->SetFillColor(0);
13639
13640
13641 cRatioPl->cd();
13642 cRatioPl->Clear();
13643 s="Ratio PMT/PIN vs Plane (Before and After Reflector Connectors)";
13644 gRatioVsPl->Draw("AP");
13645 gRatioVsPl->SetTitle(s.c_str());
13646 gRatioVsPl->GetXaxis()->SetTitle("Plane");
13647 gRatioVsPl->GetYaxis()->SetTitle("Ratio PMT/PIN");
13648 gRatioVsPl->GetXaxis()->CenterTitle();
13649 gRatioVsPl->GetYaxis()->CenterTitle();
13650 gRatioVsPl->SetMarkerStyle(3);
13651 gRatioVsPl->SetMarkerColor(2);
13652 gRatioVsPl->SetMarkerSize(0.55);
13653 gRatioVsPl->SetLineColor(46);
13654
13655 gRatioVsPl2->Draw("P");
13656 gRatioVsPl2->SetMarkerStyle(3);
13657 gRatioVsPl2->SetMarkerColor(3);
13658 gRatioVsPl2->SetMarkerSize(0.55);
13659 gRatioVsPl2->SetLineColor(30);
13660
13661 gRatioVsPl->SetMinimum(0);
13662 gRatioVsPl->SetMaximum(maxRatio+0.1*maxRatio);
13663
13664
13665 TLegend *lRatioPl = new TLegend(0.7,0.7,0.8,0.8);
13666 lRatioPl->SetBorderSize(0);
13667 lRatioPl->SetFillColor(0);
13668 lRatioPl->SetTextSize(0.035);
13669
13670
13671 s="Run ";
13672 s+=sLowRunNumber;
13673 lRatioPl->AddEntry(gRatioVsPl,s.c_str(),"p");
13674 s="Run ";
13675 s+=sHighRunNumber;
13676 lRatioPl->AddEntry(gRatioVsPl2,s.c_str(),"p");
13677 lRatioPl->Draw();
13678
13679
13680 if (sLowRunNumber==sHighRunNumber) s=sRunNumber+sName;
13681 else s=sLowRunNumber+"-"+sHighRunNumber+sName;
13682 cRatioPl->Print(s.c_str());
13683
13685
13687 TCanvas *cAdcPl=new TCanvas("cAdcPl","cAdcPl",0,0,1200,600);
13688 cAdcPl->SetFillColor(0);
13689
13690
13691 cAdcPl->cd();
13692 cAdcPl->Clear();
13693 s="Adc vs Plane (Before and After Reflector Connectors)";
13694 gAdcVsPl->Draw("AP");
13695 gAdcVsPl->SetTitle(s.c_str());
13696 gAdcVsPl->GetXaxis()->SetTitle("Plane");
13697 gAdcVsPl->GetYaxis()->SetTitle("Pmt Adc");
13698 gAdcVsPl->GetXaxis()->CenterTitle();
13699 gAdcVsPl->GetYaxis()->CenterTitle();
13700 gAdcVsPl->SetMarkerStyle(3);
13701 gAdcVsPl->SetMarkerColor(2);
13702 gAdcVsPl->SetMarkerSize(0.55);
13703 gAdcVsPl->SetLineColor(46);
13704
13705 gAdcVsPl2->Draw("P");
13706 gAdcVsPl2->SetMarkerStyle(3);
13707 gAdcVsPl2->SetMarkerColor(3);
13708 gAdcVsPl2->SetMarkerSize(0.55);
13709 gAdcVsPl2->SetLineColor(30);
13710
13711 gAdcVsPl->SetMinimum(0);
13712 gAdcVsPl->SetMaximum(maxAdc+0.1*maxAdc);
13713
13714
13715 TLegend *lAdcPl = new TLegend(0.7,0.7,0.8,0.8);
13716 lAdcPl->SetBorderSize(0);
13717 lAdcPl->SetFillColor(0);
13718 lAdcPl->SetTextSize(0.035);
13719
13720
13721 s="Run ";
13722 s+=sLowRunNumber;
13723 lAdcPl->AddEntry(gAdcVsPl,s.c_str(),"p");
13724 s="Run ";
13725 s+=sHighRunNumber;
13726 lAdcPl->AddEntry(gAdcVsPl2,s.c_str(),"p");
13727 lAdcPl->Draw();
13728
13729
13730 if (sLowRunNumber==sHighRunNumber) s=sRunNumber+sName;
13731 else s=sLowRunNumber+"-"+sHighRunNumber+sName;
13732 cAdcPl->Print(s.c_str());
13733
13735
13737 TCanvas *cNum=new TCanvas("cNum","cNum",0,0,1200,600);
13738 cNum->SetFillColor(0);
13739
13740
13741 cNum->cd();
13742 cNum->Clear();
13743 s="Number strips hit vs Plane";
13744 gNumVsPl->Draw("AP");
13745 gNumVsPl->SetTitle(s.c_str());
13746 gNumVsPl->GetXaxis()->SetTitle("Plane");
13747 gNumVsPl->GetYaxis()->SetTitle("Number strips hit");
13748 gNumVsPl->GetXaxis()->CenterTitle();
13749 gNumVsPl->GetYaxis()->CenterTitle();
13750 gNumVsPl->SetMarkerStyle(3);
13751 gNumVsPl->SetMarkerColor(2);
13752 gNumVsPl->SetMarkerSize(0.55);
13753 gNumVsPl->SetLineColor(46);
13754
13755
13756 if (sLowRunNumber==sHighRunNumber) s=sRunNumber+sName;
13757 else s=sLowRunNumber+"-"+sHighRunNumber+sName;
13758 cNum->Print(s.c_str());
13759
13761
13763
13765 TCanvas *cNormRatio=new TCanvas("cNormRatio","cNormRatio",
13766 0,0,1200,600);
13767 cNormRatio->SetFillColor(0);
13768
13769
13770 cNormRatio->cd();
13771 cNormRatio->Clear();
13772 s="Normalised Ratio PMT/PIN vs Stripend";
13773 s+=" (Before and After Reflector Connectors)";
13774 gNormRatioVsSe->Draw("AP");
13775 gNormRatioVsSe->SetTitle(s.c_str());
13776 gNormRatioVsSe->GetXaxis()->SetTitle
13777 ("Stripend index (Plane*StripsPerPlane+strip)");
13778 gNormRatioVsSe->GetYaxis()->SetTitle("Normalised Ratio PMT/PIN");
13779 gNormRatioVsSe->GetXaxis()->CenterTitle();
13780 gNormRatioVsSe->GetYaxis()->CenterTitle();
13781 gNormRatioVsSe->SetMarkerStyle(3);
13782 gNormRatioVsSe->SetMarkerColor(2);
13783 gNormRatioVsSe->SetMarkerSize(0.55);
13784 gNormRatioVsSe->SetLineColor(46);
13785
13786 gNormRatioVsSe2->Draw("P");
13787 gNormRatioVsSe2->SetMarkerStyle(3);
13788 gNormRatioVsSe2->SetMarkerColor(3);
13789 gNormRatioVsSe2->SetMarkerSize(0.55);
13790 gNormRatioVsSe2->SetLineColor(30);
13791
13792 gNormRatioVsSe->SetMinimum(1-0.1*maxNormRatio);
13793 gNormRatioVsSe->SetMaximum(maxNormRatio+0.1*maxNormRatio);
13794
13795
13796 TLegend *lNormRatio = new TLegend(0.7, 0.7, 0.8, 0.8);
13797 lNormRatio->SetBorderSize(0);
13798 lNormRatio->SetFillColor(0);
13799 lNormRatio->SetTextSize(0.035);
13800
13801
13802 s="Run ";
13803 s+=sLowRunNumber;
13804 lNormRatio->AddEntry(gNormRatioVsSe,s.c_str(),"p");
13805 s="Run ";
13806 s+=sHighRunNumber;
13807 lNormRatio->AddEntry(gNormRatioVsSe2,s.c_str(),"p");
13808 lNormRatio->Draw();
13809
13810
13811 if (sLowRunNumber==sHighRunNumber) s=sRunNumber+sName;
13812 else s=sLowRunNumber+"-"+sHighRunNumber+sName;
13813 cNormRatio->Print(s.c_str());
13814
13816
13818 TCanvas *cRatio=new TCanvas("cRatio","cRatio",0,0,1200,600);
13819 cRatio->SetFillColor(0);
13820
13821
13822 cRatio->cd();
13823 cRatio->Clear();
13824 s="Ratio PMT/PIN vs Stripend (Before and After Reflector Connectors)";
13825 gRatioVsSe->Draw("AP");
13826 gRatioVsSe->SetTitle(s.c_str());
13827 gRatioVsSe->GetXaxis()->SetTitle
13828 ("Stripend index (Plane*StripsPerPlane+strip)");
13829 gRatioVsSe->GetYaxis()->SetTitle("Ratio PMT/PIN");
13830 gRatioVsSe->GetXaxis()->CenterTitle();
13831 gRatioVsSe->GetYaxis()->CenterTitle();
13832 gRatioVsSe->SetMarkerStyle(3);
13833 gRatioVsSe->SetMarkerColor(2);
13834 gRatioVsSe->SetMarkerSize(0.55);
13835 gRatioVsSe->SetLineColor(46);
13836
13837 gRatioVsSe2->Draw("P");
13838 gRatioVsSe2->SetMarkerStyle(3);
13839 gRatioVsSe2->SetMarkerColor(3);
13840 gRatioVsSe2->SetMarkerSize(0.55);
13841 gRatioVsSe2->SetLineColor(30);
13842
13843 gRatioVsSe->SetMinimum(0);
13844 gRatioVsSe->SetMaximum(maxRatio+0.1*maxRatio);
13845
13846
13847 TLegend *lRatio = new TLegend(0.7,0.7,0.8,0.8);
13848 lRatio->SetBorderSize(0);
13849 lRatio->SetFillColor(0);
13850 lRatio->SetTextSize(0.035);
13851
13852
13853 s="Run ";
13854 s+=sLowRunNumber;
13855 lRatio->AddEntry(gRatioVsSe,s.c_str(),"p");
13856 s="Run ";
13857 s+=sHighRunNumber;
13858 lRatio->AddEntry(gRatioVsSe2,s.c_str(),"p");
13859 lRatio->Draw();
13860
13861
13862 if (sLowRunNumber==sHighRunNumber) s=sRunNumber+sName;
13863 else s=sLowRunNumber+"-"+sHighRunNumber+sName;
13864 cRatio->Print(s.c_str());
13865
13867
13869 TCanvas *cAdc=new TCanvas("cAdc","cAdc",0,0,1200,600);
13870 cAdc->SetFillColor(0);
13871
13872
13873 cAdc->cd();
13874 cAdc->Clear();
13875 s="Adc vs Stripend (Before and After Reflector Connectors)";
13876 gAdcVsSe->Draw("AP");
13877 gAdcVsSe->SetTitle(s.c_str());
13878 gAdcVsSe->GetXaxis()->SetTitle
13879 ("Stripend index (Plane*StripsPerPlane+strip)");
13880 gAdcVsSe->GetYaxis()->SetTitle("Pmt Adc");
13881 gAdcVsSe->GetXaxis()->CenterTitle();
13882 gAdcVsSe->GetYaxis()->CenterTitle();
13883 gAdcVsSe->SetMarkerStyle(3);
13884 gAdcVsSe->SetMarkerColor(2);
13885 gAdcVsSe->SetMarkerSize(0.55);
13886 gAdcVsSe->SetLineColor(46);
13887
13888 gAdcVsSe2->Draw("P");
13889 gAdcVsSe2->SetMarkerStyle(3);
13890 gAdcVsSe2->SetMarkerColor(3);
13891 gAdcVsSe2->SetMarkerSize(0.55);
13892 gAdcVsSe2->SetLineColor(30);
13893
13894 gAdcVsSe->SetMinimum(0);
13895 gAdcVsSe->SetMaximum(maxAdc+0.1*maxAdc);
13896
13897
13898 TLegend *lAdc = new TLegend(0.7,0.7,0.8,0.8);
13899 lAdc->SetBorderSize(0);
13900 lAdc->SetFillColor(0);
13901 lAdc->SetTextSize(0.035);
13902
13903
13904 s="Run ";
13905 s+=sLowRunNumber;
13906 lAdc->AddEntry(gAdcVsSe,s.c_str(),"p");
13907 s="Run ";
13908 s+=sHighRunNumber;
13909 lAdc->AddEntry(gAdcVsSe2,s.c_str(),"p");
13910 lAdc->Draw();
13911
13912
13913 if (sLowRunNumber==sHighRunNumber) s=sRunNumber+sName;
13914 else s=sLowRunNumber+"-"+sHighRunNumber+sName+")";
13915 cAdc->Print(s.c_str());
13916
13917 MSG("LIAnalysis",Msg::kInfo)
13918 <<endl<<" ** Finished the Reflectors method ** "<<endl;
13919 }
13920
13921
13922
13923 void LIAnalysis::ReflectorsGc(LILookup::ELINearOrFarSide nearOrFarSide)
13924 {
13925 MSG("LIAnalysis",Msg::kInfo)
13926 <<endl<<" ** Running the ReflectorsGc method... ** "<<endl;
13927
13928 chain->GetEvent(0);
13929 const Int_t const_numCalibPoints=calibType;
13930
13931 MSG("LIAnalysis",Msg::kInfo)
13932 <<"Using "<<const_numCalibPoints<<" calibPoints"<<endl;
13933 MSG("LIAnalysis",Msg::kInfo)
13934 <<"Number of pulser boxes = "<<NUMPULSERBOXES
13935 <<", leds = "<<NUMLEDS
13936 <<endl<<endl;
13937
13938 MSG("LIAnalysis",Msg::kInfo)
13939 <<"Creating LIRun objects"<<endl;
13940 vector<LIRun> liData(NUMSIDES*NUMPLANES*NUMSTRIPS);
13941 vector<LIRun> liData2(NUMSIDES*NUMPLANES*NUMSTRIPS);
13942
13943 Float_t **maxAdcHighPin=0;
13944 maxAdcHighPin=new Float_t*[NUMLEDS*NUMPULSERBOXES];
13945 Float_t **maxAdcLowPin=0;
13946 maxAdcLowPin=new Float_t*[NUMLEDS*NUMPULSERBOXES];
13947 Float_t **maxAdcHighPin2=0;
13948 maxAdcHighPin2=new Float_t*[NUMLEDS*NUMPULSERBOXES];
13949 Float_t **maxAdcLowPin2=0;
13950 maxAdcLowPin2=new Float_t*[NUMLEDS*NUMPULSERBOXES];
13951
13952
13953 for (Int_t i=0;i<NUMPULSERBOXES;i++){
13954 for (Int_t j=0;j<NUMLEDS;j++){
13955 Int_t l=i*NUMLEDS+j;
13956
13957 maxAdcHighPin[l]=new Float_t[const_numCalibPoints];
13958 maxAdcLowPin[l]=new Float_t[const_numCalibPoints];
13959 maxAdcHighPin2[l]=new Float_t[const_numCalibPoints];
13960 maxAdcLowPin2[l]=new Float_t[const_numCalibPoints];
13961
13962 for (Int_t k=0;k<const_numCalibPoints;k++){
13963 maxAdcHighPin[l][k]=0;
13964 maxAdcLowPin[l][k]=0;
13965 maxAdcHighPin2[l][k]=0;
13966 maxAdcLowPin2[l][k]=0;
13967 }
13968 }
13969 }
13970
13971 MSG("LIAnalysis",Msg::kInfo)
13972 <<endl<<"Looping to find pins"<<endl;
13973
13977
13978 this->InitialiseLoopVariables();
13979
13980 for(Int_t entry=0;entry<numEvents;entry++){
13981
13982 this->SetLoopVariables(entry,1);
13983
13984
13985 if (mean==0 || rms==0 || numEntries==0) continue;
13986
13987
13988 if (numEntries<0.5*pulses) continue;
13989
13990 Int_t c=calibPoint-1;
13991
13992
13993 if (runNumber==highRunNumber) run=1;
13994 else run=0;
13995
13996
13997 if (readoutType==ReadoutType::kPinDiode){
13998
13999 if (pulserBox>=FIRSTPULSERBOX && pulserBox<=LASTPULSERBOX &&
14000 led>=FIRSTLED && led<=LASTLED &&
14001 c<const_numCalibPoints){
14002
14003 Int_t l=pulserBox*NUMLEDS+led-1;
14004
14005
14006 if (run==0){
14007 if (chip==1){
14008
14009 if (mean>maxAdcHighPin[l][c]) {
14010 maxAdcHighPin[l][c]=mean;
14011 MSG("LIAnalysis",Msg::kInfo)
14012 <<"("<<pulserBox<<":"<<led<<") High pin found ("
14013 <<", "<<this->GetElecString()
14014 <<", plex gain="<<pinGain
14015 <<", mean="<<mean<<", rms="<<rms
14016 <<", num="<<numEntries<<", cHit="<<correlatedHit<<endl;
14017 }
14018 }
14019 else if (chip==0){
14020
14021 if (mean>maxAdcLowPin[l][c]) {
14022 maxAdcLowPin[l][c]=mean;
14023 MSG("LIAnalysis",Msg::kInfo)
14024 <<"("<<pulserBox<<":"<<led<<") Low pin found ("
14025 <<", "<<this->GetElecString()
14026 <<", plex gain="<<pinGain
14027 <<", mean="<<mean<<", rms="<<rms
14028 <<", num="<<numEntries<<", cHit="<<correlatedHit<<endl;
14029 }
14030 }
14031 }
14032 else if (run==1){
14033 if (chip==1){
14034
14035 if (mean>maxAdcHighPin2[l][c]) {
14036 maxAdcHighPin2[l][c]=mean;
14037 MSG("LIAnalysis",Msg::kInfo)
14038 <<"("<<pulserBox<<":"<<led<<") High pin found ("
14039 <<", "<<this->GetElecString()
14040 <<", plex gain="<<pinGain
14041 <<", mean="<<mean<<", rms="<<rms
14042 <<", num="<<numEntries<<", cHit="<<correlatedHit<<endl;
14043 }
14044 }
14045 else if (chip==0){
14046
14047 if (mean>maxAdcLowPin2[l][c]) {
14048 maxAdcLowPin2[l][c]=mean;
14049 MSG("LIAnalysis",Msg::kInfo)
14050 <<"("<<pulserBox<<":"<<led<<") Low pin found ("
14051 <<", "<<this->GetElecString()
14052 <<", plex gain="<<pinGain
14053 <<", mean="<<mean<<", rms="<<rms
14054 <<", num="<<numEntries<<", cHit="<<correlatedHit<<endl;
14055 }
14056 }
14057 }
14058 else {
14059 MSG("LIAnalysis",Msg::kWarning)
14060 <<"Code only written for 2 different runs"<<endl;
14061 }
14062 }
14063 }
14064 }
14065
14069
14070 MSG("LIAnalysis",Msg::kInfo)
14071 <<"Finished loop to find pins"<<endl;
14072
14073 MSG("LIAnalysis",Msg::kInfo)
14074 <<endl<<"Starting main loop"<<endl;
14075
14079
14080 this->InitialiseLoopVariables();
14081
14082 for(Int_t entry=0;entry<numEvents;entry++){
14083
14084 this->SetLoopVariables(entry,1);
14085
14086
14087 if (mean==0 || rms==0 || numEntries==0) continue;
14088
14089
14090 if (readoutType!=ReadoutType::kScintStrip) continue;
14091
14092 Int_t side=crate%2;
14093
14094
14095
14096 Int_t c=calibPoint-1;
14097 Int_t l=pulserBox*NUMLEDS+led-1;
14098 Int_t se=side*NUMSTRIPS*NUMPLANES+plane*NUMSTRIPS+strip;
14099
14100
14101 if (runNumber==highRunNumber) run=1;
14102 else run=0;
14103
14104
14105 if (correlatedHit==1){
14106 if (detectorType==Detector::kCalDet){
14107
14108 MSG("LIAnalysis",Msg::kVerbose)
14109 <<"("<<pulserBox<<":"<<led
14110 <<") caldet se="<<se<<endl;
14111
14112 if (pulserBox>=FIRSTPULSERBOX && pulserBox<=LASTPULSERBOX &&
14113 crate>=FIRSTCRATE && crate<=LASTCRATE &&
14114 led>=FIRSTLED && led<=LASTLED &&
14115 calibPoint>=1 && calibPoint<=const_numCalibPoints &&
14116 strip>=FIRSTSTRIP && strip<=LASTSTRIP &&
14117 plane>=FIRSTPLANE && plane<=LASTPLANE){
14118
14119
14120 if (lookup.NearOrFar(crate,pulserBox,nearPulserBox,
14121 farPulserBox,led,detectorType,
14122 plane,runNumber)==nearOrFarSide){
14123
14124
14125 if (run==0){
14126 liData[se].SetLIInfo(pulserBox,led,LIRun::kDriftPoint);
14127 liData[se].AddPoint(pulseHeight,mean,
14128 maxAdcHighPin[l][c],
14129 maxAdcLowPin[l][c],
14130 rms);
14131 }
14132 else if (run==1){
14133 liData2[se].SetLIInfo(pulserBox,led,LIRun::kDriftPoint);
14134 liData2[se].AddPoint(pulseHeight,mean,
14135 maxAdcHighPin2[l][c],
14136 maxAdcLowPin2[l][c],
14137 rms);
14138 }
14139 else {
14140 MSG("LIAnalysis",Msg::kWarning)
14141 <<"Code only written for 2 different runs"<<endl;
14142 }
14143 }
14144 }
14145 }
14146 }
14147 }
14148
14152
14153 MSG("LIAnalysis",Msg::kInfo)
14154 <<"Finished main loop"<<endl;
14155
14156
14157 gStyle->SetOptStat(1111111);
14158
14159 string sRunNumber=Form("%d",runNumber);
14160 string sLowRunNumber=Form("%d",lowRunNumber);
14161 string sHighRunNumber=Form("%d",highRunNumber);
14162 string sFirstRunNumber=Form("%d",firstRunNumber);
14163 string sLastRunNumber=Form("%d",lastRunNumber);
14164 s="";
14165
14166 string sPulseWidth=Form("%d",pulseWidth);
14167 string sPulseFreq=Form("%d",static_cast<Int_t>
14168 (ceil(1.0/(period*1.0e-5))));
14169
14170
14171 if (MsgService::Instance()->IsActive("LIAnalysis",Msg::kDebug)){
14172 for (Int_t k=0;k<NUMSIDES;k++){
14173 MSG("LIAnalysis",Msg::kDebug)<<"Side="<<k<<endl;
14174 for (Int_t i=0;i<NUMPLANES;i++){
14175 MSG("LIAnalysis",Msg::kDebug)<<"Plane="<<i<<endl;
14176 for (Int_t j=0;j<NUMSTRIPS;j++){
14177 Int_t se=k*NUMPLANES*NUMSTRIPS+i*NUMSTRIPS+j;
14178 MSG("LIAnalysis",Msg::kVerbose)<<"se="<<se<<endl;
14179 MSG("LIAnalysis",Msg::kInfo)<<"one=";
14180 liData[se].PrintAll();
14181 MSG("LIAnalysis",Msg::kInfo)<<"two=";
14182 liData2[se].PrintAll();
14183 }
14184 }
14185 }
14186 }
14187
14188 TCanvas *cNonLin=new TCanvas("cNonLin","cNonLin",0,0,1200,600);
14189 cNonLin->SetFillColor(0);
14190 TCanvas *cGain=new TCanvas("cGain","cGain",0,0,1200,600);
14191 cGain->SetFillColor(0);
14192
14193
14194 TGraph* gNonLin=new TGraph(const_numCalibPoints);
14195 TGraph* gNonLin2=new TGraph(const_numCalibPoints);
14196 TGraph* gGain=new TGraph(const_numCalibPoints);
14197 TGraph* gGain2=new TGraph(const_numCalibPoints);
14198
14199
14200 if (sLowRunNumber==sHighRunNumber) s=sRunNumber;
14201 else s=sLowRunNumber+"-"+sHighRunNumber;
14202
14203 string sNonLin="";
14204 string sGain="";
14205 if (nearOrFarSide==LILookup::kFarSide){
14206 sNonLin=s+"ReflectorsNonLinF.ps";
14207 sGain=s+"ReflectorsGainF.ps";
14208 }
14209 else if (nearOrFarSide==LILookup::kNearSide){
14210 sNonLin=s+"ReflectorsNonLinN.ps";
14211 sGain=s+"ReflectorsGainN.ps";
14212 }
14213
14214 Int_t fitPoint=-1;
14215 Int_t nonLinNormPoint=-1;
14216 Double_t maxRatio=-1;
14217 Double_t pinAdcCut=100;
14218 Int_t firstPlotDone=0;
14219
14220 for (Int_t k=0;k<NUMSIDES;k++){
14221 MSG("LIAnalysis",Msg::kInfo)<<"Side="<<k<<endl;
14222 for (Int_t i=0;i<NUMPLANES;i++){
14223 MSG("LIAnalysis",Msg::kDebug)<<"Plane="<<i<<endl;
14224 for (Int_t j=0;j<NUMSTRIPS;j++){
14225 Int_t se=k*NUMPLANES*NUMSTRIPS+i*NUMSTRIPS+j;
14226
14227 MSG("LIAnalysis",Msg::kVerbose)<<"se="<<se<<endl;
14228 vector<Double_t> pin;
14229 vector<Double_t> adc;
14230 vector<Double_t> rms;
14231 pin=liData[se].GetPin(2);
14232 adc=liData[se].GetAdc();
14233 rms=liData[se].GetAdcF();
14234
14235 vector<Double_t> pin2;
14236 vector<Double_t> adc2;
14237 vector<Double_t> rms2;
14238 pin2=liData2[se].GetPin(2);
14239 adc2=liData2[se].GetAdc();
14240 rms2=liData2[se].GetAdcF();
14241
14242 gNonLin->Clear();
14243 gNonLin2->Clear();
14244 cNonLin->Clear();
14245 gGain->Clear();
14246 gGain2->Clear();
14247 cGain->Clear();
14248
14249
14250 fitPoint=-1;
14251 nonLinNormPoint=-1;
14252 maxRatio=-1;
14253
14254 if (adc.size()>0 && adc2.size()>0){
14255 for (UInt_t p=0;p<adc.size();p++){
14256 Double_t ratio=-1;
14257 if (pin[p]!=0 && pin2[p]!=0) {
14258 ratio=adc[p]/pin[p];
14259 }
14260
14261
14262 if (ratio>maxRatio && pin[p]>pinAdcCut){
14263 maxRatio=ratio;
14264 nonLinNormPoint=p;
14265 MSG("LIAnalysis",Msg::kVerbose)
14266 <<"("<<i<<":"<<j+1<<") se="<<se
14267 <<", nonLinNormPoint="<<nonLinNormPoint
14268 <<", adc="<<adc[nonLinNormPoint]
14269 <<", pin="<<pin[nonLinNormPoint]<<endl;
14270 }
14271 }
14272
14273
14274 if (nonLinNormPoint==-1) nonLinNormPoint=0;
14275
14276
14277 for (UInt_t p=0;p<adc.size();p++){
14278
14279 if (pin[p]!=0 && pin2[p]!=0 &&
14280 pin[nonLinNormPoint]!=0 &&
14281 adc[nonLinNormPoint]!=0){
14282
14283 Double_t ratio=adc[p]/pin[p];
14284 Double_t ratio2=adc2[p]/pin2[p];
14285 Double_t normRatio=adc[nonLinNormPoint]/
14286 pin[nonLinNormPoint];
14287
14288 gNonLin->SetPoint(p,adc[p],ratio/normRatio);
14289 gNonLin2->SetPoint(p,adc2[p],ratio2/normRatio);
14290
14291
14292 if (detectorType==Detector::kNear) {
14293 gGain->SetPoint(p,adc[p],
14294 0.844*lookup.CalcGain(adc[p],rms[p],0));
14295 gGain2->SetPoint(p,adc2[p],
14296 0.844*lookup.CalcGain(adc2[p],rms2[p],0));
14297 } else {
14298 gGain->SetPoint(p,adc[p],
14299 0.8*lookup.CalcGain(adc[p],rms[p],0));
14300 gGain2->SetPoint(p,adc2[p],
14301 0.8*lookup.CalcGain(adc2[p],rms2[p],0));
14302 }
14303 }
14304 else{
14305 gNonLin->SetPoint(p,0,0);
14306 gNonLin2->SetPoint(p,0,0);
14307 gGain->SetPoint(p,0,0);
14308 gGain2->SetPoint(p,0,0);
14309 }
14310 }
14311
14312 string sPlane=Form("%d",i);
14313 string sStrip=Form("%d",j);
14314
14315 cNonLin->cd();
14316 s="Gain Curve Nonlinearity (Plane="+
14317 sPlane+", Strip="+sStrip+")";
14318 gNonLin->Draw("AP");
14319 gNonLin->SetTitle(s.c_str());
14320 gNonLin->GetXaxis()->SetTitle("Pmt Adc");
14321 gNonLin->GetYaxis()->SetTitle
14322 ("Fractional Nonlinearity (Norm. Pmt/Pin)");
14323 gNonLin->GetXaxis()->CenterTitle();
14324 gNonLin->GetYaxis()->CenterTitle();
14325 gNonLin->SetMarkerStyle(3);
14326 gNonLin->SetMarkerColor(2);
14327 gNonLin->SetMarkerSize(0.55);
14328 if (nearOrFarSide==LILookup::kFarSide){
14329 gNonLin->SetMaximum(1.4);
14330 }
14331 else if (nearOrFarSide==LILookup::kNearSide){
14332 gNonLin->SetMaximum(1.2);
14333 }
14334 gNonLin->SetMinimum(0);
14335
14336 gNonLin2->Draw("P");
14337 gNonLin2->SetTitle(s.c_str());
14338 gNonLin2->SetMarkerStyle(3);
14339 gNonLin2->SetMarkerColor(3);
14340 gNonLin2->SetMarkerSize(0.55);
14341
14342 cGain->cd();
14343 s="Gain (mean/npe) vs Pmt Adc (Plane="+
14344 sPlane+", Strip="+sStrip+")";
14345 gGain->Draw("AP");
14346 gGain->SetTitle(s.c_str());
14347 gGain->GetXaxis()->SetTitle("Pmt Adc");
14348 gGain->GetYaxis()->SetTitle("Gain (mean/npe)");
14349 gGain->GetXaxis()->CenterTitle();
14350 gGain->GetYaxis()->CenterTitle();
14351 gGain->SetMarkerStyle(3);
14352 gGain->SetMarkerColor(2);
14353 gGain->SetMarkerSize(0.55);
14354 gGain->SetMaximum(130);
14355 gGain->SetMinimum(0);
14356
14357 gGain2->Draw("P");
14358 gGain2->SetTitle(s.c_str());
14359 gGain2->SetMarkerStyle(3);
14360 gGain2->SetMarkerColor(3);
14361 gGain2->SetMarkerSize(0.55);
14362
14363 if (firstPlotDone==0){
14364
14365 cNonLin->Print((sNonLin+"(").c_str());
14366 cGain->Print((sGain+"(").c_str());
14367
14368
14369 gErrorIgnoreLevel=1;
14370 firstPlotDone=1;
14371 }
14372 else {
14373 cNonLin->Print(sNonLin.c_str());
14374 cGain->Print(sGain.c_str());
14375 }
14376 }
14377 else if ((adc.size()==0 && adc2.size()!=0) ||
14378 (adc.size()!=0 && adc2.size()==0)){
14379 MSG("LIAnalysis",Msg::kInfo)
14380 <<"Differences between runs, adc size="<<adc.size()
14381 <<", size2="<<adc2.size()<<endl;
14382 }
14383 }
14384 }
14385 }
14386
14387 gErrorIgnoreLevel=0;
14388 cNonLin->Print((sNonLin+")").c_str());
14389 cGain->Print((sGain+")").c_str());
14390
14391 MSG("LIAnalysis",Msg::kInfo)
14392 <<endl<<" ** Finished the ReflectorsGc method ** "<<endl;
14393 }
14394
14395
14396
14397 void LIAnalysis::WriteGainCurveTextFile()
14398 {
14399 MSG("LIAnalysis",Msg::kInfo)
14400 <<endl<<" ** Running the WriteGainCurveTextFile method... **"<<endl;
14401
14402
14403 string sRunNumber=Form("%d",runNumber);
14404 string fileName=sRunNumber+"GainCurve.dat";
14405
14406 ofstream TextFile(fileName.c_str());
14407
14408 if(!TextFile){
14409 MSG("LISummary",Msg::kError)
14410 << "Couldn't open file: "<<fileName<<endl
14411 <<"Will exit here..."<<endl;
14412 exit(0);
14413 }
14414
14415 chain->GetEvent(0);
14416 const Int_t const_numCalibPoints=calibType;
14417
14418 MSG("LIAnalysis",Msg::kInfo)
14419 <<"Using "<<const_numCalibPoints<<" calibPoints"<<endl;
14420 MSG("LIAnalysis",Msg::kInfo)
14421 <<"Number of pulser boxes = "<<NUMPULSERBOXES
14422 <<", leds = "<<NUMLEDS
14423 <<endl<<endl;
14424
14425 MSG("LIAnalysis",Msg::kInfo)
14426 <<"Creating LIRun objects"<<endl;
14427 vector<LIRun> gCurveData(NUMSIDES*NUMPLANES*NUMSTRIPS);
14428
14429 Float_t **maxAdcHighPin=0;
14430 maxAdcHighPin=new Float_t*[NUMLEDS*NUMPULSERBOXES];
14431 Float_t **maxAdcLowPin=0;
14432 maxAdcLowPin=new Float_t*[NUMLEDS*NUMPULSERBOXES];
14433
14434
14435 for (Int_t i=0;i<NUMPULSERBOXES;i++){
14436 for (Int_t j=0;j<NUMLEDS;j++){
14437 Int_t l=i*NUMLEDS+j;
14438
14439 maxAdcHighPin[l]=new Float_t[const_numCalibPoints];
14440 maxAdcLowPin[l]=new Float_t[const_numCalibPoints];
14441
14442 for (Int_t k=0;k<const_numCalibPoints;k++){
14443 maxAdcHighPin[l][k]=0;
14444 maxAdcLowPin[l][k]=0;
14445 }
14446 }
14447 }
14448
14449 Bool_t usePinPlex=true;
14450
14451 MSG("LIAnalysis",Msg::kInfo)
14452 <<endl<<"Looping to find pins"<<endl;
14453
14457
14458 this->InitialiseLoopVariables();
14459
14460 for(Int_t entry=0;entry<numEvents;entry++){
14461
14462 this->SetLoopVariables(entry,0);
14463
14464
14465 if (mean==0 || rms==0 || numEntries==0) continue;
14466
14467
14468 if (readoutType==ReadoutType::kPinDiode){
14469
14470 Int_t c=calibPoint-1;
14471
14472 if (pulserBox>=FIRSTPULSERBOX && pulserBox<=LASTPULSERBOX &&
14473 led>=FIRSTLED && led<=LASTLED &&
14474 c<const_numCalibPoints){
14475
14476 Int_t l=pulserBox*NUMLEDS+led-1;
14477
14478 if (usePinPlex){
14479 if (correlatedHit==1){
14480 if (chip==1){
14481
14482 maxAdcHighPin[l][c]=mean;
14483 }
14484 else if (chip==0){
14485
14486 maxAdcLowPin[l][c]=mean;
14487 }
14488 }
14489 }
14490 else{
14491
14492 if (chip==1){
14493
14494 if (mean>maxAdcHighPin[l][c]) {
14495 maxAdcHighPin[l][c]=mean;
14496 MSG("LIAnalysis",Msg::kDebug)
14497 <<"("<<pulserBox<<":"<<led<<") High pin found ("
14498 <<", "<<this->GetElecString()
14499 <<", plex gain="<<pinGain<<", mean="<<mean
14500 <<", rms="<<rms
14501 <<", num="<<numEntries<<", cHit="<<correlatedHit<<endl;
14502 }
14503 }
14504 else if (chip==0){
14505
14506 if (mean>maxAdcLowPin[l][c]) {
14507 maxAdcLowPin[l][c]=mean;
14508 MSG("LIAnalysis",Msg::kDebug)
14509 <<"("<<pulserBox<<":"<<led<<") Low pin found ("
14510 <<", "<<this->GetElecString()
14511 <<", plex gain="<<pinGain<<", mean="<<mean
14512 <<", rms="<<rms
14513 <<", num="<<numEntries<<", cHit="<<correlatedHit<<endl;
14514 }
14515 }
14516 }
14517 }
14518 }
14519 }
14520
14524
14525 MSG("LIAnalysis",Msg::kInfo)
14526 <<"Finished loop to find pins"<<endl;
14527
14528 MSG("LIAnalysis",Msg::kInfo)
14529 <<endl<<"Starting main loop"<<endl;
14530
14534
14535 this->InitialiseLoopVariables();
14536
14537 for(Int_t entry=0;entry<numEvents;entry++){
14538
14539 this->SetLoopVariables(entry,1);
14540
14541
14542 if (mean==0 || rms==0 || numEntries==0) continue;
14543
14544
14545 if (readoutType!=ReadoutType::kScintStrip) continue;
14546
14547 Int_t printMe=0;
14548 if (printMe){
14549 if (correlatedHit==1 && mean<500 && 1.*numEntries/pulses<0.99){
14550 if (lookup.NearOrFar(crate,pulserBox,nearPulserBox,
14551 farPulserBox,led,detectorType,
14552 plane,runNumber)==LILookup::kNearSide &&
14553 pulses>0){
14554 MSG("LIAnalysis",Msg::kInfo)
14555 <<"mean="<<mean
14556 <<" ("<<mean*numEntries/pulses<<")"
14557 <<", rms="<<rms
14558 <<", num="<<numEntries
14559 <<"/"<<pulses
14560 <<"="<<1.*numEntries/pulses
14561 <<endl;
14562
14563 mean*=(numEntries/pulses);
14564 }
14565 }
14566 }
14567
14568
14569 Int_t c=calibPoint-1;
14570 Int_t l=pulserBox*NUMLEDS+led-1;
14571 Int_t se=(stripEnd-1)*NUMSTRIPS*NUMPLANES+plane*NUMSTRIPS+strip;
14572
14573
14574 if (correlatedHit==1){
14575 if (detectorType==Detector::kFar){
14576
14577 if (pulserBox>=FIRSTPULSERBOX && pulserBox<=LASTPULSERBOX &&
14578 led>=FIRSTLED && led<=LASTLED &&
14579 calibPoint>=1 && calibPoint<=const_numCalibPoints){
14580
14581
14582 if (nearPulserBox==pulserBox){
14583 gCurveData[se].SetLIInfo(pulserBox,led,LIRun::kGainCurve);
14584 gCurveData[se].AddPoint(pulseHeight,mean,
14585 maxAdcHighPin[l][c],
14586 maxAdcLowPin[l][c],
14587 rms,
14588 numEntries);
14589 }
14590
14591 else if (farPulserBox==pulserBox) {
14592
14593 }
14594 }
14595 }
14596 else if (detectorType==Detector::kCalDet){
14597
14598 MSG("LIAnalysis",Msg::kVerbose)
14599 <<"("<<pulserBox<<":"<<led
14600 <<") caldet se="<<se<<endl;
14601
14602 if (pulserBox>=FIRSTPULSERBOX && pulserBox<=LASTPULSERBOX &&
14603 crate>=FIRSTCRATE && crate<=LASTCRATE &&
14604 led>=FIRSTLED && led<=LASTLED &&
14605 calibPoint>=1 && calibPoint<=const_numCalibPoints &&
14606 strip>=FIRSTSTRIP && strip<=LASTSTRIP &&
14607 plane>=FIRSTPLANE && plane<=LASTPLANE){
14608
14609
14610 if (lookup.NearOrFar(crate,pulserBox,nearPulserBox,
14611 farPulserBox,led,detectorType,
14612 plane,runNumber)==LILookup::kNearSide){
14613
14614
14615
14616
14617
14618
14619 gCurveData[se].SetLIInfo(pulserBox,led,LIRun::kGainCurve);
14620 gCurveData[se].AddPoint(pulseHeight,mean,
14621 maxAdcHighPin[l][c],
14622 maxAdcLowPin[l][c],
14623 rms,
14624 numEntries);
14625 }
14626
14627 else if (lookup.NearOrFar(crate,pulserBox,nearPulserBox,
14628 farPulserBox,led,detectorType,plane,
14629 runNumber)==LILookup::kFarSide){
14630
14631
14632
14633 }
14634 }
14635 }
14636 }
14637 }
14638
14642
14643 MSG("LIAnalysis",Msg::kInfo)
14644 <<"Finished main loop"<<endl;
14645
14646 MSG("LIAnalysis",Msg::kInfo)
14647 <<endl<<"Writing to text file..."<<endl;
14648 for (Int_t pl=0;pl<NUMPLANES;pl++){
14649 MSG("LIAnalysis",Msg::kDebug)<<"Plane="<<pl<<endl;
14650
14651
14652 if (pl==0 && detectorType==Detector::kCalDet) continue;
14653
14654
14655
14656
14657
14658 if (pl%(NUMPLANES/5)==0){
14659 MSG("LIAnalysis",Msg::kInfo)<<"Plane="<<pl<<endl;
14660 }
14661
14662 for (Int_t st=0;st<NUMSTRIPS;st++){
14663 for (Int_t end=FIRSTEND;end<=SECONDEND;end++){
14664
14665
14666 Int_t se=(end-1)*NUMPLANES*NUMSTRIPS+pl*NUMSTRIPS+st;
14667
14668 string sPlane=Form("%d",pl);
14669 string sStrip=Form("%d",st);
14670 string sEnd=Form("%d",end);
14671 string sPlStEnd=" (Pl,St,End)=("+sPlane+","+sStrip+","+sEnd+")";
14672
14673 Int_t pulserBox=gCurveData[se].GetPb();
14674 Int_t led=gCurveData[se].GetLed();
14675
14676 MSG("LIAnalysis",Msg::kVerbose)<<sPlStEnd<<endl;
14677 vector<Double_t> pin;
14678 vector<Double_t> adc;
14679 pin=gCurveData[se].GetPin(2);
14680 adc=gCurveData[se].GetAdc();
14681
14682
14683 vector<Double_t> numEntries;
14684 numEntries=gCurveData[se].GetAdcLow();
14685 vector<Double_t> rms;
14686 rms=gCurveData[se].GetAdcF();
14687 vector<Double_t> ph;
14688 ph=gCurveData[se].GetPh();
14689
14690
14691 if (adc.size()>0){
14692
14693
14694 if (pl%3==0 && st%6==0){
14695 MSG("LIAnalysis",Msg::kInfo)
14696 <<"Processing"<<sPlStEnd<<endl;
14697 }
14698
14699
14700 for (UInt_t i=0;i<adc.size();i++){
14701
14702 if (i==0){
14703 MSG("LIAnalysis",Msg::kInfo)
14704 <<"i="<<i<<", adc="<<adc[i]<<endl;
14705 }
14706
14707
14708 TextFile<<pl<<"\t"<<st<<"\t"<<end
14709 <<"\t" <<pulserBox<<"\t"<<led
14710 <<"\t"<<adc.size()<<"\t"<<ph[i]
14711 <<"\t" <<adc[i]<<"\t"<<rms[i]<<"\t"<<numEntries[i]
14712 <<"\t"<<pin[i]
14713 <<endl;
14714 }
14715 }
14716 }
14717 }
14718 }
14719
14720 MSG("LIAnalysis",Msg::kInfo)
14721 <<endl<<" ** Finished the WriteGainCurveTextFile method ** "<<endl;
14722 }
14723
14724
14725
14726 void LIAnalysis::WriteGainsTextFile(Int_t task, std::string fileName)
14727 {
14728 MSG("LIAnalysis",Msg::kInfo)
14729 <<endl<<" ** Running the WriteGainsTextFile method... ** "<<endl;
14730
14731
14732
14733
14734 string sRunNumber=Form("%d",runNumber);
14735
14736
14737
14738 if (fileName == "") {
14739 fileName=sRunNumber+"Gains.dat";
14740 }
14741
14742
14743 ofstream TextFile(fileName.c_str());
14744
14745 if(!TextFile){
14746 MSG("LISummary",Msg::kError)
14747 << "Couldn't open file: "<<fileName<<endl
14748 <<"Will exit here..."<<endl;
14749 exit(0);
14750 }
14751
14752 Int_t numAdcBins=150;
14753
14754
14755 TH1F **hAdcLed2=0;
14756 hAdcLed2= new TH1F*[NUMLEDS*NUMPULSERBOXES];
14757 for (Int_t i=0;i<NUMPULSERBOXES;i++){
14758 for (Int_t j=0;j<NUMLEDS;j++){
14759
14760 Int_t l=i*NUMLEDS+j;
14761
14762 sprintf(histname,"hAdcLed2_%d_%d",i,j+1);
14763 hAdcLed2[l]=new TH1F(histname,histname,numAdcBins,0,15000);
14764 hAdcLed2[l]->GetXaxis()->SetTitle("ADC");
14765 hAdcLed2[l]->GetXaxis()->CenterTitle();
14766 hAdcLed2[l]->GetYaxis()->SetTitle("Number of Entries");
14767 hAdcLed2[l]->GetYaxis()->CenterTitle();
14768 hAdcLed2[l]->SetFillColor(0);
14769 hAdcLed2[l]->Fill(1);
14770 hAdcLed2[l]->SetBit(TH1::kCanRebin);
14771 }
14772 }
14773
14774 TH1F **hGain2=0;
14775 hGain2= new TH1F*[NUMLEDS*NUMPULSERBOXES];
14776 for (Int_t i=0;i<NUMPULSERBOXES;i++){
14777 for (Int_t j=0;j<NUMLEDS;j++){
14778
14779 Int_t l=i*NUMLEDS+j;
14780 sprintf(histname,"hGain2_%d_%d",i,j+1);
14781 hGain2[l]=new TH1F(histname,histname,numAdcBins,0,200);
14782 hGain2[l]->GetXaxis()->SetTitle("Gain");
14783 hGain2[l]->GetXaxis()->CenterTitle();
14784 hGain2[l]->GetYaxis()->SetTitle("Number of Entries");
14785 hGain2[l]->GetYaxis()->CenterTitle();
14786 hGain2[l]->SetFillColor(0);
14787 hGain2[l]->SetLineColor(2);
14788 hGain2[l]->SetBit(TH1::kCanRebin);
14789 }
14790 }
14791
14792 TH1F **hGainErr2=0;
14793 hGainErr2= new TH1F*[NUMLEDS*NUMPULSERBOXES];
14794 for (Int_t i=0;i<NUMPULSERBOXES;i++){
14795 for (Int_t j=0;j<NUMLEDS;j++){
14796
14797 Int_t l=i*NUMLEDS+j;
14798 sprintf(histname,"hGainErr2_%d_%d",i,j+1);
14799 hGainErr2[l]=new TH1F(histname,histname,numAdcBins,0,10);
14800 hGainErr2[l]->GetXaxis()->SetTitle("GainErr");
14801 hGainErr2[l]->GetXaxis()->CenterTitle();
14802 hGainErr2[l]->GetYaxis()->SetTitle("Number of Entries");
14803 hGainErr2[l]->GetYaxis()->CenterTitle();
14804 hGainErr2[l]->SetFillColor(0);
14805 hGainErr2[l]->SetLineColor(2);
14806
14807 }
14808 }
14809
14810 TH1F **hNpe2=0;
14811 hNpe2= new TH1F*[NUMLEDS*NUMPULSERBOXES];
14812 for (Int_t i=0;i<NUMPULSERBOXES;i++){
14813 for (Int_t j=0;j<NUMLEDS;j++){
14814
14815 Int_t l=i*NUMLEDS+j;
14816 sprintf(histname,"hNpe2_%d_%d",i,j+1);
14817 hNpe2[l]=new TH1F(histname,histname,numAdcBins,0,100);
14818 hNpe2[l]->GetXaxis()->SetTitle("Npe");
14819 hNpe2[l]->GetXaxis()->CenterTitle();
14820 hNpe2[l]->GetYaxis()->SetTitle("Number of Entries");
14821 hNpe2[l]->GetYaxis()->CenterTitle();
14822 hNpe2[l]->SetFillColor(0);
14823 hNpe2[l]->SetLineColor(2);
14824 hNpe2[l]->SetBit(TH1::kCanRebin);
14825 }
14826 }
14827
14828 TH1F **hNum2=0;
14829 hNum2= new TH1F*[NUMLEDS*NUMPULSERBOXES];
14830 for (Int_t i=0;i<NUMPULSERBOXES;i++){
14831 for (Int_t j=0;j<NUMLEDS;j++){
14832
14833 Int_t l=i*NUMLEDS+j;
14834 sprintf(histname,"hNum2_%d_%d",i,j+1);
14835 hNum2[l]=new TH1F(histname,histname,numAdcBins,0,30000);
14836 hNum2[l]->GetXaxis()->SetTitle("Gain");
14837 hNum2[l]->GetXaxis()->CenterTitle();
14838 hNum2[l]->GetYaxis()->SetTitle("Number of Entries");
14839 hNum2[l]->GetYaxis()->CenterTitle();
14840 hNum2[l]->SetFillColor(0);
14841 hNum2[l]->SetLineColor(2);
14842 hNum2[l]->SetBit(TH1::kCanRebin);
14843 }
14844 }
14845
14846 vector<LIChannel> stripEndNearEnd(NUMPLANES*NUMSTRIPS*NUMENDS);
14847 vector<LIChannel> stripEndFarEnd(NUMPLANES*NUMSTRIPS*NUMENDS);
14848
14852
14853 this->InitialiseLoopVariables();
14854
14855 Int_t lowesttime = -1;
14856
14857 for(Int_t entry=0;entry<numEvents;entry++){
14858
14859 this->SetLoopVariables(entry,0);
14860
14861
14862 if (readoutType!=ReadoutType::kScintStrip) continue;
14863
14864
14865 if (mean==0 || rms==0 || numEntries==0) continue;
14866
14867
14868 if (calibType != 1) continue;
14869
14870
14871 if (lowesttime >= 0.) {
14872 lowesttime = TMath::Min(lowesttime, timestamp);
14873 } else {
14874
14875 lowesttime = timestamp;
14876 }
14877
14878
14879 Int_t seIndex=plane*NUMSTRIPS*NUMENDS+strip*NUMENDS+stripEnd-1;
14880
14881 Int_t nearOrFar=lookup.NearOrFar(crate,pulserBox,nearPulserBox,
14882 farPulserBox,led,detectorType,
14883 plane,runNumber);
14884
14885 if (correlatedHit==1 && nearOrFar==LILookup::kNearSide){
14886 if (plane<FIRSTSCINTPLANE || plane>LASTSCINTPLANE) continue;
14887 stripEndNearEnd[seIndex].AddEntry(numEntries,mean,rms);
14888 }
14889 else if (correlatedHit==1 && nearOrFar==LILookup::kFarSide){
14890 if (plane<FIRSTSCINTPLANE || plane>LASTSCINTPLANE) continue;
14891 stripEndFarEnd[seIndex].AddEntry(numEntries,mean,rms);
14892 }
14893 }
14894
14898
14899 MSG("LIAnalysis",Msg::kInfo)<<"Finished main loop"<<endl;
14900
14901
14902 TDatime datimel;
14903 datimel.Set(lowesttime);
14904 MSG("LIAnalysis",Msg::kInfo)<<" LowestTimestamp"<<setw(3)<< -1 <<" %: "<<datimel.GetDate()<<" "
14905 <<datimel.GetYear()<<" "<<setw(2)<<datimel.GetMonth()<<" "<<setw(2)<<datimel.GetDay()<<" "
14906 <<setw(2)<<datimel.GetHour()<<" "<<setw(2)<<datimel.GetMinute()<<" "<<setw(2)<<datimel.GetSecond()<<endl;
14907
14908
14909
14910
14911 chain->GetEvent(10); TDatime datime; datime.Set(timestamp);
14912
14913 MSG("LIAnalysis",Msg::kInfo)<<"Getting plex handle..."<<endl;
14914 VldTimeStamp tsnow(datime.GetYear(),datime.GetMonth(),datime.GetDay(),datime.GetHour(),datime.GetMinute(),datime.GetSecond());
14915 VldContext vldCtx(static_cast<Detector::Detector_t>(detectorType),SimFlag::kData,tsnow);
14916 Calibrator& cal = Calibrator::Instance();
14917 if(detectorType==Detector::kNear) {
14918 cal.Set("LinCalibrator=QuadLinearityCalScheme");
14919 cal.GetLinCalibrator().Set("BucketMode",0);
14920 } else cal.Set("LinCalibrator=PulserLinearityCalScheme");
14921 cal.Reset(vldCtx);
14922 PlexHandle plexHandle(vldCtx);
14923 vldCtx.Print();
14924
14925 vector<LIPlane> planeNearEnd;
14926 vector<LIPlane> planeFarEnd;
14927 for (Int_t i=0;i<=LASTSCINTPLANE;i++){
14928 planeNearEnd.push_back(LIPlane(FIRSTSTRIP,LASTSTRIP));
14929 planeFarEnd.push_back(LIPlane(FIRSTSTRIP,LASTSTRIP));
14930 }
14931
14932 MSG("LIAnalysis",Msg::kInfo)
14933 <<endl<<"Creating LIPlane objects..."<<endl;
14934 for (Int_t pl=FIRSTSCINTPLANE;pl<=LASTSCINTPLANE;pl++){
14935 for (Int_t st=FIRSTSTRIP;st<=LASTSTRIP;st++){
14936 for (Int_t end=FIRSTEND;end<=SECONDEND;end++){
14937
14938
14939 Int_t seIndex=pl*NUMSTRIPS*NUMENDS+st*NUMENDS+end-1;
14940
14941 Float_t tempRms=stripEndNearEnd[seIndex].GetRms();
14942 Float_t tempMean=stripEndNearEnd[seIndex].GetMean();
14943 Float_t tempNent=stripEndNearEnd[seIndex].GetNumEntries();
14944
14945
14946 Float_t gain=-1;
14947 Float_t gainErr=-1;
14948
14949 if(tempNent>1 && tempMean>0) {
14950
14951 if(task==1 && detectorType==Detector::kNear) {
14952
14953 PlexStripEndId seid(static_cast<Detector::Detector_t>
14954 (detectorType),pl,st,
14955 static_cast<StripEnd::EStripEnd>(end));
14956
14957
14958 if (!seid.IsValid()) continue;
14959
14960 Float_t linN = cal.GetLinearized(tempMean, seid);
14961 Float_t input_minus = tempMean - tempRms, input_plus = tempMean + tempRms;
14962 Float_t linMinus = cal.GetLinearized(input_minus, seid);
14963 Float_t linPlus = cal.GetLinearized(input_plus, seid);
14964 Float_t linNrms = (linPlus - linMinus)/2.;
14965 if((linN-tempMean)<0 || (linNrms-tempRms)<0) { linNrms = tempRms; linN = tempMean; }
14966 tempRms = linNrms; tempMean = linN;
14967 }
14968
14969
14970 gain=0.806*(tempRms*tempRms/tempMean);
14971
14972
14973 if (detectorType==Detector::kNear) {
14974 gain = 0.844*(tempRms*tempRms/tempMean);
14975 }
14976
14977 Float_t tempRmsErr=tempRms/sqrt(2.0*tempNent);
14978 Float_t tempMeanErr=tempRms/sqrt(tempNent-1);
14979
14980 gainErr=sqrt(pow(2.0*tempRms/tempMean,2)*tempRmsErr*tempRmsErr
14981 +pow(tempRms/tempMean,4)*
14982 tempMeanErr*tempMeanErr);
14983
14984
14985
14986
14987
14988 if (detectorType==Detector::kNear) {
14989 gainErr*=0.844;
14990 } else {
14991 gainErr*=0.806;
14992 }
14993
14994 }
14995
14996 planeNearEnd[pl].SetPoint(end,st,tempMean,gain,gainErr,
14997 tempNent);
14998
15000
15002 tempRms=stripEndFarEnd[seIndex].GetRms();
15003 tempMean=stripEndFarEnd[seIndex].GetMean();
15004 tempNent=stripEndFarEnd[seIndex].GetNumEntries();
15005 gain=-1;
15006 gainErr=-1;
15007
15008 if(tempNent>1 && tempMean>0) {
15009
15010 gain=0.806*(tempRms*tempRms/tempMean);
15011
15012
15013 if (detectorType==Detector::kNear) {
15014 gain = 0.844*(tempRms*tempRms/tempMean);
15015 }
15016
15017 Float_t tempRmsErr=tempRms/sqrt(2.0*tempNent);
15018 Float_t tempMeanErr=tempRms/sqrt(tempNent-1);
15019
15020 gainErr=sqrt(pow(2.0*tempRms/tempMean,2)*tempRmsErr*tempRmsErr
15021 +pow(tempRms/tempMean,4)*
15022 tempMeanErr*tempMeanErr);
15023
15024
15025
15026
15027
15028 if (detectorType==Detector::kNear) {
15029 gainErr*=0.844;
15030 } else {
15031 gainErr*=0.806;
15032 }
15033 }
15034
15035 planeFarEnd[pl].SetPoint(end,st,tempMean,gain,gainErr,
15036 tempNent);
15037 }
15038 }
15039 }
15040
15041
15042 Int_t misEvenCounter=0;
15043 Int_t misOddCounter=0;
15044 Int_t bothBadCounter=0;
15045 Int_t nearBadCounter=0;
15046 Int_t nearGoodCounter=0;
15047
15048
15049
15050 Float_t defaultGain=1;
15051 Float_t defaultGainErr=0;
15052 Float_t defaultSPEWidth=0;
15053 Float_t SPEWidthFraction=0.5;
15054
15055 MSG("LIAnalysis",Msg::kInfo)
15056 <<endl<<"Writing to text file..."<<endl;
15057 for (Int_t pl=FIRSTSCINTPLANE;pl<=LASTSCINTPLANE;pl++){
15058 for (Int_t st=FIRSTSTRIP;st<=LASTSTRIP;st++){
15059 for (Int_t end=FIRSTEND;end<=SECONDEND;end++){
15060
15061
15062 PlexStripEndId seid(static_cast<Detector::Detector_t>
15063 (detectorType),pl,st,
15064 static_cast<StripEnd::EStripEnd>(end));
15065
15066
15067 if (!seid.IsValid()) continue;
15068
15069
15070 if ((pl==SM1BOOKEND || pl==SM2BOOKEND) &&
15071 detectorType==Detector::kFar) continue;
15072
15073
15074 Float_t adcN=planeNearEnd[pl].GetAdc(end,st);
15075 Float_t adcF=planeFarEnd[pl].GetAdc(end,st);
15076 Float_t gainN=planeNearEnd[pl].GetGain(end,st);
15077 Float_t gainErrN=planeNearEnd[pl].GetGainErr(end,st);
15078 Float_t gainF=planeFarEnd[pl].GetGain(end,st);
15079 Float_t gainErrF=planeFarEnd[pl].GetGainErr(end,st);
15080 Int_t numN=static_cast<Int_t>(planeNearEnd[pl].
15081 GetNumEnt(end,st));
15082 Int_t numF=static_cast<Int_t>(planeFarEnd[pl].
15083 GetNumEnt(end,st));
15084 Float_t SPEWidthN=SPEWidthFraction*gainN;
15085 Float_t SPEWidthF=SPEWidthFraction*gainF;
15086
15087 PlexPixelSpotId pixSpotId=plexHandle.GetPixelSpotId(seid);
15088 if (! pixSpotId.IsValid()) continue;
15089 PlexLedId plexLedId = plexHandle.GetLedId(seid);
15090 Int_t l=plexLedId.GetPulserBox()*NUMLEDS+plexLedId.GetLedInBox()-1;
15091
15092 string sAdcN=Form("%.0f",adcN);
15093 string sAdcF=Form("%.0f",adcF);
15094 string sGainN=Form("%.1f",gainN);
15095 string sGainF=Form("%.1f",gainF);
15096 string sGainErrN=Form("%.1f",gainErrN);
15097 string sGainErrF=Form("%.1f",gainErrF);
15098 string sNumN=Form("%d",numN);
15099 string sNumF=Form("%d",numF);
15100
15101 Bool_t nearEndBad=false;
15102 Bool_t farEndBad=false;
15103
15104 if (detectorType==Detector::kFar
15105 || detectorType==Detector::kCalDet) {
15106
15107 if (adcN<400 || adcN>8000) nearEndBad=true;
15108 if (numN<400) nearEndBad=true;
15109
15110 if (adcF<400 || adcF>8000) farEndBad=true;
15111 if (numF<400) farEndBad=true;
15112
15113
15114 if (runNumber>80000 && detectorType==Detector::kCalDet){
15115
15116
15117 if (pl>0 && pl%2==0 && end==1){
15118 TextFile<<pl<<"\t"<<st<< "\t"<<end
15119 <<"\t" <<defaultGain<<"\t" <<defaultGainErr
15120 <<"\t" <<defaultSPEWidth<<endl;
15121 misEvenCounter++;
15122
15123 continue;
15124 }
15125 else if (pl>0 && pl%2==1 && end==2){
15126 TextFile<<pl<<"\t"<<st<< "\t"<<end
15127 <<"\t" <<defaultGain<<"\t" <<defaultGainErr
15128 <<"\t" <<defaultSPEWidth<<endl;
15129 misOddCounter++;
15130
15131 continue;
15132 }
15133 }
15134 }
15135
15136
15137
15138
15139 if (detectorType==Detector::kNear) {
15140
15141 if (adcN<600 || adcN>14000) nearEndBad=true;
15142 if (numN<400) nearEndBad=true;
15143 }
15144
15145 if (!nearEndBad){
15146 this->PrintGainTableRow(pl,st,end," Using near end.",
15147 sAdcN,sGainN,sGainErrN,sNumN,
15148 sAdcF,sGainF,sGainErrF,sNumF);
15149 nearGoodCounter++;
15150 if (gainN>-1 && gainN<200) {
15151 hAdcLed2[l]->Fill(adcN); hNum2[l]->Fill(numN); hGain2[l]->Fill(gainN); hGainErr2[l]->Fill(gainErrN); hNpe2[l]->Fill(adcN/gainN);
15152 }
15153
15154 TextFile<<pl<<"\t"<<st<< "\t"<<end
15155 <<"\t" <<gainN<<"\t" <<gainErrN
15156 <<"\t" <<SPEWidthN<<endl;
15157 }
15158 else if (!farEndBad){
15159 this->PrintGainTableRow(pl,st,end," Using far end.",
15160 sAdcN,sGainN,sGainErrN,sNumN,
15161 sAdcF,sGainF,sGainErrF,sNumF,"Info");
15162 nearBadCounter++;
15163 if(gainF>-1 && gainF<200) {
15164 hAdcLed2[l]->Fill(adcF); hNum2[l]->Fill(numF); hGain2[l]->Fill(gainF); hGainErr2[l]->Fill(gainErrF); hNpe2[l]->Fill(adcF/gainF);
15165 }
15166
15167 TextFile<<pl<<"\t"<<st<< "\t"<<end
15168 <<"\t" <<gainF<<"\t" <<gainErrF
15169 <<"\t" <<SPEWidthF<<endl;
15170 }
15171 else{
15172 this->PrintGainTableRow(pl,st,end," Both ends are bad!",
15173 sAdcN,sGainN,sGainErrN,sNumN,
15174 sAdcF,sGainF,sGainErrF,sNumF,"Info");
15175 bothBadCounter++;
15176
15177 TextFile<<pl<<"\t"<<st<< "\t"<<end
15178 <<"\t" <<-1<<"\t" <<-1<<"\t"
15179 <<-1<<endl;
15180 }
15181 }
15182 }
15183 }
15184
15185 TGraph *gAdcLed2=new TGraph(NUMPULSERBOXES*NUMLEDS);
15186 TGraph *gNpe2=new TGraph(NUMPULSERBOXES*NUMLEDS);
15187 TGraph *gNum2=new TGraph(NUMPULSERBOXES*NUMLEDS);
15188 TGraph *gGain2=new TGraph(NUMPULSERBOXES*NUMLEDS);
15189 TGraph *gGainErr2=new TGraph(NUMPULSERBOXES*NUMLEDS);
15190 gAdcLed2->SetMinimum(-1); gNpe2->SetMinimum(-1); gNum2->SetMinimum(-1); gGain2->SetMinimum(-1); gGainErr2->SetMinimum(-1);
15191
15192 for (Int_t i=0;i<NUMPULSERBOXES;i++){
15193 for (Int_t j=0;j<NUMLEDS;j++){
15194 Int_t l=i*NUMLEDS+j;
15195 gAdcLed2->SetPoint(l,static_cast<Float_t>(l+1),hAdcLed2[l]->GetMean());
15196 gNpe2->SetPoint(l,static_cast<Float_t>(l+1),hNpe2[l]->GetMean());
15197 gNum2->SetPoint(l,static_cast<Float_t>(l+1),hNum2[l]->GetMean());
15198 gGain2->SetPoint(l,static_cast<Float_t>(l+1),hGain2[l]->GetMean());
15199 gGainErr2->SetPoint(l,static_cast<Float_t>(l+1),hGainErr2[l]->GetMean());
15200
15201 Double_t x=-1, yadc=-1, ynpe=-1, ynum=-1, ygain=-1, ygainerr=-1;
15202 gAdcLed2->GetPoint(l,x,yadc); gNpe2->GetPoint(l,x,ynpe); gNum2->GetPoint(l,x,ynum);
15203 gGain2->GetPoint(l,x,ygain); gGainErr2->GetPoint(l,x,ygainerr);
15204
15205 if (yadc>1){
15206 MSG("LIAnalysis",Msg::kInfo)
15207 <<"Average LEDs: "<<detectorType<<" "<<setw(5)<<runNumber<<" "<<datime.GetDate()<<" "<<datime.GetTime()
15208 <<" "<<setw(2)<<i<<" "<<setw(2)<<j+1<<" ADC= "<<setw(8)<<yadc<<" blank= 0"
15209 <<" Npe= "<<setw(7)<<ynpe<<" Gain= "<<setw(7)<<ygain
15210 <<" GainErr= "<<setw(8)<<ygainerr<<" numEntries= "<<setw(7)<<ynum
15211 <<endl;
15212 }
15213
15214 }
15215 }
15216
15217 MSG("LIAnalysis",Msg::kInfo)
15218 <<endl
15219 <<"NUMPLANES="<<NUMPLANES<<endl
15220 <<"NUMSTRIPS="<<NUMSTRIPS<<endl
15221 <<"NUMENDS="<<NUMENDS<<endl
15222 <<"NUMBOOKENDS="<<NUMBOOKENDS<<endl
15223 <<"Total number of strip ends="
15224 <<(NUMPLANES*NUMSTRIPS*NUMENDS)-(NUMBOOKENDS*NUMSTRIPS*NUMENDS)
15225 <<endl;
15226
15227 MSG("LIAnalysis",Msg::kInfo)
15228 <<endl
15229 <<"Skipped "<<misEvenCounter<<" even strip ends"<<endl
15230 <<"Skipped "<<misOddCounter<<" odd strip ends"<<endl
15231 <<"Total skipped "<<misEvenCounter+misOddCounter<<endl;
15232 MSG("LIAnalysis",Msg::kInfo)
15233 <<endl
15234 <<"Number near good="<<nearGoodCounter<<endl
15235 <<"Number near bad="<<nearBadCounter<<endl
15236 <<"Number both bad="<<bothBadCounter<<endl
15237 <<"Total analysed="<<nearGoodCounter+nearBadCounter+bothBadCounter
15238 <<endl;
15239 MSG("LIAnalysis",Msg::kInfo)
15240 <<endl
15241 <<"Grand total = total skipped + total analysed="
15242 <<nearGoodCounter+nearBadCounter+bothBadCounter+
15243 misEvenCounter+misOddCounter
15244 <<endl;
15245
15246
15247
15248
15249
15250 if (detectorType==Detector::kNear) {
15251 MSG("LIAnalysis",Msg::kInfo)
15252 << endl
15253 << "Real number of strip ends in the NearDet: " << 11616
15254 << endl;
15255 MSG("LIAnalysis",Msg::kInfo)
15256 << endl
15257 << nearGoodCounter/11616.*100 << " per cent were good."
15258 << endl;
15259 }
15260
15261 MSG("LIAnalysis",Msg::kInfo)
15262 <<endl<<" ** Finished the WriteGainsTextFile method ** "<<endl;
15263 }
15264
15265
15266
15267 void LIAnalysis::WriteOldGainsTextFile()
15268 {
15269 MSG("LIAnalysis",Msg::kInfo)
15270 <<endl<<" ** Running the WriteOldGainsTextFile method... ** "<<endl;
15271
15272
15273
15274 Int_t* planeMax=new Int_t[NUMCRATES];
15275 Int_t* planeMin=new Int_t[NUMCRATES];
15276 lookup.SetPbPlanes(planeMin,planeMax,detectorType);
15277
15278 const Int_t firstStripBin=FIRSTSTRIP-8;
15279 const Int_t lastStripBin=LASTSTRIP+9;
15280 const Int_t bins=lastStripBin-firstStripBin;
15281
15282 TH2F **hStripVsPlaneGain=0;
15283 hStripVsPlaneGain= new TH2F*[NUMCRATES];
15284 for (Int_t i=0;i<NUMCRATES;i++){
15285 string sPb=Form("%d",i);
15286 fS="Gain (Crate "+sPb+")";
15287 hStripVsPlaneGain[i]=new TH2F(fS.c_str(),fS.c_str(),
15288 planeMax[i]-planeMin[i],
15289 planeMin[i],planeMax[i],
15290 bins,firstStripBin,lastStripBin);
15291 hStripVsPlaneGain[i]->GetXaxis()->SetTitle("Plane");
15292 hStripVsPlaneGain[i]->GetXaxis()->CenterTitle();
15293 hStripVsPlaneGain[i]->GetYaxis()->SetTitle("Strip");
15294 hStripVsPlaneGain[i]->GetYaxis()->CenterTitle();
15295 hStripVsPlaneGain[i]->SetFillColor(0);
15296
15297 }
15298
15299 TH2F **hStripVsPlaneGainErr=0;
15300 hStripVsPlaneGainErr=new TH2F*[NUMCRATES];
15301 for (Int_t i=0;i<NUMCRATES;i++){
15302 string sPb=Form("%d",i);
15303 fS="Gain Error (Crate "+sPb+")";
15304 hStripVsPlaneGainErr[i]=new TH2F(fS.c_str(),fS.c_str(),
15305 planeMax[i]-planeMin[i],
15306 planeMin[i],planeMax[i],
15307 bins,firstStripBin,lastStripBin);
15308 hStripVsPlaneGainErr[i]->GetXaxis()->SetTitle("Plane");
15309 hStripVsPlaneGainErr[i]->GetXaxis()->CenterTitle();
15310 hStripVsPlaneGainErr[i]->GetYaxis()->SetTitle("Strip");
15311 hStripVsPlaneGainErr[i]->GetYaxis()->CenterTitle();
15312 hStripVsPlaneGainErr[i]->SetFillColor(0);
15313
15314 }
15315
15316 TH2F **hStripVsPlaneGainBest=0;
15317 hStripVsPlaneGainBest= new TH2F*[NUMCRATES];
15318 for (Int_t i=0;i<NUMCRATES;i++){
15319 string sPb=Form("%d",i);
15320 fS="Best Gain (Crate "+sPb+")";
15321 hStripVsPlaneGainBest[i]=new TH2F(fS.c_str(),fS.c_str(),
15322 planeMax[i]-planeMin[i],
15323 planeMin[i],planeMax[i],
15324 bins,firstStripBin,lastStripBin);
15325 hStripVsPlaneGainBest[i]->GetXaxis()->SetTitle("Plane");
15326 hStripVsPlaneGainBest[i]->GetXaxis()->CenterTitle();
15327 hStripVsPlaneGainBest[i]->GetYaxis()->SetTitle("Strip");
15328 hStripVsPlaneGainBest[i]->GetYaxis()->CenterTitle();
15329 hStripVsPlaneGainBest[i]->SetFillColor(0);
15330
15331 }
15332
15333 TH2F **hStripVsPlaneGainDiff=0;
15334 hStripVsPlaneGainDiff= new TH2F*[NUMCRATES];
15335 for (Int_t i=0;i<NUMCRATES;i++){
15336 string sPb=Form("%d",i);
15337 fS="Gain Difference % (NearEnd - FarEnd, Crate "+sPb+")";
15338 hStripVsPlaneGainDiff[i]=new TH2F(fS.c_str(),fS.c_str(),
15339 planeMax[i]-planeMin[i],
15340 planeMin[i],planeMax[i],
15341 bins,firstStripBin,lastStripBin);
15342 hStripVsPlaneGainDiff[i]->GetXaxis()->SetTitle("Plane");
15343 hStripVsPlaneGainDiff[i]->GetXaxis()->CenterTitle();
15344 hStripVsPlaneGainDiff[i]->GetYaxis()->SetTitle("Strip");
15345 hStripVsPlaneGainDiff[i]->GetYaxis()->CenterTitle();
15346 hStripVsPlaneGainDiff[i]->SetFillColor(0);
15347
15348 }
15349
15350 TH2F **hStripVsPlaneEnt=0;
15351 hStripVsPlaneEnt= new TH2F*[NUMCRATES];
15352 for (Int_t i=0;i<NUMCRATES;i++){
15353 string sPb=Form("%d",i);
15354 fS="Ent (Crate "+sPb+")";
15355 hStripVsPlaneEnt[i]=new TH2F(fS.c_str(),fS.c_str(),
15356 planeMax[i]-planeMin[i],
15357 planeMin[i],planeMax[i],
15358 bins,firstStripBin,lastStripBin);
15359 hStripVsPlaneEnt[i]->GetXaxis()->SetTitle("Plane");
15360 hStripVsPlaneEnt[i]->GetXaxis()->CenterTitle();
15361 hStripVsPlaneEnt[i]->GetYaxis()->SetTitle("Strip");
15362 hStripVsPlaneEnt[i]->GetYaxis()->CenterTitle();
15363 hStripVsPlaneEnt[i]->SetFillColor(0);
15364
15365 }
15366
15367
15368 string sRunNumber=Form("%d",runNumber);
15369 string fileName=sRunNumber+"Gains.dat";
15370
15371 ofstream TextFile(fileName.c_str());
15372
15373 if(!TextFile){
15374 MSG("LISummary",Msg::kError)
15375 << "Couldn't open file: "<<fileName<<endl
15376 <<"Will exit here..."<<endl;
15377 exit(0);
15378 }
15379
15380 vector<LIPlane> planeNearEnd;
15381 vector<LIPlane> planeFarEnd;
15382
15383 for (Int_t i=0;i<=LASTSCINTPLANE;i++){
15384 planeNearEnd.push_back(LIPlane(FIRSTSTRIP,LASTSTRIP));
15385 planeNearEnd.push_back(LIPlane(FIRSTSTRIP,LASTSTRIP));
15386 }
15387
15391
15392 this->InitialiseLoopVariables();
15393
15394 for(Int_t entry=0;entry<numEvents;entry++){
15395
15396 this->SetLoopVariables(entry,0);
15397
15398
15399 if (readoutType!=ReadoutType::kScintStrip) continue;
15400
15401
15402 if (mean==0 || rms==0 || numEntries==0) continue;
15403
15404 Float_t gain=0.8*(rms*rms/mean);
15405
15406 if (detectorType==Detector::kNear) {
15407 gain = 0.844*(rms*rms/mean);
15408 }
15409
15410
15411 Float_t eMean=rms/sqrt(1.0*(numEntries-1));
15412
15413 Float_t eRms=rms/sqrt(2.0*numEntries);
15414 Float_t eRelMean=eMean/mean;
15415 Float_t eRelRms=eRms/rms;
15416 Float_t eRelGain=sqrt(pow(2*eRelRms,2)+pow(eRelMean,2));
15417
15418 Float_t gainErr=eRelGain*gain;
15419
15420
15421
15422 if (detectorType==Detector::kNear) {
15423 gainErr*= 0.844;
15424 } else {
15425 gainErr*=0.8;
15426 }
15427
15428
15429 Float_t tempRms=rms;
15430 Float_t tempMean=mean;
15431 Float_t tempNent=numEntries;
15432 Float_t rnGainErr=-1;
15433 if(tempNent>1) {
15434 Float_t tempRmsErr=tempRms/sqrt(2.0*tempNent);
15435 Float_t tempMeanErr=tempRms/sqrt(tempNent-1);
15436
15437 rnGainErr=sqrt(pow(2.0*tempRms/tempMean,2)*tempRmsErr*tempRmsErr
15438 +pow(tempRms/tempMean,4)*tempMeanErr*tempMeanErr);
15439
15440
15441 if (detectorType==Detector::kNear) {
15442 rnGainErr*= 0.844;
15443 }
15444 else {
15445 rnGainErr*=0.8;
15446 }
15447 }
15448
15449
15450 gainErr=rnGainErr;
15451
15452 Int_t nearOrFar=lookup.NearOrFar(crate,pulserBox,nearPulserBox,
15453 farPulserBox,led,detectorType,
15454 plane,runNumber);
15455
15456 if (correlatedHit==1 && nearOrFar==LILookup::kNearSide){
15457
15458 if (plane<FIRSTSCINTPLANE || plane>LASTSCINTPLANE) continue;
15459
15460 MSG("LIAnalysis",Msg::kDebug)
15461 <<"my gain err="<<gainErr<<", rn gain err="<<rnGainErr<<endl;
15462
15463 planeNearEnd[plane].SetPoint(stripEnd,strip,mean,gain,gainErr,
15464 numEntries);
15465 }
15466 else if (correlatedHit==1 && nearOrFar==LILookup::kFarSide){
15467
15468 if (plane<FIRSTSCINTPLANE || plane>LASTSCINTPLANE) continue;
15469
15470 planeFarEnd[plane].SetPoint(stripEnd,strip,mean,gain,gainErr,
15471 numEntries);
15472 }
15473 }
15474
15478
15479 MSG("LIAnalysis",Msg::kInfo)<<"Finished main loop"<<endl;
15480
15481
15482 Int_t misEvenCounter=0;
15483 Int_t misOddCounter=0;
15484 Int_t bothBadCounter=0;
15485 Int_t nearBadCounter=0;
15486 Int_t nearGoodCounter=0;
15487
15488
15489
15490 Float_t defaultGain=1;
15491 Float_t defaultGainErr=0;
15492
15493 MSG("LIAnalysis",Msg::kInfo)
15494 <<endl<<"Writing to text file..."<<endl;
15495 for (Int_t pl=FIRSTSCINTPLANE;pl<=LASTSCINTPLANE;pl++){
15496 for (Int_t st=FIRSTSTRIP;st<=LASTSTRIP;st++){
15497 for (Int_t end=FIRSTEND;end<=SECONDEND;end++){
15498
15499
15500 Float_t adcN=planeNearEnd[pl].GetAdc(end,st);
15501 Float_t adcF=planeFarEnd[pl].GetAdc(end,st);
15502 Float_t gainN=planeNearEnd[pl].GetGain(end,st);
15503 Float_t gainErrN=planeNearEnd[pl].GetGainErr(end,st);
15504 Float_t gainF=planeFarEnd[pl].GetGain(end,st);
15505 Float_t gainErrF=planeFarEnd[pl].GetGainErr(end,st);
15506 Int_t numN=static_cast<Int_t>(planeNearEnd[pl].
15507 GetNumEnt(end,st));
15508 Int_t numF=static_cast<Int_t>(planeFarEnd[pl].
15509 GetNumEnt(end,st));
15510
15511 string sAdcN=Form("%.0f",adcN);
15512 string sAdcF=Form("%.0f",adcF);
15513 string sGainN=Form("%.1f",gainN);
15514 string sGainF=Form("%.1f",gainF);
15515 string sGainErrN=Form("%.1f",gainErrN);
15516 string sGainErrF=Form("%.1f",gainErrF);
15517 string sNumN=Form("%d",numN);
15518 string sNumF=Form("%d",numF);
15519
15520 Bool_t nearEndBad=false;
15521 Bool_t farEndBad=false;
15522
15523 if (adcN<500 || adcN>12000) nearEndBad=true;
15524 if (adcF<500 || adcF>12000) farEndBad=true;
15525
15526
15527 if (runNumber>80000){
15528
15529 if (pl>0 && pl%2==0 && end==1){
15530 TextFile<<pl<<"\t"<<st<< "\t"<<end
15531 <<"\t" <<defaultGain<<"\t" <<defaultGainErr<<endl;
15532 misEvenCounter++;
15533
15534 continue;
15535 }
15536 else if (pl>0 && pl%2==1 && end==2){
15537 TextFile<<pl<<"\t"<<st<< "\t"<<end
15538 <<"\t" <<defaultGain<<"\t" <<defaultGainErr<<endl;
15539 misOddCounter++;
15540
15541 continue;
15542 }
15543
15544 }
15545
15546 if (!nearEndBad){
15547 this->PrintGainTableRow(pl,st,end," Using near end.",
15548 sAdcN,sGainN,sGainErrN,sNumN,
15549 sAdcF,sGainF,sGainErrF,sNumF);
15550 nearGoodCounter++;
15551
15552 TextFile<<pl<<"\t"<<st<< "\t"<<end
15553 <<"\t" <<gainN<<"\t" <<gainErrN<<endl;
15554 }
15555 else if (!farEndBad){
15556 this->PrintGainTableRow(pl,st,end," Using far end.",
15557 sAdcN,sGainN,sGainErrN,sNumN,
15558 sAdcF,sGainF,sGainErrF,sNumF,"Info");
15559 nearBadCounter++;
15560
15561 TextFile<<pl<<"\t"<<st<< "\t"<<end
15562 <<"\t" <<gainF<<"\t" <<gainErrF<<endl;
15563 }
15564 else{
15565 this->PrintGainTableRow(pl,st,end," Both ends are bad!",
15566 sAdcN,sGainN,sGainErrN,sNumN,
15567 sAdcF,sGainF,sGainErrF,sNumF,"Info");
15568 bothBadCounter++;
15569
15570 TextFile<<pl<<"\t"<<st<< "\t"<<end
15571 <<"\t" <<-1<<"\t" <<-1<<endl;
15572 }
15573 }
15574 }
15575 }
15576
15577 MSG("LIAnalysis",Msg::kInfo)
15578 <<endl
15579 <<"Skipped "<<misEvenCounter<<" even strip ends"<<endl
15580 <<"Skipped "<<misOddCounter<<" odd strip ends"<<endl
15581 <<"Total skipped "<<misEvenCounter+misOddCounter<<endl;
15582 MSG("LIAnalysis",Msg::kInfo)
15583 <<endl
15584 <<"Number near good="<<nearGoodCounter<<endl
15585 <<"Number near bad="<<nearBadCounter<<endl
15586 <<"Number both bad="<<bothBadCounter<<endl
15587 <<"Total analysed="<<nearGoodCounter+nearBadCounter+bothBadCounter
15588 <<endl;
15589 MSG("LIAnalysis",Msg::kInfo)
15590 <<endl
15591 <<"Grand total = total skipped + total analysed="
15592 <<nearGoodCounter+nearBadCounter+bothBadCounter+
15593 misEvenCounter+misOddCounter
15594 <<endl;
15595
15596 bothBadCounter=0;
15597 Int_t bigDiffCounter=0;
15598 Int_t lowDiffCounter=0;
15599 Int_t totalCounter=0;
15600
15601 vector<Double_t> vGainDiff;
15602 vector<Double_t> vMeanDiff;
15603 vector<Double_t> vGainDiff2;
15604 vector<Double_t> vMeanDiff2;
15605 vector<Double_t> vGainDiff3;
15606 vector<Double_t> vMeanDiff3;
15607 vector<Double_t> vGainDiff4;
15608 vector<Double_t> vMeanDiff4;
15609
15610 vector<Double_t> vGainDiffN;
15611 vector<Double_t> vMeanDiffN;
15612 vector<Double_t> vGainDiffN2;
15613 vector<Double_t> vMeanDiffN2;
15614 vector<Double_t> vGainDiffN3;
15615 vector<Double_t> vMeanDiffN3;
15616 vector<Double_t> vGainDiffN4;
15617 vector<Double_t> vMeanDiffN4;
15618
15619 MSG("LIAnalysis",Msg::kInfo)
15620 <<endl<<endl<<"Suspect gains:"<<endl;
15621 for (Int_t pl=0;pl<60;pl++){
15622 for (Int_t st=0;st<24;st++){
15623 for (Int_t end=1;end<3;end++){
15624
15625 totalCounter++;
15626
15627
15628 Float_t adcN=planeNearEnd[pl].GetAdc(end,st);
15629 Float_t adcF=planeFarEnd[pl].GetAdc(end,st);
15630 Float_t gainN=planeNearEnd[pl].GetGain(end,st);
15631 Float_t gainErrN=planeNearEnd[pl].GetGainErr(end,st);
15632 Float_t gainF=planeFarEnd[pl].GetGain(end,st);
15633 Float_t gainErrF=planeFarEnd[pl].GetGainErr(end,st);
15634
15635
15636
15637
15638
15639
15640 string sAdcN=Form("%.0f",adcN);
15641 string sAdcF=Form("%.0f",adcF);
15642 string sGainN=Form("%.1f",gainN);
15643 string sGainF=Form("%.1f",gainF);
15644 string sGainErrN=Form("%.1f",gainErrN);
15645 string sGainErrF=Form("%.1f",gainErrF);
15646
15647
15648 Float_t gainDiff=planeNearEnd[pl].GetGain(end,st)-
15649 planeFarEnd[pl].GetGain(end,st);
15650 string sGainDiff=Form("%.1f",gainDiff);
15651 Float_t gainAv=(planeNearEnd[pl].GetGain(end,st)+
15652 planeFarEnd[pl].GetGain(end,st))/2;
15653 Float_t gainDiffPercent=100*gainDiff/gainAv;
15654 Float_t gainDiffPercent2=100*gainDiff/gainAv;
15655 if (gainDiffPercent<0) gainDiffPercent*=-1;
15656 string sGainDiffPercent=Form("%.1f",gainDiffPercent);
15657
15658 Float_t meanAv=(planeNearEnd[pl].GetAdc(end,st)+
15659 planeFarEnd[pl].GetAdc(end,st))/2;
15660 Float_t meanDiff=planeNearEnd[pl].GetAdc(end,st)-
15661 planeFarEnd[pl].GetAdc(end,st);
15662 Float_t meanDiffPercent=100*meanDiff/meanAv;
15663 if (meanDiffPercent<0) meanDiffPercent*=-1;
15664
15665 Bool_t nearEndBad=false;
15666 Bool_t farEndBad=false;
15667
15668 if (adcN<400 || adcN>7000) nearEndBad=true;
15669 if (adcF<400 || adcF>7000) farEndBad=true;
15670
15671
15672 hStripVsPlaneGainErr[end-1]->Fill(pl,st,gainErrN);
15673 hStripVsPlaneGain[end-1]->Fill(pl,st,gainN);
15674 hStripVsPlaneEnt[end-1]->Fill(pl,st,1);
15675
15676 if (nearEndBad && farEndBad) bothBadCounter++;
15677
15678 string sPrefix="";
15679
15680 if (end==1){
15681 vGainDiff.push_back(gainDiffPercent2);
15682 vMeanDiff.push_back(meanDiff);
15683 if (adcN>4000){
15684 vGainDiff2.push_back(gainDiffPercent2);
15685 vMeanDiff2.push_back(meanDiff);
15686 }
15687 if (adcN>6000){
15688 vGainDiff3.push_back(gainDiffPercent2);
15689 vMeanDiff3.push_back(meanDiff);
15690 }
15691 if (adcN>7000){
15692 vGainDiff4.push_back(gainDiffPercent2);
15693 vMeanDiff4.push_back(meanDiff);
15694 }
15695 }
15696 if (end==2){
15697 vGainDiffN.push_back(gainDiffPercent2);
15698 vMeanDiffN.push_back(meanDiff);
15699 if (adcN>4000){
15700 vGainDiffN2.push_back(gainDiffPercent2);
15701 vMeanDiffN2.push_back(meanDiff);
15702 }
15703 if (adcN>6000){
15704 vGainDiffN3.push_back(gainDiffPercent2);
15705 vMeanDiffN3.push_back(meanDiff);
15706 }
15707 if (adcN>7000){
15708 vGainDiffN4.push_back(gainDiffPercent2);
15709 vMeanDiffN4.push_back(meanDiff);
15710 }
15711 }
15712
15714
15716 if (gainDiffPercent>3 &&
15717 !nearEndBad && !farEndBad){
15718 bigDiffCounter++;
15719
15720 hStripVsPlaneGainDiff[end-1]->Fill(pl,st,gainDiffPercent);
15721
15722 sPrefix=" ** ";
15723 MSG("LIAnalysis",Msg::kInfo)
15724 <<sPrefix<<"("<<pl<<";"<<st<<";"<<end<<")"
15725 <<" NearEnd(m,g,n)=("<<sAdcN
15726 <<","<<sGainN
15727 <<","<<planeNearEnd[pl].GetNumEnt(end,st)<<")"
15728 <<", FarEnd(m,g,n)=("<<sAdcF
15729 <<","<<sGainF
15730 <<","<<planeFarEnd[pl].GetNumEnt(end,st)<<")"
15731 <<", "<<sGainDiff<<" ("<<sGainDiffPercent<<"%)"
15732 <<endl;
15733 }
15734 else if (gainDiffPercent<3){
15735 lowDiffCounter++;
15736 }
15737 }
15738 }
15739 }
15740
15741 MSG("LIAnalysis",Msg::kInfo)
15742 <<endl<<" ** Stats: **"
15743 <<endl<<" Both bad = "<<bothBadCounter
15744 <<" ("<<100*bothBadCounter/totalCounter<<"%)"
15745 <<endl<<" Big diff = "<<bigDiffCounter
15746 <<" ("<<100*bigDiffCounter/totalCounter<<"%)"
15747 <<endl<<" Low diff = "<<lowDiffCounter
15748 <<" ("<<100*lowDiffCounter/totalCounter<<"%)"
15749 <<endl;
15750
15751
15752 gStyle->SetOptStat(0);
15753
15754 TCanvas *cStripVsPlaneGain=new TCanvas
15755 ("cStripVsPlaneGain","StripVsPlane: Gain",0,0,1000,800);
15756 cStripVsPlaneGain->SetFillColor(0);
15757 cStripVsPlaneGain->Divide(1,2);
15758 cStripVsPlaneGain->cd(1);
15759 hStripVsPlaneGain[0]->Draw("colz");
15760 cStripVsPlaneGain->cd(2);
15761 hStripVsPlaneGain[1]->Draw("colz");
15762
15763 TCanvas *cStripVsPlaneGainErr=new TCanvas
15764 ("cStripVsPlaneGainErr","StripVsPlane: GainErr",0,0,1000,800);
15765 cStripVsPlaneGainErr->SetFillColor(0);
15766 cStripVsPlaneGainErr->Divide(1,2);
15767 cStripVsPlaneGainErr->cd(1);
15768 hStripVsPlaneGainErr[0]->Draw("colz");
15769 cStripVsPlaneGainErr->cd(2);
15770 hStripVsPlaneGainErr[1]->Draw("colz");
15771
15772 TCanvas *cStripVsPlaneGainDiff=new TCanvas
15773 ("cStripVsPlaneGainDiff","StripVsPlane: GainDiff",0,0,1000,800);
15774 cStripVsPlaneGainDiff->SetFillColor(0);
15775 cStripVsPlaneGainDiff->Divide(1,2);
15776 cStripVsPlaneGainDiff->cd(1);
15777 hStripVsPlaneGainDiff[0]->Draw("colz");
15778 cStripVsPlaneGainDiff->cd(2);
15779 hStripVsPlaneGainDiff[1]->Draw("colz");
15780
15781 TCanvas *cStripVsPlaneEnt=new TCanvas
15782 ("cStripVsPlaneEnt","StripVsPlane: Ent",0,0,1000,800);
15783 cStripVsPlaneEnt->SetFillColor(0);
15784 cStripVsPlaneEnt->Divide(1,2);
15785 cStripVsPlaneEnt->cd(1);
15786 hStripVsPlaneEnt[0]->Draw("colz");
15787 cStripVsPlaneEnt->cd(2);
15788 hStripVsPlaneEnt[1]->Draw("colz");
15789
15790 TCanvas *cGainVsMeanDiff=new TCanvas
15791 ("cGainVsMeanDiff","cGainVsMeanDiff",0,0,1000,800);
15792 cGainVsMeanDiff->SetFillColor(0);
15793
15794
15795 TGraph* gGainVsMeanDiff=TGraphVect(vMeanDiff,vGainDiff);
15796 TGraph* gGainVsMeanDiff2=TGraphVect(vMeanDiff2,vGainDiff2);
15797 TGraph* gGainVsMeanDiff3=TGraphVect(vMeanDiff3,vGainDiff3);
15798 TGraph* gGainVsMeanDiff4=TGraphVect(vMeanDiff4,vGainDiff4);
15799
15800 cGainVsMeanDiff->cd();
15801 s="Correlation Between Gain Difference and ADC Difference (FD)";
15802 gGainVsMeanDiff->Draw("AP");
15803 gGainVsMeanDiff->SetTitle(s.c_str());
15804 gGainVsMeanDiff->GetXaxis()->SetTitle("ADC Difference (Near strip end - far end)");
15805 gGainVsMeanDiff->GetYaxis()->SetTitle("% Gain Difference (Near strip end - far end)");
15806 gGainVsMeanDiff->GetXaxis()->CenterTitle();
15807 gGainVsMeanDiff->GetYaxis()->CenterTitle();
15808 gGainVsMeanDiff->SetMarkerStyle(3);
15809 gGainVsMeanDiff->SetMarkerColor(1);
15810 gGainVsMeanDiff->SetMarkerSize(0.55);
15811 gGainVsMeanDiff->SetLineColor(46);
15812
15813
15814 gGainVsMeanDiff2->Draw("P");
15815 gGainVsMeanDiff2->SetTitle(s.c_str());
15816 gGainVsMeanDiff2->SetMarkerStyle(3);
15817 gGainVsMeanDiff2->SetMarkerColor(3);
15818 gGainVsMeanDiff2->SetMarkerSize(0.65);
15819
15820 gGainVsMeanDiff3->Draw("P");
15821 gGainVsMeanDiff3->SetTitle(s.c_str());
15822 gGainVsMeanDiff3->SetMarkerStyle(3);
15823 gGainVsMeanDiff3->SetMarkerColor(2);
15824 gGainVsMeanDiff3->SetMarkerSize(0.75);
15825
15826 gGainVsMeanDiff4->Draw("P");
15827 gGainVsMeanDiff4->SetTitle(s.c_str());
15828 gGainVsMeanDiff4->SetMarkerStyle(3);
15829 gGainVsMeanDiff4->SetMarkerColor(7);
15830 gGainVsMeanDiff4->SetMarkerSize(0.95);
15831
15832
15833 TLegend *lAdc = new TLegend(0.7,0.7,0.8,0.8);
15834 lAdc->SetBorderSize(0);
15835 lAdc->SetFillColor(0);
15836 lAdc->SetTextSize(0.035);
15837
15838
15839 lAdc->AddEntry(gGainVsMeanDiff,"Near end ADC<4000","p");
15840 lAdc->AddEntry(gGainVsMeanDiff2,"Near end ADC<6000","p");
15841 lAdc->AddEntry(gGainVsMeanDiff3,"Near end ADC<7000","p");
15842 lAdc->AddEntry(gGainVsMeanDiff4,"Near end ADC>7000","p");
15843 lAdc->Draw();
15844
15845 TCanvas *cGainVsMeanDiffN=new TCanvas
15846 ("cGainVsMeanDiffN","cGainVsMeanDiffN",0,0,1000,800);
15847 cGainVsMeanDiffN->SetFillColor(0);
15848
15849
15850 TGraph* gGainVsMeanDiffN=TGraphVect(vMeanDiffN,vGainDiffN);
15851 TGraph* gGainVsMeanDiffN2=TGraphVect(vMeanDiffN2,vGainDiffN2);
15852 TGraph* gGainVsMeanDiffN3=TGraphVect(vMeanDiffN3,vGainDiffN3);
15853 TGraph* gGainVsMeanDiffN4=TGraphVect(vMeanDiffN4,vGainDiffN4);
15854
15855 cGainVsMeanDiffN->cd();
15856 s="Correlation Between Gain Difference and ADC Difference (ND)";
15857 gGainVsMeanDiffN->Draw("AP");
15858 gGainVsMeanDiffN->SetTitle(s.c_str());
15859 gGainVsMeanDiffN->GetXaxis()->SetTitle("ADC Difference (Near strip end - far end)");
15860 gGainVsMeanDiffN->GetYaxis()->SetTitle("% Gain Difference (Near strip end - far end)");
15861 gGainVsMeanDiffN->GetXaxis()->CenterTitle();
15862 gGainVsMeanDiffN->GetYaxis()->CenterTitle();
15863 gGainVsMeanDiffN->SetMarkerStyle(3);
15864 gGainVsMeanDiffN->SetMarkerColor(1);
15865 gGainVsMeanDiffN->SetMarkerSize(0.55);
15866 gGainVsMeanDiffN->SetLineColor(46);
15867
15868
15869 gGainVsMeanDiffN2->Draw("P");
15870 gGainVsMeanDiffN2->SetTitle(s.c_str());
15871 gGainVsMeanDiffN2->SetMarkerStyle(3);
15872 gGainVsMeanDiffN2->SetMarkerColor(3);
15873 gGainVsMeanDiffN2->SetMarkerSize(0.65);
15874
15875 gGainVsMeanDiffN3->Draw("P");
15876 gGainVsMeanDiffN3->SetTitle(s.c_str());
15877 gGainVsMeanDiffN3->SetMarkerStyle(3);
15878 gGainVsMeanDiffN3->SetMarkerColor(2);
15879 gGainVsMeanDiffN3->SetMarkerSize(0.75);
15880
15881 gGainVsMeanDiffN4->Draw("P");
15882 gGainVsMeanDiffN4->SetTitle(s.c_str());
15883 gGainVsMeanDiffN4->SetMarkerStyle(3);
15884 gGainVsMeanDiffN4->SetMarkerColor(7);
15885 gGainVsMeanDiffN4->SetMarkerSize(0.95);
15886
15887
15888 lAdc->Draw();
15889
15890 MSG("LIAnalysis",Msg::kInfo)
15891 <<endl<<" ** Finished the WriteOldGainsTextFile method ** "<<endl;
15892 }
15893
15894
15895
15896 void LIAnalysis::NoisyChips(Float_t criterion)
15897 {
15898
15899 MSG("LIAnalysis",Msg::kInfo)
15900 <<endl<<" ** Running the NoisyChips!!!! method... ** "<<endl;
15901
15905
15906 Int_t nmax = 7000;
15907
15908 Int_t fcrate[7000], fvarc[7000], fvmm[7000], fvfb[7000];
15909 Int_t fchip[7000];
15910
15911 Bool_t crateNumber[16];
15912
15913 for(Int_t i=0;i<nmax;i++){
15914 fcrate[i] = -1;
15915 fvarc[i] = -1;
15916 fvmm[i] = -1;
15917 fvfb[i] = -1;
15918 fchip[i] = -1;
15919 }
15920
15921 for(Int_t i=0;i<16;i++){
15922 crateNumber[i] = false;
15923 }
15924
15925 this->InitialiseLoopVariables();
15926
15927 int num_noisy_sums = 0;
15928
15929 for(Int_t entry=0;entry<numEvents;entry++){
15930
15931 this->SetLoopVariables(entry,0);
15932
15933
15934 if (readoutType!=ReadoutType::kScintStrip) continue;
15935
15936
15937 if (mean==0 || rms==0) continue;
15938
15939 if(crateNumber[crate]==false&&strip!=-1) crateNumber[crate] = true;
15940
15941
15942 if(float(numEntries)<criterion*float(pulses)/100.
15943 && mean>600 && strip!=-1 && num_noisy_sums<nmax){
15944 fcrate[num_noisy_sums] = crate;
15945 fvarc[num_noisy_sums] = varc;
15946 fvmm[num_noisy_sums] = vmm;
15947 fvfb[num_noisy_sums] = vfb;
15948 fchip[num_noisy_sums] = chip;
15949 num_noisy_sums++;
15950 }
15951
15952 if(num_noisy_sums>=nmax) {
15953 MSG("LIAnalysis",Msg::kWarning) << "In NoisyChips() function:"
15954 << " arrays are too small!!"
15955 << " More than " << nmax
15956 << " noisy summaries!" << endl;
15957 MSG("LIAnalysis",Msg::kWarning) << "Quitting now! Increase array "
15958 << "size in code and run again" << endl;
15959 exit(0);
15960 }
15961
15962 MSG("LIAnalysis",Msg::kVerbose)
15963 <<"led="<<led
15964 <<", pulser box="<<pulserBox
15965 <<", channel="<<channel
15966 <<", mean="<<mean
15967 <<endl;
15968
15969
15970 }
15971
15972 if(num_noisy_sums>0) {
15973
15974 MSG("LIAnalysis",Msg::kInfo) << "Number of suspect summarys found = "
15975 << num_noisy_sums << endl;
15976
15977
15978 string sRunNumber=Form("%d",runNumber);
15979
15980
15981 Char_t txtRep[80];
15982 sprintf(txtRep,"noise_from_LI_%d.dat",runNumber);
15983 ofstream report;
15984 report.open (txtRep,ofstream::out);
15985
15986 report << "Noisy Chip Report - Run " << runNumber << endl;
15987 report << "------------------------------" << endl;
15988 report << endl;
15989 for (Int_t i=0;i<16;i++){
15990 if(crateNumber[i] == false){
15991 report<<"No Light Injection for crate = "<<i<<endl;
15992 }
15993 }
15994 report << endl;
15995 report << "CRATE\tVARC\tVMM\tVFB\tCHIP\t% Live" << endl;
15996 report << "-----\t----\t---\t---\t----\t------" << endl;
15997
15998 Int_t num_bad_chips = 0;
15999
16000 MSG("LIAnalysis",Msg::kInfo) << "Checking bad summaries:" << endl;
16001
16002
16003 TH1F *h1 = new TH1F("h1","Fraction of Entries",1000,0,1);
16004
16005 for(Int_t entry=0;entry<numEvents;entry++){
16006
16007 this->SetLoopVariables(entry,0,false);
16008
16009
16010 if (crate==fcrate[0] && varc==fvarc[0] && vmm==fvmm[0]
16011 && vfb==fvfb[0] && chip==fchip[0] && strip !=-1)
16012
16013 h1->Fill(float(numEntries)/float(pulses));
16014
16015 }
16016
16017 num_bad_chips+=1;
16018
16019 MSG("LIAnalysis",Msg::kInfo) << num_bad_chips << " bad chips ("
16020 << "1 bad summary processed)"<< endl;
16021
16022
16023 Float_t Exp_Num_Sum = 16.*8.*2.;
16024
16025
16026 Stat_t n = h1->GetEntries();
16027
16028
16029 Float_t percentage = (n/Exp_Num_Sum)*h1->GetMean()*100.;
16030
16031 delete h1;
16032
16033 report << fcrate[0] << "\t" << fvarc[0] << "\t"
16034 << fvmm[0] << "\t" << fvfb[0] << "\t" << fchip[0]
16035 << "\t(" << percentage << "%)" <<endl;
16036
16037 MSG("LIAnalysis",Msg::kVerbose) << "Noisy chip " << fcrate[0]
16038 << " " << fvarc[0] << " " << fvmm[0]
16039 << " " << fvfb[0] << " " << fchip[0]
16040 << " percentage = " << percentage
16041 << " %" << endl;
16042
16043
16044 for(Int_t j = 1; j<num_noisy_sums;j++){
16045 Int_t counter = 1;
16046
16047
16048 for (Int_t k=0; k<j;k++){
16049 if(fcrate[j]==fcrate[k] && fvarc[j]==fvarc[k] && fvmm[j]==fvmm[k]
16050 && fvfb[j]==fvfb[k] && fchip[j]==fchip[k])
16051 counter = 0;
16052 }
16053
16054
16055
16056 if(counter==1 && fcrate[j]!=-1 && fvarc[j]!=-1
16057 && fvmm[j]!=-1 && fvfb[j]!=-1 && fchip[j]!=-1){
16058
16059 num_bad_chips+=1;
16060
16061 TH1F *h1 = new TH1F("h1","Fraction of Entries",1000,0,1);
16062
16063 for(Int_t entry=0;entry<numEvents;entry++){
16064
16065 this->SetLoopVariables(entry,0,false);
16066
16067 if(crate==fcrate[j] && varc==fvarc[j] && vmm==fvmm[j]
16068 && vfb==fvfb[j] && chip==fchip[j] && strip !=-1)
16069 h1->Fill(float(numEntries)/float(pulses));
16070
16071
16072 }
16073
16074 MSG("LIAnalysis",Msg::kInfo) << num_bad_chips << " bad chips ("
16075 << j+1 << " bad summaries processed)"
16076 << endl;
16077
16078 n = h1->GetEntries();
16079 percentage = (n/Exp_Num_Sum)*h1->GetMean()*100.;
16080 delete h1;
16081
16082 report << fcrate[j] << "\t" << fvarc[j] << "\t" << fvmm[j] << "\t"
16083 << fvfb[j] << "\t" << fchip[j] << "\t("<<percentage<<"%)"
16084 << endl;
16085
16086 MSG("LIAnalysis",Msg::kVerbose) << "Noisy chip " << fcrate[j]
16087 << " " << fvarc[j] << " " << fvmm[j]
16088 << " " << fvfb[j] << " " << fchip[j]
16089 << " percentage = " << percentage
16090 << " %" << endl;
16091
16092 }
16093
16094 }
16095
16096 MSG("LIAnalysis",Msg::kInfo) << "Finished processing all bad summaries: "
16097 << num_bad_chips << " bad chips found."
16098 << endl;
16099 MSG("LIAnalysis",Msg::kInfo) << "See file: " << txtRep
16100 << " for details." << endl;
16101
16102 report << endl;
16103 report << "** End of report **" << endl;
16104
16105 report.close();
16106 }
16107 else MSG("LIAnalysis",Msg::kInfo) << "No bad summaries found" << endl;
16108
16109 MSG("LIAnalysis",Msg::kInfo)
16110 <<endl<<" ** Finished the NoisyChips!!!!! method ** "<<endl;
16111
16112 }
16113
16114
16115
16116
16117 void LIAnalysis::Template()
16118 {
16119 MSG("LIAnalysis",Msg::kInfo)
16120 <<endl<<" ** Running the TEMPLATE!!!! method... ** "<<endl;
16121
16123
16125
16126 TH1F *hChannel=new TH1F("hChannel","VA Channels hit",40,-5,35);
16127 hChannel->GetXaxis()->SetTitle("VA Channel");
16128 hChannel->GetXaxis()->CenterTitle();
16129 hChannel->GetYaxis()->SetTitle("Number of times hit");
16130 hChannel->GetYaxis()->CenterTitle();
16131 hChannel->SetFillColor(0);
16132 hChannel->SetBit(TH1::kCanRebin);
16133
16137
16138 this->InitialiseLoopVariables();
16139
16140 for(Int_t entry=0;entry<numEvents;entry++){
16141
16142 this->SetLoopVariables(entry,0);
16143
16144
16145 if (readoutType!=ReadoutType::kScintStrip) continue;
16146
16147
16148 if (mean==0 || rms==0 || numEntries==0) continue;
16149
16151
16153
16154 MSG("LIAnalysis",Msg::kVerbose)
16155 <<"led="<<led
16156 <<", pulser box="<<pulserBox
16157 <<", channel="<<channel
16158 <<", mean="<<mean
16159 <<endl;
16160
16161 if (pulserBox>=FIRSTPULSERBOX && pulserBox<=LASTPULSERBOX){
16162 hChannel->Fill(channel);
16163 }
16164
16165 }
16166
16170
16171 MSG("LIAnalysis",Msg::kInfo)<<"Finished main loop"<<endl;
16172
16173
16174 gStyle->SetOptStat(1111111);
16175
16176 string sRunNumber=Form("%d",runNumber);
16177
16179
16181
16182 TCanvas *cMean=new TCanvas("cMean","Mean adc",0,0,1200,800);
16183 cMean->SetFillColor(0);
16184 cMean->cd();
16185 hChannel->Draw();
16186
16187 MSG("LIAnalysis",Msg::kInfo)
16188 <<endl<<" ** Finished the TEMPLATE!!!!! method ** "<<endl;
16189 }
16190
16191
16192
16193 void LIAnalysis::Test()
16194 {
16195 MSG("LIAnalysis",Msg::kInfo)
16196 <<endl<<" ** Running the Test method... ** "<<endl;
16197
16198 Int_t height=2000;
16199 Int_t numPoints=10;
16200
16201 TGraph* g=new TGraph(numPoints);
16202 TGraph* g2=new TGraph(numPoints);
16203 TGraph* g3=new TGraph(numPoints);
16204
16205
16206 g2->SetMinimum(0);
16207 g2->SetMaximum(5000);
16208 g3->SetMinimum(0);
16209 g3->SetMaximum(5000);
16210
16211 for (Int_t i=0;i<numPoints;i++){
16212 height+=100;
16213 g->SetPoint(i,i,height);
16214 g2->SetPoint(i,i,height);
16215 g3->SetPoint(i,i,height);
16216 }
16217
16218
16219 g->SetMinimum(0);
16220 g->SetMaximum(5000);
16221
16222 TCanvas *c=new TCanvas("c","c",0,0,1200,800);
16223 c->SetFillColor(0);
16224 c->Divide(3,1);
16225
16226
16227 c->cd(1);
16228 g->Draw("AP");
16229 g->SetTitle("Plot Ok - Min/max set after SetPoint()");
16230 g->SetMarkerStyle(3);
16231 g->SetMarkerColor(2);
16232 g->SetMarkerSize(0.4);
16233
16234 g->GetXaxis()->SetTitle("x Value");
16235 g->GetYaxis()->SetTitle("Height");
16236 g->GetXaxis()->CenterTitle();
16237 g->GetYaxis()->CenterTitle();
16238
16239
16240 c->cd(2);
16241 g2->Draw("AP");
16242 g2->SetTitle("Plot Ok - Min/max set before SetPoint() (no axis modification)");
16243 g2->SetMarkerStyle(3);
16244 g2->SetMarkerColor(2);
16245 g2->SetMarkerSize(0.4);
16246
16247
16248 c->cd(3);
16249 g3->Draw("AP");
16250 g3->SetTitle("Plot NOT Ok - Min/max set before SetPoint() and axis modification");
16251 g3->SetMarkerStyle(3);
16252 g3->SetMarkerColor(2);
16253 g3->SetMarkerSize(0.4);
16254
16255 g3->GetXaxis()->SetTitle("x Value");
16256 g3->GetYaxis()->SetTitle("Height");
16257 g3->GetXaxis()->CenterTitle();
16258 g3->GetYaxis()->CenterTitle();
16259
16260 MSG("LIAnalysis",Msg::kInfo)
16261 <<endl<<" ** Finished the Test method ** "<<endl;
16262 }
16263
16264
16265