00001
00002
00003
00004
00005
00006
00007
00008
00009
00011
00012
00013
00014
00015
00016 #include <iostream>
00017 #include <string>
00018 #include <typeinfo>
00019 #include <iostream>
00020 #include <vector>
00021
00022
00023 #include "Riostream.h"
00024 #include "TRint.h"
00025 #include "TROOT.h"
00026 #include "TStyle.h"
00027 #include "Riostream.h"
00028
00029
00030 #include "TH2.h"
00031 #include "TH1.h"
00032 #include "TF1.h"
00033
00034 #include "TGraph.h"
00035 #include "TMultiGraph.h"
00036 #include "TCanvas.h"
00037 #include "TProfile.h"
00038 #include "TStopwatch.h"
00039
00040 #include "TFile.h"
00041 #include "TTree.h"
00042 #include "TBranch.h"
00043 #include "TMath.h"
00044 #include "TLegend.h"
00045 #include "TColor.h"
00046 #include "TText.h"
00047 #include "TKey.h"
00048 #include "TLatex.h"
00049 #include "TCanvas.h"
00050 #include "TPrincipal.h"
00051 #include "TMatrix.h"
00052
00053 #include "TRocEvent.h"
00054 #include "roc/Message.h"
00055 #include "TSpadicEvent.h"
00056
00057
00058 #include "TMbsCrateEvent.h"
00059 #include "TBeamMonitorEvent.h"
00060 #include "TCernOct11UnpackEvent.h"
00061
00062
00063
00064
00065
00066
00067 #define NUM_SPADIC_CHA 8
00068 #define SPADIC_TRACE_SIZE 45
00069 #define SPADIC_ADC_MAX 255
00070 #define noBaselineTB 5
00071 Int_t Pi_Ch1_Min, Pi_Ch1_Max, Pi_Ch2_Min, Pi_Ch2_Max, Pi_Pb_Min, Pi_Pb_Max, El_Ch1_Min, El_Ch1_Max, El_Ch2_Min, El_Ch2_Max, El_Pb_Min, El_Pb_Max;
00072 Bool_t isElectron, isPion, isMyon;
00073 TPrincipal* principal = new TPrincipal(NUM_SPADIC_CHA,"ND");
00074 Int_t pidcuts[18] = {0};
00075 using namespace std;
00076
00077 class MFSpadicEvent
00078 {
00079 public:
00080 Float_t rawPulse[NUM_SPADIC_CHA][SPADIC_TRACE_SIZE];
00081 Float_t cleanPulse[NUM_SPADIC_CHA][SPADIC_TRACE_SIZE];
00082
00083 Bool_t signalCH[NUM_SPADIC_CHA];
00084
00085 Bool_t underFlowEv;
00086 Bool_t underFlowCH[NUM_SPADIC_CHA];
00087 Bool_t underFlowTB[NUM_SPADIC_CHA][SPADIC_TRACE_SIZE];
00088
00089 Bool_t overFlowEv;
00090 Bool_t overFlowCH[NUM_SPADIC_CHA];
00091 Bool_t overFlowTB[NUM_SPADIC_CHA][SPADIC_TRACE_SIZE];
00092
00093
00094 MFSpadicEvent() {
00095 for (Int_t ch = 0; ch < NUM_SPADIC_CHA; ch++) {
00096 for (Int_t tb = 0; tb < SPADIC_TRACE_SIZE; tb++) {
00097 rawPulse[ch][tb] = 0.0;
00098 cleanPulse[ch][tb] = 0.0;
00099 underFlowTB[ch][tb] = kFALSE;
00100 overFlowTB[ch][tb] = kFALSE;
00101 }
00102 signalCH[ch] = kFALSE;
00103 underFlowCH[ch] = kFALSE;
00104 overFlowCH[ch] = kFALSE;
00105 }
00106 underFlowEv = kFALSE;
00107 overFlowEv = kFALSE;
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119 }
00120
00121 private:
00122
00123 };
00124
00125 void Statusbar(Int_t i, Int_t n) {
00126 if (int(i * 100 / float(n)) - int((i-1) * 100 / float(n)) >= 1) {
00127 if (int(i * 100 / float(n)) == 1 || i == 1 || i == 0)
00128 cout << "[" << flush;
00129 cout << "-" << flush;
00130 if (int(i * 10 / float(n)) - int((i-1) * 10 / float(n)) >= 1)
00131 cout << "|";
00132 if (int(i * 100 / float(n)) >=99)
00133 cout << "]" <<endl;
00134 }
00135 }
00136
00137 void Clusterizer(Double_t pulse[NUM_SPADIC_CHA][SPADIC_TRACE_SIZE],Int_t nSpadicSignalCh, Bool_t SignalChannel[NUM_SPADIC_CHA], Int_t maxch, Int_t maxT[NUM_SPADIC_CHA], Double_t maxA[NUM_SPADIC_CHA]) {
00138 Bool_t Run_TimeClustering(0), Run_AmplitudeClustering(0);
00139 nSpadicSignalCh = 0;
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167 }
00168
00169 void NoiseReduction(TH1D* inPulse[NUM_SPADIC_CHA], TH1D* outPulse[NUM_SPADIC_CHA], Bool_t SignalChannel[NUM_SPADIC_CHA]) {
00170 const double lowercorthreshold = 0.112;
00171 const double uppercorthreshold = 0.112;
00172 const double nosignalcorthreshold = 0.1;
00173 Double_t cortest[NUM_SPADIC_CHA];
00174 Double_t inputarray[SPADIC_TRACE_SIZE][NUM_SPADIC_CHA] = {{0.0}};
00175 Double_t minIntegral = 265*45;
00176 Double_t tempIntegral = 0.0;
00177 int minch = -1;
00178 for(Int_t ch = 0; ch < NUM_SPADIC_CHA; ch++){
00179 tempIntegral = 0.0;
00180 for(Int_t bin = 0; bin < SPADIC_TRACE_SIZE; bin++){
00181 inputarray[bin][ch] = inPulse[ch]->GetBinContent(inPulse[ch]->FindBin(bin));
00182 tempIntegral += inputarray[bin][ch];
00183 }
00184 if (tempIntegral < minIntegral){
00185 minIntegral = tempIntegral;
00186 minch = ch;
00187 }
00188 }
00189
00190 int noise_ch_counter=0;
00191
00192 Double_t thisisnoise[SPADIC_TRACE_SIZE] = {0.0};
00193
00194 double val_in=0;
00195 double val_noise=0;
00196
00197
00198 for(int t=0;t<SPADIC_TRACE_SIZE;t++)
00199 {
00200 principal->AddRow(inputarray[t]);
00201 }
00202
00203 principal->MakePrincipals();
00204
00205 TMatrixD* cova = (TMatrixD*)principal->GetCovarianceMatrix();
00206
00207 Int_t lastSigCh = -1;
00208
00209 for(int ch=0;ch<NUM_SPADIC_CHA;ch++)
00210 {
00211 cortest[ch] = TMatrixDRow (*cova,minch)(ch);
00212 if(cortest[ch]>lowercorthreshold)
00213 {
00214 SignalChannel[ch] = false;
00215 noise_ch_counter++;
00216
00217 for(Int_t bin = 0; bin < SPADIC_TRACE_SIZE; bin++){
00218 thisisnoise[bin] += inputarray[bin][ch];
00219 }
00220 }
00221 else {
00222 SignalChannel[ch] = true;
00223 }
00224 }
00225
00226 for(Int_t bin = 0; bin < SPADIC_TRACE_SIZE; bin++){
00227 thisisnoise[bin] /= (double)noise_ch_counter;
00228 }
00229
00230 for (int ch=0; ch<NUM_SPADIC_CHA; ch++)
00231 {
00232 for (int k=0; k<SPADIC_TRACE_SIZE; k++)
00233 {
00234
00235
00236
00237
00238
00239
00240 outPulse[ch]->Fill(k, inPulse[ch]->GetBinContent(inPulse[ch]->FindBin(k)) - thisisnoise[k]);
00241 }
00242 }
00243
00244 principal->Clear();
00245
00246
00247
00248
00249
00250
00251
00252
00253
00254
00255
00256
00257
00258
00259
00260
00261
00262
00263
00264
00265
00266
00267
00268 }
00269 void BaselineCompensation(TH1D* inPulse[NUM_SPADIC_CHA], TH1D* outPulse[NUM_SPADIC_CHA])
00270 {
00271 Double_t baseline[NUM_SPADIC_CHA] = {0.0};
00272 for (Int_t ch = 0; ch < NUM_SPADIC_CHA; ch++){
00273 for (Int_t bin = 0; bin < noBaselineTB; bin++){
00274 baseline[ch] += inPulse[ch]->GetBinContent(inPulse[ch]->FindBin(bin));
00275 }
00276 baseline[ch] /= noBaselineTB;
00277 }
00278
00279 for (Int_t ch = 0; ch < NUM_SPADIC_CHA; ch++){
00280 for (Int_t bin = 0; bin < SPADIC_TRACE_SIZE; bin++){
00281 outPulse[ch]->Fill(bin, inPulse[ch]->GetBinContent(inPulse[ch]->FindBin(bin)) - baseline[ch]);
00282 }
00283 }
00284 }
00285
00286
00287 void BaselineCorrection(Double_t pulse[NUM_SPADIC_CHA][SPADIC_TRACE_SIZE]) {
00288 for (Int_t ch = 0; ch < NUM_SPADIC_CHA; ch++) {
00289
00290 Float_t baseline(0);
00291 for (Int_t bin = 0; bin < noBaselineTB; bin++) {
00292 baseline += pulse[ch][bin];
00293 }
00294 baseline /= Float_t(noBaselineTB);
00295 for (Int_t bin = 0; bin < SPADIC_TRACE_SIZE; bin++) {
00296 pulse[ch][bin] -= baseline;
00297 }
00298 }
00299 }
00300
00301
00302
00303
00304
00305
00306
00307
00308
00309
00310
00311
00312
00313
00314
00315
00316
00317
00318
00319
00320
00321
00322
00323
00324
00325
00326
00327
00328
00329
00330
00331
00332
00333
00334
00335
00336
00337
00338
00339
00340
00341
00342
00343
00344
00345
00346
00347 void GetPidCuts(TString runId)
00348 {
00349 Bool_t MS_Pid = true;
00350 Bool_t FFM_Pid = false;
00351
00352 runId.ReplaceAll("Be_run","");
00353
00354 runId.ReplaceAll("Te_run","");
00355
00356 runId.ReplaceAll(".root","");
00357
00358 int runnumber=runId.Atoi();
00359
00360 pidcuts[0] = 500;
00361 pidcuts[1] = 9999;
00362 pidcuts[2] = 450;
00363 pidcuts[3] = 9999;
00364 pidcuts[4] = 1050;
00365 pidcuts[5] = 9999;
00366 pidcuts[6] = 0;
00367 pidcuts[7] = 375;
00368 pidcuts[8] = 0;
00369 pidcuts[9] = 340;
00370 pidcuts[10]= 500;
00371 pidcuts[11]= 1000;
00372 pidcuts[12]= 400;
00373 pidcuts[13]= 700;
00374 pidcuts[14]= 360;
00375 pidcuts[15]= 450;
00376 pidcuts[16]= 500;
00377 pidcuts[17]= 1000;
00378
00379
00380
00381
00382
00383
00384
00385
00386
00387
00388
00389
00390
00391
00392
00393
00394
00395
00396
00397
00398
00399
00400
00401
00402
00403
00404
00405
00406
00407
00408
00409
00410
00411
00412
00413
00414
00415
00416
00417
00418
00419
00420
00421
00422
00423
00424
00425
00426
00427
00428
00429
00430
00431
00432
00433
00434
00435
00436
00437
00438
00439
00440
00441
00442
00443
00444
00445
00446
00447
00448
00449
00450
00451
00452
00453
00454
00455
00456
00457
00458
00459
00460
00461
00462
00463
00464
00465
00466
00467
00468
00469
00470
00471
00472
00473
00474
00475
00476
00477
00478
00479
00480
00481
00482
00483
00484
00485
00486
00487
00488
00489
00490
00491
00492
00493
00494
00495
00496
00497
00498
00499
00500
00501
00502
00503
00504
00505
00506
00507
00508
00509
00510
00511
00512
00513
00514
00515
00516
00517
00518
00519
00520
00521
00522
00523
00524
00525
00526
00527
00528
00529
00530
00531
00532
00533
00534
00535
00536
00537
00538
00539
00540
00541
00542
00543
00544
00545
00546
00547
00548
00549
00550
00551
00552
00553
00554
00555
00556
00557
00558
00559
00560
00561
00562
00563
00564
00565
00566
00567
00568
00569
00570
00571
00572
00573
00574
00575
00576
00577
00578
00579
00580
00581
00582
00583
00584
00585
00586
00587
00588
00589
00590
00591
00592
00593
00594
00595
00596
00597
00598
00599
00600
00601
00602
00603
00604
00605
00606
00607
00608
00609
00610
00611
00612
00613
00614
00615
00616
00617
00618
00619
00620
00621
00622 }
00623
00624 }
00625 void getPID( Float_t ch1, Float_t ch2, Float_t pb)
00626 {
00627
00628
00629
00630
00631 if (ch1 > pidcuts[0] &&
00632 ch1 < pidcuts[1] &&
00633 ch2 > pidcuts[2] &&
00634 ch2 < pidcuts[3] &&
00635 pb > pidcuts[4] &&
00636 pb < pidcuts[5]
00637 )
00638 {
00639 isElectron=true;
00640 }
00641
00642 else if (ch1 > pidcuts[6] &&
00643 ch1 < pidcuts[7] &&
00644 ch2 > pidcuts[8] &&
00645 ch2 < pidcuts[9] &&
00646 pb > pidcuts[10] &&
00647 pb < pidcuts[11]
00648 )
00649 {
00650 isPion=true;
00651 }
00652
00653 else if (ch1 > pidcuts[12] &&
00654 ch1 < pidcuts[13] &&
00655 ch2 > pidcuts[14] &&
00656 ch2 < pidcuts[15] &&
00657 pb > pidcuts[16] &&
00658 pb < pidcuts[17]
00659 )
00660 {
00661 isMyon=true;
00662 }
00663 }
00664
00665
00666
00667
00668
00669
00670
00671
00672
00673
00674
00675
00676
00677
00678
00679
00680
00681
00682
00683
00684
00685
00686
00687
00688
00689
00690
00691
00692
00693
00694
00695
00696
00697
00698
00699
00700
00701
00702 Bool_t Distance2TrackFFM(Double_t x[8], Double_t distance[8]) {
00703
00704
00705 Double_t xPos[8] = {0.0};
00706 Int_t nPos = 0;
00707 for (Int_t i = 4; i< 8; i++) {
00708 xPos[i] = x[i];
00709 if (xPos[i] != 0.0) nPos++;
00710 }
00711 if (nPos < 4) return false;
00712
00713 Double_t zMean(0.0), xMean(0.0), m(0.0), b(0.0), SUMzx(0.0), SUMzz(0.0);
00714
00715
00716 Double_t zPos[8] = {0, 320, 638, 958, 0, 320, 638, 958};
00717 for (Int_t j = 4; j < 8; j++) {
00718 Int_t count = 0;
00719 for (Int_t i = 4; i < 8; i++) {
00720 if (i != j && x[i] != 0.0) {
00721 zMean += zPos[i];
00722 xMean += xPos[i];
00723 count++;
00724 }
00725 }
00726
00727 zMean /= count;
00728 xMean /= count;
00729 for (Int_t i = 4; i < 8; i++) {
00730 if (i != j && x[i] != 0.0) {
00731 SUMzx += (zPos[i] - zMean) * (xPos[i] - xMean);
00732 SUMzz += (zPos[i] - zMean) * (zPos[i] - zMean);
00733 }
00734 }
00735 m = SUMzx / SUMzz;
00736 b = xMean - m * zMean;
00737 distance[j] = xPos[j] - (m * zPos[j] + b);
00738 }
00739 return true;
00740 }
00741 Bool_t Distance2TrackMS(Double_t x[8], Double_t distance[8]) {
00742
00743
00744 Double_t xPos[4] = {0.0};
00745 Int_t nPos = 0;
00746 for (Int_t i = 0; i< 4; i++) {
00747 xPos[i] = x[i];
00748 if (xPos[i] != 0.0) nPos++;
00749 }
00750 if (nPos < 4) return false;
00751
00752 Double_t zMean(0.0), xMean(0.0), m(0.0), b(0.0), SUMzx(0.0), SUMzz(0.0);
00753
00754
00755 Double_t zPos[4] = {0, 320, 638, 958};
00756 for (Int_t j = 0; j < 4; j++) {
00757 Int_t count = 0;
00758 for (Int_t i = 0; i < 4; i++) {
00759 if (i != j && x[i] != 0.0) {
00760 zMean += zPos[i];
00761 xMean += xPos[i];
00762 count++;
00763 }
00764 }
00765
00766 zMean /= count;
00767 xMean /= count;
00768 for (Int_t i = 0; i < 4; i++) {
00769 if (i != j && x[i] != 0.0) {
00770 SUMzx += (zPos[i] - zMean) * (xPos[i] - xMean);
00771 SUMzz += (zPos[i] - zMean) * (zPos[i] - zMean);
00772 }
00773 }
00774 m = SUMzx / SUMzz;
00775 b = xMean - m * zMean;
00776 distance[j] = xPos[j] - (m * zPos[j] + b);
00777 }
00778 return true;
00779 }
00780
00781
00782 void readtree_spadic(TString nameFileSet, Bool_t debug=0) {
00783
00784 Bool_t raw = true;
00785 Bool_t msMerge = false;
00786
00787 ifstream fileSet;
00788 fileSet.open(nameFileSet.Data());
00789
00790 if (fileSet.is_open()) {
00791 TString ofname = "data2012/Analysis/" + TString(nameFileSet(0,nameFileSet.Sizeof()-5)).Append(".root");
00792 TFile outputFile(ofname,"RECREATE","output of readtree_spadic.cxx");
00793 TString mergeName[2] = {"NotMerged","Merged"};
00794 TString filterName[4] = {"wOwU","woOwU","woOwoU","wOwoU"};
00795 TString folder = "data2012/TTrees/";
00796 TString picEx = ".pdf";
00797 const Int_t usedSusibos = 3;
00798 const Int_t recoSets = 9;
00799 const Int_t nMerge = 2;
00800 const Int_t nFilter = 4;
00801
00802 Int_t topSuId[3] = { 11, 10, 18};
00803 Int_t usedSuId[usedSusibos] = { 11, 10, 18};
00804 Float_t padWidth[usedSusibos] = {7.125, 7.125, 7.125};
00805 TString recoSetName[recoSets] = {"ClusterInteg","3PadInteg","1PadInteg","ClusterIntegWindow","3PadIntegWindow","1PadIntegWindow","ClusterAmpl","3PadAmpl","1PadAmpl"};
00806 Int_t allPion[usedSusibos][nMerge] = {{0}};
00807 Int_t allElectron[usedSusibos][nMerge] = {{0}};
00808 Int_t allGoodEvent[usedSusibos][nMerge] = {{0}};
00809 Int_t allEvents = 0;
00810 TString formula;
00811
00812
00813
00814 TF1 *mathiesonMS336 = new TF1("mathieson",
00815 " -1. / (2. * atan(sqrt([0]))) * (atan(sqrt([0]) *tanh(3.14159265 * (-2. + sqrt([0]) ) * (5.0 + 2.* x * 1.0) / (8.* 3.0) )) + atan(sqrt([0]) * tanh(3.14159265 * (-2. + sqrt([0]) ) * (5.0 - 2.* x * 1.0) / (8.* 3.0) )) )"
00816 ,-10,10);
00817 mathiesonMS336->SetLineStyle(2);
00818 mathiesonMS336->SetLineColor(3);
00819 TF1 *mathiesonMS444 = new TF1("mathieson",
00820 " -1. / (2. * atan(sqrt([0]))) * (atan(sqrt([0]) *tanh(3.14159265 * (-2. + sqrt([0]) ) * (8.0 + 2.* x * 1.0) / (8.* 4.0) )) + atan(sqrt([0]) * tanh(3.14159265 * (-2. + sqrt([0]) ) * (8.0 - 2.* x * 1.0) / (8.* 4.0) )) )"
00821 ,-10,10);
00822 mathiesonMS444->SetLineStyle(2);
00823 mathiesonMS444->SetLineColor(3);
00824 TF1 *gausFit = new TF1("gausFit","gaus",20,50);
00825 TF1 *sigmaFit = new TF1("sigmaFit","gaus",-10,10);
00826 TF1 *alignmentFit= new TF1("alignmentFit","[0]*x+[1]",0,60);
00827
00828 TString name, title;
00829
00830
00831 TH2F* Ch1_Pb = new TH2F("Ch1_Pb","good PID Ch1_Pb",2000,0,4000,2000,0,4000);
00832 Ch1_Pb->SetXTitle("Cherenkov 1 [a.u.]");
00833 Ch1_Pb->SetYTitle("Pb-glass calorimeter [a.u.]");
00834 Ch1_Pb->SetContour(99);
00835
00836 TH2F* noCh1_Pb = new TH2F("noCh1_Pb","no good PID Ch1_Pb",2000,0,4000,2000,0,4000);
00837 noCh1_Pb->SetXTitle("Cherenkov 1 [a.u.]");
00838 noCh1_Pb->SetYTitle("Pb-glass calorimeter [a.u.]");
00839 noCh1_Pb->SetContour(99);
00840
00841 TH2F* Ch2_Pb = new TH2F("Ch2_Pb","good PID Ch2_Pb",2000,0,4000,2000,0,4000);
00842 Ch2_Pb->SetXTitle("Cherenkov 2 [a.u.]");
00843 Ch2_Pb->SetYTitle("Pb-glass calorimeter [a.u.]");
00844 Ch2_Pb->SetContour(99);
00845
00846 TH2F* noCh2_Pb = new TH2F("noCh2_Pb","no good PID Ch2_Pb",2000,0,4000,2000,0,4000);
00847 noCh2_Pb->SetXTitle("Cherenkov 2 [a.u.]");
00848 noCh2_Pb->SetYTitle("Pb-glass calorimeter [a.u.]");
00849 noCh2_Pb->SetContour(99);
00850
00851 TH2F* Ch1_Ch2 = new TH2F("Ch1_Ch2","good PID Ch1_Ch2",2000,0,4000,2000,0,4000);
00852 Ch1_Ch2->SetXTitle("Cherenkov 1 [a.u.]");
00853 Ch1_Ch2->SetYTitle("Cherenkov 2 [a.u.]");
00854 Ch1_Ch2->SetContour(99);
00855
00856 TH2F* noCh1_Ch2 = new TH2F("noCh1_Ch2","no good PID Ch1_Ch2",2000,0,4000,2000,0,4000);
00857 noCh1_Ch2->SetXTitle("Cherenkov 1 [a.u.]");
00858 noCh1_Ch2->SetYTitle("Cherenkov 2 [a.u.]");
00859 noCh1_Ch2->SetContour(99);
00860
00861 TH1D* preCompSpectraEl[usedSusibos][recoSets][nMerge][nFilter];
00862 TH1D* preCompSpectraPi[usedSusibos][recoSets][nMerge][nFilter];
00863 TH1I* hitTimeEl[usedSusibos];
00864 TH1I* hitTimePi[usedSusibos];
00865
00866 TH2I* amplitudeCorr[usedSusibos][usedSusibos];
00867
00868 TH1I* amplitudeSpectra[usedSusibos];
00869
00870 TH1F* chaGain[usedSusibos];
00871
00872 TProfile* pulseShapeEl[usedSusibos];
00873 TProfile* pulseShapePi[usedSusibos];
00874
00875 TH1I* beamProfile[usedSusibos];
00876 TProfile* chamberAlignment[usedSusibos][usedSusibos];
00877
00878 TH2D* prf[usedSusibos];
00879 TProfile* prfProfile[usedSusibos];
00880
00881 TH1I *chaGainCalibSpectra[usedSusibos][NUM_SPADIC_CHA];
00882
00883 for (Int_t suid = 0; suid < usedSusibos; suid++) {
00884 for (Int_t rs = 0; rs < recoSets; rs++) {
00885 for (Int_t imerge = 0; imerge < nMerge; imerge++) {
00886 for (Int_t ifilter = 0; ifilter < nFilter; ifilter++) {
00887 title.Form("preCompSpectra%sEl_%i_%s_%s",recoSetName[rs].Data(),usedSuId[suid],mergeName[imerge].Data(),filterName[ifilter].Data());
00888 name.Form("pre cleaned go4 output (%s) electron Sus%i (%s %s)",recoSetName[rs].Data(),usedSuId[suid],mergeName[imerge].Data(),filterName[ifilter].Data());
00889 preCompSpectraEl[suid][rs][imerge][ifilter] = new TH1D(title, name, NUM_SPADIC_CHA*SPADIC_TRACE_SIZE*SPADIC_ADC_MAX,0,NUM_SPADIC_CHA*SPADIC_TRACE_SIZE*SPADIC_ADC_MAX);
00890 preCompSpectraEl[suid][rs][imerge][ifilter]->SetXTitle("charge [a.u.]");
00891 preCompSpectraEl[suid][rs][imerge][ifilter]->SetYTitle("normalized counts");
00892 preCompSpectraEl[suid][rs][imerge][ifilter]->SetLineColor(2);
00893
00894 title.Form("preCompSpectra%sPi_%i_%s_%s",recoSetName[rs].Data(),usedSuId[suid],mergeName[imerge].Data(),filterName[ifilter].Data());
00895 name.Form("pre cleaned go4 output (%s) pion Sus%i (%s %s)",recoSetName[rs].Data(),usedSuId[suid],mergeName[imerge].Data(),filterName[ifilter].Data());
00896 preCompSpectraPi[suid][rs][imerge][ifilter] = new TH1D(title, name, NUM_SPADIC_CHA*SPADIC_TRACE_SIZE*SPADIC_ADC_MAX,0,NUM_SPADIC_CHA*SPADIC_TRACE_SIZE*SPADIC_ADC_MAX);
00897 preCompSpectraPi[suid][rs][imerge][ifilter]->SetXTitle("charge [a.u.]");
00898 preCompSpectraPi[suid][rs][imerge][ifilter]->SetYTitle("normalized counts");
00899 }
00900 }
00901 }
00902 for (Int_t ch = 0; ch < NUM_SPADIC_CHA; ch++) {
00903 title.Form("chaGainCalibSpectraCh%i_%i",ch,usedSuId[suid]);
00904 name.Form("Channel Spectra Ch%i Sus%i",ch,usedSuId[suid]);
00905 chaGainCalibSpectra[suid][ch] = new TH1I(title, name, SPADIC_TRACE_SIZE*SPADIC_ADC_MAX+50,-50,SPADIC_TRACE_SIZE*SPADIC_ADC_MAX);
00906 chaGainCalibSpectra[suid][ch]->SetLineColor(ch+1);
00907 }
00908 for (Int_t suid2 = 0; suid2 < usedSusibos; suid2++) {
00909 title.Form("amplitudeCorr_%i_%i",usedSuId[suid],usedSuId[suid2]);
00910 name.Form("max amplitude correlation (Sus%i,Sus%i)",usedSuId[suid],usedSuId[suid2]);
00911 amplitudeCorr[suid][suid2] = new TH2I(title, name, SPADIC_ADC_MAX+50,-50,SPADIC_ADC_MAX, SPADIC_ADC_MAX+50,-50,SPADIC_ADC_MAX);
00912 amplitudeCorr[suid][suid2]->SetContour(99);
00913
00914 title.Form("chamberAlignment_%i_%i",usedSuId[suid],usedSuId[suid2]);
00915 name.Form("chamber alignment Sus%i Sus%i",usedSuId[suid],usedSuId[suid2]);
00916 chamberAlignment[suid][suid2] = new TProfile(title, name, NUM_SPADIC_CHA*padWidth[suid], 0-0.5, NUM_SPADIC_CHA*padWidth[suid]-0.5*padWidth[suid]);
00917 chamberAlignment[suid][suid2]->GetYaxis()->SetRangeUser(-(NUM_SPADIC_CHA-0.5)*padWidth[suid2],(NUM_SPADIC_CHA-0.5)*padWidth[suid2]);
00918 }
00919 title.Form("beamProfile_%i",usedSuId[suid]);
00920 name.Form("pad max distribution (beam profile) Sus%i",usedSuId[suid]);
00921 beamProfile[suid] = new TH1I(title, name, NUM_SPADIC_CHA, 0-0.5, NUM_SPADIC_CHA-0.5);
00922 beamProfile[suid]->SetXTitle("pad with maximum Q");
00923 beamProfile[suid]->SetYTitle("#");
00924
00925
00926
00927
00928
00929
00930
00931
00932
00933
00934
00935
00936 title.Form("chaGain_%i",usedSuId[suid]);
00937 name.Form("channel gain pad max Sus%i",usedSuId[suid]);
00938 chaGain[suid] = new TH1F(title, name, NUM_SPADIC_CHA, 0-0.5, NUM_SPADIC_CHA-0.5);
00939
00940 title.Form("amplitudeSpectra_%i",usedSuId[suid]);
00941 name.Form("amplitude spectra pad max Sus%i",usedSuId[suid]);
00942 amplitudeSpectra[suid] = new TH1I(title, name, SPADIC_ADC_MAX+50,-50,SPADIC_ADC_MAX);
00943
00944 title.Form("hitTimeEl_%i",usedSuId[suid]);
00945 name.Form("hit time electron Sus%i",usedSuId[suid]);
00946 hitTimeEl[suid] = new TH1I(title, name, SPADIC_TRACE_SIZE,0,SPADIC_TRACE_SIZE);
00947 hitTimeEl[suid]->SetXTitle("time-bin of maximum amplitude");
00948 hitTimeEl[suid]->SetYTitle("#");
00949 hitTimeEl[suid]->SetLineColor(2);
00950
00951 title.Form("hitTimePi_%i",usedSuId[suid]);
00952 name.Form("hit time pion Sus%i",usedSuId[suid]);
00953 hitTimePi[suid] = new TH1I(title, name, SPADIC_TRACE_SIZE,0,SPADIC_TRACE_SIZE);
00954 hitTimePi[suid]->SetXTitle("time-bin of maximum amplitude");
00955 hitTimePi[suid]->SetYTitle("#");
00956
00957 title.Form("pulseShapeEl_%i",usedSuId[suid]);
00958 name.Form("pulse shape electron Sus%i",usedSuId[suid]);
00959 pulseShapeEl[suid] = new TProfile(title, name, SPADIC_TRACE_SIZE,0,SPADIC_TRACE_SIZE);
00960 pulseShapeEl[suid]->SetLineColor(2);
00961 pulseShapeEl[suid]->GetYaxis()->SetRangeUser(-20,256);
00962 pulseShapeEl[suid]->SetXTitle("time-bin");
00963 pulseShapeEl[suid]->SetYTitle("average ADC-value");
00964
00965 title.Form("pulseShapePi_%i",usedSuId[suid]);
00966 name.Form("pulse shape pion Sus%i",usedSuId[suid]);
00967 pulseShapePi[suid] = new TProfile(title, name, SPADIC_TRACE_SIZE,0,SPADIC_TRACE_SIZE);
00968 pulseShapePi[suid]->GetYaxis()->SetRangeUser(-20,256);
00969 pulseShapePi[suid]->SetXTitle("time-bin");
00970 pulseShapePi[suid]->SetYTitle("average ADC-value");
00971
00972 title.Form("PRF_%i",usedSuId[suid]);
00973 name.Form("PRF Sus%i",usedSuId[suid]);
00974 prf[suid] = new TH2D(title, name, 300, -1.5, 1.5, 100, 0, 1);
00975 prf[suid]->SetXTitle("relative pad charge");
00976 prf[suid]->SetYTitle("reco. hit position [pad units]");
00977 prf[suid]->SetContour(99);
00978
00979 title.Form("PRF_Profile%i",usedSuId[suid]);
00980 name.Form("PRF Profile Sus%i",usedSuId[suid]);
00981 prfProfile[suid] = new TProfile(title, name, 30 * padWidth[suid], -1.5 * padWidth[suid], 1.5 * padWidth[suid]);
00982 prfProfile[suid]->SetXTitle("relative pad charge");
00983 prfProfile[suid]->SetYTitle("reco. hit position [mm]");
00984 }
00985 TH1D *rawPulseA[NUM_SPADIC_CHA];
00986 TH1D *rawPulseB[NUM_SPADIC_CHA];
00987 TH1D *rawPulse[NUM_SPADIC_CHA];
00988 TH1D *baselinePulse[NUM_SPADIC_CHA];
00989 TH1D *baselinePulseA[NUM_SPADIC_CHA];
00990 TH1D *baselinePulseB[NUM_SPADIC_CHA];
00991 TH1D *baselineNoisePulse[NUM_SPADIC_CHA];
00992 TH1D *baselineNoisePulseA[NUM_SPADIC_CHA];
00993 TH1D *baselineNoisePulseB[NUM_SPADIC_CHA];
00994
00995 for (Int_t ch = 0; ch < NUM_SPADIC_CHA; ch++) {
00996 name.Form("Ch%02i",ch);
00997 rawPulseA[ch] = new TH1D("rawPulseA"+name,"rawPulse"+name,SPADIC_TRACE_SIZE,0,SPADIC_TRACE_SIZE);
00998 rawPulseB[ch] = new TH1D("rawPulseB"+name,"rawPulse"+name,SPADIC_TRACE_SIZE,0,SPADIC_TRACE_SIZE);
00999 rawPulse[ch] = new TH1D("rawPulse"+name,"rawPulse"+name,SPADIC_TRACE_SIZE,0,SPADIC_TRACE_SIZE);
01000 baselinePulseA[ch] = new TH1D("baselinePulseA"+name,"baselinePulse"+name,SPADIC_TRACE_SIZE,0,SPADIC_TRACE_SIZE);
01001 baselinePulseB[ch] = new TH1D("baselinePulseB"+name,"baselinePulse"+name,SPADIC_TRACE_SIZE,0,SPADIC_TRACE_SIZE);
01002 baselinePulse[ch] = new TH1D("baselinePulse"+name,"baselinePulse"+name,SPADIC_TRACE_SIZE,0,SPADIC_TRACE_SIZE);
01003 baselineNoisePulseA[ch] = new TH1D("baselineNoisePulseA"+name,"baselineNoisePulse"+name,SPADIC_TRACE_SIZE,0,SPADIC_TRACE_SIZE);
01004 baselineNoisePulseB[ch] = new TH1D("baselineNoisePulseB"+name,"baselineNoisePulse"+name,SPADIC_TRACE_SIZE,0,SPADIC_TRACE_SIZE);
01005 baselineNoisePulse[ch] = new TH1D("baselineNoisePulse"+name,"baselineNoisePulse"+name,SPADIC_TRACE_SIZE,0,SPADIC_TRACE_SIZE);
01006 }
01007 while (fileSet.good()) {
01008 TString filename;
01009 fileSet >> filename;
01010 printf(" %s\n",filename.Data());
01011 if (filename.Sizeof() > 5) {
01012 TString ifname = filename;
01013 if(!ifname.EndsWith(".root")) ifname.Append(".root");
01014
01015
01016
01017
01018
01019
01020
01021 ifname = folder + filename;
01022 if(!ifname.EndsWith(".root")) ifname.Append(".root");
01023 TFile inputFile(ifname,"READ");
01024
01025 TTree* theTree=0;
01026 TKey* kee=0;
01027 TIter iter(inputFile.GetListOfKeys());
01028 while ( ( kee=dynamic_cast<TKey*>(iter()) ) !=0 ) {
01029 theTree = dynamic_cast<TTree*>(kee->ReadObj());
01030 if (theTree)
01031 break;
01032 }
01033 if(theTree==0) {
01034 cout <<"Error: no Tree in file "<< ifname.Data() << endl;
01035 return;
01036 }
01037
01038
01039
01040
01041 Double_t minAmplitude[usedSusibos] = { 15, 15, 15, 15, 15, 15, 15, 15 };
01042 Int_t HitTimeWindow[usedSusibos][2] = { {13,20}, {13,20}, {13,20}, {13,20}, {13,20}, {13,20}, {13,20}, {13,20} };
01043 Int_t IntegrationWindow[usedSusibos][2] = { {14,22}, {14,22}, {14,22}, {14,22}, {14,22}, {14,22}, {14,22}, {14,22} };
01044
01045 Double_t dxPosmm[usedSusibos] = {0.0};
01046
01047
01048 TCernOct11UnpackEvent* evnt = new TCernOct11UnpackEvent;
01049 TGo4EventElement* theBase=evnt;
01050 evnt->synchronizeWithTree(theTree, &theBase);
01051
01052
01053
01054
01055
01056
01057
01058 Int_t entries = theTree->GetEntries();
01059 allEvents += entries;
01060 Int_t nPion[usedSusibos][nMerge] = {{0}};
01061 Int_t nElectron[usedSusibos][nMerge] = {{0}};
01062 Int_t nGoodEvents[usedSusibos][nMerge] = {{0}};
01063
01064 TMbsCrateEvent* fCrateInputEvent;
01065 TSpadicEvent* SpadicInputEvent;
01066 TSpadicData* theSpadic;
01067 TSpadicData* theSpadicA;
01068 TSpadicData* theSpadicB;
01069
01070 Float_t Ch1(0), Ch2(0), Pb(0);
01071 cout << " " << entries << " Entries" << endl;
01072 if (debug)
01073 entries = 10000;
01074 GetPidCuts(filename);
01075
01076 for(Int_t i=0;i<entries;++i) {
01077 Statusbar(i,entries);
01078 theTree->GetEntry(i);
01079 fCrateInputEvent=dynamic_cast<TMbsCrateEvent*>(evnt->GetSubEvent("MBSCRATE"));
01080 SpadicInputEvent=dynamic_cast<TSpadicEvent*>(evnt->GetSubEvent("SPADIC"));
01081
01082
01083 isPion = false;
01084 isElectron = false;
01085 isMyon = false;
01086
01087 Ch1 = fCrateInputEvent->fData1182[1][0];
01088 Ch2 = fCrateInputEvent->fData1182[0][1];
01089 Pb = fCrateInputEvent->fData1182[1][5];
01090 getPID( Ch1, Ch2, Pb);
01091
01092 if (isPion || isElectron) {
01093 Ch1_Pb->Fill(Ch1,Pb);
01094 Ch2_Pb->Fill(Ch2,Pb);
01095 }
01096 if (!isPion && !isElectron) {
01097 noCh1_Pb->Fill(Ch1,Pb);
01098 noCh2_Pb->Fill(Ch2,Pb);
01099 }
01100 Double_t maxAmplitudeCorr[usedSusibos] = {0.0};
01101 for (Int_t suid = 0; suid < usedSusibos; suid++){
01102
01103 theSpadic=dynamic_cast<TSpadicData*>(SpadicInputEvent->getEventElement(usedSuId[suid]));
01104 Double_t pulse[NUM_SPADIC_CHA][SPADIC_TRACE_SIZE] = {{0.0}};
01105 Bool_t signalChannel[NUM_SPADIC_CHA] = {false};
01106 Bool_t overFlow = theSpadic->fSpadicOverFlowEvent;
01107 Bool_t underShoot = theSpadic->fSpadicUndershootsEvent;
01108 maxAmplitudeCorr[suid] = -40.0;
01109 dxPosmm[suid] = 0.0;
01110
01111 for (Int_t imerge = 0; imerge < nMerge; imerge++) {
01112 msMerge = Bool_t(imerge);
01113 if (raw) {
01114 if((suid < 4) && (msMerge)) {
01115 theSpadicA = dynamic_cast<TSpadicData*>(SpadicInputEvent->getEventElement(usedSuId[suid]));
01116 if(theSpadicA==0) continue;
01117 if(!theSpadicA->IsValid()) continue;
01118
01119 theSpadicB = dynamic_cast<TSpadicData*>(SpadicInputEvent->getEventElement(topSuId[suid]));
01120 if(theSpadicB==0) continue;
01121 if(!theSpadicB->IsValid()) continue;
01122
01123 if (theSpadicA->fSpadicOverFlowEvent || theSpadicB->fSpadicOverFlowEvent) overFlow = true;
01124 if (theSpadicA->fSpadicUndershootsEvent || theSpadicB->fSpadicUndershootsEvent) underShoot = true;
01125
01126
01127 for (Int_t ch = 0; ch < NUM_SPADIC_CHA; ch++) {
01128 rawPulseA[ch]->Reset();
01129 rawPulseB[ch]->Reset();
01130 baselinePulseA[ch]->Reset();
01131 baselinePulseB[ch]->Reset();
01132 baselineNoisePulseA[ch]->Reset();
01133 baselineNoisePulseB[ch]->Reset();
01134 for (Int_t bin = 0; bin < SPADIC_TRACE_SIZE; bin++) {
01135 rawPulseA[ch]->Fill(bin, (Double_t)theSpadicA->fSpadicPulse[ch][bin]);
01136 rawPulseB[ch]->Fill(bin, (Double_t)theSpadicB->fSpadicPulse[ch][bin]);
01137
01138
01139 }
01140 }
01141
01142 BaselineCompensation(rawPulseA, baselinePulseA);
01143 NoiseReduction(baselinePulseA, baselineNoisePulseA, signalChannel);
01144
01145 BaselineCompensation(rawPulseB, baselinePulseB);
01146 NoiseReduction(baselinePulseB, baselineNoisePulseB, signalChannel);
01147
01148 for (Int_t ch = 0; ch < NUM_SPADIC_CHA; ch++) {
01149 for (Int_t bin = 0; bin < SPADIC_TRACE_SIZE; bin++) {
01150 if (baselineNoisePulseA[ch]->GetBinContent(baselineNoisePulseA[ch]->FindBin(bin)) > 0)
01151 pulse[ch][bin] = baselineNoisePulseA[ch]->GetBinContent(baselineNoisePulseA[ch]->FindBin(bin));
01152 if (baselineNoisePulseB[7-ch]->GetBinContent(baselineNoisePulseB[7-ch]->FindBin(bin)))
01153 pulse[ch][bin] += baselineNoisePulseB[7-ch]->GetBinContent(baselineNoisePulseB[7-ch]->FindBin(bin));
01154 }
01155 }
01156 }
01157 else {
01158 for (Int_t ch = 0; ch < NUM_SPADIC_CHA; ch++) {
01159 rawPulse[ch]->Reset();
01160 baselinePulse[ch]->Reset();
01161 baselineNoisePulse[ch]->Reset();
01162 for (Int_t bin = 0; bin < SPADIC_TRACE_SIZE; bin++) {
01163 rawPulse[ch]->Fill(bin, (Double_t)theSpadicA->fSpadicPulse[ch][bin]);
01164 }
01165 }
01166 BaselineCompensation(rawPulse, baselinePulse);
01167 NoiseReduction(baselinePulse, baselineNoisePulse, signalChannel);
01168 for (Int_t ch = 0; ch < NUM_SPADIC_CHA; ch++) {
01169 for (Int_t bin = 0; bin < SPADIC_TRACE_SIZE; bin++) {
01170 pulse[ch][bin] = baselineNoisePulse[ch]->GetBinContent(baselineNoisePulse[ch]->FindBin(bin));
01171 }
01172 }
01173 }
01174 }
01175 else {
01176 if((suid < 4) && (msMerge)) {
01177 theSpadicA = dynamic_cast<TSpadicData*>(SpadicInputEvent->getEventElement(usedSuId[suid]));
01178 if(theSpadicA==0) continue;
01179 if(!theSpadicA->IsValid()) continue;
01180
01181 theSpadicB = dynamic_cast<TSpadicData*>(SpadicInputEvent->getEventElement(topSuId[suid]));
01182 if(theSpadicB==0) continue;
01183 if(!theSpadicB->IsValid()) continue;
01184
01185 if (theSpadicA->fSpadicOverFlowEvent || theSpadicB->fSpadicOverFlowEvent) overFlow = true;
01186 if (theSpadicA->fSpadicUndershootsEvent || theSpadicB->fSpadicUndershootsEvent) underShoot = true;
01187
01188 Double_t pulseA[NUM_SPADIC_CHA][SPADIC_TRACE_SIZE] = {{0.0}};
01189 Double_t pulseB[NUM_SPADIC_CHA][SPADIC_TRACE_SIZE] = {{0.0}};
01190
01191 for (Int_t ch = 0; ch < NUM_SPADIC_CHA; ch++) {
01192 for (Int_t bin = 0; bin < SPADIC_TRACE_SIZE; bin++) {
01193 pulseA[ch][bin] = theSpadicA->fSpadicCompensated[ch][bin];
01194 pulseB[ch][bin] = theSpadicB->fSpadicCompensated[ch][bin];
01195 if (theSpadicA->fSpadicSignalCh[ch] || theSpadicB->fSpadicSignalCh[ch])
01196 signalChannel[ch] = true;;
01197 }
01198 }
01199 BaselineCorrection(pulseA);
01200 BaselineCorrection(pulseB);
01201 for (Int_t ch = 0; ch < NUM_SPADIC_CHA; ch++) {
01202 for (Int_t bin = 0; bin < SPADIC_TRACE_SIZE; bin++) {
01203 if (pulseA[ch][bin] > 0)
01204 pulse[ch][bin] = pulseA[ch][bin];
01205 if (pulseB[7-ch][bin] > 0)
01206 pulse[ch][bin] += pulseB[7-ch][bin];
01207 }
01208 }
01209 }
01210 else{
01211
01212 for (Int_t ch = 0; ch < NUM_SPADIC_CHA; ch++) {
01213 for (Int_t bin = 0; bin < SPADIC_TRACE_SIZE; bin++) {
01214 pulse[ch][bin] = theSpadic->fSpadicCompensated[ch][bin];
01215 signalChannel[ch] = theSpadic->fSpadicSignalCh[ch];
01216 }
01217 }
01218 BaselineCorrection(pulse);
01219 }
01220 }
01221
01222 if(theSpadic==0) continue;
01223 if(!theSpadic->IsValid()) continue;
01224
01225
01226
01227
01228
01229 Double_t maxAmplitude = 0.0;
01230 Double_t maxAmplitudeCh[NUM_SPADIC_CHA] = {0.0};
01231 Int_t maxCh = -1;
01232 Int_t maxTB[NUM_SPADIC_CHA] = {-1};
01233
01234
01235
01236
01237
01238
01239
01240
01241
01242
01243
01244
01245
01246
01247
01248
01249
01250
01251
01252 for (Int_t ch = 0; ch < NUM_SPADIC_CHA; ch++) {
01253 for (Int_t bin = 0; bin < SPADIC_TRACE_SIZE; bin++) {
01254 if (theSpadic->fSpadicOverflows[ch][bin])
01255 overFlow = true;
01256 if (pulse[ch][bin] > maxAmplitudeCh[ch]){
01257 maxAmplitudeCh[ch] = pulse[ch][bin];
01258 maxTB[ch] = bin;
01259 }
01260 }
01261 if(maxAmplitudeCh[ch] > maxAmplitude){
01262 maxAmplitude = maxAmplitudeCh[ch];
01263 maxCh = ch;
01264 }
01265 }
01266 if (!msMerge){
01267 if (maxCh != -1) {
01268 maxAmplitudeCorr[suid] = pulse[maxCh][maxTB[maxCh]];
01269 amplitudeSpectra[suid]->Fill(pulse[maxCh][maxTB[maxCh]]);
01270 chaGainCalibSpectra[suid][maxCh]->Fill(pulse[maxCh][maxTB[maxCh]]);
01271
01272
01273
01274 }
01275 else {
01276 if (debug) printf("\n <<<<< found no pad max\n");
01277 }
01278 }
01279 if (isElectron){
01280 hitTimeEl[suid]->Fill(maxTB[maxCh]);
01281 }
01282 if (isPion){
01283 hitTimePi[suid]->Fill(maxTB[maxCh]);
01284 }
01285 if (debug) {
01286 if (overFlow != theSpadic->fSpadicOverFlowEvent)
01287 cout << "wrong overflow" << endl;
01288
01289 if (maxCh != theSpadic->fSpadicHighestChannel)
01290 cout << "online: " << theSpadic->fSpadicHighestChannel << " maxA: " << maxAmplitudeCh[theSpadic->fSpadicHighestChannel]<< " offline: " << maxCh << " maxA: " << maxAmplitudeCh[maxCh] << endl;
01291 }
01292 if (maxCh < 1 || maxCh > 6) continue;
01293
01294
01295 Double_t amplCluster(0), ampl3Pad(0), ampl1Pad(0);
01296 Double_t intensCluster(0), intens3Pad(0), intens1Pad(0), intensClusterTBW(0), intens3PadTBW(0), intens1PadTBW(0);
01297 Double_t intensCh[NUM_SPADIC_CHA] = {0.0};
01298 for (Int_t ch = 0; ch < NUM_SPADIC_CHA; ch++) {
01299 for (Int_t bin = 0; bin < SPADIC_TRACE_SIZE; bin++) {
01300 if (pulse[ch][bin] > 0.0) {
01301 intensCh[ch] += pulse[ch][bin];
01302 if(signalChannel[ch]){
01303 intensCluster += pulse[ch][bin];
01304 if (bin > IntegrationWindow[suid][0] && bin < IntegrationWindow[suid][1])
01305 intensClusterTBW += pulse[ch][bin];
01306 }
01307 if (ch == maxCh){
01308 intens1Pad += pulse[ch][bin];
01309 if (bin > IntegrationWindow[suid][0] && bin < IntegrationWindow[suid][1])
01310 intens3PadTBW += pulse[ch][bin];
01311 }
01312 if (ch <= maxCh+1 && ch >= maxCh-1){
01313 intens3Pad += pulse[ch][bin];
01314 if (bin > IntegrationWindow[suid][0] && bin < IntegrationWindow[suid][1])
01315 intens1PadTBW += pulse[ch][bin];
01316 }
01317 }
01318 }
01319 if (pulse[ch][maxTB[maxCh]] > 0.0) {
01320 if(signalChannel[ch])
01321 amplCluster += pulse[ch][maxTB[maxCh]];
01322 if (ch == maxCh)
01323 ampl1Pad += pulse[ch][maxTB[maxCh]];
01324 if (ch <= maxCh+1 && ch >= maxCh-1)
01325 ampl3Pad += pulse[ch][maxTB[maxCh]];
01326
01327
01328
01329
01330
01331
01332
01333
01334 }
01335 }
01336
01337 if (maxTB[maxCh] > HitTimeWindow[suid][0] && maxTB[maxCh] < HitTimeWindow[suid][1]){
01338 if (maxAmplitude > minAmplitude[suid]) {
01339
01340 if (imerge == 0) {
01341 beamProfile[suid]->Fill(maxCh);
01342 if (maxCh >= 1 && maxCh <= NUM_SPADIC_CHA - 1){
01343 if (intensCh[maxCh-1] > 0.0 && intensCh[maxCh] > 0.0 && intensCh[maxCh+1] > 0.0) {
01344 Double_t dxPos = 0.5 * log((intensCh[maxCh+1] / intensCh[maxCh-1])) / log((pow(intensCh[maxCh],2) / (intensCh[maxCh+1] * intensCh[maxCh-1])));
01345 dxPosmm[suid] = dxPos * padWidth[suid] + maxCh * padWidth[suid];
01346 Double_t chargePercent = intensCh[maxCh-1] / (intensCh[maxCh-1] + intensCh[maxCh] + intensCh[maxCh+1]);
01347 prf[suid]->Fill(-dxPos-1,chargePercent);
01348 prfProfile[suid]->Fill((-dxPos-1) * padWidth[suid],chargePercent);
01349 chargePercent = intensCh[maxCh] / (intensCh[maxCh-1] + intensCh[maxCh] + intensCh[maxCh+1]);
01350 prf[suid]->Fill(dxPos,chargePercent);
01351 prfProfile[suid]->Fill(dxPos * padWidth[suid],chargePercent);
01352 chargePercent = intensCh[maxCh+1] / (intensCh[maxCh-1] + intensCh[maxCh] + intensCh[maxCh+1]);
01353 prf[suid]->Fill(-dxPos+1,chargePercent);
01354 prfProfile[suid]->Fill((-dxPos+1) * padWidth[suid],chargePercent);
01355 }
01356 }
01357 }
01358
01359 for (Int_t bin = 0; bin < SPADIC_TRACE_SIZE; bin++) {
01360 if (isElectron){
01361 pulseShapeEl[suid]->Fill(bin,pulse[maxCh][bin]);
01362 }
01363 if (isPion){
01364 pulseShapePi[suid]->Fill(bin,pulse[maxCh][bin]);
01365 }
01366 }
01367 for (Int_t ifilter = 0; ifilter < nFilter; ifilter++) {
01368 if ((ifilter == 0 ) ||
01369 (ifilter == 1 && !overFlow) ||
01370 (ifilter == 2 && !overFlow && !underShoot) ||
01371 (ifilter == 3 && !underShoot)
01372 ) {
01373 if (ifilter == 0 )
01374 nGoodEvents[suid][imerge]++;
01375 if (isElectron){
01376 preCompSpectraEl[suid][0][imerge][ifilter]->Fill(intensCluster);
01377 preCompSpectraEl[suid][1][imerge][ifilter]->Fill(intens3Pad);
01378 preCompSpectraEl[suid][2][imerge][ifilter]->Fill(intens1Pad);
01379 preCompSpectraEl[suid][3][imerge][ifilter]->Fill(intensClusterTBW);
01380 preCompSpectraEl[suid][4][imerge][ifilter]->Fill(intens3PadTBW);
01381 preCompSpectraEl[suid][5][imerge][ifilter]->Fill(intens1PadTBW);
01382 preCompSpectraEl[suid][6][imerge][ifilter]->Fill(amplCluster);
01383 preCompSpectraEl[suid][7][imerge][ifilter]->Fill(ampl3Pad);
01384 preCompSpectraEl[suid][8][imerge][ifilter]->Fill(ampl1Pad);
01385 if (ifilter == 0 )
01386 nElectron[suid][imerge]++;
01387 }
01388 if (isPion){
01389 preCompSpectraPi[suid][0][imerge][ifilter]->Fill(intensCluster);
01390 preCompSpectraPi[suid][1][imerge][ifilter]->Fill(intens3Pad);
01391 preCompSpectraPi[suid][2][imerge][ifilter]->Fill(intens1Pad);
01392 preCompSpectraPi[suid][3][imerge][ifilter]->Fill(intensClusterTBW);
01393 preCompSpectraPi[suid][4][imerge][ifilter]->Fill(intens3PadTBW);
01394 preCompSpectraPi[suid][5][imerge][ifilter]->Fill(intens1PadTBW);
01395 preCompSpectraPi[suid][6][imerge][ifilter]->Fill(amplCluster);
01396 preCompSpectraPi[suid][7][imerge][ifilter]->Fill(ampl3Pad);
01397 preCompSpectraPi[suid][8][imerge][ifilter]->Fill(ampl1Pad);
01398 if (ifilter == 0 )
01399 nPion[suid][imerge]++;
01400 }
01401 }
01402 }
01403 }
01404 }
01405 }
01406 }
01407
01408 Double_t distance[usedSusibos] = {0.0};
01409
01410
01411 Bool_t trackfoundMS = Distance2TrackMS(dxPosmm, distance);
01412 Bool_t trackfoundFFM = Distance2TrackFFM(dxPosmm, distance);
01413
01414 Int_t MShitCount(0), FFMhitCount(0);
01415 for (Int_t suid = 0; suid < usedSusibos; suid++) {
01416 if (dxPosmm[suid] != 0.0){
01417 if (suid < 4)
01418 MShitCount++;
01419 else
01420 FFMhitCount++;
01421 }
01422 }
01423 for (Int_t suid = 0; suid < usedSusibos; suid++) {
01424
01425
01426
01427
01428
01429
01430
01431
01432
01433
01434 for (Int_t suid2 = 0; suid2 < usedSusibos; suid2++) {
01435 if (dxPosmm[suid] > 0.0 && dxPosmm[suid2] > 0.0) {
01436 if (suid == suid2) {
01437
01438 if(suid < 4){
01439 if (trackfoundMS) {
01440 chamberAlignment[suid][suid2]->Fill(dxPosmm[suid],distance[suid]);
01441 }
01442 }
01443 else {
01444 if (trackfoundFFM) {
01445 chamberAlignment[suid][suid2]->Fill(dxPosmm[suid],distance[suid]);
01446 }
01447 }
01448 }
01449 else {
01450
01451
01452 chamberAlignment[suid][suid2]->Fill(dxPosmm[suid],dxPosmm[suid]-dxPosmm[suid2]);
01453
01454
01455
01456
01457
01458 if (debug) printf(" %.2f %.2f %.2f\n",dxPosmm[suid],dxPosmm[suid2],dxPosmm[suid]-dxPosmm[suid2]);
01459 }
01460 }
01461 amplitudeCorr[suid][suid2]->Fill(maxAmplitudeCorr[suid],maxAmplitudeCorr[suid2]);
01462 }
01463 }
01464
01465
01466 }
01467
01468 for (Int_t suid = 0; suid < usedSusibos; suid++){
01469 printf(" Susibo%3i %6i [%6i] electrons (%4.1f%%) [(%4.1f%%)] %6i [%6i] pions (%4.1f%%) [(%4.1f%%)] %6i [%6i] good events (%4.1f%%) [(%4.1f%%)]\n"
01470 ,usedSuId[suid]
01471 ,nElectron[suid][0],nElectron[suid][1],Float_t(nElectron[suid][0]*100)/entries,Float_t(nElectron[suid][1]*100)/entries
01472 ,nPion[suid][0],nPion[suid][1],Float_t(nPion[suid][0]*100)/entries,Float_t(nPion[suid][1]*100)/entries
01473 ,nElectron[suid][0]+nPion[suid][0],nElectron[suid][1]+nPion[suid][1],Float_t((nGoodEvents[suid][0])*100)/entries,Float_t((nGoodEvents[suid][1])*100)/entries
01474 );
01475 for (Int_t imerge = 0; imerge < nMerge; imerge++) {
01476 allElectron[suid][imerge] += nElectron[suid][imerge];
01477 allPion[suid][imerge] += nPion[suid][imerge];
01478 allGoodEvent[suid][imerge] += nGoodEvents[suid][imerge];
01479 }
01480 }
01481 cout <<"*** DONE."<< endl;
01482
01483 inputFile.Close();
01484 }
01485 }
01486
01487 Int_t c_x(1680*4), c_y(1050*4);
01488 if (debug){
01489 c_x /= 2;
01490 c_y /= 2;
01491 }
01492
01493 TCanvas* cSpectra = new TCanvas("Spectra","Spectra",c_x,c_y);
01494 TCanvas* cRest = new TCanvas("Rest","Rest",c_x,c_x);
01495 TCanvas* cBeamMonitor = new TCanvas("BeamMonitor","Beam Monitor",c_x/8,c_y/8);
01496 TCanvas* cACorr = new TCanvas("cACorr","cACorr",c_x,c_y);
01497 TCanvas* cPCorr = new TCanvas("cPCorr","cPCorr",c_x,c_y);
01498
01499 cSpectra->Divide(usedSusibos,recoSets);
01500 cRest->Divide(usedSusibos,12);
01501 cBeamMonitor->Divide(2,2);
01502 cACorr->Divide(usedSusibos,usedSusibos);
01503 cPCorr->Divide(usedSusibos,usedSusibos);
01504
01505 cBeamMonitor->cd(1);
01506 Ch1_Pb->DrawCopy("colz");
01507 cBeamMonitor->cd(3);
01508 Ch2_Pb->DrawCopy("colz");
01509 cBeamMonitor->cd(2);
01510 noCh1_Pb->DrawCopy("colz");
01511 cBeamMonitor->cd(4);
01512 noCh2_Pb->DrawCopy("colz");
01513 cBeamMonitor->Update();
01514
01515 for (Int_t suid = 0; suid < usedSusibos; suid++) {
01516 for (Int_t suid2 = 0; suid2 < usedSusibos; suid2++) {
01517 cACorr->cd(suid2*usedSusibos+suid+1)->SetLogz(1);
01518 amplitudeCorr[suid][suid2]->DrawCopy("colz");
01519 outputFile.cd();
01520 amplitudeCorr[suid][suid2]->Write("", TObject::kOverwrite);
01521
01522 cPCorr->cd(suid2*usedSusibos+suid+1);
01523 chamberAlignment[suid][suid2]->DrawCopy();
01524 chamberAlignment[suid][suid2]->Fit("alignmentFit","Q","0",0.25*NUM_SPADIC_CHA*padWidth[suid],0.75*NUM_SPADIC_CHA*padWidth[suid]);
01525 alignmentFit->SetLineColor(2);
01526 alignmentFit->DrawCopy("same");
01527 chamberAlignment[suid][suid2]->DrawCopy("same");
01528 chamberAlignment[suid][suid2]->Write("", TObject::kOverwrite);
01529 }
01530 }
01531
01532 outputFile.cd();
01533 Ch1_Pb->Write("", TObject::kOverwrite);
01534 noCh1_Pb->Write("", TObject::kOverwrite);
01535 Ch2_Pb->Write("", TObject::kOverwrite);
01536 noCh2_Pb->Write("", TObject::kOverwrite);
01537 cBeamMonitor->Write("", TObject::kOverwrite);
01538 cACorr->Write("", TObject::kOverwrite);
01539 cPCorr->Write("", TObject::kOverwrite);
01540
01541 Double_t MeanElectronSpectra(0), MeanPionSpectra(0);
01542 TLatex EP_Ratio;
01543 TString EP_temp;
01544 EP_Ratio.SetTextSize(0.04);
01545 TLegend* leg[usedSusibos][recoSets][nMerge][nFilter];
01546 Int_t x_max = 15000;
01547 Int_t rBin = 1;
01548
01549 for (Int_t imerge = 0; imerge < nMerge; imerge++) {
01550 for (Int_t ifilter = 0; ifilter < nFilter; ifilter++) {
01551 for (Int_t suid = 0; suid < usedSusibos; suid++){
01552 for (Int_t rs = 0; rs < recoSets; rs++) {
01553 if (rs > 5 && rs < recoSets){
01554 x_max = 1000;
01555
01556 }
01557 else
01558 {
01559 x_max = 15000;
01560
01561 }
01562 leg[suid][rs][imerge][ifilter] = new TLegend(0.5,0.6,0.85,0.85);
01563 leg[suid][rs][imerge][ifilter]->SetLineColor(0);
01564 leg[suid][rs][imerge][ifilter]->SetLineStyle(0);
01565 leg[suid][rs][imerge][ifilter]->SetFillColor(0);
01566 leg[suid][rs][imerge][ifilter]->SetFillStyle(0);
01567 leg[suid][rs][imerge][ifilter]->SetTextSize(0.035);
01568
01569 preCompSpectraEl[suid][rs][imerge][ifilter]->Scale(1./Float_t(preCompSpectraEl[suid][rs][imerge][ifilter]->GetEntries()));
01570 preCompSpectraEl[suid][rs][imerge][ifilter]->Rebin(rBin);
01571 if (preCompSpectraEl[suid][rs][imerge][ifilter]->GetEntries() > 0)
01572 MeanElectronSpectra = preCompSpectraEl[suid][rs][imerge][ifilter]->GetMean(1);
01573
01574 preCompSpectraPi[suid][rs][imerge][ifilter]->Scale(1./Float_t(preCompSpectraPi[suid][rs][imerge][ifilter]->GetEntries()));
01575 preCompSpectraPi[suid][rs][imerge][ifilter]->Rebin(rBin);
01576 if (preCompSpectraPi[suid][rs][imerge][ifilter]->GetEntries() > 0)
01577 MeanPionSpectra = preCompSpectraPi[suid][rs][imerge][ifilter]->GetMean(1);
01578
01579 preCompSpectraEl[suid][rs][imerge][ifilter]->GetXaxis()->SetRangeUser(1,x_max);
01580 preCompSpectraPi[suid][rs][imerge][ifilter]->GetXaxis()->SetRangeUser(1,x_max);
01581 EP_temp.Form("#LTe^{-}#GT = %.3f",MeanElectronSpectra);
01582 leg[suid][rs][imerge][ifilter]->AddEntry(preCompSpectraEl[suid][rs][imerge][ifilter],EP_temp,"l");
01583 EP_temp.Form("#LT#pi^{-}#GT = %.3f",MeanPionSpectra);
01584 leg[suid][rs][imerge][ifilter]->AddEntry(preCompSpectraPi[suid][rs][imerge][ifilter],EP_temp,"l");
01585 if (MeanPionSpectra != 0)
01586 EP_temp.Form("#LTe^{-}#GT/#LT#pi^{-}#GT = %.3f",MeanElectronSpectra/MeanPionSpectra);
01587 else
01588 EP_temp.Form("#LTe^{-}#GT/#LT#pi^{-}#GT = %.3f",0.0);
01589 leg[suid][rs][imerge][ifilter]->AddEntry((TObject*)0,EP_temp,"");
01590 if (debug) printf(" %s %s\n",recoSetName[rs].Data(),EP_temp.Data());
01591 if (preCompSpectraEl[suid][rs][imerge][ifilter]->GetEntries() > 0 && preCompSpectraPi[suid][rs][imerge][ifilter]->GetEntries() > 0) {
01592 cSpectra->cd(rs * usedSusibos + suid + 1);
01593 preCompSpectraPi[suid][rs][imerge][ifilter]->DrawCopy();
01594 preCompSpectraEl[suid][rs][imerge][ifilter]->DrawCopy("same");
01595 leg[suid][rs][imerge][ifilter]->Draw("same");
01596 }
01597 }
01598 }
01599 cSpectra->Update();
01600 cSpectra->SaveAs("data2012/Analysis/Pics/Spectra_" + TString(nameFileSet(0,nameFileSet.Sizeof()-5)) + "_" + mergeName[imerge] + "_" + filterName[ifilter] + ".png");
01601 cSpectra->Write(TString("Spectra_" + TString(nameFileSet(0,nameFileSet.Sizeof()-5)) + "_" + mergeName[imerge] + "_" + filterName[ifilter]), TObject::kOverwrite);
01602 }
01603 }
01604 TLegend *lPRF[usedSusibos];
01605 for (Int_t suid = 0; suid < usedSusibos; suid++){
01606 lPRF[suid] = new TLegend(0.5,0.7,0.95,0.95);
01607 cRest->cd(1+suid);
01608 pulseShapeEl[suid]->DrawCopy();
01609 pulseShapePi[suid]->DrawCopy("same");
01610 cRest->cd(9+suid);
01611 hitTimePi[suid]->DrawCopy();
01612 hitTimeEl[suid]->DrawCopy("same");
01613 cRest->cd(17+suid)->SetLogy(1);
01614 amplitudeSpectra[suid]->DrawCopy();
01615 cRest->cd(25+suid);
01616 prf[suid]->DrawCopy("colz");
01617 cRest->cd(33+suid);
01618 prfProfile[suid]->GetYaxis()->SetRangeUser(0,1);
01619 prfProfile[suid]->DrawCopy();
01620 prfProfile[suid]->Fit("sigmaFit","RQ0");
01621 TString sl;
01622 sl.Form("#sigma = %f",sigmaFit->GetParameter(2));
01623 lPRF[suid]->AddEntry(sigmaFit,sl,"lep");
01624 if (suid >= 0 && suid < 2) {
01625 prfProfile[suid]->Fit("mathiesonMS336","RQ0");
01626 sl.Form("K_{3} = %f",mathiesonMS336->GetParameter(0));
01627 }
01628 if (suid >= 2 && suid < 4) {
01629 prfProfile[suid]->Fit("mathiesonMS444","RQ0");
01630 sl.Form("K_{3} = %f",mathiesonMS444->GetParameter(0));
01631 }
01632 lPRF[suid]->AddEntry(prfProfile[suid],sl,"lep");
01633 sigmaFit->SetLineColor(2);
01634 sigmaFit->DrawCopy("same");
01635 if (suid < 4)
01636 prfProfile[suid]->DrawCopy("same");
01637 prfProfile[suid]->DrawCopy("same");
01638 lPRF[suid]->Draw("same");
01639 cRest->cd(41+suid);
01640 Int_t suid2min;
01641 if (suid < 4) {
01642 suid2min = 0;
01643 }
01644 else {
01645 suid2min = 4;
01646 }
01647 Int_t suid2max = suid2min + 4;
01648 for (Int_t suid2 = suid2min; suid2 < suid2max; suid2++){
01649 preCompSpectraPi[suid2][1][0][0]->SetLineColor(suid2+1);
01650 preCompSpectraPi[suid2][1][0][0]->GetXaxis()->SetRangeUser(0,6000);
01651 if (suid == suid2)
01652 preCompSpectraPi[suid2][1][0][0]->SetLineStyle(2);
01653 if (suid2 == 0)
01654 preCompSpectraPi[suid2][1][0][0]->DrawCopy();
01655 else
01656 preCompSpectraPi[suid2][1][0][0]->DrawCopy("same");
01657 preCompSpectraPi[suid2][1][0][0]->SetLineColor(1);
01658 preCompSpectraPi[suid2][1][0][0]->SetLineStyle(1);
01659 preCompSpectraPi[suid2][1][0][0]->GetXaxis()->SetRangeUser(1,x_max);
01660 }
01661 cRest->cd(49+suid)->SetLogy(1);
01662 for (Int_t ch = 0; ch < NUM_SPADIC_CHA; ch++) {
01663 chaGainCalibSpectra[suid][ch]->GetXaxis()->SetRangeUser(-50,255);
01664 if (ch == 0)
01665 chaGainCalibSpectra[suid][ch]->DrawCopy();
01666 else
01667 chaGainCalibSpectra[suid][ch]->DrawCopy("same");
01668
01669 chaGainCalibSpectra[suid][ch]->Fit("gausFit","RQ0");
01670 gausFit->DrawCopy("same");
01671 chaGain[suid]->Fill(ch, gausFit->GetParameter(1));
01672 }
01673 cRest->cd(57+suid);
01674 chaGain[suid]->DrawCopy();
01675
01676 cRest->cd(65+suid);
01677 beamProfile[suid]->DrawCopy();
01678
01679 cRest->cd(73+suid);
01680
01681
01682
01683
01684
01685 cRest->Update();
01686
01687
01688
01689 outputFile.cd();
01690
01691 for (Int_t ch = 0; ch < NUM_SPADIC_CHA; ch++) {
01692 chaGainCalibSpectra[suid][ch]->Write("", TObject::kOverwrite);
01693 }
01694
01695 for (Int_t rs = 0; rs < recoSets; rs++) {
01696 for (Int_t imerge = 0; imerge < nMerge; imerge++) {
01697 for (Int_t ifilter = 0; ifilter < nFilter; ifilter++) {
01698 preCompSpectraEl[suid][rs][imerge][ifilter]->Write("", TObject::kOverwrite);
01699 preCompSpectraPi[suid][rs][imerge][ifilter]->Write("", TObject::kOverwrite);
01700 }
01701 }
01702 }
01703
01704
01705 beamProfile[suid]->Write("", TObject::kOverwrite);
01706
01707 chaGain[suid]->Write("", TObject::kOverwrite);
01708
01709 amplitudeSpectra[suid]->Write("", TObject::kOverwrite);
01710
01711 pulseShapeEl[suid]->Write("", TObject::kOverwrite);
01712 pulseShapePi[suid]->Write("", TObject::kOverwrite);
01713
01714 hitTimeEl[suid]->Write("", TObject::kOverwrite);
01715 hitTimePi[suid]->Write("", TObject::kOverwrite);
01716
01717 prf[suid]->Write("", TObject::kOverwrite);
01718 prfProfile[suid]->Write("", TObject::kOverwrite);
01719 cRest->Write("", TObject::kOverwrite);
01720
01721 printf(" Susibo%3i %6i [%6i] electrons (%4.1f%%) [(%4.1f%%)] %6i [%6i] pions (%4.1f%%) [(%4.1f%%)] %6i [%6i] good events (%4.1f%%) [(%4.1f%%)]\n"
01722 ,usedSuId[suid]
01723 ,allElectron[suid][0],allElectron[suid][1],Float_t(allElectron[suid][0]*100)/allEvents,Float_t(allElectron[suid][1]*100)/allEvents
01724 ,allPion[suid][0],allPion[suid][1],Float_t(allPion[suid][0]*100)/allEvents,Float_t(allPion[suid][1]*100)/allEvents
01725 ,allPion[suid][0]+allElectron[suid][0],allPion[suid][1]+allElectron[suid][1],Float_t((allGoodEvent[suid][0])*100)/allEvents,Float_t((allGoodEvent[suid][1])*100)/allEvents
01726 );
01727
01728
01729
01730 }
01731
01732
01733 cBeamMonitor->SaveAs("data2012/Analysis/Pics/BeamMonitor_" + TString(nameFileSet(0,nameFileSet.Sizeof()-5)) + picEx);
01734
01735 cRest->SaveAs("data2012/Analysis/Pics/Rest_" + TString(nameFileSet(0,nameFileSet.Sizeof()-5)) + ".png");
01736
01737 cACorr->SaveAs("data2012/Analysis/Pics/ACorr_" + TString(nameFileSet(0,nameFileSet.Sizeof()-5)) + ".png");
01738
01739 cPCorr->SaveAs("data2012/Analysis/Pics/PR/PCorr_" + TString(nameFileSet(0,nameFileSet.Sizeof()-5)) + ".png");
01740
01741
01742 outputFile.Close();
01743
01744
01745
01746
01747
01748
01749
01750
01751
01752
01753
01754
01755
01756
01757
01758
01759
01760
01761
01762
01763
01764
01765
01766
01767
01768
01769
01770 }
01771 else {
01772 printf("no input file list in %s",nameFileSet.Data());
01773 return;
01774 }
01775 }