1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
#ifndef _CSCFAKEDBPEDESTALS_H
#define _CSCFAKEDBPEDESTALS_H
#include "FWCore/Framework/interface/ESHandle.h"
#include "FWCore/Framework/interface/ESProducer.h"
#include "FWCore/Framework/interface/Event.h"
#include "FWCore/Framework/interface/EventSetup.h"
#include "FWCore/Framework/interface/EventSetupRecordIntervalFinder.h"
#include "FWCore/Framework/interface/Frameworkfwd.h"
#include "FWCore/Framework/interface/MakerMacros.h"
#include "FWCore/Framework/interface/SourceFactory.h"
#include <memory>
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "CondFormats/CSCObjects/interface/CSCDBPedestals.h"
#include "CondFormats/DataRecord/interface/CSCDBPedestalsRcd.h"
#include <DataFormats/MuonDetId/interface/CSCDetId.h>
class CSCFakeDBPedestals : public edm::ESProducer, public edm::EventSetupRecordIntervalFinder {
public:
CSCFakeDBPedestals(const edm::ParameterSet &);
~CSCFakeDBPedestals() override;
inline static CSCDBPedestals *prefillDBPedestals();
typedef std::unique_ptr<CSCDBPedestals> Pointer;
Pointer produceDBPedestals(const CSCDBPedestalsRcd &);
private:
// ----------member data ---------------------------
void setIntervalFor(const edm::eventsetup::EventSetupRecordKey &,
const edm::IOVSyncValue &,
edm::ValidityInterval &) override;
};
#include <fstream>
#include <iostream>
#include <vector>
// to workaround plugin library
inline CSCDBPedestals *CSCFakeDBPedestals::prefillDBPedestals() {
int seed;
float meanped, meanrms;
const int MAX_SIZE = 217728; // or 252288 for ME4/2 chambers
const int PED_FACTOR = 10;
const int RMS_FACTOR = 1000;
CSCDBPedestals *cndbpedestals = new CSCDBPedestals();
cndbpedestals->pedestals.resize(MAX_SIZE);
seed = 10000;
srand(seed);
meanped = 600.0, meanrms = 1.5;
cndbpedestals->factor_ped = int(PED_FACTOR);
cndbpedestals->factor_rms = int(RMS_FACTOR);
for (int i = 0; i < MAX_SIZE; i++) {
cndbpedestals->pedestals[i].ped =
(short int)(((double)rand() / ((double)(RAND_MAX) + (double)(1))) * 100 + meanped * PED_FACTOR + 0.5);
cndbpedestals->pedestals[i].rms =
(short int)(((double)rand() / ((double)(RAND_MAX) + (double)(1))) + meanrms * RMS_FACTOR + 0.5);
}
return cndbpedestals;
}
#endif
|