| 1 |
campana |
1.1 |
/** |
| 2 |
|
|
* TOFScan |
| 3 |
|
|
* Author Nagni |
| 4 |
|
|
* Version 1.2 |
| 5 |
|
|
* Modified by G.De Rosa |
| 6 |
|
|
* Date 27 Apr 2006 |
| 7 |
campana |
1.3 |
* Modified by G.De Rosa |
| 8 |
|
|
* Date 03 Jul 2006 |
| 9 |
pam-de |
1.4 |
* Modified by W. Menn to select helium particles for PMT gain check |
| 10 |
|
|
* Date 09 Aug 2007 |
| 11 |
|
|
* Last version 08 Oct 2007 |
| 12 |
campana |
1.1 |
* |
| 13 |
|
|
* Description: |
| 14 |
|
|
* Describe the performance of the TOF. |
| 15 |
|
|
* |
| 16 |
|
|
* Parameters: |
| 17 |
|
|
* TString base - the path to the root directory for the specific Pamela unpack session |
| 18 |
|
|
* TString outDirectory - the path where to save the output image (Default = base) |
| 19 |
|
|
* TString format - the format which will be used fo rsave the produced images (Default = "gif") |
| 20 |
|
|
*/ |
| 21 |
|
|
|
| 22 |
campana |
1.3 |
#include <TROOT.h> |
| 23 |
|
|
#include <TH1.h> |
| 24 |
|
|
#include <TFile.h> |
| 25 |
|
|
#include <TObjArray.h> |
| 26 |
campana |
1.1 |
#include <TString.h> |
| 27 |
|
|
#include <TObjString.h> |
| 28 |
|
|
#include <TTree.h> |
| 29 |
|
|
#include <TBranch.h> |
| 30 |
|
|
#include <TGraph.h> |
| 31 |
|
|
#include <TStyle.h> |
| 32 |
|
|
#include <TH2S.h> |
| 33 |
|
|
#include <TPaveText.h> |
| 34 |
|
|
#include <TCanvas.h> |
| 35 |
|
|
#include <physics/tof/TofEvent.h> |
| 36 |
mocchiut |
1.5 |
#include <cstdlib> |
| 37 |
|
|
#include <sys/stat.h> |
| 38 |
|
|
#include <math.h> |
| 39 |
pam-de |
1.4 |
#include <iostream> |
| 40 |
|
|
#include <fstream> |
| 41 |
campana |
1.1 |
|
| 42 |
|
|
using namespace std; |
| 43 |
|
|
|
| 44 |
|
|
void TofScan(TString base, TString outDirectory = "", TString format = ""){ |
| 45 |
|
|
|
| 46 |
|
|
std::stringstream sst; |
| 47 |
|
|
if (outDirectory == "") outDirectory = base.Data(); |
| 48 |
|
|
TString filename = ((TObjString*)base.Tokenize('/')->Last())->GetString(); |
| 49 |
|
|
|
| 50 |
|
|
TFile *file =new TFile(base.Data()) ; |
| 51 |
|
|
if (!file){ |
| 52 |
|
|
printf("file not Found \n"); |
| 53 |
|
|
return; |
| 54 |
|
|
} |
| 55 |
|
|
|
| 56 |
|
|
TTree *PhysicsTr = (TTree*)file->Get("Physics"); |
| 57 |
|
|
TBranch *TofBr = PhysicsTr->GetBranch("Tof"); |
| 58 |
|
|
pamela::tof::TofEvent *tofEvent = 0; |
| 59 |
|
|
PhysicsTr->SetBranchAddress("Tof", &tofEvent); |
| 60 |
|
|
|
| 61 |
|
|
Long64_t nevents = TofBr->GetEntries(); |
| 62 |
|
|
if (nevents <= 0) { |
| 63 |
|
|
printf("nevents = %llu \n", nevents); |
| 64 |
|
|
file->Close(); |
| 65 |
|
|
return; |
| 66 |
|
|
} |
| 67 |
|
|
|
| 68 |
|
|
/* |
| 69 |
|
|
* Array to convert hdc/adc to the real Photomultiplier |
| 70 |
|
|
* The array rows definitions are: |
| 71 |
|
|
* tof[0][] = chxxA (strip or channel xxA) |
| 72 |
|
|
* tof[1][] = hbxxA (halfboard xxA) |
| 73 |
|
|
* tof[2][] = chxxB (strip or channel xxB) |
| 74 |
|
|
* tof[3][] = hbxxB (halfboard xxB) |
| 75 |
|
|
* |
| 76 |
|
|
* Each single row is a sequence of photomultipliers in this shape |
| 77 |
|
|
* - The elements from 0 to 7 correspond to S11_1->S11_8 |
| 78 |
|
|
* - The elements from 8 to 13 correspond to S12_1->S12_6 |
| 79 |
|
|
* - The elements from 14 to 15 correspond to S21_1->S21_2 |
| 80 |
|
|
* - The elements from 16 to 17 correspond to S22_1->S22_2 |
| 81 |
|
|
* - The elements from 18 to 20 correspond to S31_1->S31_3 |
| 82 |
|
|
* - The elements from 21 to 23 correspond to S32_1->S32_3 |
| 83 |
|
|
* |
| 84 |
|
|
* Example: |
| 85 |
|
|
* -------> the tdc of the S12_3B photomultiplier correspond to tdc[(tof[2][10])][(tof[3][10])] |
| 86 |
|
|
* -------> the tdc of the S31_3A photomultiplier correspond to tdc[(tof[0][20])][(tof[1][20])] |
| 87 |
|
|
*/ |
| 88 |
|
|
short tof[4][24] = { |
| 89 |
|
|
{4, 4, 4, 4, 1, 1, 2, 2, 3, 3, 3, 3, 3, 3, 1, 1, 1, 1, 2, 3, 3, 3, 3, 4}, |
| 90 |
|
|
{1, 3, 5, 7, 10, 12, 2, 4, 2, 4, 6, 8, 10, 12, 1, 5, 3, 9, 7, 9, 11, 1, 5, 9}, |
| 91 |
|
|
{2, 2, 2, 2, 1, 1, 1, 1, 4, 4, 4, 4, 4, 4, 2, 1, 2, 1, 2, 2, 2, 3, 3, 4}, |
| 92 |
|
|
{6, 8, 12, 10, 8, 6, 4, 2, 12, 10, 8, 6, 4, 2, 9, 7, 11, 11, 5, 3, 1, 3, 7, 11} |
| 93 |
|
|
}; |
| 94 |
|
|
|
| 95 |
|
|
TString photoS[48] = { |
| 96 |
|
|
"S11_1A", "S11_1B", "S11_2A", "S11_2B", "S11_3A", "S11_3B", "S11_4A", "S11_4B", |
| 97 |
|
|
"S11_5A", "S11_5B", "S11_6A", "S11_6B", "S11_7A", "S11_7B", "S11_8A", "S11_8B", |
| 98 |
|
|
"S12_1A", "S12_1B", "S12_2A", "S12_2B", "S12_3A", "S12_3B", "S12_4A", "S12_4B", "S12_5A", "S12_5B", "S12_6A", "S12_6B", |
| 99 |
|
|
"S21_1A", "S21_1B", "S21_2A", "S21_2B", |
| 100 |
|
|
"S22_1A", "S22_1B", "S22_2A", "S22_2B", |
| 101 |
|
|
"S31_1A", "S31_1B", "S31_2A", "S31_2B", "S31_3A", "S31_3B", |
| 102 |
|
|
"S32_1A", "S32_1B", "S32_2A", "S32_2B", "S32_3A", "S32_3B" |
| 103 |
|
|
}; |
| 104 |
|
|
|
| 105 |
campana |
1.3 |
const Int_t nh = 48; |
| 106 |
|
|
TH1F *htdc[nh]; |
| 107 |
|
|
TH1F *hadc[nh]; |
| 108 |
|
|
|
| 109 |
|
|
TObjArray *hhtdc = new TObjArray(nh); |
| 110 |
|
|
TObjArray *hhadc = new TObjArray(nh); |
| 111 |
|
|
char tdcname[48]=""; |
| 112 |
|
|
char adcname[48]=""; |
| 113 |
pam-de |
1.4 |
|
| 114 |
|
|
char htitle[50]; |
| 115 |
|
|
TH1F *adche[48]; |
| 116 |
|
|
for(int i=0;i<48;i++) { |
| 117 |
|
|
sprintf(htitle, "adche_%d",(i+1)); |
| 118 |
|
|
adche[i] = new TH1F(htitle,htitle,100,0.,1500.); |
| 119 |
|
|
} |
| 120 |
|
|
|
| 121 |
|
|
|
| 122 |
|
|
Float_t adca[48]; // vector with adc values according to "ind"=pmt_id |
| 123 |
|
|
Float_t tdca[48]; // the same for tdc |
| 124 |
campana |
1.3 |
|
| 125 |
campana |
1.1 |
int j = 0; |
| 126 |
|
|
int k = 0; |
| 127 |
|
|
int z = 0; |
| 128 |
|
|
int ch = 0; |
| 129 |
|
|
int hb = 0; |
| 130 |
campana |
1.3 |
int ind =0; |
| 131 |
|
|
|
| 132 |
pam-de |
1.4 |
int heevent =0; |
| 133 |
|
|
|
| 134 |
|
|
// upper and lower limits for the helium selection |
| 135 |
|
|
Float_t A_l[24]={200,190,300,210,220,200,210,60, 60, 120,220,120,160,50, 300,200,120,250,350,300,350,250,280,300}; |
| 136 |
|
|
Float_t A_h[24]={550,490,800,600,650,600,600,260,200,380,620,380,550,200,850,560,400,750,900,800,880,800,750,800}; |
| 137 |
|
|
|
| 138 |
|
|
// The k1 constants for the beta calculation, only for S1-S3 |
| 139 |
|
|
// k2 constant is taken to be the standard 2D/c |
| 140 |
|
|
Float_t k1[72] = {50,59.3296,28.4328,-26.0818,5.91253,-19.588,-9.26316,24.7544,2.32465, |
| 141 |
|
|
-50.5058,-15.3195,-39.1443,-91.2546,-58.6243,-84.5641,-63.1516,-32.2091, |
| 142 |
|
|
-58.3358,13.8084,45.5322,33.2416,-11.5313,51.3271,75,-14.1141, |
| 143 |
|
|
42.8466,15.1794,-63.6672,-6.07739,-32.164,-41.771,10.5274,-9.46096, |
| 144 |
|
|
-81.7404,-28.783,-52.7167,-127.394,-69.6166,-93.4655,-98.9543,-42.863, |
| 145 |
|
|
-67.8244,-19.3238,31.1221,8.7319,-43.1627,5.55573,-14.4078,-83.4466, |
| 146 |
|
|
-47.4647,-77.8379,-108.222,-75.986,-101.297,-96.0205,-63.1881,-90.1372, |
| 147 |
|
|
-22.7347,8.31409,-19.6912,-7.49008,23.6979,-1.66677,1.81556,34.4668, |
| 148 |
|
|
6.23693,-100,-59.5861,-90.9159,-141.639,-89.2521,-112.881} ; |
| 149 |
|
|
|
| 150 |
|
|
//------------------------------------------------------------------- |
| 151 |
|
|
|
| 152 |
campana |
1.3 |
|
| 153 |
|
|
for (int i=0; i < nevents; i++){ |
| 154 |
|
|
|
| 155 |
campana |
1.1 |
TofBr->GetEntry(i); |
| 156 |
campana |
1.3 |
|
| 157 |
campana |
1.1 |
k = 0; |
| 158 |
|
|
while (k < 24){ |
| 159 |
|
|
j = 0; |
| 160 |
|
|
while (j < 2){ |
| 161 |
|
|
ch = tof[2*j][k] - 1; |
| 162 |
|
|
hb = tof[2*j + 1][k] - 1; |
| 163 |
campana |
1.3 |
ind = 2*k + j; |
| 164 |
|
|
|
| 165 |
|
|
if(i==0){ |
| 166 |
|
|
sprintf(tdcname,"TDChist%4.4d",ind); |
| 167 |
|
|
sprintf(adcname,"ADChist%4.4d",ind); |
| 168 |
|
|
|
| 169 |
|
|
htdc[ind] = new TH1F(tdcname,tdcname,409,0,4096); |
| 170 |
|
|
hadc[ind] = new TH1F(adcname,adcname,409,0,4096); |
| 171 |
|
|
|
| 172 |
|
|
hhtdc->Add(htdc[ind]); |
| 173 |
|
|
hhadc->Add(hadc[ind]); |
| 174 |
|
|
} |
| 175 |
|
|
|
| 176 |
|
|
htdc[ind]->Fill(tofEvent->tdc[ch][hb]); |
| 177 |
|
|
hadc[ind]->Fill(tofEvent->adc[ch][hb]); |
| 178 |
pam-de |
1.4 |
tdca[ind]=tofEvent->tdc[ch][hb]; |
| 179 |
|
|
adca[ind]=tofEvent->adc[ch][hb]; |
| 180 |
campana |
1.1 |
j++; |
| 181 |
|
|
} |
| 182 |
|
|
k++; |
| 183 |
|
|
} |
| 184 |
pam-de |
1.4 |
|
| 185 |
|
|
//============ calculate beta and select helium ==================== |
| 186 |
|
|
|
| 187 |
|
|
// find hitted paddle by looking for ADC values on both sides |
| 188 |
|
|
// since we looking for helium this gives decent results |
| 189 |
|
|
|
| 190 |
mocchiut |
1.5 |
//Int_t tof11_i,tof12_i,tof21_i,tof22_i,tof31_i,tof32_i; |
| 191 |
|
|
Int_t tof11_i,tof12_i,tof31_i,tof32_i; |
| 192 |
pam-de |
1.4 |
Float_t a1,a2; |
| 193 |
|
|
Int_t jj; |
| 194 |
|
|
|
| 195 |
|
|
// reset values |
| 196 |
|
|
tof11_i = -1; |
| 197 |
|
|
tof12_i = -1; |
| 198 |
mocchiut |
1.5 |
//tof21_i = -1; |
| 199 |
|
|
//tof22_i = -1; |
| 200 |
pam-de |
1.4 |
tof31_i = -1; |
| 201 |
|
|
tof32_i = -1; |
| 202 |
|
|
|
| 203 |
|
|
for(jj=0; jj<8; jj++){ |
| 204 |
|
|
a1 = adca[2*jj]; |
| 205 |
|
|
a2 = adca[2*jj+1]; |
| 206 |
|
|
if ((a1 < 3000) && (a2 < 3000)) tof11_i = jj; |
| 207 |
|
|
} |
| 208 |
|
|
for(jj=0; jj<6; jj++){ |
| 209 |
|
|
a1 = adca[16+2*jj]; |
| 210 |
|
|
a2 = adca[16+2*jj+1]; |
| 211 |
|
|
if ((a1 < 3000) && (a2 < 3000)) tof12_i = jj; |
| 212 |
|
|
} |
| 213 |
mocchiut |
1.5 |
/* for(jj=0; jj<2; jj++){ |
| 214 |
pam-de |
1.4 |
a1 = adca[28+2*jj]; |
| 215 |
|
|
a2 = adca[28+2*jj+1]; |
| 216 |
mocchiut |
1.5 |
// if ((a1 < 3000) && (a2 < 3000)) tof21_i = jj; |
| 217 |
pam-de |
1.4 |
} |
| 218 |
|
|
for(jj=0; jj<2; jj++){ |
| 219 |
|
|
a1 = adca[32+2*jj]; |
| 220 |
|
|
a2 = adca[32+2*jj+1]; |
| 221 |
mocchiut |
1.5 |
// if ((a1 < 3000) && (a2 < 3000)) tof22_i = jj; |
| 222 |
|
|
}*/ |
| 223 |
pam-de |
1.4 |
for(jj=0; jj<3; jj++){ |
| 224 |
|
|
a1 = adca[36+2*jj]; |
| 225 |
|
|
a2 = adca[36+2*jj+1]; |
| 226 |
|
|
if ((a1 < 3000) && (a2 < 3000)) tof31_i = jj; |
| 227 |
|
|
} |
| 228 |
|
|
for(jj=0; jj<3; jj++){ |
| 229 |
|
|
a1 = adca[42+2*jj]; |
| 230 |
|
|
a2 = adca[42+2*jj+1]; |
| 231 |
|
|
if ((a1 < 3000) && (a2 < 3000)) tof32_i = jj; |
| 232 |
|
|
} |
| 233 |
|
|
|
| 234 |
|
|
|
| 235 |
|
|
//---------------------------------------------------------------- |
| 236 |
|
|
|
| 237 |
|
|
Float_t zin[6] = {53.74, 53.04, 23.94, 23.44, -23.49, -24.34}; |
| 238 |
|
|
Float_t c1,c2,xhelp,xhelp1,xhelp2,ds,dist,F; |
| 239 |
|
|
Float_t sw,sxw,beta_mean_tof,w_i; |
| 240 |
|
|
Float_t theta,x1,x2,y1,y2,dx,dy,dr; |
| 241 |
|
|
Int_t ihelp; |
| 242 |
|
|
Int_t ipmt[4]; |
| 243 |
|
|
Float_t time[4]; |
| 244 |
|
|
Float_t beta1[4]; |
| 245 |
|
|
|
| 246 |
|
|
// Only use events with: S11 and S12 and S31 and S32 |
| 247 |
|
|
|
| 248 |
|
|
if ( (tof11_i>-1) && (tof12_i>-1) && (tof31_i>-1) && (tof32_i>-1) ) { |
| 249 |
|
|
|
| 250 |
|
|
// calculate zenith angle theta using the locations of the hitted paddles |
| 251 |
|
|
|
| 252 |
|
|
|
| 253 |
|
|
Float_t tof11_x[8] = {-17.85,-12.75,-7.65,-2.55,2.55,7.65,12.75,17.85}; |
| 254 |
|
|
Float_t tof12_y[6] = { -13.75,-8.25,-2.75,2.75,8.25,13.75}; |
| 255 |
|
|
// Float_t tof21_y[2] = { 3.75,-3.75}; |
| 256 |
|
|
// Float_t tof22_x[2] = { -4.5,4.5}; |
| 257 |
|
|
Float_t tof31_x[3] = { -6.0,0.,6.0}; |
| 258 |
|
|
Float_t tof32_y[3] = { -5.0,0.0,5.0}; |
| 259 |
|
|
|
| 260 |
|
|
// S11 8 paddles 33.0 x 5.1 cm |
| 261 |
|
|
// S12 6 paddles 40.8 x 5.5 cm |
| 262 |
|
|
// S21 2 paddles 18.0 x 7.5 cm |
| 263 |
|
|
// S22 2 paddles 15.0 x 9.0 cm |
| 264 |
|
|
// S31 3 paddles 15.0 x 6.0 cm |
| 265 |
|
|
// S32 3 paddles 18.0 x 5.0 cm |
| 266 |
|
|
|
| 267 |
|
|
x1 = 0.; |
| 268 |
|
|
x2 = 0.; |
| 269 |
|
|
y1 = 0.; |
| 270 |
|
|
y2 = 0.; |
| 271 |
|
|
|
| 272 |
|
|
x1 = tof11_x[tof11_i] ; |
| 273 |
|
|
y1 = tof12_y[tof12_i] ; |
| 274 |
|
|
x2 = tof31_x[tof31_i] ; |
| 275 |
|
|
y2 = tof32_y[tof32_i] ; |
| 276 |
|
|
|
| 277 |
|
|
theta=0.; |
| 278 |
|
|
dx=0.; |
| 279 |
|
|
dy=0.; |
| 280 |
|
|
dr=0.; |
| 281 |
|
|
|
| 282 |
|
|
dx = x1-x2; |
| 283 |
|
|
dy = y1-y2; |
| 284 |
|
|
dr = sqrt(dx*dx+dy*dy); |
| 285 |
|
|
theta = atan(dr/77.5); |
| 286 |
|
|
|
| 287 |
|
|
|
| 288 |
|
|
beta_mean_tof=100.; |
| 289 |
|
|
|
| 290 |
|
|
for (Int_t jj=0; jj< 4; jj++) beta1[jj] = 100. ; |
| 291 |
|
|
|
| 292 |
|
|
|
| 293 |
|
|
//---------------------------------------------------------------- |
| 294 |
|
|
//--------- S1 - S3 --------------------------------------------- |
| 295 |
|
|
//---------------------------------------------------------------- |
| 296 |
|
|
|
| 297 |
|
|
//--------- S11 - S31 ------------------------------------------- |
| 298 |
|
|
|
| 299 |
|
|
if ((tof11_i>-1)&&(tof31_i>-1)) { |
| 300 |
|
|
|
| 301 |
|
|
dist = zin[0] - zin[4]; |
| 302 |
|
|
c2 = (2.*0.01*dist)/(3.E08*50.E-12); |
| 303 |
|
|
F = 1./cos(theta); |
| 304 |
|
|
|
| 305 |
|
|
ipmt[0] = (tof11_i)*2; |
| 306 |
|
|
ipmt[1] = (tof11_i)*2+1; |
| 307 |
|
|
ipmt[2] = 36+(tof31_i)*2; |
| 308 |
|
|
ipmt[3] = 36+(tof31_i)*2+1; |
| 309 |
|
|
|
| 310 |
|
|
for (Int_t jj=0; jj< 4; jj++) time[jj] = tdca[(ipmt[jj])] ; |
| 311 |
|
|
|
| 312 |
|
|
if ((time[0]<4095)&&(time[1]<4095)&&(time[2]<4095)&&(time[3]<4095)) { |
| 313 |
|
|
xhelp1 = time[0] + time[1] ; |
| 314 |
|
|
xhelp2 = time[2] + time[3] ; |
| 315 |
|
|
ds = xhelp1-xhelp2; |
| 316 |
|
|
ihelp=0+(tof11_i)*3+tof31_i ; |
| 317 |
|
|
c1 = k1[ihelp] ; |
| 318 |
|
|
beta1[0] = c2*F/(ds-c1); |
| 319 |
|
|
} |
| 320 |
|
|
} |
| 321 |
|
|
|
| 322 |
|
|
//--------- S11 - S32 ------------------------------------------- |
| 323 |
|
|
|
| 324 |
|
|
if ((tof11_i>-1)&&(tof32_i>-1)) { |
| 325 |
|
|
|
| 326 |
|
|
dist = zin[0] - zin[5]; |
| 327 |
|
|
F = 1./cos(theta); |
| 328 |
|
|
c2 = (2.*0.01*dist)/(3.E08*50.E-12); |
| 329 |
|
|
|
| 330 |
|
|
ipmt[0] = (tof11_i)*2; |
| 331 |
|
|
ipmt[1] = (tof11_i)*2+1; |
| 332 |
|
|
ipmt[2] = 42+(tof32_i)*2; |
| 333 |
|
|
ipmt[3] = 42+(tof32_i)*2+1; |
| 334 |
|
|
|
| 335 |
|
|
for (Int_t jj=0; jj< 4; jj++) time[jj] = tdca[(ipmt[jj])] ; |
| 336 |
|
|
|
| 337 |
|
|
if ((time[0]<4095)&&(time[1]<4095)&&(time[2]<4095)&&(time[3]<4095)) { |
| 338 |
|
|
xhelp1 = time[0] + time[1] ; |
| 339 |
|
|
xhelp2 = time[2] + time[3] ; |
| 340 |
|
|
ds = xhelp1-xhelp2; |
| 341 |
|
|
ihelp=24+(tof11_i)*3+tof32_i ; |
| 342 |
|
|
c1 = k1[ihelp] ; |
| 343 |
|
|
beta1[1] = c2*F/(ds-c1); |
| 344 |
|
|
} |
| 345 |
|
|
} |
| 346 |
|
|
|
| 347 |
|
|
//--------- S12 - S31 ------------------------------------------- |
| 348 |
|
|
|
| 349 |
|
|
if ((tof12_i>-1)&&(tof31_i>-1)) { |
| 350 |
|
|
|
| 351 |
|
|
dist = zin[1] - zin[4]; |
| 352 |
|
|
F = 1./cos(theta); |
| 353 |
|
|
c2 = (2.*0.01*dist)/(3.E08*50.E-12); |
| 354 |
|
|
|
| 355 |
|
|
ipmt[0] = 16+(tof12_i)*2; |
| 356 |
|
|
ipmt[1] = 16+(tof12_i)*2+1; |
| 357 |
|
|
ipmt[2] = 36+(tof31_i)*2; |
| 358 |
|
|
ipmt[3] = 36+(tof31_i)*2+1; |
| 359 |
|
|
|
| 360 |
|
|
for (Int_t jj=0; jj< 4; jj++) time[jj] = tdca[(ipmt[jj])] ; |
| 361 |
|
|
|
| 362 |
|
|
if ((time[0]<4095)&&(time[1]<4095)&&(time[2]<4095)&&(time[3]<4095)) { |
| 363 |
|
|
xhelp1 = time[0] + time[1] ; |
| 364 |
|
|
xhelp2 = time[2] + time[3] ; |
| 365 |
|
|
ds = xhelp1-xhelp2; |
| 366 |
|
|
ihelp=48+(tof12_i)*3+tof31_i ; |
| 367 |
|
|
c1 = k1[ihelp] ; |
| 368 |
|
|
beta1[2] = c2*F/(ds-c1); |
| 369 |
|
|
} |
| 370 |
|
|
} |
| 371 |
|
|
|
| 372 |
|
|
//--------- S12 - S32 ------------------------------------------- |
| 373 |
|
|
|
| 374 |
|
|
if ((tof12_i>-1)&&(tof32_i>-1)) { |
| 375 |
|
|
|
| 376 |
|
|
dist = zin[1] - zin[5]; |
| 377 |
|
|
F = 1./cos(theta); |
| 378 |
|
|
c2 = (2.*0.01*dist)/(3.E08*50.E-12); |
| 379 |
|
|
|
| 380 |
|
|
ipmt[0] = 16+(tof12_i)*2; |
| 381 |
|
|
ipmt[1] = 16+(tof12_i)*2+1; |
| 382 |
|
|
ipmt[2] = 42+(tof32_i)*2; |
| 383 |
|
|
ipmt[3] = 42+(tof32_i)*2+1; |
| 384 |
|
|
|
| 385 |
|
|
for (Int_t jj=0; jj< 4; jj++) time[jj] = tdca[(ipmt[jj])] ; |
| 386 |
|
|
|
| 387 |
|
|
if ((time[0]<4095)&&(time[1]<4095)&&(time[2]<4095)&&(time[3]<4095)) { |
| 388 |
|
|
xhelp1 = time[0] + time[1] ; |
| 389 |
|
|
xhelp2 = time[2] + time[3] ; |
| 390 |
|
|
ds = xhelp1-xhelp2; |
| 391 |
|
|
ihelp=66+(tof12_i)*3+tof32_i ; |
| 392 |
|
|
c1 = k1[ihelp] ; |
| 393 |
|
|
beta1[3] = c2*F/(ds-c1); |
| 394 |
|
|
} |
| 395 |
|
|
} |
| 396 |
|
|
|
| 397 |
|
|
//---------------------- calculate beta mean ----------------- |
| 398 |
|
|
|
| 399 |
|
|
sw=0.; |
| 400 |
|
|
sxw=0.; |
| 401 |
|
|
beta_mean_tof=100.; |
| 402 |
|
|
|
| 403 |
|
|
for (Int_t jj=0; jj<4;jj++){ |
| 404 |
|
|
if ((beta1[jj]>0.1) && (beta1[jj]<1.5)) { |
| 405 |
|
|
w_i=1./(0.13*0.13); |
| 406 |
|
|
sxw=sxw + beta1[jj]*w_i ; |
| 407 |
|
|
sw =sw + w_i ; |
| 408 |
|
|
} |
| 409 |
|
|
} |
| 410 |
|
|
|
| 411 |
|
|
if (sw>0) beta_mean_tof=sxw/sw; |
| 412 |
|
|
|
| 413 |
|
|
} // if tof11_i > -1 && ...... beta calculation |
| 414 |
|
|
|
| 415 |
|
|
|
| 416 |
|
|
Float_t beta_help = beta_mean_tof ; // pow(beta_mean_tof,1.0) gave best results |
| 417 |
|
|
|
| 418 |
|
|
//----------------------- Select helium -------------------------- |
| 419 |
|
|
|
| 420 |
|
|
Int_t icount=0; |
| 421 |
|
|
|
| 422 |
|
|
for (jj=0; jj<24; jj++){ |
| 423 |
|
|
a1 = adca[2*jj]*cos(theta); |
| 424 |
|
|
a2 = adca[2*jj+1]*cos(theta); |
| 425 |
|
|
|
| 426 |
|
|
xhelp = 100000.; |
| 427 |
|
|
if ((a1 < 3000) && (a2 < 3000)) xhelp = sqrt(a1*a2); // geometric mean |
| 428 |
|
|
// if geometric mean multiplied by beta_help is inside helium limits, increase counter |
| 429 |
|
|
if ((beta_mean_tof>0.6) && (beta_mean_tof<1.1) && |
| 430 |
|
|
((beta_help*xhelp)>A_l[jj]) && ((beta_help*xhelp)<A_h[jj])) icount++ ; |
| 431 |
|
|
} |
| 432 |
|
|
|
| 433 |
|
|
Int_t iz=0; |
| 434 |
|
|
// if (icount > 3) iz=2; // if more than three paddles see helium, then set Z=2 |
| 435 |
|
|
if (icount > 4) iz=2; |
| 436 |
|
|
|
| 437 |
|
|
//---------------------- Z=2 fill histograms ----------------------------- |
| 438 |
|
|
|
| 439 |
|
|
if (iz==2) { |
| 440 |
|
|
|
| 441 |
|
|
heevent++; |
| 442 |
|
|
for (jj=0; jj<48; jj++) adche[jj]->Fill(adca[jj]); |
| 443 |
|
|
|
| 444 |
|
|
} // iz0==2 |
| 445 |
|
|
|
| 446 |
|
|
|
| 447 |
|
|
//===================== end beta and helium part =========================== |
| 448 |
|
|
|
| 449 |
|
|
} // i < nevents |
| 450 |
|
|
|
| 451 |
|
|
|
| 452 |
campana |
1.1 |
float *X = new float[48]; |
| 453 |
|
|
float *means = new float[48]; |
| 454 |
|
|
float *entries = new float[48]; |
| 455 |
|
|
int *entriestdc = new int[48]; |
| 456 |
|
|
int *entriesadc = new int[48]; |
| 457 |
campana |
1.3 |
|
| 458 |
campana |
1.1 |
const char *saveas = format; |
| 459 |
|
|
|
| 460 |
campana |
1.3 |
int i=0; |
| 461 |
campana |
1.1 |
|
| 462 |
|
|
gStyle->SetStatW(0.4); |
| 463 |
|
|
gStyle->SetStatH(0.4); |
| 464 |
|
|
gStyle->SetOptStat("nmri"); |
| 465 |
|
|
gStyle->SetTitleH(0.10); |
| 466 |
|
|
gStyle->SetTitleW(0.96); |
| 467 |
|
|
|
| 468 |
|
|
TCanvas *SCanvas = new TCanvas("SCanvas","SCanvas", 1280, 1024); |
| 469 |
|
|
SCanvas->Divide(4,2); |
| 470 |
campana |
1.3 |
|
| 471 |
campana |
1.1 |
j = 0; |
| 472 |
|
|
while (j < 12){ |
| 473 |
|
|
k = 0; |
| 474 |
|
|
z = 0; |
| 475 |
|
|
if (gROOT->IsBatch()) { |
| 476 |
|
|
SCanvas = new TCanvas("SCanvas","SCanvas", 1280, 1024); |
| 477 |
|
|
SCanvas->Divide(4,2); |
| 478 |
|
|
} else { |
| 479 |
|
|
if (j > 0) SCanvas->DrawClone(); |
| 480 |
|
|
} |
| 481 |
|
|
|
| 482 |
|
|
|
| 483 |
|
|
while(k < 4){ |
| 484 |
|
|
if (k > 1) z = 2; |
| 485 |
|
|
i = j*4 + k; |
| 486 |
|
|
X[i] = i; |
| 487 |
|
|
|
| 488 |
|
|
SCanvas->cd(k+3+z); |
| 489 |
campana |
1.3 |
htdc[i] = (TH1F*)hhtdc->At(i); |
| 490 |
|
|
entriestdc[i] = (Int_t)htdc[i]->Integral(); |
| 491 |
campana |
1.1 |
sst.str(""); |
| 492 |
|
|
sst << "TDC - " << photoS[i].Data() << " (Nev < 4096 = " << entriestdc[i] << ")"; |
| 493 |
campana |
1.3 |
htdc[i]->SetTitle(sst.str().c_str()); |
| 494 |
|
|
htdc[i]->SetTitleSize(10); |
| 495 |
|
|
htdc[i]->SetAxisRange(690,1510); |
| 496 |
|
|
htdc[i]->DrawCopy(); |
| 497 |
|
|
htdc[i]->ComputeIntegral(); |
| 498 |
|
|
entries[i] = htdc[i]->Integral(); |
| 499 |
campana |
1.1 |
|
| 500 |
|
|
SCanvas->cd(k+1+z); |
| 501 |
campana |
1.3 |
hadc[i] = (TH1F*)hhadc->At(i); |
| 502 |
|
|
entriesadc[i] = (Int_t)hadc[i]->Integral(); |
| 503 |
campana |
1.1 |
sst.str(""); |
| 504 |
|
|
sst << "ADC - " << photoS[i].Data() << " (Nev < 4096 = " << entriesadc[i] << ")"; |
| 505 |
campana |
1.3 |
hadc[i]->SetTitle(sst.str().c_str()); |
| 506 |
|
|
hadc[i]->SetAxisRange(-10,710); |
| 507 |
|
|
hadc[i]->DrawCopy(); |
| 508 |
|
|
means[i] = hadc[i]->GetMean(); |
| 509 |
campana |
1.1 |
|
| 510 |
|
|
k++; |
| 511 |
|
|
} |
| 512 |
campana |
1.3 |
|
| 513 |
|
|
|
| 514 |
campana |
1.1 |
if ( !strcmp(saveas,"ps") ) { |
| 515 |
|
|
sst.str(""); |
| 516 |
|
|
sst << outDirectory.Data() << filename.Data() << "TOFScan.ps("; |
| 517 |
|
|
SCanvas->Print(sst.str().c_str()); |
| 518 |
|
|
} else { |
| 519 |
|
|
sst.str(""); |
| 520 |
|
|
sst << outDirectory.Data() << filename.Data() << "TOFScan" << j+1 << "." << saveas; |
| 521 |
|
|
SCanvas->SaveAs(sst.str().c_str()); |
| 522 |
|
|
|
| 523 |
|
|
} |
| 524 |
|
|
j++; |
| 525 |
|
|
} |
| 526 |
campana |
1.3 |
|
| 527 |
campana |
1.1 |
if (gROOT->IsBatch()) SCanvas->Close(); |
| 528 |
|
|
|
| 529 |
|
|
/* |
| 530 |
|
|
* This Canvas will represent a summary of the performances for TOF TDC/ADC channels |
| 531 |
|
|
*/ |
| 532 |
pam-de |
1.4 |
// TCanvas *performanceCanvas = new TCanvas("performanceCanvas","performanceCanvas", 1280, 1024); |
| 533 |
|
|
TCanvas *performanceCanvas = new TCanvas("performanceCanvas","performanceCanvas", 1024, 1280); |
| 534 |
|
|
performanceCanvas->Divide(1,3); |
| 535 |
campana |
1.1 |
|
| 536 |
|
|
gStyle->SetTitleW(.9); |
| 537 |
|
|
|
| 538 |
|
|
performanceCanvas->cd(1); |
| 539 |
|
|
TGraph *adcMeans = new TGraph(48, X, means); |
| 540 |
|
|
sst.str(""); |
| 541 |
|
|
sst << "ADCMean" << " - Data in " << base.Data() << " - Nevents in the run = " << nevents; |
| 542 |
|
|
adcMeans->SetTitle(sst.str().c_str()); |
| 543 |
campana |
1.2 |
adcMeans->SetFillColor(35); |
| 544 |
campana |
1.1 |
adcMeans->GetXaxis()->SetTitle("Photomultipliers"); |
| 545 |
|
|
adcMeans->GetXaxis()->CenterTitle(); |
| 546 |
|
|
adcMeans->GetXaxis()->SetLimits(-0.5, 47.5); |
| 547 |
|
|
adcMeans->GetYaxis()->SetTitle("ADCMean"); |
| 548 |
|
|
adcMeans->GetYaxis()->CenterTitle(); |
| 549 |
|
|
adcMeans->Draw("AB"); |
| 550 |
|
|
|
| 551 |
|
|
performanceCanvas->cd(2); |
| 552 |
|
|
TGraph *tdcEntries = new TGraph(48, X, entries); |
| 553 |
|
|
sst.str(""); |
| 554 |
|
|
sst << "TDCEntries" << " - Data in " << base.Data() << " - Nevents in the run = " << nevents; |
| 555 |
|
|
tdcEntries->SetTitle(sst.str().c_str()); |
| 556 |
campana |
1.2 |
tdcEntries->SetFillColor(35); |
| 557 |
campana |
1.1 |
tdcEntries->GetXaxis()->SetTitle("Photomultipliers"); |
| 558 |
|
|
tdcEntries->GetXaxis()->CenterTitle(); |
| 559 |
|
|
tdcEntries->GetXaxis()->SetLimits(-0.5, 47.5); |
| 560 |
|
|
tdcEntries->GetYaxis()->SetTitle("TDCIntegral"); |
| 561 |
|
|
tdcEntries->GetYaxis()->CenterTitle(); |
| 562 |
|
|
tdcEntries->Draw("AB"); |
| 563 |
pam-de |
1.4 |
|
| 564 |
|
|
//--------- new part PMT gain check ----------------------------- |
| 565 |
|
|
|
| 566 |
|
|
performanceCanvas->cd(3); |
| 567 |
|
|
|
| 568 |
|
|
Float_t xc[48],xmean1[48],xmeana[48]; |
| 569 |
|
|
Float_t xmean_arr[12][48]; |
| 570 |
|
|
|
| 571 |
|
|
// xmean values from 2-3 april 2007 |
| 572 |
|
|
|
| 573 |
|
|
char date_info[]="Reference Data: apr-2007"; |
| 574 |
|
|
|
| 575 |
|
|
Float_t xmean[48] = { |
| 576 |
|
|
491.609,509.241,400.786,530.122,699.674,555.747,521.04,486.363, |
| 577 |
|
|
470.173,227.752,611.038,455.889,553.601,520.54,403.527,382.099, |
| 578 |
|
|
349.697,365.113,447.653,377.667,517.815,572.932,338.501,436.681, |
| 579 |
|
|
485.696,450.491,395.375,329.631,751.258,626.681,385.561,578.476, |
| 580 |
|
|
374.454,356.733,641.888,562.767,582.849,521.748,527.043,505.89, |
| 581 |
|
|
489.828,628.408,532.924,506.511,482.872,532.236,554.554,498.849 }; |
| 582 |
|
|
|
| 583 |
|
|
// new 01-oct-2007 |
| 584 |
|
|
int channelmap[] = {0,7,3,6,2,8,1,5,3,7,3,6,1,7,2,10, |
| 585 |
|
|
10,10,10,5,0,7,0,5,0,6,1,5, |
| 586 |
|
|
2,8,3,8,2,6,1,8, |
| 587 |
|
|
11,9,11,11,9,11,4,4,4,9,9,4}; |
| 588 |
|
|
|
| 589 |
|
|
|
| 590 |
|
|
int colormap[] = {46,2,29,4,5,6,7,8,9,11,28,34}; |
| 591 |
|
|
//int colormap[] = {417,400,632,617,603,600,434,419,591,625,403,424}; |
| 592 |
|
|
|
| 593 |
|
|
|
| 594 |
|
|
for (Int_t j=0; j<48; j++) xmeana[j]=0.; |
| 595 |
|
|
for (Int_t j=0; j<24; j++) xmeana[2*j]=xmean[2*j]; |
| 596 |
|
|
|
| 597 |
|
|
for (Int_t i=0; i<12; i++) { |
| 598 |
|
|
for (Int_t j=0; j<48; j++) { |
| 599 |
|
|
xmean_arr[i][j]=0.; |
| 600 |
|
|
} |
| 601 |
|
|
} |
| 602 |
|
|
|
| 603 |
|
|
for (Int_t j=0; j<48; j++) { |
| 604 |
|
|
Int_t ichan = channelmap[j]; |
| 605 |
|
|
xmean_arr[ichan][j]=xmean[j]; |
| 606 |
|
|
} |
| 607 |
|
|
|
| 608 |
|
|
// get results from ADC histogram |
| 609 |
|
|
for (Int_t j=0; j<48; j++) { |
| 610 |
|
|
xc[j]=j; |
| 611 |
|
|
xmean1[j]=adche[j]->GetMean(); |
| 612 |
|
|
} |
| 613 |
|
|
|
| 614 |
|
|
|
| 615 |
|
|
gStyle->SetTitleW(.5); |
| 616 |
|
|
gStyle->SetTitleH(.05); |
| 617 |
|
|
|
| 618 |
|
|
TH2F *hr = new TH2F("frame","2-Dim",2,-0.5,47.5,2,-300.,100.); |
| 619 |
|
|
hr->SetStats(kFALSE); |
| 620 |
|
|
hr->GetXaxis()->CenterTitle(); |
| 621 |
|
|
hr->GetXaxis()->SetTitle("Photomultipliers"); |
| 622 |
|
|
hr->GetYaxis()->CenterTitle(); |
| 623 |
|
|
hr->GetYaxis()->SetTitle("Mean ADC Difference"); |
| 624 |
|
|
hr->SetTitle("Difference between Reference and Actual Values"); |
| 625 |
|
|
hr->Draw(); |
| 626 |
|
|
|
| 627 |
|
|
Int_t npoint=48; |
| 628 |
|
|
|
| 629 |
|
|
for (Int_t j=0; j<12; j++) { |
| 630 |
|
|
for (Int_t i=0; i<48; i++) xmeana[i] = 0.; |
| 631 |
|
|
for (Int_t i=0; i<48; i++) { |
| 632 |
|
|
if (xmean_arr[j][i] != 0) xmeana[i] = xmean1[i] - xmean_arr[j][i]; |
| 633 |
|
|
} |
| 634 |
|
|
|
| 635 |
|
|
|
| 636 |
|
|
TGraph *graph1 = new TGraph(npoint,xc,xmeana); |
| 637 |
|
|
graph1->SetFillColor(colormap[j]); |
| 638 |
|
|
graph1->GetXaxis()->SetLimits(-0.5, 47.5); |
| 639 |
|
|
graph1->Draw("BP"); |
| 640 |
|
|
} |
| 641 |
|
|
|
| 642 |
|
|
Float_t tp[10]; |
| 643 |
|
|
tp[0] = 15.5; |
| 644 |
|
|
tp[1] = 27.5; |
| 645 |
|
|
tp[2] = 31.5; |
| 646 |
|
|
tp[3] = 35.5; |
| 647 |
|
|
tp[4] = 41.5; |
| 648 |
|
|
|
| 649 |
|
|
for (Int_t ii=0; ii<5; ii++) { |
| 650 |
|
|
TLine *l1=new TLine(tp[ii],-300,tp[ii],100); |
| 651 |
|
|
l1->SetLineColor(38); |
| 652 |
|
|
l1->Draw("same"); |
| 653 |
|
|
} |
| 654 |
|
|
|
| 655 |
|
|
for (Int_t j=0; j<12; j++) { |
| 656 |
|
|
sprintf(htitle, "HV_%d",j); |
| 657 |
|
|
TText *text1 = new TText(0+j*4,80,htitle); |
| 658 |
|
|
text1->SetTextColor(colormap[j]); |
| 659 |
|
|
//text1->SetTextSize(0.03); |
| 660 |
|
|
text1->SetTextSize(0.05); |
| 661 |
|
|
text1->Draw(); |
| 662 |
|
|
} |
| 663 |
|
|
|
| 664 |
|
|
|
| 665 |
|
|
TText *text1 = new TText(0,-185,date_info); |
| 666 |
|
|
text1->SetTextColor(kBlack); |
| 667 |
|
|
text1->SetTextSize(0.023); |
| 668 |
|
|
text1->Draw(); |
| 669 |
|
|
|
| 670 |
|
|
|
| 671 |
|
|
sprintf(htitle, "Helium Events: %d",heevent); |
| 672 |
|
|
TText *text2 = new TText(20,-185,htitle); |
| 673 |
|
|
text2->SetTextColor(kBlack); |
| 674 |
|
|
text2->SetTextSize(0.023); |
| 675 |
|
|
text2->Draw(); |
| 676 |
|
|
|
| 677 |
|
|
|
| 678 |
|
|
for (Int_t i=0; i<6; i++) { |
| 679 |
|
|
for (Int_t j=0; j<8; j++) { |
| 680 |
|
|
Int_t ihelp = i*8+j; |
| 681 |
|
|
sprintf(htitle, "%d: %.0f/%.0f",(ihelp+1),xmean[ihelp],xmean1[ihelp]); |
| 682 |
|
|
TText *text1 = new TText(0+j*6,-200-i*15,htitle); |
| 683 |
|
|
text1->SetTextColor(kBlack); |
| 684 |
|
|
text1->SetTextSize(0.023); |
| 685 |
|
|
text1->Draw(); |
| 686 |
|
|
} |
| 687 |
|
|
} |
| 688 |
|
|
|
| 689 |
|
|
//-------- end new part ------------------------- |
| 690 |
|
|
|
| 691 |
|
|
|
| 692 |
campana |
1.1 |
//------print the ps |
| 693 |
|
|
|
| 694 |
|
|
if ( !strcmp(saveas,"ps") ) { |
| 695 |
|
|
sst.str(""); |
| 696 |
|
|
sst << outDirectory.Data() << filename.Data() << "TOFScan.ps)"; |
| 697 |
|
|
performanceCanvas->Print(sst.str().c_str()); |
| 698 |
|
|
|
| 699 |
|
|
} else { |
| 700 |
|
|
sst.str(""); |
| 701 |
|
|
sst << outDirectory.Data() << filename.Data() << "TOFScan13." << saveas; |
| 702 |
|
|
performanceCanvas->SaveAs(sst.str().c_str()); |
| 703 |
|
|
} |
| 704 |
|
|
if (gROOT->IsBatch()) { |
| 705 |
|
|
SCanvas->Close(); |
| 706 |
|
|
performanceCanvas->Close(); |
| 707 |
|
|
} |
| 708 |
|
|
|
| 709 |
pam-de |
1.4 |
|
| 710 |
|
|
|
| 711 |
campana |
1.1 |
} |
| 712 |
|
|
|
| 713 |
|
|
int main(int argc, char* argv[]){ |
| 714 |
|
|
TString path; |
| 715 |
|
|
TString outDir ="./"; |
| 716 |
|
|
TString format ="ps"; |
| 717 |
|
|
|
| 718 |
|
|
if (argc < 2){ |
| 719 |
|
|
printf("You have to insert at least the file to analyze \n"); |
| 720 |
|
|
printf("Try '--help' for more information. \n"); |
| 721 |
|
|
exit(1); |
| 722 |
|
|
} |
| 723 |
|
|
|
| 724 |
|
|
if (!strcmp(argv[1], "--help")){ |
| 725 |
|
|
printf( "Usage: TofScan FILE [OPTION] \n"); |
| 726 |
|
|
printf( "\t --help Print this help and exit \n"); |
| 727 |
|
|
printf( "\t -outDir[path] Path where to put the output [default ./] \n"); |
| 728 |
|
|
printf( "\t -format[ps] Format for output files [default 'ps'] \n"); |
| 729 |
|
|
exit(1); |
| 730 |
|
|
} |
| 731 |
|
|
|
| 732 |
|
|
|
| 733 |
|
|
path=argv[1]; |
| 734 |
|
|
|
| 735 |
|
|
for (int i = 2; i < argc; i++){ |
| 736 |
|
|
|
| 737 |
|
|
if (!strcmp(argv[i], "-outDir")){ |
| 738 |
|
|
if (++i >= argc){ |
| 739 |
|
|
printf( "-outDir needs arguments. \n"); |
| 740 |
|
|
printf( "Try '--help' for more information. \n"); |
| 741 |
|
|
exit(1); |
| 742 |
|
|
} |
| 743 |
|
|
else{ |
| 744 |
|
|
outDir = argv[i]; |
| 745 |
|
|
continue; |
| 746 |
|
|
} |
| 747 |
|
|
} |
| 748 |
|
|
|
| 749 |
|
|
|
| 750 |
|
|
|
| 751 |
|
|
if (!strcmp(argv[i], "-format")){ |
| 752 |
|
|
if (++i >= argc){ |
| 753 |
|
|
printf( "-format needs arguments. \n"); |
| 754 |
|
|
printf( "Try '--help' for more information. \n"); |
| 755 |
|
|
exit(1); |
| 756 |
|
|
} |
| 757 |
|
|
else{ |
| 758 |
|
|
format = argv[i]; |
| 759 |
|
|
continue; |
| 760 |
|
|
} |
| 761 |
|
|
} |
| 762 |
|
|
} |
| 763 |
|
|
|
| 764 |
|
|
TofScan(argv[1], outDir, format); |
| 765 |
|
|
|
| 766 |
|
|
} |
| 767 |
pam-de |
1.4 |
|