Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
#include <cstdlib>
#include "fstream"
#include "TCsI.h"
#include "TCsIData.h"
#include <TCutG.h>
#include <iostream>
#include "stdio.h"
#include "string.h"
#include "TFile.h"
ClassImp(TCsI)
TCsI::TCsI(bool bspec)
{
// Default constructor
fCsIData = new TCsIData();
BoolSpec=bspec;
GoodCoincET=GoodCoincEPI=GoodCoincTPI=BadCoincET=BadCoincEPI=BadCoincTPI=0;
PrevTSlocal=duplicatedEventC=prevBoard=prevChannel=tag=prevQ=prevQ2=0;
LUTBool=false;
CutLoaded=false;
PrevTS=0;
}
TCsI::~TCsI()
{
delete fCsIData;
}
bool TCsI::Clear()
{
fCsIData->Clear();
return true;
}
bool TCsI::InitCal()
{
return true;
}
bool TCsI::SpectraConstructor()
{
char title[50];
if(BoolSpec){
printf("\033[35mDiamant Info : Start Spectra constructors\033[m \n");
for(int k=0 ; k<50 ; k++){
sprintf(title,"Diamant_Energy%d",k);
fMyHistoCsIE[k]= new TH1F(title,title,1024,0,16384*2);
HListCsI.Add(fMyHistoCsIE[k]);
sprintf(title,"Diamant_ShortTop%d",k);
fMyHistoCsIT[k]= new TH1F(title,title,1024,0,16384*2);
HListCsI.Add(fMyHistoCsIT[k]);
sprintf(title,"Diamant_PID%d",k);
fMyHistoCsIPI[k]= new TH1F(title,title,512,0,0.9);
HListCsI.Add(fMyHistoCsIPI[k]);
sprintf(title,"Diamant_EvsPID_%d",k);
fMyHistoCsIE_PI[k]= new TH2F(title,title,1024,0,16384*2,512,0,0.9);
HListCsI.Add(fMyHistoCsIE_PI[k]);
}
TimeStampDiff= new TH1F("TimeStampDiffTCsI","TimeStampDiffTCsI",4000,-1000,3000);
fMyHistoCsIPattE2d = new TH2F ("Diamant_Pattern_Energy_2d","Diamant Pattern for Energy",90,0,90,512,0,16384*2);
fMyHistoCsIPattT2d = new TH2F ("Diamant_Pattern_ShortTop_2d","Diamant Pattern for ShortTop",90,0,90,512,0,16384*2);
fMyHistoCsIPattPI2d = new TH2F ("Diamant_Pattern_PID_2d","Diamant Pattern for PID",90,0,90,512,0,16384*2);
HListCsI.Add(TimeStampDiff);
HListCsI.Add(fMyHistoCsIPattE2d);
HListCsI.Add(fMyHistoCsIPattT2d);
HListCsI.Add(fMyHistoCsIPattPI2d);
fMyHistoCsIPattE = new TH1F ("CsI_Pattern_E","CsI_Pattern_E",90,0,90);
fMyHistoCsIPattT = new TH1F ("CsI_Pattern_T","CsI_Pattern_T",90,0,90);
fMyHistoCsIPattPI = new TH1F ("CsI_Pattern_PI","CsI_Pattern_PI",90,0,90);
HListCsI.Add(fMyHistoCsIPattE);
HListCsI.Add(fMyHistoCsIPattT);
HListCsI.Add(fMyHistoCsIPattPI);
fMyHistoCsIEmult=new TH1F("CsI_E_Mult_perEvent","CsI_E_Mult_perEvent",90,0,90);
fMyHistoCsITmult=new TH1F("CsI_T_Mult_perEvent","CsI_T_Mult_perEvent",90,0,90);
fMyHistoCsIPImult=new TH1F("CsI_PI_Mult_perEvent","CsI_PI_Mult_perEvent",90,0,90);
HListCsI.Add(fMyHistoCsIEmult);
HListCsI.Add(fMyHistoCsITmult);
HListCsI.Add(fMyHistoCsIPImult);
fMyHistoCsIDataCheckET=new TH1F("CsIDataCheckET","CsIDataCheckET",100,0,100);
fMyHistoCsIDataCheckEPI=new TH1F("CsIDataCheckEPI","CsIDataCheckEPI",100,0,100);
fMyHistoCsIDataCheckTPI=new TH1F("CsIDataCheckTPI","CsIDataCheckTPI",100,0,100);
HListCsI.Add(fMyHistoCsIDataCheckET);
HListCsI.Add(fMyHistoCsIDataCheckEPI);
HListCsI.Add(fMyHistoCsIDataCheckTPI);
printf("\033[35m ----> Done \033[m \n");
return true;
}
else{return false;}
}
bool TCsI::ReadCal()
{
return true;
}
double TCsI::Cal(UShort_t en, float offset, float gain, float gain2){
double enc;
enc = (double)en+gRandom->Uniform(1.0)-.5;
enc = enc*enc*gain2+enc*gain+offset;
return enc;
}
double TCsI::CalI(int en, float offset, float gain, float gain2){
double enc;
enc = (double)en+gRandom->Uniform(1.0)-.5;
enc = enc*enc*gain2+enc*gain+offset;
return enc;
}
bool TCsI::Init(DataParameters *params)
{
bool status = false;
Int_t channel;
TString schaine;
TObjArray* toks=0;
Char_t label[30];
Int_t nbParams = params->GetNbParameters();
for (Int_t index = 0; index < nbParams; index++) {
Int_t lbl = params->GetLabel(index);
strcpy(label,params->GetParNameFromIndex(index));
string labels=params->GetParNameFromIndex(index);
schaine.Form("%s",label);
// cout << index << " " << lbl << " " << label << endl;
if (schaine.BeginsWith("CsI")){
if(schaine.Contains("Energy")||schaine.Contains("ENERGY")) {
fLabelMap[lbl] = labels;
fTypeMap[lbl] = CsI_E;
schaine.ReplaceAll("CsI","");
toks = schaine.Tokenize("_");
channel = ((TObjString* )toks->At(0))->GetString().Atoi();
fParameterMap[lbl] = channel;
delete toks;
status = true;
}
else if(schaine.Contains("Time")||schaine.Contains("TIME")){
fLabelMap[lbl] = labels;
fTypeMap[lbl] = CsI_T;
schaine.ReplaceAll("CsI","");
toks = schaine.Tokenize("_");
channel = ((TObjString* )toks->At(0))->GetString().Atoi();
fParameterMap[lbl] = channel;
delete toks;
status = true;
}
else if(schaine.Contains("PI")){
fLabelMap[lbl] = labels;
fTypeMap[lbl] = CsI_PI;
schaine.ReplaceAll("CsI","");
toks = schaine.Tokenize("_");
channel = ((TObjString* )toks->At(0))->GetString().Atoi();
fParameterMap[lbl] = channel;
delete toks;
status = true;
}
else {printf("\033[31m Problem with Diamant Label \033[m \n");}
}//End if CsI
}
return status;
}
bool TCsI::InitNumexo2(Char_t *fileNumexo2){
LUTBool=false;
TString schainetrack;
TObjArray* toks=0;
Int_t board,Celloffset;
char stop[2];
for(Int_t i= 0 ; i<255;i++){Current_Numexo2_cfg_Board[i]=-1;}
ifstream inf_f(fileNumexo2);
if(inf_f.good()==false) {
printf("\033[31m Error Diamant:: Not a valid Look Up Table=> I complain here \033[m \n");
//gets(stop);
}
else{
LUTBool=true;
while (inf_f.good()){
schainetrack.ReadLine(inf_f);
if(schainetrack.BeginsWith("//")){continue;}
else if(schainetrack.BeginsWith("END")){break;}
else {
toks = schainetrack.Tokenize(" ");
board = ((TObjString* )toks->At(0))->GetString().Atoi();
Celloffset= ((TObjString* )toks->At(1))->GetString().Atoi();
Current_Numexo2_cfg_Board[board]=Celloffset;
delete toks;
}
}
}
inf_f.close();
cout<<"=>Look Up Table Numexo2 DIAMANT read"<<endl;
return true;
}
bool TCsI::IsMFMDiamant(MFMDiamantFrame *frame)
{
bool result = false;
int CristalId, MapFinger, Board ;
double lCsI_ZCO;
bool DuplicatedEvent=false;
bool debug = false;
Board=CristalId=MapFinger=-10;
if(LUTBool==false){
printf("\033[31m Error in TCsI::IsMFMDiamant => The Look Up Table is not known: I won't be able to unpack the event \033[m \n");
}
else{
CristalId=frame->GetTGCristalId(); //return cell ID
Board=frame->GetBoardId();
if(debug)cerr<<"GetTGCristalId() "<< frame->GetTGCristalId() <<endl;
if(debug)cerr<<"GetBoardId() "<<frame->GetBoardId() <<endl;
//Board=(frame->DiaGetCristalId()>>5) &0x07ff;
MapFinger=CristalId+Current_Numexo2_cfg_Board[Board];
//cerr<<MapFinger<<" "<<frame->GetTimeStamp()<< " "<< frame->GetEnergy()/512.<< endl;
if(CristalId>=0&&Current_Numexo2_cfg_Board[Board]>=0){
result=true;
}
else {
printf("\033[31m Error in TCsI::IsMFMDiamant => This IP (%d) is not known from the Look Up Table \033[m \n",Board);
result=false;
}
}
if(Board==prevBoard&&CristalId==prevChannel&&frame->GetTimeStamp()==PrevTSlocal&&prevQ==frame->GetEnergy()){
//cerr<<"Duplicated evt number :: Prev = "<<prevEvtNumber<<" Current = "<<frame->GetEventNumber()<<endl;
DuplicatedEvent=true;
duplicatedEventC++;
}
if(frame->GetTimeStamp()==0)cerr<<"TCsI :: MapFinger : CristalId : Board = "<<MapFinger<<" : " <<CristalId<<" : "<<Board<<endl;
if(result&&DuplicatedEvent==false&&frame->GetEnergy()>0){
lCsI_ZCO=1-frame->GetTop()*1./frame->GetEnergy();
fCsIData->SetCsIEDetectorNbr(MapFinger);
fCsIData->SetCsITDetectorNbr(MapFinger);
fCsIData->SetCsIPIDetectorNbr(MapFinger);
fCsIData->SetCsIEnergy(frame->GetEnergy());
fCsIData->SetCsIPI(lCsI_ZCO);
fCsIData->SetCsITime(frame->GetTop());
fCsIData->SetfTimeStamps(frame->GetTimeStamp(),MapFinger);
if(BoolSpec)fMyHistoCsIE[MapFinger]->Fill(frame->GetEnergy()/512.);
if(BoolSpec)fMyHistoCsIT[MapFinger]->Fill(frame->GetTop());
if(BoolSpec)fMyHistoCsIPI[MapFinger]->Fill(lCsI_ZCO);
if(BoolSpec)fMyHistoCsIE_PI[MapFinger]->Fill(frame->GetEnergy()/512.,lCsI_ZCO);
if(BoolSpec)fMyHistoCsIPattE2d->Fill(MapFinger,frame->GetEnergy()/512.);
if(BoolSpec)fMyHistoCsIPattE->Fill(MapFinger);
if(BoolSpec)fMyHistoCsIPattPI2d->Fill(MapFinger,lCsI_ZCO);
if(BoolSpec)fMyHistoCsIPattPI->Fill(MapFinger);
prevBoard=Board;
prevChannel=CristalId;
prevQ=frame->GetEnergy();
PrevTSlocal=frame->GetTimeStamp();
}
if(debug) cerr<<"Exit CsI IsMFM "<<endl;
return result;
}
bool TCsI::Is(UShort_t lbl, Short_t val)
{
bool status = false;
int MapFinger;
switch (fTypeMap[lbl]) {
case CsI_E :{
//cout<< "- ---------< CsI E >------------------!\n";
//cout<<lbl<<"CsI E "<<val <<" | "<<fParameterMap[lbl]<<endl;
MapFinger=fParameterMap[lbl];
fCsIData->SetCsIEDetectorNbr(MapFinger);
fCsIData->SetCsIEnergy(val);
if(BoolSpec)fMyHistoCsIE[MapFinger]->Fill(val);
if(BoolSpec)fMyHistoCsIPattE2d->Fill(MapFinger,val);
if(BoolSpec)fMyHistoCsIPattE->Fill(MapFinger);
status = true;
break;
}
case CsI_T :{
//cout<< "- ---------< CsI T>------------------!\n";
//cout<<lbl<<"CsI T "<<val <<" | "<<fParameterMap[lbl]<<endl;
MapFinger=fParameterMap[lbl];
fCsIData->SetCsITDetectorNbr(MapFinger);
fCsIData->SetCsITime(val);
if(BoolSpec)fMyHistoCsIPattT2d->Fill(MapFinger,val);
if(BoolSpec)fMyHistoCsIPattT->Fill(MapFinger);
status = true;
break;
}
case CsI_PI :{
//cout<< "- ---------< CsI PI>------------------!\n";
//cout<<lbl<<"CsI PI "<<val <<" | "<<fParameterMap[lbl]<<endl;
MapFinger=fParameterMap[lbl];
fCsIData->SetCsIPIDetectorNbr(MapFinger);
fCsIData->SetCsIPI(val);
if(BoolSpec)fMyHistoCsIPI[MapFinger]->Fill(val);
if(BoolSpec)fMyHistoCsIPattPI2d->Fill(MapFinger,val);
if(BoolSpec)fMyHistoCsIPattPI->Fill(MapFinger);
status = true;
break;
}
default:{
//cout<< "TCsI::Is --> not a good label"<<endl;
status = false;
break;
}
} // end of switch
return status;
}
bool TCsI::Treat()
{
bool debug = false;
PID_Index = 0;
alpham = 0;
protonm = 0;
twoprotonm = 0;
chargedm = 0;
chargeParticleDetected = false;
if(CutLoaded){
if(debug)cerr<<"In CsI TCut treat"<<endl;
for(Int_t i = 0 ; i<fCsIData->GetCsIEMult();i++){
for(Int_t j= 0 ; j<fCsIData->GetCsIPIMult();j++){
if((fCsIData->GetCsIEDetectorNbr(i))==(fCsIData->GetCsIPIDetectorNbr(j))){
//-------------------------------------------------------------------------------------------------
//-------------------------------------------testing output----------------------------------------
//-------------------------------------------------------------------------------------------------
/* cout << "detector no: " << fCsIData->GetCsIEDetectorNbr(i) << endl;
cout << "multiplicities :" << i << j << endl;
cout << "energy: " << fCsIData->GetCsIEnergy(i) << endl;
cout << "PID: " << fCsIData->GetCsIPI(j) << endl;
cout << " " << endl;
counter = counter + 1;
cout << counter << endl;*/
//-------------------------------------------------------------------------------------------------
//-------------------------------------------Gating------------------------------------------------
//-------------------------------------------------------------------------------------------------
//---------------------------------------alpha---------------------------------------------------
if ((gcut_AlphaArray[fCsIData->GetCsIEDetectorNbr(i)]->IsInside(fCsIData->GetCsIEnergy(i),fCsIData->GetCsIPI(j))==1))
{
//cout << "KAPUT " << << endl;
alpham = alpham+1;
totalalpha= totalalpha+1;
// cout << "Total alphas: " << totalalpha << endl;
}
//---------------------------------------proton---------------------------------------------------
if ((gcut_ProtonArray[fCsIData->GetCsIEDetectorNbr(i)]->IsInside(fCsIData->GetCsIEnergy(i),fCsIData->GetCsIPI(j))==1))
{
protonm = protonm+1;
totalproton= totalproton+1;
//cout << "Total protons: " << totalproton << endl;
}
//---------------------------------------two proton---------------------------------------------------
if ((gcut_TwoProtonArray[fCsIData->GetCsIEDetectorNbr(i)]->IsInside(fCsIData->GetCsIEnergy(i),fCsIData->GetCsIPI(j))==1))
{
protonm = protonm+2;
totalproton= totalproton+2;
//cout << "Total protons: " << totalproton << endl;
}
//---------------------------------------charged particle---------------------------------------------------
/* if ((gcut_ChargedArray[fCsIData->GetCsIEDetectorNbr(i)]->IsInside(fCsIData->GetCsIEnergy(i),fCsIData->GetCsIPI(j))==1))
{
chargedm = chargedm+1;
totalcharged= totalcharged+1;
// cout << "Total charged: " << totalcharged << endl;
chargeParticleDetected = true;
}*/
}
}
/* for(Int_t j= 0 ; j<fCsIData->GetCsITMult();j++){
if((fCsIData->GetCsIEDetectorNbr(i))==(fCsIData->GetCsITDetectorNbr(j))){
//if(BoolSpec)fMyHistoCsIE_T[fCsIData->GetCsIEDetectorNbr(i)]->Fill(fCsIData->GetCsIEnergy(i),fCsIData->GetCsITime(j));
}
}
*/
}
}
/*
for(Int_t i = 0 ; i<fCsIData->GetCsITMult();i++){
for(Int_t j= 0 ; j<fCsIData->GetCsIPIMult();j++){
if((fCsIData->GetCsITDetectorNbr(i))==(fCsIData->GetCsIPIDetectorNbr(j))){
if(BoolSpec)fMyHistoCsIT_PI[fCsIData->GetCsITDetectorNbr(i)]->Fill(fCsIData->GetCsITime(i),fCsIData->GetCsIPI(j));
}
}
}
*/
if(debug)cout << "In TCsI.cxx Global spectra treat"<< endl;
if(BoolSpec)fMyHistoCsIEmult->Fill(fCsIData->GetCsIEMult());
if(BoolSpec)fMyHistoCsITmult->Fill(fCsIData->GetCsITMult());
if(BoolSpec)fMyHistoCsIPImult->Fill(fCsIData->GetCsIPIMult());
if(fCsIData->GetCsIEMult()==fCsIData->GetCsIPIMult()){GoodCoincEPI++;}
else{BadCoincEPI++;}
if(fCsIData->GetCsIEMult()==fCsIData->GetCsITMult()){GoodCoincET++;}
else{BadCoincET++;}
if(fCsIData->GetCsIPIMult()==fCsIData->GetCsITMult()){GoodCoincTPI++;}
else{BadCoincET++;}
//Limit the number, so that there is no overflow
if(protonm>7)
protonm = 7;
if(alpham>3)
alpham = 3;
PID_Index = protonm*16+alpham*4;
if(PID_Index>0)
chargeParticleDetected = true;
if(debug)cout << "In TCsI.cxx PID_Index = " << PID_Index << endl;
if(debug)cout << "TCsI.cxx Treat Exit = " << endl;
return true;
}
bool TCsI::Counter()
{
printf("\033[35m ********* Diamant Info : Missing Coinc E_Time = %2.3f percent (Average 2009 value [20-50])\033[m \n",BadCoincET*100./(BadCoincET+GoodCoincET));
printf("\033[35m ********* Diamant Info : Missing Coinc E_PID = %2.3f percent (Average 2009 value [10-40])\033[m \n",BadCoincEPI*100./(BadCoincEPI+GoodCoincEPI));
printf("\033[35m ********* Diamant Info : Missing Coinc Time_PID = %2.3f percent (Average 2009 value 0)\033[m \n",BadCoincTPI*100./(BadCoincTPI+GoodCoincTPI));
if(BoolSpec)fMyHistoCsIDataCheckET->Fill(BadCoincET*100./(BadCoincET+GoodCoincET));
if(BoolSpec)fMyHistoCsIDataCheckEPI->Fill(BadCoincEPI*100./(BadCoincEPI+GoodCoincEPI));
if(BoolSpec)fMyHistoCsIDataCheckTPI->Fill(BadCoincTPI*100./(BadCoincTPI+GoodCoincTPI));
return true;
}
bool TCsI::ClearCounter()
{
GoodCoincET=GoodCoincEPI=GoodCoincTPI=BadCoincET=BadCoincEPI=BadCoincTPI=0;
return true;
}
void TCsI::InitBranch(TTree *tree)
{
tree->Branch("CsI", "TCsIData", &fCsIData);
}
int TCsI::getPID_Index() {
return PID_Index;
}
int TCsI::isParticleVeto() {
return chargeParticleDetected;
}
bool TCsI::ReadCut() {
cerr<<""<<endl;
printf("\033[32mInfo:: Reading DIAMANT cuts \033[m \n");
for(int i =0; i<84; i++) {
gcut_ProtonArray[i] = NULL;
gcut_AlphaArray[i] = NULL;
gcut_TwoProtonArray[i] = NULL;
gcut_ChargedArray[i]= NULL;
}
// Reads the cuts for Energy vs PID
for (Int_t nn = 0; nn < 84; nn++) {
sprintf(Cname, "./CutDiamant/diamantCut%d.root", nn);
if (fopen(Cname, "r") != NULL) {
TFile fileCut(Cname, "READ");
gcut_ProtonArray[nn] = (TCutG*) fileCut.Get("proton");
gcut_AlphaArray[nn] = (TCutG*) fileCut.Get("alpha");
gcut_TwoProtonArray[nn] = (TCutG*) fileCut.Get("twoproton");
gcut_ChargedArray[nn]=(TCutG*)fileCut.Get("charged");
fileCut.Close();
printf("%d cut loaded, ", nn);
} else {
cout << "Warning:: could not read cuts for diamant detector number " << nn << ". Use generic cut." << endl;
//Read an alternative Cut for this diamant detector (generic fallback solution)
TFile fileCut("./CutDiamant/diamantCut.root", "READ");
if(fileCut.IsOpen()) {
gcut_ProtonArray[nn] = (TCutG*) fileCut.Get("proton");
gcut_AlphaArray[nn] = (TCutG*) fileCut.Get("alpha");
gcut_TwoProtonArray[nn] = (TCutG*) fileCut.Get("twoproton");
gcut_ChargedArray[nn]=(TCutG*)fileCut.Get("charged");
fileCut.Close();
} else {
cout << "Warning:: Could not read generic cut, Fall back to empty cuts for " << nn << endl;
}
}
}
CutLoaded=true;
return true;
}