Newer
Older
TB_Chris / TbUT / scripts / .svn / text-base / ClusterWithTrackAna.C.svn-base
  1. #define ClusterWithTrackAna_cxx
  2. //#include "ClusterWithTrackAna_Inputs.h"
  3. #include "ClusterWithTrackAna.h"
  4. #include <TH2.h>
  5. #include <TStyle.h>
  6. #include <TLatex.h>
  7. #include <TCanvas.h>
  8. #include <iostream>
  9. #include <fstream>
  10.  
  11. void addGraphics(TH1 *h, int iCol = 1, TString XTitle="", TString YTitle="")
  12. {
  13. h->SetXTitle(XTitle);
  14. h->SetYTitle(YTitle);
  15. h->SetStats(kFALSE);
  16. h->SetLineColor(iCol);
  17. h->SetMarkerColor(iCol);
  18. h->SetMinimum(0.0);
  19. h->SetMaximum(1.2*h->GetMaximum());
  20. h->SetTitleSize(0.1);
  21. //h->SetLineColor(kBlack);
  22. h->SetMarkerSize(0.7);
  23. h->SetMarkerStyle(20);
  24. h->GetXaxis()->SetTitleOffset(1.0);
  25. h->GetYaxis()->SetTitleOffset(1.2);
  26. h->GetXaxis()->SetTitleSize(0.045);
  27. h->GetYaxis()->SetTitleSize(0.045);
  28. h->GetXaxis()->SetLabelSize(0.04);
  29. h->GetYaxis()->SetLabelSize(0.04);
  30. h->SetNdivisions(505,"X");
  31. h->SetNdivisions(505,"Y");
  32. h->SetLineWidth(2);
  33. }
  34.  
  35. void addGraphics(TH2 *h, int iCol = 1, TString XTitle="", TString YTitle="")
  36. {
  37. //float bw = h->GetBinWidth(1);
  38. h->SetXTitle(XTitle);
  39. h->SetYTitle(YTitle);
  40. h->SetStats(kFALSE);
  41. h->SetLineColor(iCol);
  42. h->SetMarkerColor(iCol);
  43. h->SetMinimum(0.0);
  44. h->SetMaximum(1.2*h->GetMaximum());
  45. h->SetTitleSize(0.1);
  46. //h->SetLineColor(kBlack);
  47. //h->SetMarkerSize(0.7);
  48. //h->SetMarkerStyle(20);
  49. h->GetXaxis()->SetTitleOffset(1.0);
  50. h->GetYaxis()->SetTitleOffset(1.2);
  51. h->GetXaxis()->SetTitleSize(0.045);
  52. h->GetYaxis()->SetTitleSize(0.045);
  53. h->GetXaxis()->SetLabelSize(0.04);
  54. h->GetYaxis()->SetLabelSize(0.04);
  55. h->SetNdivisions(505,"X");
  56. h->SetNdivisions(505,"Y");
  57. h->SetLineWidth(2);
  58. }
  59.  
  60.  
  61. void ClusterWithTrackAna::Loop()
  62. {
  63. // In a ROOT session, you can do:
  64. // Root > .L ClusterWithTrackAna.C
  65. // Root > ClusterWithTrackAna t
  66. // Root > t.GetEntry(12); // Fill t data members with entry number 12
  67. // Root > t.Show(); // Show values of entry 12
  68. // Root > t.Show(16); // Read and show values of entry 16
  69. // Root > t.Loop(); // Loop on all entries
  70. //
  71.  
  72. // This is the loop skeleton where:
  73. // jentry is the global entry number in the chain
  74. // ientry is the entry number in the current Tree
  75. // Note that the argument to GetEntry must be:
  76. // jentry for TChain::GetEntry
  77. // ientry for TTree::GetEntry and TBranch::GetEntry
  78. //
  79. // To read only selected branches, Insert statements like:
  80. // METHOD1:
  81. // fChain->SetBranchStatus("*",0); // disable all branches
  82. // fChain->SetBranchStatus("branchname",1); // activate branchname
  83. // METHOD2: replace line
  84. // fChain->GetEntry(jentry); //read all branches
  85. //by b_branchname->GetEntry(ientry); //read only this branch
  86. if (fChain == 0) return;
  87.  
  88. Int_t nentries = fChain->GetEntriesFast();
  89.  
  90. TString m_board2 = m_board;
  91. m_board2 = m_board2.ReplaceAll("_All","");
  92. m_board2 = m_board2.ReplaceAll("_Full","");
  93. m_board2 = m_board2.ReplaceAll("_v7","");
  94. TString f_out = m_fileOutdir + plotdir + "/AnalysisOutput_" + m_board2 + "_" + m_bias + "_" + m_sector + ".root";
  95. if(m_angle != "0"){
  96. f_out = m_fileOutdir + plotdir + "/AnalysisOutput_" + m_board2 + "_" + m_bias + "_" + m_sector + "_" + m_angle + ".root";
  97. }
  98. cout << "Will write out file: " << f_out << endl;
  99.  
  100.  
  101. fout = new TFile(f_out,"RECREATE");
  102.  
  103. TH1F* h0 = new TH1F("h0","#DeltaX between strip hit and track projection (strips)",101,-50.5,50.5);
  104. TH1F* h1 = new TH1F("h1","#DeltaX",800,-2.0,2.0);
  105. TH2F* h1vsx = new TH2F("h1vsx","#DeltaX vs X",50,-5,5,100,-0.2,0.2);
  106. TH1F* h1mpa = new TH1F("h1mpa","#DeltaX",400,-20.0,20.0);
  107. TH1F* h1mbpa = new TH1F("h1mbpa","#DeltaX",400,-20.0,20.0);
  108. TH1F* h1fpa = new TH1F("h1fpa","#DeltaX",400,-20.0,20.0);
  109. TH1F* h1fbpa = new TH1F("h1fbpa","#DeltaX",400,-20.0,20.0);
  110.  
  111. TH1F* h1mpa1 = new TH1F("h1mpa1","#DeltaX",800,-20.0,20.0);
  112. TH1F* h1mpa2 = new TH1F("h1mpa2","#DeltaX",800,-20.0,20.0);
  113. TH1F* h1mpa3 = new TH1F("h1mpa3","#DeltaX",800,-20.0,20.0);
  114. TH1F* h1mpa4 = new TH1F("h1mpa4","#DeltaX",800,-20.0,20.0);
  115. TH1F* h1mpa5 = new TH1F("h1mpa5","#DeltaX",800,-20.0,20.0);
  116.  
  117. TH1F* h1mpaL = new TH1F("h1mpaL","Strip# of Missed Hit in Lower PA region",512,0,512);
  118. TH1F* h1mpaU = new TH1F("h1mpaU","Strip# of Missed Hit in Upper PA region",512,0,512);
  119.  
  120.  
  121. TH1F* h1s = new TH1F("h1s","Seed strip of cluster",512,0.0,512.0);
  122. TH1F* h1a = new TH1F("h1a","#DeltaX, 1 strip",800,-2.0,2.0);
  123. TH1F* h1b = new TH1F("h1b","#DeltaX, 2 strip",800,-2.0,2.0);
  124. TH1F* h1z = new TH1F("h1z","#DeltaX, low Charge",800,-2.0,2.0);
  125. TH1F* h1w = new TH1F("h1w","#DeltaX",20000,-100.0,100.0);
  126. TH1F* h1wY = new TH1F("h1wY","#DeltaX",20000,-100.0,100.0);
  127. TH2F* h2 = new TH2F("h2","X_{DUT} vs X_{trk}",100,-8.0,8.0,100,-8,8);
  128. TH2F* h3 = new TH2F("h3","Y_{trk} vs X_{trk}, with cluster",640,-8,8.0,640,-8,8);
  129. TH2F* h3a = new TH2F("h3a","Y_{trk} vs X_{trk} in fiducial",640,-8,8.0,640,-8,8);
  130. TH2F* h3b = new TH2F("h3b","Y_{trk} vs X_{trk}, with missed cluster",640,-8,8.0,640,-8,8);
  131. TH2F* h3c = new TH2F("h3c","Y_{trk} vs X_{trk}, with found cluster",640,-8,8.0,640,-8,8);
  132. TH1F* h4 = new TH1F("h4","Detector strip # of cluster with track",512,0.0,512);
  133. TH1F* h4a = new TH1F("h4a","Electonic Strip # of cluster with track",512,0.0,512);
  134. TH1F* h4b = new TH1F("h4b","Strip # of cluster with track",1024,0.0,1024);
  135. TH1F* h4c = new TH1F("h4c","Strip # of cluster with track",1024,0.0,1024);
  136. TH1F* h5 = new TH1F("h5","#theta_{X}",500,-5.0,5.0);
  137. TH1F* h6 = new TH1F("h6","#theta_{Y}",500,-5.0,5.0);
  138. TH1F* h5c = new TH1F("h5c","#theta_{X}",500,-5.0,5.0);
  139. TH1F* h6c = new TH1F("h6c","#theta_{Y}",500,-5.0,5.0);
  140. TH1F* h5a = new TH1F("h5a","X position of track",400,-10.0,10.0);
  141. TH1F* h6a = new TH1F("h6a","Y position of track",400,-10.0,10.0);
  142. TH1F* h5b = new TH1F("h5b","X position of matched cluster",400,-10.0,10.0);
  143. TH1F* h6b = new TH1F("h6b","Y position of matched cluster",400,-10.0,10.0);
  144.  
  145. TProfile *h8 = new TProfile("h8","#DeltaX vs #theta_{trk}",100,-5,5,-1.0,1.0);
  146. TProfile *h9 = new TProfile("h9","#DeltaX vs Y_{trk} at DUT",1600,-8,8,-1.0,1.0);
  147. TProfile *h9a = new TProfile("h9a","#DeltaX vs X_{trk} at DUT",20,-5,5,-1.0,1.0);
  148.  
  149. TProfile *h10a = new TProfile("h10a","<ADC> vs strip",512,0,512,0.0,1000.0);
  150. TProfile *h10b = new TProfile("h10b","<ADC> vs strip",512,0,512,0.0,1000.0);
  151. TProfile *h10c = new TProfile("h10c","<ADC> vs strip",512,0,512,0.0,1000.0);
  152. TProfile *h10d = new TProfile("h10d","<ADC> vs Y_{trk}",100,-8,8,0.0,1000.0);
  153. TProfile *h10e = new TProfile("h10e","<ADC> vs X_{trk}",100,-8,8,0.0,1000.0);
  154. TH1F* h11n = new TH1F("h11n","Strip # of matched cluster",512,0.0,512);
  155. TH1F* h11d = new TH1F("h11d","Strip # of track",512,0.0,512);
  156. h11n->Sumw2();
  157. h11d->Sumw2();
  158. TH1F* h12 = new TH1F("h12","Y position of matched cluster",400,-10.0,10.0); h12->Sumw2();
  159. TH1F* h12c = new TH1F("h12c","X position of matched cluster",400,-10.0,10.0);h12c->Sumw2();
  160. TH1F* h12a = new TH1F("h12a","Y position of track",1600,-10.0,10.0); h12a->Sumw2();
  161. TH1F* h12b = new TH1F("h12b","Y position of track",1600,-10.0,10.0); h12b->Sumw2();
  162.  
  163. TH1F* h12dn = new TH1F("h12dn","X position of track",200,-10.0,10.0); h12dn->Sumw2();
  164. TH1F* h12en = new TH1F("h12en","X position of track",200,-10.0,10.0);h12en->Sumw2();
  165. TH1F* h12fn = new TH1F("h12fn","X position of track",200,-10.0,10.0);h12fn->Sumw2();
  166. TH1F* h12gn = new TH1F("h12gn","X position of track",200,-10.0,10.0);h12gn->Sumw2();
  167. TH1F* h12dd = new TH1F("h12dd","X position of track",200,-10.0,10.0);h12dd->Sumw2();
  168. TH1F* h12ed = new TH1F("h12ed","X position of track",200,-10.0,10.0);h12ed->Sumw2();
  169. TH1F* h12fd = new TH1F("h12fd","X position of track",200,-10.0,10.0);h12fd->Sumw2();
  170. TH1F* h12gd = new TH1F("h12gd","X position of track",200,-10.0,10.0);h12gd->Sumw2();
  171.  
  172. TH1F* h12hn = new TH1F("h12hn","X position of track",50,-0.5,0.5);h12hn->Sumw2();
  173. TH1F* h12in = new TH1F("h12in","X position of track",50,-0.5,0.5);h12in->Sumw2();
  174. TH1F* h12jn = new TH1F("h12jn","X position of track",50,-0.5,0.5);h12jn->Sumw2();
  175. TH1F* h12kn = new TH1F("h12kn","X position of track",50,-0.5,0.5);h12kn->Sumw2();
  176. TH1F* h12hd = new TH1F("h12hd","X position of track",50,-0.5,0.5);h12hd->Sumw2();
  177. TH1F* h12id = new TH1F("h12id","X position of track",50,-0.5,0.5);h12id->Sumw2();
  178. TH1F* h12jd = new TH1F("h12jd","X position of track",50,-0.5,0.5);h12jd->Sumw2();
  179. TH1F* h12kd = new TH1F("h12kd","X position of track",50,-0.5,0.5);h12kd->Sumw2();
  180.  
  181. TProfile *h12m = new TProfile("h12m","<ADC> vs interstrip pos",50,-0.5,0.5,0.0,1000.0);
  182. TProfile *h12n = new TProfile("h12n","<ClusterSize> vs interstrip pos",50,-0.5,0.5,0.0,1000.0);
  183.  
  184. TH1F* h12on = new TH1F("h12on","dist of track to cutout",700,-2.0,5.0);h12on->Sumw2();
  185. TH1F* h12od = new TH1F("h12od","dist of track to cutout",700,-2.0,5.0);h12od->Sumw2();
  186.  
  187. TH1F *h13mpa = new TH1F("h13mpa","#Clusters/Ev",10,-0.5,9.5);
  188. TH1F *h13mbpa = new TH1F("h13mbpa","#Clusters/Ev",10,-0.5,9.5);
  189. TH1F *h13fpa = new TH1F("h13fpa","#Clusters/Ev",10,-0.5,9.5);
  190. TH1F *h13fbpa = new TH1F("h13fbpa","#Clusters/Ev",10,-0.5,9.5);
  191.  
  192. TH1F* h14a = new TH1F("h14a","Nom Strip, no matched cluster",512,0.0,512);
  193. TH1F* h14b = new TH1F("h14b","Nom Strip, matched cluster",512,0.0,512);
  194.  
  195. TH1F *h15a = new TH1F("h15a","Chisq of tracks with matched DUT hit",200,0.0,200.0);
  196. TH1F *h15b = new TH1F("h15b","TDC time with matched DUT hit",12,0.0,12.0);
  197. TH1F *h15c = new TH1F("h15c","Time Between Trigger and Track",5,0.0,5.0);
  198. TH1F *h15d = new TH1F("h15d","TDC time of all clusters",12,0.0,12.0);
  199. TH1F *h15e = new TH1F("h15e","TDC time of good clusters",12,0.0,12.0);
  200.  
  201. TH1F *h16a = new TH1F("h16a","Chisq of tracks without matched DUT hit",200,0.0,200.0);
  202. TH1F *h16b = new TH1F("h16b","TDC time without matched DUT hit",12,0.0,12.0);
  203. TH1F *h16c = new TH1F("h16c","Time Between Trigger and Track",5,0.0,5.0);
  204. h15c->Sumw2();
  205. h16c->Sumw2();
  206. TH1F* h17 = new TH1F("h17","Q_{L} / (Q_{L}+Q_{R})",50,0.0,1.0);
  207. TH2F* h17a = new TH2F("h17a","Q_{L} / (Q_{L}+Q_{R}) vs Interstrip Pos",20,-0.5,0.5,120,-0.1,1.1);
  208. TProfile* h17b = new TProfile("h17b","Q_{R} / (Q_{L}+Q_{R}) vs Interstrip Pos",20,-0.5,0.5,-0.1,1.1);
  209.  
  210. TH1F* hcmpa = new TH1F("hcmpa","Cluster charge",100,0.0,1000.0);
  211. TH1F* hcmbpa = new TH1F("hcmbpa","Cluster charge",100,0.0,1000.0);
  212. TH1F* hcfpa = new TH1F("hcfpa","Cluster charge",100,0.0,1000.0);
  213. TH1F* hcfbpa = new TH1F("hcfbpa","Cluster charge",100,0.0,1000.0);
  214.  
  215. TH1F* h18a = new TH1F("h18a","Seed/Total charge",100,0.0,2.0);
  216.  
  217. TH2F* h18b = new TH2F("h18b","#DeltaX vs Interstrip Pos (1 strip Clu)",100,-0.5,0.5,100,-0.2,0.2);
  218. TH2F* h18c = new TH2F("h18c","#DeltaX vs Interstrip Pos (2 strip Clu)",100,-0.5,0.5,100,-0.2,0.2);
  219. TH2F* h18d = new TH2F("h18d","Seed/Total charge vs Interstrip Pos",100,-0.5,0.5,100,0.0,1.1);
  220.  
  221. TH1F* hcTrkXY[16];
  222. for(int i=0; i<4; i++){
  223. for(int j=0; j<4; j++){
  224. int iblock = 4*i+j;
  225. TString hname = Form("hcTrkXY_%d",iblock+1);
  226. TString htitle = Form("Cluster charge, block %d",iblock+1);
  227. hcTrkXY[iblock]= new TH1F(hname,htitle,100,0.0,1000.0);
  228. }
  229. }
  230. TH1F *hlandau[512];
  231. for(int i=0; i<nChan; i++){
  232. hlandau[i] = new TH1F(Form("hlandau_%d",i),"Cluster charge",100,0.0,1000.0);
  233. }
  234.  
  235.  
  236. TH1F* hcAll = new TH1F("hcAll","Cluster charge",100,0.0,1000.0);
  237. TH1F* hcTrk = new TH1F("hcTrk","Cluster charge",100,0.0,1000.0);
  238. TH1F* hcTrkCorr = new TH1F("hcTrkCorr","Cluster charge",100,0.0,1000.0);
  239. TH1F* hcTrkSeed = new TH1F("hcTrkSeed","Cluster charge",100,0.0,1000.0);
  240. TH1F* hcTrkSeed1 = new TH1F("hcTrkSeed1","Cluster charge",100,0.0,1000.0);
  241. TH1F* hcTrkSeed2 = new TH1F("hcTrkSeed2","Cluster charge",100,0.0,1000.0);
  242. //TH1F* hcTrkY1 = new TH1F("hcTrkY1","Cluster charge",100,0.0,1000.0);
  243. //TH1F* hcTrkY2 = new TH1F("hcTrkY2","Cluster charge",100,0.0,1000.0);
  244. //TH1F* hcTrkY3 = new TH1F("hcTrkY3","Cluster charge",100,0.0,1000.0);
  245. //TH1F* hcTrkY4 = new TH1F("hcTrkY4","Cluster charge",100,0.0,1000.0);
  246. TH1F* hcTrkNoTop = new TH1F("hcTrkNoTop","Cluster charge",100,0.0,1000.0);
  247. TH1F* hcTrkLowX = new TH1F("hcTrkLowX","Cluster charge",100,0.0,1000.0);
  248. TH1F* hcTrkHighX = new TH1F("hcTrkHighX","Cluster charge",100,0.0,1000.0);
  249. TH1F* hcTrka = new TH1F("hcTrka","Cluster charge, limited region",100,0.0,1000.0);
  250. TH1F* hcTrk1 = new TH1F("hcTrk1","Cluster charge, Size = 1",100,0.0,1000.0);
  251. TH1F* hcTrk2 = new TH1F("hcTrk2","Cluster charge, Size = 2",100,0.0,1000.0);
  252. TProfile *h2p = new TProfile("h2p","Cluster Charge vs TDC time",12,0,12,100,1000);
  253.  
  254.  
  255. TH2F* h31a = new TH2F("h31a","Y_{trk} vs X_{trk}, with cluster",64,-8,8.0,64,-8,8);
  256. TH2F* h31b = new TH2F("h31b","Y_{trk} vs X_{trk}, with cluster, low ADC",64,-8,8.0,64,-8,8);
  257. TH1F* h32a = new TH1F("h32a","Strip # of cluster with track",512,0.0,512);
  258. TH1F* h32b = new TH1F("h32b","Strip # of cluster with track & low ADC",512,0.0,512);
  259. TH1F* h33a = new TH1F("h33a","Y position of matched cluster",200,-10.0,10.0);
  260. TH1F* h33b = new TH1F("h33b","X position of matched cluster",200,-10.0,10.0);
  261. TH1F* h34 = new TH1F("h34","Y position of matched cluster & low ADC",200,-10.0,10.0);
  262.  
  263. TH1F *hnoise = new TH1F("hnoise","Noise in connected channels",100,-200,200);
  264. TH1F *hnoiseChan = new TH1F("hnoiseChan","Noise in connected channels",200,0,200);
  265. TH1F *hnoisePerChannel = new TH1F("hnoisePerChannel","Noise",512,0,512);
  266.  
  267. TH1F* h35 = new TH1F("h35","No. clusters / event",50,0.0,50.0);
  268. TH1F *h41[10];
  269. TH1F *h42[10];
  270. TH1F *h43[10];
  271. TH1F *h44[10];
  272. for(int i=0; i<10; i++){
  273. h41[i] = new TH1F(Form("h41_%d",i),Form("ADC_{L}-ADC_{R}, Bin %d, Odd Ch",i),80,-400,400);
  274. h42[i] = new TH1F(Form("h42_%d",i),Form("ADC_{L}-ADC_{R}, Bin %d, Odd Ch",i),80,-400,400);
  275. h43[i] = new TH1F(Form("h43_%d",i),Form("ADC_{L}-ADC_{R}, Bin %d, Odd Ch",i),160,-400,400);
  276. h44[i] = new TH1F(Form("h44_%d",i),Form("ADC_{L}-ADC_{R}, Bin %d, Odd Ch",i),160,-400,400);
  277. }
  278.  
  279. for(int i=0; i<nChan; i++){
  280. hnoisePerChannel->Fill(i+0.5,noise[i]);
  281. }
  282.  
  283.  
  284. //------------------------------------------------------------------------------------------------------
  285. //-----------------------------
  286. // Prepare DUT (Alignment, etc)
  287. //-----------------------------
  288.  
  289. PrepareDUT();
  290. //return;
  291. float biasVal = atof(m_bias);
  292. cout << "chargeCorrSlopeOdd, chargeCorrSlopeEven = " << chargeCorrSlopeOdd << " " << chargeCorrSlopeEven << " "
  293. << m_bias << " " << biasVal << endl;
  294.  
  295. std::ofstream myfile;
  296. if(writeEventsWithMissinhHitsToFile){
  297. myfile.open("MissingDUTHits.dat");
  298. }
  299.  
  300. int iChan = nChan;
  301. double nomStrip = 0, detStrip = 0;
  302. int nPrint = 0;
  303. double dxh[10];
  304. int njump = 10000;
  305. if(nentries > 100000) njump = 50000;
  306. Long64_t nbytes = 0, nb = 0;
  307. cout << "Begin loop over " << nentries << " events" << endl;
  308. for (Long64_t jentry=0; jentry<nentries;jentry++) {
  309. Long64_t ientry = LoadTree(jentry);
  310. if (ientry < 0) break;
  311. nb = fChain->GetEntry(jentry); nbytes += nb;
  312. if(jentry%njump==0) cout << "====> At entry = " << jentry << endl;
  313. if(n_tp3_tracks != 1) continue;
  314.  
  315. //==========================================
  316. // Example here of acccessing CMS strip data
  317. //==========================================
  318. if(fCMS){
  319. for(int k=0;k<iChan;k++){
  320. if(fCMS->cmsData[k]!=0) hnoise->Fill(fCMS->cmsData[k]);
  321. }
  322. }
  323.  
  324. h35->Fill(clusterNumberPerEvent);
  325. if(clusterNumberPerEvent>10) continue;
  326. // Loop over TPIX tracks in event
  327. for(int k=0; k<n_tp3_tracks; k++){
  328. if(dtime > trackTriggerTimeDiffCut) continue;
  329. double x_trk = vec_trk_tx->at(k)*z_DUT+vec_trk_x->at(k);
  330. double y_trk = vec_trk_ty->at(k)*z_DUT+vec_trk_y->at(k);
  331. transformTrackToDUTFrame(k, x_trk, y_trk, nomStrip, detStrip);
  332.  
  333. //if(isInCutoutRegion(x_trk, y_trk)) continue;
  334. double distToCutout = DistToCutoutRegion(x_trk, y_trk);
  335. bool awayFromCutout = distToCutout > minDistFromHole;
  336.  
  337. int closestStrip = nomStrip;
  338. double fracStrip = nomStrip - closestStrip - 0.5;
  339.  
  340. double tx = 1000*vec_trk_tx->at(k);
  341. double ty = 1000*vec_trk_ty->at(k);
  342.  
  343. h5->Fill(tx);
  344. h6->Fill(ty);
  345.  
  346. // Test cuts here, e.g. to reject regions
  347. //if(nomStrip<422 || nomStrip>442) continue;
  348. //if(y_trk>2.4) continue;
  349. //if(nomStrip<420 || nomStrip>445) continue;
  350.  
  351. bool goodRegion = true;
  352. for(int id = 0; id<nDeadRegion; id++){
  353. if(x_trk>=deadRegionLo[id] && x_trk<=deadRegionHi[id]) goodRegion = false;
  354. }
  355. if(!goodRegion) continue;
  356.  
  357. h5a->Fill(x_trk);
  358. h6a->Fill(y_trk);
  359. bool goodTrack = false;
  360. bool inFiducialX = false;
  361. bool inFiducialY = false;
  362.  
  363. if(x_trk>xMin && x_trk<xMax) inFiducialX = true;
  364. if(y_trk>yMin && y_trk<yMax) inFiducialY = true;
  365. bool inFiducial = inFiducialX && inFiducialY;
  366. inFiducial = inFiducial && (x_trk<xLeftHole || x_trk>xRightHole);
  367. if(tx>txMin && tx<txMax && ty>tyMin && ty<tyMax) goodTrack = true;
  368. bool goodTime = (clustersTDC >= tdcLo && clustersTDC <= tdcHi);
  369.  
  370. if(goodTrack && goodTime && inFiducial) h12od->Fill(distToCutout);
  371.  
  372. if(goodTrack && goodTime && inFiducial && awayFromCutout) {
  373. h3a->Fill(x_trk,y_trk);
  374. h12a->Fill(y_trk);
  375. h12dd->Fill(x_trk);
  376. if(y_trk>yInt1[0]&&y_trk<yInt1[1]) h12ed->Fill(x_trk);
  377. if(y_trk>yInt2[0]&&y_trk<yInt2[1]) h12fd->Fill(x_trk);
  378. if(y_trk>yInt3[0]&&y_trk<yInt3[1]) h12gd->Fill(x_trk);
  379. h12hd->Fill(fracStrip);
  380. if(y_trk>yInt1[0]&&y_trk<yInt1[1] && x_trk>-3.5&&x_trk<2.5) h12id->Fill(fracStrip);
  381. if(y_trk>yInt2[0]&&y_trk<yInt2[1] && x_trk>-3.5&&x_trk<2.5) h12jd->Fill(fracStrip);
  382. if(y_trk>yInt3[0]&&y_trk<yInt3[1] && x_trk>-3.5&&x_trk<2.5) h12kd->Fill(fracStrip);
  383. }
  384. bool foundHit = false;
  385. bool foundHitNoFid = false;
  386. double x_trk0 = x_trk;
  387. for(int j=0; j<min(clusterNumberPerEvent,10); j++){
  388. dxh[j] = -999;
  389. if(clustersPosition[j] < 0.1) continue;
  390. if(polarity*clustersCharge[j] < 0.2*kClusterChargeMin) continue;
  391. double x_dut = getDUTHitPosition(j);
  392. x_trk = x_trk0;
  393. int iPeak = 1;
  394. if(clustersSeedPosition[j]%2==0) iPeak = 0;
  395. h1s->Fill(clustersSeedPosition[j]);
  396. if(clustersSeedPosition[j]<iLo-5 || clustersSeedPosition[j]>iHi+5) continue;
  397.  
  398. double dx = x_dut - x_trk;
  399. dxh[j] = dx;
  400.  
  401. if(inFiducial && goodTime && awayFromCutout) h12->Fill(y_trk);
  402. if(goodTrack && inFiducial && fabs(dx)<dxWin && awayFromCutout) {
  403. h2p->Fill(clustersTDC+0.1,polarity*clustersCharge[j]);
  404. h15d->Fill(clustersTDC);
  405. if(goodTime) h15e->Fill(clustersTDC);
  406. }
  407.  
  408. if(goodTrack && inFiducial && goodTime && fabs(dx)<dxWin){
  409. h3->Fill(x_trk,y_trk);
  410. }
  411. if(goodTrack && inFiducial && goodTime && fabs(dx)<dxWin) foundHitNoFid = true;
  412.  
  413.  
  414. if(goodTrack && inFiducial && goodTime && awayFromCutout) {
  415. hcAll->Fill(polarity*clustersCharge[j]);
  416. h2->Fill(x_trk, x_dut);
  417. h1->Fill(dx);
  418. if(clustersSize[j]==1) h1a->Fill(dx);
  419. if(clustersSize[j]==2) h1b->Fill(dx);
  420. h1w->Fill(dx);
  421. if(y_trk>2.5) h1wY->Fill(dx);
  422. if(polarity*clustersCharge[j] < 250) h1z->Fill(dx);
  423. h11d->Fill(detStrip);
  424. if(fabs(dx)<dxWin) {
  425. int ichan = clustersSeedPosition[j];
  426. h4c->Fill(clustersSeedPosition[j]);
  427. if(ichan>=0 && ichan<=511){
  428. hlandau[ichan]->Fill(polarity*clustersCharge[j]);
  429. }
  430. hnoiseChan->Fill(noise[ichan]);
  431. h18a->Fill(clustersSeedCharge[j]/clustersCharge[j]);
  432. foundHit = true;
  433. if(clustersSize[j]==1) h18b->Fill(fracStrip,dx);
  434. if(clustersSize[j]==2) h18c->Fill(fracStrip,dx);
  435. h18d->Fill(fracStrip,clustersSeedCharge[j]/clustersCharge[j]);
  436. h12m->Fill(fracStrip,polarity*clustersCharge[j]);
  437. h12n->Fill(fracStrip,clustersSize[j]);
  438. h1vsx->Fill(x_trk,dx);
  439. if(y_trk>yMid&&y_trk<yMax) h10a->Fill(clustersPosition[j],polarity*clustersCharge[j]);
  440. if(y_trk>yMin&&y_trk<yMid) h10b->Fill(clustersPosition[j],polarity*clustersCharge[j]);
  441. if(y_trk>yHi2&&y_trk<yMax) h10c->Fill(clustersPosition[j],polarity*clustersCharge[j]);
  442. h10d->Fill(y_trk,polarity*clustersCharge[j]);
  443. h10e->Fill(x_trk,polarity*clustersCharge[j]);
  444. double chleft = polarity*clustersCharge1StripLeft[j];
  445. double chright = polarity*clustersCharge1StripRight[j];
  446. double rc = -999;
  447. if(detStrip <= clustersSeedPosition[j]) {
  448. if(chleft>0) rc = (chleft/(chleft+clustersSeedCharge[j]));
  449. }else{
  450. if(chright>0) rc = (clustersSeedCharge[j]/(chright+clustersSeedCharge[j]));
  451. }
  452. if( rc>=0 ) {
  453. h17->Fill(rc);
  454. h17a->Fill(fracStrip,rc);
  455. h17b->Fill(fracStrip,rc);
  456. }
  457. h8->Fill(1000*vec_trk_tx->at(k),dx);
  458. h9->Fill(y_trk,dx);
  459. h9a->Fill(x_trk,dx);
  460. h5b->Fill(x_trk);
  461. h6b->Fill(y_trk);
  462. h5c->Fill(tx);
  463. h6c->Fill(ty);
  464.  
  465. h11n->Fill(detStrip);
  466. hcTrk->Fill(polarity*clustersCharge[j]);
  467. if(clustersSize[j]==1) hcTrkCorr->Fill(polarity*clustersCharge[j]);
  468. if(clustersSize[j]==2 && iPeak==1) hcTrkCorr->Fill(polarity*clustersCharge[j]*(1.0-chargeCorrSlopeOdd));
  469. if(clustersSize[j]==2 && iPeak==0) hcTrkCorr->Fill(polarity*clustersCharge[j]*(1.0-chargeCorrSlopeEven));
  470. hcTrkSeed->Fill(polarity*clustersSeedCharge[j]);
  471. if(clustersSize[j]==1) hcTrkSeed1->Fill(polarity*clustersSeedCharge[j]);
  472. if(clustersSize[j]==2) hcTrkSeed2->Fill(polarity*clustersSeedCharge[j]);
  473. if(y_trk - yMax < 5.0) hcTrkNoTop->Fill(polarity*clustersCharge[j]);
  474. if(x_trk < (xMin+xMax)/2.) hcTrkLowX->Fill(polarity*clustersCharge[j]);
  475. if(x_trk >= (xMin+xMax)/2.) hcTrkHighX->Fill(polarity*clustersCharge[j]);
  476. int ix = 4*(x_trk - xMin - 0.001) / (xMax-xMin);
  477. int iy = 4*(y_trk - yMin - 0.001) / (yMax-yMin);
  478. int ihist = 4*ix + iy;
  479. hcTrkXY[ihist]->Fill(polarity*clustersCharge[j]);
  480. //if(y_trk>yMin && y_trk<=(yMin+0.25*yRange)) hcTrkY1->Fill(polarity*clustersCharge[j]);
  481. //if(y_trk>(yMin+0.25*yRange) && y_trk<(yMin+0.50*yRange)) hcTrkY2->Fill(polarity*clustersCharge[j]);
  482. //if(y_trk>(yMin+0.50*yRange) && y_trk<(yMin+0.75*yRange)) hcTrkY3->Fill(polarity*clustersCharge[j]);
  483. //if(y_trk>(yMin+0.75*yRange) && y_trk<(yMin+1.00*yRange)) hcTrkY4->Fill(polarity*clustersCharge[j]);
  484. //if(y_trk>yMin&&y_trk<yMid+1.0) hcTrkY2->Fill(polarity*clustersCharge[j]);
  485.  
  486. if(clustersSize[j]==1) hcTrk1->Fill(polarity*clustersCharge[j]);
  487. if(clustersSize[j]==2) hcTrk2->Fill(polarity*clustersCharge[j]);
  488. if(clustersPosition[j]>170 && clustersPosition[j]<190) hcTrka->Fill(polarity*clustersCharge[j]);
  489. h31a->Fill(x_trk,y_trk);
  490. h32a->Fill(clustersPosition[j]);
  491. h33a->Fill(y_trk);
  492. h33b->Fill(x_trk);
  493. if(polarity*clustersCharge[j] < 250) {
  494. h31b->Fill(x_trk,y_trk);
  495. h32b->Fill(clustersPosition[j]);
  496. h34->Fill(y_trk);
  497. }
  498. double chr = clustersCharge1StripRight[j]*polarity;
  499. double chl = clustersCharge1StripLeft[j]*polarity;
  500. double chr2 = clustersCharge2StripRight[j]*polarity;
  501. double chl2 = clustersCharge2StripLeft[j]*polarity;
  502. double pch = polarity*clustersSeedCharge[j];
  503. int ic = pch/50.;
  504. if(ic>=0 && ic<10 && clustersSize[j]<=2 ){
  505. if(iPeak==1) h41[ic]->Fill(chl-chr);
  506. if(iPeak==0) h42[ic]->Fill(chl-chr);
  507. if(chr2!=0 and chl2!=0){
  508. if(iPeak==1) h43[ic]->Fill(chl2-chr2);
  509. if(iPeak==0) h44[ic]->Fill(chl2-chr2);
  510. }
  511. }
  512. }
  513.  
  514. double clstrip = getCorrChannel(clustersPosition[j]);
  515. h4->Fill(clstrip);
  516. h4b->Fill(clstrip + channelOffset);
  517. h4a->Fill(clustersPosition[j]);
  518. h0->Fill(detStrip - clstrip);
  519. }
  520. }
  521.  
  522. if(inFiducial && goodTrack && goodTime && foundHitNoFid) {
  523. h12on->Fill(distToCutout);
  524. }
  525. if(inFiducial && goodTrack && goodTime && awayFromCutout) {
  526. h16c->Fill(dtime);
  527. if(foundHit) {
  528. h3c->Fill(x_trk,y_trk);
  529. for(int j=0; j<min(clusterNumberPerEvent,10); j++){
  530. hcfpa->Fill(polarity*clustersCharge[j]);
  531. if(polarity*clustersCharge[j]>120) h1fpa->Fill(dxh[j]);
  532. }
  533. h15c->Fill(dtime);
  534. h15b->Fill(clustersTDC+0.1);
  535. h15a->Fill(vec_trk_chi2ndf->at(k));
  536. h12b->Fill(y_trk);
  537. h12dn->Fill(x_trk);
  538. if(y_trk>yInt1[0]&&y_trk<yInt1[1]) h12en->Fill(x_trk);
  539. if(y_trk>yInt2[0]&&y_trk<yInt2[1]) h12fn->Fill(x_trk);
  540. if(y_trk>yInt3[0]&&y_trk<yInt3[1]) h12gn->Fill(x_trk);
  541. h12hn->Fill(fracStrip);
  542. if(y_trk>yInt1[0]&&y_trk<yInt1[1] && x_trk>-3.5&&x_trk<2.5) h12in->Fill(fracStrip);
  543. if(y_trk>yInt2[0]&&y_trk<yInt2[1] && x_trk>-3.5&&x_trk<2.5) h12jn->Fill(fracStrip);
  544. if(y_trk>yInt3[0]&&y_trk<yInt3[1] && x_trk>-3.5&&x_trk<2.5) h12kn->Fill(fracStrip);
  545. if(y_trk>yInt1[0] && y_trk < yInt2[1] && x_trk>-3.5&&x_trk<-2.0) {
  546. h14b->Fill(detStrip);
  547. h13fpa->Fill(clusterNumberPerEvent);
  548. }else if(y_trk>yInt3[0] && y_trk < yInt3[1]) {
  549. h13fbpa->Fill(clusterNumberPerEvent);
  550. for(int j=0; j<min(clusterNumberPerEvent,10); j++){
  551. h1fbpa->Fill(dxh[j]);
  552. hcfbpa->Fill(polarity*clustersCharge[j]);
  553. }
  554. }
  555. }else{
  556. h3b->Fill(x_trk,y_trk);
  557. h13mpa->Fill(clusterNumberPerEvent);
  558. h16a->Fill(vec_trk_chi2ndf->at(k));
  559. h16b->Fill(clustersTDC+0.1);
  560. for(int j=0; j<min(clusterNumberPerEvent,10); j++){
  561. hcmpa->Fill(polarity*clustersCharge[j]);
  562. if(polarity*clustersCharge[j]>120) h1mpa->Fill(dxh[j]);
  563. }
  564. nPrint++;
  565. if(y_trk>yInt1[0] && y_trk < yInt2[1]) {
  566. h14a->Fill(detStrip);
  567. if(writeEventsWithMissinhHitsToFile)
  568. myfile << jentry << " " << detStrip << " " << x_trk << " " << y_trk << endl;
  569. //if(nPrint < 100) cout << "Missed hit, event, #clu, nomStrip = " << jentry << " "
  570. // << clusterNumberPerEvent << " " << nomStrip << endl;
  571. for(int j=0; j<min(clusterNumberPerEvent,10); j++){
  572. if(x_trk>-3.5&&x_trk<-2.0) h1mpa1->Fill(dxh[j]);
  573. if(x_trk>-2.0&&x_trk<-1.0) h1mpa2->Fill(dxh[j]);
  574. if(x_trk>-1.0&&x_trk<0.0) h1mpa3->Fill(dxh[j]);
  575. if(x_trk>0.0&&x_trk<1.0) h1mpa4->Fill(dxh[j]);
  576. if(x_trk>1.5&&x_trk<3.5) h1mpa5->Fill(dxh[j]);
  577. if(y_trk<yInt1[1]) h1mpaL->Fill(clustersPosition[j]);
  578. if(y_trk>=yInt1[1]) h1mpaU->Fill(clustersPosition[j]);
  579. }
  580. }else if(y_trk>yInt3[0] && y_trk < yInt3[1]) {
  581. h13mbpa->Fill(clusterNumberPerEvent);
  582. for(int j=0; j<min(clusterNumberPerEvent,10); j++){
  583. h1mbpa->Fill(dxh[j]);
  584. hcmbpa->Fill(polarity*clustersCharge[j]);
  585. }
  586. }
  587. }
  588. }
  589. }
  590. }
  591. if(writeEventsWithMissinhHitsToFile) myfile.close();
  592.  
  593. int i1 = h1->FindBin(-0.3);
  594. int i2 = h1->FindBin(0.3);
  595. cout << "Number of track - DUT hit matchs: " << h1->Integral(i1,i2) << endl;
  596. cout << "Ry = " << Ry << endl;
  597. TString r1 = Form("%6.3f < Y < %6.3f mm",yInt1[0], yInt1[1]);
  598. TString r2 = Form("%6.3f < Y < %6.3f mm ",yInt2[0], yInt2[1]);
  599. TString r3 = Form("%6.3f < Y < %6.3f mm",yInt3[0], yInt3[1]);
  600.  
  601.  
  602. TF1 *funchole = new TF1("funchole","[0]+[1]*x+[2]*x*x",-8.0,8.0);
  603. funchole->SetParameters(holeQuadPar[0],holeQuadPar[1],holeQuadPar[2]);
  604. funchole->SetLineColor(4);
  605. funchole->SetLineWidth(2);
  606. cout << "Hole Parameters: " << holeQuadPar[0] << " " << holeQuadPar[1] << " " << holeQuadPar[2] << endl;
  607. gStyle->SetOptStat(1000000001);
  608. gStyle->SetOptFit(0011);
  609. gStyle->SetStatH(0.05);
  610. gStyle->SetStatW(0.2);
  611.  
  612. addGraphics(h3b, 1, "X_{trk} [mm]", "Y_{trk} [mm] ");
  613. h3b->GetXaxis()->SetRangeUser(-5,5);
  614. h3b->GetYaxis()->SetRangeUser(-5,5);
  615.  
  616. TCanvas *c = new TCanvas("c","Residuals",1500,1000);
  617. c->Divide(4,3);
  618. c->cd(1)->SetLeftMargin(0.13);
  619. addGraphics(h2, 1, "X_{trk} [mm]", "X_{DUT} [mm]");
  620. double dM = yMax;
  621. if(xMax>dM) dM = xMax;
  622. h2->GetXaxis()->SetRangeUser(-1.0*dM-1,dM+1);
  623. h2->GetYaxis()->SetRangeUser(-1.0*dM-1,dM+1);
  624. h2->SetMinimum(1);
  625. h2->Draw();
  626.  
  627. c->cd(2)->SetLeftMargin(0.13);;
  628. addGraphics(h1, 1, "#DeltaX [mm]", "");
  629. addGraphics(h1z, 2, "#DeltaX [mm]", "");
  630. addGraphics(h1a, 3, "#DeltaX [mm]", "");
  631. addGraphics(h1b, 6, "#DeltaX [mm]", "");
  632. h1->GetXaxis()->SetRangeUser(-0.3,0.3);
  633. if(m_board.Contains("A1")) h1->GetXaxis()->SetRangeUser(-1.5,1.5);
  634. h1->SetMaximum(1.2*h1->GetMaximum());
  635. h1->Draw();
  636. //h1z->Draw("same");
  637. h1a->Draw("same");
  638. h1b->Draw("same");
  639. TLine *l1 = new TLine(-stripPitch/2.,0,-stripPitch/2.,0.5*h1->GetMaximum());
  640. TLine *l2 = new TLine(stripPitch/2,0,stripPitch/2,0.5*h1->GetMaximum());
  641. TLine *l1a = new TLine(-dxWin,0,-dxWin,0.5*h1->GetMaximum());
  642. TLine *l2a = new TLine(dxWin,0,dxWin,0.5*h1->GetMaximum());
  643. l1->SetLineColor(kRed); l2->SetLineColor(kRed);
  644. l1a->SetLineColor(kBlue); l2a->SetLineColor(kBlue); l1a->SetLineWidth(2); l2a->SetLineWidth(2);
  645. l1->Draw(); l2->Draw();
  646. //l1a->Draw(); l2a->Draw();
  647.  
  648. TLegend* legend3 = new TLegend(0.15,0.70,0.40,0.89);
  649. legend3->SetFillStyle(0);
  650. legend3->SetBorderSize(0);
  651. legend3->SetFillStyle(0);
  652. legend3->SetTextSize(0.045);
  653. legend3->AddEntry(h1,"All","L");
  654. //legend3->AddEntry(h1z,"ADC < 250","L");
  655. legend3->AddEntry(h1a,"1-strip","L");
  656. legend3->AddEntry(h1b,"2-strip","L");
  657. legend3->Draw();
  658. c->cd(3)->SetLeftMargin(0.13);;
  659. addGraphics(h8, 1, "#theta_{X}^{trk} [mrad]", "#DeltaX [mm]");
  660. h8->GetXaxis()->SetRangeUser(txMin-0.1,txMax+0.1);
  661. h8->GetYaxis()->SetRangeUser(-0.1,0.1);
  662. h8->Draw();
  663. c->cd(4)->SetLeftMargin(0.13);;
  664. addGraphics(h9, 1, "Y^{trk} [mm]", "#DeltaX [mm]");
  665. h9->GetXaxis()->SetRangeUser(yMin-1,yMax+1);
  666. h9->GetYaxis()->SetRangeUser(-0.1,0.1);
  667. h9->Draw();
  668. c->cd(5)->SetLeftMargin(0.13);;
  669. addGraphics(h9a, 1, "X^{trk} [mm]", "#DeltaX [mm]");
  670. h9a->GetXaxis()->SetRangeUser(-4,4);
  671. h9a->GetYaxis()->SetRangeUser(-0.1,0.1);
  672. h9a->Draw();
  673.  
  674. c->cd(6)->SetLeftMargin(0.13);;
  675. addGraphics(h3, 1, "X_{trk} [mm]", "Y_{trk} [mm]");
  676. h3->GetXaxis()->SetRangeUser(xMin-1,xMax+1);
  677. h3->GetYaxis()->SetRangeUser(yMin-1,yMax+1);
  678. h3->Draw();
  679. if(holeQuadPar[0]!=0) funchole->Draw("same");
  680. if(fabs(xLeftHole)<900 && fabs(xRightHole)<900){
  681. TBox *b1 = new TBox(xMin,yMin,xLeftHole,yMax);
  682. TBox *b2 = new TBox(xRightHole,yMin,xMax,yMax);
  683. b1->SetLineColor(kBlue); b1->SetLineWidth(2);b1->SetFillStyle(0);
  684. b1->Draw();
  685. b2->SetLineColor(kBlue); b2->SetLineWidth(2);b2->SetFillStyle(0);
  686. b2->Draw();
  687. }else{
  688. TBox *b = new TBox(xMin,yMin,xMax,yMax);
  689. b->SetLineColor(kBlue); b->SetLineWidth(2);b->SetFillStyle(0);
  690. b->Draw();
  691. }
  692.  
  693. c->cd(7)->SetLeftMargin(0.13);;
  694. addGraphics(h5, 1, "#theta_{X}^{trk} [mrad]", "");
  695. h5->GetXaxis()->SetRangeUser(txMin-0.1,txMax+0.1);
  696. h5->Draw();
  697. h5c->SetLineColor(2); h5c->Draw("same");
  698. TLine *l1b = new TLine(txMin,0,txMin,h5->GetMaximum());
  699. TLine *l2b = new TLine(txMax,0,txMax,h5->GetMaximum());
  700. l1b->SetLineColor(kBlue); l2b->SetLineColor(kBlue); l1b->SetLineWidth(2); l2b->SetLineWidth(2);
  701. l1b->Draw(); l2b->Draw();
  702.  
  703. c->cd(8)->SetLeftMargin(0.13);
  704. addGraphics(h6, 1, "#theta_{Y}^{trk} [mrad]", "");
  705. h6->GetXaxis()->SetRangeUser(tyMin-0.1,tyMax+0.1);
  706. h6->Draw();
  707. h6c->SetLineColor(2); h6c->Draw("same");
  708. TLine *l1c = new TLine(tyMin,0,tyMin,h6->GetMaximum());
  709. TLine *l2c = new TLine(tyMax,0,tyMax,h6->GetMaximum());
  710. l1c->SetLineColor(kBlue); l2c->SetLineColor(kBlue); l1c->SetLineWidth(2); l2c->SetLineWidth(2);
  711. l1c->Draw(); l2c->Draw();
  712. c->cd(9)->SetLeftMargin(0.13);;
  713. addGraphics(h4, 1, "Strip # with cluster", "");
  714. addGraphics(h4a, 2, "Strip # with cluster", "");
  715. h4->GetXaxis()->SetRangeUser(max(iLo-60.0,1.0),min(iHi+60.0,512.0));
  716. h4a->GetXaxis()->SetRangeUser(max(iLo-60.0,1.0),min(iHi+60.0,512.0));
  717. double vmax = h4a->GetMaximum();
  718. //for(int ii=iLo; ii<=iHi;ii++){
  719. // if(h4a->GetBinContent(ii)>vmax) vmax = h4a->GetBinContent(ii);
  720. //}
  721. h4->SetMaximum(1.25*vmax);
  722. TLine *l1d = new TLine(iLo,0,iLo,0.75*h4a->GetMaximum());
  723. TLine *l2d = new TLine(iHi,0,iHi,0.75*h4a->GetMaximum());
  724. l1d->SetLineColor(kBlue); l2d->SetLineColor(kBlue); l1d->SetLineWidth(2); l2d->SetLineWidth(2);
  725. h4->Draw();
  726. h4a->Draw("same");
  727. l1d->Draw(); l2d->Draw();
  728. TLegend* legend4 = new TLegend(0.15,0.70,0.94,0.89);
  729. legend4->SetFillStyle(0);
  730. legend4->SetBorderSize(0);
  731. legend4->SetFillStyle(0);
  732. legend4->SetTextSize(0.045);
  733. legend4->AddEntry(h4,"Sensor strip ch #","L");
  734. legend4->AddEntry(h4a,"Electr. ch #","L");
  735.  
  736. legend4->Draw();
  737.  
  738.  
  739. c->cd(10)->SetLeftMargin(0.13);;
  740. addGraphics(hcAll, 1, "Cluster charge [ADC]", "");
  741. addGraphics(hcTrk1, 3, "Cluster charge [ADC]", "");
  742. addGraphics(hcTrk2, 6, "Cluster charge [ADC]", "");
  743. hcAll->SetMaximum(1.25*hcAll->GetMaximum());
  744. hcAll->Draw();
  745. hcTrk->SetLineColor(kBlue); hcTrk->SetLineWidth(2);
  746. hcTrk->Draw("same");
  747. hcTrk1->Draw("same");
  748. hcTrk2->Draw("same");
  749. TLegend* legend2 = new TLegend(0.15,0.70,0.94,0.89);
  750. legend2->SetFillStyle(0);
  751. legend2->SetBorderSize(0);
  752. legend2->SetFillStyle(0);
  753. legend2->SetTextSize(0.045);
  754. legend2->AddEntry(hcAll,"All clusters, trk in Fid","L");
  755. legend2->AddEntry(hcTrk,"Clusters, |#DeltaX|<200 #mum, trk in Fid.","L");
  756. legend2->AddEntry(hcTrk1,"1-strip Clusters","L");
  757. legend2->AddEntry(hcTrk2,"2-strip Clusters","L");
  758.  
  759. legend2->Draw();
  760.  
  761.  
  762. c->cd(11)->SetLeftMargin(0.13);;
  763. addGraphics(h10a, 1, "Strip #", "<ADC>");
  764. addGraphics(h10b, 2, "Strip #", "<ADC>");
  765. addGraphics(h10c, 4, "Strip #", "<ADC>");
  766. int ixl = iLo;
  767. int ixh = iHi;
  768. int yh = hcTrk->GetMean()-50;
  769. h10a->GetXaxis()->SetRangeUser(ixl-2,ixh+2);
  770. h10a->GetYaxis()->SetRangeUser(yh-200,yh+300);
  771. /*
  772. h10a->Draw();
  773. h10b->SetLineColor(2);h10b->SetMarkerColor(2);
  774. h10b->Draw("same");
  775. h10c->SetLineColor(4);h10c->SetMarkerColor(4);
  776. h10c->Draw("same");
  777.  
  778. TLegend* legend1 = new TLegend(0.25,0.75,0.94,0.89);
  779. legend1->SetFillStyle(0);
  780. legend1->SetBorderSize(0);
  781. legend1->SetFillStyle(0);
  782. legend1->SetTextSize(0.045);
  783. legend1->AddEntry(h10a,"Top half in Y","LEP");
  784. legend1->AddEntry(h10b,"Bottom half in Y","LEP");
  785. legend1->AddEntry(h10c,"Top 2 mm in Y","LEP");
  786. legend1->Draw();
  787. */
  788. addGraphics(h35, 1, "#DUT clusters", "Entries");
  789. h35->GetYaxis()->SetTitleOffset(1.2);
  790. h35->Draw();
  791.  
  792. c->cd(12)->SetLeftMargin(0.13);;
  793. addGraphics(h2p, 1, "TDC time / 2.5 ns", "<ADC>");
  794. h2p->Draw();
  795. TLine *l1e = new TLine(tdcLo,0,tdcLo,h2p->GetMaximum());
  796. TLine *l2e = new TLine(tdcHi,0,tdcHi,h2p->GetMaximum());
  797. l1e->SetLineColor(kBlue); l2e->SetLineColor(kBlue); l1e->SetLineWidth(2); l2e->SetLineWidth(2);
  798. l1e->Draw(); l2e->Draw();
  799.  
  800. c->Print("Plots/plot_"+m_board+"_s"+m_sector+"_vb"+m_bias+".png");
  801.  
  802. //return;
  803.  
  804.  
  805. TCanvas *c4 = new TCanvas("c4","Plot 4",800,600);
  806. c4->Divide(2,2);
  807. c4->cd(1)->SetLeftMargin(0.13);
  808. addGraphics(h12en, 1, "X_{trk} [mm]", "");
  809. addGraphics(h12fn, 1, "X_{trk} [mm]", "");
  810.  
  811. TH1F *hepa1 = (TH1F*)h12en->Clone("hepa1");
  812. TH1F *hepa2 = (TH1F*)h12fn->Clone("hepa2");
  813. TH1F *henpa = (TH1F*)h12gn->Clone("henpa");
  814. hepa1->Divide(h12en,h12ed,1.0,1.0,"B");
  815. hepa2->Divide(h12fn,h12fd,1.0,1.0,"B");
  816. henpa->Divide(h12gn,h12gd,1.0,1.0,"B");
  817. addGraphics(hepa1, 1, "X_{trk} [mm]", "#Good DUT hit / # Track ");
  818. addGraphics(hepa2, 1, "X_{trk} [mm]", "#Good DUT hit / # Track ");
  819. h3b->GetYaxis()->SetRangeUser(-5,5);
  820. h3b->Draw();
  821.  
  822. c4->cd(2)->SetLeftMargin(0.13);
  823. hepa1->GetXaxis()->SetRangeUser(xMin-0.5,xMax+0.5);
  824. hepa1->SetMinimum(0.0);
  825. hepa1->SetMaximum(1.2);
  826. hepa1->SetLineWidth(1);
  827. hepa1->SetTitle(r1);
  828. hepa1->Draw("hist");
  829. c4->cd(3)->SetLeftMargin(0.13);
  830. hepa2->GetXaxis()->SetRangeUser(xMin-0.5,xMax+0.5);
  831. hepa2->SetMinimum(0.0);
  832. hepa2->SetMaximum(1.2);
  833. hepa2->SetLineWidth(1);
  834. hepa2->SetTitle(r2);
  835. hepa2->Draw("hist");
  836.  
  837. c4->cd(4)->SetLeftMargin(0.13);
  838. addGraphics(henpa, 1, "X_{trk} [mm]", "#Good DUT hit / # Track ");
  839. henpa->GetXaxis()->SetRangeUser(xMin-0.5,xMax+0.5);
  840. henpa->SetMinimum(0.0);
  841. henpa->SetMaximum(1.2);
  842. henpa->SetLineWidth(1);
  843. henpa->SetTitle(r3);
  844. henpa->Draw("hist");
  845.  
  846.  
  847. TCanvas *c5 = new TCanvas("c5","Plot 5",800,600);
  848. c5->Divide(2,2);
  849. c5->cd(1)->SetLeftMargin(0.13);
  850. addGraphics(h12hn, 1, "Rel. Strip Pos", "");
  851. addGraphics(h12in, 1, "Rel. Strip Pos", "");
  852. addGraphics(h12jn, 1, "Rel. Strip Pos", "");
  853. addGraphics(h12kn, 1, "Rel. Strip Pos", "");
  854.  
  855. TH1F *hepas1 = (TH1F*)h12hn->Clone("hepas1");
  856. TH1F *hepas2 = (TH1F*)h12in->Clone("hepas2");
  857. TH1F *hepas3 = (TH1F*)h12jn->Clone("hepas3");
  858. TH1F *hepas4 = (TH1F*)h12kn->Clone("hepas4");
  859. hepas1->Divide(h12hn,h12hd,1.0,1.0,"B");
  860. hepas2->Divide(h12in,h12id,1.0,1.0,"B");
  861. hepas3->Divide(h12jn,h12jd,1.0,1.0,"B");
  862. hepas4->Divide(h12kn,h12kd,1.0,1.0,"B");
  863. addGraphics(hepas1, 1, "Rel. Strip Pos.", "#Good DUT hit / # Track ");
  864. addGraphics(hepas2, 1, "Rel. Strip Pos.", "#Good DUT hit / # Track ");
  865. addGraphics(hepas3, 1, "Rel. Strip Pos.", "#Good DUT hit / # Track ");
  866. addGraphics(hepas4, 1, "Rel. Strip Pos.", "#Good DUT hit / # Track ");
  867. hepas1->SetTitle("Full Beam Spot");
  868. hepas1->SetMinimum(0.8);
  869. hepas1->SetMaximum(1.2);
  870. hepas1->SetLineWidth(1);
  871. hepas1->Draw("hist");
  872. c5->cd(2)->SetLeftMargin(0.13);
  873. hepas2->SetTitle(r1);
  874. hepas2->SetMinimum(0.8);
  875. hepas2->SetMaximum(1.2);
  876. hepas2->SetLineWidth(1);
  877. hepas2->Draw("hist");
  878. c5->cd(3)->SetLeftMargin(0.13);
  879. hepas3->SetTitle(r2);
  880. hepas3->SetMinimum(0.8);
  881. hepas3->SetMaximum(1.2);
  882. hepas3->SetLineWidth(1);
  883. hepas3->Draw("hist");
  884. c5->cd(4)->SetLeftMargin(0.13);
  885. hepas4->SetTitle(r3);
  886. hepas4->SetMinimum(0.8);
  887. hepas4->SetMaximum(1.2);
  888. hepas4->SetLineWidth(1);
  889. hepas4->Draw("hist");
  890.  
  891. c5->Print("Plots/plot5_"+m_board+"_s"+m_sector+"_vb"+m_bias+".png");
  892. //return;
  893.  
  894. TCanvas *c1 = new TCanvas("c1","Plot 1",1600,800);
  895. c1->Divide(3,2);
  896.  
  897. c1->cd(1)->SetLeftMargin(0.13);
  898. addGraphics(h10d, 2, "Y_{trk} [mm]", "<ADC>");
  899. h10d->GetXaxis()->SetRangeUser(yMin-0.5,yMax+0.5);
  900. h10d->Draw();
  901.  
  902. //c1->cd(2)->SetLeftMargin(0.13);
  903. //h3b->Draw();
  904.  
  905. c1->cd(2)->SetLeftMargin(0.13);
  906. addGraphics(h12b, 2, "Y_{trk} [mm]", "");
  907. addGraphics(h12a, 1, "Y_{trk} [mm]", "");
  908. h12a->SetMaximum(1.2*h12a->GetMaximum());
  909. h12a->GetXaxis()->SetRangeUser(yMin-0.5,yMax+0.5);
  910. h12a->Draw("hist");
  911. h12b->Draw("hist,same");
  912.  
  913. TLegend* legend0 = new TLegend(0.15,0.75,0.94,0.89);
  914. legend0->SetFillStyle(0);
  915. legend0->SetBorderSize(0);
  916. legend0->SetFillStyle(0);
  917. legend0->SetTextSize(0.045);
  918. legend0->AddEntry(h12a,"Track Y pos","LEP");
  919. legend0->AddEntry(h12b,"Track Y pos with good cluster","LEP");
  920. legend0->Draw();
  921.  
  922. c1->cd(3)->SetLeftMargin(0.13);
  923. TH1F *he = (TH1F*)h12b->Clone("he");
  924. he->Divide(h12b,h12a,1.0,1.0,"B");
  925. float bw = 1000*h12b->GetBinWidth(1);
  926. TString yt = Form("(#Good DUT hit / # Track) / %3.0f #mum",bw);
  927. addGraphics(he, 1, "Y_{trk} [mm]", yt);
  928. he->SetTitle("DUT Efficiency vs Y_{trk}");
  929. he->GetXaxis()->SetRangeUser(yMin-0.5,yMax+0.5);
  930. he->SetMinimum(0.8);
  931. he->SetMaximum(1.1);
  932. he->Draw("e");
  933.  
  934. c1->cd(4)->SetLeftMargin(0.13);
  935. addGraphics(h10e, 2, "X_{trk} [mm]", "<ADC>");
  936. h10e->GetXaxis()->SetRangeUser(xMin-0.5,xMax+0.5);
  937. h10e->Draw();
  938.  
  939. c1->cd(5)->SetLeftMargin(0.13);
  940. addGraphics(h12dd, 2, "X_{trk} [mm]", "");
  941. addGraphics(h12dn, 1, "X_{trk} [mm]", "");
  942. h12dd->SetMaximum(1.2*h12dd->GetMaximum());
  943. h12dd->GetXaxis()->SetRangeUser(xMin-0.5,xMax+0.5);
  944. h12dd->Draw("hist");
  945. h12dn->Draw("hist,same");
  946.  
  947. c1->cd(6)->SetLeftMargin(0.13);
  948. TH1F *he2 = (TH1F*)h12dn->Clone("he");
  949. he2->Divide(h12dn,h12dd,1.0,1.0,"B");
  950. bw = 1000*h12dd->GetBinWidth(1);
  951. yt = Form("(#Good DUT hit / # Track) / %3.0f #mum",bw);
  952. addGraphics(he2, 1, "X_{trk} [mm]", yt);
  953. he2->SetTitle("DUT Efficiency vs X_{trk}");
  954. he2->GetXaxis()->SetRangeUser(xMin-0.5,xMax+0.5);
  955. he2->SetMinimum(0.8);
  956. he2->SetMaximum(1.1);
  957. he2->Draw("e");
  958. c1->Print("Plots/plot1_"+m_board+"_s"+m_sector+"_vb"+m_bias+".png");
  959.  
  960. TCanvas *c8 = new TCanvas("c8","Plot 8",800,400);
  961. c8->Divide(2,1);
  962. TH1F *he4 = (TH1F*)h15c->Clone("Eff_trigger-DUT_time");
  963. he4->Divide(h15c,h16c,1.0,1.0,"B");
  964. yt = "#Good DUT hit / # Track";
  965. addGraphics(h16c, 1, "DUT time - Track Time (ns)", "Entries");
  966. addGraphics(he4, 1, "DUT time - Track Time (ns)", "Efficiency");
  967. c8->cd(1)->SetLeftMargin(0.15);;
  968. c8->cd(1)->SetRightMargin(0.05);;
  969. h16c->Draw();
  970. c8->cd(2)->SetLeftMargin(0.13);;
  971. c8->cd(2)->SetRightMargin(0.05);;
  972. he4->Draw();
  973. c8->Print("Plots/plot8_"+m_board+"_s"+m_sector+"_vb"+m_bias+".png");
  974.  
  975. if(holeSector){
  976. TCanvas *c7 = new TCanvas("c7","Plot 7",800,800);
  977. c7->SetLeftMargin(0.13);
  978. TH1F *he3 = (TH1F*)h12on->Clone("Erf()_fit");
  979. he3->Divide(h12on,h12od,1.0,1.0,"B");
  980. bw = 1000*h12od->GetBinWidth(1);
  981. yt = Form("(#Good DUT hit / # Track) / %3.0f #mum",bw);
  982. addGraphics(he3, 1, "Dist to cutout [mm]", yt);
  983. he3->SetStats(kTRUE);
  984. he3->SetTitle("DUT Efficiency vs Dist to Cutout");
  985. he3->GetXaxis()->SetRangeUser(-0.2,2.0);
  986. he3->GetYaxis()->SetRangeUser(0.0,1.3);
  987. he3->Draw("e");
  988. TLatex *myLatex = new TLatex();
  989. myLatex->SetTextFont(42); myLatex->SetTextColor(1);
  990. myLatex->SetTextAlign(12); myLatex->SetNDC(kTRUE); myLatex->SetTextSize(0.047);
  991. TString text = "Sector "+m_sector;
  992. c7->cd();
  993. myLatex->DrawLatex(0.18,0.8,text);
  994. TF1 *f4a = new TF1("f4a","0.5*[0]*(1+TMath::Erf((x-[1])/[2]))",-0.1,2.0);
  995. f4a->SetParameters(0.5,0.0,0.04);
  996. f4a->SetParNames("Const","Mean","Sigma");
  997. he3->Fit("f4a","R");
  998. TPad *inset = new TPad("inset","y vx x",0.44,0.1,0.89,0.55);
  999. inset->SetLeftMargin(0.13);
  1000. inset->SetRightMargin(0.05);
  1001. h3->SetTitle("");
  1002. inset->Draw();
  1003. inset->cd();
  1004. h3->Draw();
  1005. h3b->SetMarkerSize(0.2);h3b->SetMarkerStyle(20);h3b->SetMarkerColor(kRed);
  1006. h3b->Draw("same");
  1007. if(holeQuadPar[0]!=0) funchole->Draw("same");
  1008. c7->Print("Plots/plot7_"+m_board+"_s"+m_sector+"_vb"+m_bias+".png");
  1009. }
  1010. /*
  1011. TCanvas *c2 = new TCanvas("c2","Plot 2",1600,600);
  1012. c2->Divide(5,2);
  1013. addGraphics(h1mpa, 2, "X_{clu}-X_{trk} [mm]", ""); h1mpa->SetTitle("2.8<Y_{trk}<4.1 mm, All X, No Match Clu");
  1014. addGraphics(h1mbpa, 4, "X_{clu}-X_{trk} [mm]", ""); h1mbpa->SetTitle("1.0<Y_{trk}<2.3 mm, All X, No Match Clu");
  1015. addGraphics(h1fpa, 1, "X_{clu}-X_{trk} [mm]", ""); h1fpa->SetTitle("2.8<Y_{trk}<4.1 mm, All X, Match Clu");
  1016. addGraphics(h1fbpa, 1, "X_{clu}-X_{trk} [mm]", ""); h1fbpa->SetTitle("1.0<Y_{trk}<2.3 mm, All X, Match Clu");
  1017.  
  1018. addGraphics(h1mpa1, 2, "X_{clu}-X_{trk} [mm]", ""); h1mpa1->SetTitle("2.8<Y_{trk}<4.1 mm, -3.5<X_{trk}<-2.0 mm, No Match Clu");
  1019. addGraphics(h1mpa2, 2, "X_{clu}-X_{trk} [mm]", ""); h1mpa2->SetTitle("2.8<Y_{trk}<4.1 mm, -2.0<X_{trk}<-1.0 mm, No Match Clu");
  1020. addGraphics(h1mpa3, 2, "X_{clu}-X_{trk} [mm]", ""); h1mpa3->SetTitle("2.8<Y_{trk}<4.1 mm, -1.0<X_{trk}<0.0 mm, No Match Clu");
  1021. addGraphics(h1mpa4, 2, "X_{clu}-X_{trk} [mm]", ""); h1mpa4->SetTitle("2.8<Y_{trk}<4.1 mm, 0.0<X_{trk}<1.0 mm, No Match Clu");
  1022. addGraphics(h1mpa5, 2, "X_{clu}-X_{trk} [mm]", ""); h1mpa5->SetTitle("2.8<Y_{trk}<4.1 mm, 1.5<X_{trk}<3.5 mm, No Match Clu");
  1023. h1mpa->SetLineWidth(1);
  1024. h1mpa1->SetLineWidth(1);
  1025. h1mpa2->SetLineWidth(1);
  1026. h1mpa3->SetLineWidth(1);
  1027. h1mpa4->SetLineWidth(1);
  1028. h1mpa5->SetLineWidth(1);
  1029. h1fpa->SetLineWidth(1);
  1030. h1fbpa->SetLineWidth(1);
  1031.  
  1032. h1fpa->GetXaxis()->SetRangeUser(-3,9);
  1033. h1fbpa->GetXaxis()->SetRangeUser(-3,9);
  1034. h1mbpa->GetXaxis()->SetRangeUser(-3,9);
  1035. h1mpa->GetXaxis()->SetRangeUser(-3,9);
  1036. h1mpa1->GetXaxis()->SetRangeUser(-3,9);
  1037. h1mpa2->GetXaxis()->SetRangeUser(-3,9);
  1038. h1mpa3->GetXaxis()->SetRangeUser(-3,9);
  1039. h1mpa4->GetXaxis()->SetRangeUser(-3,9);
  1040. h1mpa5->GetXaxis()->SetRangeUser(-3,9);
  1041.  
  1042. c2->cd(1);
  1043. h3b->Draw();
  1044. double xl[5] = {-3.5, -2.0, -1.0, 0.0, 1.5};
  1045. double xh[5] = {-2.0, -1.0, 0.0, 1.0, 3.5};
  1046. for(int i=0;i<5;i++){
  1047. TBox *b = new TBox(xl[i],yInt1[0],xh[i],yInt2[1]);
  1048. b->SetLineColor(2); b->SetFillStyle(0);b->SetLineWidth(2);
  1049. b->Draw();
  1050. }
  1051. TBox *b = new TBox(xl[0],yInt3[0],xh[4],yInt3[1]);
  1052. b->SetLineColor(4);b->SetFillStyle(0);b->SetLineWidth(2);
  1053. b->Draw();
  1054.  
  1055.  
  1056. c2->cd(2);
  1057. h1mpa->Draw();
  1058. c2->cd(3);
  1059. h1fpa->GetYaxis()->SetRangeUser(0,30);
  1060. h1fpa->Draw();
  1061. c2->cd(4);
  1062. h1mbpa->Draw();
  1063. c2->cd(5);
  1064. h1fbpa->GetYaxis()->SetRangeUser(0,30);
  1065. h1fbpa->Draw();
  1066. c2->cd(6);
  1067. h1mpa1->Draw();
  1068. c2->cd(7);
  1069. h1mpa2->Draw();
  1070. c2->cd(8);
  1071. h1mpa3->Draw();
  1072. c2->cd(9);
  1073. h1mpa4->Draw();
  1074. c2->cd(10);
  1075. h1mpa5->Draw();
  1076. c2->Print("Plots/plot2_"+m_board+"_s"+m_sector+"_vb"+m_bias+".png");
  1077. */
  1078.  
  1079. /*
  1080. TCanvas *c3 = new TCanvas("c3","Plot 3",800,600);
  1081. c3->Divide(1,2);
  1082. c3->cd(1);
  1083. h1mpaU->GetXaxis()->SetRangeUser(iLo-10,iHi+10);
  1084. h1mpaU->Draw();
  1085. c3->cd(2);
  1086. h1mpaL->GetXaxis()->SetRangeUser(iLo-10,iHi+10);
  1087. h1mpaL->Draw();
  1088. c3->Print("Plots/plot3_"+m_board+"_s"+m_sector+"_vb"+m_bias+".png");
  1089. */
  1090.  
  1091. addGraphics(h12m,1,"Interstrip Pos","<ADC>");
  1092. addGraphics(h12n,1,"Interstrip Pos","<Cluster Size>");
  1093. TCanvas *c6 = new TCanvas("c6","Plot 6",1200,400);
  1094. c6->Divide(3,1);
  1095. c6->cd(1);
  1096. hepas1->SetMaximum(1.2);
  1097. hepas1->SetMinimum(0.5);
  1098. hepas1->Draw();
  1099. c6->cd(2);
  1100. h12m->SetMinimum(0);
  1101. h12m->SetMaximum(1.2*h12m->GetMaximum());
  1102. h12m->Draw();
  1103. c6->cd(3);
  1104. h12n->SetMinimum(0.5);
  1105. h12n->SetMaximum(2.0);
  1106. h12n->Draw();
  1107. c6->Print("Plots/plot6_"+m_board+"_s"+m_sector+"_vb"+m_bias+".png");
  1108.  
  1109.  
  1110. fout->Write();
  1111.  
  1112. }