Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:26:02

0001 #!/bin/bash
0002 
0003 # to run this script, do
0004 # ./checkResiduals.sh <filepath_new> <filepath_ref>
0005 # where <filepath_new> and <filepath_ref> are the paths to the output root files from CSCValiation
0006 
0007 # example:  ./checkResiduals.sh CMSSW_1_8_0_pre8/src/RecoLocalMuon/CSCValidation/test/validationHists_muongun.root CMSSW_1_7_4/src/RecoLocalMuon/CSCValidation/test/validationHists_muongun.root
0008 
0009 ARG1=$1
0010 ARG2=$2
0011 
0012 MACRO=checkResid_temp.C
0013 cat > ${MACRO}<<EOF
0014 
0015 {
0016 
0017   std::string newReleaseFile = "${ARG1}";
0018   std::string refReleaseFile = "${ARG2}";
0019 
0020   ofstream out;
0021   out.open("residual_compare_results.txt");
0022 
0023   TFile *fn = new TFile(newReleaseFile.c_str(),"READ");
0024   TFile *fo = new TFile(refReleaseFile.c_str(),"READ");
0025 
0026   TF1 *f1 = new TF1("f1","gaus",-0.1,0.1);
0027   TF1 *f2 = new TF1("f2","gaus",-0.1,0.1);
0028 
0029   TH1F *ho;
0030   TH1F *hn;
0031 
0032   // ME 1/1a
0033   ho = (TH1F*)fo->Get("recHits/hSResid11a");
0034   hn = (TH1F*)fn->Get("recHits/hSResid11a");
0035 
0036   ho->Fit("f1","RNQ");
0037   hn->Fit("f2","RNQ");
0038 
0039   float sigmao11a = f1->GetParameter(2);
0040   float sigmaoerr11a = f1->GetParError(2);
0041   float sigman11a = f2->GetParameter(2);
0042   float sigmanerr11a = f2->GetParError(2);
0043   float diff11a = (sigman11a - sigmao11a);
0044   float differr11a = sqrt(sigmaoerr11a*sigmaoerr11a + sigmanerr11a*sigmanerr11a);
0045 
0046   out << "Results for ME11a:" << endl;
0047   out << endl;
0048   out << "Ref Fit: " << sigmao11a << " +/- " << sigmaoerr11a << endl;
0049   out << "New Fit: " << sigman11a << " +/- " << sigmanerr11a << endl;
0050   out << endl;
0051   out << "Diff: " << diff11a << " +/- " << differr11a << endl;
0052   out << endl;
0053   if (fabs(diff11a) > 0.01) out << "CAUTION!!! Residuals for this chamber type have changed!!!" << endl;
0054   out << endl;
0055   out << endl;
0056 
0057   // ME 1/1b
0058   ho = (TH1F*)fo->Get("recHits/hSResid11b");
0059   hn = (TH1F*)fn->Get("recHits/hSResid11b");
0060 
0061   ho->Fit("f1","RNQ");
0062   hn->Fit("f2","RNQ");
0063 
0064   float sigmao11b = f1->GetParameter(2);
0065   float sigmaoerr11b = f1->GetParError(2);
0066   float sigman11b = f2->GetParameter(2);
0067   float sigmanerr11b = f2->GetParError(2);
0068   float diff11b = (sigman11b - sigmao11b);
0069   float differr11b = sqrt(sigmaoerr11b*sigmaoerr11b + sigmanerr11b*sigmanerr11b);
0070 
0071   out << "Results for ME11b:" << endl;
0072   out << endl;
0073   out << "Ref Fit: " << sigmao11b << " +/- " << sigmaoerr11b << endl;
0074   out << "New Fit: " << sigman11b << " +/- " << sigmanerr11b << endl;
0075   out << endl;
0076   out << "Diff: " << diff11b << " +/- " << differr11b << endl;
0077   out << endl;
0078   if (fabs(diff11b) > 0.01) out << "CAUTION!!! Residuals for this chamber type have changed!!!" << endl;
0079   out << endl;
0080   out << endl;
0081 
0082   // ME 1/2
0083   ho = (TH1F*)fo->Get("recHits/hSResid12");
0084   hn = (TH1F*)fn->Get("recHits/hSResid12");
0085 
0086   ho->Fit("f1","RNQ");
0087   hn->Fit("f2","RNQ");
0088 
0089   float sigmao12 = f1->GetParameter(2);
0090   float sigmaoerr12 = f1->GetParError(2);
0091   float sigman12 = f2->GetParameter(2);
0092   float sigmanerr12 = f2->GetParError(2);
0093   float diff12 = (sigman12 - sigmao12);
0094   float differr12 = sqrt(sigmaoerr12*sigmaoerr12 + sigmanerr12*sigmanerr12);
0095 
0096   out << "Results for ME12:" << endl;
0097   out << endl;
0098   out << "Ref Fit: " << sigmao12 << " +/- " << sigmaoerr12 << endl;
0099   out << "New Fit: " << sigman12 << " +/- " << sigmanerr12 << endl;
0100   out << endl;
0101   out << "Diff: " << diff12 << " +/- " << differr12 << endl;
0102   out << endl;
0103   if (fabs(diff12) > 0.01) out << "CAUTION!!! Residuals for this chamber type have changed!!!" << endl;
0104   out << endl;
0105   out << endl;
0106 
0107   // ME 1/3
0108   ho = (TH1F*)fo->Get("recHits/hSResid13");
0109   hn = (TH1F*)fn->Get("recHits/hSResid13");
0110 
0111   ho->Fit("f1","RNQ");
0112   hn->Fit("f2","RNQ");
0113 
0114   float sigmao13 = f1->GetParameter(2);
0115   float sigmaoerr13 = f1->GetParError(2);
0116   float sigman13 = f2->GetParameter(2);
0117   float sigmanerr13 = f2->GetParError(2);
0118   float diff13 = (sigman13 - sigmao13);
0119   float differr13 = sqrt(sigmaoerr13*sigmaoerr13 + sigmanerr13*sigmanerr13);
0120 
0121   out << "Results for ME13:" << endl;
0122   out << endl;
0123   out << "Ref Fit: " << sigmao13 << " +/- " << sigmaoerr13 << endl;
0124   out << "New Fit: " << sigman13 << " +/- " << sigmanerr13 << endl;
0125   out << endl;
0126   out << "Diff: " << diff13 << " +/- " << differr13 << endl;
0127   out << endl;
0128   if (fabs(diff13) > 0.01) out << "CAUTION!!! Residuals for this chamber type have changed!!!" << endl;
0129   out << endl;
0130   out << endl;
0131 
0132   // ME 2/1
0133   ho = (TH1F*)fo->Get("recHits/hSResid21");
0134   hn = (TH1F*)fn->Get("recHits/hSResid21");
0135 
0136   ho->Fit("f1","RNQ");
0137   hn->Fit("f2","RNQ");
0138 
0139   float sigmao21 = f1->GetParameter(2);
0140   float sigmaoerr21 = f1->GetParError(2);
0141   float sigman21 = f2->GetParameter(2);
0142   float sigmanerr21 = f2->GetParError(2);
0143   float diff21 = (sigman21 - sigmao21);
0144   float differr21 = sqrt(sigmaoerr21*sigmaoerr21 + sigmanerr21*sigmanerr21);
0145 
0146   out << "Results for ME21:" << endl;
0147   out << endl;
0148   out << "Ref Fit: " << sigmao21 << " +/- " << sigmaoerr21 << endl;
0149   out << "New Fit: " << sigman21 << " +/- " << sigmanerr21 << endl;
0150   out << endl;
0151   out << "Diff: " << diff21 << " +/- " << differr21 << endl;
0152   out << endl;
0153   if (fabs(diff21) > 0.01) out << "CAUTION!!! Residuals for this chamber type have changed!!!" << endl;
0154   out << endl;
0155   out << endl;
0156 
0157   // ME 2/2
0158   ho = (TH1F*)fo->Get("recHits/hSResid22");
0159   hn = (TH1F*)fn->Get("recHits/hSResid22");
0160 
0161   ho->Fit("f1","RNQ");
0162   hn->Fit("f2","RNQ");
0163 
0164   float sigmao22 = f1->GetParameter(2);
0165   float sigmaoerr22 = f1->GetParError(2);
0166   float sigman22 = f2->GetParameter(2);
0167   float sigmanerr22 = f2->GetParError(2);
0168   float diff22 = (sigman22 - sigmao22);
0169   float differr22 = sqrt(sigmaoerr22*sigmaoerr22 + sigmanerr22*sigmanerr22);
0170 
0171   out << "Results for ME22:" << endl;
0172   out << endl;
0173   out << "Ref Fit: " << sigmao22 << " +/- " << sigmaoerr22 << endl;
0174   out << "New Fit: " << sigman22 << " +/- " << sigmanerr22 << endl;
0175   out << endl;
0176   out << "Diff: " << diff22 << " +/- " << differr22 << endl;
0177   out << endl;
0178   if (fabs(diff22) > 0.01) out << "CAUTION!!! Residuals for this chamber type have changed!!!" << endl;
0179   out << endl;
0180   out << endl;
0181 
0182   // ME 3/1
0183   ho = (TH1F*)fo->Get("recHits/hSResid31");
0184   hn = (TH1F*)fn->Get("recHits/hSResid31");
0185 
0186   ho->Fit("f1","RNQ");
0187   hn->Fit("f2","RNQ");
0188 
0189   float sigmao31 = f1->GetParameter(2);
0190   float sigmaoerr31 = f1->GetParError(2);
0191   float sigman31 = f2->GetParameter(2);
0192   float sigmanerr31 = f2->GetParError(2);
0193   float diff31 = (sigman31 - sigmao31);
0194   float differr31 = sqrt(sigmaoerr31*sigmaoerr31 + sigmanerr31*sigmanerr31);
0195 
0196   out << "Results for ME31:" << endl;
0197   out << endl;
0198   out << "Ref Fit: " << sigmao31 << " +/- " << sigmaoerr31 << endl;
0199   out << "New Fit: " << sigman31 << " +/- " << sigmanerr31 << endl;
0200   out << endl;
0201   out << "Diff: " << diff31 << " +/- " << differr31 << endl;
0202   out << endl;
0203   if (fabs(diff31) > 0.01) out << "CAUTION!!! Residuals for this chamber type have changed!!!" << endl;
0204   out << endl;
0205   out << endl;
0206 
0207   // ME 3/2
0208   ho = (TH1F*)fo->Get("recHits/hSResid32");
0209   hn = (TH1F*)fn->Get("recHits/hSResid32");
0210 
0211   ho->Fit("f1","RNQ");
0212   hn->Fit("f2","RNQ");
0213 
0214   float sigmao32 = f1->GetParameter(2);
0215   float sigmaoerr32 = f1->GetParError(2);
0216   float sigman32 = f2->GetParameter(2);
0217   float sigmanerr32 = f2->GetParError(2);
0218   float diff32 = (sigman32 - sigmao32);
0219   float differr32 = sqrt(sigmaoerr32*sigmaoerr32 + sigmanerr32*sigmanerr32);
0220 
0221   out << "Results for ME32:" << endl;
0222   out << endl;
0223   out << "Ref Fit: " << sigmao32 << " +/- " << sigmaoerr32 << endl;
0224   out << "New Fit: " << sigman32 << " +/- " << sigmanerr32 << endl;
0225   out << endl;
0226   out << "Diff: " << diff32 << " +/- " << differr32 << endl;
0227   out << endl;
0228   if (fabs(diff32) > 0.01) out << "CAUTION!!! Residuals for this chamber type have changed!!!" << endl;
0229   out << endl;
0230   out << endl;
0231 
0232   // ME 4/1
0233   ho = (TH1F*)fo->Get("recHits/hSResid41");
0234   hn = (TH1F*)fn->Get("recHits/hSResid41");
0235 
0236   ho->Fit("f1","RNQ");
0237   hn->Fit("f2","RNQ");
0238 
0239   float sigmao41 = f1->GetParameter(2);
0240   float sigmaoerr41 = f1->GetParError(2);
0241   float sigman41 = f2->GetParameter(2);
0242   float sigmanerr41 = f2->GetParError(2);
0243   float diff41 = (sigman41 - sigmao41);
0244   float differr41 = sqrt(sigmaoerr41*sigmaoerr41 + sigmanerr41*sigmanerr41);
0245 
0246   out << "Results for ME41:" << endl;
0247   out << endl;
0248   out << "Ref Fit: " << sigmao41 << " +/- " << sigmaoerr41 << endl;
0249   out << "New Fit: " << sigman41 << " +/- " << sigmanerr41 << endl;
0250   out << endl;
0251   out << "Diff: " << diff41 << " +/- " << differr41 << endl;
0252   out << endl;
0253   if (fabs(diff41) > 0.01) out << "CAUTION!!! Residuals for this chamber type have changed!!!" << endl;
0254 
0255   out.close();
0256 
0257 }
0258 
0259 EOF
0260 
0261 root -l -q checkResid_temp.C
0262 
0263 rm checkResid_temp.C