00001
00002
00003
00004
00006
00007
00008
00009
00010
00012
00013 #include <TF1.h>
00014 #include <TString.h>
00015 #include <TSystem.h>
00016
00017 #include "FROOT.h"
00018 #include "TFndRun.h"
00019 #include "TFndTofMon.h"
00020
00021 ClassImp(TFndTofMon)
00022
00023
00024 TFndTofMon::TFndTofMon(const TString &fmode,Int_t tof_adc_bins,Double_t tof_adc_min,Double_t tof_adc_max,Int_t tof_tdc_bins,Double_t tof_tdc_min,Double_t tof_tdc_max):
00025 shmflg(),fout(),ftof(),
00026 mtof(),mtof_adc(),mtof_tdc(),
00027 fMustRecoverHistos(kFALSE),
00028 fSharedMemName_Main(),fSharedMemName_Adc(),fSharedMemName_Tdc(),
00029 fSharedFileName_Main(),fSharedFileName_Adc(),fSharedFileName_Tdc(),
00030 tof_mon_adc(),tof_mon_tdc(),tof_mon_adc_tdc(),
00031 tofmult(),tof_i_o_mult(),tofmap(),tofmapadc0(),tofmapadc(),tofmapadce(),tofmapadcp(),
00032 tofmaptdc0(),tofmaptdc(),tofmaptdce(),tofmaptdcp(),tofcorr(),tofmapmt(),
00033 tof_mapadctdc(),tof_adc_tdc(),tofadce(),tofadcp(),tofcrg(),tofadc(),tofzet(),toftdce(),toftdcp(),toftdf(),toftmn(),toftmn_hw(),toftdc(),tof1d(),tof2d()
00034 {
00035
00036 Init();
00037 OpenSharedFiles(fmode);
00038 InitHistos(tof_adc_bins,tof_adc_min,tof_adc_max,tof_tdc_bins,tof_tdc_min,tof_tdc_max);
00039
00040
00041
00042 }
00043
00044
00045 TFndTofMon::TFndTofMon():
00046 shmflg(),fout(),ftof(),
00047 mtof(),mtof_adc(),mtof_tdc(),
00048 fMustRecoverHistos(kFALSE),
00049 fSharedMemName_Main(),fSharedMemName_Adc(),fSharedMemName_Tdc(),
00050 fSharedFileName_Main(),fSharedFileName_Adc(),fSharedFileName_Tdc(),
00051 tof_mon_adc(),tof_mon_tdc(),tof_mon_adc_tdc(),
00052 tofmult(),tof_i_o_mult(),tofmap(),tofmapadc0(),tofmapadc(),tofmapadce(),tofmapadcp(),
00053 tofmaptdc0(),tofmaptdc(),tofmaptdce(),tofmaptdcp(),tofcorr(),tofmapmt(),
00054 tof_mapadctdc(),tof_adc_tdc(),tofadce(),tofadcp(),tofcrg(),tofadc(),tofzet(),toftdce(),toftdcp(),toftdf(),toftmn(),toftmn_hw(),toftdc(),tof1d(),tof2d()
00055 {
00056
00057 Init();
00058
00059 }
00060
00061
00062 TFndTofMon::TFndTofMon(TString *filename):
00063 shmflg(),fout(),ftof(),
00064 mtof(),mtof_adc(),mtof_tdc(),
00065 fMustRecoverHistos(kFALSE),
00066 fSharedMemName_Main(),fSharedMemName_Adc(),fSharedMemName_Tdc(),
00067 fSharedFileName_Main(),fSharedFileName_Adc(),fSharedFileName_Tdc(),
00068 tof_mon_adc(),tof_mon_tdc(),tof_mon_adc_tdc(),
00069 tofmult(),tof_i_o_mult(),tofmap(),tofmapadc0(),tofmapadc(),tofmapadce(),tofmapadcp(),
00070 tofmaptdc0(),tofmaptdc(),tofmaptdce(),tofmaptdcp(),tofcorr(),tofmapmt(),
00071 tof_mapadctdc(),tof_adc_tdc(),tofadce(),tofadcp(),tofcrg(),tofadc(),tofzet(),toftdce(),toftdcp(),toftdf(),toftmn(),toftmn_hw(),toftdc(),tof1d(),tof2d()
00072 {
00073
00074 Init();
00075
00076 mtof = 0;
00077 mtof_adc = 0;
00078 mtof_tdc = 0;
00079 ftof = new TFile(filename->Data());
00080
00081 TString hname;
00082 hname = TString("tofmult");
00083 tofmult = (TH1F *) ftof->Get(hname.Data());
00084 hname = TString("tof_i_o_mult");
00085 tof_i_o_mult = (TH2F *) ftof->Get(hname.Data());
00086 hname = TString("tofcorr0");
00087 tofcorr[0] = (TH2F *) ftof->Get(hname.Data());
00088 hname = TString("tofcorr1");
00089 tofcorr[1] = (TH2F *) ftof->Get(hname.Data());
00090 hname = TString("tof_map");
00091 tofmap = (TH1F *) ftof->Get(hname.Data());
00092 hname = TString("tof_mapadc0");
00093 tofmapadc0 = (TH1F *) ftof->Get(hname.Data());
00094 hname = TString("tof_mapadc");
00095 tofmapadc = (TH1F *) ftof->Get(hname.Data());
00096 hname = TString("tof_mapadcp");
00097 tofmapadcp = (TH1F *) ftof->Get(hname.Data());
00098 hname = TString("tof_mapadce");
00099 tofmapadce = (TH1F *) ftof->Get(hname.Data());
00100 hname = TString("tof_maptdc0");
00101 tofmaptdc0 = (TH1F *) ftof->Get(hname.Data());
00102 hname = TString("tof_maptdc");
00103 tofmaptdc = (TH1F *) ftof->Get(hname.Data());
00104 hname = TString("tof_maptdcp");
00105 tofmaptdcp = (TH1F *) ftof->Get(hname.Data());
00106 hname = TString("tof_maptdce");
00107 tofmaptdce = (TH1F *) ftof->Get(hname.Data());
00108 hname = TString("tof_mapmt");
00109 tofmapmt = (TH1F *) ftof->Get(hname.Data());
00110
00111 for (Int_t idx=0;idx<n_tof_hist;idx++) {
00112 Int_t idx1 = idx;
00113 if(idx>11) idx1 = idx+88;
00114 hname = TString("tof_mapadctdc_");
00115 hname+=idx+1;
00116 tof_mapadctdc[idx] = (TH2F *) ftof->Get(hname.Data());
00117 hname = TString("tof_adc_tdc_");
00118 hname+=idx+1;
00119 tof_adc_tdc[idx] = (TH2F *) ftof->Get(hname.Data());
00120 hname = TString("tof_adcp_");
00121 hname+=idx+1;
00122 tofadcp[idx] = (TH1F *) ftof->Get(hname.Data());
00123 hname = TString("tof_adce_");
00124 hname+=idx+1;
00125 tofadce[idx] = (TH1F *) ftof->Get(hname.Data());
00126 hname = TString("tof_crg_");
00127 hname+=idx+1;
00128 tofcrg[idx] = (TH1F *) ftof->Get(hname.Data());
00129 hname = TString("tof_zet_");
00130 hname+=idx+1;
00131 tofzet[idx] = (TH1F *) ftof->Get(hname.Data());
00132 hname = TString("tof_adc_");
00133 hname+=idx+1;
00134
00135
00136 tofadc[idx] = (TH2F *) ftof->Get(hname.Data());
00137
00138 hname = TString("tof_tdcp");
00139 hname+=idx+1;
00140 toftdcp[idx] = (TH1F *) ftof->Get(hname.Data());
00141 hname = TString("tof_tdce");
00142 hname+=idx+1;
00143 toftdce[idx] = (TH1F *) ftof->Get(hname.Data());
00144 hname = TString("tof_tdf");
00145 hname+=idx+1;
00146 toftdf[idx] = (TH1F *) ftof->Get(hname.Data());
00147 hname = TString("tof_tmn");
00148 hname+=idx+1;
00149 toftmn[idx] = (TH1F *) ftof->Get(hname.Data());
00150 hname = TString("tof_tmn_hw");
00151 hname+=idx+1;
00152 toftmn_hw[idx] = (TH1F *) ftof->Get(hname.Data());
00153 hname = TString("tof_tdc");
00154 hname+=idx+1;
00155
00156 toftdc[idx] = (TH2F *) ftof->Get(hname.Data());
00157 }
00158
00159 tof1d = 0;
00160 tof2d = 0;
00161
00162 }
00163
00164
00165 TFndTofMon::~TFndTofMon() {
00166
00167 delete tof_mon_adc;
00168 delete tof_mon_tdc;
00169 delete tof_mon_adc_tdc;
00170
00171 delete tofmap;
00172 delete tofmapadc;
00173 delete tofmapadc0;
00174 delete tofmapadcp;
00175 delete tofmapadce;
00176 delete tofmaptdc;
00177 delete tofmaptdc0;
00178 delete tofmaptdcp;
00179 delete tofmaptdce;
00180 delete tofmapmt;
00181
00182 for (Int_t ji=0;ji<n_tof_hist;ji++) {
00183 delete tof_mapadctdc[ji];
00184 delete tof_adc_tdc[ji];
00185 delete tofadcp[ji];
00186 delete tofadce[ji];
00187 delete tofcrg[ji];
00188 delete tofzet[ji];
00189 delete tofadc[ji];
00190 delete toftdcp[ji];
00191 delete toftdce[ji];
00192 delete toftdf[ji];
00193 delete toftmn[ji];
00194 delete toftmn_hw[ji];
00195 delete toftdc[ji];
00196 }
00197 delete tof1d;
00198 delete tof2d;
00199
00200
00201 if(! shmflg){
00202 if(ftof) ftof->Close();
00203 delete ftof;
00204 }
00205
00206 if(fout) fout->Close();
00207 delete fout;
00208
00209
00210 if(mtof){ mtof->Close(); mtof = 0; }
00211 else delete mtof;
00212
00213 if(mtof_adc){ mtof_adc->Close(); mtof_adc = 0; }
00214 else delete mtof_adc;
00215
00216 if(mtof_tdc){ mtof_tdc->Close(); mtof_tdc = 0; }
00217 else delete mtof_tdc;
00218
00219 }
00220
00221
00222 void TFndTofMon::Init() {
00223
00224 fSharedMemName_Main = FROOT::ExpandPathName("$FND_SHR/tof_map.map");
00225 fSharedMemName_Adc = FROOT::ExpandPathName("$FND_SHR/tof_adc.map");
00226 fSharedMemName_Tdc = FROOT::ExpandPathName("$FND_SHR/tof_tdc.map");
00227
00228 fSharedFileName_Main = FROOT::ExpandPathName("tof_map.file.map");
00229 fSharedFileName_Adc = FROOT::ExpandPathName("tof_adc.file.map");
00230 fSharedFileName_Tdc = FROOT::ExpandPathName("tof_tdc.file.map");
00231
00232 }
00233
00234
00235 void TFndTofMon::InitHistos(const Int_t &tof_adc_bins,const Double_t &tof_adc_min,const Double_t &tof_adc_max,const Int_t &tof_tdc_bins,const Double_t &tof_tdc_min,const Double_t &tof_tdc_max) {
00236
00237 if(shmflg && ( !mtof || !mtof_adc || !mtof_tdc) ){
00238 Warning("InitHistos","Map-files not available: exiting method");
00239 return;
00240 }
00241
00242 TString hname;
00243 TString htitle;
00244
00245
00246 if(shmflg) mtof->cd();
00247
00248 Float_t low = 0.5;
00249 Float_t high = low+100+n_tof_hist;
00250 hname = "tofmult";
00251 htitle = "Tof multiplicity";
00252 tofmult = (fMustRecoverHistos) ?
00253 ((TH1F*) (mtof->Get(hname))) :
00254 new TH1F(hname,htitle,14,-0.5,13.5);
00255
00256 hname = "tof_i_o_mult";
00257 htitle = "Inner vs Outer Multiplicity";
00258 tof_i_o_mult = (fMustRecoverHistos) ?
00259 ((TH2F*) (mtof->Get(hname))) :
00260 new TH2F(hname,htitle,74,-0.5,73.5,13,-0.5,12.5);
00261
00262 hname = "tofcorr0";
00263 htitle = "D Slab vs Slab Number";
00264 tofcorr[0] = (fMustRecoverHistos) ?
00265 ((TH2F*) (mtof->Get(hname))) :
00266 new TH2F(hname,htitle,12,0.5,12.5,12,0.5,12.5);
00267
00268 hname = "tofcorr1";
00269 htitle = "D1 Slab vs Slab Number";
00270 tofcorr[1] = (fMustRecoverHistos) ?
00271 ((TH2F*) (mtof->Get(hname))) :
00272 new TH2F(hname,htitle,12,0.5,12.5,12,0.5,12.5);
00273
00274 hname = "tof_map";
00275 htitle = "Tof Hit pattern";
00276 tofmap = (fMustRecoverHistos) ?
00277 ((TH1F*) (mtof->Get(hname))) :
00278 new TH1F(hname,htitle,100+n_tof_hist,low,high);
00279
00280
00281 hname = "tof_mapadc0";
00282 htitle = "Tof ADC pattern (p||e != 0)";
00283 tofmapadc0 = (fMustRecoverHistos) ?
00284 ((TH1F*) (mtof->Get(hname))) :
00285 new TH1F(hname,htitle,100+n_tof_hist,low,high);
00286
00287 hname = "tof_mapadc";
00288 htitle = "Tof ADC pattern (p&&e != 0)";
00289 tofmapadc = (fMustRecoverHistos) ?
00290 ((TH1F*) (mtof->Get(hname))) :
00291 new TH1F(hname,htitle,100+n_tof_hist,low,high);
00292
00293 hname = "tof_mapadcp";
00294 htitle = "Tof ADC pattern (p-side)";
00295 tofmapadcp = (fMustRecoverHistos) ?
00296 ((TH1F*) (mtof->Get(hname))) :
00297 new TH1F(hname,htitle,100+n_tof_hist,low,high);
00298
00299 hname = "tof_mapadce";
00300 htitle = "Tof ADC pattern (e-side)";
00301 tofmapadce = (fMustRecoverHistos) ?
00302 ((TH1F*) (mtof->Get(hname))) :
00303 new TH1F(hname,htitle,100+n_tof_hist,low,high);
00304
00305 hname = "tof_maptdc0";
00306 htitle = "Tof TDC pattern (p||e != 0)";
00307 tofmaptdc0 = (fMustRecoverHistos) ?
00308 ((TH1F*) (mtof->Get(hname))) :
00309 new TH1F(hname,htitle,100+n_tof_hist,low,high);
00310
00311 hname = "tof_maptdc";
00312 htitle = "Tof TDC pattern (p&&e != 0)";
00313 tofmaptdc = (fMustRecoverHistos) ?
00314 ((TH1F*) (mtof->Get(hname))) :
00315 new TH1F(hname,htitle,100+n_tof_hist,low,high);
00316
00317 hname = "tof_maptdcp";
00318 htitle = "Tof TDC pattern (p-side)";
00319 tofmaptdcp = (fMustRecoverHistos) ?
00320 ((TH1F*) (mtof->Get(hname))) :
00321 new TH1F(hname,htitle,100+n_tof_hist,low,high);
00322
00323 hname = "tof_maptdce";
00324 htitle = "Tof TDC pattern (e-side)";
00325 tofmaptdce = (fMustRecoverHistos) ?
00326 ((TH1F*) (mtof->Get(hname))) :
00327 new TH1F(hname,htitle,100+n_tof_hist,low,high);
00328
00329
00330 hname = "tof_mapmt";
00331 htitle = "Tof MT pattern";
00332 tofmapmt = (fMustRecoverHistos) ?
00333 ((TH1F*) (mtof->Get(hname))) :
00334 new TH1F(hname,htitle,100+n_tof_hist,low,high);
00335
00336
00337 for (Int_t ji=0;ji<n_tof_hist;ji++) {
00338 Int_t slb = ji+1;
00339 if(ji > 11) slb = ji+89;
00340 hname.Form("tof_mapadctdc_%d",slb);
00341 htitle.Form("ADC p/e vs TDC p/e for slab: %d",slb);
00342 tof_mapadctdc[ji] = (fMustRecoverHistos) ?
00343 ((TH2F*) (mtof->Get(hname))) :
00344 new TH2F(hname,htitle,4,-0.5,3.5,4,-0.5,3.5);
00345
00346 hname.Form("tof_adc_tdc_%d",slb);
00347 htitle.Form("ADC vs TDC for slab: %d",slb);
00348 tof_adc_tdc[ji] = (fMustRecoverHistos) ?
00349 ((TH2F*) (mtof->Get(hname))) :
00350 new TH2F(hname,htitle,tof_tdc_bins,tof_tdc_min,tof_tdc_max,tof_adc_bins,tof_adc_min,tof_adc_max);
00351 }
00352
00354
00355
00356 if(shmflg) mtof_adc->cd();
00357
00358 for (Int_t l=0;l<n_tof_hist;l++) {
00359 Int_t slb = l+1;
00360 if(l > 11) slb = l+89;
00361 hname.Form("tof_adcp_%d",slb);
00362 htitle.Form("p-side ADC for Slab: %d",slb);
00363 tofadcp[l] = (fMustRecoverHistos) ?
00364 ((TH1F*) (mtof_adc->Get(hname))) :
00365 new TH1F(hname,htitle,tof_adc_bins,tof_adc_min,tof_adc_max);
00366 tofadcp[l]->SetLineColor(6);
00367
00368 hname.Form("tof_adce_%d",slb);
00369 htitle.Form("e-side ADC for Slab: %d",slb);
00370 tofadce[l] = (fMustRecoverHistos) ?
00371 ((TH1F*) (mtof_adc->Get(hname))) :
00372 new TH1F(hname,htitle,tof_adc_bins,tof_adc_min,tof_adc_max);
00373 tofadce[l]->SetLineColor(9);
00374
00375 hname.Form("tof_crg_%d",slb);
00376 htitle.Form("sqrt(ADC p-side*e-side) for Slab: %d",slb);
00377 tofcrg[l] = (fMustRecoverHistos) ?
00378 ((TH1F*) (mtof_adc->Get(hname))) :
00379 new TH1F(hname,htitle,tof_adc_bins,tof_adc_min,tof_adc_max);
00380
00381 tofcrg[l]->SetFillColor(9);
00382
00383 hname.Form("tof_zet_%d",slb);
00384 htitle.Form("ADC log(p/e) for Slab: %d",slb);
00385 tofzet[l] = (fMustRecoverHistos) ?
00386 ((TH1F*) (mtof_adc->Get(hname))) :
00387 new TH1F(hname,htitle,101,-20.,20.);
00388 tofzet[l]->SetFillColor(9);
00389
00390 hname.Form("tof_adc_%d",slb);
00391 htitle.Form("ADC p-side vs e-side for Slab: %d",slb);
00392 tofadc[l] = (fMustRecoverHistos) ?
00393 ((TH2F*) (mtof_adc->Get(hname))) :
00394 new TH2F(hname,htitle,tof_adc_bins,tof_adc_min,tof_adc_max,tof_adc_bins,tof_adc_min,tof_adc_max);
00395 tofadc[l]->SetFillColor(8);
00396 }
00397
00398
00399 if(shmflg) mtof_tdc->cd();
00400
00401 for (Int_t k=0;k<n_tof_hist;k++) {
00402 Int_t slb = k+1;
00403 if(k > 11) slb = k+89;
00404 hname.Form("tof_tdcp_%d",slb);
00405 htitle.Form("p-side TDC for Slab: %d",slb);
00406 toftdcp[k] = (fMustRecoverHistos) ?
00407 ((TH1F*) (mtof_tdc->Get(hname))) :
00408 new TH1F(hname,htitle,tof_tdc_bins,tof_tdc_min,tof_tdc_max);
00409 toftdcp[k]->SetLineColor(6);
00410
00411 hname.Form("tof_tdce_%d",slb);
00412 htitle.Form("e-side TDC for Slab: %d",slb);
00413 toftdce[k] = (fMustRecoverHistos) ?
00414 ((TH1F*) (mtof_tdc->Get(hname))) :
00415 new TH1F(hname,htitle,tof_tdc_bins,tof_tdc_min,tof_tdc_max);
00416
00417 toftdce[k]->SetLineColor(9);
00418
00419 hname.Form("tof_tdf_%d",slb);
00420 htitle.Form("TDC p-side - e-side for Slab: %d",slb);
00421 toftdf[k] = (fMustRecoverHistos) ?
00422 ((TH1F*) (mtof_tdc->Get(hname))) :
00423 new TH1F(hname,htitle,100,-1000.,1000.);
00424 toftdf[k]->SetFillColor(9);
00425
00426 hname.Form("tof_tmn_%d",slb);
00427 htitle.Form("TDC SW Mean Time for Slab: %d",slb);
00428 toftmn[k] = (fMustRecoverHistos) ?
00429 ((TH1F*) (mtof_tdc->Get(hname))) :
00430 new TH1F(hname,htitle,tof_tdc_bins,tof_tdc_min,tof_tdc_max);
00431 toftmn[k]->SetFillColor(9);
00432
00433 hname.Form("tof_tmn_hw_%d",slb);
00434 htitle.Form("TDC HW Mean Time for Slab: %d",slb);
00435 toftmn_hw[k] = (fMustRecoverHistos) ?
00436 ((TH1F*) (mtof_tdc->Get(hname))) :
00437 new TH1F(hname,htitle,tof_tdc_bins,tof_tdc_min,tof_tdc_max);
00438 toftmn_hw[k]->SetFillColor(9);
00439
00440 hname.Form("tof_tdc_%d",slb);
00441 htitle.Form("TDC p-side vs e-side for Slab: %d",slb);
00442 toftdc[k] = (fMustRecoverHistos) ?
00443 ((TH2F*) (mtof_tdc->Get(hname))) :
00444 new TH2F(hname,htitle,tof_tdc_bins,tof_tdc_min,tof_tdc_max,tof_tdc_bins,tof_tdc_min,tof_tdc_max);
00445 toftdc[k]->SetFillColor(8);
00446 }
00447
00448 }
00449
00450
00451 void TFndTofMon::OpenSharedFiles(const TString &fmode) {
00452 TString fhist = "_tof.root";
00453
00454 shmflg = fndrun->Onlflg();
00455 cout << "Tof Shm flag is " << shmflg << endl;
00456
00457 TString tofname = (fmode.IsNull())? "ONLM" : fmode;
00458 tofname+=fhist;
00459
00460
00461 ftof = new TFile(tofname.Data(),"RECREATE","Tof Histogram File");
00462 if(shmflg) {
00463 #if defined _FND_ONL_USE_MAP_FILES_
00464 mtof = TMapFile::Create(fSharedMemName_Main,"RECREATE",(Int_t)(1048576*FROOT::K_TofMapSize),"Tof memory mapped file with histograms");
00465 mtof->Print();
00466 #elif defined _FND_ONL_USE_SHARED_FILES_
00467 if(gSystem->AccessPathName(fSharedFileName_Main)){
00468 cout << "Shared file missing: creating it now..." << endl;
00469 mtof = new TFile(fSharedFileName_Main,"RECREATE");
00470 }
00471 else{
00472 cout << "Shared file found: histograms will be recovered..." << endl;
00473 mtof = TFile::Open(fSharedFileName_Main,"UPDATE");
00474 fMustRecoverHistos = kTRUE;
00475
00476 }
00477 #endif
00478 }
00479
00480
00481 if(shmflg) {
00482 #if defined _FND_ONL_USE_MAP_FILES_
00483 mtof_adc = TMapFile::Create(fSharedMemName_Adc,"RECREATE",(Int_t)(1048576*FROOT::K_TofAdcMapSize),"Tof memory mapped file with ADC histograms");
00484 mtof_adc->Print();
00485 #elif defined _FND_ONL_USE_SHARED_FILES_
00486 if( gSystem->AccessPathName(fSharedFileName_Adc) && fMustRecoverHistos == kTRUE){
00487 cout << "Shared file missing: creating it now..." << endl;
00488 mtof_adc = new TFile(fSharedFileName_Adc,"RECREATE");
00489 fMustRecoverHistos = kFALSE;
00490 }
00491 else{
00492 cout << "Shared file found: histograms will be recovered..." << endl;
00493 mtof_adc = TFile::Open(fSharedFileName_Adc,"UPDATE");
00494
00495 }
00496 #endif
00497 }
00498
00499
00500
00501 if(shmflg) {
00502 #if defined _FND_ONL_USE_MAP_FILES_
00503 mtof_tdc = TMapFile::Create(fSharedMemName_Tdc,"RECREATE",(Int_t)(1048576*FROOT::K_TofTdcMapSize),"Tof memory mapped file with TDC histograms");
00504 mtof_tdc->Print();
00505 #elif defined _FND_ONL_USE_SHARED_FILES_
00506 if(gSystem->AccessPathName(fSharedFileName_Tdc) && fMustRecoverHistos == kTRUE ){
00507 cout << "Shared file missing: creating it now..." << endl;
00508 mtof_tdc = new TFile(fSharedFileName_Tdc,"RECREATE");
00509 fMustRecoverHistos = kFALSE;
00510 }
00511 else{
00512 cout << "Shared file found: histograms will be recovered..." << endl;
00513 mtof_tdc = TFile::Open(fSharedFileName_Tdc,"UPDATE");
00514
00515 }
00516 #endif
00517 }
00518
00519 }
00520
00521
00522 void TFndTofMon::Fill() {
00523
00524 TClonesArray *cl = fndrun->GetCurrentHdt()->GetTofHits();
00525 Fill(*cl);
00526 }
00527
00528
00529 void TFndTofMon::Fill(const TClonesArray &TofHits) {
00530
00531 Int_t sladiv = 12;
00532 Int_t nhtof = TofHits.GetEntries();
00533 tofmult->Fill((Float_t) nhtof);
00534
00535 Int_t upp_mult = 0;
00536 Int_t low_mult = 0;
00537 for (Int_t j=0; j<nhtof; j++) {
00538 if(nhtof>84) cout << "TFndTofMon WARNING: TOF number of hits= " << nhtof << " (greater than 84)!!!" << endl;
00539 TFndHTof *htof = (TFndHTof*) TofHits[j];
00540 Float_t slb = htof->GetChannel();
00541 if(slb==0){
00542 Warning("TFndTofMon","slab out of range...skipping hit");
00543 continue;
00544 }
00545 Float_t ap = (Float_t) htof->GetAdcP();
00546 Float_t ae = (Float_t) htof->GetAdcE();
00547 Float_t tp = (Float_t) htof->GetTdcP();
00548 Float_t te = (Float_t) htof->GetTdcE();
00549 Float_t tm = (Float_t) htof->GetMeanTimer();
00550 Float_t crg = TMath::Sqrt(ap*ae);
00551
00552 if(ap <=0 && ae <=0 && tp <=0 && te <=0 && tm <=0) continue;
00553
00554 tofmap->Fill(slb);
00555
00556 if(slb<=sladiv) low_mult++;
00557 else if(slb>sladiv && slb<=172) upp_mult++;
00558
00559
00560 if(ap > 0 || ae > 0) tofmapadc0->Fill(slb);
00561 if(ap > 0 && ae > 0) tofmapadc->Fill(slb);
00562 if(ap > 0) tofmapadcp->Fill(slb);
00563 if(ae > 0) tofmapadce->Fill(slb);
00564
00565 if(tp > 0 || te > 0) tofmaptdc0->Fill(slb);
00566 if(tp > 0 && te > 0) tofmaptdc->Fill(slb);
00567
00568 if(tp > 0) tofmaptdcp->Fill(slb);
00569 if(te > 0) tofmaptdce->Fill(slb);
00570 if(tm > 0) tofmapmt->Fill(slb);
00571
00572 Int_t itdc = TFndHit::E_HIT_NO_CH;
00573 if(tp >0 && te >0) itdc = TFndHit::E_HIT_BOTH_CH;
00574 if(tp <=0 && te >0) itdc = TFndHit::E_HIT_E_CH;
00575 if(tp >0 && te <=0) itdc = TFndHit::E_HIT_P_CH;
00576
00577 Int_t iadc = TFndHit::E_HIT_NO_CH;
00578 if(ap >0 && ae >0) iadc = TFndHit::E_HIT_BOTH_CH;
00579 if(ap <=0 && ae >0) iadc = TFndHit::E_HIT_E_CH;
00580 if(ap >0 && ae <=0) iadc = TFndHit::E_HIT_P_CH;
00581
00582 Int_t sf = (Int_t) slb - 1;
00583 if(slb>100) sf -= 88;
00584 tof_mapadctdc[sf]->Fill(itdc,iadc);
00585 if(tp >=0 && ap >=0) tof_adc_tdc[sf]->Fill(tp,ap);
00586 if(te >=0 && ae >=0) tof_adc_tdc[sf]->Fill(te,ae);
00587
00588 if(ap >=0) tofadcp[sf]->Fill(ap);
00589 if(ae >=0) tofadce[sf]->Fill(ae);
00590
00591 Float_t zet = -100.;
00592 if(ae >=0 && ap >=0){
00593 tofadc[sf]->Fill(ae,ap);
00594 tofcrg[sf]->Fill(crg);
00595 zet = TMath::Log(ap/ae);
00596 tofzet[sf]->Fill(zet);
00597 }
00598
00599
00600 if(tp >=0) toftdcp[sf]->Fill(tp);
00601 if(te >=0) toftdce[sf]->Fill(te);
00602 if(tp >=0 && te >=0){
00603 toftdc[sf]->Fill(te,tp);
00604 toftmn_hw[sf]->Fill(tm);
00605 tm = (tp+te)/2.;
00606 toftmn[sf]->Fill(tm);
00607 toftdf[sf]->Fill(tp-te);
00608 }
00609
00610 }
00611
00612 tof_i_o_mult->Fill((Float_t) upp_mult,(Float_t) low_mult);
00613
00614 }
00615
00616
00617 void TFndTofMon::Update(Bool_t purge) {
00618
00619
00620 #if defined _FND_ONL_USE_MAP_FILES_
00621 if(mtof) mtof->Print();
00622 if( mtof && mtof->IsWritable() ) mtof->Update();
00623 if( mtof_adc) mtof_adc->Print();
00624 if( mtof_adc && mtof_adc->IsWritable() ) mtof_adc->Update();
00625 if( mtof_tdc) mtof_tdc->Print();
00626 if( mtof_tdc && mtof_tdc->IsWritable() ) mtof_tdc->Update();
00627 #elif defined _FND_ONL_USE_SHARED_FILES_
00628 WriteToFile(0,kTRUE);
00629
00630 mtof->cd();
00631 if(purge) mtof->Purge();
00632 mtof->Flush();
00633 mtof_adc->cd();
00634 if(purge) mtof_adc->Purge();
00635 mtof_adc->Flush();
00636 mtof_tdc->cd();
00637 if(purge) mtof_tdc->Purge();
00638 mtof_tdc->Flush();
00639
00640
00641
00642 TString comm_cp = "";
00643 comm_cp.Form("cp ./tof_map.file.map %s",FROOT::ExpandPathName("$FND_SHR/tof_map.file.map").Data());
00644 gSystem->Exec(comm_cp);
00645
00646 comm_cp.Form("cp ./tof_adc.file.map %s",FROOT::ExpandPathName("$FND_SHR/tof_adc.file.map").Data());
00647 gSystem->Exec(comm_cp);
00648
00649 comm_cp.Form("cp ./tof_tdc.file.map %s",FROOT::ExpandPathName("$FND_SHR/tof_tdc.file.map").Data());
00650 gSystem->Exec(comm_cp);
00651 #endif
00652
00653 Info("Update","TOF histograms updated (producer)");
00654
00655 }
00656
00657
00658 void TFndTofMon::ResetHistos(){
00659
00660 if(tofmap) tofmap->Reset();
00661 if(tofmapadc0) tofmapadc0->Reset();
00662 if(tofmapadc) tofmapadc->Reset();
00663 if(tofmapadcp) tofmapadcp->Reset();
00664 if(tofmapadce) tofmapadce->Reset();
00665
00666 if(tofmaptdc0) tofmaptdc0->Reset();
00667 if(tofmaptdc) tofmaptdc->Reset();
00668 if(tofmaptdcp) tofmaptdcp->Reset();
00669 if(tofmaptdce) tofmaptdce->Reset();
00670 if(tofmapmt) tofmapmt->Reset();
00671
00672 if(tofmult) tofmult->Reset();
00673 if(tof_i_o_mult) tof_i_o_mult->Reset();
00674 if(tofcorr[0]) tofcorr[0]->Reset();
00675 if(tofcorr[1]) tofcorr[1]->Reset();
00676
00677 for(Int_t sf=0; sf<n_tof_hist; sf++) {
00678 if(tof_mapadctdc[sf]) tof_mapadctdc[sf]->Reset();
00679 if(tof_adc_tdc[sf]) tof_adc_tdc[sf]->Reset();
00680
00681 if(tofadcp[sf]) tofadcp[sf]->Reset();
00682 if(tofadce[sf]) tofadce[sf]->Reset();
00683 if(tofadc[sf]) tofadc[sf]->Reset();
00684 if(tofcrg[sf]) tofcrg[sf]->Reset();
00685 if(tofzet[sf]) tofzet[sf]->Reset();
00686
00687 if(toftdcp[sf]) toftdcp[sf]->Reset();
00688 if(toftdce[sf]) toftdce[sf]->Reset();
00689 if(toftdc[sf]) toftdc[sf]->Reset();
00690 if(toftdf[sf]) toftdf[sf]->Reset();
00691 if(toftmn[sf]) toftmn[sf]->Reset();
00692 if(toftmn_hw[sf]) toftmn_hw[sf]->Reset();
00693 }
00694
00695 }
00696
00697
00698 void TFndTofMon::WriteToFile(TString file,Bool_t IsShared) {
00699
00700 if(IsShared){
00701
00702 mtof->cd();
00703 }
00704 else{
00705 if(file.IsNull())
00706 ftof->cd();
00707 else {
00708 if(fout) fout->Close();
00709 delete fout;
00710 fout = new TFile(file.Data(),"RECREATE","Tof Histogram File");
00711 fout->cd();
00712 }
00713 }
00714 if(tofmap) tofmap->Write();
00715 if(tofmapadc0) tofmapadc0->Write();
00716 if(tofmapadc) tofmapadc->Write();
00717 if(tofmapadcp) tofmapadcp->Write();
00718 if(tofmapadce) tofmapadce->Write();
00719
00720 if(tofmaptdc0) tofmaptdc0->Write();
00721 if(tofmaptdc) tofmaptdc->Write();
00722 if(tofmaptdcp) tofmaptdcp->Write();
00723 if(tofmaptdce) tofmaptdce->Write();
00724 if(tofmapmt) tofmapmt->Write();
00725
00726 if(tofmult) tofmult->Write();
00727 if(tof_i_o_mult) tof_i_o_mult->Write();
00728 if(tofcorr[0]) tofcorr[0]->Write();
00729 if(tofcorr[1]) tofcorr[1]->Write();
00730
00731 for(Int_t sf=0; sf<n_tof_hist; sf++) {
00732
00733 if(tof_mapadctdc[sf]) tof_mapadctdc[sf]->Write();
00734 if(tof_adc_tdc[sf]) tof_adc_tdc[sf]->Write();
00735 }
00736
00737 if(IsShared){
00738 Info("TFndTofMon::WriteToFile","Writing histograms in on-line mode");
00739 mtof_adc->cd();
00740 }
00741 for(Int_t sf=0; sf<n_tof_hist; sf++) {
00742 if(tofadcp[sf]) tofadcp[sf]->Write();
00743 if(tofadce[sf]) tofadce[sf]->Write();
00744 if(tofadc[sf]) tofadc[sf]->Write();
00745 if(tofcrg[sf]) tofcrg[sf]->Write();
00746 if(tofzet[sf]) tofzet[sf]->Write();
00747 }
00748
00749 if(IsShared){
00750 Info("TFndTofMon::WriteToFile","Writing histograms in on-line mode");
00751 mtof_tdc->cd();
00752 }
00753 for(Int_t sf=0; sf<n_tof_hist; sf++) {
00754 if(toftdcp[sf]) toftdcp[sf]->Write();
00755 if(toftdce[sf]) toftdce[sf]->Write();
00756 if(toftdc[sf]) toftdc[sf]->Write();
00757 if(toftdf[sf]) toftdf[sf]->Write();
00758 if(toftmn[sf]) toftmn[sf]->Write();
00759 if(toftmn_hw[sf]) toftmn_hw[sf]->Write();
00760 }
00761
00762
00763 }
00764
00765
00766 void TFndTofMon::Add(TFndTofMon *tofmon) {
00767
00768 if(tofmult) tofmult->Add((const TH1 *) tofmon->TofMult());
00769 if(tof_i_o_mult) tof_i_o_mult->Add((const TH2 *) tofmon->TofMultIO());
00770 if(tofcorr[0]) tofcorr[0]->Add((const TH2 *) tofmon->TofCorr(0));
00771 if(tofcorr[1]) tofcorr[1]->Add((const TH2 *) tofmon->TofCorr(1));
00772 if(tofmap) tofmap->Add((const TH1 *) tofmon->TofMap());
00773 if(tofmapadc0) tofmapadc0->Add((const TH1 *) tofmon->TofMapAdc0());
00774 if(tofmapadce) tofmapadce->Add((const TH1 *) tofmon->TofMapAdcP());
00775 if(tofmapadcp) tofmapadcp->Add((const TH1 *) tofmon->TofMapAdcE());
00776 if(tofmapadc) tofmapadc->Add((const TH1 *) tofmon->TofMapAdc());
00777
00778 if(tofmaptdc0) tofmaptdc0->Add((const TH1 *) tofmon->TofMapTdc0());
00779 if(tofmaptdce) tofmaptdce->Add((const TH1 *) tofmon->TofMapTdcP());
00780 if(tofmaptdcp) tofmaptdcp->Add((const TH1 *) tofmon->TofMapTdcE());
00781 if(tofmaptdc) tofmaptdc->Add((const TH1 *) tofmon->TofMapTdc());
00782 if(tofmapmt) tofmapmt->Add((const TH1 *) tofmon->TofMapMT());
00783
00784 for (Int_t idx=0;idx<n_tof_hist;idx++) {
00785 if(tof_mapadctdc[idx]) tof_mapadctdc[idx]->Add((const TH2 *) tofmon->TofMapAdcTdc(idx));
00786 if(tof_adc_tdc[idx]) tof_adc_tdc[idx]->Add((const TH2 *) tofmon->TofAdcTdc(idx));
00787 if(tofadce[idx]) tofadce[idx]->Add((const TH1 *) tofmon->TofAdcE(idx));
00788 if(tofadcp[idx]) tofadcp[idx]->Add((const TH1 *) tofmon->TofAdcP(idx));
00789 if(tofcrg[idx]) tofcrg[idx]->Add((const TH1 *) tofmon->TofCrg(idx));
00790 if(tofzet[idx]) tofzet[idx]->Add((const TH1 *) tofmon->TofZet(idx));
00791 if(tofadc[idx]) tofadc[idx]->Add((const TH2 *) tofmon->TofAdc(idx));
00792 if(toftdce[idx]) toftdce[idx]->Add((const TH1 *) tofmon->TofTdcE(idx));
00793 if(toftdcp[idx]) toftdcp[idx]->Add((const TH1 *) tofmon->TofTdcP(idx));
00794 if(toftdf[idx]) toftdf[idx]->Add((const TH1 *) tofmon->TofTdf(idx));
00795 if(toftmn[idx]) toftmn[idx]->Add((const TH1 *) tofmon->TofTmn(idx));
00796 if(toftmn_hw[idx]) toftmn_hw[idx]->Add((const TH1 *) tofmon->TofTmnHW(idx));
00797 if(toftdc[idx]) toftdc[idx]->Add((const TH2 *) tofmon->TofTdc(idx));
00798 }
00799 }