Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 11:58:23

0001 #!/bin/sh
0002 
0003 echo Analyzing for run: $1
0004 
0005        ##########################################################################
0006        ######      CSC Automated Calibration  -   Revision 11-24-2010      ######
0007        ######      Darin Baumgartel, Northeastern University               ######
0008        ##########################################################################
0009 
0010 echo " "
0011 echo "                  ***************************************************"
0012 echo "                  ****     Beginning new Calibration Update      ****"
0013 echo "                  ***************************************************"; echo " "
0014 
0015 # Date label
0016 NOW=$(date +"%b_%d_%Y__%R_%S")
0017 echo $NOW
0018 ######################################################################################
0019 ###        MERGE THE GAINS, PEDS, XTALK, MATRIX VALUES INTO SUMMARY FILES           ### 
0020 #######################################################################################
0021 
0022 # Replace the run numbes with your desired run numbers (things like "run_######_Calib_CFEB_[----].plots" directories)
0023 
0024 echo " ";echo "                  ****     Creating Summary Files:";echo " "
0025 # CFEB02 - SCAPed is used for both noise-matrix (*_DB_NoiseMatrix.dat files) and pedestals (*_DB.dat files)
0026 matrixname="matrixSummary_$NOW.dat"
0027 for i in /nfshome0/cscdqm/results/calib/Test_CFEB02/run_$1_Calib_CFEB_SCAPed.plots/*/*_DB_NoiseMatrix.dat
0028 do
0029 cat $i >> $matrixname
0030 done
0031 echo "CFEB02: NoiseMatrix Summary File:      $matrixname    has been produced."; echo " "
0032 
0033 pedsname="pedSummary_$NOW.dat"
0034 for i in /nfshome0/cscdqm/results/calib/Test_CFEB02/run_$1_Calib_CFEB_SCAPed.plots/*/*_DB.dat
0035 do
0036 cat $i >> $pedsname
0037 done
0038 echo "CFEB02: Pedestals Summary File:        $pedsname       has been produced."; echo " "
0039 
0040 # CFEB03 - Crosstalk is used for Crosstalk (*_DB_XTalk.dat files) 
0041 xtalkname="xtalkSummary_$NOW.dat"
0042 for i in /nfshome0/cscdqm/results/calib/Test_CFEB03/run_$1_Calib_CFEB_CrossTalk.plots/*/*_DB_Xtalk.dat
0043 do
0044 cat $i >> $xtalkname
0045 done
0046 echo "CFEB03: Crosstalk Summary File:        $xtalkname     has been produced."; echo " "
0047 
0048 # CFEB04 - Gains is used for Gains (*_DB.dat files)
0049 gainsname="gainSummary_$NOW.dat"
0050 for i in /nfshome0/cscdqm/results/calib/Test_CFEB04/run_$1_Calib_CFEB_Gains.plots/*/*.dat
0051 do
0052 cat $i >> $gainsname
0053 done
0054 echo "CFEB04: Gains Summary File:            $gainsname      has been produced."; echo " "
0055 
0056 #######################################################################################
0057 ###        Copy the read[----].cpp template files to date-labeled files and           ### 
0058 ###        filenames (replacing the string "FileName" with the names above)          ### 
0059 #######################################################################################
0060 
0061 echo " ";echo "                  ****     The following \"read\" files have been produced from templates:";echo " "
0062 cat readMatrix.cpp | sed -e 's/FileName/'$matrixname'/' > readMatrix_$NOW.cpp; echo "readMatrix_$NOW.cpp"
0063 cat readPeds.cpp | sed -e 's/FileName/'$pedsname'/' > readPeds_$NOW.cpp; echo "readPeds_$NOW.cpp"
0064 cat readXtalk.cpp | sed -e 's/FileName/'$xtalkname'/' > readXtalk_$NOW.cpp; echo "readXtalk_$NOW.cpp"
0065 cat readGains.cpp | sed -e 's/FileName/'$gainsname'/' > readGains_$NOW.cpp; echo "readGains_$NOW.cpp"; echo " "
0066 
0067 
0068 #######################################################################################
0069 ###        Run the read[----].cpp files                                              ###
0070 #######################################################################################
0071 
0072 echo " ";echo "                  ****     Running read____.cpp files. Succesful completetion:";echo " "
0073 echo "             READ___.CPP FILE:                           INPUT_FILE                    -->                       OUTPUT_FILE";echo " "
0074 
0075 g++ readMatrix_$NOW.cpp -o readMatrix_$NOW  
0076 ./readMatrix_$NOW
0077 echo "readMatrix_$NOW.cpp:      $matrixname     -->     GoodVals_$matrixname";
0078 
0079 g++ readPeds_$NOW.cpp -o readPeds_$NOW  
0080 ./readPeds_$NOW
0081 echo "readPeds_$NOW.cpp:        $pedsname        -->     GoodVals_$pedsname";
0082 
0083 g++ readXtalk_$NOW.cpp -o readXtalk_$NOW  
0084 ./readXtalk_$NOW
0085 echo "readXtalk_$NOW.cpp:       $xtalkname      -->     GoodVals_$xtalkname";
0086 
0087 g++ readGains_$NOW.cpp -o readGains_$NOW  
0088 ./readGains_$NOW
0089 echo "readGains_$NOW.cpp:       $gainsname       -->     GoodVals_$gainsname";
0090 
0091 echo " "
0092 
0093 #######################################################################################
0094 ###    Read DataBase Values, designate them as "old_db[---].dat" for comparison     ###
0095 #######################################################################################
0096 
0097 echo " ";echo " ";
0098 echo "          ---------------------------------------------------------"
0099 echo "          -----    RETRIEVING DATABASE VALUES AND STORING     -----"
0100 echo "          ---------------------------------------------------------"
0101 echo " ";echo "         >>>>>>>>>>>>>> Retrieve Crosstalk from DataBase <<<<<<<<<<<<<<";echo " ";cmsRun readDBCrosstalk_cfg.py 
0102 echo " ";echo "         >>>>>>>>>>>>>> Retrieve Matrix from DataBase <<<<<<<<<<<<<<";echo " ";cmsRun readDBNoiseMatrix_cfg.py
0103 echo " ";echo "         >>>>>>>>>>>>>> Retrieve Gains from DataBase <<<<<<<<<<<<<<";echo " ";cmsRun readDBGains_cfg.py 
0104 echo " ";echo "         >>>>>>>>>>>>>> Retrieve Pedestals from DataBase <<<<<<<<<<<<<<";echo " ";cmsRun readDBPedestals_cfg.py; echo " "
0105 echo " ";echo " ";
0106 echo "          ---------------------------------------------------------"
0107 echo "          -----          DATABASE VALUES RETRIEVED            -----"
0108 echo "          ---------------------------------------------------------"
0109 
0110 echo " ";echo " ";echo "                  ****     Reading Database Values: ";echo " "
0111 rm old_dbxtalk.dat;rm old_dbmatrix.dat;rm old_dbgains.dat;rm old_dbpeds.dat
0112 mv dbxtalk.dat old_dbxtalk.dat;                      echo "Crosstalk     -- DataBase file:   old_dbxtalk.dat    has been produced.";
0113 mv dbmatrix.dat old_dbmatrix.dat;                    echo "Noise Matrix  -- DataBase file:   old_dbmatrix.dat   has been produced.";
0114 mv dbgains.dat old_dbgains.dat;                      echo "Gains         -- DataBase file:   old_dbgains.dat    has been produced.";
0115 mv dbpeds.dat old_dbpeds.dat;                        echo "Pedestals     -- DataBase file:   old_dbpeds.dat     has been produced."; echo " "
0116 
0117 # Here I remove unnecessary characters in the matrix file not suitable for comparison with the merged file...
0118 mv old_dbmatrix.dat old_dbmatrix_orig.dat
0119 cat old_dbmatrix_orig.dat | sed -e 's/E:[0-9][0-9]//;s/E:[0-9]//;s/S:[0-9][0-9]//;s/S:[0-9]//;s/R:[0-9][0-9]//;s/R:[0-9]//;s/C:[0-9][0-9]//;s/C:[0-9]//;s/L:[0-9][0-9]//;s/L:[0-9]//;s/chan [0-9][0-9]//;s/chan [0-9]//;s/          /  /' > old_dbmatrix.dat
0120 rm old_dbmatrix_orig.dat
0121 
0122 #######################################################################################
0123 ###      Save values into SQLite File                                               ###
0124 #######################################################################################
0125 
0126 echo " ";echo " ";
0127 echo "          ---------------------------------------------------------"
0128 echo "          -----             Creating SQLite Files             -----"
0129 echo "          ---------------------------------------------------------"
0130 
0131 mv GoodVals_$gainsname gains.dat; mv GoodVals_$pedsname peds.dat; mv GoodVals_$matrixname matrix.dat; mv GoodVals_$xtalkname xtalk.dat;
0132 cmsRun CSCDBCrosstalkPopCon_cfg.py; cmsRun CSCDBGainsPopCon_cfg.py; cmsRun CSCDBNoiseMatrixPopCon_cfg.py; cmsRun CSCDBPedestalsPopCon_cfg.py;
0133 mv gains.dat GoodVals_$gainsname; mv peds.dat GoodVals_$pedsname; mv matrix.dat GoodVals_$matrixname; mv xtalk.dat GoodVals_$xtalkname;
0134 mv DBCrossTalk.db DBCrossTalk_$NOW.db; mv DBGains.db DBGains_$NOW.db; mv DBNoiseMatrix.db DBNoiseMatrix_$NOW.db; mv DBPedestals.db DBPedestals_$NOW.db;
0135 echo " "; echo " "; echo " SQLite File Creation Complete"
0136 
0137 #######################################################################################
0138 ###       Create and Run Python Comparison Module                                   ###
0139 #######################################################################################
0140 echo " ";echo " ";
0141 echo "          ---------------------------------------------------------"
0142 echo "          -----    Running Comparison With Python Modules     -----"
0143 echo "          ---------------------------------------------------------"
0144 
0145 rm stubs/Compare.cc;
0146 cat Compare_template.txt | sed -e 's/Matrix_FileName/'GoodVals_$matrixname'/;s/Peds_FileName/'GoodVals_$pedsname'/;s/Gains_FileName/'GoodVals_$gainsname'/;s/Xtalk_FileName/'GoodVals_$xtalkname'/' > stubs/Compare.cc;
0147 cd ../../../
0148 scramv1 b -j 4
0149 cd -
0150 echo "              "
0151 echo "                    stubs/Compare.C File Created"; echo " "
0152  echo        "THIS MAY TAKE SEVERAL MINUTES, GO HAVE A CUP OF COFFEE"
0153 echo " "; echo "                    Running Comparisons... ";
0154 
0155 cmsRun compare_cfg.py
0156 
0157 #######################################################################################
0158 ###      Load Results into Root NTuple                                              ###
0159 #######################################################################################
0160 
0161 echo " ";echo " ";
0162 echo "          ---------------------------------------------------------"
0163 echo "          -----      Creating/Running Root-NTuple Scripts     -----"
0164 echo "          ---------------------------------------------------------"
0165 
0166 
0167 cat diffGainsNtuple.C | sed -e 's/Gains_FileName/'GoodVals_$gainsname'/;s/RootFile/'diffGains_$NOW.root'/' >  "diffGainsNtuple_$NOW.C"
0168 cat diffPedsNtuple.C | sed -e 's/Peds_FileName/'GoodVals_$pedsname'/;s/RootFile/'diffPeds_$NOW.root'/' >  "diffPedsNtuple_$NOW.C"
0169 cat diffMatrixNtuple.C | sed -e 's/Matrix_FileName/'GoodVals_$matrixname'/;s/RootFile/'diffMatrix_$NOW.root'/' >  "diffMatrixNtuple_$NOW.C"
0170 cat diffXtalkNtuple.C | sed -e 's/Xtalk_FileName/'GoodVals_$xtalkname'/;s/RootFile/'diffXtalk_$NOW.root'/' >  "diffXtalkNtuple_$NOW.C"
0171 
0172 echo "               Scripts Produced:"; echo " "
0173 echo "diffGainsNtuple_$NOW.C"; echo "diffPedsNtuple_$NOW.C";echo "diffMatrixNtuple_$NOW.C";echo "diffXtalkNtuple_$NOW.C"; echo " ";echo " "
0174 echo "               Running Scripts:"; echo " "
0175  
0176 rm RootProcesses
0177 echo "{gROOT->ProcessLine(\"gROOT->Reset()\"); gROOT->ProcessLine(\".x diffGainsNtuple_$NOW.C\"); gROOT->ProcessLine(\"gROOT->Reset()\"); gROOT->ProcessLine(\".x diffPedsNtuple_$NOW.C\"); gROOT->ProcessLine(\"gROOT->Reset()\"); gROOT->ProcessLine(\".x diffMatrixNtuple_$NOW.C\"); gROOT->ProcessLine(\"gROOT->Reset()\"); gROOT->ProcessLine(\".x diffXtalkNtuple_$NOW.C\"); gROOT->ProcessLine(\".q\");}" >RootProcesses
0178 root -l RootProcesses
0179 
0180 echo " "; echo " ";echo "Root N-tuple production complete. "
0181 
0182 
0183 #######################################################################################
0184 ###      Store Results                                                              ###
0185 #######################################################################################
0186 
0187 echo " ";echo " ";
0188 echo "          ---------------------------------------------------------"
0189 echo "          -----      Transferring Results to Dated Folder     -----"
0190 echo "          ---------------------------------------------------------"
0191 
0192 mkdir "Calibration_$NOW"
0193 mv *$NOW* Calibration_$NOW
0194 mv old_db*dat Calibration_$NOW
0195 echo "          Results/Files stored in folder Calibration_$NOW"
0196 
0197 echo " "
0198 echo "                  ***************************************************"
0199 echo "                  ****        Calibration Run is Complete        ****"
0200 echo "                  ***************************************************"; echo " "
0201 
0202 
0203 
0204 
0205 
0206