Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:33:49

0001 //
0002 //  Plots from StripClusterMCanalysis
0003 //
0004 
0005 /*
0006 Generate plots produced exhibiting properties of Si strip clusters and 
0007 their associated simTracks and simHits.
0008  */
0009 
0010 void stripClusterMCplot(const char* ntupleFile="clusNtuple.root") {
0011 
0012   gROOT->Reset();
0013 
0014   // use the 'plain' style for plots (white backgrounds, etc)
0015   cout << "...using style 'Plain'\n";
0016 
0017   gROOT->SetStyle("Plain");
0018 
0019   // use bold lines and markers
0020   gStyle->SetMarkerStyle(8);  // non-scalable dot
0021   gStyle->SetHistLineWidth(2);
0022   gStyle->SetLineStyleString(2,"[12 12]"); // postscript dashes
0023 
0024   // For the fit/function:
0025   gStyle->SetOptFit(1);
0026   gStyle->SetFitFormat("5.4g");
0027   gStyle->SetFuncColor(4);
0028   gStyle->SetFuncStyle(1);
0029   gStyle->SetFuncWidth(2);
0030 
0031   //..Get rid of X error bars
0032   gStyle->SetErrorX(0.001);
0033 
0034   // do not display any of the standard histogram decorations
0035   gStyle->SetOptTitle(0);
0036 
0037   // put tick marks on top and RHS of plots
0038   gStyle->SetPadTickX(1);
0039   gStyle->SetPadTickY(1);
0040   gStyle->SetHistLineWidth(2);
0041 
0042   //  ===============================================================
0043 
0044   double Pi = 2*acos(0);
0045 
0046   const TCut oneSimHit = "NsimHits == 1";
0047   const TCut twoSimHit = "NsimHits == 2";
0048   const TCut threeSimHit = "NsimHits == 3";
0049   const TCut fourSimHit = "NsimHits == 4";
0050   const TCut oneTp = "Ntp == 1";
0051   const TCut twoTp = "Ntp == 2";
0052   const TCut threeTp = "Ntp == 3";
0053   const TCut fourTp = "Ntp == 4";
0054 
0055   // // Following are for the old process ID scheme
0056   // const TCut primary = "firstProcess == 2";
0057   // const TCut primarytwo = primary && "secondProcess == 2";
0058   // const TCut primarythree = primarytwo && "thirdProcess == 2";
0059   // const TCut primaryfour = primarythree && "fourthProcess == 2";
0060   // const TCut primDec = "firstProcess == 2 || firstProcess == 4";
0061   // const TCut primDectwo = primDec && "(secondProcess == 2 || secondProcess == 4)";
0062   // const TCut primDecthree = primDectwo && "(thirdProcess == 2 || thirdProcess == 4)";
0063   // const TCut primDecfour = primDecthree && "(fourthProcess == 2 || fourthProcess == 4)";
0064 
0065 //
0066 //  Particle interaction process codes for the new scheme are found in
0067 // SimG4Core/Physics/src/G4ProcessTypeEnumerator.cc
0068 // See also https://twiki.cern.ch/twiki/bin/view/CMSPublic/SWGuideMCTruth
0069 //
0070   const TCut primary = "firstProcess == 0";
0071   const TCut primarytwo = primary && "secondProcess == 0";
0072   const TCut primarythree = primarytwo && "thirdProcess == 0";
0073   const TCut primaryfour = primarythree && "fourthProcess == 0";
0074   const TCut primDec = "firstProcess >= 201 && firstProcess <= 203";
0075   const TCut primDectwo = primDec && "(secondProcess >= 201 && secondProcess <= 203)";
0076   const TCut primDecthree = primDectwo && "(thirdProcess >= 201 && thirdProcess <= 203)";
0077   const TCut primDecfour = primDecthree && "(fourthProcess >= 201 && fourthProcess <= 203)";
0078 
0079   const TCut chgPi = "abs(firstPID) == 211";
0080   const TCut chgPitwo = chgPi && "abs(secondPID) == 211";
0081   const TCut chgPithree = chgPitwo && "abs(thirdPID) == 211";
0082   const TCut chgPifour = chgPithree && "abs(fourthPID) == 211";
0083   const TCut chgNotEp = "abs(firstPID) == 13 || abs(firstPID) == 211 || abs(firstPID) == 321";
0084   const TCut chgNotEptwo = chgNotEp && "(abs(secondPID) == 13 || abs(secondPID) == 211 || abs(secondPID) == 321)";
0085   const TCut chgNotEpthree = chgNotEptwo && "(abs(thirdPID) == 13 || abs(thirdPID) == 211 || abs(thirdPID) == 321)";
0086   const TCut chgNotEpfour = chgNotEpthree && "(abs(fourthPID) == 13 || abs(fourthPID) == 211 || abs(fourthPID) == 321)";
0087   const TCut chgNotE = "abs(firstPID) == 13 || abs(firstPID) == 211 || abs(firstPID) == 321 || abs(firstPID) == 2212";
0088   const TCut chgNotEtwo = chgNotE && "(abs(secondPID) == 13 || abs(secondPID) == 211 || abs(secondPID) == 321 || abs(secondPID) == 2212)";
0089   const TCut chgNotEthree = chgNotEtwo && "(abs(thirdPID) == 13 || abs(thirdPID) == 211 || abs(thirdPID) == 321 || abs(thirdPID) == 2212)";
0090   const TCut chgNotEfour = chgNotEthree && "(abs(fourthPID) == 13 || abs(fourthPID) == 211 || abs(fourthPID) == 321 || abs(fourthPID) == 2212)";
0091   const TCut chg = "abs(firstPID) == 11 || abs(firstPID) == 13 || abs(firstPID) == 211 || abs(firstPID) == 321 || abs(firstPID) == 2212";
0092   const TCut chgtwo = chg && "(abs(secondPID) == 11 || abs(secondPID) == 13 || abs(secondPID) == 211 || abs(secondPID) == 321 || abs(secondPID) == 2212)";
0093   const TCut chgthree = chg && "(abs(thirdPID) == 11 || abs(thirdPID) == 13 || abs(thirdPID) == 211 || abs(thirdPID) == 321 || abs(thirdPID) == 2212)";
0094   const TCut chgtwofour = chg && "(abs(fourthPID) == 11 || abs(fourthPID) == 13 || abs(fourthPID) == 211 || abs(fourthPID) == 321 || abs(fourthPID) == 2212)";
0095 
0096   const TCut Pmin = "firstPmag > 1";
0097   const TCut Pmintwo = Pmin && "secondPmag > 1";
0098   const TCut Pminthree = Pmintwo && "thirdPmag > 1";
0099   const TCut Pminfour = Pminthree && "fourthPmag > 1";
0100   const TCut saturated = "sat == 1";
0101   const TCut notEMnoise = "abs(firstPID) != 11 && firstPID != 22 && firstPID != 0";
0102   const TCut sym = "abs(firstTkChg-secondTkChg)/(firstTkChg+secondTkChg) < 0.9";
0103 
0104   void drawStats(TH1* hist, double& top);
0105   void plot_Ncross(TTree* tp);
0106   void plot_process(TTree* tp, const TCut& cut);
0107   void plot_process2(TTree* tp, const TCut& cut);
0108   void plot_PID(TTree* tree);
0109   void plot_PIDzoom(TTree* tree);
0110   void plot_Pmag(TTree* tree, const TCut& cut);
0111   void plot_charge(TTree* tree, const TCut& cut);
0112   void plot_Eloss(TTree* tree, const TCut& cut);
0113   void plot_chargeEloss(TTree* tree, const TCut& cut);
0114   void plot_width(TTree* tree, const TCut& cut);
0115   void plot_path(TTree* tree, const TCut& cut);
0116   void plot_path1(TTree* tree, const TCut& cut);
0117   void plot_NormCharge(TTree* tree, const TString& MIPdEdx, const TCut& cut1, const TCut& cut2, const TCut& cut3);
0118   void plot_NormEloss(TTree* tree, const TString& MIPdEdx, const TCut& cut1, const TCut& cut2, const TCut& cut3);
0119   void plot_chgTotPath(TTree* tree, const TString& MIPdEdx, const TCut& cut0, const TCut& cut1, const TCut& cut2, const TCut& cut3,
0120                const char* title0, const char* title1, const char* title2, const char* title3 );
0121   void plot_ChgTnrm_v_Snrm(TTree* tree, const TString& MIPdEdx, const TCut& cut1, const TCut& cut2, const TCut& cut3);
0122   void plot_NormChgSpl(TTree* tree, const TString& MIPdEdx, const TCut& cut);
0123   void plot_NormChgNtp(TTree* tree, const TString& MIPdEdx, const TCut& cut);
0124   void plot_NrmChgWid(TTree* tree, const TString& MIPdEdx);
0125   void plot_ChgPath(TTree* tree, const TCut& cut);
0126   void plot_ChgAsym(TTree* tree, const TString& MIPdEdx, const TCut& cut);
0127   void plot_Asym(TTree* tree, const TCut& cut);
0128 
0129   TFile tfile(ntupleFile);
0130 
0131   TTree* clTree;
0132   if (tfile.Get("makeNtuple/ClusterNtuple")) 
0133     clTree = (TTree*) tfile.Get("makeNtuple/ClusterNtuple");
0134   else if (tfile.Get("ClusterNtuplizer/ClusterNtuple"))
0135     clTree = (TTree*) tfile.Get("ClusterNtuplizer/ClusterNtuple");
0136   else if (tfile.Get("StripClusterMCanalysis/ClusterNtuple"))
0137     clTree = (TTree*) tfile.Get("StripClusterMCanalysis/ClusterNtuple");
0138   else {
0139     cout << "No ntuple found in this file and directory" << endl;
0140     return;
0141   }
0142 
0143   // clTree->Print();
0144 
0145   TDirectory *rootdir = gDirectory->GetDirectory("Rint:"); // Without these 2 lines
0146   rootdir->cd();                     // the histo disappears when the macro exits.
0147 
0148 // 298 ADC counts per mm for MIP:
0149 #define MIPdEdxVal 3.36e-4
0150   char scharge[80];  sprintf(scharge, "%10.3e", MIPdEdxVal);
0151   TString MIPdEdx(scharge);
0152   cout << "MIPdEdx = " << MIPdEdx << endl;
0153 
0154   gStyle->SetOptStat("ormen");  plot_Ncross(clTree);
0155   gStyle->SetOptStat("orme");  plot_width(clTree, oneSimHit&&!saturated&&primary&&notEMnoise&&Pmin);
0156   gStyle->SetOptStat("euo");  plot_process(clTree, oneSimHit);
0157 //   gStyle->SetOptStat(0);  plot_process2(clTree, twoTp);
0158   gStyle->SetOptStat(0);  plot_PID(clTree);
0159   gStyle->SetOptStat(0);  plot_PIDzoom(clTree);
0160   gStyle->SetOptStat("ormen");  plot_Pmag(clTree, oneSimHit&&!saturated&&primary&&chgNotE&&Pmin);
0161   gStyle->SetOptStat("ormen");  plot_charge(clTree, oneSimHit);
0162   gStyle->SetOptStat("ormen");  plot_Eloss(clTree, oneSimHit);
0163   gStyle->SetOptStat("ormen");  plot_chargeEloss(clTree, oneSimHit);
0164   gStyle->SetOptStat("oen");  plot_path(clTree, oneSimHit&&!saturated&&primary&&chgNotE&&Pmin);
0165   gStyle->SetOptStat("oen");  plot_path1(clTree, oneSimHit&&!saturated&&primary&&chgNotE&&Pmin);
0166   gStyle->SetOptStat("oen");  plot_NormCharge(clTree, MIPdEdx, oneSimHit&&!saturated&&primary&&chgNotE, twoTp&&!saturated&&sym, twoTp&&twoSimHit&&!saturated&&primarytwo&&chgNotEtwo&&sym);
0167   gStyle->SetOptStat("oen");  plot_NormEloss(clTree, (const TString)"350.", oneSimHit&&!saturated&&primary&&chgNotE, twoTp&&!saturated&&sym, twoTp&&twoSimHit&&!saturated&&primarytwo&&chgNotEtwo&&sym);
0168 
0169 // //   gStyle->SetOptStat("oen");  plot_chgTotPath(clTree, MIPdEdx, oneSimHit&&!saturated, oneSimHit&&!saturated&&primary&&chgNotE, twoSimHit&&!saturated, twoTp&&twoSimHit&&!saturated&&primarytwo&&chgNotEtwo, "One hit", "One primary", "Two hits", "Two primaries");
0170 // //   gStyle->SetOptStat("oen");  plot_chgTotPath(clTree, MIPdEdx, oneSimHit&&!saturated, twoSimHit&&!saturated, threeSimHit&&!saturated, fourSimHit&&!saturated, "One hit", "Two hits", "Three hits", "Four hits");
0171 // //   gStyle->SetOptStat("oen");  plot_chgTotPath(clTree, MIPdEdx, oneSimHit&&!saturated&&primary&&chgNotE, twoTp&&twoSimHit&&!saturated&&primarytwo&&chgNotEtwo, threeTp&&threeSimHit&&!saturated&&primarythree&&chgNotEthree, fourTp&&fourSimHit&&!saturated&&primaryfour&&chgNotEfour, "One primary", "Two primaries", "Three primaries", "Four primaries");
0172 
0173   gStyle->SetOptStat("oen");  plot_ChgTnrm_v_Snrm(clTree, MIPdEdx, oneSimHit&&!saturated&&primary&&chgNotE, twoTp&&!saturated&&sym, twoTp&&twoSimHit&&!saturated&&primarytwo&&chgNotEtwo&&sym);
0174 //   //  With no truth info for black and green curves:
0175 //   gStyle->SetOptStat("oen");  plot_ChgTnrm_v_Snrm(clTree, MIPdEdx, !saturated, twoTp&&!saturated&&sym, twoTp&&twoSimHit&&!saturated&&primarytwo&&chgNotEtwo&&sym);
0176 // //   gStyle->SetOptStat("orme");  plot_NormChgSpl(clTree, MIPdEdx, split);
0177 //   gStyle->SetOptStat(0);  plot_NormChgNtp(clTree, MIPdEdx, !saturated);
0178 //   gStyle->SetOptStat(0);  plot_NrmChgWid(clTree, MIPdEdx);
0179 //   gStyle->SetOptStat("oen");  plot_ChgPath(clTree, twoTp&&twoSimHit&&!saturated&&primarytwo&&chgNotEtwo&&sym);
0180   gStyle->SetOptStat("oen");  plot_ChgAsym(clTree, MIPdEdx, twoTp&&twoSimHit&&!saturated&&primarytwo&&chgNotEtwo);
0181   gStyle->SetOptStat("oen");  plot_Asym(clTree, twoTp&&twoSimHit&&!saturated&&primarytwo&&chgNotEtwo);
0182 
0183 //   clTree->draw("secondPmag:firstPmag", "twoTp&&twoSimHit", "box");
0184 //   clTree->draw("secondPmag:firstPmag");
0185 //   clTree->Draw("charge:firstTkChg+secondTkChg",
0186 //        "Ntp==2&&NsimHits==2&&abs(firstPID)==211&&abs(secondPID)==211&&firstProcess==2&&secondProcess==2&&sat==0&&subDet==3","box");
0187 //   clTree->Draw("secondProcess:firstProcess","Ntp==2&&NsimHits==2&&sat==0&&subDet==3","box");
0188 //   clTree->Draw("abs(firstTkChg-secondTkChg)/(firstTkChg+secondTkChg)", "Ntp==2&&NsimHits==2&&abs(firstPID)==211&&abs(secondPID)==211&&firstProcess==2&&secondProcess==2&&sat==0&&subDet==3");
0189 //   clTree->Draw("abs(firstTkChg-secondTkChg)/(firstTkChg+secondTkChg):firstTkChg+secondTkChg", "Ntp==2&&NsimHits==2&&abs(firstPID)==211&&abs(secondPID)==211&&firstProcess==2&&secondProcess==2&&sat==0&&subDet==3","box");
0190 //   clTree->Draw("(1-2*tkFlip)*(firstTkChg-secondTkChg)/(firstTkChg+secondTkChg)", "Ntp==2&&NsimHits==2&&abs(firstPID)==211&&abs(secondPID)==211&&firstProcess==2&&secondProcess==2&&sat==0&&subDet==3");
0191 
0192 }  // ---------------------------------------------------------------
0193 
0194 void drawStats(TH1* hist, double& top) {
0195   TPaveStats* stats = (TPaveStats*)hist->FindObject("stats");
0196   if (stats) {
0197     stats->SetLineColor(hist->GetLineColor());
0198     stats->SetTextColor(hist->GetLineColor());
0199     double height = stats->GetY2NDC()-stats->GetY1NDC();
0200     if (top != 0.0) {
0201       stats->SetY2NDC(top);
0202       stats->SetY1NDC(top - height);
0203     }
0204     top = stats->GetY1NDC() - 0.005;
0205     stats->Draw();
0206   }
0207 }  // ---------------------------------------------------------------
0208 
0209 void plot_Ncross(TTree* tree) {
0210 
0211   TCanvas *canv1 = new TCanvas("canv1", "canv1", 700, 500);
0212 
0213   TH1F* hNtp = new TH1F("hNtp", "No. of crossing simTracks", 10, 0, 10);
0214   tree->Project("hNtp", "Ntp");
0215   hNtp->GetXaxis()->SetTitle("No. of track crossings");
0216   hNtp->SetLineColor(kBlue);
0217   hNtp->Draw();
0218 
0219   TH1F* hNhit = new TH1F("hNhit", "No. of SimHits", 10, 0, 10);
0220   tree->Project("hNhit", "NsimHits");
0221   hNhit->GetXaxis()->SetTitle("No. of SimHits");
0222   hNhit->SetLineColor(kRed);
0223   hNhit->Draw("sames");
0224 
0225   canv1->Update();  // without this the "stats" pointers are null
0226   double top = 0.0;
0227   drawStats(hNtp, top);
0228   drawStats(hNhit, top);
0229   canv1->Update();
0230 
0231   TLegend* Rtlegend = new TLegend(.32, .65, .72, .80, "");
0232   Rtlegend->AddEntry(hNtp, "simTracks", "L");
0233   Rtlegend->AddEntry(hNhit, "SimHits", "L");
0234   Rtlegend->Draw();
0235   canv1->Update();
0236 
0237   canv1->SaveAs("clusNtp_Ncross.pdf");
0238 
0239 }  // ---------------------------------------------------------------
0240 
0241 void plot_process(TTree* tree, const TCut& cut) {
0242 
0243   TCanvas *canv2 = new TCanvas("canv2", "canv2", 700, 500);
0244 
0245   TH1F* hProcess = new TH1F("hProcess", "Process that produced hit", 210, 0, 210);
0246   tree->Project("hProcess", "firstProcess", cut);
0247   hProcess->GetXaxis()->SetTitle("Process code");
0248   hProcess->SetLineColor(kBlue);
0249   hProcess->Draw();
0250 
0251   canv2->Update();  // without this the "stats" pointers are null
0252 
0253   canv2->SaveAs("clusNtp_process.pdf");
0254 
0255 }  // ---------------------------------------------------------------
0256 
0257 /*
0258 void plot_process(TTree* tree, const TCut& cut) {
0259 
0260   TCanvas *canv2 = new TCanvas("canv2", "canv2", 700, 500);
0261 
0262   TH1F* hProcess = new TH1F("hProcess", "Process that produced hit", 20, 0, 20);
0263   tree->Project("hProcess", "firstProcess", cut);
0264 //   hProcess->GetXaxis()->SetTitle("Process that produced simHit");
0265   hProcess->GetXaxis()->SetTitle("");
0266   hProcess->SetLineColor(kBlue);
0267   hProcess->GetXaxis()->SetBinLabel(1, "Undefined");
0268   hProcess->GetXaxis()->SetBinLabel(2, "Unknown");
0269   hProcess->GetXaxis()->SetBinLabel(3, "Primary");
0270   hProcess->GetXaxis()->SetBinLabel(4, "Hadronic");
0271   hProcess->GetXaxis()->SetBinLabel(5, "Decay");
0272   hProcess->GetXaxis()->SetBinLabel(6, "Compton");
0273   hProcess->GetXaxis()->SetBinLabel(7, "Annihilation");
0274   hProcess->GetXaxis()->SetBinLabel(8, "EIoni");
0275   hProcess->GetXaxis()->SetBinLabel(9, "HIoni");
0276   hProcess->GetXaxis()->SetBinLabel(10, "MuIoni");
0277   hProcess->GetXaxis()->SetBinLabel(11, "Photon");
0278   hProcess->GetXaxis()->SetBinLabel(12, "MuPairProd");
0279   hProcess->GetXaxis()->SetBinLabel(13, "Conversions");
0280   hProcess->GetXaxis()->SetBinLabel(14, "EBrem");
0281   hProcess->GetXaxis()->SetBinLabel(15, "SynchrotronRadiation");
0282   hProcess->GetXaxis()->SetBinLabel(16, "MuBrem");
0283   hProcess->GetXaxis()->SetBinLabel(17, "MuNucl");
0284   hProcess->Draw();
0285 
0286 //   canv2->SetBottomMargin(.2);
0287 //   gStyle->SetTitleOffset(1.1, "x");
0288 
0289   canv2->Update();  // without this the "stats" pointers are null
0290 
0291   canv2->SaveAs("clusNtp_process.pdf");
0292 
0293 }  // ---------------------------------------------------------------
0294 
0295 void plot_process2(TTree* tree, const TCut& cut) {
0296 
0297   TCanvas *canvProc2 = new TCanvas("canvProc2", "canvProc2", 700, 500);
0298 
0299   TH2F* hProcess2 = new TH2F("hProcess2", "Processes that produced hits", 210, 0, 210, 210, 0, 210);
0300   tree->Project("hProcess2", "secondProcess:firstProcess", cut);
0301 //   hProcess2->GetXaxis()->SetTitle("Process that produced simHit");
0302   hProcess2->SetLineColor(kBlue);
0303   hProcess2->GetXaxis()->SetTitle("");
0304   hProcess2->GetXaxis()->SetBinLabel(1, "Undefined");
0305   hProcess2->GetXaxis()->SetBinLabel(2, "Unknown");
0306   hProcess2->GetXaxis()->SetBinLabel(3, "Primary");
0307   hProcess2->GetXaxis()->SetBinLabel(4, "Hadronic");
0308   hProcess2->GetXaxis()->SetBinLabel(5, "Decay");
0309   hProcess2->GetXaxis()->SetBinLabel(6, "Compton");
0310   hProcess2->GetXaxis()->SetBinLabel(7, "Annihilation");
0311   hProcess2->GetXaxis()->SetBinLabel(8, "EIoni");
0312   hProcess2->GetXaxis()->SetBinLabel(9, "HIoni");
0313   hProcess2->GetXaxis()->SetBinLabel(10, "MuIoni");
0314   hProcess2->GetXaxis()->SetBinLabel(11, "Photon");
0315   hProcess2->GetXaxis()->SetBinLabel(12, "MuPairProd");
0316   hProcess2->GetXaxis()->SetBinLabel(13, "Conversions");
0317   hProcess2->GetXaxis()->SetBinLabel(14, "EBrem");
0318   hProcess2->GetXaxis()->SetBinLabel(15, "SynchrotronRadiation");
0319   hProcess2->GetXaxis()->SetBinLabel(16, "MuBrem");
0320   hProcess2->GetXaxis()->SetBinLabel(17, "MuNucl");
0321   hProcess2->GetYaxis()->SetTitle("");
0322   hProcess2->GetYaxis()->SetBinLabel(1, "Undefined");
0323   hProcess2->GetYaxis()->SetBinLabel(2, "Unknown");
0324   hProcess2->GetYaxis()->SetBinLabel(3, "Primary");
0325   hProcess2->GetYaxis()->SetBinLabel(4, "Hadronic");
0326   hProcess2->GetYaxis()->SetBinLabel(5, "Decay");
0327   hProcess2->GetYaxis()->SetBinLabel(6, "Compton");
0328   hProcess2->GetYaxis()->SetBinLabel(7, "Annihilation");
0329   hProcess2->GetYaxis()->SetBinLabel(8, "EIoni");
0330   hProcess2->GetYaxis()->SetBinLabel(9, "HIoni");
0331   hProcess2->GetYaxis()->SetBinLabel(10, "MuIoni");
0332   hProcess2->GetYaxis()->SetBinLabel(11, "Photon");
0333   hProcess2->GetYaxis()->SetBinLabel(12, "MuPairProd");
0334   hProcess2->GetYaxis()->SetBinLabel(13, "Conversions");
0335   hProcess2->GetYaxis()->SetBinLabel(14, "EBrem");
0336   hProcess2->GetYaxis()->SetBinLabel(15, "SynchrotronRadiation");
0337   hProcess2->GetYaxis()->SetBinLabel(16, "MuBrem");
0338   hProcess2->GetYaxis()->SetBinLabel(17, "MuNucl");
0339   hProcess2->Draw("box");
0340 
0341 //   canvProc2->SetBottomMargin(.2);
0342 //   gStyle->SetTitleOffset(1.1, "x");
0343 
0344   canvProc2->Update();  // without this the "stats" pointers are null
0345 
0346   canvProc2->SaveAs("clusNtp_process2.pdf");
0347 
0348 }  
0349 */
0350 
0351 // ---------------------------------------------------------------
0352 
0353 void plot_PID(TTree* tree) {
0354 
0355   TCanvas *canvPID = new TCanvas("canvPID", "canvPID", 700, 500);
0356 
0357   TH1F* hPID = new TH1F("hPID", "Particle ID", 600, -3000, 3000);
0358   tree->Project("hPID", "firstPID");
0359   hPID->GetXaxis()->SetTitle("Particle ID");
0360   hPID->Draw();
0361 
0362   canvPID->Update();  // without this the "stats" pointers are null
0363 
0364   canvPID->SaveAs("clusNtp_PID.pdf");
0365 
0366 }  // ---------------------------------------------------------------
0367 
0368 void plot_PIDzoom(TTree* tree) {
0369 
0370   TCanvas *canvPIDzoom = new TCanvas("canvPIDzoom", "canvPIDzoom", 700, 500);
0371 
0372   TH1F* hPIDzoom = new TH1F("hPIDzoom", "Particle ID", 800, -400, 400);
0373   tree->Project("hPIDzoom", "firstPID");
0374   hPIDzoom->GetXaxis()->SetTitle("Particle ID");
0375   hPIDzoom->Draw();
0376 
0377   canvPIDzoom->Update();  // without this the "stats" pointers are null
0378 
0379   canvPIDzoom->SaveAs("clusNtp_PIDzoom.pdf");
0380 
0381 }  // ---------------------------------------------------------------
0382 
0383 void plot_Pmag(TTree* tree, const TCut& cut) {
0384 
0385   TCanvas *canvPmag = new TCanvas("canvPmag", "canvPmag", 700, 500);
0386 
0387   TH1F* hPmag = new TH1F("hPmag", "Particle momentum", 200, 0, 1000);
0388   tree->Project("hPmag", "firstPmag");
0389   hPmag->GetXaxis()->SetTitle("Particle momentum");
0390   hPmag->Draw();
0391 
0392   canvPmag->SetLogy(1);
0393   canvPmag->Update();  // without this the "stats" pointers are null
0394   double top = 0.0;
0395   drawStats(hPmag, top);
0396 
0397   canvPmag->SaveAs("clusNtp_Pmag.pdf");
0398 
0399 }  // ---------------------------------------------------------------
0400 
0401 void plot_charge(TTree* tree, const TCut& cut) {
0402 
0403   TCanvas *canv3 = new TCanvas("canv3", "canv3", 1100, 800);
0404   canv3->Divide(2,2);
0405 
0406 //  enum SubDetector { UNKNOWN=0, TIB=3, TID=4, TOB=5, TEC=6 };
0407   TH1F* hChgTIB = new TH1F("hChgTIB", "Charge read out", 200, 0, 1000);
0408   tree->Project("hChgTIB", "charge", cut&&"subDet==3");
0409   hChgTIB->GetXaxis()->SetTitle("Charge read out");
0410   hChgTIB->SetLineColor(kBlue);
0411   canv3->cd(1);
0412   hChgTIB->Draw();
0413 
0414   TH1F* hChgTID = new TH1F("hChgTID", "Charge read out", 200, 0, 1000);
0415   tree->Project("hChgTID", "charge", cut&&"subDet==4");
0416   hChgTID->GetXaxis()->SetTitle("Charge read out");
0417   hChgTID->SetLineColor(kBlue);
0418   canv3->cd(2);
0419   hChgTID->Draw();
0420 
0421   TH1F* hChgTOB = new TH1F("hChgTOB", "Charge read out", 200, 0, 1000);
0422   tree->Project("hChgTOB", "charge", cut&&"subDet==5");
0423   hChgTOB->GetXaxis()->SetTitle("Charge read out");
0424   hChgTOB->SetLineColor(kBlue);
0425   canv3->cd(3);
0426   hChgTOB->Draw();
0427 
0428   TH1F* hChgTEC = new TH1F("hChgTEC", "Charge read out", 200, 0, 1000);
0429   tree->Project("hChgTEC", "charge", cut&&"subDet==6");
0430   hChgTEC->GetXaxis()->SetTitle("Charge read out");
0431   hChgTEC->SetLineColor(kBlue);
0432   canv3->cd(4);
0433   hChgTEC->Draw();
0434 
0435   canv3->Update();  // without this the "stats" pointers are null
0436 
0437   canv3->SaveAs("clusNtp_charge.pdf");
0438 
0439 }  // ---------------------------------------------------------------
0440 
0441 void plot_Eloss(TTree* tree, const TCut& cut) {
0442 
0443   TCanvas *canv4 = new TCanvas("canv4", "canv4", 1100, 800);
0444   canv4->Divide(2,2);
0445 
0446 //  enum SubDetector { UNKNOWN=0, TIB=3, TID=4, TOB=5, TEC=6 };
0447   TH1F* hElossTIB = new TH1F("hElossTIB", "energy loss", 200, 0, 0.002);
0448   tree->Project("hElossTIB", "Eloss", cut&&"subDet==3");
0449   hElossTIB->GetXaxis()->SetTitle("energy loss");
0450   hElossTIB->SetLineColor(kBlue);
0451   canv4->cd(1);
0452   hElossTIB->Draw();
0453 
0454   TH1F* hElossTID = new TH1F("hElossTID", "energy loss", 200, 0, 0.002);
0455   tree->Project("hElossTID", "Eloss", cut&&"subDet==4");
0456   hElossTID->GetXaxis()->SetTitle("energy loss");
0457   hElossTID->SetLineColor(kBlue);
0458   canv4->cd(2);
0459   hElossTID->Draw();
0460 
0461   TH1F* hElossTOB = new TH1F("hElossTOB", "energy loss", 200, 0, 0.002);
0462   tree->Project("hElossTOB", "Eloss", cut&&"subDet==5");
0463   hElossTOB->GetXaxis()->SetTitle("energy loss");
0464   hElossTOB->SetLineColor(kBlue);
0465   canv4->cd(3);
0466   hElossTOB->Draw();
0467 
0468   TH1F* hElossTEC = new TH1F("hElossTEC", "energy loss", 200, 0, 0.002);
0469   tree->Project("hElossTEC", "Eloss", cut&&"subDet==6");
0470   hElossTEC->GetXaxis()->SetTitle("energy loss");
0471   hElossTEC->SetLineColor(kBlue);
0472   canv4->cd(4);
0473   hElossTEC->Draw();
0474 
0475   canv4->Update();  // without this the "stats" pointers are null
0476 
0477   canv4->SaveAs("clusNtp_Eloss.pdf");
0478 
0479 }  // ---------------------------------------------------------------
0480 
0481 void plot_chargeEloss(TTree* tree, const TCut& cut) {
0482 
0483   TCanvas *canvChgEloss = new TCanvas("canvChgEloss", "canvChgEloss", 1100, 800);
0484   canvChgEloss->Divide(2,2);
0485 
0486 //  enum SubDetector { UNKNOWN=0, TIB=3, TID=4, TOB=5, TEC=6 };
0487   TH2F* hChgElossTIB = new TH2F("hChgElossTIB", "Charge read out vs Eloss", 200, 0, 0.002, 200, 0, 1000);
0488   tree->Project("hChgElossTIB", "charge:Eloss", cut&&"subDet==3");
0489   hChgElossTIB->GetXaxis()->SetTitle("Energy loss");
0490   hChgElossTIB->GetYaxis()->SetTitle("Charge read out");
0491   canvChgEloss->cd(1);
0492   hChgElossTIB->Draw("colz");
0493 
0494   TH2F* hChgElossTID = new TH2F("hChgElossTID", "Charge read out vs Eloss", 200, 0, 0.002, 200, 0, 1000);
0495   tree->Project("hChgElossTID", "charge:Eloss", cut&&"subDet==4");
0496   hChgElossTID->GetXaxis()->SetTitle("Energy loss");
0497   hChgElossTID->GetYaxis()->SetTitle("Charge read out");
0498   canvChgEloss->cd(2);
0499   hChgElossTID->Draw("colz");
0500 
0501   TH2F* hChgElossTOB = new TH2F("hChgElossTOB", "Charge read out vs Eloss", 200, 0, 0.002, 200, 0, 1000);
0502   tree->Project("hChgElossTOB", "charge:Eloss", cut&&"subDet==5");
0503   hChgElossTOB->GetXaxis()->SetTitle("Energy loss");
0504   hChgElossTOB->GetYaxis()->SetTitle("Charge read out");
0505   canvChgEloss->cd(3);
0506   hChgElossTOB->Draw("colz");
0507 
0508   TH2F* hChgElossTEC = new TH2F("hChgElossTEC", "Charge read out vs Eloss", 200, 0, 0.002, 200, 0, 1000);
0509   tree->Project("hChgElossTEC", "charge:Eloss", cut&&"subDet==6");
0510   hChgElossTEC->GetXaxis()->SetTitle("Energy loss");
0511   hChgElossTEC->GetYaxis()->SetTitle("Charge read out");
0512   canvChgEloss->cd(4);
0513   hChgElossTEC->Draw("colz");
0514 
0515   canvChgEloss->Update();  // without this the "stats" pointers are null
0516 
0517   canvChgEloss->SaveAs("clusNtp_chargeEloss.pdf");
0518 
0519 }  // ---------------------------------------------------------------
0520 
0521 void plot_width(TTree* tree, const TCut& cut) {
0522 
0523   TCanvas *canv5 = new TCanvas("canv5", "canv5", 700, 500);
0524 
0525   TH1F* hwidth = new TH1F("hwidth", "Cluster width", 20, 0, 20);
0526   tree->Project("hwidth", "width");
0527   hwidth->GetXaxis()->SetTitle("Cluster width (strips)");
0528   hwidth->SetLineColor(kRed);
0529   hwidth->Draw();
0530 
0531   TH1F* hwidOne = new TH1F("hwidOne", "Cluster width", 20, 0, 20);
0532   tree->Project("hwidOne", "width", cut);
0533   hwidOne->GetXaxis()->SetTitle("Cluster width (strips)");
0534   hwidOne->SetLineColor(kBlue);
0535   hwidOne->Draw("sames");
0536 
0537   canv5->Update();  // without this the "stats" pointers are null
0538   double top = 0.0;
0539   drawStats(hwidth, top);
0540   drawStats(hwidOne, top);
0541 
0542   TLegend* Rtlegend = new TLegend(.34, .65, .76, .80, "");
0543   Rtlegend->AddEntry(hwidth, "all clusters", "L");
0544   Rtlegend->AddEntry(hwidOne, "1 crossing track", "L");
0545   canv5->cd(1);
0546   Rtlegend->Draw();
0547   canv5->Update();
0548 
0549   canv5->SaveAs("clusNtp_width.pdf");
0550 
0551 }  // ---------------------------------------------------------------
0552 
0553 void plot_path(TTree* tree, const TCut& cut) {
0554 
0555   TCanvas *canvPath = new TCanvas("canvPath", "canvPath", 1100, 800);
0556   canvPath->Divide(2,2);
0557   gStyle->SetPalette(1);
0558 
0559   // TIB
0560   TH2F* hPathTIBMI = new TH2F("hPathTIBMI", "Path length, MC truth vs straight line", 280, 280, 560, 280, 280, 560);
0561   tree->Project("hPathTIBMI", "10000*firstPathLength:10000*pathLstraight", cut&&"subDet==3");
0562   hPathTIBMI->GetXaxis()->SetTitle("straight path (microns)");
0563   hPathTIBMI->GetYaxis()->SetTitle("MC path (microns)");
0564   hPathTIBMI->SetLineColor(8);
0565   hPathTIBMI->SetMaximum(80);
0566   canvPath->cd(1);
0567   hPathTIBMI->Draw("colz");
0568 
0569   // TID
0570   TH2F* hPathTIDMI = new TH2F("hPathTIDMI", "Path length, MC truth vs straight line", 240, 280, 400, 240, 280, 400);
0571   tree->Project("hPathTIDMI", "10000*firstPathLength:10000*pathLstraight", cut&&"subDet==4");
0572   hPathTIDMI->GetXaxis()->SetTitle("straight path (microns)");
0573   hPathTIDMI->GetYaxis()->SetTitle("MC path (microns)");
0574   hPathTIDMI->SetLineColor(8);
0575   hPathTIDMI->SetMaximum(20);
0576   canvPath->cd(2);
0577   hPathTIDMI->Draw("colz");
0578 
0579   // TOB
0580   TH2F* hPathTOBMI = new TH2F("hPathTOBMI", "Path length, MC truth vs straight line", 340, 460, 800, 170, 460, 800);
0581   tree->Project("hPathTOBMI", "10000*firstPathLength:10000*pathLstraight", cut&&"subDet==5");
0582   hPathTOBMI->GetXaxis()->SetTitle("straight path (microns)");
0583   hPathTOBMI->GetYaxis()->SetTitle("MC path (microns)");
0584   hPathTOBMI->SetLineColor(8);
0585   hPathTOBMI->SetMaximum(80);
0586   canvPath->cd(3);
0587   hPathTOBMI->Draw("colz");
0588 
0589   // TEC
0590   TH2F* hPathTECMI = new TH2F("hPathTECMI", "Path length, MC truth vs straight line", 320, 280, 600, 320, 280, 600);
0591   tree->Project("hPathTECMI", "10000*firstPathLength:10000*pathLstraight", cut&&"subDet==6");
0592   hPathTECMI->GetXaxis()->SetTitle("straight path (microns)");
0593   hPathTECMI->GetYaxis()->SetTitle("MC path (microns)");
0594   hPathTECMI->SetLineColor(8);
0595   hPathTECMI->SetMaximum(20);
0596   canvPath->cd(4);
0597   hPathTECMI->Draw("colz");
0598 
0599   canvPath->SaveAs("clusNtp_path.pdf");
0600 
0601 }  // ---------------------------------------------------------------
0602 
0603 void plot_path1(TTree* tree, const TCut& cut) {
0604 
0605   TCanvas *canvPath1 = new TCanvas("canvPath1", "canvPath1", 1100, 800);
0606   canvPath1->Divide(2,2);
0607   gStyle->SetPalette(1);
0608 
0609   // TIB
0610   TH1F* hPath1TIBMI = new TH1F("hPath1TIBMI", "Path length, straight line", 280, 280, 560);
0611   tree->Project("hPath1TIBMI", "10000*pathLstraight", cut&&"subDet==3");
0612   hPath1TIBMI->GetXaxis()->SetTitle("path length (microns)");
0613   hPath1TIBMI->SetLineColor(kBlue);
0614   TH1F* hPath2TIBMI = new TH1F("hPath2TIBMI", "Path length, MC truth", 280, 280, 560);
0615   tree->Project("hPath2TIBMI", "10000*firstPathLength", cut&&"subDet==3");
0616   hPath2TIBMI->SetLineColor(kRed);
0617   canvPath1->cd(1);
0618   hPath1TIBMI->Draw();
0619   hPath2TIBMI->Draw("sames");
0620 
0621   canvPath1->Update();  // without this the "stats" pointers are null
0622   double top = 0.0;
0623   drawStats(hPath1TIBMI, top);
0624   drawStats(hPath2TIBMI, top);
0625   canvPath1->Update();
0626 
0627   // TID
0628   TH1F* hPath1TIDMI = new TH1F("hPath1TIDMI", "Path length, straight line", 240, 280, 400);
0629   tree->Project("hPath1TIDMI", "10000*pathLstraight", cut&&"subDet==4");
0630   hPath1TIDMI->GetXaxis()->SetTitle("path length (microns)");
0631   hPath1TIDMI->SetLineColor(kBlue);
0632   TH1F* hPath2TIDMI = new TH1F("hPath2TIDMI", "Path length, MC truth", 240, 280, 400);
0633   tree->Project("hPath2TIDMI", "10000*firstPathLength", cut&&"subDet==4");
0634   hPath2TIDMI->SetLineColor(kRed);
0635   canvPath1->cd(2);
0636   hPath1TIDMI->Draw();
0637   hPath2TIDMI->Draw("sames");
0638 
0639   canvPath1->Update();  // without this the "stats" pointers are null
0640   top = 0.0;
0641   drawStats(hPath1TIDMI, top);
0642   drawStats(hPath2TIDMI, top);
0643   canvPath1->Update();
0644 
0645   // TOB
0646   TH1F* hPath1TOBMI = new TH1F("hPath1TOBMI", "Path length, straight line", 340, 460, 800);
0647   tree->Project("hPath1TOBMI", "10000*pathLstraight", cut&&"subDet==5");
0648   hPath1TOBMI->GetXaxis()->SetTitle("path length (microns)");
0649   hPath1TOBMI->SetLineColor(kBlue);
0650   TH1F* hPath2TOBMI = new TH1F("hPath2TOBMI", "Path length, MC truth", 340, 460, 800);
0651   tree->Project("hPath2TOBMI", "10000*firstPathLength", cut&&"subDet==5");
0652   hPath2TOBMI->SetLineColor(kRed);
0653   canvPath1->cd(3);
0654   hPath1TOBMI->Draw();
0655   hPath2TOBMI->Draw("sames");
0656 
0657   canvPath1->Update();  // without this the "stats" pointers are null
0658   top = 0.0;
0659   drawStats(hPath1TOBMI, top);
0660   drawStats(hPath2TOBMI, top);
0661   canvPath1->Update();
0662 
0663   // TEC
0664   TH1F* hPath1TECMI = new TH1F("hPath1TECMI", "Path length, straight line", 320, 280, 600);
0665   tree->Project("hPath1TECMI", "10000*pathLstraight", cut&&"subDet==6");
0666   hPath1TECMI->GetXaxis()->SetTitle("path length (microns)");
0667   hPath1TECMI->SetLineColor(kBlue);
0668   TH1F* hPath2TECMI = new TH1F("hPath2TECMI", "Path length, MC truth", 320, 280, 600);
0669   tree->Project("hPath2TECMI", "10000*firstPathLength", cut&&"subDet==6");
0670   hPath2TECMI->SetLineColor(kRed);
0671   canvPath1->cd(4);
0672   hPath1TECMI->Draw();
0673   hPath2TECMI->Draw("sames");
0674 
0675   canvPath1->Update();  // without this the "stats" pointers are null
0676   top = 0.0;
0677   drawStats(hPath1TECMI, top);
0678   drawStats(hPath2TECMI, top);
0679   canvPath1->Update();
0680 
0681   TLegend* Rtlegend = new TLegend(.32, .65, .72, .80, "");
0682   Rtlegend->AddEntry(hPath1TOBMI, "Straight-track", "L");
0683   Rtlegend->AddEntry(hPath2TOBMI, "MC", "L");
0684   canvPath1->cd(1);
0685   Rtlegend->Draw();
0686   canvPath1->Update();
0687 
0688   canvPath1->SaveAs("clusNtp_path1.pdf");
0689 
0690 }  // ---------------------------------------------------------------
0691 
0692 void plot_NormCharge(TTree* tree, const TString& MIPdEdx, const TCut& cut1, const TCut& cut2, const TCut& cut3) {
0693 
0694   TCanvas *canv6 = new TCanvas("canv6", "canv6", 1100, 800);
0695   canv6->Divide(2,2);
0696 
0697   TH1F* hrelChgTIB = new TH1F("hrelChgTIB", "Relative charge", 100, 0, 10);
0698   tree->Project("hrelChgTIB", MIPdEdx+"*charge/max(1.e-6,firstPathLength)", "subDet == 3");
0699   hrelChgTIB->GetXaxis()->SetTitle("Charge/(path length), MIP");
0700   hrelChgTIB->SetMinimum(10);
0701   canv6->cd(1);
0702   hrelChgTIB->Draw();
0703 
0704   TH1F* hrelChgTIBMI = new TH1F("hrelChgTIBMI", "Relative charge", 100, 0, 10);
0705   tree->Project("hrelChgTIBMI", MIPdEdx+"*charge/max(1.e-6,firstPathLength)", cut1&&"subDet==3");
0706   hrelChgTIBMI->GetXaxis()->SetTitle("Charge/(path length), MIP");
0707   hrelChgTIBMI->SetLineColor(8);
0708 //   hrelChgTIBMI->SetLineStyle(kDashed);
0709   hrelChgTIBMI->Draw("sames");
0710 
0711   TH1F* hrelChgTIB2h = new TH1F("hrelChgTIB2h", "Relative charge", 100, 0, 10);
0712   tree->Project("hrelChgTIB2h", MIPdEdx+"*charge/max(1.e-6,firstPathLength)", cut2&&"subDet == 3");
0713   hrelChgTIB2h->GetXaxis()->SetTitle("Charge/(path length), MIP");
0714   hrelChgTIB2h->SetLineColor(kBlue);
0715   hrelChgTIB2h->Draw("sames");
0716 
0717   TH1F* hrelChgTIB2hcl = new TH1F("hrelChgTIB2hcl", "Relative charge", 100, 0, 10);
0718   tree->Project("hrelChgTIB2hcl", MIPdEdx+"*charge/max(1.e-6,firstPathLength)", cut3&&"subDet == 3");
0719   hrelChgTIB2hcl->GetXaxis()->SetTitle("Charge/(path length), MIP");
0720   hrelChgTIB2hcl->SetMinimum(10);
0721   hrelChgTIB2hcl->SetLineColor(kRed);
0722   hrelChgTIB2hcl->Draw("sames");
0723 
0724   gPad->SetLogy(1);
0725 
0726   canv6->Update();  // without this the "stats" pointers are null
0727   double top = 0.0;
0728   drawStats(hrelChgTIB, top);
0729   drawStats(hrelChgTIBMI, top);
0730   drawStats(hrelChgTIB2h, top);
0731   drawStats(hrelChgTIB2hcl, top);
0732   canv6->Update();
0733 
0734   TH1F* hrelChgTID = new TH1F("hrelChgTID", "Relative charge", 100, 0, 10);
0735   tree->Project("hrelChgTID", MIPdEdx+"*charge/max(1.e-6,firstPathLength)", "subDet == 4");
0736   hrelChgTID->GetXaxis()->SetTitle("Charge/(path length), MIP");
0737   hrelChgTID->SetMinimum(1);
0738   canv6->cd(2);
0739   hrelChgTID->Draw();
0740 
0741   TH1F* hrelChgTIDMI = new TH1F("hrelChgTIDMI", "Relative charge", 100, 0, 10);
0742   tree->Project("hrelChgTIDMI", MIPdEdx+"*charge/max(1.e-6,firstPathLength)", cut1&&"subDet==4");
0743   hrelChgTIDMI->GetXaxis()->SetTitle("Charge/(path length), MIP");
0744   hrelChgTIDMI->SetLineColor(8);
0745   hrelChgTIDMI->Draw("sames");
0746 
0747   TH1F* hrelChgTID2h = new TH1F("hrelChgTID2h", "Relative charge", 100, 0, 10);
0748   tree->Project("hrelChgTID2h", MIPdEdx+"*charge/max(1.e-6,firstPathLength)", cut2&&"subDet==4");
0749   hrelChgTID2h->GetXaxis()->SetTitle("Charge/(path length), MIP");
0750   hrelChgTID2h->SetLineColor(kBlue);
0751   hrelChgTID2h->Draw("sames");
0752 
0753   TH1F* hrelChgTID2hcl = new TH1F("hrelChgTID2hcl", "Relative charge", 100, 0, 10);
0754   tree->Project("hrelChgTID2hcl", MIPdEdx+"*charge/max(1.e-6,firstPathLength)", cut3&&"subDet==4");
0755   hrelChgTID2hcl->GetXaxis()->SetTitle("Charge/(path length), MIP");
0756   hrelChgTID2hcl->SetLineColor(kRed);
0757   hrelChgTID2hcl->Draw("sames");
0758 
0759   gPad->SetLogy(1);
0760 
0761   canv6->Update();  // without this the "stats" pointers are null
0762   top = 0.0;
0763   drawStats(hrelChgTID, top);
0764   drawStats(hrelChgTIDMI, top);
0765   drawStats(hrelChgTID2h, top);
0766   drawStats(hrelChgTID2hcl, top);
0767   canv6->Update();
0768 
0769   TH1F* hrelChgTOB = new TH1F("hrelChgTOB", "Relative charge", 100, 0, 10);
0770   tree->Project("hrelChgTOB", MIPdEdx+"*charge/max(1.e-6,firstPathLength)", "subDet == 5");
0771   hrelChgTOB->GetXaxis()->SetTitle("Charge/(path length), MIP");
0772   hrelChgTOB->SetMinimum(10);
0773   canv6->cd(3);
0774   hrelChgTOB->Draw();
0775 
0776   TH1F* hrelChgTOBMI = new TH1F("hrelChgTOBMI", "Relative charge", 100, 0, 10);
0777   tree->Project("hrelChgTOBMI", MIPdEdx+"*charge/max(1.e-6,firstPathLength)", cut1&&"subDet==5");
0778   hrelChgTOBMI->GetXaxis()->SetTitle("Charge/(path length), MIP");
0779   hrelChgTOBMI->SetLineColor(8);
0780   hrelChgTOBMI->Draw("sames");
0781 
0782   TH1F* hrelChgTOB2h = new TH1F("hrelChgTOB2h", "Relative charge", 100, 0, 10);
0783   tree->Project("hrelChgTOB2h", MIPdEdx+"*charge/max(1.e-6,firstPathLength)", cut2&&"subDet==5");
0784   hrelChgTOB2h->GetXaxis()->SetTitle("Charge/(path length), MIP");
0785   hrelChgTOB2h->SetLineColor(kBlue);
0786   hrelChgTOB2h->Draw("sames");
0787 
0788   TH1F* hrelChgTOB2hcl = new TH1F("hrelChgTOB2hcl", "Relative charge", 100, 0, 10);
0789   tree->Project("hrelChgTOB2hcl", MIPdEdx+"*charge/max(1.e-6,firstPathLength)", cut3&&"subDet==5");
0790   hrelChgTOB2hcl->GetXaxis()->SetTitle("Charge/(path length), MIP");
0791   hrelChgTOB2hcl->SetLineColor(kRed);
0792   hrelChgTOB2hcl->Draw("sames");
0793 
0794   gPad->SetLogy(1);
0795 
0796   canv6->Update();  // without this the "stats" pointers are null
0797   top = 0.0;
0798   drawStats(hrelChgTOB, top);
0799   drawStats(hrelChgTOBMI, top);
0800   drawStats(hrelChgTOB2h, top);
0801   drawStats(hrelChgTOB2hcl, top);
0802   canv6->Update();
0803 
0804   TH1F* hrelChgTEC = new TH1F("hrelChgTEC", "Relative charge", 100, 0, 10);
0805   tree->Project("hrelChgTEC", MIPdEdx+"*charge/max(1.e-6,firstPathLength)", "subDet == 6");
0806   hrelChgTEC->GetXaxis()->SetTitle("Charge/(path length), MIP");
0807   hrelChgTEC->SetMinimum(1);
0808   canv6->cd(4);
0809   hrelChgTEC->Draw();
0810 
0811   TH1F* hrelChgTECMI = new TH1F("hrelChgTECMI", "Relative charge", 100, 0, 10);
0812   tree->Project("hrelChgTECMI", MIPdEdx+"*charge/max(1.e-6,firstPathLength)", cut1&&"subDet==6");
0813   hrelChgTECMI->GetXaxis()->SetTitle("Charge/(path length), MIP");
0814   hrelChgTECMI->SetLineColor(8);
0815   hrelChgTECMI->Draw("sames");
0816 
0817   TH1F* hrelChgTEC2h = new TH1F("hrelChgTEC2h", "Relative charge", 100, 0, 10);
0818   tree->Project("hrelChgTEC2h", MIPdEdx+"*charge/max(1.e-6,firstPathLength)", cut2&&"subDet==6");
0819   hrelChgTEC2h->GetXaxis()->SetTitle("Charge/(path length), MIP");
0820   hrelChgTEC2h->SetLineColor(kBlue);
0821   hrelChgTEC2h->Draw("sames");
0822 
0823   TH1F* hrelChgTEC2hcl = new TH1F("hrelChgTEC2hcl", "Relative charge", 100, 0, 10);
0824   tree->Project("hrelChgTEC2hcl", MIPdEdx+"*charge/max(1.e-6,firstPathLength)", cut3&&"subDet==6");
0825   hrelChgTEC2hcl->GetXaxis()->SetTitle("Charge/(path length), MIP");
0826   hrelChgTEC2hcl->SetLineColor(kRed);
0827   hrelChgTEC2hcl->Draw("sames");
0828 
0829   gPad->SetLogy(1);
0830 
0831   canv6->Update();  // without this the "stats" pointers are null
0832   top = 0.0;
0833   drawStats(hrelChgTEC, top);
0834   drawStats(hrelChgTECMI, top);
0835   drawStats(hrelChgTEC2h, top);
0836   drawStats(hrelChgTEC2hcl, top);
0837   canv6->Update();
0838 
0839   TLegend* Rtlegend = new TLegend(.36, .67, .78, .87, "");
0840   Rtlegend->AddEntry(hrelChgTIB, "all clusters", "L");
0841   Rtlegend->AddEntry(hrelChgTIBMI, "1 crossing primary", "L");
0842   Rtlegend->AddEntry(hrelChgTIB2h, "2 crossing tracks", "L");
0843   Rtlegend->AddEntry(hrelChgTIB2hcl, "2 crossing primaries", "L");
0844   canv6->cd(1);
0845   Rtlegend->Draw();
0846   canv6->Update();
0847 
0848   canv6->SaveAs("clusNtp_relCharge.pdf");
0849 
0850 }  // ---------------------------------------------------------------
0851 
0852 void plot_NormEloss(TTree* tree, const TString& MIPdEdx, const TCut& cut1, const TCut& cut2, const TCut& cut3) {
0853 
0854   TCanvas *canvNormEloss = new TCanvas("canvNormEloss", "canvNormEloss", 1100, 800);
0855   canvNormEloss->Divide(2,2);
0856 
0857   TH1F* hrelElossTIB = new TH1F("hrelElossTIB", "Relative Eloss", 100, 0, 10);
0858   tree->Project("hrelElossTIB", MIPdEdx+"*Eloss/max(1.e-6,firstPathLength)", "subDet == 3");
0859   hrelElossTIB->GetXaxis()->SetTitle("Eloss/(path length), MIP");
0860   hrelElossTIB->SetMinimum(10);
0861   canvNormEloss->cd(1);
0862   hrelElossTIB->Draw();
0863 
0864   TH1F* hrelElossTIBMI = new TH1F("hrelElossTIBMI", "Relative Eloss", 100, 0, 10);
0865   tree->Project("hrelElossTIBMI", MIPdEdx+"*Eloss/max(1.e-6,firstPathLength)", cut1&&"subDet==3");
0866   hrelElossTIBMI->GetXaxis()->SetTitle("Eloss/(path length), MIP");
0867   hrelElossTIBMI->SetLineColor(8);
0868   hrelElossTIBMI->Draw("sames");
0869 
0870   TH1F* hrelElossTIB2h = new TH1F("hrelElossTIB2h", "Relative Eloss", 100, 0, 10);
0871   tree->Project("hrelElossTIB2h", MIPdEdx+"*Eloss/max(1.e-6,firstPathLength)", cut2&&"subDet == 3");
0872   hrelElossTIB2h->GetXaxis()->SetTitle("Eloss/(path length), MIP");
0873   hrelElossTIB2h->SetLineColor(kBlue);
0874   hrelElossTIB2h->Draw("sames");
0875 
0876   TH1F* hrelElossTIB2hcl = new TH1F("hrelElossTIB2hcl", "Relative Eloss", 100, 0, 10);
0877   tree->Project("hrelElossTIB2hcl", MIPdEdx+"*Eloss/max(1.e-6,firstPathLength)", cut3&&"subDet == 3");
0878   hrelElossTIB2hcl->GetXaxis()->SetTitle("Eloss/(path length), MIP");
0879   hrelElossTIB2hcl->SetMinimum(10);
0880   hrelElossTIB2hcl->SetLineColor(kRed);
0881   hrelElossTIB2hcl->Draw("sames");
0882 
0883   gPad->SetLogy(1);
0884 
0885   canvNormEloss->Update();  // without this the "stats" pointers are null
0886   double top = 0.0;
0887   drawStats(hrelElossTIB, top);
0888   drawStats(hrelElossTIBMI, top);
0889   drawStats(hrelElossTIB2h, top);
0890   drawStats(hrelElossTIB2hcl, top);
0891   canvNormEloss->Update();
0892 
0893   TH1F* hrelElossTID = new TH1F("hrelElossTID", "Relative Eloss", 100, 0, 10);
0894   tree->Project("hrelElossTID", MIPdEdx+"*Eloss/max(1.e-6,firstPathLength)", "subDet == 4");
0895   hrelElossTID->GetXaxis()->SetTitle("Eloss/(path length), MIP");
0896   hrelElossTID->SetMinimum(1);
0897   canvNormEloss->cd(2);
0898   hrelElossTID->Draw();
0899 
0900   TH1F* hrelElossTIDMI = new TH1F("hrelElossTIDMI", "Relative Eloss", 100, 0, 10);
0901   tree->Project("hrelElossTIDMI", MIPdEdx+"*Eloss/max(1.e-6,firstPathLength)", cut1&&"subDet==4");
0902   hrelElossTIDMI->GetXaxis()->SetTitle("Eloss/(path length), MIP");
0903   hrelElossTIDMI->SetLineColor(8);
0904   hrelElossTIDMI->Draw("sames");
0905 
0906   TH1F* hrelElossTID2h = new TH1F("hrelElossTID2h", "Relative Eloss", 100, 0, 10);
0907   tree->Project("hrelElossTID2h", MIPdEdx+"*Eloss/max(1.e-6,firstPathLength)", cut2&&"subDet==4");
0908   hrelElossTID2h->GetXaxis()->SetTitle("Eloss/(path length), MIP");
0909   hrelElossTID2h->SetLineColor(kBlue);
0910   hrelElossTID2h->Draw("sames");
0911 
0912   TH1F* hrelElossTID2hcl = new TH1F("hrelElossTID2hcl", "Relative Eloss", 100, 0, 10);
0913   tree->Project("hrelElossTID2hcl", MIPdEdx+"*Eloss/max(1.e-6,firstPathLength)", cut3&&"subDet==4");
0914   hrelElossTID2hcl->GetXaxis()->SetTitle("Eloss/(path length), MIP");
0915   hrelElossTID2hcl->SetLineColor(kRed);
0916   hrelElossTID2hcl->Draw("sames");
0917 
0918   gPad->SetLogy(1);
0919 
0920   canvNormEloss->Update();  // without this the "stats" pointers are null
0921   top = 0.0;
0922   drawStats(hrelElossTID, top);
0923   drawStats(hrelElossTIDMI, top);
0924   drawStats(hrelElossTID2h, top);
0925   drawStats(hrelElossTID2hcl, top);
0926   canvNormEloss->Update();
0927 
0928   TH1F* hrelElossTOB = new TH1F("hrelElossTOB", "Relative Eloss", 100, 0, 10);
0929   tree->Project("hrelElossTOB", MIPdEdx+"*Eloss/max(1.e-6,firstPathLength)", "subDet == 5");
0930   hrelElossTOB->GetXaxis()->SetTitle("Eloss/(path length), MIP");
0931   hrelElossTOB->SetMinimum(10);
0932   canvNormEloss->cd(3);
0933   hrelElossTOB->Draw();
0934 
0935   TH1F* hrelElossTOBMI = new TH1F("hrelElossTOBMI", "Relative Eloss", 100, 0, 10);
0936   tree->Project("hrelElossTOBMI", MIPdEdx+"*Eloss/max(1.e-6,firstPathLength)", cut1&&"subDet==5");
0937   hrelElossTOBMI->GetXaxis()->SetTitle("Eloss/(path length), MIP");
0938   hrelElossTOBMI->SetLineColor(8);
0939   hrelElossTOBMI->Draw("sames");
0940 
0941   TH1F* hrelElossTOB2h = new TH1F("hrelElossTOB2h", "Relative Eloss", 100, 0, 10);
0942   tree->Project("hrelElossTOB2h", MIPdEdx+"*Eloss/max(1.e-6,firstPathLength)", cut2&&"subDet==5");
0943   hrelElossTOB2h->GetXaxis()->SetTitle("Eloss/(path length), MIP");
0944   hrelElossTOB2h->SetLineColor(kBlue);
0945   hrelElossTOB2h->Draw("sames");
0946 
0947   TH1F* hrelElossTOB2hcl = new TH1F("hrelElossTOB2hcl", "Relative Eloss", 100, 0, 10);
0948   tree->Project("hrelElossTOB2hcl", MIPdEdx+"*Eloss/max(1.e-6,firstPathLength)", cut3&&"subDet==5");
0949   hrelElossTOB2hcl->GetXaxis()->SetTitle("Eloss/(path length), MIP");
0950   hrelElossTOB2hcl->SetLineColor(kRed);
0951   hrelElossTOB2hcl->Draw("sames");
0952 
0953   gPad->SetLogy(1);
0954 
0955   canvNormEloss->Update();  // without this the "stats" pointers are null
0956   top = 0.0;
0957   drawStats(hrelElossTOB, top);
0958   drawStats(hrelElossTOBMI, top);
0959   drawStats(hrelElossTOB2h, top);
0960   drawStats(hrelElossTOB2hcl, top);
0961   canvNormEloss->Update();
0962 
0963   TH1F* hrelElossTEC = new TH1F("hrelElossTEC", "Relative Eloss", 100, 0, 10);
0964   tree->Project("hrelElossTEC", MIPdEdx+"*Eloss/max(1.e-6,firstPathLength)", "subDet == 6");
0965   hrelElossTEC->GetXaxis()->SetTitle("Eloss/(path length), MIP");
0966   hrelElossTEC->SetMinimum(1);
0967   canvNormEloss->cd(4);
0968   hrelElossTEC->Draw();
0969 
0970   TH1F* hrelElossTECMI = new TH1F("hrelElossTECMI", "Relative Eloss", 100, 0, 10);
0971   tree->Project("hrelElossTECMI", MIPdEdx+"*Eloss/max(1.e-6,firstPathLength)", cut1&&"subDet==6");
0972   hrelElossTECMI->GetXaxis()->SetTitle("Eloss/(path length), MIP");
0973   hrelElossTECMI->SetLineColor(8);
0974   hrelElossTECMI->Draw("sames");
0975 
0976   TH1F* hrelElossTEC2h = new TH1F("hrelElossTEC2h", "Relative Eloss", 100, 0, 10);
0977   tree->Project("hrelElossTEC2h", MIPdEdx+"*Eloss/max(1.e-6,firstPathLength)", cut2&&"subDet==6");
0978   hrelElossTEC2h->GetXaxis()->SetTitle("Eloss/(path length), MIP");
0979   hrelElossTEC2h->SetLineColor(kBlue);
0980   hrelElossTEC2h->Draw("sames");
0981 
0982   TH1F* hrelElossTEC2hcl = new TH1F("hrelElossTEC2hcl", "Relative Eloss", 100, 0, 10);
0983   tree->Project("hrelElossTEC2hcl", MIPdEdx+"*Eloss/max(1.e-6,firstPathLength)", cut3&&"subDet==6");
0984   hrelElossTEC2hcl->GetXaxis()->SetTitle("Eloss/(path length), MIP");
0985   hrelElossTEC2hcl->SetLineColor(kRed);
0986   hrelElossTEC2hcl->Draw("sames");
0987 
0988   gPad->SetLogy(1);
0989 
0990   canvNormEloss->Update();  // without this the "stats" pointers are null
0991   top = 0.0;
0992   drawStats(hrelElossTEC, top);
0993   drawStats(hrelElossTECMI, top);
0994   drawStats(hrelElossTEC2h, top);
0995   drawStats(hrelElossTEC2hcl, top);
0996   canvNormEloss->Update();
0997 
0998   TLegend* Rtlegend = new TLegend(.36, .67, .78, .87, "");
0999   Rtlegend->AddEntry(hrelElossTIB, "all clusters", "L");
1000   Rtlegend->AddEntry(hrelElossTIBMI, "1 crossing primary", "L");
1001   Rtlegend->AddEntry(hrelElossTIB2h, "2 crossing tracks", "L");
1002   Rtlegend->AddEntry(hrelElossTIB2hcl, "2 crossing primaries", "L");
1003   canvNormEloss->cd(1);
1004   Rtlegend->Draw();
1005   canvNormEloss->Update();
1006 
1007   canvNormEloss->SaveAs("clusNtp_relEloss.pdf");
1008 
1009 }  // ---------------------------------------------------------------
1010 
1011 void plot_chgTotPath(TTree* tree, const TString& MIPdEdx, const TCut& cut0, const TCut& cut1, const TCut& cut2, const TCut& cut3,
1012              const char* title0, const char* title1, const char* title2, const char* title3 ) {
1013 
1014   TCanvas *canvChgTotPath = new TCanvas("canvChgTotPath", "canvChgTotPath", 1100, 800);
1015   canvChgTotPath->Divide(2,2);
1016 
1017   TH1F* hchgTPaTIB = new TH1F("hchgTPaTIB", "Relative charge", 100, 0, 10);
1018   tree->Project("hchgTPaTIB", MIPdEdx+"*charge/max(1.e-6,allHtPathLength)", "subDet == 3");
1019   hchgTPaTIB->GetXaxis()->SetTitle("Charge/(total path length), MIP");
1020   hchgTPaTIB->SetMinimum(10);
1021   canvChgTotPath->cd(1);
1022   hchgTPaTIB->Draw();
1023 
1024   TH1F* hchgTPaTIBMI = new TH1F("hchgTPaTIBMI", "Relative charge", 100, 0, 10);
1025   tree->Project("hchgTPaTIBMI", MIPdEdx+"*charge/max(1.e-6,allHtPathLength)", cut1&&"subDet==3");
1026   hchgTPaTIBMI->GetXaxis()->SetTitle("Charge/(total path length), MIP");
1027   hchgTPaTIBMI->SetLineColor(8);
1028   hchgTPaTIBMI->Draw("sames");
1029 
1030   TH1F* hchgTPaTIB2h = new TH1F("hchgTPaTIB2h", "Relative charge", 100, 0, 10);
1031   tree->Project("hchgTPaTIB2h", MIPdEdx+"*charge/max(1.e-6,allHtPathLength)", cut2&&"subDet == 3");
1032   hchgTPaTIB2h->GetXaxis()->SetTitle("Charge/(total path length), MIP");
1033   hchgTPaTIB2h->SetLineColor(kBlue);
1034   hchgTPaTIB2h->Draw("sames");
1035 
1036   TH1F* hchgTPaTIB2hcl = new TH1F("hchgTPaTIB2hcl", "Relative charge", 100, 0, 10);
1037   tree->Project("hchgTPaTIB2hcl", MIPdEdx+"*charge/max(1.e-6,allHtPathLength)", cut3&&"subDet == 3");
1038   hchgTPaTIB2hcl->GetXaxis()->SetTitle("Charge/(total path length), MIP");
1039   hchgTPaTIB2hcl->SetMinimum(10);
1040   hchgTPaTIB2hcl->SetLineColor(kRed);
1041   hchgTPaTIB2hcl->Draw("sames");
1042 
1043   gPad->SetLogy(1);
1044 
1045   canvChgTotPath->Update();  // without this the "stats" pointers are null
1046   double top = 0.0;
1047   drawStats(hchgTPaTIB, top);
1048   drawStats(hchgTPaTIBMI, top);
1049   drawStats(hchgTPaTIB2h, top);
1050   drawStats(hchgTPaTIB2hcl, top);
1051   canvChgTotPath->Update();
1052 
1053   TH1F* hchgTPaTID = new TH1F("hchgTPaTID", "Relative charge", 100, 0, 10);
1054   tree->Project("hchgTPaTID", MIPdEdx+"*charge/max(1.e-6,allHtPathLength)", "subDet == 4");
1055   hchgTPaTID->GetXaxis()->SetTitle("Charge/(total path length), MIP");
1056   hchgTPaTID->SetMinimum(1);
1057   canvChgTotPath->cd(2);
1058   hchgTPaTID->Draw();
1059 
1060   TH1F* hchgTPaTIDMI = new TH1F("hchgTPaTIDMI", "Relative charge", 100, 0, 10);
1061   tree->Project("hchgTPaTIDMI", MIPdEdx+"*charge/max(1.e-6,allHtPathLength)", cut1&&"subDet==4");
1062   hchgTPaTIDMI->GetXaxis()->SetTitle("Charge/(total path length), MIP");
1063   hchgTPaTIDMI->SetLineColor(8);
1064   hchgTPaTIDMI->Draw("sames");
1065 
1066   TH1F* hchgTPaTID2h = new TH1F("hchgTPaTID2h", "Relative charge", 100, 0, 10);
1067   tree->Project("hchgTPaTID2h", MIPdEdx+"*charge/max(1.e-6,allHtPathLength)", cut2&&"subDet==4");
1068   hchgTPaTID2h->GetXaxis()->SetTitle("Charge/(total path length), MIP");
1069   hchgTPaTID2h->SetLineColor(kBlue);
1070   hchgTPaTID2h->Draw("sames");
1071 
1072   TH1F* hchgTPaTID2hcl = new TH1F("hchgTPaTID2hcl", "Relative charge", 100, 0, 10);
1073   tree->Project("hchgTPaTID2hcl", MIPdEdx+"*charge/max(1.e-6,allHtPathLength)", cut3&&"subDet==4");
1074   hchgTPaTID2hcl->GetXaxis()->SetTitle("Charge/(total path length), MIP");
1075   hchgTPaTID2hcl->SetLineColor(kRed);
1076   hchgTPaTID2hcl->Draw("sames");
1077 
1078   gPad->SetLogy(1);
1079 
1080   canvChgTotPath->Update();  // without this the "stats" pointers are null
1081   top = 0.0;
1082   drawStats(hchgTPaTID, top);
1083   drawStats(hchgTPaTIDMI, top);
1084   drawStats(hchgTPaTID2h, top);
1085   drawStats(hchgTPaTID2hcl, top);
1086   canvChgTotPath->Update();
1087 
1088   TH1F* hchgTPaTOB = new TH1F("hchgTPaTOB", "Relative charge", 100, 0, 10);
1089   tree->Project("hchgTPaTOB", MIPdEdx+"*charge/max(1.e-6,allHtPathLength)", "subDet == 5");
1090   hchgTPaTOB->GetXaxis()->SetTitle("Charge/(total path length), MIP");
1091   hchgTPaTOB->SetMinimum(10);
1092   canvChgTotPath->cd(3);
1093   hchgTPaTOB->Draw();
1094 
1095   TH1F* hchgTPaTOBMI = new TH1F("hchgTPaTOBMI", "Relative charge", 100, 0, 10);
1096   tree->Project("hchgTPaTOBMI", MIPdEdx+"*charge/max(1.e-6,allHtPathLength)", cut1&&"subDet==5");
1097   hchgTPaTOBMI->GetXaxis()->SetTitle("Charge/(total path length), MIP");
1098   hchgTPaTOBMI->SetLineColor(8);
1099   hchgTPaTOBMI->Draw("sames");
1100 
1101   TH1F* hchgTPaTOB2h = new TH1F("hchgTPaTOB2h", "Relative charge", 100, 0, 10);
1102   tree->Project("hchgTPaTOB2h", MIPdEdx+"*charge/max(1.e-6,allHtPathLength)", cut2&&"subDet==5");
1103   hchgTPaTOB2h->GetXaxis()->SetTitle("Charge/(total path length), MIP");
1104   hchgTPaTOB2h->SetLineColor(kBlue);
1105   hchgTPaTOB2h->Draw("sames");
1106 
1107   TH1F* hchgTPaTOB2hcl = new TH1F("hchgTPaTOB2hcl", "Relative charge", 100, 0, 10);
1108   tree->Project("hchgTPaTOB2hcl", MIPdEdx+"*charge/max(1.e-6,allHtPathLength)", cut3&&"subDet==5");
1109   hchgTPaTOB2hcl->GetXaxis()->SetTitle("Charge/(total path length), MIP");
1110   hchgTPaTOB2hcl->SetLineColor(kRed);
1111   hchgTPaTOB2hcl->Draw("sames");
1112 
1113   gPad->SetLogy(1);
1114 
1115   canvChgTotPath->Update();  // without this the "stats" pointers are null
1116   top = 0.0;
1117   drawStats(hchgTPaTOB, top);
1118   drawStats(hchgTPaTOBMI, top);
1119   drawStats(hchgTPaTOB2h, top);
1120   drawStats(hchgTPaTOB2hcl, top);
1121   canvChgTotPath->Update();
1122 
1123   TH1F* hchgTPaTEC = new TH1F("hchgTPaTEC", "Relative charge", 100, 0, 10);
1124   tree->Project("hchgTPaTEC", MIPdEdx+"*charge/max(1.e-6,allHtPathLength)", "subDet == 6");
1125   hchgTPaTEC->GetXaxis()->SetTitle("Charge/(total path length), MIP");
1126   hchgTPaTEC->SetMinimum(1);
1127   canvChgTotPath->cd(4);
1128   hchgTPaTEC->Draw();
1129 
1130   TH1F* hchgTPaTECMI = new TH1F("hchgTPaTECMI", "Relative charge", 100, 0, 10);
1131   tree->Project("hchgTPaTECMI", MIPdEdx+"*charge/max(1.e-6,allHtPathLength)", cut1&&"subDet==6");
1132   hchgTPaTECMI->GetXaxis()->SetTitle("Charge/(total path length), MIP");
1133   hchgTPaTECMI->SetLineColor(8);
1134   hchgTPaTECMI->Draw("sames");
1135 
1136   TH1F* hchgTPaTEC2h = new TH1F("hchgTPaTEC2h", "Relative charge", 100, 0, 10);
1137   tree->Project("hchgTPaTEC2h", MIPdEdx+"*charge/max(1.e-6,allHtPathLength)", cut2&&"subDet==6");
1138   hchgTPaTEC2h->GetXaxis()->SetTitle("Charge/(total path length), MIP");
1139   hchgTPaTEC2h->SetLineColor(kBlue);
1140   hchgTPaTEC2h->Draw("sames");
1141 
1142   TH1F* hchgTPaTEC2hcl = new TH1F("hchgTPaTEC2hcl", "Relative charge", 100, 0, 10);
1143   tree->Project("hchgTPaTEC2hcl", MIPdEdx+"*charge/max(1.e-6,allHtPathLength)", cut3&&"subDet==6");
1144   hchgTPaTEC2hcl->GetXaxis()->SetTitle("Charge/(total path length), MIP");
1145   hchgTPaTEC2hcl->SetLineColor(kRed);
1146   hchgTPaTEC2hcl->Draw("sames");
1147 
1148   gPad->SetLogy(1);
1149 
1150   canvChgTotPath->Update();  // without this the "stats" pointers are null
1151   top = 0.0;
1152   drawStats(hchgTPaTEC, top);
1153   drawStats(hchgTPaTECMI, top);
1154   drawStats(hchgTPaTEC2h, top);
1155   drawStats(hchgTPaTEC2hcl, top);
1156   canvChgTotPath->Update();
1157 
1158   TLegend* Rtlegend = new TLegend(.36, .67, .78, .87, "");
1159   Rtlegend->AddEntry(hchgTPaTIB, title0, "L");
1160   Rtlegend->AddEntry(hchgTPaTIBMI, title1, "L");
1161   Rtlegend->AddEntry(hchgTPaTIB2h, title2, "L");
1162   Rtlegend->AddEntry(hchgTPaTIB2hcl, title3, "L");
1163   canvChgTotPath->cd(1);
1164   Rtlegend->Draw();
1165   canvChgTotPath->Update();
1166 
1167   canvChgTotPath->SaveAs("clusNtp_chgTotPath.pdf");
1168 
1169 }  // ---------------------------------------------------------------
1170 
1171 void plot_NormChgSpl(TTree* tree, const TString& MIPdEdx, const TCut& cut) {
1172 
1173   TCanvas *canv7 = new TCanvas("canv7", "canv7", 700, 500);
1174 
1175   TH1F* hrelChg = new TH1F("hrelChg", "Relative charge", 100, 0, 10);
1176   tree->Project("hrelChg", MIPdEdx+"*charge/max(1.e-6,Eloss)");
1177   hrelChg->GetXaxis()->SetTitle("Charge/(expected charge)");
1178   hrelChg->SetLineColor(kBlue);
1179   hrelChg->Draw();
1180 
1181   TH1F* hrelChgSpl = new TH1F("hrelChgSpl", "Relative charge", 100, 0, 10);
1182   tree->Project("hrelChgSpl", MIPdEdx+"*charge/max(1.e-6,Eloss)", cut);
1183   hrelChgSpl->GetXaxis()->SetTitle("Charge/(expected charge)");
1184   hrelChgSpl->SetLineColor(kRed);
1185   hrelChgSpl->Draw("sames");
1186 
1187   canv7->Update();  // without this the "stats" pointers are null
1188   double top = 0.0;
1189   drawStats(hrelChg, top);
1190   drawStats(hrelChgSpl, top);
1191   canv7->Update();
1192 
1193   TLegend* Rtlegend = new TLegend(.35, .65, .75, .80, "");
1194   Rtlegend->AddEntry(hrelChg, "All clusters", "L");
1195   Rtlegend->AddEntry(hrelChgSpl, "2-simHit clusters", "L");
1196   Rtlegend->Draw();
1197   canv7->Update();
1198 
1199   canv7->SaveAs("clusNtp_relChgSplit.pdf");
1200 
1201 }  // ---------------------------------------------------------------
1202 
1203 
1204 void plot_NormChgNtp(TTree* tree, const TString& MIPdEdx, const TCut& cut) {
1205 
1206   TCanvas *canvNchgNtp = new TCanvas("canvNchgNtp", "canvNchgNtp", 700, 900);
1207   canvNchgNtp->Divide(1,2);
1208 
1209   TH2F* hNchgNtp = new TH2F("hNchgNtp", "Ntp vs Relative charge", 25, 0, 5, 10, 0, 10);
1210   tree->Project("hNchgNtp", "Ntp:"+MIPdEdx+"*charge/max(1.e-6,firstPathLength)", cut);
1211   hNchgNtp->GetXaxis()->SetTitle("Charge/(path length), MIP");
1212   hNchgNtp->GetYaxis()->SetTitle("No. tracks");
1213   hNchgNtp->SetLineColor(kBlue);
1214   canvNchgNtp->cd(1);  hNchgNtp->Draw("box");
1215 
1216   TH2F* hNchgNht = new TH2F("hNchgNht", "Nhits vs Relative charge", 25, 0, 5, 10, 0, 10);
1217   tree->Project("hNchgNht", "NsimHits:"+MIPdEdx+"*charge/max(1.e-6,firstPathLength)", cut);
1218   hNchgNht->GetXaxis()->SetTitle("Charge/(path length), MIP");
1219   hNchgNht->GetYaxis()->SetTitle("No. hits");
1220   hNchgNht->SetLineColor(kBlue);
1221   canvNchgNtp->cd(2);  hNchgNht->Draw("box");
1222 
1223   canvNchgNtp->Update();
1224 
1225   canvNchgNtp->SaveAs("clusNtp_NchgNtp.pdf");
1226 
1227 }  // ---------------------------------------------------------------
1228 
1229 void plot_NrmChgWid(TTree* tree, const TString& MIPdEdx) {
1230 
1231   TCanvas *canvNchgWid = new TCanvas("canvNchgWid", "canvNchgWid", 1100, 800);
1232   canvNchgWid->Divide(2,2);
1233 
1234   // TIB
1235 
1236   TH1F* hChgWidTIB3 = new TH1F("hChgWidTIB3", "Relative charge", 100, 0, 10);
1237   tree->Project("hChgWidTIB3", MIPdEdx+"*charge/max(1.e-6,firstPathLength)", "subDet==3 && width == 3");
1238   hChgWidTIB3->GetXaxis()->SetTitle("Charge/(path length), MIP");
1239   hChgWidTIB3->SetLineColor(kBlack);
1240   canvNchgWid->cd(1);
1241   hChgWidTIB3->Draw();
1242 
1243   TH1F* hChgWidTIB1 = new TH1F("hChgWidTIB1", "Relative charge", 100, 0, 10);
1244   tree->Project("hChgWidTIB1", MIPdEdx+"*charge/max(1.e-6,firstPathLength)", "subDet==3 && width == 1");
1245   hChgWidTIB1->SetLineColor(kRed);
1246   hChgWidTIB1->Draw("same");
1247 
1248   TH1F* hChgWidTIB2 = new TH1F("hChgWidTIB2", "Relative charge", 100, 0, 10);
1249   tree->Project("hChgWidTIB2", MIPdEdx+"*charge/max(1.e-6,firstPathLength)", "subDet==3 && width == 2");
1250   hChgWidTIB2->SetLineColor(kBlue);
1251   hChgWidTIB2->Draw("same");
1252 
1253   TH1F* hChgWidTIB4 = new TH1F("hChgWidTIB4", "Relative charge", 100, 0, 10);
1254   tree->Project("hChgWidTIB4", MIPdEdx+"*charge/max(1.e-6,firstPathLength)", "subDet==3 && width == 4");
1255   hChgWidTIB4->SetLineColor(8);
1256   hChgWidTIB4->Draw("same");
1257 
1258   TH1F* hChgWidTIB5 = new TH1F("hChgWidTIB5", "Relative charge", 100, 0, 10);
1259   tree->Project("hChgWidTIB5", MIPdEdx+"*charge/max(1.e-6,firstPathLength)", "subDet==3 && width == 5");
1260   hChgWidTIB5->SetLineColor(7);
1261   hChgWidTIB5->Draw("same");
1262 
1263   TH1F* hChgWidTIB6 = new TH1F("hChgWidTIB6", "Relative charge", 100, 0, 10);
1264   tree->Project("hChgWidTIB6", MIPdEdx+"*charge/max(1.e-6,firstPathLength)", "subDet==3 && width >= 6 && width <= 8");
1265   hChgWidTIB6->SetLineColor(28);
1266   hChgWidTIB6->Draw("same");
1267 
1268   TH1F* hChgWidTIB8 = new TH1F("hChgWidTIB8", "Relative charge", 100, 0, 10);
1269   tree->Project("hChgWidTIB8", MIPdEdx+"*charge/max(1.e-6,firstPathLength)", "subDet==3 && width > 8");
1270   hChgWidTIB8->SetLineColor(6);
1271   hChgWidTIB8->Draw("same");
1272 
1273   TLegend* CWlegend = new TLegend(.54, .43, .76, .83, "");
1274   CWlegend->AddEntry(hChgWidTIB1, "width = 1", "L");
1275   CWlegend->AddEntry(hChgWidTIB2, "width = 2", "L");
1276   CWlegend->AddEntry(hChgWidTIB3, "width = 3", "L");
1277   CWlegend->AddEntry(hChgWidTIB4, "width = 4", "L");
1278   CWlegend->AddEntry(hChgWidTIB5, "width = 5", "L");
1279   CWlegend->AddEntry(hChgWidTIB6, "width = 6-8", "L");
1280   CWlegend->AddEntry(hChgWidTIB8, "width > 8", "L");
1281   canvNchgWid->cd(1);
1282   CWlegend->Draw();
1283   canvNchgWid->Update();
1284 
1285   canvNchgWid->cd(2);
1286   hChgWidTIB3->Draw();
1287   hChgWidTIB1->Draw("same");
1288   hChgWidTIB2->Draw("same");
1289   hChgWidTIB4->Draw("same");
1290   hChgWidTIB5->Draw("same");
1291   hChgWidTIB6->Draw("same");
1292   hChgWidTIB8->Draw("same");
1293   gPad->SetLogy(1);
1294   canvNchgWid->Update();
1295 
1296   // TOB
1297 
1298   TH1F* hChgWidTOB3 = new TH1F("hChgWidTOB3", "Relative charge", 100, 0, 10);
1299   tree->Project("hChgWidTOB3", MIPdEdx+"*charge/max(1.e-6,firstPathLength)", "subDet==5 && width == 3");
1300   hChgWidTOB3->GetXaxis()->SetTitle("Charge/(path length), MIP");
1301   hChgWidTOB3->SetLineColor(kBlack);
1302   canvNchgWid->cd(3);
1303   hChgWidTOB3->Draw();
1304 
1305   TH1F* hChgWidTOB1 = new TH1F("hChgWidTOB1", "Relative charge", 100, 0, 10);
1306   tree->Project("hChgWidTOB1", MIPdEdx+"*charge/max(1.e-6,firstPathLength)", "subDet==5 && width == 1");
1307   hChgWidTOB1->SetLineColor(kRed);
1308   hChgWidTOB1->Draw("same");
1309 
1310   TH1F* hChgWidTOB2 = new TH1F("hChgWidTOB2", "Relative charge", 100, 0, 10);
1311   tree->Project("hChgWidTOB2", MIPdEdx+"*charge/max(1.e-6,firstPathLength)", "subDet==5 && width == 2");
1312   hChgWidTOB2->SetLineColor(kBlue);
1313   hChgWidTOB2->Draw("same");
1314 
1315   TH1F* hChgWidTOB4 = new TH1F("hChgWidTOB4", "Relative charge", 100, 0, 10);
1316   tree->Project("hChgWidTOB4", MIPdEdx+"*charge/max(1.e-6,firstPathLength)", "subDet==5 && width == 4");
1317   hChgWidTOB4->SetLineColor(8);
1318   hChgWidTOB4->Draw("same");
1319 
1320   TH1F* hChgWidTOB5 = new TH1F("hChgWidTOB5", "Relative charge", 100, 0, 10);
1321   tree->Project("hChgWidTOB5", MIPdEdx+"*charge/max(1.e-6,firstPathLength)", "subDet==5 && width == 5");
1322   hChgWidTOB5->SetLineColor(7);
1323   hChgWidTOB5->Draw("same");
1324 
1325   TH1F* hChgWidTOB6 = new TH1F("hChgWidTOB6", "Relative charge", 100, 0, 10);
1326   tree->Project("hChgWidTOB6", MIPdEdx+"*charge/max(1.e-6,firstPathLength)", "subDet==5 && width >= 6 && width <= 8");
1327   hChgWidTOB6->SetLineColor(28);
1328   hChgWidTOB6->Draw("same");
1329 
1330   TH1F* hChgWidTOB8 = new TH1F("hChgWidTOB8", "Relative charge", 100, 0, 10);
1331   tree->Project("hChgWidTOB8", MIPdEdx+"*charge/max(1.e-6,firstPathLength)", "subDet==5 && width > 8");
1332   hChgWidTOB8->SetLineColor(6);
1333   hChgWidTOB8->Draw("same");
1334 
1335   canvNchgWid->cd(4);
1336   hChgWidTOB3->Draw();
1337   hChgWidTOB1->Draw("same");
1338   hChgWidTOB2->Draw("same");
1339   hChgWidTOB4->Draw("same");
1340   hChgWidTOB5->Draw("same");
1341   hChgWidTOB6->Draw("same");
1342   hChgWidTOB8->Draw("same");
1343   gPad->SetLogy(1);
1344   canvNchgWid->Update();
1345 
1346   TCanvas *canvNchgWidEC = new TCanvas("canvNchgWidEC", "canvNchgWidEC", 1100, 800);
1347   canvNchgWidEC->Divide(2,2);
1348 
1349   // TID
1350 
1351   TH1F* hChgWidTID3 = new TH1F("hChgWidTID3", "Relative charge", 100, 0, 10);
1352   tree->Project("hChgWidTID3", MIPdEdx+"*charge/max(1.e-6,firstPathLength)", "subDet==4 && width == 3");
1353   hChgWidTID3->GetXaxis()->SetTitle("Charge/(path length), MIP");
1354   hChgWidTID3->SetLineColor(kBlack);
1355   canvNchgWidEC->cd(1);
1356   hChgWidTID3->Draw();
1357 
1358   TH1F* hChgWidTID1 = new TH1F("hChgWidTID1", "Relative charge", 100, 0, 10);
1359   tree->Project("hChgWidTID1", MIPdEdx+"*charge/max(1.e-6,firstPathLength)", "subDet==4 && width == 1");
1360   hChgWidTID1->SetLineColor(kRed);
1361   hChgWidTID1->Draw("same");
1362 
1363   TH1F* hChgWidTID2 = new TH1F("hChgWidTID2", "Relative charge", 100, 0, 10);
1364   tree->Project("hChgWidTID2", MIPdEdx+"*charge/max(1.e-6,firstPathLength)", "subDet==4 && width == 2");
1365   hChgWidTID2->SetLineColor(kBlue);
1366   hChgWidTID2->Draw("same");
1367 
1368   TH1F* hChgWidTID4 = new TH1F("hChgWidTID4", "Relative charge", 100, 0, 10);
1369   tree->Project("hChgWidTID4", MIPdEdx+"*charge/max(1.e-6,firstPathLength)", "subDet==4 && width == 4");
1370   hChgWidTID4->SetLineColor(8);
1371   hChgWidTID4->Draw("same");
1372 
1373   TH1F* hChgWidTID5 = new TH1F("hChgWidTID5", "Relative charge", 100, 0, 10);
1374   tree->Project("hChgWidTID5", MIPdEdx+"*charge/max(1.e-6,firstPathLength)", "subDet==4 && width == 5");
1375   hChgWidTID5->SetLineColor(7);
1376   hChgWidTID5->Draw("same");
1377 
1378   TH1F* hChgWidTID6 = new TH1F("hChgWidTID6", "Relative charge", 100, 0, 10);
1379   tree->Project("hChgWidTID6", MIPdEdx+"*charge/max(1.e-6,firstPathLength)", "subDet==4 && width >= 6 && width <= 8");
1380   hChgWidTID6->SetLineColor(28);
1381   hChgWidTID6->Draw("same");
1382 
1383   TH1F* hChgWidTID8 = new TH1F("hChgWidTID8", "Relative charge", 100, 0, 10);
1384   tree->Project("hChgWidTID8", MIPdEdx+"*charge/max(1.e-6,firstPathLength)", "subDet==4 && width > 8");
1385   hChgWidTID8->SetLineColor(6);
1386   hChgWidTID8->Draw("same");
1387 
1388   canvNchgWidEC->cd(2);
1389   hChgWidTID3->Draw();
1390   hChgWidTID1->Draw("same");
1391   hChgWidTID2->Draw("same");
1392   hChgWidTID4->Draw("same");
1393   hChgWidTID5->Draw("same");
1394   hChgWidTID6->Draw("same");
1395   hChgWidTID8->Draw("same");
1396   gPad->SetLogy(1);
1397   canvNchgWidEC->Update();
1398 
1399   canvNchgWidEC->cd(1);
1400   CWlegend->Draw();
1401   canvNchgWidEC->Update();
1402 
1403   // TEC
1404 
1405   TH1F* hChgWidTEC3 = new TH1F("hChgWidTEC3", "Relative charge", 100, 0, 10);
1406   tree->Project("hChgWidTEC3", MIPdEdx+"*charge/max(1.e-6,firstPathLength)", "subDet==6 && width == 3");
1407   hChgWidTEC3->GetXaxis()->SetTitle("Charge/(path length), MIP");
1408   hChgWidTEC3->SetLineColor(kBlack);
1409   canvNchgWidEC->cd(3);
1410   hChgWidTEC3->Draw();
1411 
1412   TH1F* hChgWidTEC1 = new TH1F("hChgWidTEC1", "Relative charge", 100, 0, 10);
1413   tree->Project("hChgWidTEC1", MIPdEdx+"*charge/max(1.e-6,firstPathLength)", "subDet==6 && width == 1");
1414   hChgWidTEC1->SetLineColor(kRed);
1415   hChgWidTEC1->Draw("same");
1416 
1417   TH1F* hChgWidTEC2 = new TH1F("hChgWidTEC2", "Relative charge", 100, 0, 10);
1418   tree->Project("hChgWidTEC2", MIPdEdx+"*charge/max(1.e-6,firstPathLength)", "subDet==6 && width == 2");
1419   hChgWidTEC2->SetLineColor(kBlue);
1420   hChgWidTEC2->Draw("same");
1421 
1422   TH1F* hChgWidTEC4 = new TH1F("hChgWidTEC4", "Relative charge", 100, 0, 10);
1423   tree->Project("hChgWidTEC4", MIPdEdx+"*charge/max(1.e-6,firstPathLength)", "subDet==6 && width == 4");
1424   hChgWidTEC4->SetLineColor(8);
1425   hChgWidTEC4->Draw("same");
1426 
1427   TH1F* hChgWidTEC5 = new TH1F("hChgWidTEC5", "Relative charge", 100, 0, 10);
1428   tree->Project("hChgWidTEC5", MIPdEdx+"*charge/max(1.e-6,firstPathLength)", "subDet==6 && width == 5");
1429   hChgWidTEC5->SetLineColor(7);
1430   hChgWidTEC5->Draw("same");
1431 
1432   TH1F* hChgWidTEC6 = new TH1F("hChgWidTEC6", "Relative charge", 100, 0, 10);
1433   tree->Project("hChgWidTEC6", MIPdEdx+"*charge/max(1.e-6,firstPathLength)", "subDet==6 && width >= 6 && width <= 8");
1434   hChgWidTEC6->SetLineColor(28);
1435   hChgWidTEC6->Draw("same");
1436 
1437   TH1F* hChgWidTEC8 = new TH1F("hChgWidTEC8", "Relative charge", 100, 0, 10);
1438   tree->Project("hChgWidTEC8", MIPdEdx+"*charge/max(1.e-6,firstPathLength)", "subDet==6 && width > 8");
1439   hChgWidTEC8->SetLineColor(6);
1440   hChgWidTEC8->Draw("same");
1441 
1442   canvNchgWidEC->cd(4);
1443   hChgWidTEC3->Draw();
1444   hChgWidTEC1->Draw("same");
1445   hChgWidTEC2->Draw("same");
1446   hChgWidTEC4->Draw("same");
1447   hChgWidTEC5->Draw("same");
1448   hChgWidTEC6->Draw("same");
1449   hChgWidTEC8->Draw("same");
1450   gPad->SetLogy(1);
1451   canvNchgWidEC->Update();
1452 
1453   canvNchgWid->SaveAs("clusNtp_relChgWid.pdf");
1454   canvNchgWidEC->SaveAs("clusNtp_relChgWidEC.pdf");
1455 
1456 }  // ---------------------------------------------------------------
1457 
1458 void plot_ChgTnrm_v_Snrm(TTree* tree, const TString& MIPdEdx, const TCut& cut1, const TCut& cut2, const TCut& cut3) {
1459 
1460   TCanvas *canvChgTnrm_v_Snrm = new TCanvas("canvChgTnrm_v_Snrm", "canvChgTnrm_v_Snrm", 1100, 800);
1461   canvChgTnrm_v_Snrm->Divide(2,2);
1462 
1463   // TIB
1464   TH1F* hrelChgTIBMItrue = new TH1F("hrelChgTIBMItrue", "Relative charge", 100, 0, 10);
1465   tree->Project("hrelChgTIBMItrue", MIPdEdx+"*charge/max(1.e-6,firstPathLength)", cut1&&"subDet==3");
1466   hrelChgTIBMItrue->GetXaxis()->SetTitle("Charge/(path length), MIP");
1467   hrelChgTIBMItrue->SetMinimum(10);
1468   hrelChgTIBMItrue->SetLineColor(8);
1469   canvChgTnrm_v_Snrm->cd(1);
1470   hrelChgTIBMItrue->Draw();
1471 
1472   TH1F* hrelChgTIBMIstr = new TH1F("hrelChgTIBMIstr", "Relative charge", 100, 0, 10);
1473   tree->Project("hrelChgTIBMIstr", MIPdEdx+"*charge/max(1.e-6,pathLstraight)", cut1&&"subDet==3");
1474   hrelChgTIBMIstr->GetXaxis()->SetTitle("Charge/(path length), MIP");
1475   hrelChgTIBMIstr->SetLineColor(kBlack);
1476   hrelChgTIBMIstr->SetLineStyle(kDashed);
1477   hrelChgTIBMIstr->Draw("sames");
1478 
1479   TH1F* hrelChgTIB2MItrue = new TH1F("hrelChgTIB2MItrue", "Relative charge", 100, 0, 10);
1480   tree->Project("hrelChgTIB2MItrue", MIPdEdx+"*charge/max(1.e-6,firstPathLength)", cut3&&"subDet==3");
1481   hrelChgTIB2MItrue->GetXaxis()->SetTitle("Charge/(path length), MIP");
1482   hrelChgTIB2MItrue->SetLineColor(kRed);
1483   hrelChgTIB2MItrue->Draw("sames");
1484 
1485   TH1F* hrelChgTIB2MIstr = new TH1F("hrelChgTIB2MIstr", "Relative charge", 100, 0, 10);
1486   tree->Project("hrelChgTIB2MIstr", MIPdEdx+"*charge/max(1.e-6,pathLstraight)", cut3&&"subDet==3");
1487   hrelChgTIB2MIstr->GetXaxis()->SetTitle("Charge/(path length), MIP");
1488   hrelChgTIB2MIstr->SetLineColor(kBlue);
1489   hrelChgTIB2MIstr->SetLineStyle(kDashed);
1490   hrelChgTIB2MIstr->Draw("sames");
1491 
1492   gPad->SetLogy(1);
1493 
1494   canvChgTnrm_v_Snrm->Update();  // without this the "stats" pointers are null
1495   double top = 0.0;
1496   drawStats(hrelChgTIBMItrue, top);
1497   drawStats(hrelChgTIBMIstr, top);
1498   drawStats(hrelChgTIB2MItrue, top);
1499   drawStats(hrelChgTIB2MIstr, top);
1500   canvChgTnrm_v_Snrm->Update();
1501 
1502   // TID
1503   TH1F* hrelChgTIDMItrue = new TH1F("hrelChgTIDMItrue", "Relative charge", 100, 0, 10);
1504   tree->Project("hrelChgTIDMItrue", MIPdEdx+"*charge/max(1.e-6,firstPathLength)", cut1&&"subDet==4");
1505   hrelChgTIDMItrue->GetXaxis()->SetTitle("Charge/(path length), MIP");
1506   hrelChgTIDMItrue->SetMinimum(1);
1507   hrelChgTIDMItrue->SetLineColor(8);
1508   canvChgTnrm_v_Snrm->cd(2);
1509   hrelChgTIDMItrue->Draw();
1510 
1511   TH1F* hrelChgTIDMIstr = new TH1F("hrelChgTIDMIstr", "Relative charge", 100, 0, 10);
1512   tree->Project("hrelChgTIDMIstr", MIPdEdx+"*charge/max(1.e-6,pathLstraight)", cut1&&"subDet==4");
1513   hrelChgTIDMIstr->GetXaxis()->SetTitle("Charge/(path length), MIP");
1514   hrelChgTIDMIstr->SetLineColor(kBlack);
1515   hrelChgTIDMIstr->SetLineStyle(kDashed);
1516   hrelChgTIDMIstr->Draw("sames");
1517 
1518   TH1F* hrelChgTID2MItrue = new TH1F("hrelChgTID2MItrue", "Relative charge", 100, 0, 10);
1519   tree->Project("hrelChgTID2MItrue", MIPdEdx+"*charge/max(1.e-6,firstPathLength)", cut3&&"subDet==4");
1520   hrelChgTID2MItrue->GetXaxis()->SetTitle("Charge/(path length), MIP");
1521   hrelChgTID2MItrue->SetLineColor(kRed);
1522   hrelChgTID2MItrue->Draw("sames");
1523 
1524   TH1F* hrelChgTID2MIstr = new TH1F("hrelChgTID2MIstr", "Relative charge", 100, 0, 10);
1525   tree->Project("hrelChgTID2MIstr", MIPdEdx+"*charge/max(1.e-6,pathLstraight)", cut3&&"subDet==4");
1526   hrelChgTID2MIstr->GetXaxis()->SetTitle("Charge/(path length), MIP");
1527   hrelChgTID2MIstr->SetLineColor(kBlue);
1528   hrelChgTID2MIstr->SetLineStyle(kDashed);
1529   hrelChgTID2MIstr->Draw("sames");
1530 
1531   gPad->SetLogy(1);
1532 
1533   canvChgTnrm_v_Snrm->Update();  // without this the "stats" pointers are null
1534   top = 0.0;
1535   drawStats(hrelChgTIDMItrue, top);
1536   drawStats(hrelChgTIDMIstr, top);
1537   drawStats(hrelChgTID2MItrue, top);
1538   drawStats(hrelChgTID2MIstr, top);
1539   canvChgTnrm_v_Snrm->Update();
1540 
1541   // TOB
1542   TH1F* hrelChgTOBMItrue = new TH1F("hrelChgTOBMItrue", "Relative charge", 100, 0, 10);
1543   tree->Project("hrelChgTOBMItrue", MIPdEdx+"*charge/max(1.e-6,firstPathLength)", cut1&&"subDet==5");
1544   hrelChgTOBMItrue->GetXaxis()->SetTitle("Charge/(path length), MIP");
1545   hrelChgTOBMItrue->SetMinimum(10);
1546   hrelChgTOBMItrue->SetLineColor(8);
1547   canvChgTnrm_v_Snrm->cd(3);
1548   hrelChgTOBMItrue->Draw();
1549 
1550   TH1F* hrelChgTOBMIstr = new TH1F("hrelChgTOBMIstr", "Relative charge", 100, 0, 10);
1551   tree->Project("hrelChgTOBMIstr", MIPdEdx+"*charge/max(1.e-6,pathLstraight)", cut1&&"subDet==5");
1552   hrelChgTOBMIstr->GetXaxis()->SetTitle("Charge/(path length), MIP");
1553   hrelChgTOBMIstr->SetLineColor(kBlack);
1554   hrelChgTOBMIstr->SetLineStyle(kDashed);
1555   hrelChgTOBMIstr->Draw("sames");
1556 
1557   TH1F* hrelChgTOB2MItrue = new TH1F("hrelChgTOB2MItrue", "Relative charge", 100, 0, 10);
1558   tree->Project("hrelChgTOB2MItrue", MIPdEdx+"*charge/max(1.e-6,firstPathLength)", cut3&&"subDet==5");
1559   hrelChgTOB2MItrue->GetXaxis()->SetTitle("Charge/(path length), MIP");
1560   hrelChgTOB2MItrue->SetLineColor(kRed);
1561   hrelChgTOB2MItrue->Draw("sames");
1562 
1563   TH1F* hrelChgTOB2MIstr = new TH1F("hrelChgTOB2MIstr", "Relative charge", 100, 0, 10);
1564   tree->Project("hrelChgTOB2MIstr", MIPdEdx+"*charge/max(1.e-6,pathLstraight)", cut3&&"subDet==5");
1565   hrelChgTOB2MIstr->GetXaxis()->SetTitle("Charge/(path length), MIP");
1566   hrelChgTOB2MIstr->SetLineColor(kBlue);
1567   hrelChgTOB2MIstr->SetLineStyle(kDashed);
1568   hrelChgTOB2MIstr->Draw("sames");
1569 
1570   gPad->SetLogy(1);
1571 
1572   canvChgTnrm_v_Snrm->Update();  // without this the "stats" pointers are null
1573   top = 0.0;
1574   drawStats(hrelChgTOBMItrue, top);
1575   drawStats(hrelChgTOBMIstr, top);
1576   drawStats(hrelChgTOB2MItrue, top);
1577   drawStats(hrelChgTOB2MIstr, top);
1578   canvChgTnrm_v_Snrm->Update();
1579 
1580   // TEC
1581   TH1F* hrelChgTECMItrue = new TH1F("hrelChgTECMItrue", "Relative charge", 100, 0, 10);
1582   tree->Project("hrelChgTECMItrue", MIPdEdx+"*charge/max(1.e-6,firstPathLength)", cut1&&"subDet==6");
1583   hrelChgTECMItrue->GetXaxis()->SetTitle("Charge/(path length), MIP");
1584   hrelChgTECMItrue->SetMinimum(1);
1585   hrelChgTECMItrue->SetLineColor(8);
1586   canvChgTnrm_v_Snrm->cd(4);
1587   hrelChgTECMItrue->Draw();
1588 
1589   TH1F* hrelChgTECMIstr = new TH1F("hrelChgTECMIstr", "Relative charge", 100, 0, 10);
1590   tree->Project("hrelChgTECMIstr", MIPdEdx+"*charge/max(1.e-6,pathLstraight)", cut1&&"subDet==6");
1591   hrelChgTECMIstr->GetXaxis()->SetTitle("Charge/(path length), MIP");
1592   hrelChgTECMIstr->SetLineColor(kBlack);
1593   hrelChgTECMIstr->SetLineStyle(kDashed);
1594   hrelChgTECMIstr->Draw("sames");
1595 
1596   TH1F* hrelChgTEC2MItrue = new TH1F("hrelChgTEC2MItrue", "Relative charge", 100, 0, 10);
1597   tree->Project("hrelChgTEC2MItrue", MIPdEdx+"*charge/max(1.e-6,firstPathLength)", cut3&&"subDet==6");
1598   hrelChgTEC2MItrue->GetXaxis()->SetTitle("Charge/(path length), MIP");
1599   hrelChgTEC2MItrue->SetLineColor(kRed);
1600   hrelChgTEC2MItrue->Draw("sames");
1601 
1602   TH1F* hrelChgTEC2MIstr = new TH1F("hrelChgTEC2MIstr", "Relative charge", 100, 0, 10);
1603   tree->Project("hrelChgTEC2MIstr", MIPdEdx+"*charge/max(1.e-6,pathLstraight)", cut3&&"subDet==6");
1604   hrelChgTEC2MIstr->GetXaxis()->SetTitle("Charge/(path length), MIP");
1605   hrelChgTEC2MIstr->SetLineColor(kBlue);
1606   hrelChgTEC2MIstr->SetLineStyle(kDashed);
1607   hrelChgTEC2MIstr->Draw("sames");
1608 
1609   gPad->SetLogy(1);
1610 
1611   canvChgTnrm_v_Snrm->Update();  // without this the "stats" pointers are null
1612   top = 0.0;
1613   drawStats(hrelChgTECMItrue, top);
1614   drawStats(hrelChgTECMIstr, top);
1615   drawStats(hrelChgTEC2MItrue, top);
1616   drawStats(hrelChgTEC2MIstr, top);
1617   canvChgTnrm_v_Snrm->Update();
1618 
1619   TLegend* Rtlegend = new TLegend(.30, .67, .74, .87, "");
1620   Rtlegend->AddEntry(hrelChgTIBMItrue, "1 crossing primary, true path", "L");
1621   Rtlegend->AddEntry(hrelChgTIBMIstr, "1 crossing primary, straight path", "L");
1622   Rtlegend->AddEntry(hrelChgTIB2MItrue, "2 crossing primaries, true path", "L");
1623   Rtlegend->AddEntry(hrelChgTIB2MIstr, "2 crossing primaries, straight path", "L");
1624   canvChgTnrm_v_Snrm->cd(1);
1625   Rtlegend->Draw();
1626   canvChgTnrm_v_Snrm->Update();
1627 
1628   canvChgTnrm_v_Snrm->SaveAs("clusNtp_ChgTnrm_v_Snrm.pdf");
1629 
1630 }  // ---------------------------------------------------------------
1631 
1632 
1633 void plot_ChgPath(TTree* tree, const TCut& cut) {
1634 
1635   TCanvas *canvChgPath = new TCanvas("canvChgPath", "canvChgPath", 1100, 800);
1636   canvChgPath->Divide(2,2);
1637   gStyle->SetPalette(1);
1638 
1639   // TIB
1640   TH2F* hChgPathTIBMI = new TH2F("hChgPathTIBMI", "Charge vs Path length", 140, 280, 420, 110, 0, 550);
1641   tree->Project("hChgPathTIBMI", "charge:10000*secondPathLength", cut&&"subDet==3");
1642   hChgPathTIBMI->GetXaxis()->SetTitle("MC path (microns)");
1643   hChgPathTIBMI->GetYaxis()->SetTitle("Raw charge");
1644   hChgPathTIBMI->SetLineColor(8);
1645   canvChgPath->cd(1);
1646   hChgPathTIBMI->Draw("colz");
1647 
1648   // TID
1649   TH2F* hChgPathTIDMI = new TH2F("hChgPathTIDMI", "Charge vs Path length", 240, 280, 400, 110, 0, 550);
1650   tree->Project("hChgPathTIDMI", "charge:10000*secondPathLength", cut&&"subDet==4");
1651   hChgPathTIDMI->GetXaxis()->SetTitle("MC path (microns)");
1652   hChgPathTIDMI->GetYaxis()->SetTitle("Raw charge");
1653   hChgPathTIDMI->SetLineColor(8);
1654   canvChgPath->cd(2);
1655   hChgPathTIDMI->Draw("colz");
1656 
1657   // TOB
1658   TH2F* hChgPathTOBMI = new TH2F("hChgPathTOBMI", "Charge vs Path length", 170, 460, 630, 110, 0, 550);
1659   tree->Project("hChgPathTOBMI", "charge:10000*secondPathLength", cut&&"subDet==5");
1660   hChgPathTOBMI->GetXaxis()->SetTitle("MC path (microns)");
1661   hChgPathTOBMI->GetYaxis()->SetTitle("Raw charge");
1662   hChgPathTOBMI->SetLineColor(8);
1663   canvChgPath->cd(3);
1664   hChgPathTOBMI->Draw("colz");
1665 
1666   // TEC
1667   TH2F* hChgPathTECMI = new TH2F("hChgPathTECMI", "Charge vs Path length", 320, 280, 600, 110, 0, 550);
1668   tree->Project("hChgPathTECMI", "charge:10000*secondPathLength", cut&&"subDet==6");
1669   hChgPathTECMI->GetXaxis()->SetTitle("MC path (microns)");
1670   hChgPathTECMI->GetYaxis()->SetTitle("Raw charge");
1671   hChgPathTECMI->SetLineColor(8);
1672   canvChgPath->cd(4);
1673   hChgPathTECMI->Draw("colz");
1674 
1675   canvChgPath->SaveAs("clusNtp_chgPath.pdf");
1676 
1677 }  // ---------------------------------------------------------------
1678 
1679 void plot_ChgAsym(TTree* tree, const TString& MIPdEdx, const TCut& cut) {
1680 
1681   TCanvas *canvChgAsym = new TCanvas("canvChgAsym", "canvChgAsym", 1100, 800);
1682   canvChgAsym->Divide(2,2);
1683   gStyle->SetPalette(1);
1684 
1685   // TIB
1686   TH2F* hChgAsymTIB = new TH2F("hChgAsymTIB", "Charge asymmetry vs norm. charge", 100, 0, 10, 100, -1, 1);
1687   tree->Project("hChgAsymTIB", "(1-2*tkFlip)*(firstTkChg-secondTkChg)/(firstTkChg+secondTkChg):"+MIPdEdx+"*charge/max(1.e-6,firstPathLength)", cut&&"subDet==3");
1688   hChgAsymTIB->GetXaxis()->SetTitle("Charge/(path length), MIP");
1689   hChgAsymTIB->GetYaxis()->SetTitle("2-track charge asymmetry");
1690   hChgAsymTIB->SetLineColor(8);
1691   hChgAsymTIB->SetMaximum(80);
1692   canvChgAsym->cd(1);
1693   hChgAsymTIB->Draw("colz");
1694 
1695   // TID
1696   TH2F* hChgAsymTID = new TH2F("hChgAsymTID", "Charge asymmetry vs norm. charge", 100, 0, 10, 100, -1, 1);
1697   tree->Project("hChgAsymTID", "(1-2*tkFlip)*(firstTkChg-secondTkChg)/(firstTkChg+secondTkChg):"+MIPdEdx+"*charge/max(1.e-6,firstPathLength)", cut&&"subDet==4");
1698   hChgAsymTID->GetXaxis()->SetTitle("Charge/(path length), MIP");
1699   hChgAsymTID->GetYaxis()->SetTitle("2-track charge asymmetry");
1700   hChgAsymTID->SetLineColor(8);
1701   hChgAsymTID->SetMaximum(20);
1702   canvChgAsym->cd(2);
1703   hChgAsymTID->Draw("colz");
1704 
1705   // TOB
1706   TH2F* hChgAsymTOB = new TH2F("hChgAsymTOB", "Charge asymmetry vs norm. charge", 100, 0, 10, 100, -1, 1);
1707   tree->Project("hChgAsymTOB", "(1-2*tkFlip)*(firstTkChg-secondTkChg)/(firstTkChg+secondTkChg):"+MIPdEdx+"*charge/max(1.e-6,firstPathLength)", cut&&"subDet==5");
1708   hChgAsymTOB->GetXaxis()->SetTitle("Charge/(path length), MIP");
1709   hChgAsymTOB->GetYaxis()->SetTitle("2-track charge asymmetry");
1710   hChgAsymTOB->SetLineColor(8);
1711   hChgAsymTOB->SetMaximum(80);
1712   canvChgAsym->cd(3);
1713   hChgAsymTOB->Draw("colz");
1714 
1715   // TEC
1716   TH2F* hChgAsymTEC = new TH2F("hChgAsymTEC", "Charge asymmetry vs norm. charge", 100, 0, 10, 100, -1, 1);
1717   tree->Project("hChgAsymTEC", "(1-2*tkFlip)*(firstTkChg-secondTkChg)/(firstTkChg+secondTkChg):"+MIPdEdx+"*charge/max(1.e-6,firstPathLength)", cut&&"subDet==6");
1718   hChgAsymTEC->GetXaxis()->SetTitle("Charge/(path length), MIP");
1719   hChgAsymTEC->GetYaxis()->SetTitle("2-track charge asymmetry");
1720   hChgAsymTEC->SetLineColor(8);
1721   hChgAsymTEC->SetMaximum(20);
1722   canvChgAsym->cd(4);
1723   hChgAsymTEC->Draw("colz");
1724 
1725   canvChgAsym->SaveAs("clusNtp_chgAsym.pdf");
1726 
1727 }  // ---------------------------------------------------------------
1728 
1729 void plot_Asym(TTree* tree, const TCut& cut) {
1730 
1731   TCanvas *canvAsym = new TCanvas("canvAsym", "canvAsym", 1100, 800);
1732   canvAsym->Divide(2,2);
1733   gStyle->SetPalette(1);
1734 
1735   // TIB
1736   TH1F* hAsymTIB = new TH1F("hAsymTIB", "Charge asymmetry vs norm. charge", 115, -1.15, 1.15);
1737   tree->Project("hAsymTIB", "(1-2*tkFlip)*(firstTkChg-secondTkChg)/(firstTkChg+secondTkChg)", cut&&"subDet==3");
1738   hAsymTIB->GetXaxis()->SetTitle("2-track charge asymmetry");
1739   canvAsym->cd(1);
1740   hAsymTIB->Draw();
1741   canvAsym->Update();
1742 
1743   // TID
1744   TH1F* hAsymTID = new TH1F("hAsymTID", "Charge asymmetry", 100, -1.15, 1.15);
1745   tree->Project("hAsymTID", "(1-2*tkFlip)*(firstTkChg-secondTkChg)/(firstTkChg+secondTkChg)", cut&&"subDet==4");
1746   hAsymTID->GetXaxis()->SetTitle("2-track charge asymmetry");
1747   canvAsym->cd(2);
1748   hAsymTID->Draw();
1749   canvAsym->Update();
1750 
1751   // TOB
1752   TH1F* hAsymTOB = new TH1F("hAsymTOB", "Charge asymmetry", 100, -1.15, 1.15);
1753   tree->Project("hAsymTOB", "(1-2*tkFlip)*(firstTkChg-secondTkChg)/(firstTkChg+secondTkChg)", cut&&"subDet==5");
1754   hAsymTOB->GetXaxis()->SetTitle("2-track charge asymmetry");
1755   canvAsym->cd(3);
1756   hAsymTOB->Draw();
1757   canvAsym->Update();
1758 
1759   // TEC
1760   TH1F* hAsymTEC = new TH1F("hAsymTEC", "Charge asymmetry", 100, -1.15, 1.15);
1761   tree->Project("hAsymTEC", "(1-2*tkFlip)*(firstTkChg-secondTkChg)/(firstTkChg+secondTkChg)", cut&&"subDet==6");
1762   hAsymTEC->GetXaxis()->SetTitle("2-track charge asymmetry");
1763   canvAsym->cd(4);
1764   hAsymTEC->Draw();
1765   canvAsym->Update();
1766 
1767   canvAsym->SaveAs("clusNtp_asym.pdf");
1768 
1769 }  // ---------------------------------------------------------------