00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00014
00015 #include <iostream>
00016 #include <vector>
00017 #include <fstream>
00018 #include <cmath>
00019
00020 #include "TCanvas.h"
00021 #include "TDatime.h"
00022 #include "TError.h"
00023 #include "TF1.h"
00024 #include "TH2.h"
00025 #include "TObject.h"
00026 #include "TPad.h"
00027 #include "TPaveText.h"
00028 #include "TProfile2D.h"
00029 #include "TStyle.h"
00030 #include "TText.h"
00031 #include "TRandom.h"
00032 #include "TStopwatch.h"
00033
00034 #include "Calibrator/CalADCtoPE.h"
00035 #include "Calibrator/CalADCtoPEs.h"
00036 #include "Calibrator/CalMIPCalibration.h"
00037 #include "Calibrator/CalStripToStrip.h"
00038 #include "Calibrator/CalStripAtten.h"
00039 #include "Conventions/Detector.h"
00040 #include "Conventions/StripEnd.h"
00041 #include "DatabaseInterface/DbiResultPtr.h"
00042 #include "DatabaseInterface/DbiValidityRec.h"
00043 #include "DatabaseInterface/DbiWriter.h"
00044 #include "MessageService/MsgService.h"
00045 #include "Plex/PlexRawChannelToPinDiode.h"
00046 #include "PulserCalibration/PulserRawDrift.h"
00047 #include "PulserCalibration/PulserRawDriftF.h"
00048 #include "PulserCalibration/PulserRefDrift.h"
00049 #include "PulserCalibration/PulserRefDriftF.h"
00050 #include "PulserCalibration/PulserRawDriftPin.h"
00051 #include "PulserCalibration/PulserRefDriftPin.h"
00052 #include "PulserCalibration/PulserRawGain.h"
00053 #include "RawData/RawChannelId.h"
00054 #include "Validity/VldContext.h"
00055 #include "Validity/VldTimeStamp.h"
00056
00057 #include "LISummary/LIPlexMaps.h"
00058 #include "LISummary/LIPmt.h"
00059 #include "LISummary/LIRun.h"
00060
00061 CVSID("$Id: LIPlexMaps.cxx,v 1.61 2007/11/11 08:00:53 rhatcher Exp $");
00062
00063 ClassImp(LIPlexMaps)
00064
00065
00066
00067 class LedIdList : public std::vector<PlexLedId>
00068 {
00069
00070 public:
00071
00072 LedIdList(const VldContext& context) { Reset(context);};
00073 LedIdList() {
00074 VldTimeStamp ts;
00075 VldContext cx(Detector::kCalDet,SimFlag::kData,ts);
00076 Reset(cx);
00077 };
00078
00079 void Reset(const VldContext& context) {
00080 Int_t numRows=fResPtr.NewQuery(context,0);
00081 MSG("LIPlexMaps",Msg::kInfo)
00082 <<"New DB query produced "<<numRows<<" rows"<<endl;
00083 std::map<PlexLedId,int> tmpMap;
00084
00085 for (UInt_t i=0;i<fResPtr.GetNumRows();i++) {
00086 const PlexPinDiodeToLed* datum = fResPtr.GetRow(i);
00087 if(datum){
00088 tmpMap[datum->GetPlexLedId()] += 1;
00089 }
00090 }
00091
00092 this->clear();
00093 for (std::map<PlexLedId,int>::iterator it=tmpMap.begin();
00094 it!=tmpMap.end(); it++) {
00095 this->push_back(it->first);
00096 }
00097 };
00098
00099 private:
00100
00101 DbiResultPtr<PlexPinDiodeToLed> fResPtr;
00102
00103 };
00104
00105
00106
00107 LIPlexMaps::LIPlexMaps()
00108 {
00109 MSG("LIPlexMaps",Msg::kDebug)<<"LIPlexMaps Constructor"<<endl;
00110
00111
00112 gStyle->SetPalette(1,(Int_t*)0);
00113
00114 }
00115
00116
00117
00118 LIPlexMaps::~LIPlexMaps()
00119 {
00120 MSG("LIPlexMaps",Msg::kDebug)<<"LIPlexMaps Destructor"<<endl;
00121 }
00122
00123
00124
00125 Bool_t LIPlexMaps::IsPermitted() const
00126 {
00127 MSG("LIPlexMaps",Msg::kDebug)
00128 <<" ** Running IsPermitted method... **"<<endl;
00129
00130 char* envVariable=getenv("LITSQLPERMISSION");
00131 if (envVariable==NULL){
00132 MSG("LIAnalysis",Msg::kWarning)
00133 <<endl<<endl
00134 <<"*************************************************************"
00135 <<endl
00136 <<"WARNING: You have tried to do a sensitive operation."<<endl
00137 <<"This feature is designed to make you stop and think."<<endl
00138 <<"If you know what you are doing then look at the code."<<endl
00139 <<"*************************************************************"
00140 <<endl<<endl;
00141 return false;
00142 }
00143
00144 MSG("LIPlexMaps",Msg::kDebug)
00145 <<" ** Finished IsPermitted method **"<<endl;
00146 return true;
00147 }
00148
00149
00150
00151 void LIPlexMaps::ScaleVector(vector<Double_t>& v,Double_t scaleFactor)
00152 {
00153 MSG("LIPlexMaps",Msg::kDebug)
00154 <<" ** Running ScaleVector method... **"<<endl;
00155
00156 for (UInt_t i=0;i<v.size();i++) v[i]*=scaleFactor;
00157
00158 MSG("LIPlexMaps",Msg::kDebug)
00159 <<" ** Finished ScaleVector method **"<<endl;
00160 }
00161
00162
00163
00164 void LIPlexMaps::NormaliseVector(vector<Double_t>& v,Int_t mode)
00165 {
00166 MSG("LIPlexMaps",Msg::kDebug)
00167 <<" ** Running NormaliseVector method... **"<<endl;
00168
00169 if (v.size()>0){
00170
00171 if (mode==1){
00172
00173 Double_t average=0;
00174 for (UInt_t i=0;i<v.size();i++) average+=v[i];
00175 average/=v.size();
00176
00177 MSG("LIPlexMaps",Msg::kVerbose)<<"Average="<<average<<endl;
00178
00179
00180 for (UInt_t i=0;i<v.size();i++) v[i]/=average;
00181 }
00182 else if (mode==2){
00183
00184 Double_t vMax=-9e50;
00185 Double_t vMin=9e50;
00186
00187
00188 for (UInt_t i=0;i<v.size();i++){
00189 if (v[i]>vMax) vMax=v[i];
00190 if (v[i]<vMin) vMin=v[i];
00191 }
00192
00193
00194 Int_t numBins=300;
00195 if (4*v.size()<10000) numBins=4*v.size();
00196
00197 MSG("LIAnalysis",Msg::kInfo)
00198 <<"vMax="<<vMax <<", vMin="<<vMin<<", numBins="<<numBins<<endl;
00199
00200
00201
00202 TH1F* h=new TH1F("h","h",numBins,vMin-fabs(0.1*vMin),
00203 vMax+fabs(0.1*vMin));
00204 h->SetBit(TH1::kCanRebin);
00205
00206 Double_t average=0;
00207 for (UInt_t i=0;i<v.size();i++){
00208
00209 average+=v[i];
00210
00211
00212 h->Fill(v[i]);
00213 }
00214 average/=v.size();
00215
00216
00217 h->Fit("gaus","q0");
00218 TF1* func=h->GetFunction("gaus");
00219 Double_t p1=func->GetParameter(1);
00220 Double_t p2=func->GetParameter(2);
00221
00222
00223 Double_t avToNormWith=p1;
00224 if (p1<vMin || p1>vMax) avToNormWith=average;
00225
00226 MSG("LIAnalysis",Msg::kInfo)
00227 <<"Fitted mean="<<p1
00228 <<" (average="<<average
00229 <<") fitted rms="<<p2
00230 <<", using avToNormWith="<<avToNormWith<<endl;
00231
00232
00233 for (UInt_t i=0;i<v.size();i++) v[i]/=avToNormWith;
00234
00235 delete h;
00236 }
00237 }
00238
00239 MSG("LIPlexMaps",Msg::kDebug)
00240 <<" ** Finished NormaliseVector method **"<<endl;
00241 }
00242
00243
00244
00245 void LIPlexMaps::BinomialGen(vector<Double_t>& v,Int_t N,Double_t p)
00246 {
00247 MSG("LIPlexMaps",Msg::kDebug)
00248 <<" ** Running BinomialGen method... **"<<endl;
00249
00250
00251
00252
00253
00254
00255
00256
00257
00258
00259 Double_t totalProb=0;
00260
00261 if (N<=170){
00262 vector<Double_t> factorials(N+1);
00263 this->FactorialGen(factorials);
00264
00265 for (UInt_t r=0;r<v.size();r++){
00266 Double_t perm=factorials[N]/(factorials[r]*factorials[N-r]);
00267 Double_t successes=pow(p,(Int_t)(r));
00268 Double_t failures=pow(1-p,(Int_t)(N-r));
00269 v[r]=perm*successes*failures;
00270 totalProb+=v[r];
00271 MSG("LIPlexMaps",Msg::kInfo)
00272 <<"Prob of "<<r<<" events = "<<v[r]
00273 <<" (perm="<<perm
00274 <<", succ="<<successes
00275 <<", fail="<<failures<<")"
00276 <<endl;
00277
00278 MSG("LIPlexMaps",Msg::kInfo)<<"Total prob = "<<totalProb<<endl;
00279 }
00280 }
00281 else if (N>170){
00282
00283
00284
00285 MSG("LIPlexMaps",Msg::kInfo)
00286 <<"Above N=170 this has not been implemented"<<endl;
00287 }
00288
00289 MSG("LIPlexMaps",Msg::kDebug)
00290 <<" ** Finished BinomialGen method **"<<endl;
00291 }
00292
00293
00294
00295 void LIPlexMaps::FactorialGen(vector<Double_t>& v)
00296 {
00297 MSG("LIPlexMaps",Msg::kDebug)
00298 <<" ** Running FactorialGen method... **"<<endl;
00299
00300
00301
00302
00303
00304
00305
00306
00307
00308 if (v.size()>=2){
00309 v[0]=1;
00310 v[1]=1;
00311 }
00312
00313 for (UInt_t i=2;i<v.size();i++){
00314 v[i]=v[i-1]*i;
00315 MSG("LIPlexMaps",Msg::kInfo)<<i<<" factorial = "<<v[i]<<endl;
00316 }
00317
00318 MSG("LIPlexMaps",Msg::kDebug)
00319 <<" ** Finished FactorialGen method **"<<endl;
00320 }
00321
00322
00323
00324 Int_t LIPlexMaps::SampleDist(vector<Double_t> v,TRandom* tRand)
00325 {
00326 MSG("LIPlexMaps",Msg::kVerbose)
00327 <<" ** Running SampleDist method... **"<<endl;
00328
00329
00330
00331 Int_t size=v.size();
00332 Int_t p=-1;
00333
00334 Int_t foundPoint=0;
00335 while (foundPoint==0){
00336
00337 p=tRand->Integer(size);
00338 Double_t probToChose=v[p];
00339 Double_t r1=tRand->Rndm();
00340
00341 MSG("LIPlexMaps",Msg::kVerbose)
00342 <<"point="<<p<<", probToChose="<<probToChose<<", r1="<<r1<<endl;
00343
00344 if (probToChose>=r1) foundPoint=1;
00345 }
00346
00347 MSG("LIPlexMaps",Msg::kVerbose)
00348 <<" ** Finished SampleDist method **"<<endl;
00349 return p;
00350 }
00351
00352
00353
00354 void LIPlexMaps::Attenuation()
00355 {
00356 MSG("LIPlexMaps",Msg::kInfo)
00357 <<" ** Running Attenuation method... **"<<endl;
00358
00359 vector<Double_t> x;
00360 vector<Double_t> xNorm;
00361 vector<Double_t> yGreenAtt1;
00362 vector<Double_t> yGreenAtt2;
00363 vector<Double_t> yGreen;
00364 vector<Double_t> yClear;
00365 vector<Double_t> y12C;
00366 vector<Double_t> y6G;
00367 vector<Double_t> y2G;
00368 vector<Double_t> y1G_12C_1G_1;
00369 vector<Double_t> y1G_12C_1G_2;
00370 vector<Double_t> y1G_12C_1G_3;
00371 vector<Double_t> x1G_12C_1G_1;
00372 vector<Double_t> x1G_12C_1G_2;
00373 vector<Double_t> x1G_12C_1G_3;
00374 vector<Double_t> y8G;
00375 vector<Double_t> y3GNear;
00376 vector<Double_t> y6CNear;
00377 vector<Double_t> y3GFar;
00378 vector<Double_t> y6CFar;
00379
00380 vector<Double_t> boost12C;
00381 vector<Double_t> boost6G;
00382 vector<Double_t> boost8G;
00383 vector<Double_t> boost1G_12C_1G;
00384 vector<Double_t> reflectivity;
00385
00386 Double_t maxCableLength=20;
00387 Int_t numPoints=1000;
00388
00389
00390 Double_t greenAtt1=1;
00391 Double_t greenAtt2=10;
00392 Double_t clearAtt=12;
00393
00394
00395
00396
00397
00398
00399 Double_t ref=1.0;
00400
00401 Double_t ref12C=exp(-12./clearAtt);
00402 Double_t ref6G=0.5*(exp(-6./greenAtt1)+exp(-6./greenAtt2));
00403 Double_t ref2G=0.5*(exp(-2./greenAtt1)+exp(-2./greenAtt2));
00404 Double_t ref8G=0.5*(exp(-8./greenAtt1)+exp(-8./greenAtt2));
00405 Double_t ref1G_12C_1G=ref2G*ref12C;
00406
00407 MSG("LIPlexMaps",Msg::kInfo)
00408 <<"Reflectivity = "<<ref
00409 <<endl
00410 <<"6m green = "<<ref6G<<" (0.22)"
00411 <<endl
00412 <<"12m clear = "<<ref12C<<" (0.20)"
00413 <<endl
00414 <<"8m green = "<<ref8G<<" (0.06)"
00415 <<endl
00416 <<"1mG & 12mC & 1mG = "<<ref1G_12C_1G<<" (0.09)"
00417 <<endl;
00418
00419 MSG("LIPlexMaps",Msg::kInfo)
00420 <<"Calculating boosts..."<<endl;
00421 for (Int_t i=0;i<numPoints;i++){
00422 reflectivity.push_back(0);
00423 boost12C.push_back(0);
00424 boost6G.push_back(0);
00425 boost1G_12C_1G.push_back(0);
00426 boost8G.push_back(0);
00427
00428 Double_t connectorEff=1.0;
00429
00430 reflectivity[i]=i*1./numPoints;
00431 boost12C[i]=connectorEff*reflectivity[i]*ref12C;
00432 boost1G_12C_1G[i]=connectorEff*reflectivity[i]*ref12C*ref2G;
00433
00434 boost6G[i]=reflectivity[i]*ref6G;
00435 boost8G[i]=reflectivity[i]*ref8G;
00436 }
00437
00438 MSG("LIPlexMaps",Msg::kInfo)
00439 <<"Calculating basic attenuation curves..."<<endl;
00440 for (Int_t i=0;i<numPoints;i++){
00441 x.push_back(0);
00442 yGreenAtt1.push_back(0);
00443 yGreenAtt2.push_back(0);
00444 yGreen.push_back(0);
00445 yClear.push_back(0);
00446
00447 x[i]=i*maxCableLength/numPoints;
00448 yGreenAtt1[i]=exp(-x[i]/greenAtt1);
00449 yGreenAtt2[i]=exp(-x[i]/greenAtt2);
00450 yGreen[i]=0.5*(exp(-x[i]/greenAtt1)+exp(-x[i]/greenAtt2));
00451 yClear[i]=exp(-x[i]/clearAtt);
00452 }
00453
00454 MSG("LIPlexMaps",Msg::kInfo)
00455 <<"Calculating for 1st 1 m of green..."<<endl;
00456 for (Int_t i=0;i<numPoints;i++){
00457 Double_t x=i*1./numPoints;
00458 xNorm.push_back(0);
00459 y12C.push_back(0);
00460 y6G.push_back(0);
00461 y2G.push_back(0);
00462 y8G.push_back(0);
00463
00464
00465 xNorm[i]=i*1./numPoints;
00466
00467 y12C[i]=exp(-12*xNorm[i]/clearAtt);
00468 y6G[i]=0.5*(exp(-6*xNorm[i]/greenAtt1)+exp(-6*xNorm[i]/greenAtt2));
00469 y2G[i]=0.5*(exp(-2*xNorm[i]/greenAtt1)+exp(-2*xNorm[i]/greenAtt2));
00470
00471 if (x<1./14){
00472 Double_t x2=i*1./((1./14)*numPoints);
00473 y1G_12C_1G_1.push_back(0);
00474 x1G_12C_1G_1.push_back(0);
00475 x1G_12C_1G_1[i]=x;
00476 y1G_12C_1G_1[i]=0.5*(exp(-1*x2/greenAtt1)+exp(-1*x2/greenAtt2));
00477 MSG("LIPlexMaps",Msg::kDebug)
00478 <<"x="<<x<<", x2="<<x2
00479 <<", x1G_12C_1G_1[i]="<<x1G_12C_1G_1[i]
00480 <<", y1G_12C_1G_1[i]="<<y1G_12C_1G_1[i]
00481 <<endl;
00482 }
00483 y8G[i]=0.5*(exp(-8*xNorm[i]/greenAtt1)+exp(-8*xNorm[i]/greenAtt2));
00484 }
00485
00486 UInt_t size_1=y1G_12C_1G_1.size();
00487 Int_t counter=0;
00488
00489 MSG("LIPlexMaps",Msg::kInfo)
00490 <<"Calculating for 12 m of clear..."<<endl;
00491 for (Int_t i=0;i<numPoints;i++){
00492 Double_t x=i*1./numPoints;
00493
00494 if (x>1./14 && x<13./14){
00495 Double_t x2=counter*1./((12./14)*numPoints);
00496 y1G_12C_1G_2.push_back(0);
00497 x1G_12C_1G_2.push_back(0);
00498 x1G_12C_1G_2[counter]=x;
00499 y1G_12C_1G_2[counter]=y1G_12C_1G_1[size_1-1]*exp(-12*x2/clearAtt);
00500 MSG("LIPlexMaps",Msg::kDebug)
00501 <<"x="<<x<<", x2="<<x2
00502 <<", x1G_12C_1G_2[i]="<<x1G_12C_1G_2[counter]
00503 <<", y1G_12C_1G_2[i]="<<y1G_12C_1G_2[counter]
00504 <<endl;
00505 counter++;
00506 }
00507 }
00508
00509 UInt_t size_2=y1G_12C_1G_2.size();
00510 counter=0;
00511
00512 MSG("LIPlexMaps",Msg::kInfo)
00513 <<"Calculating for last 1 m of green..."<<endl;
00514 for (Int_t i=0;i<numPoints;i++){
00515 Double_t x=i*1./numPoints;
00516
00517 if (x>13./14){
00518 Double_t x2=counter*1./((1./14)*numPoints);
00519 y1G_12C_1G_3.push_back(0);
00520 x1G_12C_1G_3.push_back(0);
00521 x1G_12C_1G_3[counter]=x;
00522
00523
00524 Double_t scaleFactor=1./y1G_12C_1G_1[size_1-1];
00525 y1G_12C_1G_3[counter]=scaleFactor*y1G_12C_1G_2[size_2-1]*0.5*
00526 (exp(-1*(x2+1)/greenAtt1)+
00527 exp(-1*(x2+1)/greenAtt2));
00528 MSG("LIPlexMaps",Msg::kDebug)
00529 <<"x="<<x<<", x2="<<x2
00530 <<", x1G_12C_1G_3[i]="<<x1G_12C_1G_3[counter]
00531 <<", y1G_12C_1G_3[i]="<<y1G_12C_1G_3[counter]
00532 <<endl;
00533 counter++;
00534 }
00535 }
00536
00537 UInt_t size_3=y1G_12C_1G_3.size();
00538 UInt_t size_8G=y8G.size();
00539
00540 MSG("LIPlexMaps",Msg::kInfo)
00541 <<"Calculating for last section to PMT..."<<endl;
00542 MSG("LIPlexMaps",Msg::kInfo)
00543 <<"Near side..."<<endl;
00544 for (Int_t i=0;i<numPoints;i++){
00545 Double_t x=i*1./numPoints;
00546
00547 y3GNear.push_back(0);
00548 y6CNear.push_back(0);
00549
00550 y3GNear[i]=y1G_12C_1G_3[size_3-1]*0.5*
00551 (exp(-3.*x/greenAtt1)+exp(-3.*x/greenAtt2));
00552 y6CNear[i]=y8G[size_8G-1]*exp(-6.*x/clearAtt);
00553
00554 MSG("LIPlexMaps",Msg::kDebug)
00555 <<"x="<<x
00556 <<", y3GNear[i]="<<y3GNear[i]
00557 <<", y6CNear[i]"<<y6CNear[i]
00558 <<endl;
00559 }
00560
00561 UInt_t size_12C=y12C.size();
00562 UInt_t size_6G=y6G.size();
00563
00564 MSG("LIPlexMaps",Msg::kInfo)
00565 <<"Far side..."<<endl;
00566 for (Int_t i=0;i<numPoints;i++){
00567 Double_t x=i*1./numPoints;
00568
00569 y3GFar.push_back(0);
00570 y6CFar.push_back(0);
00571
00572 y3GFar[i]=y12C[size_12C-1]*0.5*
00573 (exp(-3.*x/greenAtt1)+exp(-3.*x/greenAtt2));
00574 y6CFar[i]=y6G[size_6G-1]*exp(-6.*x/clearAtt);
00575
00576 MSG("LIPlexMaps",Msg::kDebug)
00577 <<"x="<<x
00578 <<", y3GFar[i]="<<y3GFar[i]
00579 <<", y6CFar[i]"<<y6CFar[i]
00580 <<endl;
00581 }
00582
00583
00584 TCanvas *cAttenuation=new TCanvas("cAttenuation","cAttenuation",
00585 1,1,1000,800);
00586 cAttenuation->SetFillColor(0);
00587 cAttenuation->Divide(2,2);
00588
00589
00590 TGraph* gGreen=TGraphVect(x,yGreen);
00591 gGreen->SetTitle("Green Attenuation length (1+2)");
00592 gGreen->SetMarkerStyle(3);
00593 gGreen->SetMarkerColor(3);
00594 gGreen->SetMarkerSize(0.2);
00595 cAttenuation->cd(1);
00596 gGreen->Draw("AP");
00597 gGreen->GetXaxis()->SetTitle("Cable length");
00598 gGreen->GetYaxis()->SetTitle("Intensity");
00599 gGreen->GetXaxis()->CenterTitle();
00600 gGreen->GetYaxis()->CenterTitle();
00601 gGreen->SetMinimum(0);
00602
00603
00604 TGraph* gGreenAtt1=TGraphVect(x,yGreenAtt1);
00605 gGreenAtt1->SetTitle("Green Attenuation length 1");
00606 gGreenAtt1->SetMarkerStyle(3);
00607 gGreenAtt1->SetMarkerColor(30);
00608 gGreenAtt1->SetMarkerSize(0.2);
00609 cAttenuation->cd(2);
00610 gGreenAtt1->Draw("AP");
00611 gGreenAtt1->GetXaxis()->SetTitle("Cable length");
00612 gGreenAtt1->GetYaxis()->SetTitle("Intensity");
00613 gGreenAtt1->GetXaxis()->CenterTitle();
00614 gGreenAtt1->GetYaxis()->CenterTitle();
00615 gGreenAtt1->SetMinimum(0);
00616
00617
00618 TGraph* gGreenAtt2=TGraphVect(x,yGreenAtt2);
00619 gGreenAtt2->SetTitle("Green Attenuation length 2");
00620 gGreenAtt2->SetMarkerStyle(3);
00621 gGreenAtt2->SetMarkerColor(8);
00622 gGreenAtt2->SetMarkerSize(0.2);
00623 cAttenuation->cd(3);
00624 gGreenAtt2->Draw("AP");
00625 gGreenAtt2->GetXaxis()->SetTitle("Cable length");
00626 gGreenAtt2->GetYaxis()->SetTitle("Intensity");
00627 gGreenAtt2->GetXaxis()->CenterTitle();
00628 gGreenAtt2->GetYaxis()->CenterTitle();
00629 gGreenAtt2->SetMinimum(0);
00630
00631
00632 TGraph* gClear=TGraphVect(x,yClear);
00633 gClear->SetTitle("Clear Attenuation length");
00634 gClear->SetMarkerStyle(3);
00635 gClear->SetMarkerColor(1);
00636 gClear->SetMarkerSize(0.2);
00637 cAttenuation->cd(4);
00638 gClear->Draw("AP");
00639 gClear->GetXaxis()->SetTitle("Cable length");
00640 gClear->GetYaxis()->SetTitle("Intensity");
00641 gClear->GetXaxis()->CenterTitle();
00642 gClear->GetYaxis()->CenterTitle();
00643 gClear->SetMinimum(0);
00644
00646
00648 MSG("LIPlexMaps",Msg::kInfo)
00649 <<"Drawing cAttCalDet canvas..."<<endl;
00650 TCanvas *cAttCalDet=new TCanvas("cAttCalDet","cAttCalDet",
00651 1,1,1000,800);
00652 cAttCalDet->SetFillColor(0);
00653
00654
00655
00656 TGraph* g12C=TGraphVect(xNorm,y12C);
00657 g12C->SetTitle("Fractional Attenuation (LI Far Side)");
00658 g12C->SetMarkerStyle(3);
00659 g12C->SetMarkerColor(1);
00660 g12C->SetMarkerSize(0.2);
00661 cAttCalDet->cd(1);
00662 g12C->Draw("AP");
00663 g12C->GetXaxis()->SetTitle("Fraction of reflected distance (m)");
00664 g12C->GetYaxis()->SetTitle("Intensity");
00665 g12C->GetXaxis()->CenterTitle();
00666 g12C->GetYaxis()->CenterTitle();
00667 g12C->SetMinimum(0);
00668
00669
00670 TGraph* g6G=TGraphVect(xNorm,y6G);
00671 g6G->SetTitle("Fractional Attenuation");
00672 g6G->SetMarkerStyle(3);
00673 g6G->SetMarkerColor(3);
00674 g6G->SetMarkerSize(0.2);
00675 cAttCalDet->cd(1);
00676 g6G->Draw("P");
00677
00678
00679 TGraph* g12C_2=TGraphVect(xNorm,y12C);
00680 g12C_2->SetTitle("12 m Clear Attenuation");
00681 g12C_2->SetMarkerStyle(3);
00682 g12C_2->SetMarkerColor(1);
00683 g12C_2->SetMarkerSize(0.2);
00684
00685
00686 g12C_2->GetXaxis()->SetTitle("Fraction of reflected distance (m)");
00687 g12C_2->GetYaxis()->SetTitle("Intensity");
00688 g12C_2->GetXaxis()->CenterTitle();
00689 g12C_2->GetYaxis()->CenterTitle();
00690 g12C_2->SetMinimum(0);
00691
00692
00693 g6G->SetTitle("6 m Green Attenuation");
00694 g6G->SetMarkerStyle(3);
00695 g6G->SetMarkerColor(3);
00696 g6G->SetMarkerSize(0.2);
00697
00698
00699 g6G->GetXaxis()->SetTitle("Fraction of reflected distance (m)");
00700 g6G->GetYaxis()->SetTitle("Intensity");
00701 g6G->GetXaxis()->CenterTitle();
00702 g6G->GetYaxis()->CenterTitle();
00703 g6G->SetMinimum(0);
00704
00706
00708 MSG("LIPlexMaps",Msg::kInfo)
00709 <<"Drawing cAttCalDet2 canvas..."<<endl;
00710 TCanvas *cAttCalDet2=new TCanvas("cAttCalDet2","cAttCalDet2",
00711 1,1,1000,800);
00712 cAttCalDet2->SetFillColor(0);
00713 cAttCalDet2->Divide(1,1);
00714
00715
00716 TGraph* gDummy=TGraphVect(xNorm,xNorm);
00717 gDummy->SetTitle("Fractional Attenuation (LI Near Side)");
00718 gDummy->SetMinimum(0);
00719 gDummy->SetMaximum(1.2);
00720 gDummy->SetMarkerColor(0);
00721 cAttCalDet2->cd(1);
00722 gDummy->Draw("AP");
00723 gDummy->GetXaxis()->SetTitle("Fraction of reflected distance (m)");
00724 gDummy->GetYaxis()->SetTitle("Intensity");
00725 gDummy->GetXaxis()->CenterTitle();
00726 gDummy->GetYaxis()->CenterTitle();
00727
00728
00729 TGraph* g1G_12C_1G_1=TGraphVect(x1G_12C_1G_1,y1G_12C_1G_1);
00730 g1G_12C_1G_1->SetTitle("Fractional Attenuation");
00731 g1G_12C_1G_1->SetMarkerStyle(3);
00732 g1G_12C_1G_1->SetMarkerColor(3);
00733 g1G_12C_1G_1->SetMarkerSize(0.2);
00734 cAttCalDet2->cd(1);
00735 g1G_12C_1G_1->Draw("p");
00736 g1G_12C_1G_1->SetMinimum(0);
00737
00738
00739 TGraph* g1G_12C_1G_2=TGraphVect(x1G_12C_1G_2,y1G_12C_1G_2);
00740 g1G_12C_1G_2->SetTitle("Fractional Attenuation");
00741 g1G_12C_1G_2->SetMarkerStyle(3);
00742 g1G_12C_1G_2->SetMarkerColor(1);
00743 g1G_12C_1G_2->SetMarkerSize(0.2);
00744 cAttCalDet2->cd(1);
00745 g1G_12C_1G_2->Draw("P");
00746 g1G_12C_1G_2->SetMinimum(0);
00747
00748
00749 TGraph* g1G_12C_1G_3=TGraphVect(x1G_12C_1G_3,y1G_12C_1G_3);
00750 g1G_12C_1G_3->SetTitle("Fractional Attenuation");
00751 g1G_12C_1G_3->SetMarkerStyle(3);
00752 g1G_12C_1G_3->SetMarkerColor(3);
00753 g1G_12C_1G_3->SetMarkerSize(0.2);
00754 cAttCalDet2->cd(1);
00755 g1G_12C_1G_3->Draw("P");
00756 g1G_12C_1G_3->SetMinimum(0);
00757
00758
00759 TGraph* g8G=TGraphVect(xNorm,y8G);
00760 g8G->SetTitle("Fractional Attenuation");
00761 g8G->SetMarkerStyle(3);
00762 g8G->SetMarkerColor(8);
00763 g8G->SetMarkerSize(0.2);
00764 cAttCalDet2->cd(1);
00765 g8G->Draw("P");
00766 g8G->SetMinimum(0);
00767
00769
00771
00772
00773
00774
00775
00776
00777
00778
00779
00780
00781
00782
00783
00784
00785
00786
00787
00788
00789
00790
00791
00792
00793
00794
00795
00796
00797
00798
00799
00800
00801
00802
00803
00805
00807
00808
00809
00810
00811
00812
00813
00814
00815
00816
00817
00818
00819
00820
00821
00822
00823
00824
00825
00826
00827
00828
00829
00830
00831
00832
00833
00834
00835
00836
00837
00838
00839
00841
00843 MSG("LIPlexMaps",Msg::kInfo)
00844 <<"Drawing cBoostsFar canvas..."<<endl;
00845 TCanvas *cBoostsFar=new TCanvas("cBoostsFar","cBoostsFar",
00846 1,1,1000,800);
00847 cBoostsFar->SetFillColor(0);
00848 cBoostsFar->Divide(1,1);
00849
00850
00851 TGraph* cBoost6G=TGraphVect(reflectivity,boost6G);
00852 cBoost6G->SetTitle("Fractional Boost vs Reflectivity");
00853 cBoost6G->SetMarkerStyle(3);
00854 cBoost6G->SetMarkerColor(3);
00855 cBoost6G->SetMarkerSize(0.2);
00856 cBoostsFar->cd(1);
00857 cBoost6G->Draw("AP");
00858 cBoost6G->GetXaxis()->SetTitle("Reflectivity");
00859 cBoost6G->GetYaxis()->SetTitle("Fractional Boost");
00860 cBoost6G->GetXaxis()->CenterTitle();
00861 cBoost6G->GetYaxis()->CenterTitle();
00862 cBoost6G->SetMaximum(1.2);
00863 cBoost6G->SetMinimum(0);
00864
00865
00866 TGraph* cBoost12C=TGraphVect(reflectivity,boost12C);
00867 cBoost12C->SetTitle("Fractional Boost vs Reflectivity");
00868 cBoost12C->SetMarkerStyle(3);
00869 cBoost12C->SetMarkerColor(1);
00870 cBoost12C->SetMarkerSize(0.2);
00871 cBoostsFar->cd(1);
00872 cBoost12C->Draw("P");
00873 cBoost12C->SetMinimum(0);
00874
00875
00877
00879 MSG("LIPlexMaps",Msg::kInfo)
00880 <<"Drawing cBoostsNear canvas..."<<endl;
00881 TCanvas *cBoostsNear=new TCanvas("cBoostsNear","cBoostsNear",
00882 1,1,1000,800);
00883 cBoostsNear->SetFillColor(0);
00884 cBoostsNear->Divide(1,1);
00885
00886
00887 TGraph* cBoost8G=TGraphVect(reflectivity,boost8G);
00888 cBoost8G->SetTitle("Fractional Boost vs Reflectivity");
00889 cBoost8G->SetMarkerStyle(3);
00890 cBoost8G->SetMarkerColor(3);
00891 cBoost8G->SetMarkerSize(0.2);
00892 cBoostsNear->cd(1);
00893 cBoost8G->Draw("AP");
00894 cBoost8G->GetXaxis()->SetTitle("Reflectivity");
00895 cBoost8G->GetYaxis()->SetTitle("Fractional Boost");
00896 cBoost8G->GetXaxis()->CenterTitle();
00897 cBoost8G->GetYaxis()->CenterTitle();
00898 cBoost8G->SetMaximum(1.2);
00899 cBoost8G->SetMinimum(0);
00900
00901
00902 TGraph* cBoost1G_12C_1G=TGraphVect(reflectivity,boost1G_12C_1G);
00903 cBoost1G_12C_1G->SetTitle("Fractional Boost vs Reflectivity");
00904 cBoost1G_12C_1G->SetMarkerStyle(3);
00905 cBoost1G_12C_1G->SetMarkerColor(1);
00906 cBoost1G_12C_1G->SetMarkerSize(0.2);
00907 cBoostsNear->cd(1);
00908 cBoost1G_12C_1G->Draw("P");
00909 cBoost1G_12C_1G->SetMinimum(0);
00910
00911 MSG("LIPlexMaps",Msg::kInfo)
00912 <<" ** Finished Attenuation method **"<<endl;
00913 }
00914
00915
00916
00917 void LIPlexMaps::ADCRailEffect()
00918 {
00919 MSG("LIPlexMaps",Msg::kInfo)
00920 <<" ** Running ADCRailEffect method... **"<<endl;
00921
00923
00925
00926
00927
00928
00929
00930
00931
00932 gStyle->SetPalette(1);
00933
00934 gStyle->SetOptStat(1111111);
00935
00936 TStopwatch stopwatch;
00937
00938
00939 const Double_t kQE=0.13;
00940
00941
00942
00943
00944
00945
00946 const Int_t kNumBinomPoints=static_cast<Int_t>(1e6);
00947
00948 MSG("LIPlexMaps",Msg::kInfo)
00949 <<endl<<"The following parameters are used in the MC:"<<endl
00950 <<"kQE="<<kQE<<endl
00951 <<"kNumBinomPoints="<<kNumBinomPoints<<endl;
00952
00953 Int_t maxN=150;
00954 TH1F *hBinomial= new TH1F("hBinomial","Binomial distribution",
00955 maxN+5,-1,maxN+4);
00956 hBinomial->SetFillColor(0);
00957 hBinomial->SetBit(TH1::kCanRebin);
00958
00959 TH1F *hBinomial2= new TH1F("hBinomial2","Binomial distribution",
00960 maxN+5,-1,maxN+4);
00961 hBinomial2->SetFillColor(0);
00962 hBinomial2->SetLineColor(2);
00963 hBinomial2->SetBit(TH1::kCanRebin);
00964
00965 TH1F *hBinomial3= new TH1F("hBinomial3","Binomial distribution",
00966 maxN+5,-1,maxN+4);
00967 hBinomial3->SetFillColor(0);
00968 hBinomial3->SetLineColor(3);
00969 hBinomial3->SetBit(TH1::kCanRebin);
00970
00971
00972 TRandom *tRandom=new TRandom(0);
00973
00974 for (Int_t N=100;N<160;N+=20){
00975 static Int_t counter=0;
00976 counter++;
00977
00978 MSG("LIPlexMaps",Msg::kInfo)
00979 <<endl<<"Generating binomial distribution..."<<endl;
00980 for (Int_t i=0;i<kNumBinomPoints;i++){
00981
00982
00983
00984 Int_t r1=tRandom->Binomial(static_cast<Int_t>(N),
00985 static_cast<Double_t>(kQE));
00986
00987
00988 if (r1>15) r1=15;
00989
00990 if (counter==1) hBinomial->Fill(r1);
00991 if (counter==2) hBinomial2->Fill(r1);
00992 if (counter==3) hBinomial3->Fill(r1);
00993
00994
00995 Float_t fract=ceil(kNumBinomPoints/5.);
00996 if (ceil(((Float_t)i)/fract)==((Float_t)i)/fract){
00997 MSG("LIPlexMaps",Msg::kInfo)
00998 <<"Fraction of loop complete: "<<i
00999 <<"/"<<kNumBinomPoints<<" ("
01000 <<(Int_t)(100.*i/kNumBinomPoints)<<"%)"<<endl;
01001 }
01002 }
01003 MSG("LIPlexMaps",Msg::kInfo)
01004 <<"Binomial distribution done"<<endl;
01005 }
01006
01007
01008 TCanvas *cBinomial=new TCanvas("cBinomial","cBinomial",1,1,1000,800);
01009 cBinomial->SetFillColor(0);
01010 cBinomial->cd();
01011 hBinomial->Draw();
01012 hBinomial2->Draw("sames");
01013 hBinomial3->Draw("sames");
01014
01015 MSG("LIPlexMaps",Msg::kInfo)
01016 <<" ** Finished ADCRailEffect method **"<<endl;
01017 }
01018
01019
01020
01021 void LIPlexMaps::NonLinearity()
01022 {
01023 MSG("LIPlexMaps",Msg::kInfo)
01024 <<" ** Running NonLinearity method... **"<<endl;
01025
01026
01027 gStyle->SetPalette(1);
01028
01029 gStyle->SetOptStat(1111111);
01030
01031 Int_t maxN=1000;
01032
01033 TH1F *hBinomial= new TH1F("hBinomial","Binomial distribution",
01034 maxN+5,-1,maxN+4);
01035 hBinomial->SetFillColor(0);
01036 hBinomial->SetLineColor(3);
01037 hBinomial->SetBit(TH1::kCanRebin);
01038
01039 TH1F *hAdc= new TH1F("hAdc","Binomial distribution",
01040 60*maxN+5,-1,60*maxN+4);
01041 hAdc->SetFillColor(0);
01042 hAdc->SetLineColor(3);
01043 hAdc->SetBit(TH1::kCanRebin);
01044
01045 TH1F *hGauss= new TH1F("hGauss","Binomial distribution",
01046 maxN+5,-1,maxN+4);
01047 hGauss->SetFillColor(0);
01048 hGauss->SetLineColor(2);
01049 hGauss->SetBit(TH1::kCanRebin);
01050
01051
01052 TRandom *tRandom=new TRandom(0);
01053
01054 Int_t kNumBinomPoints=10000;
01055 vector<Double_t> vPe;
01056 vector<Double_t> vAdc;
01057
01058 for (Int_t N=120;N<270;N+=2){
01059 static Int_t counter=0;
01060 counter++;
01061
01062 hBinomial->Reset();
01063 hAdc->Reset();
01064 hGauss->Reset();
01065
01066 MSG("LIPlexMaps",Msg::kInfo)
01067 <<endl<<"Generating distribution, N="<<N<<endl;
01068 for (Int_t i=0;i<kNumBinomPoints;i++){
01069
01070 Double_t gauss=tRandom->Gaus(1.*N,sqrt(1.*N));
01071 hGauss->Fill(gauss);
01072
01073 Double_t adc=70.*gauss-(1.3e-6*pow(1.*gauss,4.));
01074
01075
01076 if (gauss>237) adc=70*237-(1.3e-6*pow(237,4.));
01077
01078 hAdc->Fill(adc);
01079 }
01080
01081 vPe.push_back(1.*N);
01082 vAdc.push_back(hAdc->GetMean());
01083 }
01084
01085
01086
01087
01088
01089
01090
01091
01092
01093
01094
01095
01096
01097
01098
01099
01100
01101
01102
01103
01104
01105
01106
01107
01108
01109
01110
01111
01112
01113
01114
01115
01116
01117
01118
01119
01120
01121
01122
01123 TCanvas *cBinomial=new TCanvas("cBinomial","cBinomial",1,1,1000,800);
01124 cBinomial->SetFillColor(0);
01125 cBinomial->cd();
01126 hBinomial->Draw();
01127 hGauss->Draw("sames");
01128
01129
01130 TCanvas *cAdc=new TCanvas("cAdc","cAdc",1,1,1000,800);
01131 cAdc->SetFillColor(0);
01132 cAdc->cd();
01133 hAdc->Draw();
01134
01135 vector<Double_t> vx;
01136 vector<Double_t> vy;
01137 vector<Double_t> vStraight;
01138
01139 for (Double_t i=0;i<300;i+=1){
01140 Double_t x=i;
01141 Double_t y=70*x-(1.3e-6*pow(x,4.));
01142
01143
01144 if (x>237) y=70*237-(1.3e-6*pow(237,4.));
01145
01146 vx.push_back(x);
01147 vy.push_back(y);
01148 vStraight.push_back(70*x);
01149
01150 }
01151
01152 TGraph* g=this->TGraphVect(vx,vy);
01153 TGraph* gStraight=this->TGraphVect(vx,vStraight);
01154 TGraph* gAdcVsPe=this->TGraphVect(vPe,vAdc);
01155
01156
01157 TCanvas *cNonLin=new TCanvas("cNonLin","cNonLin",1,1,1000,800);
01158 cNonLin->SetFillColor(0);
01159 cNonLin->cd();
01160 g->Draw("AP");
01161 g->SetMarkerSize(1);
01162 g->SetMarkerStyle(3);
01163 g->SetMarkerColor(3);
01164 gStraight->Draw("p");
01165 gStraight->SetMarkerSize(1);
01166 gStraight->SetMarkerStyle(3);
01167 gStraight->SetMarkerColor(1);
01168 gAdcVsPe->Draw("p");
01169 gAdcVsPe->SetMarkerSize(1);
01170 gAdcVsPe->SetMarkerStyle(3);
01171 gAdcVsPe->SetMarkerColor(2);
01172
01173
01174
01175
01176
01177 MSG("LIPlexMaps",Msg::kInfo)
01178 <<" ** Finished NonLinearity method **"<<endl;
01179 }
01180
01181
01182
01183 void LIPlexMaps::PeGen()
01184 {
01185 MSG("LIPlexMaps",Msg::kInfo)
01186 <<" ** Running PeGen method... **"<<endl;
01187
01189
01191
01192
01193
01194
01195
01196
01197
01198 gStyle->SetPalette(1);
01199
01200 gStyle->SetOptStat(1111111);
01201
01202 TStopwatch stopwatch;
01203
01204
01205 const Double_t kQE=0.13;
01206 const Double_t kGain=80;
01207
01208
01209
01210
01211 Double_t roughMean=500;
01212 Double_t roughRms=fLookup.CalcRms(roughMean,kGain,kQE);
01213 Double_t roughNpe=fLookup.CalcNpe(roughMean,roughRms,kQE);
01214
01215
01216 Double_t tempN=-1;
01217 Double_t rem=0;
01218 rem=modf(roughNpe/kQE,&tempN);
01219 if (rem>=0.5) tempN++;
01220
01221
01222
01223 const Int_t kN=static_cast<Int_t>(tempN);
01224 const Double_t kNpe=kN*kQE;
01225 const Double_t kMean=kGain*kNpe;
01226 const Double_t kRms=fLookup.CalcRms(kMean,kGain,kQE);
01227 const Double_t kAdcsPerPe=kMean/kNpe;
01228
01229
01230
01231
01232
01233
01234 const Int_t kNumBinomPoints=static_cast<Int_t>(1e6);
01235
01236 MSG("LIPlexMaps",Msg::kInfo)
01237 <<endl<<"The following parameters are used in the MC:"<<endl
01238 <<"kQE="<<kQE<<endl
01239 <<"kN="<<kN<<endl
01240 <<"kMean="<<kMean<<endl
01241 <<"kRms="<<kRms<<endl
01242 <<"kGain="<<kGain<<endl
01243 <<"kNpe="<<kNpe<<endl
01244 <<"kAdcsPerPe="<<kAdcsPerPe<<endl
01245 <<"kNumBinomPoints="<<kNumBinomPoints<<endl;
01246
01247 TH1F *hBinomial= new TH1F("hBinomial","Binomial distribution",
01248 kN+3,-1,kN+2);
01249 hBinomial->SetFillColor(0);
01250 hBinomial->SetBit(TH1::kCanRebin);
01251
01252 TH1F *hADC= new TH1F("hADC","hADC",15000,-1,15000);
01253 hADC->SetFillColor(0);
01254 hADC->SetBit(TH1::kCanRebin);
01255 TH1F *hADC2= new TH1F("hADC2","hADC2",15000,-1,15000);
01256 hADC2->SetFillColor(0);
01257 hADC2->SetBit(TH1::kCanRebin);
01258
01259 vector<Double_t> vBinomial(kN+1);
01260 Double_t maxInBinomial=0;
01261 Int_t maxInBinomialPos=0;
01262
01263
01264 TRandom *tRandom=new TRandom(0);
01265 MSG("LIPlexMaps",Msg::kInfo)
01266 <<endl<<"Generating binomial distribution..."<<endl;
01267 for (Int_t i=0;i<kNumBinomPoints;i++){
01268
01269
01270
01271 Int_t r1=tRandom->Binomial(static_cast<Int_t>(kN),
01272 static_cast<Double_t>(kQE));
01273 hBinomial->Fill(r1);
01274 vBinomial[r1]++;
01275
01276
01277 if (vBinomial[r1]>maxInBinomial){
01278 maxInBinomial=vBinomial[r1];
01279 maxInBinomialPos=r1;
01280 }
01281
01282
01283 Float_t fract=ceil(kNumBinomPoints/5.);
01284 if (ceil(((Float_t)i)/fract)==((Float_t)i)/fract){
01285 MSG("LIPlexMaps",Msg::kInfo)
01286 <<"Fraction of loop complete: "<<i
01287 <<"/"<<kNumBinomPoints<<" ("
01288 <<(Int_t)(100.*i/kNumBinomPoints)<<"%)"<<endl;
01289 }
01290 }
01291 MSG("LIPlexMaps",Msg::kInfo)
01292 <<"Binomial distribution done"<<endl;
01293
01294
01295 TCanvas *cBinomial=new TCanvas("cBinomial","cBinomial",1,1,1000,800);
01296 cBinomial->SetFillColor(0);
01297 cBinomial->cd();
01298 hBinomial->Draw();
01299
01300
01301 this->ScaleVector(vBinomial,1/maxInBinomial);
01302
01303
01304
01305 for (Int_t i=0;i<2500;i++){
01306 MSG("LIPlexMaps",Msg::kVerbose)<<"i="<<i<<endl;
01307 hADC->Fill(kAdcsPerPe*hBinomial->GetRandom());
01308 Int_t npe=this->SampleDist(vBinomial,tRandom);
01309 hADC2->Fill(kAdcsPerPe*npe);
01310 }
01311
01312
01313 TCanvas *cAdc=new TCanvas("cAdc","cAdc",1,1,1000,800);
01314 cAdc->SetFillColor(0);
01315 cAdc->Divide(2,1);
01316 cAdc->cd(1);
01317 hADC->Draw();
01318 cAdc->cd(2);
01319 hADC2->Draw();
01320
01321 const Int_t kNumPoints=20;
01322 const Int_t kFlashes=500;
01323 Double_t *numFlashes=new Double_t[kNumPoints];
01324
01325 MSG("LIPlexMaps",Msg::kInfo)
01326 <<endl<<"Calculating errors analytically"<<endl;
01327
01328 for (Int_t j=0;j<kNumPoints;j++){
01329 numFlashes[j]=static_cast<Double_t>((j+1)*kFlashes);
01330 MSG("LIPlexMaps",Msg::kInfo)
01331 <<endl<<"Point "<<j+1<<"/"<<kNumPoints
01332 <<", numFlashes="<<numFlashes[j]<<endl;
01333
01334
01335
01336 MSG("LIPlexMaps",Msg::kInfo)
01337 <<"Mean="<<kMean<<", rms="<<kRms
01338 <<", N="<<numFlashes[j]
01339 <<", Errors: eMean="<<kRms/sqrt(numFlashes[j])
01340 <<" ("<<((kRms/sqrt(numFlashes[j]))/kMean)*100<<"%)"
01341 <<", eRms="<<kRms/sqrt(numFlashes[j])
01342 <<" ("<<(1/sqrt(numFlashes[j]))*100<<"%)"
01343 <<", eGain="
01344 <<"("<<((1/sqrt(numFlashes[j]))*2+
01345 (kRms/sqrt(numFlashes[j]))/kMean)*100<<"%)"
01346 <<" quad="
01347 <<"("<<sqrt((1/numFlashes[j])*2+
01348 pow((kRms/sqrt(numFlashes[j]))/kMean,2))*100<<"%)"
01349 <<endl;
01350 }
01351
01352 Double_t *mean=new Double_t[kNumPoints*kFlashes];
01353 Double_t *rms=new Double_t[kNumPoints*kFlashes];
01354 Double_t *gain=new Double_t[kNumPoints*kFlashes];
01355 Double_t *xAxis=new Double_t[kNumPoints*kFlashes];
01356
01357 Double_t *rmsOfMean=new Double_t[kNumPoints];
01358 Double_t *rmsOfGain=new Double_t[kNumPoints];
01359 Double_t *rmsOfRms=new Double_t[kNumPoints];
01360 Double_t *errorOnMean=new Double_t[kNumPoints];
01361 Double_t *errorOnGain=new Double_t[kNumPoints];
01362 Double_t *errorOnRms=new Double_t[kNumPoints];
01363 Double_t *errorOnMeanN=new Double_t[kNumPoints];
01364 Double_t *errorOnGainN=new Double_t[kNumPoints];
01365 Double_t *errorOnRmsN=new Double_t[kNumPoints];
01366
01367 const Int_t kNumLiRuns=1000;
01368
01369 MSG("LIPlexMaps",Msg::kInfo)
01370 <<endl<<"Calculating errors by MC"<<endl;
01371
01372 for (Int_t j=0;j<kNumPoints;j++){
01373 numFlashes[j]=static_cast<Double_t>((j+1)*kFlashes);
01374 MSG("LIPlexMaps",Msg::kInfo)
01375 <<endl<<"Point "<<j+1<<"/"<<kNumPoints
01376 <<", numFlashes="<<numFlashes[j]<<endl;
01377
01378 stopwatch.Start();
01379
01380
01381 for (Int_t k=0;k<kNumLiRuns;k++){
01382 hADC->Reset();
01383 for (Int_t i=0;i<(j+1)*kFlashes;i++){
01384
01385 hADC->Fill(kAdcsPerPe*this->SampleDist(vBinomial,tRandom));
01386 }
01387 mean[k]=hADC->GetMean();
01388 rms[k]=hADC->GetRMS();
01389 gain[k]=fLookup.CalcGain(mean[k],rms[k],kQE);
01390 xAxis[k]=static_cast<Double_t>(k);
01391 rmsOfMean[j]+=pow(kMean-mean[k],2);
01392 rmsOfGain[j]+=pow(kGain-gain[k],2);
01393 rmsOfRms[j]+=pow(kRms-rms[k],2);
01394 }
01395
01396 stopwatch.Stop();
01397 MSG("LIPlexMaps",Msg::kInfo)
01398 <<"Time elapsed, real="<<stopwatch.RealTime()
01399 <<", cpu="<<stopwatch.CpuTime()
01400 <<endl;
01401
01402
01403 rmsOfMean[j]=sqrt(rmsOfMean[j]/kNumLiRuns);
01404 rmsOfGain[j]=sqrt(rmsOfGain[j]/kNumLiRuns);
01405 rmsOfRms[j]=sqrt(rmsOfRms[j]/kNumLiRuns);
01406
01407
01408
01409
01410 errorOnMean[j]=rmsOfMean[j]/sqrt(1.);
01411 errorOnGain[j]=rmsOfGain[j]/sqrt(1.);
01412 errorOnRms[j]=rmsOfRms[j]/sqrt(1.);
01413
01414
01415 errorOnMeanN[j]=errorOnMean[j]/kMean;
01416 errorOnGainN[j]=errorOnGain[j]/kGain;
01417 errorOnRmsN[j]=errorOnRms[j]/kRms;
01418
01419 MSG("LIPlexMaps",Msg::kInfo)
01420 <<"Errors: eMean="<<errorOnMean[j]
01421 <<" ("<<errorOnMeanN[j]*100<<"%)"
01422 <<", eGain="<<errorOnGain[j]
01423 <<" ("<<errorOnGainN[j]*100<<"%)"
01424 <<", eRms="<<errorOnRms[j]
01425 <<" ("<<errorOnRmsN[j]*100<<"%)"
01426 <<endl;
01427 }
01428
01429
01430 TCanvas *cGain=new TCanvas("cGain","cGain",1,1,1000,800);
01431 cGain->SetFillColor(0);
01432 cGain->Divide(1,2);
01433
01434 TGraph *gGain=new TGraph(kNumLiRuns,xAxis,gain);
01435 gGain->SetTitle("Gain Vs 'run'");
01436 gGain->SetMarkerStyle(3);
01437 gGain->SetMarkerColor(2);
01438 gGain->SetMarkerSize(0.4);
01439 cGain->cd(1);
01440 gGain->Draw("AP");
01441 gGain->GetXaxis()->SetTitle("'run' number");
01442 gGain->GetYaxis()->SetTitle("Gain");
01443 gGain->GetXaxis()->CenterTitle();
01444 gGain->GetYaxis()->CenterTitle();
01445
01446 TGraph *gMean=new TGraph(kNumLiRuns,xAxis,mean);
01447 gMean->SetTitle("Mean Vs 'run'");
01448 gMean->SetMarkerStyle(3);
01449 gMean->SetMarkerColor(2);
01450 gMean->SetMarkerSize(0.4);
01451 cGain->cd(2);
01452 gMean->Draw("AP");
01453 gMean->GetXaxis()->SetTitle("'run' number");
01454 gMean->GetYaxis()->SetTitle("Mean");
01455 gMean->GetXaxis()->CenterTitle();
01456 gMean->GetYaxis()->CenterTitle();
01457
01459
01461
01462 TCanvas *cGainError=new TCanvas("cGainError","cGainError",
01463 1,1,1000,800);
01464 cGainError->SetFillColor(0);
01465 cGainError->Divide(1,2);
01466
01467
01468 TGraph *gGainErrorNormVsFlashes=new TGraph(kNumPoints,
01469 numFlashes,errorOnGainN);
01470 gGainErrorNormVsFlashes->SetTitle
01471 ("Fractional Error on Gain Vs Flashes");
01472 gGainErrorNormVsFlashes->SetMarkerStyle(3);
01473 gGainErrorNormVsFlashes->SetMarkerColor(2);
01474 gGainErrorNormVsFlashes->SetMarkerSize(0.2);
01475 cGainError->cd(1);
01476 gGainErrorNormVsFlashes->Draw("AP");
01477 gGainErrorNormVsFlashes->GetXaxis()->SetTitle("Number of Flashes");
01478 gGainErrorNormVsFlashes->GetYaxis()->SetTitle
01479 ("Fractional Error on Gain");
01480 gGainErrorNormVsFlashes->GetXaxis()->CenterTitle();
01481 gGainErrorNormVsFlashes->GetYaxis()->CenterTitle();
01482 gGainErrorNormVsFlashes->SetMinimum(0);
01483
01484
01485 TGraph *gGainErrorVsFlashes=new TGraph(kNumPoints,
01486 numFlashes,errorOnGain);
01487 gGainErrorVsFlashes->SetTitle("Error on Gain Vs Flashes");
01488 gGainErrorVsFlashes->SetMarkerStyle(3);
01489 gGainErrorVsFlashes->SetMarkerColor(2);
01490 gGainErrorVsFlashes->SetMarkerSize(0.2);
01491 cGainError->cd(2);
01492 gGainErrorVsFlashes->Draw("AP");
01493 gGainErrorVsFlashes->GetXaxis()->SetTitle("Number of Flashes");
01494 gGainErrorVsFlashes->GetYaxis()->SetTitle("Error on Gain");
01495 gGainErrorVsFlashes->GetXaxis()->CenterTitle();
01496 gGainErrorVsFlashes->GetYaxis()->CenterTitle();
01497
01499
01501
01502 TCanvas *cGainMean=new TCanvas("cGainMean","cGainMean",1,1,1000,800);
01503 cGainMean->SetFillColor(0);
01504 cGainMean->Divide(1,2);
01505
01506
01507 TGraph *gMeanErrorNormVsFlashes=new TGraph(kNumPoints,
01508 numFlashes,errorOnMeanN);
01509 gMeanErrorNormVsFlashes->SetTitle
01510 ("Fractional Error on Mean Vs Flashes");
01511 gMeanErrorNormVsFlashes->SetMarkerStyle(3);
01512 gMeanErrorNormVsFlashes->SetMarkerColor(2);
01513 gMeanErrorNormVsFlashes->SetMarkerSize(0.2);
01514 cGainMean->cd(1);
01515 gMeanErrorNormVsFlashes->Draw("AP");
01516 gMeanErrorNormVsFlashes->GetXaxis()->SetTitle("Number of Flashes");
01517 gMeanErrorNormVsFlashes->GetYaxis()->SetTitle
01518 ("Fractional Error on Mean");
01519 gMeanErrorNormVsFlashes->GetXaxis()->CenterTitle();
01520 gMeanErrorNormVsFlashes->GetYaxis()->CenterTitle();
01521 gMeanErrorNormVsFlashes->SetMinimum(0);
01522
01523
01524 TGraph *gMeanErrorVsFlashes=new TGraph(kNumPoints,
01525 numFlashes,errorOnMean);
01526 gMeanErrorVsFlashes->SetTitle("Error on Mean Vs Flashes");
01527 gMeanErrorVsFlashes->SetMarkerStyle(3);
01528 gMeanErrorVsFlashes->SetMarkerColor(2);
01529 gMeanErrorVsFlashes->SetMarkerSize(0.2);
01530 cGainMean->cd(2);
01531 gMeanErrorVsFlashes->Draw("AP");
01532 gMeanErrorVsFlashes->GetXaxis()->SetTitle("Number of Flashes");
01533 gMeanErrorVsFlashes->GetYaxis()->SetTitle("Error on Mean");
01534 gMeanErrorVsFlashes->GetXaxis()->CenterTitle();
01535 gMeanErrorVsFlashes->GetYaxis()->CenterTitle();
01536
01538
01540
01541 TCanvas *cRmsErr=new TCanvas("cRmsErr","cRmsErr",1,1,1000,800);
01542 cRmsErr->SetFillColor(0);
01543 cRmsErr->Divide(1,2);
01544
01545
01546 TGraph *gRmsErrorNormVsFlashes=new TGraph(kNumPoints,
01547 numFlashes,errorOnRmsN);
01548 gRmsErrorNormVsFlashes->SetTitle
01549 ("Fractional Error on Rms Vs Flashes");
01550 gRmsErrorNormVsFlashes->SetMarkerStyle(3);
01551 gRmsErrorNormVsFlashes->SetMarkerColor(2);
01552 gRmsErrorNormVsFlashes->SetMarkerSize(0.2);
01553 cRmsErr->cd(1);
01554 gRmsErrorNormVsFlashes->Draw("AP");
01555 gRmsErrorNormVsFlashes->GetXaxis()->SetTitle("Number of Flashes");
01556 gRmsErrorNormVsFlashes->GetYaxis()->SetTitle
01557 ("Fractional Error on Rms");
01558 gRmsErrorNormVsFlashes->GetXaxis()->CenterTitle();
01559 gRmsErrorNormVsFlashes->GetYaxis()->CenterTitle();
01560 gRmsErrorNormVsFlashes->SetMinimum(0);
01561
01562
01563 TGraph *gRmsErrorVsFlashes=new TGraph(kNumPoints,
01564 numFlashes,errorOnRms);
01565 gRmsErrorVsFlashes->SetTitle("Error on Rms Vs Flashes");
01566 gRmsErrorVsFlashes->SetMarkerStyle(3);
01567 gRmsErrorVsFlashes->SetMarkerColor(2);
01568 gRmsErrorVsFlashes->SetMarkerSize(0.2);
01569 cRmsErr->cd(2);
01570 gRmsErrorVsFlashes->Draw("AP");
01571 gRmsErrorVsFlashes->GetXaxis()->SetTitle("Number of Flashes");
01572 gRmsErrorVsFlashes->GetYaxis()->SetTitle("Error on Rms");
01573 gRmsErrorVsFlashes->GetXaxis()->CenterTitle();
01574 gRmsErrorVsFlashes->GetYaxis()->CenterTitle();
01575
01576
01577
01578
01579
01580
01581
01582
01583
01584
01585
01586
01587
01588
01589
01590
01591
01592
01593
01594
01595
01596
01597
01598
01599
01600
01601
01602
01603
01604
01605
01606
01607
01608
01609
01610
01611
01612
01613
01614
01615
01616
01617
01618
01619
01620
01621
01622 MSG("LIPlexMaps",Msg::kInfo)
01623 <<" ** Finished the PeGen method ** "<<endl;
01624 }
01625
01626
01627
01628 void LIPlexMaps::LIErrors()
01629 {
01630 MSG("LIPlexMaps",Msg::kInfo)
01631 <<" ** Running LIErrors method... **"<<endl;
01632
01633
01634 gStyle->SetPalette(1);
01635
01636 gStyle->SetOptStat(1111111);
01637
01638
01639 const Double_t kQE=0.13;
01640 const Double_t kGain=80;
01641
01642 const Int_t kNumPoints=50;
01643
01644 TGraph *gGainErrorNormVsMean=new TGraph(kNumPoints);
01645 TGraph *gMeanErrorNormVsMean=new TGraph(kNumPoints);
01646 TGraph *gRmsErrorNormVsMean=new TGraph(kNumPoints);
01647
01648 for (Int_t i=0;i<kNumPoints;i++){
01649
01650
01651
01652
01653 Double_t roughMean=200*(i+1);
01654 Double_t roughRms=fLookup.CalcRms(roughMean,kGain,kQE);
01655 Double_t roughNpe=fLookup.CalcNpe(roughMean,roughRms,kQE);
01656
01657
01658 Double_t tempN=-1;
01659 Double_t rem=0;
01660 rem=modf(roughNpe/kQE,&tempN);
01661 if (rem>=0.5) tempN++;
01662
01663
01664
01665 const Int_t kN=static_cast<Int_t>(tempN);
01666 const Double_t kNpe=kN*kQE;
01667 const Double_t kMean=kGain*kNpe;
01668 const Double_t kRms=fLookup.CalcRms(kMean,kGain,kQE);
01669 const Double_t kAdcsPerPe=kMean/kNpe;
01670
01671 MSG("LIPlexMaps",Msg::kInfo)
01672 <<endl<<"The following parameters are used in the MC:"<<endl
01673 <<"kQE="<<kQE<<endl
01674 <<"kN="<<kN<<endl
01675 <<"kMean="<<kMean<<endl
01676 <<"kRms="<<kRms<<endl
01677 <<"kGain="<<kGain<<endl
01678 <<"kNpe="<<kNpe<<endl
01679 <<"kAdcsPerPe="<<kAdcsPerPe<<endl;
01680
01681 Double_t numFlashes=1000;
01682 Double_t errorOnMeanN=-1;
01683 Double_t errorOnGainN=-1;
01684 Double_t errorOnRmsN=-1;
01685
01686
01687
01688
01689
01690 errorOnMeanN=(kRms/sqrt(numFlashes))/kMean;
01691 errorOnRmsN=1/sqrt(numFlashes);
01692 errorOnGainN=sqrt(pow(errorOnRmsN,2)*2+
01693 pow(errorOnMeanN,2));
01694
01695 MSG("LIPlexMaps",Msg::kInfo)
01696 <<"Mean="<<kMean<<", rms="<<kRms
01697 <<", N="<<numFlashes
01698 <<", Errors: eMean="
01699 <<"("<<errorOnMeanN*100<<"%)"
01700 <<", eRms="
01701 <<"("<<errorOnRmsN*100<<"%)"
01702 <<", eGain="<<"("<<errorOnGainN*100<<"%)"
01703 <<endl;
01704
01705 gGainErrorNormVsMean->SetPoint(i,kMean,errorOnGainN);
01706 gMeanErrorNormVsMean->SetPoint(i,kMean,errorOnMeanN);
01707 gRmsErrorNormVsMean->SetPoint(i,kMean,errorOnRmsN);
01708 }
01709
01711
01713
01714 TCanvas *cGainErrorVsMean=new TCanvas("cGainErrorVsMean",
01715 "cGainErrorVsMean",
01716 1,1,1000,800);
01717 cGainErrorVsMean->SetFillColor(0);
01718
01719 gGainErrorNormVsMean->SetTitle("Fractional Error on Gain Vs Mean");
01720 gGainErrorNormVsMean->SetMarkerStyle(3);
01721 gGainErrorNormVsMean->SetMarkerColor(2);
01722 gGainErrorNormVsMean->SetMarkerSize(0.2);
01723 cGainErrorVsMean->cd(1);
01724 gGainErrorNormVsMean->Draw("AP");
01725 gGainErrorNormVsMean->GetXaxis()->SetTitle("Mean");
01726 gGainErrorNormVsMean->GetYaxis()->SetTitle
01727 ("Fractional Error on Gain");
01728 gGainErrorNormVsMean->GetXaxis()->CenterTitle();
01729 gGainErrorNormVsMean->GetYaxis()->CenterTitle();
01730 gGainErrorNormVsMean->SetMinimum(0);
01731
01733
01735
01736 TCanvas *cMeanErrorVsMean=new TCanvas("cMeanErrorVsMean",
01737 "cMeanErrorVsMean",
01738 1,1,1000,800);
01739 cMeanErrorVsMean->SetFillColor(0);
01740
01741 gMeanErrorNormVsMean->SetTitle("Fractional Error on Mean Vs Mean");
01742 gMeanErrorNormVsMean->SetMarkerStyle(3);
01743 gMeanErrorNormVsMean->SetMarkerColor(2);
01744 gMeanErrorNormVsMean->SetMarkerSize(0.2);
01745 cMeanErrorVsMean->cd(1);
01746 gMeanErrorNormVsMean->Draw("AP");
01747 gMeanErrorNormVsMean->GetXaxis()->SetTitle("Mean");
01748 gMeanErrorNormVsMean->GetYaxis()->SetTitle
01749 ("Fractional Error on Mean");
01750 gMeanErrorNormVsMean->GetXaxis()->CenterTitle();
01751 gMeanErrorNormVsMean->GetYaxis()->CenterTitle();
01752 gMeanErrorNormVsMean->SetMinimum(0);
01753
01755
01757
01758 TCanvas *cRmsErrVsMean=new TCanvas("cRmsErrVsMean","cRmsErrVsMean",
01759 1,1,1000,800);
01760 cRmsErrVsMean->SetFillColor(0);
01761
01762 gRmsErrorNormVsMean->SetTitle
01763 ("Fractional Error on Rms Vs Mean");
01764 gRmsErrorNormVsMean->SetMarkerStyle(3);
01765 gRmsErrorNormVsMean->SetMarkerColor(2);
01766 gRmsErrorNormVsMean->SetMarkerSize(0.2);
01767 cRmsErrVsMean->cd(1);
01768 gRmsErrorNormVsMean->Draw("AP");
01769 gRmsErrorNormVsMean->GetXaxis()->SetTitle("Mean");
01770 gRmsErrorNormVsMean->GetYaxis()->SetTitle
01771 ("Fractional Error on Rms");
01772 gRmsErrorNormVsMean->GetXaxis()->CenterTitle();
01773 gRmsErrorNormVsMean->GetYaxis()->CenterTitle();
01774 gRmsErrorNormVsMean->SetMinimum(0);
01775
01776 MSG("LIPlexMaps",Msg::kInfo)
01777 <<" ** Finished the LIErrors method ** "<<endl;
01778 }
01779
01780
01781
01782 void LIPlexMaps::PlotPlexPinMap()
01783 {
01784 MSG("LIAnalysis",Msg::kInfo)
01785 <<"Running PlotPlexPinMap method..."<<endl;
01786
01787
01788
01789
01790
01791
01792
01793
01794
01795
01796
01797
01798
01799
01800
01801
01802
01803
01804
01805
01806
01807
01808
01809
01810
01811
01812
01813
01814
01815
01816
01817
01818
01819
01820
01821
01822
01823
01824
01825
01826
01827
01828
01829
01830
01831
01832
01833
01834
01835
01836
01837
01838
01839
01840
01841
01842
01843
01844
01845
01846
01847
01848
01849
01850
01851
01852
01853
01854
01855
01856
01857
01858
01859
01860
01861
01862
01863
01864
01865
01866
01867
01868
01869
01870
01871
01872
01873
01874
01875
01876
01877
01878
01879
01880
01881
01882
01883
01884
01885
01886
01887
01888
01889
01890
01891
01892
01893
01894
01895
01896
01897
01898
01899
01900
01901
01902
01903
01904
01905
01906
01907
01908
01909
01910
01911
01912
01913
01914
01915
01916
01917
01918
01919
01920
01921
01922
01923
01924
01925
01926
01927
01928
01929
01930
01931
01932
01933
01934
01935
01936
01937
01938
01939
01940
01941
01942
01943
01944
01945
01946
01947
01948
01949
01950
01951
01952
01953
01954
01955
01956
01957
01958
01959
01960
01961
01962
01963
01964
01965
01966
01967
01968
01969
01970
01971
01972
01973
01974
01975
01976
01977
01978
01979
01980
01981
01982
01983
01984
01985
01986
01987
01988
01989
01990
01991
01992
01993
01994
01995
01996
01997
01998
01999
02000
02001
02002
02003
02004
02005
02006
02007
02008
02009
02010
02011
02012
02013
02014
02015
02016
02017
02018
02019
02020
02021
02022
02023
02024
02025
02026
02027
02028
02029
02030
02031
02032
02033
02034
02035
02036
02037
02038
02039
02040
02041
02042
02043
02044
02045
02046
02047
02048
02049
02050
02051
02052
02053
02054
02055
02056
02057
02058
02059
02060
02061
02062
02063
02064
02065
02066
02067
02068
02069
02070
02071
02072
02073
02074
02075
02076
02077
02078
02079
02080
02081
02082
02083
02084
02085
02086
02087
02088
02089
02090
02091
02092
02093
02094
02095
02096
02097
02098
02099
02100
02101
02102
02103
02104
02105
02106
02107
02108
02109
02110
02111
02112
02113
02114
02115
02116
02117
02118
02119
02120
02121
02122
02123
02124
02125
02126
02127
02128
02129
02130
02131
02132
02133
02134
02135
02136
02137
02138
02139
02140
02141
02142
02143
02144
02145
02146
02147
02148
02149
02150
02151
02152
02153
02154
02155
02156
02157
02158
02159
02160
02161
02162
02163
02164
02165
02166
02167
02168
02169
02170
02171
02172
02173
02174
02175
02176
02177
02178
02179
02180
02181
02182
02183
02184
02185
02186
02187
02188
02189
02190
02191
02192
02193
02194
02195
02196
02197
02198
02199
02200
02201
02202
02203
02204
02205
02206
02207
02208
02209
02210
02211
02212
02213
02214
02215
02216
02217
02218
02219
02220
02221
02222
02223
02224
02225
02226
02227
02228
02229
02230
02231
02232
02233
02234
02235
02236
02237
02238
02239
02240
02241
02242
02243
02244
02245
02246
02247
02248
02249
02250
02251
02252
02253
02254
02255
02256
02257
02258
02259
02260
02261
02262
02263
02264
02265
02266
02267
02268
02269
02270
02271
02272
02273
02274
02275
02276
02277
02278
02279
02280
02281
02282
02283
02284
02285
02286
02287
02288
02289
02290
02291
02292
02293
02294
02295
02296
02297
02298
02299
02300
02301
02302
02303
02304
02305
02306
02307
02308
02309
02310
02311
02312
02313
02314
02315
02316
02317
02318
02319
02320
02321
02322
02323
02324
02325
02326
02327
02328
02329
02330
02331
02332
02333
02334
02335
02336
02337
02338
02339
02340
02341
02342
02343
02344
02345
02346
02347
02348
02349
02350
02351
02352
02353
02354
02355
02356
02357
02358
02359
02360
02361
02362
02363
02364
02365
02366
02367
02368
02369
02370
02371
02372
02373
02374
02375
02376
02377
02378
02379
02380
02381
02382
02383
02384
02385
02386
02387
02388
02389
02390
02391
02392
02393
02394
02395
02396
02397
02398
02399
02400
02401
02402
02403
02404
02405
02406
02407
02408
02409
02410
02411
02412
02413
02414
02415
02416
02417
02418
02419
02420
02421
02422
02423
02424
02425
02426
02427
02428
02429
02430
02431
02432
02433
02434
02435
02436
02437
02438
02439
02440
02441
02442
02443
02444
02445
02446
02447
02448
02449
02450
02451
02452
02453
02454
02455
02456
02457
02458
02459
02460
02461
02462
02463
02464
02465
02466
02467
02468
02469
02470
02471
02472
02473
02474
02475
02476
02477
02478
02479
02480
02481
02482
02483
02484
02485
02486
02487
02488
02489
02490
02491
02492
02493
02494
02495
02496
02497
02498
02499
02500
02501
02502
02503
02504
02505
02506
02507
02508
02509
02510
02511
02512
02513
02514
02515
02516
02517
02518
02519
02520
02521
02522
02523
02524
02525
02526
02527 MSG("LIAnalysis",Msg::kInfo)
02528 <<"PlotPlexPinMap method finished"<<endl;
02529 }
02530
02531
02532
02533 void LIPlexMaps::PrintDbPinDiodeInfo()
02534 {
02535 VldTimeStamp timeStamp;
02536
02537
02538 VldContext vldc(Detector::kFar,SimFlag::kData,timeStamp);
02539
02540 DbiResultPtr<PlexRawChannelToPinDiode> rc2pdResPtr(vldc);
02541
02542 cout<<"Num of PlexRawChannelToPinDiode rows="
02543 <<rc2pdResPtr.GetNumRows()<<endl;
02544
02545 for (UInt_t irow = 0; irow < rc2pdResPtr.GetNumRows(); ++irow) {
02546
02547 const PlexRawChannelToPinDiode* rc2pd = rc2pdResPtr.GetRow(irow);
02548
02549 RawChannelId rcid = rc2pd->GetRawChannelId();
02550 PlexPinDiodeId pinid = rc2pd->GetPlexPinDiodeId();
02551
02552 cout<<"row="<<irow<<", rcid="<<this->GetElecString(rcid)
02553 <<", pinid="<<pinid<<", g="<<pinid.GetGain()
02554 <<", inbox="<<pinid.GetInBox()<<endl;
02555 }
02556
02557
02558 cout<<"gain==0"<<endl;
02559 for (UInt_t irow = 0; irow < rc2pdResPtr.GetNumRows(); ++irow) {
02560
02561 const PlexRawChannelToPinDiode* rc2pd = rc2pdResPtr.GetRow(irow);
02562
02563 RawChannelId rcid = rc2pd->GetRawChannelId();
02564 PlexPinDiodeId pinid = rc2pd->GetPlexPinDiodeId();
02565
02566 if (pinid.GetGain()==0){
02567 cout<<"row="<<irow<<", rcid="<<this->GetElecString(rcid)
02568 <<", pinid="<<pinid<<", g="<<pinid.GetGain()
02569
02570 <<endl;
02571 }
02572 }
02573
02574
02575 cout<<"gain==1"<<endl;
02576 for (UInt_t irow = 0; irow < rc2pdResPtr.GetNumRows(); ++irow) {
02577
02578 const PlexRawChannelToPinDiode* rc2pd = rc2pdResPtr.GetRow(irow);
02579
02580 RawChannelId rcid = rc2pd->GetRawChannelId();
02581 PlexPinDiodeId pinid = rc2pd->GetPlexPinDiodeId();
02582
02583 if (pinid.GetGain()==1){
02584 cout<<"row="<<irow<<", rcid="<<this->GetElecString(rcid)
02585 <<", pinid="<<pinid<<", g="<<pinid.GetGain()
02586
02587 <<endl;
02588 }
02589 }
02590
02591 }
02592
02593
02594
02595 void LIPlexMaps::PrintPlexPinDiodeInfo(Int_t detectorType)
02596 {
02597 MSG("LIPlexMaps",Msg::kInfo)
02598 <<"Running PrintPlexPinDiodeInfo method..."<<endl;
02599
02600
02601
02602 VldTimeStamp timeStamp;
02603
02604
02605
02606
02607 VldContext* validityContext;
02608 if (detectorType==Detector::kFar){
02609 validityContext=new VldContext(Detector::kFar,SimFlag::kData,
02610 timeStamp);
02611 }
02612 else if (detectorType==Detector::kCalDet){
02613 validityContext=new VldContext(Detector::kCalDet,SimFlag::kData,
02614 timeStamp);
02615 }
02616 else if (detectorType==Detector::kNear){
02617 validityContext=new VldContext(Detector::kNear,SimFlag::kData,
02618 timeStamp);
02619 }
02620 else{
02621 MSG("LIPlexMaps",Msg::kFatal)
02622 <<"Detector type not known = "<<detectorType
02623 <<endl<<"Program will exit here!"<<endl;
02624 exit(1);
02625 }
02626
02627 MSG("LIPlexMaps",Msg::kInfo)
02628 <<"Using validity context: "<<validityContext->AsString()<<endl;
02629
02630
02631 PlexHandle *plexHandle=new PlexHandle(*validityContext);
02632
02633
02634 LedIdList leds(*validityContext);
02635 LedIdList::iterator ledId=leds.begin();
02636
02637
02638 MSG("LIPlexMaps",Msg::kInfo)
02639 <<endl
02640 <<"The pin diode information in the plex is as follows"<<endl
02641 <<"The electronics information is in descending hierarchial order"
02642 <<endl
02643 <<"(x:y) is pulser box x and led y"<<endl
02644 <<"e.g. (crate,varc,vmm,vfb,VA chip,VA channel)"<<endl<<endl;
02645
02646
02647 while (ledId!=leds.end()){
02648
02649 if (!(*ledId).IsValid()){
02650 MSG("LIPlexMaps",Msg::kWarning)
02651 <<"LedId not valid = "<<ledId->AsString()<<endl;
02652 }
02653
02654
02655 pair<PlexPinDiodeId,PlexPinDiodeId> plexPins=plexHandle->
02656 GetPinDiodeIds(*ledId);
02657
02658
02659 MSG("LIPlexMaps",Msg::kVerbose)
02660 <<"first pin gain="<<plexPins.first.GetGain()
02661 <<", second pin gain="<<plexPins.second.GetGain()<<endl;
02662
02663
02664 pair<Int_t,Int_t> pin1Planes=fLookup.GetPinDiodePlanes
02665 (plexPins.first,plexHandle);
02666 pair<Int_t,Int_t> pin2Planes=fLookup.GetPinDiodePlanes
02667 (plexPins.second,plexHandle);
02668
02669
02670 pair<RawChannelId,RawChannelId> rawChanIds;
02671 rawChanIds.first=plexHandle->GetRawChannelId(plexPins.first);
02672 rawChanIds.second=plexHandle->GetRawChannelId(plexPins.second);
02673
02674
02675
02676 string sPlane1=Form("%d",pin1Planes.first);
02677 string sPlane2=Form("%d",pin1Planes.second);
02678
02679 string sPin1Planes=" Planes="+sPlane1+"&"+sPlane2;
02680 if (pin1Planes.second==-1){
02681 sPin1Planes=" Plane="+sPlane1;
02682 }
02683
02684 sPlane1=Form("%d",pin2Planes.first);
02685 sPlane2=Form("%d",pin2Planes.second);
02686 string sPin2Planes=" Planes="+sPlane1+"&"+sPlane2;
02687 if (pin2Planes.second==-1){
02688 sPin2Planes=" Plane="+sPlane1;
02689 }
02690
02691 MSG("LIPlexMaps",Msg::kInfo)
02692 <<endl
02693 <<"("<<ledId->GetPulserBox()<<":"<<ledId->GetLedInBox()<<")"
02694 <<" Pin1="<<this->GetElecString(rawChanIds.first)
02695 <<"="<<rawChanIds.first.GetChAdd()
02696 <<" MUX BOX: E/W="<<plexPins.first.GetEastWest()
02697 <<", rLevel="<<plexPins.first.GetRackLevel()
02698 <<", rBay="<<plexPins.first.GetRackBay()
02699 <<", inRack="<<plexPins.first.GetInRack()
02700 <<sPin1Planes
02701 <<endl
02702
02703 <<"("<<ledId->GetPulserBox()<<":"<<ledId->GetLedInBox()<<")"
02704 <<" Pin2="<<this->GetElecString(rawChanIds.second)
02705 <<"="<<rawChanIds.second.GetChAdd()
02706 <<" MUX BOX: E/W="<<plexPins.second.GetEastWest()
02707 <<", rLevel="<<plexPins.second.GetRackLevel()
02708 <<", rBay="<<plexPins.second.GetRackBay()
02709 <<", inRack="<<plexPins.second.GetInRack()
02710 <<sPin2Planes
02711 <<endl;
02712
02713 ledId++;
02714 }
02715
02716 MSG("LIPlexMaps",Msg::kInfo)
02717 <<endl<<" ** Finished the PrintPlexPinDiodeInfo method ** "
02718 <<endl;
02719 }
02720
02721
02722
02723 string LIPlexMaps::GetElecString(RawChannelId rChId)
02724 {
02725 MSG("LISummarySorter",Msg::kVerbose)
02726 <<"Running GetElecString method..."<<endl;
02727
02728 string elecString="";
02729 string sCrate=Form("%d",rChId.GetCrate());
02730 string sElecType=ElecType::AsString(rChId.GetElecType());
02731
02732 if (rChId.GetElecType()==ElecType::kVA){
02733 string sVarc=Form("%d",rChId.GetVarcId());
02734 string sVmm=Form("%d",rChId.GetVmm());
02735 string sVfb=Form("%d",rChId.GetVaAdcSel());
02736 string sChip=Form("%d",rChId.GetVaChip());
02737 string sChannel=Form("%d",rChId.GetVaChannel());
02738
02739 elecString=sElecType+
02740 "("+sCrate+","+sVarc+","+sVmm+","+sVfb+","+sChip+","+sChannel+")";
02741 }
02742 else if (rChId.GetElecType()==ElecType::kQIE){
02743 string sGeoAdd=Form("%d",rChId.GetGeographicAddress());
02744 string sMaster=Form("%d",rChId.GetMasterChannel());
02745 string sMinder=Form("%d",rChId.GetMinderChannel());
02746
02747 elecString=sElecType+
02748 "("+sCrate+","+sGeoAdd+","+sMaster+","+sMinder+")";
02749 }
02750 return elecString;
02751 }
02752
02753
02754
02755 void LIPlexMaps::PlotPlexStripMap(Int_t detectorType)
02756 {
02757 MSG("LIPlexMaps",Msg::kInfo)
02758 <<"Running PlotPlexStripMap method..."<<endl;
02759
02760 Int_t planeMax=-1;
02761 Int_t planeMin=-1;
02762
02763 planeMin=FIRSTSCINTPLANE-2;
02764 planeMax=LASTSCINTPLANE+5;
02765
02766 const Int_t firstStripBin=FIRSTSTRIP-8;
02767 const Int_t lastStripBin=LASTSTRIP+9;
02768 const Int_t bins=lastStripBin-firstStripBin;
02769
02770
02771
02772
02773 VldTimeStamp timeStamp(2001,7,1,1,1,1,1,0,0);
02774
02775
02776 VldContext* validityContext;
02777
02778 if (detectorType==Detector::kFar){
02779 validityContext=new VldContext(Detector::kFar,
02780 SimFlag::kData,timeStamp);
02781 }
02782 else if (detectorType==Detector::kCalDet){
02783 validityContext=new VldContext(Detector::kCalDet,
02784 SimFlag::kData,timeStamp);
02785 }
02786 else if (detectorType==Detector::kNear){
02787 validityContext=new VldContext(Detector::kNear,
02788 SimFlag::kData,timeStamp);
02789 }
02790 else{
02791 MSG("LIPlexMaps",Msg::kFatal)
02792 <<"Detector type not known = "<<detectorType
02793 <<endl<<"Program will exit here!"<<endl;
02794 exit(1);
02795 }
02796
02797 MSG("LIPlexMaps",Msg::kInfo)
02798 <<"Using validity context: "<<validityContext->AsString()<<endl;
02799
02800 PlexHandle *plexhandle=new PlexHandle(*validityContext);
02801
02802 TH2F *hStripVsPlaneLed=new TH2F("hStripVsPlaneLed",
02803 "Led (StripEnd=kNeg=kEast)",
02804 planeMax-planeMin,
02805 planeMin,planeMax,
02806 bins,firstStripBin,lastStripBin);
02807 hStripVsPlaneLed->GetXaxis()->SetTitle("Plane");
02808 hStripVsPlaneLed->GetXaxis()->CenterTitle();
02809 hStripVsPlaneLed->GetYaxis()->SetTitle("Strip");
02810 hStripVsPlaneLed->GetYaxis()->CenterTitle();
02811 hStripVsPlaneLed->SetFillColor(0);
02812
02813
02814 TH2F *hStripVsPlanePix=new TH2F("hStripVsPlanePix",
02815 "Pixel (StripEnd=kNeg=kEast)",
02816 planeMax-planeMin,planeMin,planeMax,
02817 bins,firstStripBin,lastStripBin);
02818 hStripVsPlanePix->GetXaxis()->SetTitle("Plane");
02819 hStripVsPlanePix->GetXaxis()->CenterTitle();
02820 hStripVsPlanePix->GetYaxis()->SetTitle("Strip");
02821 hStripVsPlanePix->GetYaxis()->CenterTitle();
02822 hStripVsPlanePix->SetFillColor(0);
02823 hStripVsPlanePix->SetMinimum(-2);
02824
02825
02826 TH2F *hStripVsPlaneCrate=new TH2F("hStripVsPlaneCrate",
02827 "Crate (StripEnd=kNeg=kEast)",
02828 planeMax-planeMin,planeMin,
02829 planeMax,
02830 bins,firstStripBin,lastStripBin);
02831 hStripVsPlaneCrate->GetXaxis()->SetTitle("Plane");
02832 hStripVsPlaneCrate->GetXaxis()->CenterTitle();
02833 hStripVsPlaneCrate->GetYaxis()->SetTitle("Strip");
02834 hStripVsPlaneCrate->GetYaxis()->CenterTitle();
02835 hStripVsPlaneCrate->SetFillColor(0);
02836 hStripVsPlaneCrate->SetMinimum(-2);
02837
02838
02839 TH2F *hStripVsPlaneVarc=new TH2F("hStripVsPlaneVarc",
02840 "Varc (StripEnd=kNeg=kEast)",
02841 planeMax-planeMin,planeMin,planeMax,
02842 bins,firstStripBin,lastStripBin);
02843 hStripVsPlaneVarc->GetXaxis()->SetTitle("Plane");
02844 hStripVsPlaneVarc->GetXaxis()->CenterTitle();
02845 hStripVsPlaneVarc->GetYaxis()->SetTitle("Strip");
02846 hStripVsPlaneVarc->GetYaxis()->CenterTitle();
02847 hStripVsPlaneVarc->SetFillColor(0);
02848 hStripVsPlaneVarc->SetMinimum(-2);
02849
02850
02851 TH2F *hStripVsPlaneVmm=new TH2F("hStripVsPlaneVmm",
02852 "Vmm (StripEnd=kNeg=kEast)",
02853 planeMax-planeMin,planeMin,planeMax,
02854 bins,firstStripBin,lastStripBin);
02855 hStripVsPlaneVmm->GetXaxis()->SetTitle("Plane");
02856 hStripVsPlaneVmm->GetXaxis()->CenterTitle();
02857 hStripVsPlaneVmm->GetYaxis()->SetTitle("Strip");
02858 hStripVsPlaneVmm->GetYaxis()->CenterTitle();
02859 hStripVsPlaneVmm->SetFillColor(0);
02860 hStripVsPlaneVmm->SetMinimum(-2);
02861
02862
02863 TH2F *hStripVsPlaneVfb=new TH2F("hStripVsPlaneVfb",
02864 "Vfb (StripEnd=kNeg=kEast)",
02865 planeMax-planeMin,planeMin,planeMax,
02866 bins,firstStripBin,lastStripBin);
02867 hStripVsPlaneVfb->GetXaxis()->SetTitle("Plane");
02868 hStripVsPlaneVfb->GetXaxis()->CenterTitle();
02869 hStripVsPlaneVfb->GetYaxis()->SetTitle("Strip");
02870 hStripVsPlaneVfb->GetYaxis()->CenterTitle();
02871 hStripVsPlaneVfb->SetFillColor(0);
02872 hStripVsPlaneVfb->SetMinimum(-2);
02873
02874
02875 TH2F *hStripVsPlaneVaChip=new TH2F("hStripVsPlaneVaChip",
02876 "VA Chip (StripEnd=kNeg=kEast)",
02877 planeMax-planeMin,planeMin,planeMax,
02878 bins,firstStripBin,lastStripBin);
02879 hStripVsPlaneVaChip->GetXaxis()->SetTitle("Plane");
02880 hStripVsPlaneVaChip->GetXaxis()->CenterTitle();
02881 hStripVsPlaneVaChip->GetYaxis()->SetTitle("Strip");
02882 hStripVsPlaneVaChip->GetYaxis()->CenterTitle();
02883 hStripVsPlaneVaChip->SetFillColor(0);
02884 hStripVsPlaneVaChip->SetMinimum(-2);
02885
02886
02887 TH2F *hStripVsPlaneCh=new TH2F("hStripVsPlaneCh",
02888 "VA Channel (StripEnd=kNeg=kEast)",
02889 planeMax-planeMin,planeMin,planeMax,
02890 bins,firstStripBin,lastStripBin);
02891 hStripVsPlaneCh->GetXaxis()->SetTitle("Plane");
02892 hStripVsPlaneCh->GetXaxis()->CenterTitle();
02893 hStripVsPlaneCh->GetYaxis()->SetTitle("Strip");
02894 hStripVsPlaneCh->GetYaxis()->CenterTitle();
02895 hStripVsPlaneCh->SetFillColor(0);
02896 hStripVsPlaneCh->SetMinimum(-2);
02897
02898
02899 TH2F *hStripVsPlaneGeoAdd=new TH2F("hStripVsPlaneGeoAdd",
02900 "Geographic Address (StripEnd=kNeg=kEast)",
02901 planeMax-planeMin,planeMin,
02902 planeMax,
02903 bins,firstStripBin,lastStripBin);
02904 hStripVsPlaneGeoAdd->GetXaxis()->SetTitle("Plane");
02905 hStripVsPlaneGeoAdd->GetXaxis()->CenterTitle();
02906 hStripVsPlaneGeoAdd->GetYaxis()->SetTitle("Strip");
02907 hStripVsPlaneGeoAdd->GetYaxis()->CenterTitle();
02908 hStripVsPlaneGeoAdd->SetFillColor(0);
02909 hStripVsPlaneGeoAdd->SetMinimum(-2);
02910
02911
02912 TH2F *hStripVsPlaneMasterCh=new TH2F("hStripVsPlaneMasterCh",
02913 "Master Channel (StripEnd=kNeg=kEast)",
02914 planeMax-planeMin,
02915 planeMin,planeMax,
02916 bins,
02917 firstStripBin,lastStripBin);
02918 hStripVsPlaneMasterCh->GetXaxis()->SetTitle("Plane");
02919 hStripVsPlaneMasterCh->GetXaxis()->CenterTitle();
02920 hStripVsPlaneMasterCh->GetYaxis()->SetTitle("Strip");
02921 hStripVsPlaneMasterCh->GetYaxis()->CenterTitle();
02922 hStripVsPlaneMasterCh->SetFillColor(0);
02923 hStripVsPlaneMasterCh->SetMinimum(-2);
02924
02925
02926 TH2F *hStripVsPlaneMinderCh=new TH2F("hStripVsPlaneMinderCh",
02927 "Minder Channel (StripEnd=kNeg=kEast)",
02928 planeMax-planeMin,
02929 planeMin,planeMax,
02930 bins,
02931 firstStripBin,lastStripBin);
02932 hStripVsPlaneMinderCh->GetXaxis()->SetTitle("Plane");
02933 hStripVsPlaneMinderCh->GetXaxis()->CenterTitle();
02934 hStripVsPlaneMinderCh->GetYaxis()->SetTitle("Strip");
02935 hStripVsPlaneMinderCh->GetYaxis()->CenterTitle();
02936 hStripVsPlaneMinderCh->SetFillColor(0);
02937 hStripVsPlaneMinderCh->SetMinimum(-2);
02938
02939
02940 TH2F *hStripVsPlaneSpot=new TH2F("hStripVsPlaneSpot",
02941 "Pixel Spot (StripEnd=kNeg=kEast)",
02942 planeMax-planeMin,planeMin,planeMax,
02943 bins,firstStripBin,lastStripBin);
02944 hStripVsPlaneSpot->GetXaxis()->SetTitle("Plane");
02945 hStripVsPlaneSpot->GetXaxis()->CenterTitle();
02946 hStripVsPlaneSpot->GetYaxis()->SetTitle("Strip");
02947 hStripVsPlaneSpot->GetYaxis()->CenterTitle();
02948 hStripVsPlaneSpot->SetFillColor(0);
02949 hStripVsPlaneSpot->SetMinimum(-2);
02950
02951
02952 TH2F *hStripVsPlaneEnt=new TH2F("hStripVsPlaneEnt",
02953 "Number Entries (StripEnd=kNeg=kEast)",
02954 planeMax-planeMin,planeMin,planeMax,
02955 bins,firstStripBin,lastStripBin);
02956 hStripVsPlaneEnt->GetXaxis()->SetTitle("Plane");
02957 hStripVsPlaneEnt->GetXaxis()->CenterTitle();
02958 hStripVsPlaneEnt->GetYaxis()->SetTitle("Strip");
02959 hStripVsPlaneEnt->GetYaxis()->CenterTitle();
02960 hStripVsPlaneEnt->SetFillColor(0);
02961 hStripVsPlaneEnt->SetMinimum(-2);
02962
02963
02965
02967 TH2F *hStripVsPlane2Led=new TH2F("hStripVsPlane2Led",
02968 "Led (StripEnd=kPos=kWest)",
02969 planeMax-planeMin,
02970 planeMin,planeMax,
02971 bins,firstStripBin,lastStripBin);
02972 hStripVsPlane2Led->GetXaxis()->SetTitle("Plane");
02973 hStripVsPlane2Led->GetXaxis()->CenterTitle();
02974 hStripVsPlane2Led->GetYaxis()->SetTitle("Strip");
02975 hStripVsPlane2Led->GetYaxis()->CenterTitle();
02976 hStripVsPlane2Led->SetFillColor(0);
02977
02978
02979 TH2F *hStripVsPlane2Pix=new TH2F("hStripVsPlane2Pix",
02980 "Pixel (StripEnd=kPos=kWest)",
02981 planeMax-planeMin,planeMin,planeMax,
02982 bins,firstStripBin,lastStripBin);
02983 hStripVsPlane2Pix->GetXaxis()->SetTitle("Plane");
02984 hStripVsPlane2Pix->GetXaxis()->CenterTitle();
02985 hStripVsPlane2Pix->GetYaxis()->SetTitle("Strip");
02986 hStripVsPlane2Pix->GetYaxis()->CenterTitle();
02987 hStripVsPlane2Pix->SetFillColor(0);
02988 hStripVsPlane2Pix->SetMinimum(-2);
02989
02990
02991 TH2F *hStripVsPlane2Crate=new TH2F("hStripVsPlane2Crate",
02992 "Crate (StripEnd=kPos=kWest)",
02993 planeMax-planeMin,planeMin,planeMax,
02994 bins,firstStripBin,lastStripBin);
02995 hStripVsPlane2Crate->GetXaxis()->SetTitle("Plane");
02996 hStripVsPlane2Crate->GetXaxis()->CenterTitle();
02997 hStripVsPlane2Crate->GetYaxis()->SetTitle("Strip");
02998 hStripVsPlane2Crate->GetYaxis()->CenterTitle();
02999 hStripVsPlane2Crate->SetFillColor(0);
03000 hStripVsPlane2Crate->SetMinimum(-2);
03001
03002
03003 TH2F *hStripVsPlane2Varc=new TH2F("hStripVsPlane2Varc",
03004 "Varc (StripEnd=kPos=kWest)",
03005 planeMax-planeMin,planeMin,planeMax,
03006 bins,firstStripBin,lastStripBin);
03007 hStripVsPlane2Varc->GetXaxis()->SetTitle("Plane");
03008 hStripVsPlane2Varc->GetXaxis()->CenterTitle();
03009 hStripVsPlane2Varc->GetYaxis()->SetTitle("Strip");
03010 hStripVsPlane2Varc->GetYaxis()->CenterTitle();
03011 hStripVsPlane2Varc->SetFillColor(0);
03012 hStripVsPlane2Varc->SetMinimum(-2);
03013
03014
03015 TH2F *hStripVsPlane2Vmm=new TH2F("hStripVsPlane2Vmm",
03016 "Vmm (StripEnd=kPos=kWest)",
03017 planeMax-planeMin,planeMin,planeMax,
03018 bins,firstStripBin,lastStripBin);
03019 hStripVsPlane2Vmm->GetXaxis()->SetTitle("Plane");
03020 hStripVsPlane2Vmm->GetXaxis()->CenterTitle();
03021 hStripVsPlane2Vmm->GetYaxis()->SetTitle("Strip");
03022 hStripVsPlane2Vmm->GetYaxis()->CenterTitle();
03023 hStripVsPlane2Vmm->SetFillColor(0);
03024 hStripVsPlane2Vmm->SetMinimum(-2);
03025
03026
03027 TH2F *hStripVsPlane2Vfb=new TH2F("hStripVsPlane2Vfb",
03028 "Vfb (StripEnd=kPos=kWest)",
03029 planeMax-planeMin,planeMin,planeMax,
03030 bins,firstStripBin,lastStripBin);
03031 hStripVsPlane2Vfb->GetXaxis()->SetTitle("Plane");
03032 hStripVsPlane2Vfb->GetXaxis()->CenterTitle();
03033 hStripVsPlane2Vfb->GetYaxis()->SetTitle("Strip");
03034 hStripVsPlane2Vfb->GetYaxis()->CenterTitle();
03035 hStripVsPlane2Vfb->SetFillColor(0);
03036 hStripVsPlane2Vfb->SetMinimum(-2);
03037
03038
03039 TH2F *hStripVsPlane2VaChip=new TH2F("hStripVsPlane2VaChip",
03040 "Va Chip(StripEnd=kPos=kWest)",
03041 planeMax-planeMin,planeMin,planeMax,
03042 bins,firstStripBin,lastStripBin);
03043 hStripVsPlane2VaChip->GetXaxis()->SetTitle("Plane");
03044 hStripVsPlane2VaChip->GetXaxis()->CenterTitle();
03045 hStripVsPlane2VaChip->GetYaxis()->SetTitle("Strip");
03046 hStripVsPlane2VaChip->GetYaxis()->CenterTitle();
03047 hStripVsPlane2VaChip->SetFillColor(0);
03048 hStripVsPlane2VaChip->SetMinimum(-2);
03049
03050
03051 TH2F *hStripVsPlane2Ch=new TH2F("hStripVsPlane2Ch",
03052 "VA Channel (StripEnd=kPos=kWest)",
03053 planeMax-planeMin,planeMin,planeMax,
03054 bins,firstStripBin,lastStripBin);
03055 hStripVsPlane2Ch->GetXaxis()->SetTitle("Plane");
03056 hStripVsPlane2Ch->GetXaxis()->CenterTitle();
03057 hStripVsPlane2Ch->GetYaxis()->SetTitle("Strip");
03058 hStripVsPlane2Ch->GetYaxis()->CenterTitle();
03059 hStripVsPlane2Ch->SetFillColor(0);
03060 hStripVsPlane2Ch->SetMinimum(-2);
03061
03062
03063 TH2F *hStripVsPlane2GeoAdd=new TH2F("hStripVsPlane2GeoAdd",
03064 "Geographic Address (StripEnd=kPos=kWest)",
03065 planeMax-planeMin,
03066 planeMin,planeMax,
03067 bins,firstStripBin,lastStripBin);
03068 hStripVsPlane2GeoAdd->GetXaxis()->SetTitle("Plane");
03069 hStripVsPlane2GeoAdd->GetXaxis()->CenterTitle();
03070 hStripVsPlane2GeoAdd->GetYaxis()->SetTitle("Strip");
03071 hStripVsPlane2GeoAdd->GetYaxis()->CenterTitle();
03072 hStripVsPlane2GeoAdd->SetFillColor(0);
03073 hStripVsPlane2GeoAdd->SetMinimum(-2);
03074
03075
03076 TH2F *hStripVsPlane2MasterCh=new TH2F("hStripVsPlane2MasterCh",
03077 "Master Channel (StripEnd=kPos=kWest)",
03078 planeMax-planeMin,
03079 planeMin,planeMax,
03080 bins,
03081 firstStripBin,lastStripBin);
03082 hStripVsPlane2MasterCh->GetXaxis()->SetTitle("Plane");
03083 hStripVsPlane2MasterCh->GetXaxis()->CenterTitle();
03084 hStripVsPlane2MasterCh->GetYaxis()->SetTitle("Strip");
03085 hStripVsPlane2MasterCh->GetYaxis()->CenterTitle();
03086 hStripVsPlane2MasterCh->SetFillColor(0);
03087 hStripVsPlane2MasterCh->SetMinimum(-2);
03088
03089
03090 TH2F *hStripVsPlane2MinderCh=new TH2F("hStripVsPlane2MinderCh",
03091 "Minder Channel (StripEnd=kPos=kWest)",
03092 planeMax-planeMin,planeMin,
03093 planeMax,
03094 bins,firstStripBin,
03095 lastStripBin);
03096 hStripVsPlane2MinderCh->GetXaxis()->SetTitle("Plane");
03097 hStripVsPlane2MinderCh->GetXaxis()->CenterTitle();
03098 hStripVsPlane2MinderCh->GetYaxis()->SetTitle("Strip");
03099 hStripVsPlane2MinderCh->GetYaxis()->CenterTitle();
03100 hStripVsPlane2MinderCh->SetFillColor(0);
03101 hStripVsPlane2MinderCh->SetMinimum(-2);
03102
03103
03104 TH2F *hStripVsPlane2Spot=new TH2F("hStripVsPlane2Spot",
03105 "Pixel Spot (StripEnd=kPos=kWest)",
03106 planeMax-planeMin,planeMin,planeMax,
03107 bins,firstStripBin,lastStripBin);
03108 hStripVsPlane2Spot->GetXaxis()->SetTitle("Plane");
03109 hStripVsPlane2Spot->GetXaxis()->CenterTitle();
03110 hStripVsPlane2Spot->GetYaxis()->SetTitle("Strip");
03111 hStripVsPlane2Spot->GetYaxis()->CenterTitle();
03112 hStripVsPlane2Spot->SetFillColor(0);
03113 hStripVsPlane2Spot->SetMinimum(-2);
03114
03115
03116 TH2F *hStripVsPlane2Ent=new TH2F("hStripVsPlane2Ent",
03117 "Number Entries (StripEnd=kPos=kWest)",
03118 planeMax-planeMin,planeMin,planeMax,
03119 bins,firstStripBin,lastStripBin);
03120 hStripVsPlane2Ent->GetXaxis()->SetTitle("Plane");
03121 hStripVsPlane2Ent->GetXaxis()->CenterTitle();
03122 hStripVsPlane2Ent->GetYaxis()->SetTitle("Strip");
03123 hStripVsPlane2Ent->GetYaxis()->CenterTitle();
03124 hStripVsPlane2Ent->SetFillColor(0);
03125 hStripVsPlane2Ent->SetMinimum(-2);
03126
03127
03128
03129 PlexPlaneId* planeId;
03130
03134
03135 for (Int_t pl=planeMin;pl<planeMax;pl++){
03136
03137
03138 if (detectorType==Detector::kFar){
03139 planeId=new PlexPlaneId(Detector::kFar,pl);
03140 }
03141 else if (detectorType==Detector::kCalDet){
03142 planeId=new PlexPlaneId(Detector::kCalDet,pl);
03143 }
03144 else{
03145 planeId=new PlexPlaneId(Detector::kNear,pl);
03146 }
03147
03148 MSG("LIPlexMaps",Msg::kInfo)
03149 <<"pl="<<pl<<", gPl="<<planeId->GetPlane()
03150 <<", view="<<planeId->GetPlaneView()
03151 <<", valid="<<planeId->IsValid()
03152 <<endl;
03153
03154 for (Int_t st=-1;st<NUMSTRIPS+2;st++){
03155 for (Int_t se=0;se<NUMSIDES;se++){
03156
03157
03158 StripEnd::EStripEnd stripEnd = StripEnd::kUnknown;
03159
03160
03161 if (se==0) stripEnd=StripEnd::kEast;
03162 else if (se==1) stripEnd=StripEnd::kWest;
03163
03164
03165 PlexStripEndId stripEndId(*planeId,st,stripEnd);
03166
03167
03168 PlexLedId ledId=plexhandle->GetLedId(stripEndId);
03169 PlexPixelSpotId pixelId=plexhandle->GetPixelSpotId(stripEndId);
03170
03171 Int_t crate=plexhandle->GetRawChannelId(stripEndId).
03172 GetCrate();
03173 Int_t varc=plexhandle->GetRawChannelId(stripEndId).GetVarcId();
03174 Int_t vmm=plexhandle->GetRawChannelId(stripEndId).GetVmm();
03175 Int_t vfb=plexhandle->GetRawChannelId(stripEndId).GetVaAdcSel();
03176 Int_t vaChip=plexhandle->GetRawChannelId(stripEndId).GetVaChip();
03177 Int_t ch=plexhandle->GetRawChannelId(stripEndId).GetVaChannel();
03178
03179 Int_t masterCh=plexhandle->GetRawChannelId(stripEndId).
03180 GetMasterChannel();
03181 Int_t minderCh=plexhandle->GetRawChannelId(stripEndId).
03182 GetMinderChannel();
03183 Int_t geoAdd=plexhandle->GetRawChannelId(stripEndId).
03184 GetGeographicAddress();
03185
03186 if (geoAdd>60000) geoAdd=-1;
03187 if (masterCh>60000) masterCh=-1;
03188 if (minderCh>60000) minderCh=-1;
03189
03190 if (varc>60000) varc=-1;
03191 if (vmm>60000) vmm=-1;
03192 if (vfb>60000) vfb=-1;
03193 if (vaChip>60000) vaChip=-1;
03194 if (ch>60000) ch=-1;
03195
03196
03197 Int_t led=static_cast<Int_t>(ledId.GetLedInBox());
03198 Int_t pix=static_cast<Int_t>(pixelId.GetPixel());
03199 Int_t spot=pixelId.GetSpot();
03200
03201 MSG("LIPlexMaps",Msg::kVerbose)
03202 <<"st="<<st<<", gSt="<<stripEndId.GetStrip()
03203 <<", end="<<stripEndId.GetEnd()
03204 <<", val="<<stripEndId.IsValid()
03205 <<", gled="<<led
03206 <<", gpB="<<ledId.GetPulserBox()
03207 <<", val="<<ledId.IsValid()
03208 <<", pixel="<<pix
03209 <<", val="<<pixelId.IsValid()
03210 <<endl;
03211
03212 if (se==0){
03213
03214 hStripVsPlanePix->Fill(pl,st,pix);
03215 hStripVsPlaneSpot->Fill(pl,st,spot);
03216 hStripVsPlaneCrate->Fill(pl,st,crate);
03217 hStripVsPlaneVarc->Fill(pl,st,varc);
03218 hStripVsPlaneVmm->Fill(pl,st,vmm);
03219 hStripVsPlaneVfb->Fill(pl,st,vfb);
03220 hStripVsPlaneVaChip->Fill(pl,st,vaChip);
03221 hStripVsPlaneCh->Fill(pl,st,ch);
03222 hStripVsPlaneGeoAdd->Fill(pl,st,geoAdd);
03223 hStripVsPlaneMasterCh->Fill(pl,st,masterCh);
03224 hStripVsPlaneMinderCh->Fill(pl,st,minderCh);
03225 hStripVsPlaneLed->Fill(pl,st,led);
03226 hStripVsPlaneEnt->Fill(pl,st,1.);
03227 }
03228 else if (se==1){
03229
03230 hStripVsPlane2Pix->Fill(pl,st,pix);
03231 hStripVsPlane2Spot->Fill(pl,st,spot);
03232 hStripVsPlane2Crate->Fill(pl,st,crate);
03233 hStripVsPlane2Varc->Fill(pl,st,varc);
03234 hStripVsPlane2Vmm->Fill(pl,st,vmm);
03235 hStripVsPlane2Vfb->Fill(pl,st,vfb);
03236 hStripVsPlane2VaChip->Fill(pl,st,vaChip);
03237 hStripVsPlane2Ch->Fill(pl,st,ch);
03238 hStripVsPlane2GeoAdd->Fill(pl,st,geoAdd);
03239 hStripVsPlane2MasterCh->Fill(pl,st,masterCh);
03240 hStripVsPlane2MinderCh->Fill(pl,st,minderCh);
03241 hStripVsPlane2Led->Fill(pl,st,led);
03242 hStripVsPlane2Ent->Fill(pl,st,1.);
03243 }
03244 }
03245 }
03246 }
03247
03251
03252
03253 gStyle->SetOptStat(0);
03254
03255 Int_t draw=1;
03256 if (draw==1){
03257 TCanvas *cStripVsPlaneLed=new TCanvas
03258 ("cStripVsPlaneLed","StripVsPlane: Led",0,0,1000,800);
03259 cStripVsPlaneLed->SetFillColor(0);
03260 cStripVsPlaneLed->cd();
03261 hStripVsPlaneLed->Draw("colz");
03262
03263 TCanvas *cStripVsPlanePix=new TCanvas
03264 ("cStripVsPlanePix","StripVsPlane: Pixel",0,0,1000,800);
03265 cStripVsPlanePix->SetFillColor(0);
03266 cStripVsPlanePix->cd();
03267 hStripVsPlanePix->Draw("textcolz");
03268
03269 TCanvas *cStripVsPlaneCrate=new TCanvas
03270 ("cStripVsPlaneCrate","StripVsPlane: Crate",0,0,1000,800);
03271 cStripVsPlaneCrate->SetFillColor(0);
03272 cStripVsPlaneCrate->cd();
03273 hStripVsPlaneCrate->Draw("textcolz");
03274
03275 TCanvas *cStripVsPlaneVarc=new TCanvas
03276 ("cStripVsPlaneVarc","StripVsPlane: Varc",0,0,1000,800);
03277 cStripVsPlaneVarc->SetFillColor(0);
03278 cStripVsPlaneVarc->cd();
03279 hStripVsPlaneVarc->Draw("textcolz");
03280
03281 TCanvas *cStripVsPlaneVmm=new TCanvas
03282 ("cStripVsPlaneVmm","StripVsPlane: Vmm",0,0,1000,800);
03283 cStripVsPlaneVmm->SetFillColor(0);
03284 cStripVsPlaneVmm->cd();
03285 hStripVsPlaneVmm->Draw("textcolz");
03286
03287 TCanvas *cStripVsPlaneVfb=new TCanvas
03288 ("cStripVsPlaneVfb","StripVsPlane: Vfb",0,0,1000,800);
03289 cStripVsPlaneVfb->SetFillColor(0);
03290 cStripVsPlaneVfb->cd();
03291 hStripVsPlaneVfb->Draw("textcolz");
03292
03293 TCanvas *cStripVsPlaneVaChip=new TCanvas
03294 ("cStripVsPlaneVaChip","StripVsPlane: VaChip",0,0,1000,800);
03295 cStripVsPlaneVaChip->SetFillColor(0);
03296 cStripVsPlaneVaChip->cd();
03297 hStripVsPlaneVaChip->Draw("textcolz");
03298
03299 TCanvas *cStripVsPlaneCh=new TCanvas
03300 ("cStripVsPlaneCh","StripVsPlane: Ch",0,0,1000,800);
03301 cStripVsPlaneCh->SetFillColor(0);
03302 cStripVsPlaneCh->cd();
03303 hStripVsPlaneCh->Draw("textcolz");
03304
03305 TCanvas *cStripVsPlaneGeoAdd=new TCanvas
03306 ("cStripVsPlaneGeoAdd","StripVsPlane: GeoAdd",0,0,1000,800);
03307 cStripVsPlaneGeoAdd->SetFillColor(0);
03308 cStripVsPlaneGeoAdd->cd();
03309 hStripVsPlaneGeoAdd->Draw("textcolz");
03310
03311 TCanvas *cStripVsPlaneMasterCh=new TCanvas
03312 ("cStripVsPlaneMasterCh","StripVsPlane: Master Channel",
03313 0,0,1000,800);
03314 cStripVsPlaneMasterCh->SetFillColor(0);
03315 cStripVsPlaneMasterCh->cd();
03316 hStripVsPlaneMasterCh->Draw("textcolz");
03317
03318 }
03319
03320 TCanvas *cStripVsPlaneMinderCh=new TCanvas
03321 ("cStripVsPlaneMinderCh","StripVsPlane: MinderCh",0,0,1000,800);
03322 cStripVsPlaneMinderCh->SetFillColor(0);
03323 cStripVsPlaneMinderCh->cd();
03324 hStripVsPlaneMinderCh->Draw("textcolz");
03325
03326 TCanvas *cStripVsPlaneSpot=new TCanvas
03327 ("cStripVsPlaneSpot","StripVsPlane: Spot",0,0,1000,800);
03328 cStripVsPlaneSpot->SetFillColor(0);
03329 cStripVsPlaneSpot->cd();
03330 hStripVsPlaneSpot->Draw("textcolz");
03331
03332 TCanvas *cStripVsPlaneEnt=new TCanvas
03333 ("cStripVsPlaneEnt","StripVsPlane: NumEntries",0,0,1000,800);
03334 cStripVsPlaneEnt->SetFillColor(0);
03335 cStripVsPlaneEnt->cd();
03336 hStripVsPlaneEnt->Draw("textcolz");
03337
03338
03340
03342
03343 TCanvas *cStripVsPlane2Led=new TCanvas
03344 ("cStripVsPlane2Led","StripVsPlane2: Led",0,0,1000,800);
03345 cStripVsPlane2Led->SetFillColor(0);
03346 cStripVsPlane2Led->cd();
03347 hStripVsPlane2Led->Draw("colz");
03348
03349 TCanvas *cStripVsPlane2Pix=new TCanvas
03350 ("cStripVsPlane2Pix","StripVsPlane2: Pixel",0,0,1000,800);
03351 cStripVsPlane2Pix->SetFillColor(0);
03352 cStripVsPlane2Pix->cd();
03353 hStripVsPlane2Pix->Draw("textcolz");
03354
03355 TCanvas *cStripVsPlane2Crate=new TCanvas
03356 ("cStripVsPlane2Crate","StripVsPlane2: Crate",0,0,1000,800);
03357 cStripVsPlane2Crate->SetFillColor(0);
03358 cStripVsPlane2Crate->cd();
03359 hStripVsPlane2Crate->Draw("textcolz");
03360
03361 TCanvas *cStripVsPlane2Varc=new TCanvas
03362 ("cStripVsPlane2Varc","StripVsPlane2: Varc",0,0,1000,800);
03363 cStripVsPlane2Varc->SetFillColor(0);
03364 cStripVsPlane2Varc->cd();
03365 hStripVsPlane2Varc->Draw("textcolz");
03366
03367 TCanvas *cStripVsPlane2Vmm=new TCanvas
03368 ("cStripVsPlane2Vmm","StripVsPlane2: Vmm",0,0,1000,800);
03369 cStripVsPlane2Vmm->SetFillColor(0);
03370 cStripVsPlane2Vmm->cd();
03371 hStripVsPlane2Vmm->Draw("textcolz");
03372
03373 TCanvas *cStripVsPlane2Vfb=new TCanvas
03374 ("cStripVsPlane2Vfb","StripVsPlane2: Vfb",0,0,1000,800);
03375 cStripVsPlane2Vfb->SetFillColor(0);
03376 cStripVsPlane2Vfb->cd();
03377 hStripVsPlane2Vfb->Draw("textcolz");
03378
03379 TCanvas *cStripVsPlane2VaChip=new TCanvas
03380 ("cStripVsPlane2VaChip","StripVsPlane2: VaChip",0,0,1000,800);
03381 cStripVsPlane2VaChip->SetFillColor(0);
03382 cStripVsPlane2VaChip->cd();
03383 hStripVsPlane2VaChip->Draw("textcolz");
03384
03385 TCanvas *cStripVsPlane2Ch=new TCanvas
03386 ("cStripVsPlane2Ch","StripVsPlane2: Ch",0,0,1000,800);
03387 cStripVsPlane2Ch->SetFillColor(0);
03388 cStripVsPlane2Ch->cd();
03389 hStripVsPlane2Ch->Draw("textcolz");
03390
03391 TCanvas *cStripVsPlane2GeoAdd=new TCanvas
03392 ("cStripVsPlane2GeoAdd","StripVsPlane2: GeoAdd",0,0,1000,800);
03393 cStripVsPlane2GeoAdd->SetFillColor(0);
03394 cStripVsPlane2GeoAdd->cd();
03395 hStripVsPlane2GeoAdd->Draw("textcolz");
03396
03397 TCanvas *cStripVsPlane2MasterCh=new TCanvas
03398 ("cStripVsPlane2MasterCh","StripVsPlane2: Master Channel",
03399 0,0,1000,800);
03400 cStripVsPlane2MasterCh->SetFillColor(0);
03401 cStripVsPlane2MasterCh->cd();
03402 hStripVsPlane2MasterCh->Draw("textcolz");
03403
03404 TCanvas *cStripVsPlane2MinderCh=new TCanvas
03405 ("cStripVsPlane2MinderCh","StripVsPlane2: MinderCh",0,0,1000,800);
03406 cStripVsPlane2MinderCh->SetFillColor(0);
03407 cStripVsPlane2MinderCh->cd();
03408 hStripVsPlane2MinderCh->Draw("textcolz");
03409
03410 TCanvas *cStripVsPlane2Spot=new TCanvas
03411 ("cStripVsPlane2Spot","StripVsPlane2: Spot",0,0,1000,800);
03412 cStripVsPlane2Spot->SetFillColor(0);
03413 cStripVsPlane2Spot->cd();
03414 hStripVsPlane2Spot->Draw("textcolz");
03415
03416 TCanvas *cStripVsPlane2Ent=new TCanvas
03417 ("cStripVsPlane2Ent","StripVsPlane2: NumEntries",0,0,1000,800);
03418 cStripVsPlane2Ent->SetFillColor(0);
03419 cStripVsPlane2Ent->cd();
03420 hStripVsPlane2Ent->Draw("textcolz");
03421
03422 MSG("LIPlexMaps",Msg::kInfo)
03423 <<endl<<" ** Finished the PlotPlexStripMap method ** "
03424 <<endl;
03425 }
03426
03427
03428
03429 void LIPlexMaps::MakePinPlexTables()
03430 {
03431 MSG("LIPlexMaps",Msg::kInfo)
03432 <<endl<<" ** Running the MakePinPlexTables() method... ** "
03433 <<endl;
03434
03435
03436
03437
03438 VldTimeStamp farpinstart = VldTimeStamp(2000,1,1,12,0,0);
03439 VldTimeStamp farpinend = VldTimeStamp(2010,1,1,12,0,0);
03440 VldRange farpinvr(Detector::kFar,SimFlag::kData,farpinstart,
03441 farpinend,"LIPlexMaps");
03442 VldTimeStamp create;
03443 VldContext vc(Detector::kFar,SimFlag::kData,create);
03444 PlexHandle plexHandle(vc);
03445
03446 for(Int_t pb=0;pb<NUMPULSERBOXES;pb++){
03447 for(Int_t led=1;led<=LASTPULSERBOX;led++){
03448
03449 PlexLedId ledId(Detector::kFar,pb,led);
03450
03451 int aggNo = 0x7ff & ledId.GetEncoded();
03452
03453 DbiWriter<PlexPinDiodeToLed> writer(farpinvr,aggNo,0,create);
03454
03455 std::pair<PlexPinDiodeId,PlexPinDiodeId> newPins=fLookup.
03456 GetPinDiodeIds(plexHandle,ledId.GetLedInBox());
03457
03458 PlexPinDiodeToLed hpin2led(newPins.first.GetDetector(),
03459 newPins.first.GetElecType(),
03460 newPins.first.GetEastWest(),
03461 newPins.first.GetRackLevel(),
03462 newPins.first.GetRackBay(),
03463 newPins.first.GetInRack(),
03464 newPins.first.GetInBox(),
03465 newPins.first.GetGain(),
03466 ledId.GetPulserBox(),
03467 ledId.GetLedInBox());
03468 PlexPinDiodeToLed lpin2led(newPins.second.GetDetector(),
03469 newPins.second.GetElecType(),
03470 newPins.second.GetEastWest(),
03471 newPins.second.GetRackLevel(),
03472 newPins.second.GetRackBay(),
03473 newPins.second.GetInRack(),
03474 newPins.second.GetInBox(),
03475 newPins.second.GetGain(),
03476 ledId.GetPulserBox(),
03477 ledId.GetLedInBox());
03478 writer <<hpin2led;
03479 writer <<lpin2led;
03480
03481 }
03482 }
03483
03484 MSG("LIPlexMaps",Msg::kInfo)
03485 <<endl<<" ** Finished the MakePinPlexTables() method... ** "
03486 <<endl;
03487 }
03488
03489
03490
03491 void LIPlexMaps::MakeCalAdcToPe(string sGainsFileName,
03492 Detector::Detector_t det,
03493 SimFlag::ESimFlag simFlag,
03494 VldTimeStamp vldStart,
03495 VldTimeStamp vldEnd,
03496 Int_t aggNo,
03497 Int_t task,
03498 Int_t aggStat[484],
03499 VldTimeStamp creationDate,
03500 std::string dbName,
03501 std::string sLogComment,
03502 Int_t gainTooHigh,Int_t gainCeiling,
03503 Bool_t writeToDb)
03504 {
03505 MSG("LIPlexMaps",Msg::kInfo)
03506 <<endl<<" ** Running the MakeCalAdcToPe() method... **"<<endl;
03507
03508
03509
03510
03511
03512
03513
03514
03515
03516
03517
03518
03519
03520
03521
03522
03523
03524
03525
03526
03527
03528
03529
03530
03531
03532
03533
03534
03535
03536
03537
03538
03539
03540
03541
03542
03543
03544
03545
03546
03547
03548
03549
03550
03551
03552
03553
03554
03555
03556
03557
03558
03559
03560
03561 this->SetDetector(det);
03562
03563
03564 MSG("LIPlexMaps",Msg::kInfo)<<"Getting plex handle..."<<endl;
03565 VldContext vldCtx(det,SimFlag::kData,creationDate);
03566 PlexHandle plexHandle(vldCtx);
03567
03568 gStyle->SetOptStat(1111111);
03569
03570 TH1F *hGain=new TH1F("hGain","PMT Gains",300,-1,gainTooHigh);
03571 hGain->GetXaxis()->SetTitle("PMT Gain");
03572 hGain->GetXaxis()->CenterTitle();
03573 hGain->GetYaxis()->SetTitle("");
03574 hGain->GetYaxis()->CenterTitle();
03575 hGain->SetLineColor(2);
03576 hGain->SetFillStyle(3015);
03577 hGain->SetFillColor(2);
03578 hGain->SetLineWidth(2);
03579
03580
03581 TH1F *hGainHighPmt=new TH1F("hGainHighPmt","PMT Gains: HighPmts",
03582 100,gainTooHigh,gainCeiling+5);
03583 hGainHighPmt->GetXaxis()->SetTitle("PMT Gain");
03584 hGainHighPmt->GetXaxis()->CenterTitle();
03585 hGainHighPmt->GetYaxis()->SetTitle("");
03586 hGainHighPmt->GetYaxis()->CenterTitle();
03587 hGainHighPmt->SetLineColor(2);
03588 hGainHighPmt->SetFillStyle(3015);
03589 hGainHighPmt->SetFillColor(2);
03590 hGainHighPmt->SetLineWidth(2);
03591
03592
03593 TH1F *hGainCrazyHighPmt=new TH1F("hGainCrazyHighPmt",
03594 "PMT Gains: CrazyHighPmts",
03595 200,gainCeiling,gainCeiling+100);
03596 hGainCrazyHighPmt->GetXaxis()->SetTitle("PMT Gain");
03597 hGainCrazyHighPmt->GetXaxis()->CenterTitle();
03598 hGainCrazyHighPmt->GetYaxis()->SetTitle("");
03599 hGainCrazyHighPmt->GetYaxis()->CenterTitle();
03600 hGainCrazyHighPmt->SetLineColor(2);
03601 hGainCrazyHighPmt->SetFillStyle(3015);
03602 hGainCrazyHighPmt->SetFillColor(2);
03603 hGainCrazyHighPmt->SetLineWidth(2);
03604 hGainCrazyHighPmt->SetBit(TH1::kCanRebin);
03605
03606 TH1F *hGainAvDet=new TH1F("hGainAvDet","PMT Gains in Av Detector PMT",
03607 100,55,85);
03608 hGainAvDet->GetXaxis()->SetTitle("PMT Gain");
03609 hGainAvDet->GetXaxis()->CenterTitle();
03610 hGainAvDet->GetYaxis()->SetTitle("");
03611 hGainAvDet->GetYaxis()->CenterTitle();
03612 hGainAvDet->SetLineColor(2);
03613 hGainAvDet->SetFillStyle(3015);
03614 hGainAvDet->SetFillColor(2);
03615 hGainAvDet->SetLineWidth(2);
03616 hGainAvDet->SetBit(TH1::kCanRebin);
03617
03618 TH1F *hGainErr=new TH1F("hGainErr","PMT GainErrs",
03619 400,0,110);
03620 hGainErr->GetXaxis()->SetTitle("PMT GainErr");
03621 hGainErr->GetXaxis()->CenterTitle();
03622 hGainErr->GetYaxis()->SetTitle("");
03623 hGainErr->GetYaxis()->CenterTitle();
03624 hGainErr->SetLineColor(2);
03625 hGainErr->SetFillStyle(3015);
03626 hGainErr->SetFillColor(2);
03627 hGainErr->SetLineWidth(5);
03628 hGainErr->SetBit(TH1::kCanRebin);
03629
03630 TH1F *hGainErrZoom=new TH1F("hGainErrZoom","PMT GainErrs (Zoomed)",
03631 400,0,10);
03632 hGainErrZoom->GetXaxis()->SetTitle("PMT GainErrZoom");
03633 hGainErrZoom->GetXaxis()->CenterTitle();
03634 hGainErrZoom->GetYaxis()->SetTitle("");
03635 hGainErrZoom->GetYaxis()->CenterTitle();
03636 hGainErrZoom->SetLineColor(2);
03637 hGainErrZoom->SetFillStyle(3015);
03638 hGainErrZoom->SetFillColor(2);
03639 hGainErrZoom->SetLineWidth(2);
03640
03641
03642 TH1F *hGainErrFract=new TH1F("hGainErrFract",
03643 "Fractional PMT GainErrs",
03644 800,0.005,0.05);
03645 hGainErrFract->GetXaxis()->SetTitle("Fractional PMT GainErr");
03646 hGainErrFract->GetXaxis()->CenterTitle();
03647 hGainErrFract->GetYaxis()->SetTitle("");
03648 hGainErrFract->GetYaxis()->CenterTitle();
03649 hGainErrFract->SetLineColor(2);
03650 hGainErrFract->SetFillStyle(3015);
03651 hGainErrFract->SetFillColor(2);
03652 hGainErrFract->SetLineWidth(2);
03653
03654
03655 TH1F *hSPEWidth=new TH1F("hSPEWidth","PMT SPEWidths",
03656 300,0,gainCeiling/2+5);
03657 hSPEWidth->GetXaxis()->SetTitle("PMT SPEWidth");
03658 hSPEWidth->GetXaxis()->CenterTitle();
03659 hSPEWidth->GetYaxis()->SetTitle("");
03660 hSPEWidth->GetYaxis()->CenterTitle();
03661 hSPEWidth->SetLineColor(2);
03662 hSPEWidth->SetFillStyle(3015);
03663 hSPEWidth->SetFillColor(2);
03664 hSPEWidth->SetLineWidth(2);
03665
03666
03667 Int_t* planeMax=new Int_t[NUMCRATES];
03668 Int_t* planeMin=new Int_t[NUMCRATES];
03669 fLookup.SetPbPlanes(planeMin,planeMax,det);
03670
03671 const Int_t firstStripBin=FIRSTSTRIP-8;
03672 const Int_t lastStripBin=LASTSTRIP+9;
03673 const Int_t bins=lastStripBin-firstStripBin;
03674
03675 TH2F **hStripVsPlaneGain=0;
03676 hStripVsPlaneGain= new TH2F*[NUMCRATES];
03677 for (Int_t i=0;i<NUMCRATES;i++){
03678 string sPb=Form("%d",i);
03679 fS="Gains (Crate "+sPb+")";
03680 hStripVsPlaneGain[i]=new TH2F(fS.c_str(),fS.c_str(),
03681 planeMax[i]-planeMin[i],
03682 planeMin[i],planeMax[i],
03683 bins,firstStripBin,lastStripBin);
03684 hStripVsPlaneGain[i]->GetXaxis()->SetTitle("Plane");
03685 hStripVsPlaneGain[i]->GetXaxis()->CenterTitle();
03686 hStripVsPlaneGain[i]->GetYaxis()->SetTitle("Strip");
03687 hStripVsPlaneGain[i]->GetYaxis()->CenterTitle();
03688 hStripVsPlaneGain[i]->SetFillColor(0);
03689
03690 }
03691
03692 TH2F **hStripVsPlaneGainErr=0;
03693 hStripVsPlaneGainErr= new TH2F*[NUMCRATES];
03694 for (Int_t i=0;i<NUMCRATES;i++){
03695 string sPb=Form("%d",i);
03696 fS="Gain Errors (Crate "+sPb+")";
03697 hStripVsPlaneGainErr[i]=new TH2F(fS.c_str(),fS.c_str(),
03698 planeMax[i]-planeMin[i],
03699 planeMin[i],planeMax[i],
03700 bins,firstStripBin,lastStripBin);
03701 hStripVsPlaneGainErr[i]->GetXaxis()->SetTitle("Plane");
03702 hStripVsPlaneGainErr[i]->GetXaxis()->CenterTitle();
03703 hStripVsPlaneGainErr[i]->GetYaxis()->SetTitle("Strip");
03704 hStripVsPlaneGainErr[i]->GetYaxis()->CenterTitle();
03705 hStripVsPlaneGainErr[i]->SetFillColor(0);
03706
03707 }
03708
03709 TH2F **hStripVsPlaneSPEWidth=0;
03710 hStripVsPlaneSPEWidth= new TH2F*[NUMCRATES];
03711 for (Int_t i=0;i<NUMCRATES;i++){
03712 string sPb=Form("%d",i);
03713 fS="Single PE Width (Crate "+sPb+")";
03714 hStripVsPlaneSPEWidth[i]=new TH2F(fS.c_str(),fS.c_str(),
03715 planeMax[i]-planeMin[i],
03716 planeMin[i],planeMax[i],
03717 bins,firstStripBin,lastStripBin);
03718 hStripVsPlaneSPEWidth[i]->GetXaxis()->SetTitle("Plane");
03719 hStripVsPlaneSPEWidth[i]->GetXaxis()->CenterTitle();
03720 hStripVsPlaneSPEWidth[i]->GetYaxis()->SetTitle("Strip");
03721 hStripVsPlaneSPEWidth[i]->GetYaxis()->CenterTitle();
03722 hStripVsPlaneSPEWidth[i]->SetFillColor(0);
03723
03724 }
03725
03726 vector<Float_t> vGains(NUMPLANES*NUMSTRIPS*NUMENDS,0);
03727 vector<Float_t> vGainErrs(NUMPLANES*NUMSTRIPS*NUMENDS,0);
03728 vector<Float_t> vSPEWidths(NUMPLANES*NUMSTRIPS*NUMENDS,0);
03729 vector<Float_t> vSPEWidthErrs(NUMPLANES*NUMSTRIPS*NUMENDS,0);
03730 map<UInt_t,LIPmt> pmts;
03731 LIPmt avDetPmt;
03732 avDetPmt.Initialise(NUMPIXELS,NUMPIXELSPOTS);
03733
03734
03735 Double_t gainAvDet=0;
03736 Double_t gainErrAvDet=0;
03737 Int_t gainNum=0;
03738
03739 Float_t gainErrUnknownPixelSpot=10;
03740 Float_t gainErrUnknownPixel=40;
03741 Float_t gainErrUnknownNN=50;
03742 Float_t gainErrUnknownPmt=100;
03743 Float_t gainErrTooHighGain=90;
03744 Float_t SPEWidthFraction=0.5;
03745
03746
03747 MSG("LIPlexMaps",Msg::kInfo)
03748 <<"Opening file "<<sGainsFileName<<"..."<<endl;
03749 ifstream gainsFile(sGainsFileName.c_str());
03750
03751
03752 if (gainsFile){
03753
03754
03755 Int_t plane=-1;
03756 Int_t strip=-1;
03757 Int_t end=-1;
03758 Float_t gain=-1;
03759 Float_t gainErr=-1;
03760 Float_t SPEWidth=-1;
03761
03762
03763 Int_t lastPlane=-1;
03764
03765
03766 while(gainsFile>>plane>>strip>>end>>gain>>gainErr>>SPEWidth) {
03767
03768 Int_t seIndex=plane*NUMSTRIPS*NUMENDS+strip*NUMENDS+end-1;
03769
03770 if (plane<FIRSTPLANE || plane>LASTPLANE || strip<FIRSTSTRIP ||
03771 strip>LASTSTRIP || end<FIRSTEND || end>LASTEND){
03772 MSG("LIPlexMaps",Msg::kWarning)
03773 <<"Plane, strip or stripend are out of range: plane="<<plane
03774 <<", strip="<<strip<<", end="<<end<<endl
03775 <<"Detector type is set to "<<Detector::AsString(det)
03776 <<endl
03777 <<"Program will exit here..."<<endl;
03778 exit(1);
03779 }
03780
03781
03782 if (plane!=lastPlane && plane%20==0){
03783 MSG("LIPlexMaps",Msg::kInfo)<<"New plane="<<plane<<endl;
03784 }
03785 else if (plane!=lastPlane){
03786 MSG("LIPlexMaps",Msg::kDebug)<<"New plane="<<plane<<endl;
03787 }
03788 lastPlane=plane;
03789
03790
03791 vGains[seIndex]=gain;
03792 vGainErrs[seIndex]=gainErr;
03793 vSPEWidths[seIndex]=SPEWidth;
03794 vSPEWidthErrs[seIndex]=0.5;
03795
03796
03797 if (gain>-1 && gain<2){
03798 MSG("LIPlexMaps",Msg::kWarning)
03799 <<"What sort of gain is this? gain="<<gain<<endl;
03800 }
03801
03802
03803 PlexStripEndId seid(det,plane,strip,
03804 static_cast<StripEnd::EStripEnd>(end));
03805
03806 PlexPixelSpotId pixSpotId=plexHandle.GetPixelSpotId(seid);
03807
03808 MSG("LIPlexMaps",Msg::kVerbose)
03809 <<"("<<plane<<":"<<strip<<":"<<end<<") "
03810 <<pixSpotId.AsString()<<endl;
03811
03812 UInt_t pmtKey=pixSpotId.GetUniquePmtEncodedValue();
03813
03814 pmts[pmtKey].Initialise(NUMPIXELS,NUMPIXELSPOTS);
03815
03816
03817 if (gain>-1){
03818 gainErrAvDet+=gainErr;
03819 gainAvDet+=gain;
03820 gainNum++;
03821
03822 if (pixSpotId.GetSpot()<1){
03823 seid.Print();
03824 pixSpotId.Print();
03825 }
03826
03827 pmts[pmtKey].SetPoint(pixSpotId.GetPixel(),pixSpotId.GetSpot(),
03828 gain);
03829
03830 avDetPmt.AddMultiPoint(pixSpotId.GetPixel(),pixSpotId.GetSpot(),
03831 gain);
03832 }
03833 }
03834 }
03835 else{
03836 MSG("LIPlexMaps",Msg::kInfo)
03837 <<"Can't open file "<<sGainsFileName<<endl
03838 <<"Exiting here..."<<endl;
03839 exit(1);
03840 }
03841
03842 MSG("LIPlexMaps",Msg::kInfo) << "All detector gain="<<gainAvDet<<", gainErr="<<gainErrAvDet<<endl;
03843 if (gainNum!=0) gainAvDet/=gainNum;
03844 if (gainNum!=0) gainErrAvDet/=gainNum;
03845 MSG("LIPlexMaps",Msg::kInfo)
03846 <<"AverageDetector: gain= "<<gainAvDet<<" gainErr= "<<gainErrAvDet
03847 <<" gainNum= "<<gainNum
03848 <<" Npmts= "<<pmts.size()<<endl;
03849
03850 avDetPmt.FillGainsHisto(hGainAvDet);
03851
03853
03855
03856 Int_t pixCounter=0;
03857 Int_t nnCounter=0;
03858 Int_t pmtCounter=0;
03859 Int_t detCounter=0;
03860 Int_t gainHighCounter=0;
03861 Int_t gainCappedCounter=0;
03862 Int_t totalCounter=0;
03863 Int_t goodCounter=0;
03864
03865 Int_t pixgainHighCounter=0;
03866 Int_t pixgainCappedCounter=0;
03867 Int_t nngainHighCounter=0;
03868 Int_t nngainCappedCounter=0;
03869 Int_t pmtgainHighCounter=0;
03870 Int_t pmtgainCappedCounter=0;
03871 Int_t detgainHighCounter=0;
03872 Int_t detgainCappedCounter=0;
03873
03874
03875 VldRange vr(det,simFlag,vldStart,vldEnd,
03876 "LISummary/LIPlexMaps::MakeCalAdcToPe");
03877
03878 MSG("LIPlexMaps",Msg::kInfo)
03879 <<"Using Validity Range: "<<vr.AsString()<<endl;
03880
03881 MSG("LIPlexMaps",Msg::kInfo)
03882 <<endl<<"Log comment="<<sLogComment<<endl<<endl;
03883
03884
03885 DbiWriter<CalADCtoPE> writer(vr,aggNo,task,creationDate,dbName,
03886 sLogComment);
03887
03888 Int_t NUMAGG = NUMCRATES; if(task==1) { NUMAGG = 484; if(det==1) NUMAGG = 194; }
03889 for(Int_t agg=0;agg<NUMAGG;agg++){
03890 if(aggStat[agg]<0) continue;
03891
03892
03893 if(aggNo==-1) agg = NUMAGG-1;
03894 DbiWriter<CalADCtoPEs> writers(vr,agg,task,creationDate,dbName,sLogComment);
03895
03896 Int_t pixCounter2=0;
03897 Int_t nnCounter2=0;
03898 Int_t pmtCounter2=0;
03899 Int_t detCounter2=0;
03900 Int_t gainHighCounter2=0;
03901 Int_t gainCappedCounter2=0;
03902 Int_t totalCounter2=0;
03903 Int_t goodCounter2=0;
03904
03905
03906 for(Int_t pl=FIRSTSCINTPLANE;pl<=LASTSCINTPLANE;pl++){
03907 for(Int_t st=FIRSTSTRIP;st<=LASTSTRIP;st++){
03908 for(Int_t end=FIRSTEND;end<=SECONDEND;end++) {
03909
03910
03911 if ((pl==SM1BOOKEND || pl==SM2BOOKEND) &&
03912 det==Detector::kFar) continue;
03913
03914
03915
03916
03917
03918 Int_t seIndex=pl*NUMSTRIPS*NUMENDS+st*NUMENDS+end-1;
03919
03920
03921 PlexStripEndId seid(det,pl,st,
03922 static_cast<StripEnd::EStripEnd>(end));
03923
03924
03925 if (!seid.IsValid() ) continue;
03926
03927
03928
03929
03930 if (det==Detector::kNear) {
03931 if (((pl-1)%5) && (pl%2) && st>63) continue;
03932 if (((pl-1)%5) && (pl%2)==0 && st<4 ) continue;
03933 }
03934
03935
03936 Int_t crate=plexHandle.GetRawChannelId(seid).GetCrate();
03937 PlexPixelSpotId pixSpotId=plexHandle.GetPixelSpotId(seid);
03938 if (aggNo!=-1 && ((task==0 && crate!=agg) || (task==1 && static_cast<Int_t>(pixSpotId.GetNumericMuxBox())!=LILookup::GetNumericMuxBox(agg)))) continue;
03939
03940 if(vGains[seIndex]==-1){
03941
03942 Int_t pmtKey=pixSpotId.GetUniquePmtEncodedValue();
03943
03944
03945 Double_t pmtGain=pmts[pmtKey].GetAvPmtGain();
03946 Int_t pmtNum=pmts[pmtKey].GetPmtNum();
03947 Double_t pixelGain=pmts[pmtKey].GetPixelGain(pixSpotId.
03948 GetPixel());
03949 Int_t pixelNum=pmts[pmtKey].GetPixelNum(pixSpotId.GetPixel());
03950 Double_t nnGain=pmts[pmtKey].
03951 GetNearestNeighboursAvGain(pixSpotId.GetPixel());
03952 Int_t nnNum=pmts[pmtKey].
03953 GetNearestNeighboursNum(pixSpotId.GetPixel());
03954
03955 Bool_t pixGood=false;
03956 Bool_t nnGood=false;
03957 Bool_t pmtGood=false;
03958
03959 if (pixelNum>0 && pixelGain>0) pixGood=true;
03960 if (nnNum>0 && nnGain>0) nnGood=true;
03961 if (pmtNum>0 && pmtGain>0) pmtGood=true;
03962
03963 if (pixGood){
03964 pixCounter++; pixCounter2++;
03965 vGains[seIndex]=pixelGain;
03966 vGainErrs[seIndex]=gainErrUnknownPixelSpot;
03967 vSPEWidths[seIndex]=SPEWidthFraction*vGains[seIndex];
03968 if (MsgService::Instance()->
03969 IsActive("LIPlexMaps",Msg::kDebug)){
03970 MSG("LIPlexMaps",Msg::kInfo)
03971 <<"("<<pl<<":"<<st<<":"<<end<<")"
03972 <<" No Data: Setting gain to be average of pixel ("
03973 <<vGains[seIndex]<<")"<<endl
03974 <<" pixGain="<<pixelGain<<" (N="<<pixelNum
03975 <<"), nnGain="<<nnGain<<" (N="<<nnNum
03976 <<"), pmtGain="<<pmtGain<<", (N="<<pmtNum<<")"<<endl;
03977 }
03978 }
03979 else if (nnGood){
03980 nnCounter++; nnCounter2++;
03981 vGains[seIndex]=nnGain;
03982 vGainErrs[seIndex]=gainErrUnknownPixel;
03983 vSPEWidths[seIndex]=SPEWidthFraction*vGains[seIndex];
03984 MSG("LIPlexMaps",Msg::kInfo)
03985 <<"("<<pl<<":"<<st<<":"<<end<<")"
03986 <<" No Data: Setting gain to be average of NN ("
03987 <<vGains[seIndex]<<")"<<endl
03988 <<" pixGain="<<pixelGain<<" (N="<<pixelNum
03989 <<"), nnGain="<<nnGain<<" (N="<<nnNum
03990 <<"), pmtGain="<<pmtGain<<", (N="<<pmtNum<<")"<<endl;
03991 }
03992 else if (pmtGood){
03993 pmtCounter++; pmtCounter2++;
03994 vGains[seIndex]=pmtGain;
03995 vGainErrs[seIndex]=gainErrUnknownNN;
03996 vSPEWidths[seIndex]=SPEWidthFraction*vGains[seIndex];
03997 MSG("LIPlexMaps",Msg::kInfo)
03998 <<"("<<pl<<":"<<st<<":"<<end<<")"
03999 <<" No Data: Setting gain to be average of pmt ("
04000 <<vGains[seIndex]<<")"<<endl
04001 <<" pixGain="<<pixelGain<<" (N="<<pixelNum
04002 <<"), nnGain="<<nnGain<<" (N="<<nnNum
04003 <<"), pmtGain="<<pmtGain<<", (N="<<pmtNum<<")"<<endl;
04004 }
04005 else{
04006 detCounter++; detCounter2++;
04007
04008 Double_t avDetPmtGain=avDetPmt.GetAvPmtGain();
04009 Int_t avDetPmtNum=avDetPmt.GetPmtNum();
04010 Double_t avDetPmtPixelGain=avDetPmt.
04011 GetPixelGain(pixSpotId.GetPixel());
04012 Int_t avDetPmtPixelNum=avDetPmt.
04013 GetPixelNum(pixSpotId.GetPixel());
04014
04015 Double_t avDetPmtSpotGain=avDetPmt.
04016 GetGain(pixSpotId.GetPixel(),pixSpotId.GetSpot());
04017
04018 vGains[seIndex]=avDetPmtSpotGain;
04019 vGainErrs[seIndex]=gainErrUnknownPmt;
04020 vSPEWidths[seIndex]=SPEWidthFraction*vGains[seIndex];
04021 MSG("LIPlexMaps",Msg::kInfo)
04022 <<"("<<pl<<":"<<st<<":"<<end<<")"
04023 <<" No Data: Setting gain to same spot on average pmt ("
04024 <<vGains[seIndex]<<")"<<endl
04025 <<" pixGain="<<avDetPmtPixelGain
04026 <<", pixNum="<<avDetPmtPixelNum
04027 <<", pmtGain="<<avDetPmtGain
04028 <<", pmtNum="<<avDetPmtNum<<endl;
04029 }
04030 }
04031 else{
04032 goodCounter++; goodCounter2++;
04033 }
04034
04035
04036 if(vGains[seIndex]>gainTooHigh){
04037
04038 if(vGainErrs[seIndex]!=gainErrUnknownPixelSpot && vGainErrs[seIndex]!=gainErrUnknownPixel &&
04039 vGainErrs[seIndex]!=gainErrUnknownNN && vGainErrs[seIndex]!=gainErrUnknownPmt ) {
04040
04041
04042 goodCounter--; goodCounter2--;
04043
04044 gainHighCounter++; gainHighCounter2++;
04045
04046 }
04047 if(vGainErrs[seIndex]==gainErrUnknownPixelSpot) {
04048 pixgainHighCounter++; if (vGains[seIndex]>gainCeiling) pixgainCappedCounter++;
04049 }
04050 if(vGainErrs[seIndex]==gainErrUnknownPixel) {
04051 nngainHighCounter++; if (vGains[seIndex]>gainCeiling) nngainCappedCounter++;
04052 }
04053 if(vGainErrs[seIndex]==gainErrUnknownNN) {
04054 pmtgainHighCounter++; if (vGains[seIndex]>gainCeiling) pmtgainCappedCounter++;
04055 }
04056 if(vGainErrs[seIndex]==gainErrUnknownPmt) {
04057 detgainHighCounter++; if (vGains[seIndex]>gainCeiling) detgainCappedCounter++;
04058 }
04059
04060 Int_t pmtKey=pixSpotId.GetUniquePmtEncodedValue();
04061
04062
04063 Double_t pmtGain=pmts[pmtKey].GetAvPmtGain();
04064 Int_t pmtNum=pmts[pmtKey].GetPmtNum();
04065 Double_t pixelGain=pmts[pmtKey].GetPixelGain(pixSpotId.
04066 GetPixel());
04067 Int_t pixelNum=pmts[pmtKey].GetPixelNum(pixSpotId.GetPixel());
04068
04069 if (vGains[seIndex]>gainCeiling){
04070 hGainCrazyHighPmt->Fill(vGains[seIndex]);
04071
04072 if(vGainErrs[seIndex]!=gainErrUnknownPixelSpot && vGainErrs[seIndex]!=gainErrUnknownPixel &&
04073 vGainErrs[seIndex]!=gainErrUnknownNN && vGainErrs[seIndex]!=gainErrUnknownPmt ) {
04074
04075 gainCappedCounter++; gainCappedCounter2++;
04076
04077 }
04078
04079 Float_t oldGain=vGains[seIndex];
04080 vGains[seIndex]=gainCeiling;
04081 vSPEWidths[seIndex]=SPEWidthFraction*vGains[seIndex];
04082
04083 MSG("LIPlexMaps",Msg::kInfo)
04084 <<"("<<pl<<":"<<st<<":"<<end<<")"
04085 <<" ** Capping very high gain ("<<oldGain
04086 <<") to be gainCeiling ("<<vGains[seIndex]<<")"<<endl
04087 <<" pixGain="<<pixelGain<<", pixNum="<<pixelNum
04088 <<", pmtGain="<<pmtGain<<", pmtNum="<<pmtNum<<endl;
04089 }
04090
04091
04092 vGainErrs[seIndex]=gainErrTooHighGain;
04093
04094
04095 hGainHighPmt->Fill(vGains[seIndex]);
04096 }
04097
04098
04099 CalADCtoPE calAdcToPe(seid.BuildPlnStripEndKey(),
04100 seid.GetEncoded(),vGains[seIndex],
04101 vGainErrs[seIndex],vSPEWidths[seIndex]);
04102 CalADCtoPEs calAdcToPes(agg,
04103 seid.BuildPlnStripEndKey(),vGains[seIndex],
04104 vGainErrs[seIndex],vSPEWidths[seIndex],vSPEWidthErrs[seIndex]);
04105
04106
04107 hGain->Fill(vGains[seIndex]);
04108 hGainErr->Fill(vGainErrs[seIndex]);
04109 hGainErrZoom->Fill(vGainErrs[seIndex]);
04110 hGainErrFract->Fill(vGainErrs[seIndex]/vGains[seIndex]);
04111 hSPEWidth->Fill(vSPEWidths[seIndex]);
04112
04113 if (crate>=FIRSTCRATE && crate<=LASTCRATE){
04114 hStripVsPlaneGain[crate]->Fill(pl,st,vGains[seIndex]);
04115 hStripVsPlaneGainErr[crate]->Fill(pl,st,vGainErrs[seIndex]);
04116 hStripVsPlaneSPEWidth[crate]->
04117 Fill(pl,st,vSPEWidths[seIndex]);
04118 }
04119
04120
04121 if(aggNo==-1) writer<<calAdcToPe; else writers<<calAdcToPes;
04122
04123 totalCounter++; totalCounter2++;
04124
04125 if (MsgService::Instance()->
04126 IsActive("LIPlexMaps",Msg::kVerbose)){
04127 MSG("LIPlexMaps",Msg::kInfo)
04128 <<"("<<pl<<":"<<st<<":"<<end<<")"
04129 <<" "<<vGains[seIndex]<<" "
04130 <<vGainErrs[seIndex]<<" "<<vSPEWidths[seIndex]<<endl;
04131 }
04132 }
04133 }
04134 }
04135
04136 if(aggNo!=-1) {
04137
04138 Int_t totalCounted2=goodCounter2+pixCounter2+nnCounter2+pmtCounter2+
04139 detCounter2+gainHighCounter2;
04140 Int_t numBadStripends2=totalCounted2-goodCounter2;
04141
04142 MSG("LIPlexMaps",Msg::kInfo)
04143 <<" AggNo= "<<setw(4)<<agg<<" Ntot= "<<setw(3)<<totalCounted2
04144 <<" Ngood= "<<setw(3)<<goodCounter2<<" Nbad= "<<setw(3)<<numBadStripends2
04145 <<" Npix= "<<setw(3)<<pixCounter2<<" Nnn= "<<setw(3)<<nnCounter2<<" Npmt= "<<setw(3)<<pmtCounter2<<" Ndet= "<<setw(3)<<detCounter2
04146 <<" Nhot= "<<setw(3)<<gainHighCounter2<<" Ncrazy= "<<setw(3)<<gainCappedCounter2<<endl;
04147
04148 MSG("LIPlexMaps",Msg::kInfo)
04149 <<"DbiWriters.IsOpen="<<writers.IsOpen()<<endl
04150 <<"DbiWriters.CanOuptpu="<<writers.CanOutput()<<endl;
04151
04152 if (writeToDb){
04153 if (this->IsPermitted()){
04154 MSG("LIPlexMaps",Msg::kInfo)
04155 <<"Writing to database..."<<endl;
04156
04157 writers.Close();
04158 MSG("LIPlexMaps",Msg::kInfo)
04159 <<"Finished writing to database"<<endl<<endl;
04160 }
04161 }
04162 else {
04163 MSG("LIPlexMaps",Msg::kInfo)
04164 <<"Mode is set to NOT write to database"<<endl<<endl;
04165 }
04166
04167 }
04168
04169 }
04170
04171 MSG("LIPlexMaps",Msg::kInfo)
04172 <<endl
04173 <<"Corrected_Info(mean+-rms): GainAvDet(overall)= "<<hGainAvDet->GetMean()<<" +- "<<hGainAvDet->GetRMS()
04174 <<" Gain(<"<<gainTooHigh<<")= "<<hGain->GetMean()<<" +- "<<hGain->GetRMS()
04175 <<" GainErrZoom= "<<hGainErrZoom->GetMean()<<" +- "<<hGainErrZoom->GetRMS()
04176 <<endl;
04177
04178 MSG("LIPlexMaps",Msg::kInfo)
04179 <<endl
04180 <<" ** Values used in method: **"<<endl
04181 <<" NUMPLANES="<<NUMPLANES<<endl
04182 <<" NUMSTRIPS="<<NUMSTRIPS<<endl
04183 <<" NUMENDS="<<NUMENDS<<endl
04184 <<" NUMBOOKENDS="<<NUMBOOKENDS<<endl;
04185
04186 if (det==Detector::kNear) {
04187 MSG("LIPlexMaps",Msg::kInfo)
04188 << " Total number of strip ends=" << 11616 << endl;
04189 }
04190 else {
04191 MSG("LIPlexMaps",Msg::kInfo)
04192 <<" Total number of strip ends="
04193 <<(NUMPLANES*NUMSTRIPS*NUMENDS)-(NUMBOOKENDS*NUMSTRIPS*NUMENDS)
04194 <<endl;
04195 }
04196
04197 Int_t totalCounted=goodCounter+pixCounter+nnCounter+pmtCounter+
04198 detCounter+gainHighCounter;
04199 Int_t numBadStripends=totalCounted-goodCounter;
04200
04201 MSG("LIPlexMaps",Msg::kInfo)
04202 <<endl
04203 <<" ** Job Summary **"<<endl
04204 <<" Num good stripends= "<<goodCounter
04205 <<" ( "<<100.*goodCounter/totalCounted<<" %)"<<endl
04206 <<" Num bad stripends= "<<numBadStripends
04207 <<" ( "<<100.*numBadStripends/totalCounted<<" %)"<<endl
04208 <<" with average pixel value= "<<pixCounter
04209 <<" ( "<<100.*pixCounter/totalCounted<<" %) gain too high= "<<pixgainHighCounter<<" (capped= "<<pixgainCappedCounter<<" )"<<endl
04210 <<" with average NN value= "<<nnCounter
04211 <<" ( "<<100.*nnCounter/totalCounted<<" %) gain too high= "<<nngainHighCounter<<" (capped= "<<nngainCappedCounter<<" )"<<endl
04212 <<" with average PMT value= "<<pmtCounter
04213 <<" ( "<<100.*pmtCounter/totalCounted<<" %) gain too high= "<<pmtgainHighCounter<<" (capped= "<<pmtgainCappedCounter<<" )"<<endl
04214 <<" with average-detector-PMT value= "<<detCounter
04215 <<" ( "<<100.*detCounter/totalCounted<<" %) Equiv. num PMTs= "
04216 <<1.*detCounter/(NUMPIXELS*NUMPIXELSPOTS)<<" gain too high= "<<detgainHighCounter<<" (capped= "<<detgainCappedCounter<<" )"<<endl
04217 <<" with too high gain= "<<gainHighCounter
04218 <<" ( "<<100.*gainHighCounter/totalCounted<<" %) gain capped= "<<gainCappedCounter
04219 <<" ( "<<100.*gainCappedCounter/totalCounted<<" %)"<<endl
04220 <<" Sum of above= "<<totalCounted<<endl
04221 <<" Total num written to DB= "<<totalCounter<<endl;
04222
04223 if(aggNo==-1) {
04224
04225 MSG("LIPlexMaps",Msg::kInfo)
04226 <<"DbiWriter.IsOpen="<<writer.IsOpen()<<endl
04227 <<"DbiWriter.CanOutput="<<writer.CanOutput()<<endl;
04228
04229 if (writeToDb){
04230 if (this->IsPermitted()){
04231 MSG("LIPlexMaps",Msg::kInfo)
04232 <<"Writing to database..."<<endl;
04233
04234 writer.Close();
04235 MSG("LIPlexMaps",Msg::kInfo)
04236 <<"Finished writing to database"<<endl;
04237 }
04238 }
04239 else {
04240 MSG("LIPlexMaps",Msg::kInfo)
04241 <<"Mode is set to NOT write to database"<<endl;
04242 }
04243
04244 }
04245
04246
04247 gStyle->SetOptStat(1111111);
04248
04249
04250 TCanvas *cGain=new TCanvas("cGain","PMT Gain",0,0,1000,600);
04251 cGain->SetFillColor(0);
04252 cGain->cd();
04253 hGain->Draw();
04254
04255
04256 TCanvas *cGainHighPmt=new TCanvas("cGainHighPmt","PMT Gain: HighPmts",
04257 0,0,1000,600);
04258 cGainHighPmt->SetFillColor(0);
04259 cGainHighPmt->cd();
04260 hGainHighPmt->Draw();
04261
04262
04263
04264 TCanvas *cGainCrazyHighPmt=new TCanvas("cGainCrazyHighPmt",
04265 "PMT Gain: CrazyHighPmts",
04266 0,0,1000,600);
04267 cGainCrazyHighPmt->SetFillColor(0);
04268 cGainCrazyHighPmt->cd();
04269 hGainCrazyHighPmt->Draw();
04270
04271
04272 TCanvas *cGainErr=new TCanvas("cGainErr","PMT GainErr",0,0,1000,600);
04273 cGainErr->SetFillColor(0);
04274 cGainErr->cd();
04275 hGainErr->Draw();
04276 cGainErr->SetLogy();
04277
04278
04279 TCanvas *cGainErrZoom=new TCanvas("cGainErrZoom","PMT GainErrZoom",
04280 0,0,1000,600);
04281 cGainErrZoom->SetFillColor(0);
04282 cGainErrZoom->cd();
04283 hGainErrZoom->Draw();
04284
04285
04286 TCanvas *cGainErrFract=new TCanvas("cGainErrFract","PMT GainErrFract",
04287 0,0,1000,600);
04288 cGainErrFract->SetFillColor(0);
04289 cGainErrFract->cd();
04290 hGainErrFract->Draw();
04291
04292
04293 TCanvas *cSPEWidth=new TCanvas("cSPEWidth","PMT SPEWidth",
04294 0,0,1000,600);
04295 cSPEWidth->SetFillColor(0);
04296 cSPEWidth->cd();
04297 hSPEWidth->Draw();
04298
04299
04300 TCanvas *cGainAvDet=new TCanvas("cGainAvDet",
04301 "Gains of Av. PMT in Detector",
04302 0,0,1000,600);
04303 cGainAvDet->SetFillColor(0);
04304 cGainAvDet->cd();
04305 hGainAvDet->Draw();
04306
04307
04308 TCanvas *cStripVsPlaneGain=new TCanvas
04309 ("cStripVsPlaneGain","StripVsPlane: Gain",0,0,1000,800);
04310 cStripVsPlaneGain->SetFillColor(0);
04311 cStripVsPlaneGain->cd();
04312 string sDbGains="DbGainsNew";
04313 sDbGains+=Detector::AsString(static_cast<Detector::
04314 Detector_t>(det));
04315 sDbGains+=".ps";
04316 cStripVsPlaneGain->Print((sDbGains+"[").c_str());
04317 gErrorIgnoreLevel=1;
04318
04319 gStyle->SetOptStat(0);
04320 for (Int_t i=0;i<NUMCRATES;i++){
04321 cStripVsPlaneGain->Clear();
04322 hStripVsPlaneGain[i]->Draw("colz");
04323 cStripVsPlaneGain->Print(sDbGains.c_str());
04324 }
04325
04326
04327 gStyle->SetOptStat(1111111);
04328 cGain->Print(sDbGains.c_str());
04329 cGainAvDet->Print(sDbGains.c_str());
04330 cGainHighPmt->Print(sDbGains.c_str());
04331 cGainCrazyHighPmt->Print(sDbGains.c_str());
04332
04333 cStripVsPlaneGain->Print((sDbGains+"]").c_str());
04334 gErrorIgnoreLevel=0;
04335
04336
04337 TCanvas *cStripVsPlaneGainErr=new TCanvas
04338 ("cStripVsPlaneGainErr","StripVsPlane: GainErr",0,0,1000,800);
04339 cStripVsPlaneGainErr->SetFillColor(0);
04340 cStripVsPlaneGainErr->cd();
04341 string sDbGainErrs="DbGainErrsNew";
04342 sDbGainErrs+=Detector::AsString(static_cast<Detector::
04343 Detector_t>(det));
04344 sDbGainErrs+=".ps";
04345 cStripVsPlaneGainErr->Print((sDbGainErrs+"[").c_str());
04346 gErrorIgnoreLevel=1;
04347
04348 gStyle->SetOptStat(0);
04349 for (Int_t i=0;i<NUMCRATES;i++){
04350 cStripVsPlaneGainErr->Clear();
04351 hStripVsPlaneGainErr[i]->Draw("colz");
04352 hStripVsPlaneGainErr[i]->SetMaximum(2.0*gainErrAvDet);
04353 cStripVsPlaneGainErr->Print(sDbGainErrs.c_str());
04354 }
04355
04356
04357 gStyle->SetOptStat(1111111);
04358 cGainErr->Print(sDbGainErrs.c_str());
04359 cGainErrZoom->Print(sDbGainErrs.c_str());
04360 cGainErrFract->Print(sDbGainErrs.c_str());
04361
04362 cStripVsPlaneGainErr->Print((sDbGainErrs+"]").c_str());
04363 gErrorIgnoreLevel=0;
04364
04366
04368 TCanvas *cStripVsPlaneSPEWidth=new TCanvas
04369 ("cStripVsPlaneSPEWidth","StripVsPlane: SPEWidth",0,0,1000,800);
04370 cStripVsPlaneSPEWidth->SetFillColor(0);
04371 cStripVsPlaneSPEWidth->cd();
04372 string sDbSPEWidths="DbSPEWidthsNew";
04373 sDbSPEWidths+=Detector::AsString(static_cast<Detector::
04374 Detector_t>(det));
04375 sDbSPEWidths+=".ps";
04376 cStripVsPlaneSPEWidth->Print((sDbSPEWidths+"[").c_str());
04377 gErrorIgnoreLevel=1;
04378
04379 gStyle->SetOptStat(0);
04380 for (Int_t i=0;i<NUMCRATES;i++){
04381 cStripVsPlaneSPEWidth->Clear();
04382 hStripVsPlaneSPEWidth[i]->Draw("colz");
04383 cStripVsPlaneSPEWidth->Print(sDbSPEWidths.c_str());
04384 }
04385
04386
04387 gStyle->SetOptStat(1111111);
04388 cSPEWidth->Print(sDbSPEWidths.c_str());
04389
04390 cStripVsPlaneSPEWidth->Print((sDbSPEWidths+"]").c_str());
04391 gErrorIgnoreLevel=0;
04392
04393
04394 gStyle->SetOptStat(1111111);
04395
04396 MSG("LIPlexMaps",Msg::kInfo)
04397 <<endl<<" ** Finished the MakeCalAdcToPe method... ** "<<endl;
04398 }
04399
04400
04401
04402 void LIPlexMaps::DumpCalStripToStrip(std::string sDataFileName,
04403 Detector::Detector_t det,
04404 SimFlag::ESimFlag simFlag,
04405 VldTimeStamp ts,Int_t task) const
04406 {
04407 MSG("LIPlexMaps",Msg::kInfo)
04408 <<endl<<" ** Running the DumpCalStripToStrip() method... **"<<endl;
04409
04410 DbiResultPtr<CalStripToStrip> dbiCalStripToStrip;
04411 VldContext vldCtx(det,simFlag,ts);
04412 UInt_t numRows=dbiCalStripToStrip.NewQuery(vldCtx,task);
04413
04414
04415 MSG("LIPlexMaps",Msg::kInfo)
04416 <<"Opening file "<<sDataFileName<<"..."<<endl;
04417 ofstream odataFile(sDataFileName.c_str());
04418
04419 MSG("LIPlexMaps",Msg::kInfo)
04420 <<"New DB query produced "<<numRows<<" rows"
04421 <<", using task="<<task<<endl
04422 <<"Looping over rows..."<<endl;
04423
04424 for(UInt_t i=0;i<numRows;i++) {
04425 const CalStripToStrip* calStripToStrip=dbiCalStripToStrip.GetRow(i);
04426
04427 Int_t seid_enc=calStripToStrip->GetStripEndId().GetEncoded();
04428 Float_t resp=calStripToStrip->GetResponse();
04429 Float_t respErr=calStripToStrip->GetResponseErr();
04430
04431 odataFile<<seid_enc<<"\t"<<resp<<"\t"<<respErr<<endl;
04432 }
04433 MSG("LIPlexMaps",Msg::kInfo)
04434 <<"Output file completed"<<endl;
04435
04436 MSG("LIPlexMaps",Msg::kInfo)
04437 <<endl<<" ** Finished the DumpCalStripToStrip method... ** "<<endl;
04438 }
04439
04440
04441
04442 void LIPlexMaps::DumpCalStripAtten(std::string sDataFileName,
04443 Detector::Detector_t det,
04444 SimFlag::ESimFlag simFlag,
04445 VldTimeStamp ts,Int_t task)
04446 {
04447 MSG("LIPlexMaps",Msg::kInfo)
04448 <<endl<<" ** Running the DumpCalStripAtten() method... **"<<endl;
04449
04450
04451 this->SetDetector(static_cast<Int_t>(det));
04452
04453 const Int_t firstStripBin=FIRSTSTRIP-8;
04454 const Int_t lastStripBin=LASTSTRIP+9;
04455 const Int_t bins=lastStripBin-firstStripBin;
04456
04457 string s="Lambda1, East side";
04458 TH2F *hStripVsPlaneLambda1East=new TH2F(s.c_str(),s.c_str(),
04459 LASTSCINTPLANE-FIRSTSCINTPLANE+2,
04460 0,LASTSCINTPLANE+1,
04461 bins,firstStripBin,lastStripBin);
04462 hStripVsPlaneLambda1East->GetXaxis()->SetTitle("Plane");
04463 hStripVsPlaneLambda1East->GetXaxis()->CenterTitle();
04464 hStripVsPlaneLambda1East->GetYaxis()->SetTitle("Strip");
04465 hStripVsPlaneLambda1East->GetYaxis()->CenterTitle();
04466
04467 s="Lambda1, West side";
04468 TH2F *hStripVsPlaneLambda1West=new TH2F(s.c_str(),s.c_str(),
04469 LASTSCINTPLANE-FIRSTSCINTPLANE+2,
04470 0,LASTSCINTPLANE+1,
04471 bins,firstStripBin,lastStripBin);
04472 hStripVsPlaneLambda1West->GetXaxis()->SetTitle("Plane");
04473 hStripVsPlaneLambda1West->GetXaxis()->CenterTitle();
04474 hStripVsPlaneLambda1West->GetYaxis()->SetTitle("Strip");
04475 hStripVsPlaneLambda1West->GetYaxis()->CenterTitle();
04476
04477 s="Lambda2, East side";
04478 TH2F *hStripVsPlaneLambda2East=new TH2F(s.c_str(),s.c_str(),
04479 LASTSCINTPLANE-FIRSTSCINTPLANE+2,
04480 0,LASTSCINTPLANE+1,
04481 bins,firstStripBin,lastStripBin);
04482 hStripVsPlaneLambda2East->GetXaxis()->SetTitle("Plane");
04483 hStripVsPlaneLambda2East->GetXaxis()->CenterTitle();
04484 hStripVsPlaneLambda2East->GetYaxis()->SetTitle("Strip");
04485 hStripVsPlaneLambda2East->GetYaxis()->CenterTitle();
04486
04487 s="Lambda2, West side";
04488 TH2F *hStripVsPlaneLambda2West=new TH2F(s.c_str(),s.c_str(),
04489 LASTSCINTPLANE-FIRSTSCINTPLANE+2,
04490 0,LASTSCINTPLANE+1,
04491 bins,firstStripBin,lastStripBin);
04492 hStripVsPlaneLambda2West->GetXaxis()->SetTitle("Plane");
04493 hStripVsPlaneLambda2West->GetXaxis()->CenterTitle();
04494 hStripVsPlaneLambda2West->GetYaxis()->SetTitle("Strip");
04495 hStripVsPlaneLambda2West->GetYaxis()->CenterTitle();
04496
04497 s="Frac1, East side";
04498 TH2F *hStripVsPlaneFrac1East=new TH2F(s.c_str(),s.c_str(),
04499 LASTSCINTPLANE-FIRSTSCINTPLANE+2,
04500 0,LASTSCINTPLANE+1,
04501 bins,firstStripBin,lastStripBin);
04502 hStripVsPlaneFrac1East->GetXaxis()->SetTitle("Plane");
04503 hStripVsPlaneFrac1East->GetXaxis()->CenterTitle();
04504 hStripVsPlaneFrac1East->GetYaxis()->SetTitle("Strip");
04505 hStripVsPlaneFrac1East->GetYaxis()->CenterTitle();
04506
04507 s="Frac1, West side";
04508 TH2F *hStripVsPlaneFrac1West=new TH2F(s.c_str(),s.c_str(),
04509 LASTSCINTPLANE-FIRSTSCINTPLANE+2,
04510 0,LASTSCINTPLANE+1,
04511 bins,firstStripBin,lastStripBin);
04512 hStripVsPlaneFrac1West->GetXaxis()->SetTitle("Plane");
04513 hStripVsPlaneFrac1West->GetXaxis()->CenterTitle();
04514 hStripVsPlaneFrac1West->GetYaxis()->SetTitle("Strip");
04515 hStripVsPlaneFrac1West->GetYaxis()->CenterTitle();
04516
04517 s="Atten, East side";
04518 TH2F *hStripVsPlaneAttenEast=new TH2F(s.c_str(),s.c_str(),
04519 LASTSCINTPLANE-FIRSTSCINTPLANE+2,
04520 0,LASTSCINTPLANE+1,
04521 bins,firstStripBin,lastStripBin);
04522 hStripVsPlaneAttenEast->GetXaxis()->SetTitle("Plane");
04523 hStripVsPlaneAttenEast->GetXaxis()->CenterTitle();
04524 hStripVsPlaneAttenEast->GetYaxis()->SetTitle("Strip");
04525 hStripVsPlaneAttenEast->GetYaxis()->CenterTitle();
04526
04527 s="Atten, West side";
04528 TH2F *hStripVsPlaneAttenWest=new TH2F(s.c_str(),s.c_str(),
04529 LASTSCINTPLANE-FIRSTSCINTPLANE+2,
04530 0,LASTSCINTPLANE+1,
04531 bins,firstStripBin,lastStripBin);
04532 hStripVsPlaneAttenWest->GetXaxis()->SetTitle("Plane");
04533 hStripVsPlaneAttenWest->GetXaxis()->CenterTitle();
04534 hStripVsPlaneAttenWest->GetYaxis()->SetTitle("Strip");
04535 hStripVsPlaneAttenWest->GetYaxis()->CenterTitle();
04536
04537 DbiResultPtr<CalStripAtten> dbiCalStripAtten;
04538 VldContext vldCtx(det,simFlag,ts);
04539 UInt_t numRows=dbiCalStripAtten.NewQuery(vldCtx,task);
04540
04541
04542 MSG("LIPlexMaps",Msg::kInfo)
04543 <<"Opening file "<<sDataFileName<<"..."<<endl;
04544 ofstream odataFile(sDataFileName.c_str());
04545
04546 MSG("LIPlexMaps",Msg::kInfo)
04547 <<"New DB query produced "<<numRows<<" rows"
04548 <<", using task="<<task<<endl
04549 <<"Looping over rows..."<<endl;
04550
04551 for(UInt_t i=0;i<numRows;i++) {
04552 const CalStripAtten* calStripAtten=dbiCalStripAtten.GetRow(i);
04553
04554
04555
04556
04557
04558
04559
04560
04561
04562
04563
04564
04565
04566
04567
04568
04569
04570
04571
04572 Int_t seid_enc=calStripAtten->GetStripEndId().GetEncoded();
04573 Float_t lambda1=calStripAtten->GetLambda1();
04574 Float_t lambda2=calStripAtten->GetLambda2();
04575 Float_t frac1=calStripAtten->GetFrac1();
04576 Float_t lambda1Err=calStripAtten->GetLambda1Err();
04577 Float_t lambda2Err=calStripAtten->GetLambda2Err();
04578 Float_t frac1Err=calStripAtten->GetFrac1Err();
04579
04580 MAXMSG("LIPlexMaps",Msg::kInfo,10)
04581 <<"seid_enc="<<seid_enc
04582 <<", GetSEIDkey="<<calStripAtten->GetSEIDkey()<<endl;
04583
04584 PlexStripEndId seid=calStripAtten->GetStripEndId();
04585 Int_t plane=seid.GetPlane();
04586 Int_t strip=seid.GetStrip();
04587 Int_t se=seid.GetEnd();
04588 Float_t x=1.5;
04589
04590
04591
04592
04593
04594
04595
04596 Float_t atten=frac1*exp(-x/lambda1)+(1-frac1)*exp(-x/lambda2);
04597
04598 if (se==StripEnd::kEast){
04599 hStripVsPlaneLambda1East->Fill(plane,strip,lambda1);
04600 hStripVsPlaneLambda2East->Fill(plane,strip,lambda2);
04601 hStripVsPlaneFrac1East->Fill(plane,strip,frac1);
04602 hStripVsPlaneAttenEast->Fill(plane,strip,atten);
04603 }
04604 else {
04605 hStripVsPlaneLambda1West->Fill(plane,strip,lambda1);
04606 hStripVsPlaneLambda2West->Fill(plane,strip,lambda2);
04607 hStripVsPlaneFrac1West->Fill(plane,strip,frac1);
04608 hStripVsPlaneAttenWest->Fill(plane,strip,atten);
04609 }
04610
04611 odataFile<<seid_enc
04612 <<"\t"<<lambda1
04613 <<"\t"<<lambda2
04614 <<"\t"<<frac1
04615 <<"\t"<<lambda1Err
04616 <<"\t"<<lambda2Err
04617 <<"\t"<<frac1Err
04618 <<endl;
04619 }
04620 MSG("LIPlexMaps",Msg::kInfo)
04621 <<"Output file completed"<<endl;
04622
04623 TCanvas *cStripVsPlaneLambda1=new TCanvas
04624 ("cStripVsPlaneLambda1","StripVsPlane: Mean",0,0,1100,800);
04625 cStripVsPlaneLambda1->SetFillColor(0);
04626 cStripVsPlaneLambda1->Divide(1,2);
04627 cStripVsPlaneLambda1->cd(1);
04628 hStripVsPlaneLambda1East->Draw("colz");
04629 cStripVsPlaneLambda1->cd(2);
04630 hStripVsPlaneLambda1West->Draw("colz");
04631
04632 TCanvas *cStripVsPlaneLambda2=new TCanvas
04633 ("cStripVsPlaneLambda2","StripVsPlane: Mean",0,0,1100,800);
04634 cStripVsPlaneLambda2->SetFillColor(0);
04635 cStripVsPlaneLambda2->Divide(1,2);
04636 cStripVsPlaneLambda2->cd(1);
04637 hStripVsPlaneLambda2East->Draw("colz");
04638 cStripVsPlaneLambda2->cd(2);
04639 hStripVsPlaneLambda2West->Draw("colz");
04640
04641 TCanvas *cStripVsPlaneFrac1=new TCanvas
04642 ("cStripVsPlaneFrac1","StripVsPlane: Mean",0,0,1100,800);
04643 cStripVsPlaneFrac1->SetFillColor(0);
04644 cStripVsPlaneFrac1->Divide(1,2);
04645 cStripVsPlaneFrac1->cd(1);
04646 hStripVsPlaneFrac1East->Draw("colz");
04647 cStripVsPlaneFrac1->cd(2);
04648 hStripVsPlaneFrac1West->Draw("colz");
04649
04650 TCanvas *cStripVsPlaneAtten=new TCanvas
04651 ("cStripVsPlaneAtten","StripVsPlane: Mean",0,0,1100,800);
04652 cStripVsPlaneAtten->SetFillColor(0);
04653 cStripVsPlaneAtten->Divide(1,2);
04654 cStripVsPlaneAtten->cd(1);
04655 hStripVsPlaneAttenEast->Draw("colz");
04656 cStripVsPlaneAtten->cd(2);
04657 hStripVsPlaneAttenWest->Draw("colz");
04658
04659 MSG("LIPlexMaps",Msg::kInfo)
04660 <<endl<<" ** Finished the DumpCalStripAtten method... ** "<<endl;
04661 }
04662
04663
04664
04665 void LIPlexMaps::MakeCalStripToStrip(std::string sDataFileName,
04666 Detector::Detector_t det,
04667 SimFlag::ESimFlag simFlag,
04668 VldTimeStamp vldStart,
04669 VldTimeStamp vldEnd,
04670 Int_t aggNo,
04671 Int_t task,
04672 VldTimeStamp creationDate,
04673 std::string dbName,
04674 std::string sLogComment,
04675 Bool_t writeToDb)
04676 {
04677 MSG("LIPlexMaps",Msg::kInfo)
04678 <<endl<<" ** Running the MakeCalStripToStrip() method... **"<<endl;
04679
04680 this->SetDetector(static_cast<Int_t>(det));
04681
04682
04683 MSG("LIPlexMaps",Msg::kInfo)
04684 <<"Opening file "<<sDataFileName<<"..."<<endl;
04685 ifstream dataFile(sDataFileName.c_str());
04686
04687 if (!dataFile){
04688 MSG("LIPlexMaps",Msg::kInfo)
04689 <<"Can't open file "<<sDataFileName<<endl
04690 <<"Exiting here..."<<endl;
04691 exit(1);
04692 }
04693
04694
04695 VldRange vr(det,simFlag,vldStart,vldEnd,
04696 "LISummary/LIPlexMaps::MakeCalStripToStrip");
04697 MSG("LIPlexMaps",Msg::kInfo)
04698 <<"Using Validity Range: "<<vr.AsString()<<endl;
04699
04700 MSG("LIPlexMaps",Msg::kInfo)
04701 <<"Log comment="<<sLogComment<<endl;
04702
04703
04704 DbiWriter<CalStripToStrip> writer(vr,aggNo,task,creationDate,dbName,
04705 sLogComment);
04706
04707 Int_t seid_enc=-1;
04708 Float_t resp=-1;
04709 Float_t respErr=-1;
04710 Float_t defaultResp=1;
04711 Float_t defaultRespErr=1;
04712
04713 Int_t counter=0;
04714
04715
04716 map<Int_t,myCalStripToStrip> inputCalSts;
04717
04718
04719
04720 for (Int_t pl=FIRSTSCINTPLANE;pl<=LASTSCINTPLANE;pl++){
04721 for (Int_t st=FIRSTSTRIP;st<=LASTSTRIP;st++){
04722
04723
04724 if (det==Detector::kNear && st>67 && (pl-1)%5!=0) continue;
04725
04726
04727 if (det==Detector::kNear && pl>120 && (pl-1)%5!=0) continue;
04728
04729
04730 if (det==Detector::kFar && pl==249) continue;
04731
04732 MAXMSG("LIPlexMaps",Msg::kInfo,10)
04733 <<"pl="<<pl<<", st="<<st<<endl;
04734
04735 PlexStripEndId seidE(det,pl,st,StripEnd::kEast);
04736 PlexStripEndId seidW(det,pl,st,StripEnd::kWest);
04737
04738
04739 if (det!=Detector::kNear){
04740 MAXMSG("LIPlexMaps",Msg::kInfo,1)
04741 <<endl<<"Detector is not ND thus creating East stripends..."
04742 <<endl;
04743 inputCalSts[seidE.GetEncoded()]=myCalStripToStrip
04744 (seidE.GetEncoded(),defaultResp,defaultRespErr);;
04745 }
04746
04747
04748 inputCalSts[seidW.GetEncoded()]=myCalStripToStrip
04749 (seidW.GetEncoded(),defaultResp,defaultRespErr);;
04750
04751 }
04752 }
04753
04754 MSG("LIPlexMaps",Msg::kInfo)
04755 <<"Map initialised with size="<<inputCalSts.size()<<endl;
04756
04757
04758 while(dataFile>>seid_enc>>resp>>respErr) {
04759
04760 MAXMSG("LIPlexMaps",Msg::kInfo,10)
04761 <<"Found line in file: seid_enc="<<seid_enc
04762 <<", resp="<<resp<<", respErr="<<respErr<<endl;
04763
04764
04765
04766
04767
04768 inputCalSts[seid_enc]=myCalStripToStrip(seid_enc,resp,respErr);;
04769
04770
04771
04772
04773 counter++;
04774 }
04775
04776 MSG("LIPlexMaps",Msg::kInfo)
04777 <<"Found "<<counter<<" rows in file: "<<sDataFileName
04778 <<", mapSize="<<inputCalSts.size()<<endl;
04779
04780
04781 typedef map<Int_t,myCalStripToStrip>::const_iterator stsIt;
04782 for (stsIt it=inputCalSts.begin();it!=inputCalSts.end();it++){
04783 const myCalStripToStrip& c=it->second;
04784 CalStripToStrip calStripToStrip(c.seid_enc,c.response,c.responseErr);
04785 MAXMSG("LIPlexMaps",Msg::kInfo,10)
04786 <<"Writing to database: seidEnc="<<c.seid_enc
04787 <<", resp="<<c.response<<", respErr="<<c.responseErr<<endl;
04788 writer<<calStripToStrip;
04789 }
04790
04791 MSG("LIPlexMaps",Msg::kInfo)
04792 <<"DbiWriter.IsOpen="<<writer.IsOpen()<<endl
04793 <<"DbiWriter.CanOutput="<<writer.CanOutput()<<endl;
04794
04795 if (writeToDb){
04796 if (this->IsPermitted()){
04797 MSG("LIPlexMaps",Msg::kInfo)
04798 <<"Writing to database..."<<endl;
04799
04800 writer.Close();
04801 MSG("LIPlexMaps",Msg::kInfo)
04802 <<"Finished writing to database"<<endl;
04803 }
04804 }
04805 else {
04806 MSG("LIPlexMaps",Msg::kInfo)
04807 <<"Mode is set to NOT write to database"<<endl;
04808 }
04809
04810 MSG("LIPlexMaps",Msg::kInfo)
04811 <<endl<<" ** Finished the MakeCalStripToStrip method... ** "<<endl;
04812 }
04813
04814
04815
04816 void LIPlexMaps::MakeCalStripAtten(std::string sDataFileName,
04817 Detector::Detector_t det,
04818 SimFlag::ESimFlag simFlag,
04819 VldTimeStamp vldStart,
04820 VldTimeStamp vldEnd,
04821 Int_t aggNo,
04822 Int_t task,
04823 VldTimeStamp creationDate,
04824 std::string dbName,
04825 std::string sLogComment,
04826 Int_t iFileFormat,
04827 Bool_t writeToDb)
04828 {
04829 MSG("LIPlexMaps",Msg::kInfo)
04830 <<endl<<" ** Running the MakeCalStripAtten() method... **"<<endl;
04831
04832 this->SetDetector(static_cast<Int_t>(det));
04833
04834
04835 MSG("LIPlexMaps",Msg::kInfo)
04836 <<"Opening file "<<sDataFileName<<"..."<<endl;
04837 ifstream dataFile(sDataFileName.c_str());
04838
04839 if (!dataFile){
04840 MSG("LIPlexMaps",Msg::kInfo)
04841 <<"Can't open file "<<sDataFileName<<endl
04842 <<"Exiting here..."<<endl;
04843 exit(1);
04844 }
04845
04846
04847 VldRange vr(det,simFlag,vldStart,vldEnd,
04848 "LISummary/LIPlexMaps::MakeCalStripAtten");
04849 MSG("LIPlexMaps",Msg::kInfo)
04850 <<"Using Validity Range: "<<vr.AsString()<<endl;
04851
04852 MSG("LIPlexMaps",Msg::kInfo)
04853 <<"Log comment="<<sLogComment<<endl;
04854
04855
04856 DbiWriter<CalStripAtten> writer(vr,aggNo,task,creationDate,dbName,
04857 sLogComment);
04858 Int_t counter=0;
04859
04860 if (iFileFormat==0) {
04861 MAXMSG("LIPlexMaps",Msg::kInfo,100)
04862 <<"Assuming fileFormat=0 (=Leon/Jiajie's format)"<<endl;
04863 Int_t TotalLines=12000;
04864 Char_t buffer[248], moduleid[11];
04865 Int_t plane,strip,module_strip,ndf;
04866 Double_t chi2,shortAmp,shortAmp_err,shortAtt,shortAtt_err;
04867 Double_t longAmp,longAmp_err,longAtt,longAtt_err;
04868
04869 dataFile.getline(buffer,248);
04870
04871 for(Int_t i=0; i<TotalLines; i++) {
04872 if(!dataFile.good()) break;
04873 dataFile >> moduleid >> module_strip >> plane >> strip >> shortAmp
04874 >> shortAmp_err >> shortAtt >> shortAtt_err >> longAmp
04875 >> longAmp_err >> longAtt >> longAtt_err >> chi2 >> ndf;
04876
04877 Double_t frac1 = shortAmp/(shortAmp+longAmp);
04878 Double_t frac1_err = 0;
04879 Double_t SAerr_2 = pow(shortAmp_err,2);
04880 Double_t LAerr_2 = pow(longAmp_err,2);
04881 Double_t SLA = shortAmp + longAmp;
04882
04883 if(shortAmp>0)
04884 frac1_err = frac1 * sqrt(SAerr_2/(2*shortAmp)+
04885 (SAerr_2+LAerr_2)/pow(SLA,2));
04886 PlexStripEndId seid(Detector::kNear,plane,strip,StripEnd::kWest);
04887
04888 MAXMSG("LIPlexMaps",Msg::kInfo,100)
04889 <<"Found line in file: seid_enc="<<seid.AsString()
04890 <<", shortAtt="<<shortAtt/100.<< ", longAtt=" <<longAtt/100.
04891 <<", frac1="<<frac1 << endl;
04892
04893 CalStripAtten calStripAtten(seid,shortAtt/100.,longAtt/100.,
04894 frac1,shortAtt_err/100,longAtt_err/100.,
04895 frac1_err);
04896 writer << calStripAtten;
04897 counter++;
04898 }
04899 dataFile.getline(buffer,248);
04900 }
04901 else if (iFileFormat==1) {
04902 MAXMSG("LIPlexMaps",Msg::kInfo,100)
04903 <<"Assuming fileFormat=1 (=DumpCalStripAtten)"<<endl;
04904
04905 Int_t seid_enc=-1;
04906 Float_t lambda1=-1;
04907 Float_t lambda2=-1;
04908 Float_t frac1=-1;
04909 Float_t lambda1Err=-1;
04910 Float_t lambda2Err=-1;
04911 Float_t frac1Err=-1;
04912
04913
04914 while(dataFile
04915 >>seid_enc
04916 >>lambda1
04917 >>lambda2
04918 >>frac1
04919 >>lambda1Err
04920 >>lambda2Err
04921 >>frac1Err) {
04922
04923 MAXMSG("LIPlexMaps",Msg::kInfo,10)
04924 <<"Found line in file: seid_enc="<<seid_enc
04925 <<", lambda1="<<lambda1
04926 <<", lambda2="<<lambda2
04927 <<", frac1="<<frac1
04928 <<endl;
04929
04930
04931 CalStripAtten calStripAtten(seid_enc,lambda1,lambda2,frac1,
04932 lambda1Err,lambda2Err,frac1Err);
04933
04934
04935 writer<<calStripAtten;
04936
04937 counter++;
04938 }
04939 }
04940 else {
04941 MSG("LIPlexMaps",Msg::kError)
04942 <<"Input file format not recognised = "<<iFileFormat
04943 <<", will exit here..."<<endl;
04944 exit(1);
04945 }
04946 dataFile.close();
04947
04948 MSG("LIPlexMaps",Msg::kInfo)
04949 <<"Found "<<counter<<" rows in file: "<<sDataFileName<<endl;
04950
04951 MSG("LIPlexMaps",Msg::kInfo)
04952 <<"DbiWriter.IsOpen="<<writer.IsOpen()<<endl
04953 <<"DbiWriter.CanOutput="<<writer.CanOutput()<<endl;
04954
04955 if (writeToDb){
04956 if (this->IsPermitted()){
04957 MSG("LIPlexMaps",Msg::kInfo)
04958 <<"Writing to database..."<<endl;
04959
04960 writer.Close();
04961 MSG("LIPlexMaps",Msg::kInfo)
04962 <<"Finished writing to database"<<endl;
04963 }
04964 }
04965 else {
04966 MSG("LIPlexMaps",Msg::kInfo)
04967 <<"Mode is set to NOT write to database"<<endl;
04968 }
04969
04970 MSG("LIPlexMaps",Msg::kInfo)
04971 <<endl<<" ** Finished the MakeCalStripAtten method... ** "<<endl;
04972 }
04973
04974
04975
04976 void LIPlexMaps::MakeCalMIPCalibration(Float_t scale,
04977 Detector::Detector_t det,
04978 SimFlag::ESimFlag simFlag,
04979 VldTimeStamp vldStart,
04980 VldTimeStamp vldEnd,
04981 Int_t aggNo,
04982 Int_t task,
04983 VldTimeStamp creationDate,
04984 std::string dbName,
04985 std::string sLogComment,
04986 Bool_t writeToDb)
04987 {
04988 MSG("LIPlexMaps",Msg::kInfo)
04989 <<endl<<" ** Running the MakeCalMIPCalibration() method... **"<<endl;
04990
04991
04992
04993 VldRange vr(det,simFlag,vldStart,vldEnd,
04994 "LISummary/LIPlexMaps::MakeCalMIPCalibration");
04995 MSG("LIPlexMaps",Msg::kInfo)
04996 <<"Using Validity Range: "<<vr.AsString()<<endl;
04997
04998 MSG("LIPlexMaps",Msg::kInfo)
04999 <<"Other settings used:"<<endl
05000 <<"aggNo="<<aggNo<<endl
05001 <<"task="<<task<<endl
05002 <<"creationDate="<<creationDate<<endl
05003 <<"dbName="<<dbName<<endl
05004 <<"sLogComment="<<sLogComment<<endl
05005 <<"writeToDb="<<writeToDb<<endl;
05006
05007
05008 DbiWriter<CalMIPCalibration> writer(vr,aggNo,task,creationDate,dbName,
05009 sLogComment);
05010
05011
05012
05013 Int_t seidkey=0;
05014 Int_t stripendid=0;
05015
05016
05017 CalMIPCalibration calMIPCalibration(seidkey,stripendid,scale);
05018 MSG("LIPlexMaps",Msg::kInfo)
05019 <<"Writing point with:"<<endl
05020 <<" seidkey="<<seidkey<<endl
05021 <<" stripendid="<<stripendid<<endl
05022 <<" scale="<<scale<<endl;
05023
05024
05025 writer<<calMIPCalibration;
05026
05027 MSG("LIPlexMaps",Msg::kInfo)
05028 <<"DbiWriter.IsOpen="<<writer.IsOpen()<<endl
05029 <<"DbiWriter.CanOutput="<<writer.CanOutput()<<endl;
05030
05031 if (writeToDb){
05032 if (this->IsPermitted()){
05033 MSG("LIPlexMaps",Msg::kInfo)
05034 <<"Writing to database..."<<endl;
05035
05036 writer.Close();
05037 MSG("LIPlexMaps",Msg::kInfo)
05038 <<"Finished writing to database"<<endl;
05039 }
05040 }
05041 else {
05042 MSG("LIPlexMaps",Msg::kInfo)
05043 <<"Mode is set to NOT write to database"<<endl;
05044 }
05045
05046 MSG("LIPlexMaps",Msg::kInfo)
05047 <<endl<<" ** Finished the MakeCalMIPCalibration method... ** "<<endl;
05048 }
05049
05050
05051
05052 void LIPlexMaps::MakePlexStripEndToLed(Bool_t writeToDb)
05053 {
05054 MSG("LIPlexMaps",Msg::kInfo)
05055 <<endl<<" ** Running the MakePlexStripEndToLed method... ** "
05056 <<endl;
05057
05058
05059 Detector::Detector_t det=Detector::kCalDet;
05060
05061 Int_t* planeMax=new Int_t[NUMCRATES];
05062 Int_t* planeMin=new Int_t[NUMCRATES];
05063 fLookup.SetPbPlanes(planeMin,planeMax,det);
05064
05065 const Int_t firstStripBin=FIRSTSTRIP-8;
05066 const Int_t lastStripBin=LASTSTRIP+9;
05067 const Int_t bins=lastStripBin-firstStripBin;
05068
05069 string sConstantBit="";
05070
05071 MSG("LIAnalysis",Msg::kInfo)
05072 <<"sConstantBit="<<sConstantBit<<endl;
05073
05074 TH2F **hStripVsPlaneLed=0;
05075 hStripVsPlaneLed= new TH2F*[NUMCRATES];
05076 for (Int_t i=0;i<NUMCRATES;i++){
05077 string sPb=Form("%d",i);
05078 fS="Led (Crate "+sPb+")";
05079 hStripVsPlaneLed[i]=new TH2F(fS.c_str(),fS.c_str(),
05080 planeMax[i]-planeMin[i],
05081 planeMin[i],planeMax[i],
05082 bins,firstStripBin,lastStripBin);
05083 hStripVsPlaneLed[i]->GetXaxis()->SetTitle("Plane");
05084 hStripVsPlaneLed[i]->GetXaxis()->CenterTitle();
05085 hStripVsPlaneLed[i]->GetYaxis()->SetTitle("Strip");
05086 hStripVsPlaneLed[i]->GetYaxis()->CenterTitle();
05087 hStripVsPlaneLed[i]->SetFillColor(0);
05088
05089 }
05090
05091
05092 VldTimeStamp tsStart=VldTimeStamp(2003,3,1,12,0,0);
05093 MSG("LIPlexMaps",Msg::kInfo)
05094 <<"Vld start time: ";
05095 tsStart.Print();
05096 MSG("LIPlexMaps",Msg::kInfo)
05097 <<endl;
05098 VldTimeStamp tsEnd=VldTimeStamp(2010,1,1,12,0,0);
05099 MSG("LIPlexMaps",Msg::kInfo)
05100 <<"Vld end time: ";
05101 tsEnd.Print();
05102 MSG("LIPlexMaps",Msg::kInfo)
05103 <<endl;
05104
05105
05106 VldRange vldRng(det,SimFlag::kData,tsStart,tsEnd,
05107 "MakePlexStripEndToLed");
05108 MSG("LIPlexMaps",Msg::kInfo)
05109 <<"Validity range: ";
05110 vldRng.Print();
05111 MSG("LIPlexMaps",Msg::kInfo)
05112 <<endl;
05113
05114 VldTimeStamp tsNow;
05115 VldContext vldNow(det,SimFlag::kData,tsNow);
05116 PlexHandle plexHandle(vldNow);
05117
05118
05119
05120
05122
05124
05125
05126
05127
05128
05129
05130
05131
05132
05133
05134
05135
05136
05137
05138
05139
05140 for(Int_t pb=0;pb<NUMPULSERBOXES;pb++){
05141 for(Int_t led=4;led<=6;led++){
05142
05143 MSG("LIPlexMaps",Msg::kInfo)
05144 <<"Pulser box="<<pb<<", led="<<led<<endl;
05145
05146
05147 PlexLedId ledId(det,pb,led);
05148
05149
05150 int aggNo=0x7ff & ledId.GetEncoded();
05151 MSG("LIPlexMaps",Msg::kInfo)
05152 <<"aggNo="<<aggNo<<", encoded="<<ledId.GetEncoded()
05153 <<", det="<<(ledId.GetEncoded()>>11)<<endl;
05154
05155
05156 string logComment="Updated to reflect the state of the detector";
05157
05158 UInt_t dbNo=1;
05159
05160
05161 DbiWriter<PlexStripEndToLed> writer(vldRng,aggNo,0,tsNow,dbNo,
05162 logComment);
05163
05164 MSG("LIPlexMaps",Msg::kInfo)
05165 <<"DbiWriter.IsOpen="<<writer.IsOpen()<<endl;
05166
05167
05168
05169
05170
05171 for(Int_t plane=FIRSTPLANE;plane<=LASTPLANE;plane++){
05172 for(Int_t strip=FIRSTSTRIP;strip<=LASTSTRIP;strip++){
05173 for(Int_t end=FIRSTEND;end<=SECONDEND;end++){
05174
05175 StripEnd::StripEnd_t stripEndType = StripEnd::kUnknown;
05176 if (end==StripEnd::kEast) stripEndType=StripEnd::kEast;
05177 else if (end==StripEnd::kWest) stripEndType=StripEnd::kWest;
05178
05179 PlexStripEndId stripEndId(det,plane,strip,stripEndType);
05180
05181
05182 Int_t crate=plexHandle.GetRawChannelId(stripEndId).
05183 GetCrate();
05184
05186
05187 if (plane==0 && end==1 && (crate==1 || crate==2) &&
05188 det==Detector::kCalDet){
05189 crate=0;
05190 MSG("LIPlexMaps",Msg::kInfo)
05191 <<"Doing plane 0 caldet hack"<<endl;
05192 }
05193
05194
05195
05196 PlexStripEndToLed stripEndToLed
05197 (det,plane,strip,stripEndType,pb,
05198 fLookup.Strip2Led(strip,plane,det,crate));
05199
05200
05201
05202 MSG("LIPlexMaps",Msg::kDebug)
05203 <<"("<<plane<<";"<<strip<<";"<<stripEndType<<")"
05204 <<" ("<<pb<<":"<<led<<")"
05205 <<", strip2led="
05206 <<fLookup.Strip2Led(strip,plane,det,crate)<<")"
05207 <<", crate="<<crate
05208 <<", aggNo="<<stripEndToLed.GetAggregateNo()
05209 <<endl;
05210
05211 ReadoutType::Readout_t rt=plexHandle.GetReadoutType
05212 (plexHandle.GetRawChannelId(stripEndToLed.
05213 GetPlexStripEndId()));
05214
05215 if (rt!=ReadoutType::kScintStrip){
05216 MSG("LIPlexMaps",Msg::kInfo)
05217 <<"rt="<<ReadoutType::AsString(rt)<<endl;
05218 continue;
05219 }
05220
05221
05222 if(stripEndToLed.GetPlexStripEndId().GetPlane()!=plane ||
05223 stripEndToLed.GetPlexStripEndId().IsSteel() ||
05224 stripEndToLed.GetPlexStripEndId().IsVetoShield() ||
05225 !stripEndToLed.GetPlexStripEndId().IsValid()) {
05226
05227 MSG("LIPlexMaps",Msg::kInfo)
05228 <<"Stripend to led was bad: IsSteel="
05229 <<stripEndToLed.GetPlexStripEndId().IsSteel()
05230 <<", IsVetoShield="
05231 <<stripEndToLed.GetPlexStripEndId().IsVetoShield()
05232 <<", IsValid="
05233 <<stripEndToLed.GetPlexStripEndId().IsValid()
05234 <<", GetPlane="
05235 <<stripEndToLed.GetPlexStripEndId().GetPlane()
05236 <<", plane="<<plane
05237 <<endl;
05238 continue;
05239 }
05240
05241
05242
05243 if(stripEndToLed.GetPlexLedId().GetEncoded()==
05244 ledId.GetEncoded()) {
05245
05246
05247
05248
05249
05250 if(crate!=pb && det==Detector::kFar) continue;
05251
05252 MSG("LIPlexMaps",Msg::kInfo)
05253 <<stripEndToLed.GetAggregateNo()<<" "
05254 <<stripEndToLed.GetPlexStripEndId().GetPlane()<<" "
05255 <<stripEndToLed.GetPlexStripEndId().GetStrip()<<" "
05256 <<stripEndToLed.GetPlexStripEndId().GetEnd()<<" "
05257 <<stripEndToLed.GetPlexLedId().GetPulserBox()<<" "
05258 <<stripEndToLed.GetPlexLedId().GetLedInBox()<<endl;
05259
05260
05261 hStripVsPlaneLed[end-1]->Fill
05262 (stripEndToLed.GetPlexStripEndId().GetPlane(),
05263 stripEndToLed.GetPlexStripEndId().GetStrip(),
05264 stripEndToLed.GetPlexLedId().GetLedInBox());
05265
05266 writer<<stripEndToLed;
05267
05268 }
05269 else{
05270 MSG("LIPlexMaps",Msg::kDebug)
05271 <<"("<<plane<<";"<<strip<<";"<<stripEndType<<")"
05272 <<" ("<<pb<<":"<<led<<")"
05273 <<" These don't match: stripend to led encoded="
05274 <<stripEndToLed.GetPlexLedId().GetEncoded()
05275 <<", ledid encoded="<<ledId.GetEncoded()
05276 <<endl;
05277 }
05278 }
05279 }
05280 }
05281
05282 MSG("LIPlexMaps",Msg::kInfo)
05283 <<"DbiWriter.IsOpen="<<writer.IsOpen()<<endl
05284 <<"DbiWriter.CanOutput="<<writer.CanOutput()<<endl;
05285
05286 if (writeToDb){
05287 if (this->IsPermitted()){
05288 MSG("LIPlexMaps",Msg::kInfo)
05289 <<"Writing to database..."<<endl;
05290
05291 writer.Close();
05292 MSG("LIPlexMaps",Msg::kInfo)
05293 <<"Finished writing to database"<<endl;
05294 }
05295 }
05296 else {
05297 MSG("LIPlexMaps",Msg::kInfo)
05298 <<"Mode is set to NOT write to database"<<endl;
05299 }
05300
05301 }
05302 }
05303
05304
05305 gStyle->SetOptStat(0);
05306
05307 TCanvas *cStripVsPlaneLed=new TCanvas
05308 ("cStripVsPlaneLed","StripVsPlane: Led",0,0,1000,800);
05309 cStripVsPlaneLed->SetFillColor(0);
05310 cStripVsPlaneLed->Divide(1,2);
05311 cStripVsPlaneLed->cd(1);
05312 hStripVsPlaneLed[0]->Draw("textcolz");
05313 cStripVsPlaneLed->cd(2);
05314 hStripVsPlaneLed[1]->Draw("textcolz");
05315
05316 MSG("LIPlexMaps",Msg::kInfo)
05317 <<endl<<" ** Finished the MakePlexStripEndToLed method... ** "
05318 <<endl;
05319 }
05320
05321
05322
05323 void LIPlexMaps::ReadDbCalStripToStrip(Int_t det,VldTimeStamp ts,
05324 Int_t task)
05325 {
05326 MSG("LIPlexMaps",Msg::kInfo)
05327 <<endl<<" ** Running the ReadDbCalStripToStrip() method... ** "<<endl;
05328
05329 this->SetDetector(det);
05330
05331 const Int_t firstStripBin=FIRSTSTRIP-2;
05332 const Int_t lastStripBin=LASTSTRIP+2;
05333 const Int_t stripBins=lastStripBin-firstStripBin;
05334
05335 const Int_t firstPlaneBin=FIRSTPLANE-2;;
05336 const Int_t lastPlaneBin=LASTPLANE+2;
05337 const Int_t planeBins=lastPlaneBin-firstPlaneBin;
05338
05339 TH2F* hStVsPlResp1=new TH2F("hStVsPlResp1","hStVsPlResp1",
05340 planeBins,firstPlaneBin,lastPlaneBin,
05341 stripBins,firstStripBin,lastStripBin);
05342 hStVsPlResp1->SetTitle("Detector Response (East side)");
05343 hStVsPlResp1->GetXaxis()->SetTitle("Plane");
05344 hStVsPlResp1->GetXaxis()->CenterTitle();
05345 hStVsPlResp1->GetYaxis()->SetTitle("Strip");
05346 hStVsPlResp1->GetYaxis()->CenterTitle();
05347 hStVsPlResp1->SetFillColor(0);
05348
05349 TH2F* hStVsPlRespErr1=new TH2F("hStVsPlRespErr1","hStVsPlRespErr1",
05350 planeBins,firstPlaneBin,lastPlaneBin,
05351 stripBins,firstStripBin,lastStripBin);
05352 hStVsPlRespErr1->SetTitle("Detector Response Error (East side)");
05353 hStVsPlRespErr1->GetXaxis()->SetTitle("Plane");
05354 hStVsPlRespErr1->GetXaxis()->CenterTitle();
05355 hStVsPlRespErr1->GetYaxis()->SetTitle("Strip");
05356 hStVsPlRespErr1->GetYaxis()->CenterTitle();
05357 hStVsPlRespErr1->SetFillColor(0);
05358
05359 TH2F* hStVsPlResp2=new TH2F("hStVsPlResp2","hStVsPlResp2",
05360 planeBins,firstPlaneBin,lastPlaneBin,
05361 stripBins,firstStripBin,lastStripBin);
05362 hStVsPlResp2->SetTitle("Detector Response (West side)");
05363 hStVsPlResp2->GetXaxis()->SetTitle("Plane");
05364 hStVsPlResp2->GetXaxis()->CenterTitle();
05365 hStVsPlResp2->GetYaxis()->SetTitle("Strip");
05366 hStVsPlResp2->GetYaxis()->CenterTitle();
05367 hStVsPlResp2->SetFillColor(0);
05368
05369 TH2F* hStVsPlRespErr2=new TH2F("hStVsPlRespErr2","hStVsPlRespErr2",
05370 planeBins,firstPlaneBin,lastPlaneBin,
05371 stripBins,firstStripBin,lastStripBin);
05372 hStVsPlRespErr2->SetTitle("Detector Response Error (West side)");
05373 hStVsPlRespErr2->GetXaxis()->SetTitle("Plane");
05374 hStVsPlRespErr2->GetXaxis()->CenterTitle();
05375 hStVsPlRespErr2->GetYaxis()->SetTitle("Strip");
05376 hStVsPlRespErr2->GetYaxis()->CenterTitle();
05377 hStVsPlRespErr2->SetFillColor(0);
05378
05379 TH1F *hResponse=new TH1F("hResponse","hResponse",300,-1,10);
05380 hResponse->GetXaxis()->SetTitle("Response of Stripends");
05381 hResponse->GetXaxis()->CenterTitle();
05382 hResponse->GetYaxis()->SetTitle("");
05383 hResponse->GetYaxis()->CenterTitle();
05384 hResponse->SetLineColor(2);
05385 hResponse->SetFillStyle(3015);
05386 hResponse->SetFillColor(2);
05387 hResponse->SetLineWidth(3);
05388
05389
05390 TH1F *hRespE=new TH1F("hRespE","hRespE",500,-1,10);
05391 hRespE->GetXaxis()->SetTitle("Response of East Stripends");
05392 hRespE->GetXaxis()->CenterTitle();
05393 hRespE->GetYaxis()->SetTitle("");
05394 hRespE->GetYaxis()->CenterTitle();
05395 hRespE->SetLineColor(4);
05396 hRespE->SetFillStyle(3015);
05397 hRespE->SetFillColor(4);
05398 hRespE->SetLineWidth(3);
05399
05400
05401 TH1F *hRespW=new TH1F("hRespW","hRespW",500,-1,10);
05402 hRespW->GetXaxis()->SetTitle("Response of West Stripends");
05403 hRespW->GetXaxis()->CenterTitle();
05404 hRespW->GetYaxis()->SetTitle("");
05405 hRespW->GetYaxis()->CenterTitle();
05406 hRespW->SetLineColor(2);
05407 hRespW->SetFillStyle(3015);
05408 hRespW->SetFillColor(2);
05409 hRespW->SetLineWidth(3);
05410
05411
05412 TH1F *hResponseErr=new TH1F("hResponseErr","hResponseErr",
05413 200,-0.02,0.2);
05414 hResponseErr->GetXaxis()->SetTitle("ResponseErr of Stripends");
05415 hResponseErr->GetXaxis()->CenterTitle();
05416 hResponseErr->GetYaxis()->SetTitle("");
05417 hResponseErr->GetYaxis()->CenterTitle();
05418 hResponseErr->SetLineColor(3);
05419 hResponseErr->SetFillStyle(3015);
05420 hResponseErr->SetFillColor(3);
05421 hResponseErr->SetLineWidth(3);
05422
05423
05424 TProfile* pSigCorVsPlane=new TProfile
05425 ("pSigCorVsPlane","pSigCorVsPlane",
05426 planeBins,firstPlaneBin,lastPlaneBin);
05427 pSigCorVsPlane->GetXaxis()->SetTitle("Plane");
05428 pSigCorVsPlane->GetXaxis()->CenterTitle();
05429 pSigCorVsPlane->GetYaxis()->SetTitle("SigCor");
05430 pSigCorVsPlane->GetYaxis()->CenterTitle();
05431 pSigCorVsPlane->SetLineColor(2);
05432 pSigCorVsPlane->SetLineWidth(3);
05433
05434
05435 TProfile* pSigCorVsPlaneCoarse=new TProfile
05436 ("pSigCorVsPlaneCoarse","pSigCorVsPlaneCoarse",6,0,60);
05437 pSigCorVsPlaneCoarse->GetXaxis()->SetTitle("Plane");
05438 pSigCorVsPlaneCoarse->GetXaxis()->CenterTitle();
05439 pSigCorVsPlaneCoarse->GetYaxis()->SetTitle("SigCor");
05440 pSigCorVsPlaneCoarse->GetYaxis()->CenterTitle();
05441 pSigCorVsPlaneCoarse->SetLineColor(2);
05442 pSigCorVsPlaneCoarse->SetLineWidth(3);
05443
05444
05445 TProfile* pSigCorVsPlane1=new TProfile
05446 ("pSigCorVsPlane1","pSigCorVsPlane1",
05447 planeBins,firstPlaneBin,lastPlaneBin);
05448 pSigCorVsPlane1->GetXaxis()->SetTitle("Plane");
05449 pSigCorVsPlane1->GetXaxis()->CenterTitle();
05450 pSigCorVsPlane1->GetYaxis()->SetTitle("SigCor");
05451 pSigCorVsPlane1->GetYaxis()->CenterTitle();
05452 pSigCorVsPlane1->SetLineColor(2);
05453 pSigCorVsPlane1->SetLineWidth(3);
05454
05455
05456 TProfile* pSigCorVsPlane2=new TProfile
05457 ("pSigCorVsPlane2","pSigCorVsPlane2",
05458 planeBins,firstPlaneBin,lastPlaneBin);
05459 pSigCorVsPlane2->GetXaxis()->SetTitle("Plane");
05460 pSigCorVsPlane2->GetXaxis()->CenterTitle();
05461 pSigCorVsPlane2->GetYaxis()->SetTitle("SigCor");
05462 pSigCorVsPlane2->GetYaxis()->CenterTitle();
05463 pSigCorVsPlane2->SetLineColor(2);
05464 pSigCorVsPlane2->SetLineWidth(3);
05465
05466
05467 TProfile* pSigCorVsStrip=new TProfile
05468 ("pSigCorVsStrip","pSigCorVsStrip",
05469 stripBins,firstStripBin,lastStripBin);
05470 pSigCorVsStrip->GetXaxis()->SetTitle("Strip");
05471 pSigCorVsStrip->GetXaxis()->CenterTitle();
05472 pSigCorVsStrip->GetYaxis()->SetTitle("SigCor");
05473 pSigCorVsStrip->GetYaxis()->CenterTitle();
05474 pSigCorVsStrip->SetLineColor(4);
05475 pSigCorVsStrip->SetLineWidth(3);
05476
05477
05478 TProfile* pSigCorVsStripCoarse=new TProfile
05479 ("pSigCorVsStripCoarse","pSigCorVsStripCoarse",12,0,24);
05480 pSigCorVsStripCoarse->GetXaxis()->SetTitle("Strip");
05481 pSigCorVsStripCoarse->GetXaxis()->CenterTitle();
05482 pSigCorVsStripCoarse->GetYaxis()->SetTitle("SigCor");
05483 pSigCorVsStripCoarse->GetYaxis()->CenterTitle();
05484 pSigCorVsStripCoarse->SetLineColor(2);
05485 pSigCorVsStripCoarse->SetLineWidth(3);
05486
05487
05488 TProfile* pSigCorVsStrip1=new TProfile
05489 ("pSigCorVsStrip1","pSigCorVsStrip1",
05490 stripBins,firstStripBin,lastStripBin);
05491 pSigCorVsStrip1->GetXaxis()->SetTitle("Strip");
05492 pSigCorVsStrip1->GetXaxis()->CenterTitle();
05493 pSigCorVsStrip1->GetYaxis()->SetTitle("SigCor");
05494 pSigCorVsStrip1->GetYaxis()->CenterTitle();
05495 pSigCorVsStrip1->SetLineColor(4);
05496 pSigCorVsStrip1->SetLineWidth(3);
05497
05498
05499 TProfile* pSigCorVsStrip2=new TProfile
05500 ("pSigCorVsStrip2","pSigCorVsStrip2",
05501 stripBins,firstStripBin,lastStripBin);
05502 pSigCorVsStrip2->GetXaxis()->SetTitle("Strip");
05503 pSigCorVsStrip2->GetXaxis()->CenterTitle();
05504 pSigCorVsStrip2->GetYaxis()->SetTitle("SigCor");
05505 pSigCorVsStrip2->GetYaxis()->CenterTitle();
05506 pSigCorVsStrip2->SetLineColor(4);
05507 pSigCorVsStrip2->SetLineWidth(3);
05508
05509
05510 Float_t avRespSpect=0;
05511 Float_t avCorSpect=0;
05512 Float_t avRespSpectCounter=0;
05513 Float_t avRespCalor=0;
05514 Float_t avCorCalor=0;
05515 Float_t avRespCalorCounter=0;
05516
05517 map<Int_t,Float_t> mStripResp1;
05518 map<Int_t,Float_t> mStripResp2;
05519
05520 VldContext vldCtx(static_cast<Detector::Detector_t>(det),
05521 SimFlag::kData,ts);
05522 vldCtx.Print();
05523
05524 DbiResultPtr<CalStripToStrip> dbiCalStripToStrip;
05525 UInt_t numRows=dbiCalStripToStrip.NewQuery(vldCtx,task);
05526
05527 MSG("LIPlexMaps",Msg::kInfo)
05528 <<"New DB query produced "<<numRows<<" rows"
05529 <<", using task="<<task<<endl
05530 <<"Looping over rows..."<<endl;
05531
05532
05533 for(UInt_t i=0;i<numRows;i++) {
05534 const CalStripToStrip* calStripToStrip=dbiCalStripToStrip.GetRow(i);
05535
05536 Float_t response=calStripToStrip->GetResponse();
05537 Float_t responseErr=calStripToStrip->GetResponseErr();
05538 PlexStripEndId seid=calStripToStrip->GetStripEndId();
05539 Int_t plane=seid.GetPlane();
05540 Int_t strip=seid.GetStrip();
05541 Int_t se=seid.GetEnd();
05542
05543 if (plane==2){
05544 if (se==1){
05545 mStripResp1[strip]=response;
05546 }
05547 else if (se==2){
05548 mStripResp2[strip]=response;
05549 }
05550 }
05551
05552 pSigCorVsStrip->Fill(strip,response);
05553 pSigCorVsPlane->Fill(plane,response);
05554
05555 if (se==StripEnd::kEast){
05556 hRespE->Fill(response);
05557 pSigCorVsStrip1->Fill(strip,response);
05558 pSigCorVsPlane1->Fill(plane,response);
05559 hStVsPlResp1->Fill(plane,strip,response);
05560 hStVsPlRespErr1->Fill(plane,strip,responseErr);
05561 }
05562 else if (se==StripEnd::kWest){
05563 hRespW->Fill(response);
05564 pSigCorVsStrip2->Fill(strip,response);
05565 pSigCorVsPlane2->Fill(plane,response);
05566 hStVsPlResp2->Fill(plane,strip,response);
05567 hStVsPlRespErr2->Fill(plane,strip,responseErr);
05568
05569 if (plane>120) {
05570 avRespSpect+=response;
05571 avCorSpect+=1./response;
05572 avRespSpectCounter++;
05573 }
05574 else {
05575 avRespCalor+=response;
05576 avCorCalor+=1./response;
05577 avRespCalorCounter++;
05578 }
05579 }
05580 else cout<<"Ahhhhh"<<endl;
05581
05582 hResponse->Fill(response);
05583 hResponseErr->Fill(responseErr);
05584 }
05585
05586 MSG("LIPlexMaps",Msg::kInfo)
05587 <<"Av response="<<hResponse->GetMean()
05588 <<" (N="<<hResponse->GetEntries()<<")"<<endl
05589 <<" East av response="<<hRespE->GetMean()
05590 <<" (N="<<hRespE->GetEntries()<<")"<<endl
05591 <<" West av response="<<hRespW->GetMean()
05592 <<" (N="<<hRespW->GetEntries()<<")"<<endl;
05593
05594
05595 avRespSpect/=avRespSpectCounter;
05596 avCorSpect/=avRespSpectCounter;
05597 avRespCalor/=avRespCalorCounter;
05598 avCorCalor/=avRespCalorCounter;
05599
05600 MSG("LIPlexMaps",Msg::kInfo)
05601 <<endl
05602 <<"Calorimeter av response ="<<avRespCalor
05603 <<"(N="<<avRespCalorCounter<<")"
05604 <<endl
05605 <<"Calorimeter av correction ="<<avCorCalor
05606 <<endl
05607 <<"Spectrometer av response ="<<avRespSpect
05608 <<"(N="<<avRespSpectCounter<<")"
05609 <<endl
05610 <<"Spectrometer av correction="<<avCorSpect
05611 <<endl;
05612
05613 for (UInt_t i=0;i<mStripResp2.size();i++){
05614 cout<<"Strip="<<i<<", response 1="<<mStripResp1[i]
05615 <<" response 2="<<mStripResp2[i]<<endl;
05616 }
05617
05618 TCanvas *cResponse=new TCanvas
05619 ("cResponse","cResponse",0,0,1000,1000);
05620 cResponse->SetFillColor(0);
05621 cResponse->Divide(2,1);
05622 cResponse->cd(1);
05623 hResponse->Draw();
05624 cResponse->cd(2);
05625 hResponseErr->Draw();
05626
05627 TCanvas *cPlSt=new TCanvas
05628 ("cPlSt","cPlSt",0,0,1000,1000);
05629 cPlSt->SetFillColor(0);
05630 cPlSt->Divide(1,2);
05631 cPlSt->cd(1);
05632 pSigCorVsPlane->Draw();
05633 cPlSt->cd(2);
05634 pSigCorVsStrip->Draw();
05635
05636 TCanvas *cPlSt1_2=new TCanvas
05637 ("cPlSt1_2","cPlSt1_2",0,0,1000,1000);
05638 cPlSt1_2->SetFillColor(0);
05639 cPlSt1_2->Divide(2,2);
05640 cPlSt1_2->cd(1);
05641 pSigCorVsPlane1->Draw();
05642 cPlSt1_2->cd(2);
05643 pSigCorVsPlane2->Draw();
05644 cPlSt1_2->cd(3);
05645 pSigCorVsStrip1->Draw();
05646 cPlSt1_2->cd(4);
05647 pSigCorVsStrip2->Draw();
05648
05649 TCanvas *cStVsPlResp=new TCanvas
05650 ("cStVsPlResp","cStVsPlResp",0,0,1000,1000);
05651 cStVsPlResp->SetFillColor(0);
05652 cStVsPlResp->Divide(1,2);
05653 cStVsPlResp->cd(1);
05654 hStVsPlResp1->Draw("colz");
05655 cStVsPlResp->cd(2);
05656 hStVsPlResp2->Draw("colz");
05657
05658 TCanvas *cStVsPlRespErr=new TCanvas
05659 ("cStVsPlRespErr","cStVsPlRespErr",0,0,1000,1000);
05660 cStVsPlRespErr->SetFillColor(0);
05661 cStVsPlRespErr->Divide(1,2);
05662 cStVsPlRespErr->cd(1);
05663 hStVsPlRespErr1->SetMaximum(0.12);
05664 hStVsPlRespErr2->SetMaximum(0.12);
05665 hStVsPlRespErr1->Draw("colz");
05666 cStVsPlRespErr->cd(2);
05667 hStVsPlRespErr2->Draw("colz");
05668
05669 cout<<"Printing histos..."<<endl;
05670 cResponse->Print("stripToStrip.ps[");
05671 cResponse->Print("stripToStrip.ps");
05672 cStVsPlResp->Print("stripToStrip.ps");
05673 cStVsPlRespErr->Print("stripToStrip.ps");
05674 cPlSt->Print("stripToStrip.ps");
05675 cPlSt1_2->Print("stripToStrip.ps");
05676 cResponse->Print("stripToStrip.ps]");
05677 cout<<"Finished printing histos"<<endl;
05678
05679 MSG("LIPlexMaps",Msg::kInfo)
05680 <<endl<<" ** Finished the ReadDbCalStripToStrip() method... **"<<endl;
05681 }
05682
05683
05684
05685 void LIPlexMaps::ReadDbCalStripAtten(Int_t det,VldTimeStamp ts, Int_t task) {
05686 MSG("LIPlexMaps",Msg::kInfo)
05687 <<endl<<" ** Running the ReadDbCalStripToStrip() method... ** "<<endl;
05688
05689 this->SetDetector(det);
05690
05691 TH1F *hShortAmp = new TH1F("hShortAmp","Short Attenuation fraction",200,0,1);
05692 hShortAmp->GetXaxis()->SetTitle("Short Attenuation fraction");
05693 hShortAmp->GetXaxis()->CenterTitle();
05694 hShortAmp->GetYaxis()->SetTitle("");
05695 hShortAmp->GetYaxis()->CenterTitle();
05696 hShortAmp->SetLineColor(2);
05697 hShortAmp->SetFillStyle(3015);
05698 hShortAmp->SetFillColor(2);
05699 hShortAmp->SetLineWidth(3);
05700
05701
05702 TH2F *hShortAmpDet = new TH2F("hShortAmpDet","Short Attenuation fraction",282,0,282,96,0,96);
05703 hShortAmpDet->GetXaxis()->SetTitle("Plane NO.");
05704 hShortAmpDet->GetXaxis()->CenterTitle();
05705 hShortAmpDet->GetYaxis()->SetTitle("Strip NO.");
05706 hShortAmpDet->GetYaxis()->CenterTitle();
05707
05708 TH1F *hLongAmp = new TH1F("hLongAmp","Long Attenuation fraction",200,0,1);
05709 hLongAmp->GetXaxis()->SetTitle("Long Attenuation fraction");
05710 hLongAmp->GetXaxis()->CenterTitle();
05711 hLongAmp->GetYaxis()->SetTitle("");
05712 hLongAmp->GetYaxis()->CenterTitle();
05713 hLongAmp->SetLineColor(4);
05714 hLongAmp->SetFillStyle(3015);
05715 hLongAmp->SetFillColor(4);
05716 hLongAmp->SetLineWidth(3);
05717
05718
05719 TH2F *hLongAmpDet = new TH2F("hLongAmpDet","Long Attenuation fraction",282,0,282,96,0,96);
05720 hLongAmpDet->GetXaxis()->SetTitle("Plane NO.");
05721 hLongAmpDet->GetXaxis()->CenterTitle();
05722 hLongAmpDet->GetYaxis()->SetTitle("Strip NO.");
05723 hLongAmpDet->GetYaxis()->CenterTitle();
05724
05725 TH1F *hShortLength = new TH1F("hShortLength","Short Attenuation Length",200,0,5.);
05726 hShortLength->GetXaxis()->SetTitle("Short Attenuation Length (m)");
05727 hShortLength->GetXaxis()->CenterTitle();
05728 hShortLength->GetYaxis()->SetTitle("");
05729 hShortLength->GetYaxis()->CenterTitle();
05730 hShortLength->SetLineColor(2);
05731 hShortLength->SetFillStyle(3015);
05732 hShortLength->SetFillColor(2);
05733 hShortLength->SetLineWidth(3);
05734
05735
05736 TH2F *hShortLenDet = new TH2F("hShortLenDet","Short Attenuation Length",282,0,282,96,0,96);
05737 hShortLenDet->GetXaxis()->SetTitle("Plane NO.");
05738 hShortLenDet->GetXaxis()->CenterTitle();
05739 hShortLenDet->GetYaxis()->SetTitle("Strip NO.");
05740 hShortLenDet->GetYaxis()->CenterTitle();
05741
05742 TH1F *hLongLength = new TH1F("hLongLength","Long Attenuation Length",200,0,50);
05743 hLongLength->GetXaxis()->SetTitle("Long Attenuation Length (m)");
05744 hLongLength->GetXaxis()->CenterTitle();
05745 hLongLength->GetYaxis()->SetTitle("");
05746 hLongLength->GetYaxis()->CenterTitle();
05747 hLongLength->SetLineColor(4);
05748 hLongLength->SetFillStyle(3015);
05749 hLongLength->SetFillColor(4);
05750 hLongLength->SetLineWidth(3);
05751
05752
05753 TH2F *hLongLenDet = new TH2F("hLongLenDet","Long Attenuation Length",282,0,282,96,0,96);
05754 hLongLenDet->GetXaxis()->SetTitle("Plane NO.");
05755 hLongLenDet->GetXaxis()->CenterTitle();
05756 hLongLenDet->GetYaxis()->SetTitle("Strip NO.");
05757 hLongLenDet->GetYaxis()->CenterTitle();
05758
05759 VldContext vldCtx(static_cast<Detector::Detector_t>(det),SimFlag::kData,ts);
05760 vldCtx.Print();
05761
05762 DbiResultPtr<CalStripAtten> dbiCalStripAtten;
05763 UInt_t numRows = dbiCalStripAtten.NewQuery(vldCtx,task);
05764
05765 MSG("LIPlexMaps",Msg::kInfo)
05766 <<"New DB query produced "<<numRows<<" rows"
05767 <<", using task="<<task<<endl
05768 <<"Looping over rows..."<<endl;
05769
05770
05771
05772
05773
05774
05775
05776
05777
05778
05779
05780
05781
05782
05783
05784
05785
05786
05787
05788
05789
05790
05791
05792
05793
05794
05795
05796
05797
05798
05799
05800
05801
05802
05803
05804
05805
05806
05807
05808 for(UInt_t i=0;i<numRows;i++) {
05809 const CalStripAtten* calStripAtten=dbiCalStripAtten.GetRow(i);
05810 Float_t Lambda1 = calStripAtten->GetLambda1();
05811 Float_t Lambda2 = calStripAtten->GetLambda2();
05812 Float_t frac1 = calStripAtten->GetFrac1();
05813
05814
05815
05816 PlexStripEndId seid = calStripAtten->GetStripEndId();
05817 Int_t plane = seid.GetPlane();
05818 Int_t strip = seid.GetStrip();
05819
05820
05821 hShortAmp->Fill(frac1);
05822 hLongAmp->Fill(1-frac1);
05823 hShortLength->Fill(Lambda1);
05824 hLongLength->Fill(Lambda2);
05825 hShortAmpDet->Fill(plane,strip,frac1);
05826 hLongAmpDet->Fill(plane,strip,1-frac1);
05827 hShortLenDet->Fill(plane,strip,Lambda1);
05828 hLongLenDet->Fill(plane,strip,Lambda2);
05829 }
05830
05831 TCanvas *cAtten = new TCanvas("cAtten","Attenuation Parameters",0,0,800,1000);
05832 cAtten->SetFillColor(0);
05833 cAtten->Divide(2,2);
05834 cAtten->cd(1);
05835 hShortAmp->Draw();
05836 cAtten->cd(2);
05837 hLongAmp->Draw();
05838 cAtten->cd(3);
05839 hShortLength->Draw();
05840 cAtten->cd(4);
05841 hLongLength->Draw();
05842
05843 TCanvas *cDet = new TCanvas("cDet","Attenuation Parameters for All the Strips",0,0,800,1000);
05844 cDet->SetFillColor(0);
05845 cDet->Divide(2,2);
05846 cDet->cd(1);
05847 hShortAmpDet->Draw("colz");
05848 cDet->cd(2);
05849 hLongAmpDet->Draw("colz");
05850 cDet->cd(3);
05851 hShortLenDet->Draw("colz");
05852 cDet->cd(4);
05853 hLongLenDet->Draw("colz");
05854
05855 cDet->Print("stripAtten.ps[");
05856 cDet->Print("stripAtten.ps");
05857 cAtten->Print("stripAtten.ps");
05858 cDet->Print("stripAtten.ps]");
05859
05860 MSG("LIPlexMaps",Msg::kInfo)
05861 <<endl<<" ** Finished the ReadDbCalStripAtten() method... ** "<<endl;
05862 }
05863
05864
05865
05866 void LIPlexMaps::CompareStripToStrip(Int_t det,VldTimeStamp ts,
05867 Int_t taskA,Int_t taskB)
05868 {
05869 MSG("LIPlexMaps",Msg::kInfo)
05870 <<endl<<" ** Running the CompareStripToStrip() method... ** "<<endl;
05871
05872 this->SetDetector(det);
05873
05874 const Int_t firstStripBin=FIRSTSTRIP-2;
05875 const Int_t lastStripBin=LASTSTRIP+2;
05876 const Int_t stripBins=lastStripBin-firstStripBin;
05877
05878 const Int_t firstPlaneBin=FIRSTPLANE-2;;
05879 const Int_t lastPlaneBin=LASTPLANE+2;
05880 const Int_t planeBins=lastPlaneBin-firstPlaneBin;
05881
05882
05883 TH1F *hResponse=new TH1F("hResponse","hResponse",300,-1,10);
05884 hResponse->GetXaxis()->SetTitle("Response of Stripends");
05885 hResponse->GetXaxis()->CenterTitle();
05886 hResponse->GetYaxis()->SetTitle("");
05887 hResponse->GetYaxis()->CenterTitle();
05888 hResponse->SetLineColor(2);
05889 hResponse->SetFillStyle(3015);
05890 hResponse->SetFillColor(2);
05891 hResponse->SetLineWidth(3);
05892
05893
05894 TH1F *hResponseErr=new TH1F("hResponseErr","hResponseErr",
05895 200,-0.02,0.2);
05896 hResponseErr->GetXaxis()->SetTitle("ResponseErr of Stripends");
05897 hResponseErr->GetXaxis()->CenterTitle();
05898 hResponseErr->GetYaxis()->SetTitle("");
05899 hResponseErr->GetYaxis()->CenterTitle();
05900 hResponseErr->SetLineColor(3);
05901 hResponseErr->SetFillStyle(3015);
05902 hResponseErr->SetFillColor(3);
05903 hResponseErr->SetLineWidth(3);
05904
05905
05906 TProfile* pRatioVsPlane=new TProfile
05907 ("pRatioVsPlane","pRatioVsPlane",
05908 planeBins,firstPlaneBin,lastPlaneBin);
05909 pRatioVsPlane->GetXaxis()->SetTitle("Plane");
05910 pRatioVsPlane->GetXaxis()->CenterTitle();
05911 pRatioVsPlane->GetYaxis()->SetTitle("Ratio");
05912 pRatioVsPlane->GetYaxis()->CenterTitle();
05913 pRatioVsPlane->SetLineColor(2);
05914 pRatioVsPlane->SetLineWidth(3);
05915
05916
05917 TProfile* pRatioVsPlaneCoarse=new TProfile
05918 ("pRatioVsPlaneCoarse","pRatioVsPlaneCoarse",6,0,60);
05919 pRatioVsPlaneCoarse->SetTitle("Ratio of S2S Cal. Const. (Cosmic/PS)");
05920 pRatioVsPlaneCoarse->GetXaxis()->SetTitle("Plane");
05921 pRatioVsPlaneCoarse->GetXaxis()->CenterTitle();
05922 pRatioVsPlaneCoarse->GetYaxis()->SetTitle("Ratio");
05923 pRatioVsPlaneCoarse->GetYaxis()->CenterTitle();
05924 pRatioVsPlaneCoarse->SetLineColor(2);
05925 pRatioVsPlaneCoarse->SetLineWidth(3);
05926
05927
05928 TProfile* pRatioVsPlane1=new TProfile
05929 ("pRatioVsPlane1","pRatioVsPlane1",
05930 planeBins,firstPlaneBin,lastPlaneBin);
05931 pRatioVsPlane1->GetXaxis()->SetTitle("Plane");
05932 pRatioVsPlane1->GetXaxis()->CenterTitle();
05933 pRatioVsPlane1->GetYaxis()->SetTitle("Ratio");
05934 pRatioVsPlane1->GetYaxis()->CenterTitle();
05935 pRatioVsPlane1->SetLineColor(2);
05936 pRatioVsPlane1->SetLineWidth(3);
05937
05938
05939 TProfile* pRatioVsPlane2=new TProfile
05940 ("pRatioVsPlane2","pRatioVsPlane2",
05941 planeBins,firstPlaneBin,lastPlaneBin);
05942 pRatioVsPlane2->GetXaxis()->SetTitle("Plane");
05943 pRatioVsPlane2->GetXaxis()->CenterTitle();
05944 pRatioVsPlane2->GetYaxis()->SetTitle("Ratio");
05945 pRatioVsPlane2->GetYaxis()->CenterTitle();
05946 pRatioVsPlane2->SetLineColor(2);
05947 pRatioVsPlane2->SetLineWidth(3);
05948
05949
05950 Int_t coarseStBins=(lastStripBin-firstStripBin)/2;
05951 TProfile* pRatioVsStripO1=new TProfile
05952 ("pRatioVsStripO1","pRatioVsStripO1",
05953 coarseStBins,firstStripBin,lastStripBin);
05954 pRatioVsStripO1->GetXaxis()->SetTitle("Strip");
05955 pRatioVsStripO1->GetXaxis()->CenterTitle();
05956 pRatioVsStripO1->GetYaxis()->SetTitle("Ratio");
05957 pRatioVsStripO1->GetYaxis()->CenterTitle();
05958 pRatioVsStripO1->SetLineColor(2);
05959 pRatioVsStripO1->SetLineWidth(3);
05960
05961
05962 TProfile* pRatioVsStripO2=new TProfile
05963 ("pRatioVsStripO2","pRatioVsStripO2",
05964 coarseStBins,firstStripBin,lastStripBin);
05965 pRatioVsStripO2->GetXaxis()->SetTitle("Strip");
05966 pRatioVsStripO2->GetXaxis()->CenterTitle();
05967 pRatioVsStripO2->GetYaxis()->SetTitle("Ratio");
05968 pRatioVsStripO2->GetYaxis()->CenterTitle();
05969 pRatioVsStripO2->SetLineColor(2);
05970 pRatioVsStripO2->SetLineWidth(3);
05971
05972
05973 TProfile* pRatioVsStripE1=new TProfile
05974 ("pRatioVsStripE1","pRatioVsStripE1",
05975 coarseStBins,firstStripBin,lastStripBin);
05976 pRatioVsStripE1->GetXaxis()->SetTitle("Strip");
05977 pRatioVsStripE1->GetXaxis()->CenterTitle();
05978 pRatioVsStripE1->GetYaxis()->SetTitle("Ratio");
05979 pRatioVsStripE1->GetYaxis()->CenterTitle();
05980 pRatioVsStripE1->SetLineColor(2);
05981 pRatioVsStripE1->SetLineWidth(3);
05982
05983
05984 TProfile* pRatioVsStripE2=new TProfile
05985 ("pRatioVsStripE2","pRatioVsStripE2",
05986 coarseStBins,firstStripBin,lastStripBin);
05987 pRatioVsStripE2->GetXaxis()->SetTitle("Strip");
05988 pRatioVsStripE2->GetXaxis()->CenterTitle();
05989 pRatioVsStripE2->GetYaxis()->SetTitle("Ratio");
05990 pRatioVsStripE2->GetYaxis()->CenterTitle();
05991 pRatioVsStripE2->SetLineColor(2);
05992 pRatioVsStripE2->SetLineWidth(3);
05993
05994
05995 TProfile* pRatioVsStrip=new TProfile
05996 ("pRatioVsStrip","pRatioVsStrip",
05997 stripBins,firstStripBin,lastStripBin);
05998 pRatioVsStrip->GetXaxis()->SetTitle("Strip");
05999 pRatioVsStrip->GetXaxis()->CenterTitle();
06000 pRatioVsStrip->GetYaxis()->SetTitle("Ratio");
06001 pRatioVsStrip->GetYaxis()->CenterTitle();
06002 pRatioVsStrip->SetLineColor(4);
06003 pRatioVsStrip->SetLineWidth(3);
06004
06005
06006 TProfile* pRatioVsStripCoarse=new TProfile
06007 ("pRatioVsStripCoarse","pRatioVsStripCoarse",12,0,24);
06008 pRatioVsStripCoarse->SetTitle("Ratio of S2S Cal. Const. (Cosmic/PS)");
06009 pRatioVsStripCoarse->GetXaxis()->SetTitle("Strip");
06010 pRatioVsStripCoarse->GetXaxis()->CenterTitle();
06011 pRatioVsStripCoarse->GetYaxis()->SetTitle("Ratio");
06012 pRatioVsStripCoarse->GetYaxis()->CenterTitle();
06013 pRatioVsStripCoarse->SetLineColor(2);
06014 pRatioVsStripCoarse->SetLineWidth(3);
06015
06016
06017 TProfile* pRatioVsStripCoarseFront=new TProfile
06018 ("pRatioVsStripCoarseFront","pRatioVsStripCoarseFront",12,0,24);
06019 pRatioVsStripCoarseFront->
06020 SetTitle("Ratio of S2S Cal. Const. Det. Front (Cosmic/PS)");
06021 pRatioVsStripCoarseFront->GetXaxis()->SetTitle("Strip");
06022 pRatioVsStripCoarseFront->GetXaxis()->CenterTitle();
06023 pRatioVsStripCoarseFront->GetYaxis()->SetTitle("Ratio");
06024 pRatioVsStripCoarseFront->GetYaxis()->CenterTitle();
06025 pRatioVsStripCoarseFront->SetLineColor(2);
06026 pRatioVsStripCoarseFront->SetLineWidth(3);
06027
06028
06029 TProfile* pRatioVsStripCoarseBack=new TProfile
06030 ("pRatioVsStripCoarseBack","pRatioVsStripCoarseBack",12,0,24);
06031 pRatioVsStripCoarseBack->
06032 SetTitle("Ratio of S2S Cal. Const. Det. Back (Cosmic/PS)");
06033 pRatioVsStripCoarseBack->GetXaxis()->SetTitle("Strip");
06034 pRatioVsStripCoarseBack->GetXaxis()->CenterTitle();
06035 pRatioVsStripCoarseBack->GetYaxis()->SetTitle("Ratio");
06036 pRatioVsStripCoarseBack->GetYaxis()->CenterTitle();
06037 pRatioVsStripCoarseBack->SetLineColor(2);
06038 pRatioVsStripCoarseBack->SetLineWidth(3);
06039
06040
06041 TProfile* pRatioVsStrip1=new TProfile
06042 ("pRatioVsStrip1","pRatioVsStrip1",
06043 stripBins,firstStripBin,lastStripBin);
06044 pRatioVsStrip1->GetXaxis()->SetTitle("Strip");
06045 pRatioVsStrip1->GetXaxis()->CenterTitle();
06046 pRatioVsStrip1->GetYaxis()->SetTitle("Ratio");
06047 pRatioVsStrip1->GetYaxis()->CenterTitle();
06048 pRatioVsStrip1->SetLineColor(4);
06049 pRatioVsStrip1->SetLineWidth(3);
06050
06051
06052 TProfile* pRatioVsStrip2=new TProfile
06053 ("pRatioVsStrip2","pRatioVsStrip2",
06054 stripBins,firstStripBin,lastStripBin);
06055 pRatioVsStrip2->GetXaxis()->SetTitle("Strip");
06056 pRatioVsStrip2->GetXaxis()->CenterTitle();
06057 pRatioVsStrip2->GetYaxis()->SetTitle("Ratio");
06058 pRatioVsStrip2->GetYaxis()->CenterTitle();
06059 pRatioVsStrip2->SetLineColor(4);
06060 pRatioVsStrip2->SetLineWidth(3);
06061
06062
06063 TProfile2D* pStVsPlRatio1=new TProfile2D
06064 ("pStVsPlRatio1","pStVsPlRatio1",
06065 planeBins,firstPlaneBin,lastPlaneBin,
06066 stripBins,firstStripBin,lastStripBin);
06067 pStVsPlRatio1->GetXaxis()->SetTitle("Plane");
06068 pStVsPlRatio1->GetXaxis()->CenterTitle();
06069 pStVsPlRatio1->GetYaxis()->SetTitle("Strip");
06070 pStVsPlRatio1->GetYaxis()->CenterTitle();
06071
06072
06073 TProfile2D* pStVsPlRatio2=new TProfile2D
06074 ("pStVsPlRatio2","pStVsPlRatio2",
06075 planeBins,firstPlaneBin,lastPlaneBin,
06076 stripBins,firstStripBin,lastStripBin);
06077 pStVsPlRatio2->GetXaxis()->SetTitle("Plane");
06078 pStVsPlRatio2->GetXaxis()->CenterTitle();
06079 pStVsPlRatio2->GetYaxis()->SetTitle("Strip");
06080 pStVsPlRatio2->GetYaxis()->CenterTitle();
06081
06082
06083 map<PlexStripEndId,Float_t> sigCorA;
06084 map<PlexStripEndId,Float_t> sigCorB;
06085
06086 VldContext vldCtx(static_cast<Detector::Detector_t>(det),
06087 SimFlag::kData,ts);
06088 vldCtx.Print();
06089 UInt_t year=0;
06090 ts.GetDate(true,0,&year);
06091
06092 DbiResultPtr<CalStripToStrip> dbiCalStripToStrip;
06093
06094
06095 UInt_t numRows=dbiCalStripToStrip.NewQuery(vldCtx,taskA);
06096
06097 MSG("LIPlexMaps",Msg::kInfo)
06098 <<"New DB query produced "<<numRows<<" rows"
06099 <<", using task="<<taskA<<endl
06100 <<"Looping over rows..."<<endl;
06101
06102 for(UInt_t i=0;i<numRows;i++) {
06103 const CalStripToStrip* calStripToStrip=dbiCalStripToStrip.GetRow(i);
06104
06105 Float_t response=calStripToStrip->GetResponse();
06106 PlexStripEndId seid=calStripToStrip->GetStripEndId();
06107 sigCorA[seid]=response;
06108 }
06109
06110
06111 numRows=dbiCalStripToStrip.NewQuery(vldCtx,taskB);
06112
06113 MSG("LIPlexMaps",Msg::kInfo)
06114 <<"New DB query produced "<<numRows<<" rows"
06115 <<", using task="<<taskB<<endl
06116 <<"Looping over rows..."<<endl;
06117
06118 for(UInt_t i=0;i<numRows;i++) {
06119 const CalStripToStrip* calStripToStrip=dbiCalStripToStrip.GetRow(i);
06120
06121 Float_t response=calStripToStrip->GetResponse();
06122 PlexStripEndId seid=calStripToStrip->GetStripEndId();
06123 sigCorB[seid]=response;
06124 }
06125
06126 MSG("LIPlexMaps",Msg::kInfo)
06127 <<"Found maps, sigCorA size="<<sigCorA.size()
06128 <<", sigCorB size="<<sigCorB.size()<<endl;
06129
06130 for (map<PlexStripEndId,Float_t>::iterator iterA=sigCorA.begin();
06131 iterA!=sigCorA.end();++iterA){
06132
06133 map<PlexStripEndId,Float_t>::iterator iterB=
06134 sigCorB.find(iterA->first);
06135
06136 if (iterB==sigCorB.end()){
06137 MSG("LIPlexMaps",Msg::kWarning)
06138 <<"Ahhhhhh, missing iterB"<<endl;
06139 continue;
06140 }
06141
06142 Int_t planeA=iterA->first.GetPlane();
06143 Int_t stripA=iterA->first.GetStrip();
06144 Int_t seA=iterA->first.GetEnd();
06145 Int_t planeB=iterB->first.GetPlane();
06146 Int_t stripB=iterB->first.GetStrip();
06147 Int_t seB=iterB->first.GetEnd();
06148
06149 MSG("LIPlexMaps",Msg::kDebug)
06150 <<"A: st="<<stripA<<", pl="<<planeA<<", se="<<seA<<endl;
06151 MSG("LIPlexMaps",Msg::kDebug)
06152 <<"B: st="<<stripB<<", pl="<<planeB<<", se="<<seB<<endl;
06153
06154 Float_t sigCorDiff=1;
06155 if (iterB->second!=0){
06156
06157 sigCorDiff=iterA->second/iterB->second;
06158 }
06159 else{
06160 MSG("LIPlexMaps",Msg::kWarning)<<"Ahh, zero calib constant"<<endl;
06161 }
06162
06163
06164
06165 if (planeA==0){
06166 MAXMSG("LIPlexMaps",Msg::kWarning,1)
06167 <<"Cutting out plane 0. It's known to be bad!"<<endl;
06168 continue;
06169 }
06170 else if (planeA==25 && stripA==5){
06171 MAXMSG("LIPlexMaps",Msg::kWarning,1)
06172 <<"Cutting out plane 25, strip 5. It's used to be bad"<<endl;
06173 continue;
06174 }
06175 else if (planeA==35 && year==2002){
06176 MAXMSG("LIPlexMaps",Msg::kWarning,1)
06177 <<"Cutting out plane 35. It's bad in 2002"<<endl;
06178 continue;
06179 }
06180 else if ((planeA==56 || planeA==58) && seA==StripEnd::kWest &&
06181 year==2003){
06182 MAXMSG("LIPlexMaps",Msg::kWarning,1)
06183 <<"Cutting out plane 56 & 58. It's bad in 2003"<<endl;
06184 continue;
06185 }
06186 else if ((planeA==33 || planeA==35) && year==2003){
06187 MAXMSG("LIPlexMaps",Msg::kWarning,1)
06188 <<"Cutting out plane 33 & 35. It's bad in 2003"<<endl;
06189 continue;
06190 }
06191
06192
06193 if (seA==StripEnd::kEast){
06194 pStVsPlRatio1->Fill(planeA,stripA,sigCorDiff);
06195 }
06196 else if (seA==StripEnd::kWest){
06197 pStVsPlRatio2->Fill(planeA,stripA,sigCorDiff);
06198 }
06199
06200
06201 if (stripA>=22 || stripA<=1){
06202 MAXMSG("LIPlexMaps",Msg::kWarning,1)
06203 <<"Making fiducial volume cut on strip"<<endl;
06204 continue;
06205 }
06206
06207 hResponse->Fill(sigCorDiff);
06208 pRatioVsStrip->Fill(stripA,sigCorDiff);
06209 pRatioVsPlane->Fill(planeA,sigCorDiff);
06210 pRatioVsStripCoarse->Fill(stripA,sigCorDiff);
06211 if (planeA<=30) pRatioVsStripCoarseFront->Fill(stripA,sigCorDiff);
06212 if (planeA>30) pRatioVsStripCoarseBack->Fill(stripA,sigCorDiff);
06213 pRatioVsPlaneCoarse->Fill(planeA,sigCorDiff);
06214
06215 if (seA==StripEnd::kEast){
06216 pRatioVsStrip1->Fill(stripA,sigCorDiff);
06217 pRatioVsPlane1->Fill(planeA,sigCorDiff);
06218 if (planeA%2==0) pRatioVsStripE1->Fill(stripA,sigCorDiff);
06219 else if (planeA%2==1) pRatioVsStripO1->Fill(stripA,sigCorDiff);
06220 }
06221 else if (seA==StripEnd::kWest){
06222 pRatioVsStrip2->Fill(stripA,sigCorDiff);
06223 pRatioVsPlane2->Fill(planeA,sigCorDiff);
06224 if (planeA%2==0) pRatioVsStripE2->Fill(stripA,sigCorDiff);
06225 else if (planeA%2==1) pRatioVsStripO2->Fill(stripA,sigCorDiff);
06226 }
06227 }
06228
06229 TCanvas *cResponse=new TCanvas
06230 ("cResponse","cResponse",0,0,1000,800);
06231 cResponse->SetFillColor(0);
06232 cResponse->Divide(2,1);
06233 cResponse->cd(1);
06234 hResponse->Draw();
06235 cResponse->cd(2);
06236 hResponseErr->Draw();
06237
06238 TCanvas *cPlSt=new TCanvas
06239 ("cPlSt","cPlSt",0,0,800,1000);
06240 cPlSt->SetFillColor(0);
06241 cPlSt->Divide(1,2);
06242 cPlSt->cd(1);
06243 pRatioVsPlane->Draw();
06244 cPlSt->cd(2);
06245 pRatioVsStrip->Draw();
06246
06247 TCanvas *cPlStCoarse=new TCanvas
06248 ("cPlStCoarse","cPlStCoarse",0,0,800,1000);
06249 cPlStCoarse->SetFillColor(0);
06250 cPlStCoarse->Divide(1,2);
06251 cPlStCoarse->cd(1);
06252 pRatioVsPlaneCoarse->Draw();
06253 cPlStCoarse->cd(2);
06254 pRatioVsStripCoarse->Draw();
06255
06256 TCanvas *cStCoarse=new TCanvas
06257 ("cStCoarse","cStCoarse",0,0,800,1000);
06258 cStCoarse->SetFillColor(0);
06259 cStCoarse->Divide(1,2);
06260 cStCoarse->cd(1);
06261 pRatioVsStripCoarseFront->Draw();
06262 cStCoarse->cd(2);
06263 pRatioVsStripCoarseBack->Draw();
06264
06265 TCanvas *cPlSt1_2=new TCanvas
06266 ("cPlSt1_2","cPlSt1_2",0,0,1000,1000);
06267 cPlSt1_2->SetFillColor(0);
06268 cPlSt1_2->Divide(2,2);
06269 cPlSt1_2->cd(1);
06270 pRatioVsPlane1->Draw();
06271 cPlSt1_2->cd(2);
06272 pRatioVsPlane2->Draw();
06273 cPlSt1_2->cd(3);
06274 pRatioVsStrip1->Draw();
06275 cPlSt1_2->cd(4);
06276 pRatioVsStrip2->Draw();
06277
06278 TCanvas *cPlSt1_2OE=new TCanvas
06279 ("cPlSt1_2OE","cPlSt1_2OE",0,0,1000,1000);
06280 cPlSt1_2OE->SetFillColor(0);
06281 cPlSt1_2OE->Divide(2,2);
06282 cPlSt1_2OE->cd(1);
06283 pRatioVsStripO1->Draw();
06284 cPlSt1_2OE->cd(2);
06285 pRatioVsStripE1->Draw();
06286 cPlSt1_2OE->cd(3);
06287 pRatioVsStripO2->Draw();
06288 cPlSt1_2OE->cd(4);
06289 pRatioVsStripE2->Draw();
06290
06291 TCanvas *cStVsPl=new TCanvas
06292 ("cStVsPl","cStVsPl",0,0,800,800);
06293 cStVsPl->SetFillColor(0);
06294 cStVsPl->Divide(1,2);
06295 cStVsPl->cd(1);
06296 pStVsPlRatio1->Draw("colz");
06297 cStVsPl->cd(2);
06298 pStVsPlRatio2->Draw("colz");
06299
06300 MSG("LIPlexMaps",Msg::kInfo)
06301 <<endl<<" ** Finished the CompareStripToStrip() method... **"<<endl;
06302 }
06303
06304
06305
06306 void LIPlexMaps::ReadDbGains(Int_t det,SimFlag::ESimFlag simFlag,
06307 VldTimeStamp ts,std::string runNumber,std::string sAgg,Int_t task)
06308 {
06309
06310 MSG("LIPlexMaps",Msg::kInfo)
06311 <<endl<<" ** Running the ReadDbGains() method... ** "<<endl;
06312
06313
06314 string fileName=runNumber+"GainsDB.dat";
06315
06316 ofstream TextFile(fileName.c_str());
06317
06318
06319 this->SetDetector(det);
06320
06321
06322 LIPmt avM64SE1;
06323 LIPmt avM64SE2;
06324 LIPmt avM16VA0SE1;
06325 LIPmt avM16VA0SE2;
06326 LIPmt avM16VA1SE1;
06327 LIPmt avM16VA1SE2;
06328 LIPmt avM16VA2SE1;
06329 LIPmt avM16VA2SE2;
06330
06331
06332 avM64SE1.Initialise(64,1);
06333 avM64SE2.Initialise(64,1);
06334 avM16VA0SE1.Initialise(16,8);
06335 avM16VA0SE2.Initialise(16,8);
06336 avM16VA1SE1.Initialise(16,8);
06337 avM16VA1SE2.Initialise(16,8);
06338 avM16VA2SE1.Initialise(16,8);
06339 avM16VA2SE2.Initialise(16,8);
06340
06341
06342 vector<LIPmt*> vPmts;
06343 vPmts.push_back(&avM64SE1);
06344 vPmts.push_back(&avM64SE2);
06345 vPmts.push_back(&avM16VA0SE1);
06346 vPmts.push_back(&avM16VA0SE2);
06347 vPmts.push_back(&avM16VA1SE1);
06348 vPmts.push_back(&avM16VA1SE2);
06349 vPmts.push_back(&avM16VA2SE1);
06350 vPmts.push_back(&avM16VA2SE2);
06351
06352 Int_t* planeMax=new Int_t[NUMCRATES];
06353 Int_t* planeMin=new Int_t[NUMCRATES];
06354 fLookup.SetPbPlanes(planeMin,planeMax,det);
06355
06356
06357
06358 const Int_t firstStripBin=FIRSTSTRIP-8;
06359 const Int_t lastStripBin=LASTSTRIP+9;
06360 const Int_t bins=lastStripBin-firstStripBin;
06361
06362 string sConstantBit="";
06363
06364 MSG("LIAnalysis",Msg::kInfo)
06365 <<"sConstantBit="<<sConstantBit<<endl;
06366
06367 TH2F **hStripVsPlaneGain=0;
06368 hStripVsPlaneGain= new TH2F*[NUMCRATES];
06369 for (Int_t i=0;i<NUMCRATES;i++){
06370 string sPb=Form("%d",i);
06371 string sTs=ts.AsString("s");
06372
06373 fS="Gains (Crate "+sPb+")";
06374 hStripVsPlaneGain[i]=new TH2F(fS.c_str(),fS.c_str(),
06375 planeMax[i]-planeMin[i],
06376 planeMin[i],planeMax[i],
06377 bins,firstStripBin,lastStripBin);
06378 hStripVsPlaneGain[i]->GetXaxis()->SetTitle("Plane");
06379 hStripVsPlaneGain[i]->GetXaxis()->CenterTitle();
06380 hStripVsPlaneGain[i]->GetYaxis()->SetTitle("Strip");
06381 hStripVsPlaneGain[i]->GetYaxis()->CenterTitle();
06382 hStripVsPlaneGain[i]->SetFillColor(0);
06383
06384 }
06385
06386 TH2F **hAvDetGains=0;
06387 hAvDetGains= new TH2F*[NUMCRATES];
06388 for (Int_t i=0;i<NUMCRATES;i++){
06389 string sPb=Form("%d",i);
06390 string sTs=ts.AsString("s");
06391
06392 fS="Av Detector Gains (Crate "+sPb+")";
06393 hAvDetGains[i]=new TH2F(fS.c_str(),fS.c_str(),
06394 planeMax[i]-planeMin[i],
06395 planeMin[i],planeMax[i],
06396 bins,firstStripBin,lastStripBin);
06397 hAvDetGains[i]->GetXaxis()->SetTitle("Plane");
06398 hAvDetGains[i]->GetXaxis()->CenterTitle();
06399 hAvDetGains[i]->GetYaxis()->SetTitle("Strip");
06400 hAvDetGains[i]->GetYaxis()->CenterTitle();
06401 hAvDetGains[i]->SetFillColor(0);
06402
06403 }
06404
06405 TH2F **hStripVsPlaneGainErr=0;
06406 hStripVsPlaneGainErr= new TH2F*[NUMCRATES];
06407 for (Int_t i=0;i<NUMCRATES;i++){
06408 string sPb=Form("%d",i);
06409 fS="Gain Errors (Crate "+sPb+")";
06410 hStripVsPlaneGainErr[i]=new TH2F(fS.c_str(),fS.c_str(),
06411 planeMax[i]-planeMin[i],
06412 planeMin[i],planeMax[i],
06413 bins,firstStripBin,lastStripBin);
06414 hStripVsPlaneGainErr[i]->GetXaxis()->SetTitle("Plane");
06415 hStripVsPlaneGainErr[i]->GetXaxis()->CenterTitle();
06416 hStripVsPlaneGainErr[i]->GetYaxis()->SetTitle("Strip");
06417 hStripVsPlaneGainErr[i]->GetYaxis()->CenterTitle();
06418 hStripVsPlaneGainErr[i]->SetFillColor(0);
06419
06420 }
06421
06422 TH2F **hStripVsPlaneSPEWidth=0;
06423 hStripVsPlaneSPEWidth= new TH2F*[NUMCRATES];
06424 for (Int_t i=0;i<NUMCRATES;i++){
06425 string sPb=Form("%d",i);
06426 fS="Single PE Width (Crate "+sPb+")";
06427 hStripVsPlaneSPEWidth[i]=new TH2F(fS.c_str(),fS.c_str(),
06428 planeMax[i]-planeMin[i],
06429 planeMin[i],planeMax[i],
06430 bins,firstStripBin,lastStripBin);
06431 hStripVsPlaneSPEWidth[i]->GetXaxis()->SetTitle("Plane");
06432 hStripVsPlaneSPEWidth[i]->GetXaxis()->CenterTitle();
06433 hStripVsPlaneSPEWidth[i]->GetYaxis()->SetTitle("Strip");
06434 hStripVsPlaneSPEWidth[i]->GetYaxis()->CenterTitle();
06435 hStripVsPlaneSPEWidth[i]->SetFillColor(0);
06436
06437 }
06438
06439 TH1F *hGains=new TH1F("hGains","hGains",200,-1,200);
06440 hGains->GetXaxis()->SetTitle("Response of Stripends");
06441 hGains->GetXaxis()->CenterTitle();
06442 hGains->GetYaxis()->SetTitle("");
06443 hGains->GetYaxis()->CenterTitle();
06444 hGains->SetLineColor(2);
06445 hGains->SetFillStyle(3015);
06446 hGains->SetFillColor(2);
06447 hGains->SetLineWidth(3);
06448
06449
06450 TH1F *hGainsAll=new TH1F("hGainsAll","hGainsAll",400,-1,300);
06451 hGainsAll->GetXaxis()->SetTitle("Response of Stripends");
06452 hGainsAll->GetXaxis()->CenterTitle();
06453 hGainsAll->GetYaxis()->SetTitle("");
06454 hGainsAll->GetYaxis()->CenterTitle();
06455 hGainsAll->SetLineColor(2);
06456 hGainsAll->SetFillStyle(3015);
06457 hGainsAll->SetFillColor(2);
06458 hGainsAll->SetLineWidth(3);
06459 hGainsAll->SetBit(TH1::kCanRebin);
06460
06461 VldContext vldCtx(static_cast<Detector::Detector_t>(det),
06462 simFlag,ts);
06463 vldCtx.Print();
06464
06465
06466 PlexHandle plexHandle(vldCtx);
06467
06468 DbiResultPtr<CalADCtoPE> dbiCalADCtoPE;
06469 DbiResultPtr<CalADCtoPEs> dbiCalADCtoPEs;
06470
06471 UInt_t numRows=dbiCalADCtoPE.NewQuery(vldCtx,task);
06472 if(sAgg!="-1") numRows=dbiCalADCtoPEs.NewQuery(vldCtx,task);
06473
06474 MSG("LIPlexMaps",Msg::kInfo)<<endl
06475 <<"New DB query produced "<<numRows<<" rows"<<endl
06476 <<"Looping over rows..."<<endl;
06477
06478
06479 for(UInt_t i=0;i<numRows;i++) {
06480
06481 Float_t gain, gainErr, SPEWidth, SPEWidthErr;
06482 Int_t seId;
06483 UInt_t seidkey;
06484
06485 if(sAgg=="-1") {
06486 const CalADCtoPE* calAdcToPe = dbiCalADCtoPE.GetRow(i);
06487 gain=calAdcToPe->GetGain();
06488 gainErr=calAdcToPe->GetGainErr();
06489 SPEWidth=calAdcToPe->GetSPEWidth();
06490 seId=calAdcToPe->GetStripEndId();
06491 seidkey=calAdcToPe->GetSEIDkey();
06492 } else {
06493 const CalADCtoPEs* calAdcToPe = dbiCalADCtoPEs.GetRow(i);
06494 gain=calAdcToPe->GetGain();
06495 gainErr=calAdcToPe->GetGainErr();
06496 SPEWidth=calAdcToPe->GetSPEWidth();
06497 SPEWidthErr=calAdcToPe->GetSPEWidthErr();
06498 seidkey=calAdcToPe->GetSEIDkey();
06499 }
06500
06501 Int_t plane=-1;
06502 Int_t strip=-1;
06503 Int_t end=-1;
06504 fLookup.UnencodePlnStripEndKey(seidkey,static_cast<Detector::
06505 Detector_t>(det),plane,strip,end);
06506
06507
06508 hGains->Fill(gain);
06509 hGainsAll->Fill(gain);
06510
06511
06512 PlexStripEndId seid(static_cast<Detector::Detector_t>(det),
06513 plane,strip,
06514 static_cast<StripEnd::EStripEnd>(end));
06515
06516 PlexPixelSpotId pixSpotId=plexHandle.GetPixelSpotId(seid);
06517
06518 MSG("LIPlexMaps",Msg::kDebug)
06519 <<"pl="<<plane<<", st="<<strip<<", end="<<end
06520 <<", pix="<<pixSpotId.GetPixel()
06521 <<", pixSpot="<<pixSpotId.GetSpot()
06522 <<endl;
06523
06524 ElecType::Elec_t elecType=plexHandle.GetRawChannelId(seid).
06525 GetElecType();
06526 Int_t vaChip=plexHandle.GetRawChannelId(seid).GetVaChip();
06527
06528
06529
06530 if (elecType==ElecType::kQIE){
06531 if (plane%2==1) avM64SE1.AddMultiPoint(pixSpotId.GetPixel(),
06532 pixSpotId.GetSpot(),gain);
06533 else if (plane%2==0) avM64SE2.AddMultiPoint(pixSpotId.GetPixel(),
06534 pixSpotId.GetSpot(),gain);
06535 }
06536 else if (elecType==ElecType::kVA){
06537 if (vaChip==0){
06538 if (end==1) avM16VA0SE1.AddMultiPoint(pixSpotId.GetPixel(),
06539 pixSpotId.GetSpot(),gain);
06540 if (end==2) avM16VA0SE2.AddMultiPoint(pixSpotId.GetPixel(),
06541 pixSpotId.GetSpot(),gain);
06542 }
06543 else if (vaChip==1){
06544 if (end==1) avM16VA1SE1.AddMultiPoint(pixSpotId.GetPixel(),
06545 pixSpotId.GetSpot(),gain);
06546 if (end==2) avM16VA1SE2.AddMultiPoint(pixSpotId.GetPixel(),
06547 pixSpotId.GetSpot(),gain);
06548 }
06549 else if (vaChip==2){
06550 if (end==1) avM16VA2SE1.AddMultiPoint(pixSpotId.GetPixel(),
06551 pixSpotId.GetSpot(),gain);
06552 if (end==2) avM16VA2SE2.AddMultiPoint(pixSpotId.GetPixel(),
06553 pixSpotId.GetSpot(),gain);
06554 }
06555 }
06556
06557
06558 TextFile<<plane<<"\t"<<strip<< "\t"<<end
06559 <<"\t" <<gain<<"\t" <<gainErr<<"\t" <<SPEWidth<<endl;
06560
06561 Int_t crate=plexHandle.GetRawChannelId(seid).GetCrate();
06562 if (crate>=FIRSTCRATE && crate<=LASTCRATE){
06563 hStripVsPlaneGainErr[crate]->Fill(plane,strip,gainErr);
06564 hStripVsPlaneGain[crate]->Fill(plane,strip,gain);
06565 hStripVsPlaneSPEWidth[crate]->Fill(plane,strip,SPEWidth);
06566 }
06567
06568 Bool_t print=false;
06569 if (det==Detector::kCalDet) print=true;
06570 else if (det==Detector::kFar &&
06571 MsgService::Instance()->
06572 IsActive("LIPlexMaps",Msg::kDebug)) print=true;
06573 else if (det==Detector::kNear &&
06574 MsgService::Instance()->
06575 IsActive("LIPlexMaps",Msg::kDebug)) print=true;
06576
06577 if (print){
06578 MSG("LIPlexMaps",Msg::kInfo)
06579 <<"("<<plane<<";"<<strip<<";"<<end<<")"
06580 <<" Gain="<<gain<<", gainErr="<<gainErr<<", SPEW="<<SPEWidth<<endl;
06581
06582
06583 }
06584 }
06585
06586 for (vector<LIPmt*>::iterator it=vPmts.begin();
06587 it!=vPmts.end();it++) {
06588
06589 if ((*it)->IsEmpty()) cout<<"empty"<<endl;
06590 else{
06591 cout<<"not emp"<<endl;
06592 (*it)->Print();
06593 }
06594 }
06595
06596
06597
06598 for (Int_t pl=*planeMin;pl<*planeMax;pl++){
06599 for (Int_t st=-1;st<NUMSTRIPS+2;st++){
06600 for (Int_t se=0;se<NUMSIDES;se++){
06601
06602
06603 PlexStripEndId seid(static_cast<Detector::Detector_t>
06604 (det),pl,st,
06605 static_cast<StripEnd::EStripEnd>(se+1));
06606
06607
06608 PlexPixelSpotId psid=plexHandle.GetPixelSpotId(seid);
06609 ElecType::Elec_t elecType=plexHandle.GetRawChannelId(seid).
06610 GetElecType();
06611
06612 if (se+1==StripEnd::kWest && elecType==ElecType::kQIE){
06613
06614 Double_t gain=avM64SE2.GetPixelGain(psid.GetPixel());
06615
06616 hAvDetGains[1]->Fill(pl,st,gain);
06617 }
06618 }
06619 }
06620 }
06621
06622 gStyle->SetOptStat(1111111);
06623
06624
06625 if (!avM64SE1.IsEmpty() || !avM64SE2.IsEmpty()){
06626 TCanvas *cPmtFaceM64=new TCanvas
06627 ("cPmtFaceM64","cPmtFaceM64",0,0,1000,550);
06628 cPmtFaceM64->SetFillColor(0);
06629 cPmtFaceM64->Divide(2,1);
06630 cPmtFaceM64->cd(1);
06631 fS="M64 Gains (U view)";
06632 if (!avM64SE1.IsEmpty()) avM64SE1.GetPmtFaceMap(fS.c_str())->
06633 Draw("colztext");
06634 cPmtFaceM64->cd(2);
06635 fS="M64 Gains (V view)";
06636 if (!avM64SE2.IsEmpty()) avM64SE2.GetPmtFaceMap(fS.c_str())->
06637 Draw("colztext");
06638
06639 string sDbPmts="DbPmts";
06640 sDbPmts+=Detector::AsString(static_cast<Detector::
06641 Detector_t>(det));
06642 sDbPmts+=".ps";
06643 cPmtFaceM64->Print(sDbPmts.c_str());
06644
06645 }
06646
06647
06648 if (!avM16VA0SE1.IsEmpty() || !avM16VA0SE1.IsEmpty() ||
06649 !avM16VA1SE1.IsEmpty() || !avM16VA1SE1.IsEmpty() ||
06650 !avM16VA2SE1.IsEmpty() || !avM16VA2SE1.IsEmpty()){
06651
06652 TCanvas *cPmtFaceM16=new TCanvas
06653 ("cPmtFaceM16","cPmtFaceM16",0,0,1000,700);
06654 cPmtFaceM16->SetFillColor(0);
06655 cPmtFaceM16->Divide(3,2);
06656 cPmtFaceM16->cd(1);
06657 fS="M16 Gains (VA0, stripend1)";
06658 if (!avM16VA0SE1.IsEmpty()) avM16VA0SE1.GetPmtFaceMap(fS.c_str())->
06659 Draw("colztext");
06660 cPmtFaceM16->cd(2);
06661 fS="M16 Gains (VA1, stripend1)";
06662 if (!avM16VA1SE1.IsEmpty()) avM16VA1SE1.GetPmtFaceMap(fS.c_str())->
06663 Draw("colztext");
06664 cPmtFaceM16->cd(3);
06665 fS="M16 Gains (VA2, stripend1)";
06666 if (!avM16VA2SE1.IsEmpty()) avM16VA2SE1.GetPmtFaceMap(fS.c_str())->
06667 Draw("colztext");
06668 cPmtFaceM16->cd(4);
06669 fS="M16 Gains (VA0, stripend2)";
06670 if (!avM16VA0SE2.IsEmpty()) avM16VA0SE2.GetPmtFaceMap(fS.c_str())->
06671 Draw("colztext");
06672 cPmtFaceM16->cd(5);
06673 fS="M16 Gains (VA1, stripend2)";
06674 if (!avM16VA1SE2.IsEmpty()) avM16VA1SE2.GetPmtFaceMap(fS.c_str())->
06675 Draw("colztext");
06676 cPmtFaceM16->cd(6);
06677 fS="M16 Gains (VA2, stripend2)";
06678 if (!avM16VA2SE2.IsEmpty()) avM16VA2SE2.GetPmtFaceMap(fS.c_str())->
06679 Draw("colztext");
06680
06681 string sDbPmts="DbPmts";
06682 sDbPmts+=Detector::AsString(static_cast<Detector::
06683 Detector_t>(det));
06684 sDbPmts+=".ps";
06685 cPmtFaceM16->Print(sDbPmts.c_str());
06686
06687 }
06688
06689
06690 TCanvas *cAvDetGain=new TCanvas
06691 ("cAvDetGain","cAvDetGain",0,0,1000,800);
06692 cAvDetGain->SetFillColor(0);
06693 cAvDetGain->cd();
06694 hAvDetGains[1]->Draw("colz");
06695
06696
06697 gStyle->SetOptStat(0);
06698
06699
06700 TCanvas *cStripVsPlaneGain=new TCanvas
06701 ("cStripVsPlaneGain","StripVsPlane: Gain",0,0,1000,800);
06702 cStripVsPlaneGain->SetFillColor(0);
06703 cStripVsPlaneGain->cd();
06704 string sDbGains="DbGains";
06705 sDbGains+=Detector::AsString(static_cast<Detector::
06706 Detector_t>(det));
06707 sDbGains+=".ps";
06708 cStripVsPlaneGain->Print((sDbGains+"[").c_str());
06709 gErrorIgnoreLevel=1;
06710 for (Int_t i=0;i<NUMCRATES;i++){
06711 cStripVsPlaneGain->Clear();
06712 hStripVsPlaneGain[i]->Draw("colz");
06713 cStripVsPlaneGain->Print(sDbGains.c_str());
06714 }
06715 cStripVsPlaneGain->Print((sDbGains+"]").c_str());
06716 gErrorIgnoreLevel=0;
06717
06718
06719 TCanvas *cStripVsPlaneGainErr=new TCanvas
06720 ("cStripVsPlaneGainErr","StripVsPlane: GainErr",0,0,1000,800);
06721 cStripVsPlaneGainErr->SetFillColor(0);
06722 cStripVsPlaneGainErr->cd();
06723 string sDbGainErrs="DbGainErrs";
06724 sDbGainErrs+=Detector::AsString(static_cast<Detector::
06725 Detector_t>(det));
06726 sDbGainErrs+=".ps";
06727 cStripVsPlaneGainErr->Print((sDbGainErrs+"[").c_str());
06728 gErrorIgnoreLevel=1;
06729 for (Int_t i=0;i<NUMCRATES;i++){
06730 cStripVsPlaneGainErr->Clear();
06731 hStripVsPlaneGainErr[i]->Draw("colz");
06732 cStripVsPlaneGainErr->Print(sDbGainErrs.c_str());
06733 }
06734 cStripVsPlaneGainErr->Print((sDbGainErrs+"]").c_str());
06735 gErrorIgnoreLevel=0;
06736
06737
06738 TCanvas *cStripVsPlaneSPEWidth=new TCanvas
06739 ("cStripVsPlaneSPEWidth","StripVsPlane: SPEWidth",0,0,1000,800);
06740 cStripVsPlaneSPEWidth->SetFillColor(0);
06741 cStripVsPlaneSPEWidth->cd();
06742 string sDbSPEWidths="DbSPEWidths";
06743 sDbSPEWidths+=Detector::AsString(static_cast<Detector::
06744 Detector_t>(det));
06745 sDbSPEWidths+=".ps";
06746 cStripVsPlaneSPEWidth->Print((sDbSPEWidths+"[").c_str());
06747 gErrorIgnoreLevel=1;
06748 for (Int_t i=0;i<NUMCRATES;i++){
06749 cStripVsPlaneSPEWidth->Clear();
06750 hStripVsPlaneSPEWidth[i]->Draw("colz");
06751 cStripVsPlaneSPEWidth->Print(sDbSPEWidths.c_str());
06752 }
06753 cStripVsPlaneSPEWidth->Print((sDbSPEWidths+"]").c_str());
06754 gErrorIgnoreLevel=0;
06755
06756 if (det==Detector::kCalDet){
06757 TCanvas *cGain=new TCanvas("cGain","cGain",0,0,1000,800);
06758 cGain->SetFillColor(0);
06759 cGain->Divide(1,2);
06760 cGain->cd(1);
06761 hStripVsPlaneGain[0]->Draw("colz");
06762 cGain->cd(2);
06763 hStripVsPlaneGain[1]->Draw("colz");
06764 }
06765
06766 gStyle->SetOptStat(1111);
06767 TCanvas *cGain=new TCanvas("cGain","cGain",0,0,1000,800);
06768 cGain->SetFillColor(0);
06769 cGain->Divide(2,1);
06770 cGain->cd(1);
06771 hGains->Draw();
06772 cGain->cd(2);
06773 hGainsAll->Draw();
06774
06775 MSG("LIPlexMaps",Msg::kInfo)
06776 <<endl<<" ** Finished the ReadDbGains() method... ** "<<endl;
06777 }
06778
06779
06780
06781 void LIPlexMaps::ReadDbPulserDrift(Int_t det,VldTimeStamp ts)
06782 {
06783 MSG("LIPlexMaps",Msg::kInfo)
06784 <<endl<<" ** Running the ReadDbPulserDrift() method... ** "<<endl;
06785
06786
06787
06788 this->SetDetector(det);
06789
06790 Int_t* planeMax=new Int_t[NUMCRATES];
06791 Int_t* planeMin=new Int_t[NUMCRATES];
06792 fLookup.SetPbPlanes(planeMin,planeMax,det);
06793
06794 const Int_t firstStripBin=FIRSTSTRIP-8;
06795 const Int_t lastStripBin=LASTSTRIP+9;
06796 const Int_t bins=lastStripBin-firstStripBin;
06797
06798 string sConstantBit="";
06799
06800 MSG("LIAnalysis",Msg::kInfo)
06801 <<"sConstantBit="<<sConstantBit<<endl;
06802
06803 TH2F **hStripVsPlaneMean=0;
06804 hStripVsPlaneMean= new TH2F*[NUMCRATES];
06805 for (Int_t i=0;i<NUMCRATES;i++){
06806 string sPb=Form("%d",i);
06807 fS="Mean (Crate "+sPb+")";
06808 hStripVsPlaneMean[i]=new TH2F(fS.c_str(),fS.c_str(),
06809 planeMax[i]-planeMin[i],
06810 planeMin[i],planeMax[i],
06811 bins,firstStripBin,lastStripBin);
06812 hStripVsPlaneMean[i]->GetXaxis()->SetTitle("Plane");
06813 hStripVsPlaneMean[i]->GetXaxis()->CenterTitle();
06814 hStripVsPlaneMean[i]->GetYaxis()->SetTitle("Strip");
06815 hStripVsPlaneMean[i]->GetYaxis()->CenterTitle();
06816 hStripVsPlaneMean[i]->SetFillColor(0);
06817
06818 }
06819
06820 TH2F **hStripVsPlaneError=0;
06821 hStripVsPlaneError= new TH2F*[NUMCRATES];
06822 for (Int_t i=0;i<NUMCRATES;i++){
06823 string sPb=Form("%d",i);
06824 fS="Gain Error (Crate "+sPb+")";
06825 hStripVsPlaneError[i]=new TH2F(fS.c_str(),fS.c_str(),
06826 planeMax[i]-planeMin[i],
06827 planeMin[i],planeMax[i],
06828 bins,firstStripBin,lastStripBin);
06829 hStripVsPlaneError[i]->GetXaxis()->SetTitle("Plane");
06830 hStripVsPlaneError[i]->GetXaxis()->CenterTitle();
06831 hStripVsPlaneError[i]->GetYaxis()->SetTitle("Strip");
06832 hStripVsPlaneError[i]->GetYaxis()->CenterTitle();
06833 hStripVsPlaneError[i]->SetFillColor(0);
06834
06835 }
06836
06837 TH2F **hStripVsPlaneNumEntries=0;
06838 hStripVsPlaneNumEntries= new TH2F*[NUMCRATES];
06839 for (Int_t i=0;i<NUMCRATES;i++){
06840 string sPb=Form("%d",i);
06841 fS="NumEntries_Crate"+sPb;
06842 hStripVsPlaneNumEntries[i]=new TH2F(fS.c_str(),fS.c_str(),
06843 planeMax[i]-planeMin[i],
06844 planeMin[i],planeMax[i],
06845 bins,firstStripBin,lastStripBin);
06846 hStripVsPlaneNumEntries[i]->GetXaxis()->SetTitle("Plane");
06847 hStripVsPlaneNumEntries[i]->GetXaxis()->CenterTitle();
06848 hStripVsPlaneNumEntries[i]->GetYaxis()->SetTitle("Strip");
06849 hStripVsPlaneNumEntries[i]->GetYaxis()->CenterTitle();
06850 hStripVsPlaneNumEntries[i]->SetFillColor(0);
06851
06852 }
06853
06854 VldContext vldCtx(static_cast<Detector::Detector_t>(det),
06855 SimFlag::kData,ts);
06856 vldCtx.Print();
06857
06858
06859
06860 DbiResultPtr<PulserRefDrift> dbiPulserDrift;
06861
06862
06863 UInt_t numRows=dbiPulserDrift.NewQuery(vldCtx,0);
06864
06865 MSG("LIPlexMaps",Msg::kInfo)
06866 <<"New DB query produced "<<numRows<<" rows"<<endl
06867 <<"Looping over rows..."<<endl;
06868
06870
06872 for(UInt_t i=0;i<numRows;i++) {
06873
06874
06875 const PulserRefDrift* pulserDrift = dbiPulserDrift.GetRow(i);
06876
06877
06878 Float_t mean=pulserDrift->GetMean();
06879 Float_t error=pulserDrift->GetError();
06880 Float_t numEntries=pulserDrift->GetNumEntries();
06881
06882 UInt_t seidkey=pulserDrift->GetStripEnd();
06883 Int_t plane=-1;
06884 Int_t strip=-1;
06885 Int_t end=-1;
06886 fLookup.UnencodePlnStripEndKey(seidkey,static_cast<Detector::
06887 Detector_t>(det),plane,strip,end);
06888
06889 Int_t crate=Plane2Crate(plane,end,det);
06890 if (crate>=FIRSTCRATE && crate<=LASTCRATE){
06891 hStripVsPlaneMean[crate]->Fill(plane,strip,mean);
06892 hStripVsPlaneError[crate]->Fill(plane,strip,error);
06893 hStripVsPlaneNumEntries[crate]->Fill(plane,strip,numEntries);
06894 }
06895
06896 Bool_t print=false;
06897
06898 if (det==Detector::kCalDet) print=true;
06899 else if (det==Detector::kFar &&
06900 MsgService::Instance()->
06901 IsActive("LIPlexMaps",Msg::kDebug)) print=true;
06902 else if (det==Detector::kNear &&
06903 MsgService::Instance()->
06904 IsActive("LIPlexMaps",Msg::kDebug)) print=true;
06905
06906 if (print){
06907 MSG("LIPlexMaps",Msg::kInfo)
06908 <<"("<<plane<<";"<<strip<<";"<<end<<")"
06909 <<" Mean="<<mean<<", error="<<error<<", numEnt="<<numEntries
06910 <<", seidkey="<<seidkey<<endl;
06911 }
06912 }
06914
06916
06917
06918 gStyle->SetOptStat(0);
06919
06920
06921 TCanvas *cStripVsPlaneMean=new TCanvas
06922 ("cStripVsPlaneMean","StripVsPlane: Mean",0,0,1000,800);
06923 cStripVsPlaneMean->SetFillColor(0);
06924 cStripVsPlaneMean->cd();
06925 string sDbMeans="DbDrift";
06926 sDbMeans+=Detector::AsString(static_cast<Detector::
06927 Detector_t>(det));
06928 sDbMeans+=".ps";
06929 cStripVsPlaneMean->Print((sDbMeans+"[").c_str());
06930 gErrorIgnoreLevel=1;
06931
06932 gStyle->SetOptStat(0);
06933 for (Int_t i=0;i<NUMCRATES;i++){
06934 cStripVsPlaneMean->Clear();
06935 hStripVsPlaneMean[i]->Draw("colz");
06936 cStripVsPlaneMean->Print(sDbMeans.c_str());
06937 }
06938
06939 cStripVsPlaneMean->Print((sDbMeans+"]").c_str());
06940 gErrorIgnoreLevel=0;
06941
06942 TCanvas *cStripVsPlaneError=new TCanvas
06943 ("cStripVsPlaneError","StripVsPlane: Error",0,0,1000,800);
06944 cStripVsPlaneError->SetFillColor(0);
06945 cStripVsPlaneError->Divide(1,2);
06946 cStripVsPlaneError->cd(1);
06947 hStripVsPlaneError[0]->Draw("colz");
06948 cStripVsPlaneError->cd(2);
06949 hStripVsPlaneError[1]->Draw("colz");
06950
06951 TCanvas *cStripVsPlaneNumEntries=new TCanvas
06952 ("cStripVsPlaneNumEntries","StripVsPlane: NumEntries",
06953 0,0,1000,800);
06954 cStripVsPlaneNumEntries->SetFillColor(0);
06955 cStripVsPlaneNumEntries->Divide(1,2);
06956 cStripVsPlaneNumEntries->cd(1);
06957 hStripVsPlaneNumEntries[0]->Draw("colz");
06958 cStripVsPlaneNumEntries->cd(2);
06959 hStripVsPlaneNumEntries[1]->Draw("colz");
06960
06961 MSG("LIPlexMaps",Msg::kInfo)
06962 <<endl<<" ** Finished the ReadDbPulserDrift() method... ** "<<endl;
06963 }
06964
06965
06966
06967 void LIPlexMaps::DriftWithTime(VldRange vldRng,
06968 Float_t pointSpacingMinutes)
06969 {
06970 MSG("LIPlexMaps",Msg::kInfo)
06971 <<endl<<" ** Running the DriftWithTime method... ** "<<endl;
06972
06973
06974 VldTimeStamp startTime=vldRng.GetTimeStart();
06975 VldTimeStamp endTime=vldRng.GetTimeEnd();
06976 const Detector::Detector_t det=static_cast
06977 <Detector::Detector_t>(vldRng.GetDetectorMask());
06978 const SimFlag::ESimFlag simFlag=static_cast
06979 <SimFlag::ESimFlag>(vldRng.GetSimMask());
06980
06981
06982 VldContext startVldCtx(det,simFlag,startTime);
06983
06984
06985 if (det==Detector::kCalDet){
06986 fLookup.SetDetector(static_cast<Int_t>(det));
06987 }
06988 else if (det==Detector::kFar){
06989 fLookup.SetDetector(static_cast<Int_t>(det));
06990 }
06991 else if (det==Detector::kNear){
06992 fLookup.SetDetector(static_cast<Int_t>(det));
06993 }
06994 else{
06995 MSG("LIPlexMaps",Msg::kWarning)
06996 <<"Detector not supported="
06997 <<Detector::AsString(det)<<endl
06998 <<"Program will exit here..."<<endl;
06999 exit(1);
07000 }
07001
07002 DbiResultPtr<PulserRawDrift> dbiPulserDrift;
07003 DbiResultPtr<PulserRawDriftF> dbiPulserDriftF;
07004
07005 MSG("LIPlexMaps",Msg::kInfo)
07006 <<"Creating maps..."<<endl;
07007
07008 map<Int_t,LIPulserPin> refAdcPinRatio=this->
07009 GetRefAdcPinRatio(startVldCtx);
07010
07011 map<UInt_t,LIRun> stripEnds;
07012 map<PlexLedId,LIRun> pins;
07013
07014 VldContext* vldCtx=0;
07015 const PulserRawDrift *pulserDrift;
07016 const PulserRawDriftF *pulserDriftF;
07017 string sLastVldRange="Not set!";
07018
07019
07020 StripEnd::EStripEnd stripEndType=StripEnd::kUnknown;
07021 StripEnd::EStripEnd stripEndTypeF=StripEnd::kUnknown;
07022
07023
07024 PlexHandle* plexHandle=0;
07025
07026 Int_t pointSpacingSecs=static_cast<Int_t>(pointSpacingMinutes*60);
07027 Int_t startTimeSecs=startTime.GetSec();
07028 Int_t endTimeSecs=endTime.GetSec();
07029 Int_t secCounter=startTimeSecs;
07030
07031 MSG("LIPlexMaps",Msg::kInfo)
07032 <<"Starting main loop over vld range..."<<endl;
07033 while(secCounter<endTimeSecs){
07034 VldTimeStamp currentLoopTime(secCounter,0);
07035
07036
07037 if (MsgService::Instance()->IsActive("LIPlexMaps",Msg::kInfo)){
07038 MSG("LIPlexMaps",Msg::kInfo)<<"New Loop ";
07039 currentLoopTime.Print();
07040 }
07041 vldCtx=new VldContext(Detector::kCalDet,SimFlag::kData,
07042 currentLoopTime);
07043
07044
07045 map<Int_t,LIPulserPin> tempRefAdcPinRatio=
07046 this->GetRefAdcPinRatio(*vldCtx);
07047 if (tempRefAdcPinRatio.size()>0){
07048 refAdcPinRatio=tempRefAdcPinRatio;
07049 MSG("LIPlexMaps",Msg::kInfo)
07050 <<"New pin reference point, regenerated map"<<endl;
07051 }
07052 else{
07053 MSG("LIPlexMaps",Msg::kDebug)
07054 <<"Checked for new pin reference point, doing nothing"
07055 <<" because same as before"<<endl;
07056 }
07057
07058
07059 plexHandle=new PlexHandle(*vldCtx);
07060
07061 UInt_t numRows=dbiPulserDrift.NewQuery(*vldCtx,0);
07062
07063 if (numRows!=static_cast<UInt_t>(NUMPLANES*NUMSTRIPS*NUMENDS)){
07064 MSG("LIPlexMaps",Msg::kWarning)
07065 <<"PulserRawDrift only contains "<<numRows<<" rows"
07066 <<", it should have "<<NUMPLANES*NUMSTRIPS*NUMENDS<<endl;
07067 }
07068
07069 string sVldRange=dbiPulserDrift.GetValidityRec()->GetVldRange().
07070 AsString();
07071
07072 MSG("LIPlexMaps",Msg::kVerbose)
07073 <<"Vld range = "<<sVldRange<<endl;
07074
07075 if (sVldRange==sLastVldRange){
07076 MSG("LIPlexMaps",Msg::kInfo)
07077 <<"Skipping this point because validity range is the same"
07078 <<" as the previous point"<<endl;
07079 MSG("LIPlexMaps",Msg::kDebug)
07080 <<endl
07081 <<"VldRange="<<sVldRange<<endl
07082 <<"Previous VldRange="<<sLastVldRange<<endl;
07083
07084 sLastVldRange=sVldRange;
07085
07086
07087 secCounter+=pointSpacingSecs;
07088
07089
07090 delete vldCtx;
07091 delete plexHandle;
07092 continue;
07093 }
07094
07095
07096 sLastVldRange=sVldRange;
07097
07098 map<Int_t,Float_t> rawPin=this->GetRawPinMap(*vldCtx);
07099 map<PlexLedId,LIPulserPin> rawPinLedMap=this->
07100 GetRawPinLedMap(*vldCtx);
07101 UInt_t numRowsF=dbiPulserDriftF.NewQuery(*vldCtx,0);
07102
07103 if (numRows!=numRowsF){
07104 MSG("LIPlexMaps",Msg::kInfo)
07105 <<"Near and far end tables are different sizes! Near="
07106 <<numRows<<", far="<<numRowsF<<endl;
07107 }
07108
07110
07112 for(Int_t pb=FIRSTPULSERBOX;pb<=LASTPULSERBOX;pb++){
07113 for(Int_t led=FIRSTLED;led<=LASTLED;led++){
07114
07115 PlexLedId ledId(det,pb,led);
07116
07117
07118 pins[ledId].AddPoint
07119 (secCounter,rawPinLedMap[ledId].mean,
07120 rawPinLedMap[ledId].error,rawPinLedMap[ledId].numEnt);
07121
07122 MSG("LIPlexMaps",Msg::kDebug)
07123 <<"Adding point to lirun "<<rawPinLedMap[ledId].mean<<endl;
07124 }
07125 }
07128
07129 for(Int_t pl=FIRSTPLANE;pl<=LASTPLANE;pl++){
07130
07131
07132 if (pl>5) continue;
07133
07134 for(Int_t st=FIRSTSTRIP;st<=LASTSTRIP;st++){
07135 for(Int_t end=FIRSTEND;end<=SECONDEND;end++){
07136
07137 if (end==StripEnd::kEast) stripEndType=StripEnd::kEast;
07138 else if (end==StripEnd::kWest) stripEndType=StripEnd::kWest;
07139
07140 if (end==StripEnd::kEast) stripEndTypeF=StripEnd::kWest;
07141 else if(end==StripEnd::kWest) stripEndTypeF=StripEnd::kEast;
07142
07143 PlexStripEndId stripEndId(det,pl,st,stripEndType);
07144 PlexStripEndId stripEndIdF(det,pl,st,stripEndTypeF);
07145
07146
07147 if (!this->IsScintStrip(stripEndId,plexHandle)) continue;
07148
07149 pulserDrift=0;
07150 pulserDrift=dbiPulserDrift.GetRowByIndex
07151 (stripEndId.BuildPlnStripEndKey());
07152
07153 pulserDriftF=0;
07154 pulserDriftF=dbiPulserDriftF.GetRowByIndex
07155 (stripEndIdF.BuildPlnStripEndKey());
07156
07157 if (pulserDrift){
07158 Float_t mean=pulserDrift->GetMean();
07159 Float_t error=pulserDrift->GetError();
07160 Float_t numEntries=pulserDrift->GetNumEntries();
07161 UInt_t seidkey=pulserDrift->GetStripEnd();
07162
07163 Float_t meanF=-1;
07164 Float_t errorF=-1;
07165 Float_t numEntriesF=-1;
07166
07167 if (pulserDriftF){
07168 meanF=pulserDriftF->GetMean();
07169 errorF=pulserDriftF->GetError();
07170 numEntriesF=pulserDriftF->GetNumEntries();
07171 }
07172
07173 Float_t nearOverFar=-1;
07174 if (meanF>0){
07175 if (stripEndType==StripEnd::kWest){
07176 nearOverFar=mean/meanF;
07177 }
07178 else if (stripEndType==StripEnd::kEast){
07179 nearOverFar=meanF/mean;
07180 }
07181 }
07182
07183 Float_t adcPinRatio=-1;
07184 if (rawPin[seidkey]>0){
07185 adcPinRatio=mean/rawPin[seidkey];
07186 }
07187 else {
07188 MSG("LIPlexMaps",Msg::kDebug)
07189 <<"Raw pin has zero mean!"<<endl;
07190 }
07191
07192 Float_t gainDrift=-1;
07193 if (refAdcPinRatio[seidkey].mean>0){
07194 if (adcPinRatio>0){
07195 gainDrift=adcPinRatio/refAdcPinRatio[seidkey].mean;
07196 }
07197 }
07198 else {
07199 MSG("LIPlexMaps",Msg::kWarning)
07200 <<"Ref ADC/PIN ratio has zero mean!"<<endl;
07201 }
07202
07203 MSG("LIPlexMaps",Msg::kDebug)
07204 <<"Gain drift="<<gainDrift<<endl;
07205
07206 if (numEntries>500 && gainDrift>0){
07207 stripEnds[seidkey].AddPoint(secCounter,mean,error,
07208 numEntries,gainDrift,
07209 nearOverFar);
07210 }
07211
07212 Int_t plane=-1;
07213 Int_t strip=-1;
07214 Int_t end=-1;
07215 fLookup.UnencodePlnStripEndKey(seidkey,det,plane,strip,
07216 end);
07217
07218 string sMean=Form("%.1f",mean);
07219 string sError=Form("%.2f",error);
07220 string sNumEntries=Form("%.0f",numEntries);
07221 string sSeId=Form("%d",seidkey);
07222
07223 MSG("LIPlexMaps",Msg::kDebug)
07224 <<"("<<plane<<";"<<strip<<";"<<end<<")"
07225 <<" Mean="<<sMean<<", error="<<sError
07226 <<", numEnt="<<sNumEntries
07227 <<", seidkey="<<sSeId<<endl;
07228 }
07229 }
07230 }
07231 }
07232
07233
07234 secCounter+=pointSpacingSecs;
07235
07236
07237 delete vldCtx;
07238 delete plexHandle;
07239 }
07240
07241
07242 MSG("LIPlexMaps",Msg::kInfo)
07243 <<"Finished main loop over vld range"<<endl;
07244
07245
07246 Int_t canvasXmax=1200;
07247 Int_t canvasYmax=600;
07248
07249
07250 TCanvas *cMeanVsTime=new TCanvas("cMeanVsTime","MeanVsTime",
07251 0,0,canvasXmax,canvasYmax);
07252 cMeanVsTime->SetFillColor(0);
07253 TCanvas *cErrorVsTime=new TCanvas("cErrorVsTime","ErrorVsTime",
07254 0,0,canvasXmax,canvasYmax);
07255 cErrorVsTime->SetFillColor(0);
07256 TCanvas *cNumEntVsTime=new TCanvas("cNumEntVsTime","NumEntVsTime",
07257 0,0,canvasXmax,canvasYmax);
07258 cNumEntVsTime->SetFillColor(0);
07259 TCanvas *cGainDriftVsTime=new TCanvas("cGainDriftVsTime",
07260 "GainDriftVsTime",
07261 0,0,canvasXmax,canvasYmax);
07262 cGainDriftVsTime->SetFillColor(0);
07263 TCanvas *cGainDriftVsTimeZoom=new TCanvas("cGainDriftVsTimeZoom",
07264 "GainDriftVsTimeZoom",
07265 0,0,canvasXmax,canvasYmax);
07266 cGainDriftVsTimeZoom->SetFillColor(0);
07267 TCanvas *cPinVsTime=new TCanvas("cPinVsTime","PinVsTime",
07268 0,0,canvasXmax,canvasYmax);
07269 cPinVsTime->SetFillColor(0);
07270 TCanvas *cNormPinVsTime=new TCanvas("cNormPinVsTime","NormPinVsTime",
07271 0,0,canvasXmax,canvasYmax);
07272 cNormPinVsTime->SetFillColor(0);
07273 TCanvas *cNormPinVsTimeZoom=new TCanvas("cNormPinVsTimeZoom",
07274 "NormPinVsTimeZoom",
07275 0,0,canvasXmax,canvasYmax);
07276 cNormPinVsTimeZoom->SetFillColor(0);
07277 TCanvas *cPinErrorVsTime=new TCanvas("cPinErrorVsTime",
07278 "PinErrorVsTime",
07279 0,0,canvasXmax,canvasYmax);
07280 cPinErrorVsTime->SetFillColor(0);
07281 TCanvas *cPinNumEntVsTime=new TCanvas("cPinNumEntVsTime",
07282 "PinNumEntVsTime",
07283 0,0,canvasXmax,canvasYmax);
07284 cPinNumEntVsTime->SetFillColor(0);
07285 TCanvas *cNearOverFarVsTime=new TCanvas("cNearOverFarVsTime",
07286 "NearOverFarVsTime",
07287 0,0,canvasXmax,canvasYmax);
07288 cNearOverFarVsTime->SetFillColor(0);
07289 TCanvas *cNormNearOverFarVsTime=new TCanvas("cNormNearOverFarVsTime",
07290 "NormNearOverFarVsTime",
07291 0,0,canvasXmax,canvasYmax);
07292 cNormNearOverFarVsTime->SetFillColor(0);
07293
07294 string sMeanVsTime="MeanVsTime.ps";
07295 string sErrorVsTime="ErrorVsTime.ps";
07296 string sNumEntVsTime="NumEntVsTime.ps";
07297 string sGainDriftVsTime="GainDriftVsTime.ps";
07298 string sGainDriftVsTimeZoom="GainDriftVsTimeZoom.ps";
07299 string sPinVsTime="PinVsTime.ps";
07300 string sNormPinVsTime="NormPinVsTime.ps";
07301 string sNormPinVsTimeZoom="NormPinVsTimeZoom.ps";
07302 string sPinErrorVsTime="PinErrorVsTime.ps";
07303 string sPinNumEntVsTime="PinNumEntVsTime.ps";
07304 string sNearOverFarVsTime="NearOverFarVsTime.ps";
07305 string sNormNearOverFarVsTime="NormNearOverFarVsTime.ps";
07306
07307
07308 cMeanVsTime->Print((sMeanVsTime+"[").c_str());
07309 cErrorVsTime->Print((sErrorVsTime+"[").c_str());
07310 cNumEntVsTime->Print((sNumEntVsTime+"[").c_str());
07311 cGainDriftVsTime->Print((sGainDriftVsTime+"[").c_str());
07312 cGainDriftVsTimeZoom->Print((sGainDriftVsTimeZoom+"[").c_str());
07313 cPinVsTime->Print((sPinVsTime+"[").c_str());
07314 cNormPinVsTime->Print((sNormPinVsTime+"[").c_str());
07315 cNormPinVsTimeZoom->Print((sNormPinVsTimeZoom+"[").c_str());
07316 cPinErrorVsTime->Print((sPinErrorVsTime+"[").c_str());
07317 cPinNumEntVsTime->Print((sPinNumEntVsTime+"[").c_str());
07318 cNearOverFarVsTime->Print((sNearOverFarVsTime+"[").c_str());
07319 cNormNearOverFarVsTime->Print((sNormNearOverFarVsTime+"[").c_str());
07320
07321 gErrorIgnoreLevel=1;
07322
07324
07326 map<PlexLedId,LIRun>::iterator pinIt=pins.begin();
07327
07328 MSG("LIPlexMaps",Msg::kInfo)
07329 <<"Iterating over the pins..."<<endl;
07330 while(pinIt!=pins.end()){
07331
07332
07333
07334 vector<Double_t> vTime=pinIt->second.GetPh();
07335 vector<Double_t> vMean=pinIt->second.GetAdc();
07336 vector<Double_t> vError=pinIt->second.GetPin(1);
07337 vector<Double_t> vNumEnt=pinIt->second.GetPin(2);
07338
07339 TGraph* gPinVsTime=0;
07340 TGraph* gNormPinVsTime=0;
07341 TGraph* gNormPinVsTimeZoom=0;
07342 TGraph* gPinErrorVsTime=0;
07343 TGraph* gPinNumEntVsTime=0;
07344
07345 gPinVsTime=TGraphVect(vTime,vMean);
07346 gPinErrorVsTime=TGraphVect(vTime,vError);
07347 gPinNumEntVsTime=TGraphVect(vTime,vNumEnt);
07348
07349 string sPb=Form("%d",pinIt->first.GetPulserBox());
07350 string sLed=Form("%d",pinIt->first.GetLedInBox());
07351
07352 MSG("LIPlexMaps",Msg::kInfo)
07353 <<"Printing ("<<sPb<<":"<<sLed<<")"
07354 <<" to postscript"<<endl;
07355
07356 cPinVsTime->cd();
07357 cPinVsTime->Clear();
07358 fS="Light level drifts (PIN ADC) with time (PB,LED)=("+
07359 sPb+","+sLed+")";
07360 gPinVsTime->Draw("AP");
07361 gPinVsTime->SetTitle(fS.c_str());
07362 gPinVsTime->GetYaxis()->SetTitle("Pin ADC");
07363 gPinVsTime->GetYaxis()->CenterTitle();
07364 this->SetGraphAxisEtc(gPinVsTime,startTimeSecs,endTimeSecs);
07365
07366
07367 this->NormaliseVector(vMean,2);
07368 gNormPinVsTime=TGraphVect(vTime,vMean);
07369 gNormPinVsTimeZoom=TGraphVect(vTime,vMean);
07370
07371 cNormPinVsTime->cd();
07372 cNormPinVsTime->Clear();
07373 fS="Fractional Drifts in PIN ADC with time (PB,LED)=("+
07374 sPb+","+sLed+")";
07375 gNormPinVsTime->Draw("AP");
07376 gNormPinVsTime->SetTitle(fS.c_str());
07377 gNormPinVsTime->GetYaxis()->SetTitle("Normalised Pin ADC");
07378 gNormPinVsTime->GetYaxis()->CenterTitle();
07379 this->SetGraphAxisEtc(gNormPinVsTime,startTimeSecs,endTimeSecs);
07380
07381 cNormPinVsTimeZoom->cd();
07382 cNormPinVsTimeZoom->Clear();
07383 fS="Fractional Drifts in PIN ADC with time, zoomed (PB,LED)=("+
07384 sPb+","+sLed+")";
07385 gNormPinVsTimeZoom->Draw("AP");
07386 gNormPinVsTimeZoom->SetTitle(fS.c_str());
07387 gNormPinVsTimeZoom->GetYaxis()->SetTitle("Normalised Pin ADC");
07388 gNormPinVsTimeZoom->GetYaxis()->CenterTitle();
07389 this->SetGraphAxisEtc(gNormPinVsTimeZoom,startTimeSecs,endTimeSecs);
07390 gNormPinVsTimeZoom->SetMinimum(0.97);
07391 gNormPinVsTimeZoom->SetMaximum(1.03);
07392
07393
07394
07395 cPinErrorVsTime->cd();
07396 cPinErrorVsTime->Clear();
07397 fS="Error on the PIN vs time (PB,LED)=("+
07398 sPb+","+sLed+")";
07399 gPinErrorVsTime->Draw("AP");
07400 gPinErrorVsTime->SetTitle(fS.c_str());
07401 gPinErrorVsTime->GetYaxis()->SetTitle(