CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_4_5_patch3/src/DataFormats/Scalers/src/LumiScalers.cc

Go to the documentation of this file.
00001 
00002 /*
00003  *   File: DataFormats/Scalers/src/LumiScalers.cc   (W.Badgett)
00004  */
00005 
00006 #include "DataFormats/Scalers/interface/LumiScalers.h"
00007 #include "DataFormats/Scalers/interface/ScalersRaw.h"
00008 #include <cstdio>
00009 #include <ostream>
00010 
00011 LumiScalers::LumiScalers() : 
00012    trigType_(0),
00013    eventID_(0),
00014    sourceID_(0),
00015    bunchNumber_(0),
00016    version_(0),
00017    normalization_(0.0),
00018    deadTimeNormalization_(0.0),
00019    lumiFill_(0.0),
00020    lumiRun_(0.0),
00021    liveLumiFill_(0.0),
00022    liveLumiRun_(0.0),
00023    instantLumi_(0.0),
00024    instantLumiErr_(0.0),
00025    instantLumiQlty_(0),
00026    lumiETFill_(0.0),
00027    lumiETRun_(0.0),
00028    liveLumiETFill_(0.0),
00029    liveLumiETRun_(0.0),
00030    instantETLumi_(0.0),
00031    instantETLumiErr_(0.0),
00032    instantETLumiQlty_(0),
00033    lumiOccFill_(nOcc),
00034    lumiOccRun_(nOcc),
00035    liveLumiOccFill_(nOcc),
00036    liveLumiOccRun_(nOcc),
00037    instantOccLumi_(nOcc),
00038    instantOccLumiErr_(nOcc),
00039    instantOccLumiQlty_(nOcc),
00040    lumiNoise_(nOcc),
00041    sectionNumber_(0),
00042    startOrbit_(0),
00043    numOrbits_(0)
00044 { 
00045 }
00046 
00047 LumiScalers::LumiScalers(const unsigned char * rawData)
00048 { 
00049   LumiScalers();
00050 
00051   struct ScalersEventRecordRaw_v1 * raw 
00052     = (struct ScalersEventRecordRaw_v1 *)rawData;
00053   trigType_     = ( raw->header >> 56 ) &        0xFULL;
00054   eventID_      = ( raw->header >> 32 ) & 0x00FFFFFFULL;
00055   sourceID_     = ( raw->header >>  8 ) & 0x00000FFFULL;
00056   bunchNumber_  = ( raw->header >> 20 ) &      0xFFFULL;
00057   version_      = raw->version;
00058 
00059   struct LumiScalersRaw_v1 * lumi = NULL;
00060 
00061   if ( version_ >= 1 )
00062   {
00063     if ( version_ <= 2 )
00064     {
00065       lumi = & (raw->lumi);
00066     }
00067     else 
00068     {
00069       struct ScalersEventRecordRaw_v3 * raw3 
00070         = (struct ScalersEventRecordRaw_v3 *)rawData;
00071       lumi = & (raw3->lumi);
00072     }
00073     collectionTime_.set_tv_sec(static_cast<long>(lumi->collectionTime_sec));
00074     collectionTime_.set_tv_nsec(lumi->collectionTime_nsec);
00075     deadTimeNormalization_  = lumi->DeadtimeNormalization;
00076     normalization_          = lumi->Normalization;
00077     lumiFill_               = lumi->LumiFill;
00078     lumiRun_                = lumi->LumiRun;
00079     liveLumiFill_           = lumi->LiveLumiFill;
00080     liveLumiRun_            = lumi->LiveLumiRun;
00081     instantLumi_            = lumi->InstantLumi;
00082     instantLumiErr_         = lumi->InstantLumiErr;
00083     instantLumiQlty_        = lumi->InstantLumiQlty;
00084     lumiETFill_             = lumi->LumiETFill;
00085     lumiETRun_              = lumi->LumiETRun;
00086     liveLumiETFill_         = lumi->LiveLumiETFill;
00087     liveLumiETRun_          = lumi->LiveLumiETRun;
00088     instantETLumi_          = lumi->InstantETLumi;
00089     instantETLumiErr_       = lumi->InstantETLumiErr;
00090     instantETLumiQlty_      = lumi->InstantETLumiQlty;
00091     for ( int i=0; i<ScalersRaw::N_LUMI_OCC_v1; i++)
00092     {
00093       lumiOccFill_.push_back(lumi->LumiOccFill[i]);
00094       lumiOccRun_.push_back(lumi->LumiOccRun[i]);
00095       liveLumiOccFill_.push_back(lumi->LiveLumiOccFill[i]);
00096       liveLumiOccRun_.push_back(lumi->LiveLumiOccRun[i]);
00097       instantOccLumi_.push_back(lumi->InstantOccLumi[i]);
00098       instantOccLumiErr_.push_back(lumi->InstantOccLumiErr[i]);
00099       instantOccLumiQlty_.push_back(lumi->InstantOccLumiQlty[i]);
00100       lumiNoise_.push_back(lumi->lumiNoise[i]);
00101     }
00102     sectionNumber_ = lumi->sectionNumber;
00103     startOrbit_    = lumi->startOrbit;
00104     numOrbits_     = lumi->numOrbits;
00105   }
00106 }
00107 
00108 LumiScalers::~LumiScalers() { } 
00109 
00110 
00112 std::ostream& operator<<(std::ostream& s, const LumiScalers& c) 
00113 {
00114   char zeit[128];
00115   char line[128];
00116   struct tm * hora;
00117 
00118   s << "LumiScalers    Version: " << c.version() << 
00119     "   SourceID: "<< c.sourceID() << std::endl;
00120 
00121   timespec ts = c.collectionTime();
00122   hora = gmtime(&ts.tv_sec);
00123   strftime(zeit, sizeof(zeit), "%Y.%m.%d %H:%M:%S", hora);
00124   sprintf(line, " CollectionTime: %s.%9.9d", zeit, 
00125           (int)ts.tv_nsec);
00126   s << line << std::endl;
00127 
00128   sprintf(line, " TrigType: %d   EventID: %d    BunchNumber: %d", 
00129           c.trigType(), c.eventID(), c.bunchNumber());
00130   s << line << std::endl;
00131 
00132   sprintf(line," SectionNumber: %10d   StartOrbit: %10d  NumOrbits: %10d",
00133           c.sectionNumber(), c.startOrbit(), c.numOrbits());
00134   s << line << std::endl;
00135 
00136   sprintf(line," Normalization: %e  DeadTimeNormalization: %e",
00137           c.normalization(), c.deadTimeNormalization());
00138   s << line << std::endl;
00139 
00140   // Integrated Luminosity
00141 
00142   sprintf(line," LumiFill:            %e   LumiRun:            %e", 
00143           c.lumiFill(), c.lumiRun());
00144   s << line << std::endl;
00145   sprintf(line," LiveLumiFill:        %e   LiveLumiRun:        %e", 
00146           c.liveLumiFill(), c.liveLumiRun());
00147   s << line << std::endl;
00148 
00149   sprintf(line," LumiETFill:          %e   LumiETRun:          %e", 
00150           c.lumiFill(), c.lumiRun());
00151   s << line << std::endl;
00152 
00153   sprintf(line," LiveLumiETFill:      %e   LiveLumETiRun:      %e", 
00154           c.liveLumiETFill(), c.liveLumiETRun());
00155   s << line << std::endl;
00156 
00157   int length = c.instantOccLumi().size();
00158   for (int i=0; i<length; i++)
00159   {
00160     sprintf(line,
00161                " LumiOccFill[%d]:      %e   LumiOccRun[%d]:      %e", 
00162             i, c.lumiOccFill()[i], i, c.lumiOccRun()[i]);
00163     s << line << std::endl;
00164 
00165     sprintf(line,
00166                " LiveLumiOccFill[%d]:  %e   LiveLumiOccRun[%d]:v %e", 
00167             i, c.liveLumiOccFill()[i], i, c.liveLumiOccRun()[i]);
00168     s << line << std::endl;
00169   }
00170 
00171   // Instantaneous Luminosity
00172 
00173   sprintf(line," InstantLumi:       %e  Err: %e  Qlty: %d",
00174           c.instantLumi(), c.instantLumiErr(), c.instantLumiQlty());
00175   s << line << std::endl;
00176 
00177   sprintf(line," InstantETLumi:     %e  Err: %e  Qlty: %d",
00178           c.instantETLumi(), c.instantETLumiErr(), c.instantETLumiQlty());
00179   s << line << std::endl;
00180 
00181   for (int i=0; i<length; i++)
00182   {
00183     sprintf(line," InstantOccLumi[%d]: %e  Err: %e  Qlty: %d",
00184             i, c.instantOccLumi()[i], c.instantOccLumiErr()[i], 
00185             c.instantOccLumiQlty()[i]);
00186     s << line << std::endl;
00187     sprintf(line,"      LumiNoise[%d]: %e", i, c.lumiNoise()[i]);
00188     s << line << std::endl;
00189   }
00190 
00191   return s;
00192 }