CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_2_7_hltpatch1/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    pileup_(0.0),
00045    spare_(0.0)
00046 { 
00047 }
00048 
00049 LumiScalers::LumiScalers(const unsigned char * rawData)
00050 { 
00051   LumiScalers();
00052 
00053   struct ScalersEventRecordRaw_v1 * raw 
00054     = (struct ScalersEventRecordRaw_v1 *)rawData;
00055   trigType_     = ( raw->header >> 56 ) &        0xFULL;
00056   eventID_      = ( raw->header >> 32 ) & 0x00FFFFFFULL;
00057   sourceID_     = ( raw->header >>  8 ) & 0x00000FFFULL;
00058   bunchNumber_  = ( raw->header >> 20 ) &      0xFFFULL;
00059   version_      = raw->version;
00060 
00061   struct LumiScalersRaw_v1 * lumi = NULL;
00062 
00063   if ( version_ >= 1 )
00064   {
00065     if ( version_ <= 2 )
00066     {
00067       lumi = & (raw->lumi);
00068     }
00069     else 
00070     {
00071       struct ScalersEventRecordRaw_v3 * raw3 
00072         = (struct ScalersEventRecordRaw_v3 *)rawData;
00073       lumi = & (raw3->lumi);
00074     }
00075     collectionTime_.set_tv_sec(static_cast<long>(lumi->collectionTime_sec));
00076     collectionTime_.set_tv_nsec(lumi->collectionTime_nsec);
00077     deadTimeNormalization_  = lumi->DeadtimeNormalization;
00078     normalization_          = lumi->Normalization;
00079     lumiFill_               = lumi->LumiFill;
00080     lumiRun_                = lumi->LumiRun;
00081     liveLumiFill_           = lumi->LiveLumiFill;
00082     liveLumiRun_            = lumi->LiveLumiRun;
00083     instantLumi_            = lumi->InstantLumi;
00084     instantLumiErr_         = lumi->InstantLumiErr;
00085     instantLumiQlty_        = lumi->InstantLumiQlty;
00086     lumiETFill_             = lumi->LumiETFill;
00087     lumiETRun_              = lumi->LumiETRun;
00088     liveLumiETFill_         = lumi->LiveLumiETFill;
00089     liveLumiETRun_          = lumi->LiveLumiETRun;
00090     instantETLumi_          = lumi->InstantETLumi;
00091     instantETLumiErr_       = lumi->InstantETLumiErr;
00092     instantETLumiQlty_      = lumi->InstantETLumiQlty;
00093     for ( int i=0; i<ScalersRaw::N_LUMI_OCC_v1; i++)
00094     {
00095       lumiOccFill_.push_back(lumi->LumiOccFill[i]);
00096       lumiOccRun_.push_back(lumi->LumiOccRun[i]);
00097       liveLumiOccFill_.push_back(lumi->LiveLumiOccFill[i]);
00098       liveLumiOccRun_.push_back(lumi->LiveLumiOccRun[i]);
00099       instantOccLumi_.push_back(lumi->InstantOccLumi[i]);
00100       instantOccLumiErr_.push_back(lumi->InstantOccLumiErr[i]);
00101       instantOccLumiQlty_.push_back(lumi->InstantOccLumiQlty[i]);
00102       lumiNoise_.push_back(lumi->lumiNoise[i]);
00103     }
00104     sectionNumber_ = lumi->sectionNumber;
00105     startOrbit_    = lumi->startOrbit;
00106     numOrbits_     = lumi->numOrbits;
00107     if ( version_ >= 7 )
00108     {
00109       struct ScalersEventRecordRaw_v6 * raw6 
00110         = (struct ScalersEventRecordRaw_v6 *)rawData;
00111       float * fspare = (float *) raw6->spare;
00112       pileup_ = fspare[ScalersRaw::I_SPARE_PILEUP_v7];
00113       spare_  = fspare[ScalersRaw::I_SPARE_SPARE_v7];
00114     }
00115     else
00116     {
00117       pileup_ = (float)0.0;
00118       spare_  = (float)0.0;
00119     }
00120   }
00121 }
00122 
00123 LumiScalers::~LumiScalers() { } 
00124 
00125 
00127 std::ostream& operator<<(std::ostream& s, const LumiScalers& c) 
00128 {
00129   char zeit[128];
00130   char line[128];
00131   struct tm * hora;
00132 
00133   s << "LumiScalers    Version: " << c.version() << 
00134     "   SourceID: "<< c.sourceID() << std::endl;
00135 
00136   timespec ts = c.collectionTime();
00137   hora = gmtime(&ts.tv_sec);
00138   strftime(zeit, sizeof(zeit), "%Y.%m.%d %H:%M:%S", hora);
00139   sprintf(line, " CollectionTime: %s.%9.9d", zeit, 
00140           (int)ts.tv_nsec);
00141   s << line << std::endl;
00142 
00143   sprintf(line, " TrigType: %d   EventID: %d    BunchNumber: %d", 
00144           c.trigType(), c.eventID(), c.bunchNumber());
00145   s << line << std::endl;
00146 
00147   sprintf(line," SectionNumber: %10d   StartOrbit: %10d  NumOrbits: %10d",
00148           c.sectionNumber(), c.startOrbit(), c.numOrbits());
00149   s << line << std::endl;
00150 
00151   sprintf(line," Normalization: %e  DeadTimeNormalization: %e",
00152           c.normalization(), c.deadTimeNormalization());
00153   s << line << std::endl;
00154 
00155   // Integrated Luminosity
00156 
00157   sprintf(line," LumiFill:            %e   LumiRun:            %e", 
00158           c.lumiFill(), c.lumiRun());
00159   s << line << std::endl;
00160   sprintf(line," LiveLumiFill:        %e   LiveLumiRun:        %e", 
00161           c.liveLumiFill(), c.liveLumiRun());
00162   s << line << std::endl;
00163 
00164   sprintf(line," LumiETFill:          %e   LumiETRun:          %e", 
00165           c.lumiFill(), c.lumiRun());
00166   s << line << std::endl;
00167 
00168   sprintf(line," LiveLumiETFill:      %e   LiveLumETiRun:      %e", 
00169           c.liveLumiETFill(), c.liveLumiETRun());
00170   s << line << std::endl;
00171 
00172   int length = c.instantOccLumi().size();
00173   for (int i=0; i<length; i++)
00174   {
00175     sprintf(line,
00176                " LumiOccFill[%d]:      %e   LumiOccRun[%d]:      %e", 
00177             i, c.lumiOccFill()[i], i, c.lumiOccRun()[i]);
00178     s << line << std::endl;
00179 
00180     sprintf(line,
00181                " LiveLumiOccFill[%d]:  %e   LiveLumiOccRun[%d]:v %e", 
00182             i, c.liveLumiOccFill()[i], i, c.liveLumiOccRun()[i]);
00183     s << line << std::endl;
00184   }
00185 
00186   // Instantaneous Luminosity
00187 
00188   sprintf(line," InstantLumi:       %e  Err: %e  Qlty: %d",
00189           c.instantLumi(), c.instantLumiErr(), c.instantLumiQlty());
00190   s << line << std::endl;
00191 
00192   sprintf(line," InstantETLumi:     %e  Err: %e  Qlty: %d",
00193           c.instantETLumi(), c.instantETLumiErr(), c.instantETLumiQlty());
00194   s << line << std::endl;
00195 
00196   for (int i=0; i<length; i++)
00197   {
00198     sprintf(line," InstantOccLumi[%d]: %e  Err: %e  Qlty: %d",
00199             i, c.instantOccLumi()[i], c.instantOccLumiErr()[i], 
00200             c.instantOccLumiQlty()[i]);
00201     s << line << std::endl;
00202     sprintf(line,"      LumiNoise[%d]: %e", i, c.lumiNoise()[i]);
00203     s << line << std::endl;
00204   }
00205 
00206   sprintf(line,"            Pileup: %f      Spare: %f", c.pileup(), c.spare());
00207   s << line << std::endl;
00208 
00209   return s;
00210 }