trim.C

Go to the documentation of this file.
00001 
00002 //
00003 // Small macro used to get gain average values for PbSc sectors
00004 // for a given run.
00005 // see emcCalibrationDataHelper class for meaning of details param.
00006 //
00007 // Here's the result from this macro, executed on 25-March-2004
00008 // using runnumber 92446 (last good Run3 pp run)
00009 // trim(92446,"xmax:-3:-9:-15") gives :
00010 //
00011 //
00012 // Trimmed mean results for run 92446 details=xmax:-3:-9:-15
00013 //
00014 //   Trim percent    0.00          10.00          20.00          30.00          40.00          45.00          47.50        
00015 // W0              147.85 +- 0.61 146.84 +- 0.49 146.30 +- 0.38 146.01 +- 0.26 145.78 +- 0.13 145.67 +- 0.08 145.55 +- 0.04
00016 // W1              155.23 +- 0.80 151.95 +- 0.51 151.54 +- 0.39 151.24 +- 0.27 151.13 +- 0.13 151.10 +- 0.08 151.02 +- 0.04
00017 // W2              142.10 +- 0.78 139.72 +- 0.58 138.82 +- 0.45 138.41 +- 0.32 137.77 +- 0.17 137.53 +- 0.10 137.42 +- 0.05
00018 // W3              127.58 +- 1.22 123.37 +- 0.71 122.91 +- 0.49 122.46 +- 0.33 122.47 +- 0.17 122.45 +- 0.10 122.49 +- 0.05
00019 // E2              131.15 +- 0.65 129.25 +- 0.52 128.37 +- 0.39 127.77 +- 0.26 127.43 +- 0.14 127.45 +- 0.09 127.46 +- 0.05
00020 // E3              129.74 +- 0.77 126.85 +- 0.58 125.10 +- 0.43 124.26 +- 0.28 124.03 +- 0.15 124.06 +- 0.09 124.09 +- 0.04
00021 
00022 struct result
00023 {
00024   float value;
00025   float error;
00026 };
00027 
00028 void trim(int runnumber, const char* details="xmin:-3:-9:-15")
00029 {
00030   gSystem->Load("libPgCalInstance.so");
00031   gSystem->Load("libemcOMpg.so");
00032   emcCalibrationDataHelper cdh(runnumber,false);
00033 
00034   cdh.getGainBaseLine(0);
00035   
00036   const int N = 7;
00037 
00038   float percent[N] = { 0,0.1,0.2,0.3,0.4,0.45,0.475 };
00039   result R[6][N];
00040 
00041   char* mdetails = new char[strlen(details)+10];
00042 
00043   for ( int isector = 0; isector < 6; ++isector )
00044     {
00045       for ( int i = 0; i < 7; ++i ) 
00046         {
00047           sprintf(mdetails,"%2d:%s",percent[i]*100,details);
00048 
00049           R[isector][i].value = cdh.getGainBaseLine(isector,"value",mdetails),
00050           R[isector][i].error = cdh.getGainBaseLine(isector,"error",mdetails);
00051         }
00052       printf("\n");
00053     }
00054 
00055 
00056   printf("Trimmed mean results for run %5d details=%s\n\n",
00057          runnumber,details);
00058 
00059   printf("  Trim percent ");
00060   for ( int i = 0; i < 7; ++i ) 
00061     {
00062       printf("%7.2f %7c",percent[i]*100,' ');
00063     }
00064   printf("\n");
00065 
00066   for ( int isector = 0; isector < 6; ++isector )
00067     {
00068       printf("%s             ",EmcIndexer::EmcSectorId(isector));
00069     
00070       for ( int i = 0; i < 7; ++i ) 
00071         {
00072           printf("%7.2f +-%5.2f ",
00073                  R[isector][i].value,
00074                  R[isector][i].error);
00075         }
00076       printf("\n");
00077     }
00078 
00079   
00080 
00081 }