Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 11:56:31

0001 // Take two treeFile names as input,
0002 // plot pixel module positions using PlotMillePede::DrawOrigPos(..)
0003 // for BPIX and (BPIX+FPIX) and get the mean values of the histograms
0004 // (i.e. centre of gravity).
0005 // These are printed (in cm) and the difference is evaluated (in mum).
0006 //
0007 // Before executing this script you have to execute allMillePede.C.
0008 
0009 #include <vector>
0010 #include <iostream>
0011 #include "GFUtils/GFHistManager.h"
0012 #include "GFUtils/GFHistArray.h"
0013 #include "PlotMillePede.h"
0014 
0015 void pixelPositionChange(const char *treeFile1, const char *treeFile2)
0016 {
0017   std::vector<PlotMillePede*> ps;
0018   ps.push_back(new PlotMillePede(treeFile1));
0019   ps.push_back(new PlotMillePede(treeFile2));
0020 
0021   std::vector<double> meanBPIX_X(ps.size());
0022   std::vector<double> meanBPIX_Y(ps.size());
0023   std::vector<double> meanBPIX_Z(ps.size());
0024 
0025   std::vector<double> meanPixel_X(ps.size());
0026   std::vector<double> meanPixel_Y(ps.size());
0027   std::vector<double> meanPixel_Z(ps.size());
0028   for (unsigned int i = 0; i < ps.size(); ++i) {
0029     ps[i]->GetHistManager()->SetBatch();
0030     ps[i]->SetSubDetId(1);
0031     ps[i]->DrawOrigPos();
0032     meanBPIX_X[i] = ps[i]->GetHistManager()->GetHistsOf(0,2)->First()->GetMean();
0033     meanBPIX_Y[i] = ps[i]->GetHistManager()->GetHistsOf(0,3)->First()->GetMean();
0034     meanBPIX_Z[i] = ps[i]->GetHistManager()->GetHistsOf(0,4)->First()->GetMean();
0035     ps[i]->SetSubDetIds(1,2);
0036     ps[i]->DrawOrigPos(true);
0037     meanPixel_X[i] = ps[i]->GetHistManager()->GetHistsOf(1,2)->First()->GetMean();
0038     meanPixel_Y[i] = ps[i]->GetHistManager()->GetHistsOf(1,3)->First()->GetMean();
0039     meanPixel_Z[i] = ps[i]->GetHistManager()->GetHistsOf(1,4)->First()->GetMean();
0040 
0041   }
0042   ps[0]->GetHistManager()->Overlay(ps[1]->GetHistManager(), 0, 0, "second");
0043   ps[0]->GetHistManager()->Overlay(ps[1]->GetHistManager(), 1, 1, "second");
0044   ps[0]->GetHistManager()->SetBatch(false);
0045   ps[0]->GetHistManager()->SameWithStats(true);
0046   ps[0]->GetHistManager()->Draw();
0047 
0048   const char separator[] = "====================================================\n";
0049 
0050   std::cout << separator << "BPIX:\n" << separator 
0051         << "x1 x2: " << meanBPIX_X[0] << " " << meanBPIX_X[1]
0052         << '\n'
0053         // << ", diff (in mum) " 
0054         // << (meanBPIX_X[1] - meanBPIX_X[0])* 10000. << '\n'
0055 
0056         << "y1 y2: " << meanBPIX_Y[0] << " " << meanBPIX_Y[1]
0057         << '\n'
0058         // << ", diff (in mum) " 
0059         // << (meanBPIX_Y[1] - meanBPIX_Y[0])* 10000. << '\n'
0060 
0061         << "z1 z2: " << meanBPIX_Z[0] << " " << meanBPIX_Z[1]
0062         << '\n'
0063         // << ", diff (in mum) " 
0064         // << (meanBPIX_Z[1] - meanBPIX_Z[0])* 10000.
0065 
0066         << "Delta(x,y,z) = 2-1 = ("
0067         << (meanBPIX_X[1] - meanBPIX_X[0])* 10000. << ','
0068         << (meanBPIX_Y[1] - meanBPIX_Y[0])* 10000. << ','
0069         << (meanBPIX_Z[1] - meanBPIX_Z[0])* 10000. << ") mum"
0070         << std::endl;
0071 
0072   std::cout << separator << "Pixel:\n" << separator; 
0073   
0074   std::cout << "x1 x2: " << meanPixel_X[0] << " " << meanPixel_X[1]
0075         << '\n'
0076         // << ", diff (in mum) " 
0077         // << (meanPixel_X[1] - meanPixel_X[0])* 10000. << '\n'
0078 
0079         << "y1 y2 " << meanPixel_Y[0] << " " << meanPixel_Y[1]
0080         << '\n'
0081         // << ", diff (in mum) " 
0082         // << (meanPixel_Y[1] - meanPixel_Y[0])* 10000. << '\n'
0083 
0084         << "z1 z2: " << meanPixel_Z[0] << " " << meanPixel_Z[1]
0085         << '\n'
0086         // << ", diff (in mum) " 
0087         // << (meanPixel_Z[1] - meanPixel_Z[0])* 10000.
0088 
0089         << "Delta(x,y,z) = 2-1 = ("
0090         << (meanPixel_X[1] - meanPixel_X[0])* 10000. << ','
0091         << (meanPixel_Y[1] - meanPixel_Y[0])* 10000. << ','
0092         << (meanPixel_Z[1] - meanPixel_Z[0])* 10000. << ") mum"
0093         << std::endl;
0094   
0095   TString shortFileName1(treeFile1);
0096   if (shortFileName1.Contains("/")) { // remove all directory info
0097     shortFileName1.Remove(0, shortFileName1.Last('/') + 1);
0098   }
0099   TString shortFileName2(treeFile2);
0100   if (shortFileName2.Contains("/")) {
0101     shortFileName2.Remove(0, shortFileName2.Last('/') + 1);
0102   }
0103 
0104   std::cout << "|  | *" << shortFileName1 << "* || *"<< shortFileName1 << "*||\n"
0105         << "| *Position* |  *BPIX* | *Full Pixel* | *BPIX* | *Full Pixel* |\n"
0106         << "|  x  | " << meanBPIX_X[0] << " | " << meanPixel_X[0] << " | " << meanBPIX_X[1] << " | " << meanPixel_X[1] << " |\n"
0107         << "|  y  | " << meanBPIX_Y[0] << " | " << meanPixel_Y[0] << " | " << meanBPIX_Y[1] << " | " << meanPixel_Y[1] << " |\n"
0108         << "|  z  | " << meanBPIX_Z[0] << " | " << meanPixel_Z[0] << " | " << meanBPIX_Z[1] << " | " << meanPixel_Z[1] << " |\n"
0109         << std::endl;
0110 
0111   std::cout << separator << separator << separator << std::endl; 
0112 
0113 }
0114