Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:31:12

0001 #include "TBDataFormats/EcalTBObjects/interface/EcalTBEventHeader.h"
0002 #include <cstdio>
0003 
0004 //! Return the event type: "beam", "laser", "pedestal". "error"
0005 //! or a number orresponding to the orginal eventype stored in
0006 //! the RRF.
0007 std::string EcalTBEventHeader::eventType() const {
0008   // this piece of code was in TPilot (ievtype)
0009   int m = triggerMask_ & 0x00FFFF01;  // bits 0, 8..23
0010 
0011   // this piece of code was in TPilot (numbit)
0012   int w = m;
0013   int num = 0;
0014   if (w < 0) {        //
0015     w &= 0x7FFFFFFF;  // CINT Error
0016     num++;            //
0017   }
0018   do {
0019     num += (w & 0x1);
0020   } while ((w >>= 1) != 0);
0021   // end of numbit
0022 
0023   if (num != 1)
0024     return std::string("error");
0025 
0026   char chEvtype[80];
0027   if (m == 1)
0028     return std::string("beam");  // Physics triggers
0029   for (int i = 0; i < 24; i++) {
0030     if ((m & 0x1) == 1) {
0031       sprintf(chEvtype, "%d", i);
0032       if (i == 11)
0033         return std::string("pedestal");
0034       if (i == 13)
0035         return std::string("laser");
0036       return std::string(chEvtype);
0037     }
0038     m >>= 1;
0039   }
0040   return std::string("error");
0041 
0042   //   // FIXME: to be uncommented with new rawroot
0043   //   int evtype = rawHeader->GetEventType() ;
0044   //   if (evtype == 0) return std::string("error") ;
0045   //   if (evtype == 1) return std::string("beam") ;
0046   //   if (evtype == 11) return std::string("pedestal") ;
0047   //   if (evtype == 13) return std::string("laser") ;
0048   //   char chEvtype[80] ;
0049   //   sprintf(chEvtype, "%d", evtype) ;
0050   //   return std::string(chEvtype) ;
0051 }
0052 
0053 int EcalTBEventHeader::dbEventType() const {
0054   std::string evtType = eventType();
0055   int ievtType = 0;
0056   if (evtType == "beam")
0057     ievtType = 1;
0058   if (evtType == "laser")
0059     ievtType = 2;
0060   if (evtType == "pedestal")
0061     ievtType = 1;  // same as beam
0062   if (ievtType == 2) {
0063     LaserType laser_type = laserTypeName();
0064     //if (laser_type == EcalTBEventHeader::LBlue) ievtType += 0 ;
0065     if (laser_type == EcalTBEventHeader::LGreen)
0066       ievtType += 1;
0067     if (laser_type == EcalTBEventHeader::LInfrared)
0068       ievtType += 2;
0069     if (laser_type == EcalTBEventHeader::LRed)
0070       ievtType += 3;
0071   }
0072   return ievtType;
0073 }
0074 
0075 std::ostream& operator<<(std::ostream& s, const EcalTBEventHeader& eventHeader) {
0076   s << "Run Number " << eventHeader.runNumber() << " Event Number " << eventHeader.eventNumber() << " Burst Number "
0077     << eventHeader.burstNumber();
0078   return s;
0079 }