#include "tools/Log.hh"
#include "tools/Toolbox.hh"
#include "root/MTRun.hh"
#include "root/MTChannel.hh"
#include "root/MTEvent.hh"
#include "root/MTTrack.hh"
#include "MicroException.hh"
#include "mysql/Mysql.hh"
#include "TFile.h"
#include "TTree.h"
#include "TKey.h"
#include "TBranch.h"
#include "TRandom.h"
#include "TProfile.h"
#include "TH2I.h"
#include "TF1.h"
#include <sstream>
#include <sys/types.h>
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
Include dependency graph for Tag_tracks.cpp:
Go to the source code of this file.
Functions | |
void | Find_track (MTTrack *track, MTEvent &evt) |
bool | Valid_time (MTEvent *evt_prev, MTEvent *evt_curr) |
void | Fill_histos (int e, MTEvent *evt, TH1I *hdt, TH2I *hxy, TH2I *hxy_cut, TH1I *hnhit, TH1I *hnhit_cut, TH1I *hc_nhit, TH1I *hc_nhit_cut, TH1I *hnhit_ro, TH1I *hnhit_cut_ro, TH2F *hx_cor, TH2F *hy_cor, TH1F *hx_res, TH1F *hy_res, int chb) |
void | Calculate_offset (TH2F *hx_cor, TH2F *hy_cor, TH1F *hx_res, TH1F *hy_res, float *offset_x, float *offset_y, float *offset_x_err, float *offset_y_err) |
void | Average_pres_temp (TTree *tree, float *pres, float *temp, float *pres_rms, float *temp_rms, int npoints) |
int | main (int argc, char **argv) |
Variables | |
int | errsv = errno |
Definition at line 624 of file Tag_tracks.cpp.
Referenced by main().
00625 { 00626 00627 int adc_cut = 25; 00628 int tel_square_cut = 10; 00629 00630 bool display = 0; 00631 00632 TH2I * hxz = new TH2I("hxz","Hit pattern in XZ plane;z;x",40,0,40,16,0,16); 00633 TH2I * hyz = new TH2I("hyz","Hit pattern in YZ plane;z;y",40,0,40,16,0,16); 00634 TH2I * hxy[3]; 00635 for (int i=0;i<3;i++){hxy[i] = new TH2I(Form("hxy_%i",i+7),Form("Hit pattern (adc>%i) chambeDr %i;y (cm);x (cm)",adc_cut,i+7),16,0,16,16,0,16);} 00636 00637 float zmean[3] = {10,20,30}; 00638 00639 float xavg = 0; 00640 float yavg = 0; 00641 float zavg = 20; 00642 float ax = 0; 00643 float bx = 0; 00644 float ay = 0; 00645 float by = 0; 00646 float ax1 = 0; 00647 float ax2 = 0; 00648 float ay1 = 0; 00649 float ay2 = 0; 00650 00651 float xextrapol = 0; 00652 float yextrapol = 0; 00653 00654 int content = 0; 00655 int nhit[3] = {0,0,0}; 00656 int xmax[3] = {0,0,0}; 00657 int ymax[3] = {0,0,0}; 00658 float xmean[3] = {0,0,0}; 00659 float ymean[3] = {0,0,0}; 00660 int ztemp; 00661 00662 bool track = 0; 00663 bool hot = 0; 00664 bool square_tel = 0; 00665 bool xstraight = 0; 00666 bool ystraight = 0; 00667 bool straight = 0; 00668 bool stiff = 0; 00669 00670 00671 00672 00673 //noisy channels 00674 bool noisy[3][96]; 00675 for (int i=0;i<3;i++){ 00676 for (int j=0;j<96;j++){ 00677 noisy[i][j] = 0;}} 00678 00679 /*HV pad*/ 00680 noisy[0][77] = 1; 00681 noisy[1][77] = 1; 00682 noisy[2][77] = 1; 00683 00684 /*floating pad*/ 00685 noisy[0][9] = 1; 00686 noisy[2][33] = 1; 00687 00688 int nhit_tel_cut[3] = {0,0,0}; 00689 bool hot_tel[3] = {0,0,0}; 00690 00691 00692 //fill XZ and YZ histos 00693 00694 if (display){cout<<evt.GetNchannel()<<endl;} 00695 00696 for (int j=0;j<evt.GetNchannel();j++) 00697 { 00698 MTChannel* channel = (MTChannel*)evt.GetChannels()->UncheckedAt(j); 00699 int chb = channel->GetChamberId() - 7; 00700 bool pad_telescope = chb >= 0 && chb < 3; 00701 00702 if (pad_telescope) 00703 { 00704 int hardid = channel->GetHardId(); 00705 00706 if (noisy[chb][hardid] == 0) 00707 { 00708 int adc = channel->GetAnalogValue(); 00709 00710 if (adc >= adc_cut) 00711 { 00712 nhit_tel_cut[chb]++; 00713 00714 int xpos = (int)(channel->GetX() / 10000); 00715 int ypos = (int)(channel->GetY() / 10000); 00716 int zpos = (int)(channel->GetZ() / 10000); 00717 00718 if (!hot_tel[chb]){hot_tel[chb] = 1;} 00719 00720 hxy[chb]->Fill(xpos,ypos,adc); 00721 hxz->Fill((chb+1)*10,xpos,adc); 00722 hyz->Fill((chb+1)*10,ypos,adc); 00723 } 00724 } 00725 } 00726 } 00727 00728 //require 3 hot chambers 00729 track = 0; 00730 hot = hot_tel[0] && hot_tel[1] && hot_tel[2]; 00731 00732 if (hot) 00733 { 00734 //tag square events 00735 square_tel = 0; 00736 for (int k=0;k<3;k++) 00737 { 00738 if (nhit_tel_cut[k] >= tel_square_cut) 00739 { 00740 square_tel = 1; 00741 } 00742 } 00743 00744 //find tracks 00745 if (!square_tel) 00746 { 00747 //get position with maximum charge 00748 for (int k=0;k<3;k++) 00749 { 00750 hxy[k]->GetMaximumBin(xmax[k],ymax[k],ztemp); 00751 } 00752 00753 //request align maxima +/- 1 pad 00754 //define track from first and last chamber 00755 00756 xextrapol = floor(0.5*(xmax[2] + xmax[0])); 00757 yextrapol = floor(0.5*(ymax[2] + ymax[0])); 00758 00759 if ((fabs(xextrapol - xmax[1]) <= 1) && (fabs(yextrapol - ymax[1]) <= 1)) 00760 { 00761 track = 1; 00762 } 00763 00764 if (track) 00765 { 00766 /*************form clusters**************/ 00767 00768 for (int k=0;k<3;k++) 00769 { 00770 if (nhit_tel_cut[k] != 1) 00771 { 00772 for (int xx=-1;xx<=1;xx++) 00773 { 00774 for (int yy=-1;yy<=1;yy++) 00775 { 00776 content = hxy[k]->GetBinContent(xmax[k] + xx,ymax[k] + yy); 00777 00778 if (content != 0) 00779 { 00780 xmean[k] += (xmax[k] + xx - 0.5); 00781 ymean[k] += (ymax[k] + yy - 0.5); 00782 nhit[k]++; 00783 } 00784 } 00785 } 00786 00787 if (nhit[k] != 1) 00788 { 00789 xmean[k] /= nhit[k]; 00790 ymean[k] /= nhit[k]; 00791 } 00792 } 00793 else 00794 { 00795 xmean[k] = xmax[k] - 0.5; 00796 ymean[k] = ymax[k] - 0.5; 00797 } 00798 } 00799 00800 /************determine track parameters**********/ 00801 00802 //tracks in xz plane 00803 //if straight 00804 if (xmean[0]==xmean[1] && xmean[0]==xmean[2]) 00805 { 00806 ax = 0; 00807 bx = xmean[0]; 00808 xstraight = 1; 00809 } 00810 //if inclined 00811 else 00812 { 00813 xavg = 1/3.*(xmean[0] + xmean[1] + xmean[2]); 00814 00815 for (int l=0;l<3;l++) 00816 { 00817 ax1 += ((zmean[l] - zavg) * (xmean[l] - xavg)); 00818 ax2 += pow(zmean[l] - zavg,2); 00819 } 00820 00821 ax = ax1/ax2; 00822 bx = xavg - ax*zavg; 00823 } 00824 00825 //tracks in yz plane 00826 //if straight 00827 if (ymean[0]==ymean[1] && ymean[0]==ymean[2]) 00828 { 00829 ay = 0; 00830 by = ymean[0]; 00831 ystraight = 1; 00832 } 00833 //if inclined 00834 else 00835 { 00836 yavg = 1/3.*(ymean[0] + ymean[1] + ymean[2]); 00837 00838 for (int l=0;l<3;l++) 00839 { 00840 ay1 += ((zmean[l] - zavg) * (ymean[l] - yavg)); 00841 ay2 += pow(zmean[l] - zavg,2); 00842 } 00843 00844 ay = ay1/ay2; 00845 by = yavg - ay*zavg; 00846 } 00847 00848 straight = xstraight && ystraight; 00849 stiff = straight && nhit_tel_cut[0]==1 && nhit_tel_cut[1]==1 && nhit_tel_cut[2]==1; 00850 00851 trk->SetFromPad(1); 00852 trk->SetFromStrip(0); 00853 00854 trk->SetStraight(straight); 00855 trk->SetSingleHit(stiff); 00856 00857 trk->SetAx(ax); 00858 trk->SetAy(ay); 00859 00860 trk->SetBx(bx); 00861 trk->SetBy(by); 00862 00863 evt.SetTrack(trk); 00864 00865 } 00866 } 00867 } 00868 00869 00870 if (display) 00871 { 00872 cout<<"Hot = "<<hot<<endl; 00873 if (hot) 00874 { 00875 cout<<"Track = "<<track<<endl; 00876 if (track) 00877 { 00878 cout<<"XZ plane : "<<ax<<" "<<bx<<endl; 00879 cout<<"YZ plane : "<<ay<<" "<<by<<endl; 00880 } 00881 } 00882 } 00883 00884 00885 hxz->Delete(); 00886 hyz->Delete(); 00887 00888 for (int k=0;k<3;k++) 00889 { 00890 hxy[k]->Delete(); 00891 } 00892 00893 00894 }
Definition at line 553 of file Tag_tracks.cpp.
Referenced by main().
00554 { 00555 00556 bool valid = 0; 00557 00558 00559 00560 Long64_t tprevious = 0; 00561 Long64_t tcurrent = 0; 00562 00563 bool tprev_defined = 0; 00564 bool tcurr_defined = 0; 00565 00566 // search time in previous event 00567 int nchannel = evt_prev->GetNchannel(); 00568 for (int j=0;j<nchannel;j++) 00569 { 00570 MTChannel* channel = (MTChannel*)evt_prev->GetChannels()->UncheckedAt(j); 00571 00572 if (channel->GetChamberId() == 10) 00573 { 00574 tprevious = channel->GetBcId_Abs(); 00575 tprev_defined = 1; 00576 j = nchannel; 00577 } 00578 } 00579 //if no m2 hits were found, no time info 00580 if (tprev_defined == 0){return 0;} 00581 00582 // search time in current event 00583 nchannel = evt_curr->GetNchannel(); 00584 for (int j=0;j<nchannel;j++) 00585 { 00586 MTChannel* channel = (MTChannel*)evt_curr->GetChannels()->UncheckedAt(j); 00587 00588 if (channel->GetChamberId() == 10) 00589 { 00590 tcurrent = channel->GetBcId_Abs(); 00591 tcurr_defined = 1; 00592 j = nchannel; 00593 } 00594 } 00595 //if no m2 hits were found, no time info 00596 if (tcurr_defined == 0){return 0;} 00597 00598 //calculate time difference 00599 00600 if (tcurr_defined && tprev_defined) 00601 { 00602 Long64_t tdiff = tcurrent - tprevious; 00603 double dt = tdiff * 200e-9; 00604 00605 if (dt <= 3.35) 00606 { 00607 valid = 1; 00608 evt_curr->SetTimeInfo(1); 00609 } 00610 } 00611 00612 return valid; 00613 }
void Fill_histos | ( | int | e, | |
MTEvent * | evt, | |||
TH1I * | hdt, | |||
TH2I * | hxy, | |||
TH2I * | hxy_cut, | |||
TH1I * | hnhit, | |||
TH1I * | hnhit_cut, | |||
TH1I * | hc_nhit, | |||
TH1I * | hc_nhit_cut, | |||
TH1I * | hnhit_ro, | |||
TH1I * | hnhit_cut_ro, | |||
TH2F * | hx_cor, | |||
TH2F * | hy_cor, | |||
TH1F * | hx_res, | |||
TH1F * | hy_res, | |||
int | chb | |||
) |
Definition at line 441 of file Tag_tracks.cpp.
Referenced by main().
00442 { 00443 00444 00445 00446 //look for a straight track to fill correlation histos 00447 MTTrack * trk = evt->GetTrack(); 00448 bool correlation = 0; 00449 float bx = 0; 00450 float by = 0; 00451 00452 if (trk!=NULL) 00453 { 00454 if (trk->GetFromPad() && trk->GetStraight()) 00455 { 00456 correlation = 1; 00457 bx = trk->GetBx(); 00458 by = trk->GetBy(); 00459 } 00460 } 00461 00462 //delete trk; 00463 00464 00465 int nhit = 0; 00466 int nhit_cut = 0; 00467 int nchannel = evt->GetNchannel(); 00468 00469 for (int j=0;j<nchannel;j++) 00470 { 00471 MTChannel* channel = (MTChannel*)evt->GetChannels()->UncheckedAt(j); 00472 00473 00474 00475 if (channel->GetChamberId() == chb) 00476 { 00477 int hardid = channel->GetHardId(); 00478 int chipid = channel->GetChipId(); 00479 00480 int channelid = (chipid-1)*64 + hardid; 00481 00482 float xpos = (int)(channel->GetX() / 10000); 00483 float ypos = (int)(channel->GetY() / 10000); 00484 00485 int digit = channel->GetDigitalValue(); 00486 00487 hc_nhit->Fill(channelid); 00488 hxy->Fill(ypos,xpos); 00489 nhit++; 00490 00491 Long64_t dt = channel->GetBcId_Dif() - channel->GetBcId_Hit(); 00492 00493 hdt->Fill(dt); 00494 00495 if (dt>=6 && dt<=9) 00496 { 00497 hc_nhit_cut->Fill(channelid); 00498 hxy_cut->Fill(ypos,xpos); 00499 nhit_cut++; 00500 00501 if (correlation) 00502 { 00503 //take m2 prototype dead area into account 00504 //parallel to DIF side 00505 if (xpos >= 32) 00506 { 00507 xpos += 0.5; 00508 00509 if (xpos >= 32*2) 00510 { 00511 xpos += 0.5; 00512 } 00513 } 00514 00515 //perpendicular to DIF side 00516 if (ypos >= 48) 00517 { 00518 ypos += 0.5; 00519 } 00520 00521 hx_res->Fill(xpos-bx); 00522 hy_res->Fill(ypos-by); 00523 00524 hx_cor->Fill(bx,xpos); 00525 hy_cor->Fill(by,ypos); 00526 } 00527 } 00528 } 00529 } 00530 00531 hnhit->Fill(nhit); 00532 hnhit_cut->Fill(nhit_cut); 00533 00534 hnhit_ro->Fill(e+1,nhit); 00535 hnhit_cut_ro->Fill(e+1,nhit_cut); 00536 00537 }
void Calculate_offset | ( | TH2F * | hx_cor, | |
TH2F * | hy_cor, | |||
TH1F * | hx_res, | |||
TH1F * | hy_res, | |||
float * | offset_x, | |||
float * | offset_y, | |||
float * | offset_x_err, | |||
float * | offset_y_err | |||
) |
Definition at line 396 of file Tag_tracks.cpp.
Referenced by main().
00397 { 00398 00399 TF1 * fx = new TF1("fx","[0]+[1]*x",0,100); 00400 TF1 * fy = new TF1("fy","[0]+[1]*x",0,100); 00401 00402 fx->SetParameters(hx_res->GetMaximumBin() - 100,1); 00403 fy->SetParameters(hy_res->GetMaximumBin() - 100,1); 00404 00405 TProfile * tpfx = hx_cor->ProfileX(); 00406 TProfile * tpfy = hy_cor->ProfileX(); 00407 00408 tpfx->Fit(fx,"q"); 00409 tpfy->Fit(fy,"q"); 00410 00411 *offset_x = fx->GetParameter(0); 00412 *offset_x_err = fx->GetParError(0); 00413 00414 *offset_y = fy->GetParameter(0); 00415 *offset_y_err = fy->GetParError(0); 00416 00417 tpfx->Delete(); 00418 tpfy->Delete(); 00419 00420 fx->Delete(); 00421 fy->Delete(); 00422 00423 cout<<endl; 00424 cout<<" Offsets"<<endl; 00425 cout<<"Along X = ["<<*offset_x<<" +/- "<<*offset_x_err<<"] cm"<<endl; 00426 cout<<"Along Y = ["<<*offset_y<<" +/- "<<*offset_y_err<<"] cm"<<endl; 00427 cout<<endl; 00428 00429 }
void Average_pres_temp | ( | TTree * | tree, | |
float * | pres, | |||
float * | temp, | |||
float * | pres_rms, | |||
float * | temp_rms, | |||
int | npoints | |||
) |
Definition at line 334 of file Tag_tracks.cpp.
Referenced by main().
00336 { 00337 00338 int nbEntries = tree->GetEntries(); 00339 00340 MTEvent *evt = new MTEvent(); 00341 TBranch *branch= tree->GetBranch("MTEvent"); 00342 branch->SetAddress(&evt); 00343 00344 cout<<" Average Pressure and Temperature ("<<npoints<<" points)"<<endl; 00345 00346 int evtStep = floor(nbEntries/1./(npoints-1)); 00347 00348 float t = 0; 00349 float p = 0; 00350 00351 for ( int evtNum = 0; evtNum < nbEntries ; evtNum += evtStep) 00352 { 00353 tree->GetEntry(evtNum); 00354 00355 p = evt->GetPressure(); 00356 t = evt->GetTemperature(); 00357 00358 *pres += p; 00359 *temp += t; 00360 00361 *pres_rms += pow(p,2); 00362 *temp_rms += pow(t,2); 00363 } 00364 00365 *pres /= npoints; 00366 *temp /= npoints; 00367 00368 *pres_rms /= npoints; 00369 *temp_rms /= npoints; 00370 00371 *pres_rms = sqrt(*pres_rms - pow(*pres,2)); 00372 *temp_rms = sqrt(*temp_rms - pow(*temp,2)); 00373 00374 cout<<"P = ["<<*pres<<" +/- "<<*pres_rms<<"] mbar"<<endl; 00375 cout<<"T = ["<<*temp<<" +/- "<<*temp_rms<<"] deg C"<<endl; 00376 cout<<endl; 00377 00378 delete evt; 00379 delete branch; 00380 00381 }
int main | ( | int | argc, | |
char ** | argv | |||
) |
Definition at line 59 of file Tag_tracks.cpp.
00059 { 00060 00061 if ( argc != 2 ) { 00062 FILE_LOG(logERROR) << "usage:" << endl; 00063 FILE_LOG(logERROR) << ":process_example fileToProcess" << endl; 00064 exit(1); 00065 } 00066 string inputfile = argv[1] ; 00067 00068 // build temporaly fill path and name 00069 pid_t pid = getpid(); 00070 std::ostringstream oss; 00071 oss << "/tmp/" << pid << ".root"; 00072 string outputfile = oss.str(); 00073 00074 cout<<"Read "<<inputfile<<endl; 00075 cout<<"Create "<<outputfile<<endl; 00076 00077 00078 00079 // Open Root TFile in read only mode 00080 TFile infile(inputfile.c_str(),"READ"); 00081 00082 // Open Root TFile in write mode 00083 TFile oufile(outputfile.c_str(),"RECREATE"); 00084 // Change current directory to "this" directory 00085 // Mandatory to use updateTree->GetCurrentFile() later 00086 oufile.cd(); 00087 00088 00089 00090 TH1I * hdt = new TH1I("hdt","Time to readout;bcid_dif - bcid_hit (200 ns)",100,0,100); 00091 00092 TH2I * hxy = new TH2I("hxy","Hit position;y (pad number);x (pad number)",96,0,96,96,0,96); 00093 TH2I * hxy_cut = new TH2I("hxy_cut","Hit position after time cut;y (pad number);x (pad number)",96,0,96,96,0,96); 00094 00095 TH1I * hnhit = new TH1I("hnhit","Number of hits;nhit",10000,0,10000); 00096 TH1I * hnhit_cut = new TH1I("hnhit_cut","Number of hits after time cut;nhit",10000,0,10000); 00097 00098 TH1I * hc_nhit = new TH1I("hc_nhit","Number of hits;channel;nhit",9216,0,9216); 00099 TH1I * hc_nhit_cut = new TH1I("hc_nhit_cut","Number of hits after time cut;channel;nhit",9216,0,9216); 00100 00101 TH2F * hx_cor = new TH2F("hx_cor","Correlation Prototype - telescope;Xtelescope (cm);Xm2 (cm)",100,0,100,200,0,100); 00102 TH2F * hy_cor = new TH2F("hy_cor","Correlation Prototype - telescope;Ytelescope (cm);Ym2 (cm)",100,0,100,200,0,100); 00103 00104 TH1F * hx_res = new TH1F("hx_res","Correlation Prototype - telescope;Xm2 - Xtelescope (cm)",200,-100,100); 00105 TH1F * hy_res = new TH1F("hy_res","Correlation Prototype - telescope;Ym2 - Ytelescope (cm)",200,-100,100); 00106 00107 00108 00109 //square events cuts 00110 UInt_t square_asu = 0; 00111 UInt_t square_bcid = 0; 00112 UInt_t square_cut = 1000; 00113 UInt_t m2_chb = 10; 00114 00115 00116 00117 00118 00119 // Loop over original TTrees 00120 TIter nextkey(infile.GetListOfKeys()); 00121 MTEvent *updateEvt = new MTEvent(); 00122 00123 TKey* key = (TKey*)nextkey(); 00124 00125 TTree *tree = (TTree*)key->ReadObj(); 00126 00127 // Create new TTree which will contain processed MTRun and MTEvent 00128 string treeName = tree->GetName(); 00129 treeName = treeName + "_preprocessed"; 00130 TTree *updateTree = new TTree(treeName.c_str(),"MicroMegas event"); 00131 updateTree->Branch("MTEvent",&updateEvt,16000,2); 00132 00133 MTRun * run = (MTRun*)tree->GetUserInfo()->FindObject("MTRun"); 00134 00135 // Set Processed flag to MTRun 00136 run->SetProcessed(true); 00137 00138 // Save MTRun information to new processed TTree 00139 updateTree->GetUserInfo()->Add(run); 00140 MTEvent *evt = new MTEvent(); 00141 TBranch *branch= tree->GetBranch("MTEvent"); 00142 branch->SetAddress(&evt); 00143 00144 00145 //MTChannel* channel =NULL; 00146 int nbEntries = tree->GetEntries(); 00147 MTEvent* prev_evt = NULL; 00148 00149 cout<<endl; 00150 cout<<"NUMBER OF EVENTS = "<<nbEntries<<endl; 00151 cout<<endl; 00152 00153 00154 TH1I * hnhit_ro = new TH1I("hnhit_ro","Number of hits per readout;readout;nhit",nbEntries,0,nbEntries); 00155 TH1I * hnhit_cut_ro = new TH1I("hnhit_cut_ro","Number of hits per readout after time cut;readout;nhit",nbEntries,0,nbEntries); 00156 00157 00158 //for ( int evtNum = 0; evtNum < nbEntries ; evtNum++) 00159 for ( int evtNum = 0; evtNum < 500 ; evtNum++) 00160 { 00161 tree->GetEntry(evtNum); 00162 00163 // Copy original MTEvent to new processed MTEvent 00164 *updateEvt = *evt; 00165 00166 //check if time info is valid 00167 if ( prev_evt != NULL ) 00168 { 00169 bool temp = Valid_time(prev_evt,updateEvt); 00170 } 00171 00172 //look for square event in m2 prototype 00173 bool square = updateEvt->IsSquare(square_cut,square_asu,square_bcid,m2_chb); 00174 00175 //Associate or not a track to this event 00176 //MTTrack* track = NULL; 00177 MTTrack* track = new MTTrack(); 00178 Find_track(track,*updateEvt); 00179 00180 //Write MTEvent into Branch 00181 cout << "Write Event[" << evtNum << "] \r" << flush; 00182 updateTree->Fill(); 00183 delete track; 00184 00185 //Start basic analysis 00186 Fill_histos(evtNum,updateEvt,hdt,hxy,hxy_cut,hnhit,hnhit_cut,hc_nhit,hc_nhit_cut,hnhit_ro,hnhit_cut_ro,hx_cor,hy_cor,hx_res,hy_res,m2_chb); 00187 00188 //keep event for time-between-readout calculation 00189 prev_evt = updateEvt; 00190 } 00191 00192 00193 00194 //calculate offsets and errors 00195 float offset_x = 0; 00196 float offset_y = 0; 00197 00198 float offset_x_err = 0; 00199 float offset_y_err = 0; 00200 00201 Calculate_offset(hx_cor,hy_cor,hx_res,hy_res,&offset_x,&offset_y,&offset_x_err,&offset_y_err); 00202 00203 00204 00205 //determine pressure and temperature 00206 float pres = 0; 00207 float temp = 0; 00208 float pres_rms = 0; 00209 float temp_rms = 0; 00210 int npoints = 10; 00211 Average_pres_temp(tree,&pres,&temp,&pres_rms,&temp_rms,npoints); 00212 00213 00214 //display profile infos 00215 00216 float xmean = hxy_cut->GetMean(2); 00217 float ymean = hxy_cut->GetMean(1); 00218 float xrms = hxy_cut->GetRMS(2); 00219 float yrms = hxy_cut->GetRMS(1); 00220 float nhit_mean = hnhit->GetMean(); 00221 float nhit_cut_mean = hnhit_cut->GetMean(); 00222 int dt_max = hdt->GetMaximumBin()-1; 00223 float eff = 100. * (1 - 1.*hnhit_cut->GetBinContent(1)/hnhit_cut->GetEntries()); 00224 00225 cout<<" Hit profile and RMS"<<endl; 00226 cout<<"Along X = ["<<xmean<<" +/- "<<xrms<<"] cm"<<endl; 00227 cout<<"Along Y = ["<<ymean<<" +/- "<<yrms<<"] cm"<<endl; 00228 cout<<endl; 00229 00230 cout<<" Nhits / readout"<<endl; 00231 cout<<"No time cut = "<<nhit_mean<<endl; 00232 cout<<"With time cut = "<<nhit_cut_mean<<endl; 00233 cout<<endl; 00234 00235 cout<<" Timing"<<endl; 00236 cout<<"Delta_t_max = "<<dt_max<<" bcid"<<endl; 00237 cout<<endl; 00238 00239 cout<<" Efficiency = "<<eff<<" %"<<endl; 00240 cout<<endl; 00241 00242 00243 00244 00245 00246 00247 00248 //Write offsets and other infos to database 00249 int runid = run->GetRunId(); 00250 if (runid == 0) 00251 { 00252 cout<<"RunId not known, please enter: "; 00253 cin>>runid; 00254 cout<<endl; 00255 cout<<endl; 00256 //runid = 10227; 00257 } 00258 00259 00260 00261 Mysql mysql; 00262 mysql.updateRunProcessInfo(runid, // runId 00263 offset_x, // offsetX 00264 offset_y, // offsetY 00265 pres, // pressure 00266 temp, // temperature 00267 dt_max);// deltaTMax 00268 00269 mysql.addRunChamberProcessInfo(runid,//runid 00270 m2_chb, // chamberId, 00271 xmean, // xmean, 00272 ymean, // ymean, 00273 eff,// inefficiency, 00274 nhit_cut_mean,// nHitMean, 00275 dt_max);// deltaTMax; 00276 00277 00278 00279 // Write Root Object to TFile 00280 TFile * curFile = updateTree->GetCurrentFile(); 00281 updateTree->Write("", TObject::kOverwrite); 00282 updateTree->SetDirectory(0); 00283 00284 // free heap memory 00285 delete evt; 00286 00287 00288 //Write histo to new TFile 00289 00290 hdt->Write(); 00291 hxy->Write(); 00292 hxy_cut->Write(); 00293 hc_nhit->Write(); 00294 hc_nhit_cut->Write(); 00295 hnhit->Write(); 00296 hnhit_cut->Write(); 00297 hnhit_ro->Write(); 00298 hnhit_cut_ro->Write(); 00299 hx_cor->Write(); 00300 hy_cor->Write(); 00301 hx_res->Write(); 00302 hy_res->Write(); 00303 00304 00305 00306 infile.Close(); 00307 oufile.Close(); 00308 00309 00310 00311 // Replace original root file by the new processed one 00312 string command = "cp -f "; 00313 command = command + outputfile + " " + inputfile ; 00314 int result = system(command.c_str()); 00315 if ( result == -1 ) { cout << strerror(errno) << endl; } 00316 command = "rm -f " + outputfile; 00317 result = system(command.c_str()); 00318 if ( result == -1 ) { cout << strerror(errno) << endl; } 00319 00320 00321 cout << endl << "Done." << endl; 00322 00323 00324 return 0; 00325 }
int errsv = errno |
Definition at line 33 of file Tag_tracks.cpp.