Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-09-07 04:38:11

0001 #ifndef RECECAL_ECALTBEVENTHEADER_H
0002 #define RECECAL_ECALTBEVENTHEADER_H 1
0003 
0004 #include <ostream>
0005 #include <string>
0006 #include <vector>
0007 #include "DataFormats/EcalDetId/interface/EBDetId.h"
0008 
0009 /** \class EcalTBEventHeader
0010  *  Container for event ancilllary informations defined in TB raw data formats  
0011  *
0012  */
0013 
0014 class EcalTBEventHeader {
0015 public:
0016   EcalTBEventHeader() {}
0017 
0018   ~EcalTBEventHeader() {}
0019 
0020   typedef struct magnetsMeasurement {
0021     int magnet6IRead_ampere;
0022     int magnet6ISet_ampere;
0023 
0024     int magnet7IRead_ampere;
0025     int magnet7ISet_ampere;
0026 
0027     int magnet7VMeas_uvolt;
0028     int magnet7IMeas_uampere;
0029 
0030     int magnet6VMeas_uvolt;
0031     int magnet6IMeas_uampere;
0032   } magnetsMeasurement_t;
0033 
0034   //! Returns the event number
0035   int eventNumber() const { return eventNumber_; }
0036 
0037   int runNumber() const { return runNumber_; }
0038 
0039   //! Returns the burst number
0040   short burstNumber() const { return burstNumber_; }
0041 
0042   //! Returns the burst number
0043   short smInBeam() const { return smInBeam_; }
0044 
0045   //! Returns the begin burst time (sec)
0046   int begBurstTimeSec() const { return begBurstTime_sec_; }
0047 
0048   //! Returns the begin burst time (msec)
0049   int begBurstTimeMsec() const { return begBurstTime_msec_; }
0050 
0051   //! Returns the end burst time (sec)
0052   int endBurstTimeSec() const { return endBurstTime_sec_; }
0053 
0054   //! Returns the end burst time (msec)
0055   int endBurstTimeMsec() const { return endBurstTime_msec_; }
0056 
0057   //! Returns the begin burst time (msec)
0058   int begBurstLV1A() const { return begBurstLV1A_; }
0059 
0060   //! Returns the end burst time (sec)
0061   int endBurstLV1A() const { return endBurstLV1A_; }
0062 
0063   // Return the event type: "beam", "laser", "pedestal". "error"
0064   // or a number orresponding to the orginal eventype stored in
0065   // the RRF.
0066   std::string eventType() const;
0067 
0068   //! Returns the event type as in the H4ROOTDB
0069   int dbEventType() const;
0070 
0071   //! Returns the trigger mask
0072   int triggerMask() const { return triggerMask_; }
0073 
0074   //! Returns the date in Unix time
0075   int date() const { return date_; }
0076 
0077   //! Returns the crystal which is being hit by the beam (in the internal SM numbering scheme)
0078 
0079   //Table supervisor information
0080   int crystalInBeam() const { return EBDetId(crystalInBeam_).ic(); }
0081   int nominalCrystalInBeam() const { return EBDetId(nominalCrystalInBeam_).ic(); }
0082   int nextCrystalInBeam() const { return EBDetId(nextCrystalInBeam_).ic(); }
0083   //! Returns the theta table index
0084   unsigned int thetaTableIndex() const { return thetaTableIndex_; }
0085   //! Returns the phi table index
0086   unsigned int phiTableIndex() const { return phiTableIndex_; }
0087   //! Tell if the table is Moving
0088   bool tableIsMoving() const { return tableIsMoving_; }
0089   //! Tell if the table is Moving At the begin of the spill (available in runs only after 1st August 06)
0090   bool tableIsMovingAtBegSpill() const { return tableIsMovingAtBegSpill_; }
0091   //! is there any sync error
0092   bool syncError() const { return syncError_; }
0093 
0094   ///SHOULD WE REMOVE ALL THIS???
0095   //! Unique codes for the 4 lasers
0096   /*! The Caltech laser system (resp. R. Zhu, contact at CERN A. Bornheim)
0097        is a two-laser (2 times "YLF and Ti:Sapphire lasers") which provides 
0098        25 ns (FWHM) pulses at 4 different wavelengths:
0099           -# Laser 1  Blue (violet)  440 nm 
0100                       Green (blue)   495 nm
0101           -# Laser 2  Red            709 nm
0102                       Infrared       801 nm
0103   */
0104   // FIXME: add the codes used by Jean Bourotte here.
0105   enum LaserType {
0106     LBlue = 440,     //! 440 nm
0107     LGreen = 495,    //! 495 nm
0108     LRed = 709,      //! 709 nm
0109     LInfrared = 800  //! 800 nm
0110   };
0111   //! return the laser intensity
0112   int lightIntensity() const { return lightIntensity_; }
0113   //! return the event laser type
0114   int laserType() const {
0115     return laserType_;  // returns wavelength
0116   }
0117 
0118   LaserType laserTypeName() const {
0119     LaserType laser_type;
0120     switch (laserType_) {
0121       case 440:
0122         laser_type = LBlue;
0123         break;
0124       case 495:
0125         laser_type = LGreen;
0126         break;
0127       case 709:
0128         laser_type = LRed;
0129         break;
0130       case 800:
0131         laser_type = LInfrared;
0132         break;
0133       default:
0134         laser_type = LRed;
0135         break;
0136     }
0137     return laser_type;  // returns laserTypeName
0138   }
0139 
0140   //! returns S6 ADC value
0141   int S6ADC() const { return S6ADC_; }
0142 
0143   int numberOfMagnetMeasurements() const { return numberOfMagnetMeasurements_; }
0144 
0145   const std::vector<magnetsMeasurement_t>& magnetMeasurements() const { return magnetMeasurements_; }
0146 
0147   int scaler(int scalerId) const {
0148     if (scalerId < ((int)scalers_.size()))
0149       return scalers_[scalerId];
0150     else
0151       return -1;
0152   }
0153 
0154   ///////////////
0155   //Set Methods
0156 
0157   void setEventNumber(const int& eventNumber) { eventNumber_ = eventNumber; }
0158 
0159   void setRunNumber(const int& runNumber) { runNumber_ = runNumber; }
0160 
0161   void setSmInBeam(const int& smInBeam) { smInBeam_ = smInBeam; }
0162 
0163   void setBurstNumber(const short& burstNumber) { burstNumber_ = burstNumber; }
0164 
0165   void setTriggerMask(const int& triggerMask) { triggerMask_ = triggerMask; }
0166 
0167   void setBegBurstTimeSec(const int& begBurstTimeSec) { begBurstTime_sec_ = begBurstTimeSec; }
0168 
0169   void setBegBurstTimeMsec(const int& begBurstTimeMsec) { begBurstTime_msec_ = begBurstTimeMsec; }
0170 
0171   void setEndBurstTimeSec(const int& endBurstTimeSec) { endBurstTime_sec_ = endBurstTimeSec; }
0172 
0173   void setEndBurstTimeMsec(const int& endBurstTimeMsec) { endBurstTime_msec_ = endBurstTimeMsec; }
0174 
0175   void setBegBurstLV1A(const int& begBurstLV1A) { begBurstLV1A_ = begBurstLV1A; }
0176 
0177   void setEndBurstLV1A(const int& endBurstLV1A) { endBurstLV1A_ = endBurstLV1A; }
0178 
0179   void setDate(const int& date) { date_ = date; }
0180 
0181   void setCrystalInBeam(const DetId& crystalInBeam) { crystalInBeam_ = crystalInBeam; }
0182 
0183   void setNominalCrystalInBeam(const DetId& crystalInBeam) { nominalCrystalInBeam_ = crystalInBeam; }
0184 
0185   void setNextCrystalInBeam(const DetId& crystalInBeam) { nextCrystalInBeam_ = crystalInBeam; }
0186 
0187   void setThetaTableIndex(const unsigned int& thetaTableIndex) { thetaTableIndex_ = thetaTableIndex; }
0188 
0189   void setPhiTableIndex(const unsigned int& phiTableIndex) { phiTableIndex_ = phiTableIndex; }
0190 
0191   void setTableIsMoving(const bool& tableIsMoving) { tableIsMoving_ = tableIsMoving; }
0192 
0193   void setTableIsMovingAtBegSpill(const bool& tableIsMoving) { tableIsMovingAtBegSpill_ = tableIsMoving; }
0194 
0195   void setSyncError(const bool& syncError) { syncError_ = syncError; }
0196 
0197   void setLightIntensity(const int& lightIntensity) { lightIntensity_ = lightIntensity; }
0198 
0199   void setLaserType(const int& laserType) { laserType_ = laserType; }
0200 
0201   void setS6ADC(const int& S6ADC) { S6ADC_ = S6ADC; }
0202 
0203   void setNumberOfMagnetMeasurements(const int& numberOfMagnetMeasurements) {
0204     numberOfMagnetMeasurements_ = numberOfMagnetMeasurements;
0205   }
0206   void setMagnetMeasurements(const std::vector<magnetsMeasurement_t>& magnetMeasurements) {
0207     magnetMeasurements_ = magnetMeasurements;
0208   }
0209 
0210   void setScalers(const std::vector<int>& scalers) { scalers_ = scalers; }
0211 
0212 private:
0213   int eventNumber_;    ///< The numner of the event
0214   int runNumber_;      ///< The number of the run
0215   short burstNumber_;  ///< The number of the burst
0216 
0217   /// Information from the ecalSupervisor
0218   int begBurstTime_sec_;
0219   int begBurstTime_msec_;
0220   int endBurstTime_sec_;
0221   int endBurstTime_msec_;
0222   int begBurstLV1A_;
0223   int endBurstLV1A_;
0224 
0225   int triggerMask_;  ///< The trigger mask
0226 
0227   /// Magnet currents
0228   int numberOfMagnetMeasurements_;
0229   std::vector<magnetsMeasurement_t> magnetMeasurements_;
0230 
0231   /*   int      nominalMagnet6ReadAmpere_; */
0232   /*   int      nominalMagnet7ReadAmpere_; */
0233   /*   int      nominalMagnet6SetAmpere_; */
0234   /*   int      nominalMagnet7SetAmpere_; */
0235   /*   int      measuredMagnet6MicroAmpere_; */
0236   /*   int      measuredMagnet7MicroAmpere_; */
0237   /*   int      measuredMagnet6Volt_; */
0238   /*   int      measuredMagnet7Volt_; */
0239 
0240   int date_;  ///< The date when the run was taken
0241 
0242   /// Information from the table Supervisor
0243   DetId crystalInBeam_;           ///< The current crystal hit by the beam
0244   DetId nominalCrystalInBeam_;    ///< The nominal crystal which should be hit by the beam
0245   DetId nextCrystalInBeam_;       ///< The nominal next crystal which should be hit by the beam
0246   unsigned int thetaTableIndex_;  ///< Theta table index (X)
0247   unsigned int phiTableIndex_;    ///< Phi table index (Y)
0248 
0249   bool tableIsMoving_;
0250 
0251   bool tableIsMovingAtBegSpill_;  //indipendent but from CAMAC one saying if table is moving at the begin of the spill
0252 
0253   //Sync error for Camac stuff
0254   bool syncError_;
0255 
0256   //FIXME for use in CMSSW(Probably unuseful when reading from new RawData Information will be stored in EcalDCCHeaderBlock)
0257   int lightIntensity_;  ///< The light intensity
0258   int laserType_;       ///< The laser type --see enum LaserType
0259 
0260   int S6ADC_;  ///< ADC lecture of the S6 counter
0261 
0262   short smInBeam_;
0263 
0264   // array of 36 scalers
0265   std::vector<int> scalers_;
0266 };
0267 
0268 std::ostream& operator<<(std::ostream&, const EcalTBEventHeader&);
0269 
0270 #endif