CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_6_2_7/src/DataFormats/Scalers/src/L1TriggerScalers.cc

Go to the documentation of this file.
00001 
00002 /*
00003  *   File: DataFormats/Scalers/src/L1TriggerScalers.cc   (W.Badgett)
00004  */
00005 
00006 #include "DataFormats/Scalers/interface/L1TriggerScalers.h"
00007 #include "DataFormats/Scalers/interface/ScalersRaw.h"
00008 
00009 #include <iostream>
00010 #include <cstdio>
00011 
00012 L1TriggerScalers::L1TriggerScalers():
00013   version_(0),
00014   collectionTimeSpecial_(0,0),
00015   orbitNumber_(0),
00016   luminositySection_(0),
00017   bunchCrossingErrors_(0),
00018   collectionTimeSummary_(0,0),
00019   triggerNumber_(0),
00020   eventNumber_(0),
00021   finalTriggersDistributed_(0),
00022   calibrationTriggers_(0),
00023   randomTriggers_(0),
00024   totalTestTriggers_(0),
00025   finalTriggersGenerated_(0),
00026   finalTriggersInvalidBC_(0),
00027   deadTime_(0),
00028   lostFinalTriggers_(0),
00029   deadTimeActive_(0),
00030   lostFinalTriggersActive_(0),
00031   deadTimeActivePrivate_(0),
00032   deadTimeActivePartition_(0),
00033   deadTimeActiveThrottle_(0),
00034   deadTimeActiveCalibration_(0),
00035   deadTimeActiveTimeSlot_(0),
00036   numberResets_(0),
00037   collectionTimeDetails_(0,0),
00038   triggers_(nL1Triggers),
00039   testTriggers_(nL1TestTriggers)
00040 { 
00041 }
00042 
00043 L1TriggerScalers::L1TriggerScalers(const unsigned char * rawData)
00044 { 
00045   L1TriggerScalers();
00046 
00047   struct ScalersEventRecordRaw_v1 * raw 
00048     = (struct ScalersEventRecordRaw_v1 *)rawData;
00049 
00050   trigType_     = ( raw->header >> 56 ) &        0xFULL;
00051   eventID_      = ( raw->header >> 32 ) & 0x00FFFFFFULL;
00052   sourceID_     = ( raw->header >>  8 ) & 0x00000FFFULL;
00053   bunchNumber_  = ( raw->header >> 20 ) &      0xFFFULL;
00054 
00055   version_ = raw->version;
00056   if ( ( version_ == 1 ) || ( version_ == 2 ) )
00057   {
00058     collectionTimeSpecial_.set_tv_sec( static_cast<long>(
00059       raw->trig.collectionTimeSpecial_sec));
00060     collectionTimeSpecial_.set_tv_nsec( 
00061       raw->trig.collectionTimeSpecial_nsec);
00062     orbitNumber_               = raw->trig.ORBIT_NUMBER;
00063     luminositySection_         = raw->trig.LUMINOSITY_SEGMENT;
00064     bunchCrossingErrors_       = raw->trig.BC_ERRORS;
00065 
00066     collectionTimeSummary_.set_tv_sec( static_cast<long>(
00067       raw->trig.collectionTimeSummary_sec));
00068     collectionTimeSummary_.set_tv_nsec( 
00069       raw->trig.collectionTimeSummary_nsec);
00070 
00071     triggerNumber_             = raw->trig.TRIGGER_NR;
00072     eventNumber_               = raw->trig.EVENT_NR;
00073     finalTriggersDistributed_  = raw->trig.FINOR_DISTRIBUTED;
00074     calibrationTriggers_       = raw->trig.CAL_TRIGGER;
00075     randomTriggers_            = raw->trig.RANDOM_TRIGGER;
00076     totalTestTriggers_         = raw->trig.TEST_TRIGGER;
00077 
00078     finalTriggersGenerated_    = raw->trig.FINOR_GENERATED;
00079     finalTriggersInvalidBC_    = raw->trig.FINOR_IN_INVALID_BC;
00080 
00081     deadTime_                  = raw->trig.DEADTIME;
00082     lostFinalTriggers_         = raw->trig.LOST_FINOR;
00083     deadTimeActive_            = raw->trig.DEADTIMEA;
00084     lostFinalTriggersActive_   = raw->trig.LOST_FINORA;
00085     deadTimeActivePrivate_     = raw->trig.PRIV_DEADTIMEA;
00086     deadTimeActivePartition_   = raw->trig.PTCSTATUS_DEADTIMEA;
00087     deadTimeActiveThrottle_    = raw->trig.THROTTLE_DEADTIMEA;
00088     deadTimeActiveCalibration_ = raw->trig.CALIBRATION_DEADTIMEA;
00089     deadTimeActiveTimeSlot_    = raw->trig.TIMESLOT_DEADTIMEA;
00090     numberResets_              = raw->trig.NR_OF_RESETS;
00091 
00092     collectionTimeDetails_.set_tv_sec( static_cast<long>(
00093       raw->trig.collectionTimeDetails_sec));
00094     collectionTimeDetails_.set_tv_nsec(
00095       raw->trig.collectionTimeDetails_nsec);
00096 
00097     for ( int i=0; i<ScalersRaw::N_L1_TRIGGERS_v1; i++)
00098     { triggers_.push_back( raw->trig.ALGO_RATE[i]);}
00099 
00100     for ( int i=0; i<ScalersRaw::N_L1_TEST_TRIGGERS_v1; i++)
00101     { testTriggers_.push_back( raw->trig.TEST_RATE[i]);}
00102   }
00103 }
00104 
00105 L1TriggerScalers::~L1TriggerScalers() { } 
00106 
00107 
00109 std::ostream& operator<<(std::ostream& s,L1TriggerScalers const &c) 
00110 {
00111   s << "L1TriggerScalers    Version:" << c.version() <<
00112     "   SourceID: " << c.sourceID() << std::endl;
00113   char line[128];
00114   char zeitHeaven[128];
00115   char zeitHell[128];
00116   char zeitLimbo[128];
00117   struct tm * horaHeaven;
00118   struct tm * horaHell;
00119   struct tm * horaLimbo;
00120 
00121   sprintf(line, " TrigType: %d   EventID: %d    BunchNumber: %d", 
00122           c.trigType(), c.eventID(), c.bunchNumber());
00123   s << line << std::endl;
00124 
00125   timespec secondsToHeaven = c.collectionTimeSummary();
00126   horaHeaven = gmtime(&secondsToHeaven.tv_sec);
00127   strftime(zeitHeaven, sizeof(zeitHeaven), "%Y.%m.%d %H:%M:%S", horaHeaven);
00128   sprintf(line, " CollectionTimeSummary: %s.%9.9d" , 
00129           zeitHeaven, (int)secondsToHeaven.tv_nsec);
00130   s << line << std::endl;
00131 
00132   timespec secondsToHell= c.collectionTimeSpecial();
00133   horaHell = gmtime(&secondsToHell.tv_sec);
00134   strftime(zeitHell, sizeof(zeitHell), "%Y.%m.%d %H:%M:%S", horaHell);
00135   sprintf(line, " CollectionTimeSpecial: %s.%9.9d" , 
00136           zeitHell, (int)secondsToHell.tv_nsec);
00137   s << line << std::endl;
00138 
00139   timespec secondsToLimbo= c.collectionTimeDetails();
00140   horaLimbo = gmtime(&secondsToLimbo.tv_sec);
00141   strftime(zeitLimbo, sizeof(zeitLimbo), "%Y.%m.%d %H:%M:%S", horaLimbo);
00142   sprintf(line, " CollectionTimeDetails: %s.%9.9d" , 
00143           zeitLimbo, (int)secondsToLimbo.tv_nsec);
00144   s << line << std::endl;
00145 
00146   sprintf(line,
00147           " LuminositySection: %15d  BunchCrossingErrors:      %15d",
00148           c.luminositySection(), c.bunchCrossingErrors());
00149   s << line << std::endl;
00150 
00151   sprintf(line,
00152           " TriggerNumber:     %15d  EventNumber:              %15d",
00153           c.triggerNumber(), c.eventNumber());
00154   s << line << std::endl;
00155 
00156   sprintf(line,
00157           " TriggersDistributed:    %10d  TriggersGenerated:        %15d",
00158           c.finalTriggersDistributed(), 
00159           c.finalTriggersGenerated());
00160   s << line << std::endl;
00161 
00162   sprintf(line,
00163           " TriggersInvalidBC: %15d  CalibrationTriggers:      %15d",
00164           c.finalTriggersInvalidBC(), c.calibrationTriggers());
00165   s << line << std::endl;
00166 
00167   sprintf(line,
00168           " TestTriggers:      %15d  RandomTriggers:           %15d",
00169           c.totalTestTriggers(), c.randomTriggers());
00170   s << line << std::endl;
00171 
00172   sprintf(line,
00173           " DeadTime:          %15d  DeadTimeActiveTimeSlot:   %15ld",
00174           c.numberResets(), (long int)c.deadTime());
00175   s << line << std::endl;
00176 
00177   sprintf(line,
00178           " DeadTimeActive:    %15ld  DeadTimeActiveCalibration:%15ld",
00179           (long int)c.deadTimeActive(), 
00180           (long int)c.deadTimeActiveCalibration());
00181   s << line << std::endl;
00182 
00183   sprintf(line,
00184           " LostTriggers:      %15ld  DeadTimeActivePartition:  %15ld",
00185           (long int)c.lostFinalTriggers(), 
00186           (long int)c.deadTimeActivePartition());
00187   s << line << std::endl;
00188 
00189   sprintf(line,
00190           " LostTriggersActive:%15ld  DeadTimeActiveThrottle:   %15ld",
00191           (long int)c.lostFinalTriggersActive(),
00192           (long int)c.deadTimeActiveThrottle());
00193   s << line << std::endl;
00194 
00195   sprintf(line,
00196           " NumberResets:      %15d  DeadTimeActivePrivate:    %15ld",
00197           c.numberResets(),
00198           (long int)c.deadTimeActivePrivate());
00199   s << line << std::endl;
00200 
00201   s << "Physics Triggers" << std::endl;
00202   std::vector<unsigned int> triggers = c.triggers();
00203   int length = triggers.size() / 4;
00204   for ( int i=0; i<length; i++)
00205   {
00206     sprintf(line," %3.3d: %10d    %3.3d: %10d    %3.3d: %10d    %3.3d: %10d",
00207             i,              triggers[i], 
00208             (i+length),     triggers[i+length], 
00209             (i+(length*2)), triggers[i+(length*2)], 
00210             (i+(length*3)), triggers[i+(length*3)]);
00211     s << line << std::endl;
00212   }
00213 
00214   s << "Test Triggers" << std::endl;
00215   std::vector<unsigned int> testTriggers = c.testTriggers();
00216   length = testTriggers.size() / 4;
00217   for ( int i=0; i<length; i++)
00218   {
00219     sprintf(line," %3.3d: %10d    %3.3d: %10d    %3.3d: %10d    %3.3d: %10d",
00220             i,              testTriggers[i], 
00221             (i+length),     testTriggers[i+length], 
00222             (i+(length*2)), testTriggers[i+(length*2)], 
00223             (i+(length*3)), testTriggers[i+(length*3)]);
00224     s << line << std::endl;
00225   }
00226   return s;
00227 }