CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Attributes
DTTTrigCorrectionFirst Class Reference

#include <DTTTrigCorrectionFirst.h>

Inheritance diagram for DTTTrigCorrectionFirst:
edm::EDAnalyzer

Public Member Functions

virtual void analyze (const edm::Event &event, const edm::EventSetup &setup)
 
virtual void beginJob ()
 
virtual void beginRun (const edm::Run &run, const edm::EventSetup &setup)
 
 DTTTrigCorrectionFirst (const edm::ParameterSet &pset)
 Constructor. More...
 
virtual void endJob ()
 
virtual ~DTTTrigCorrectionFirst ()
 Destructor. More...
 
- Public Member Functions inherited from edm::EDAnalyzer
 EDAnalyzer ()
 
std::string workerType () const
 
virtual ~EDAnalyzer ()
 

Private Attributes

std::string dbLabel
 
bool debug
 
edm::ESHandle< DTGeometrymuonGeom
 
double rmsLimit
 
const DTTtrigtTrigMap
 
double ttrigMax
 
double ttrigMin
 

Additional Inherited Members

- Public Types inherited from edm::EDAnalyzer
typedef EDAnalyzer ModuleType
 
typedef WorkerT< EDAnalyzerWorkerType
 
- Static Public Member Functions inherited from edm::EDAnalyzer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &)
 
- Protected Member Functions inherited from edm::EDAnalyzer
CurrentProcessingContext const * currentContext () const
 

Detailed Description

Definition at line 22 of file DTTTrigCorrectionFirst.h.

Constructor & Destructor Documentation

DTTTrigCorrectionFirst::DTTTrigCorrectionFirst ( const edm::ParameterSet pset)

Constructor.

Definition at line 30 of file DTTTrigCorrectionFirst.cc.

References dtTTrigAnalyzer_cfg::dbLabel, debug, and edm::ParameterSet::getUntrackedParameter().

30  {
31 
32  debug = pset.getUntrackedParameter<bool>("debug",false);
33  ttrigMin = pset.getUntrackedParameter<double>("ttrigMin",0);
34  ttrigMax = pset.getUntrackedParameter<double>("ttrigMax",5000);
35  rmsLimit = pset.getUntrackedParameter<double>("rmsLimit",5.);
36 
37  dbLabel = pset.getUntrackedParameter<string>("dbLabel", "");
38 }
T getUntrackedParameter(std::string const &, T const &) const
DTTTrigCorrectionFirst::~DTTTrigCorrectionFirst ( )
virtual

Destructor.

Definition at line 40 of file DTTTrigCorrectionFirst.cc.

40 {}

Member Function Documentation

virtual void DTTTrigCorrectionFirst::analyze ( const edm::Event event,
const edm::EventSetup setup 
)
inlinevirtual

Implements edm::EDAnalyzer.

Definition at line 34 of file DTTTrigCorrectionFirst.h.

34 {}
virtual void DTTTrigCorrectionFirst::beginJob ( void  )
inlinevirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 32 of file DTTTrigCorrectionFirst.h.

32 {}
void DTTTrigCorrectionFirst::beginRun ( const edm::Run run,
const edm::EventSetup setup 
)
virtual

Reimplemented from edm::EDAnalyzer.

Definition at line 42 of file DTTTrigCorrectionFirst.cc.

References gather_cfg::cout, dtTTrigAnalyzer_cfg::dbLabel, and edm::EventSetup::get().

42  {
43  ESHandle<DTTtrig> tTrig;
44  setup.get<DTTtrigRcd>().get(dbLabel,tTrig);
45  tTrigMap = &*tTrig;
46  cout << "[DTTTrigCorrection]: TTrig version: " << tTrig->version() << endl;
47 
48  setup.get<MuonGeometryRecord>().get(muonGeom);
49 }
const T & get() const
Definition: EventSetup.h:55
tuple cout
Definition: gather_cfg.py:121
edm::ESHandle< DTGeometry > muonGeom
void DTTTrigCorrectionFirst::endJob ( void  )
virtual

Reimplemented from edm::EDAnalyzer.

Definition at line 51 of file DTTTrigCorrectionFirst.cc.

References abs, PDRates::average, gather_cfg::cout, debug, DTTimeUnits::ns, record, plotscripts::rms(), DTTtrig::set(), and mathSSE::sqrt().

51  {
52  // Create the object to be written to DB
53  DTTtrig* tTrigNewMap = new DTTtrig();
54  //Get the superlayers list
55  vector<DTSuperLayer*> dtSupLylist = muonGeom->superLayers();
56 
57  //Loop on all superlayers to compute the mean
58  double average = 0.;
59  double average2 = 0.;
60  double rms = 0.;
61  double averageSigma = 0.;
62  double average2Sigma = 0.;
63  double rmsSigma = 0.;
64  double counter = 0.;
65  double averagekfactor = 0;
66  float kfactor = 0;
67 
68  for (vector<DTSuperLayer*>::const_iterator sl = dtSupLylist.begin();
69  sl != dtSupLylist.end(); sl++) {
70  float ttrigMean = 0;
71  float ttrigSigma = 0;
72  tTrigMap->get((*sl)->id(),
73  ttrigMean,
74  ttrigSigma,
75  kfactor,
77  if( ttrigMean < ttrigMax && ttrigMean > ttrigMin ) {
78  average += ttrigMean;
79  averageSigma += ttrigSigma;
80  if(ttrigMean > 0)
81  counter += 1.;
82  }
83  }//End of loop on superlayers
84 
85  average = average/ counter;
86  averageSigma = averageSigma/counter;
87  averagekfactor = kfactor;
88 
89  // cout << " average counter "<< average << " "<< counter <<endl;
90 
91  for (vector<DTSuperLayer*>::const_iterator sl = dtSupLylist.begin();
92  sl != dtSupLylist.end(); sl++) {
93  float ttrigMean = 0;
94  float ttrigSigma = 0;
95  float kfactor = 0;
96  tTrigMap->get((*sl)->id(),
97  ttrigMean,
98  ttrigSigma,
99  kfactor,
101  if( ttrigMean < ttrigMax && ttrigMean > ttrigMin ) {
102  average2 += (ttrigMean-average)*(ttrigMean-average);
103  average2Sigma += (ttrigSigma-averageSigma)*(ttrigSigma-averageSigma);
104  }
105  }//End of loop on superlayers
106 
107  rms = average2 /(counter-1);
108  rmsSigma = average2Sigma /(counter-1);
109  rms = sqrt(rms);
110  rmsSigma = sqrt(rmsSigma);
111  cout << "average averageSigma counter rms "<< average <<" " << averageSigma << " " << counter << " " << rms <<endl;
112 
113 
114  for (vector<DTSuperLayer*>::const_iterator sl = dtSupLylist.begin();
115  sl != dtSupLylist.end(); sl++) {
116  //Compute new ttrig
117  double newTTrigMean = 0;
118  double newTTrigSigma = 0;
119  double newkfactor =0;
120  float tempttrigMean = 0;
121  float tempttrigSigma = 0;
122  float tempkfactor = 0;
123  float ttrigMean = 0;
124  float ttrigSigma = 0;
125  float kfactor = 0;
126  tTrigMap->get((*sl)->id(),
127  ttrigMean,
128  ttrigSigma,
129  kfactor,
131  int chamber = (*sl)->id().chamberId().station();
132 
133  //check if ttrigMean is similar to the mean
134  if (abs(ttrigMean - average) < rmsLimit*rms ){
135  newTTrigMean = ttrigMean;
136  newTTrigSigma = ttrigSigma;
137  newkfactor = kfactor;
138  } else {
139  // do not consider if ttrig == 0
140  if(ttrigMean > 0) {
141  //cout << "ttrig chamber " << ttrigMean <<" "<<chamber<<endl;
142  if(((*sl)->id().superlayer()) == 1){
143  //cout << " superlayer " << ((*sl)->id().superlayer()) <<endl;
144  DTSuperLayerId slId((*sl)->id().chamberId(),3);
145  tTrigMap->get(slId,
146  tempttrigMean,
147  tempttrigSigma,
148  tempkfactor,
150  if (abs(tempttrigMean - average) < rmsLimit*rms) {
151  newTTrigMean = tempttrigMean;
152  newTTrigSigma = tempttrigSigma;
153  newkfactor = tempkfactor;
154  cout <<"Chamber "<< chamber << " sl " << ((*sl)->id().superlayer()) << "has ttrig "<< ttrigMean
155  << " -> takes value of sl 3 " << newTTrigMean <<endl;
156  } else if(chamber == 4){
157  cout << "No correction possible within same chamber (sl1) " <<endl;
158  newTTrigMean = average;
159  newTTrigSigma = averageSigma;
160  newkfactor = averagekfactor;
161  cout<<"####### Bad SL: " << (*sl)->id() << " from "<< ttrigMean <<" to "<< newTTrigMean <<endl;
162  } else if(chamber != 4){
163  DTSuperLayerId slId((*sl)->id().chamberId(),2);
164  tTrigMap->get(slId,
165  tempttrigMean,
166  tempttrigSigma,
167  tempkfactor,
169  if (abs(tempttrigMean - average) < rmsLimit*rms) {
170  newTTrigMean = tempttrigMean;
171  newTTrigSigma = tempttrigSigma;
172  newkfactor = tempkfactor;
173  cout <<"Chamber "<< chamber << " sl " << ((*sl)->id().superlayer()) << "has ttrig "<< ttrigMean
174  <<" -> takes value of sl 2 " << newTTrigMean <<endl;
175  } else {
176  cout << "No correction possible within same chamber (sl1) " <<endl;
177  newTTrigMean = average;
178  newTTrigSigma = averageSigma;
179  newkfactor = averagekfactor;
180  cout<<"####### Bad SL: " << (*sl)->id() << " from "<< ttrigMean <<" to "<< newTTrigMean <<endl;
181  }
182  }
183  } else if (((*sl)->id().superlayer()) == 2) {
184  //cout << " superlayer " << ((*sl)->id().superlayer()) <<endl;
185  DTSuperLayerId slId((*sl)->id().chamberId(),1);
186  tTrigMap->get(slId,
187  tempttrigMean,
188  tempttrigSigma,
189  tempkfactor,
191  if (abs(tempttrigMean - average) < rmsLimit*rms) {
192  newTTrigMean = tempttrigMean;
193  newTTrigSigma = tempttrigSigma;
194  newkfactor = tempkfactor;
195  cout <<"Chamber "<< chamber << " sl " << ((*sl)->id().superlayer()) << "has ttrig "<< ttrigMean
196  << " -> takes value of sl 1 " << newTTrigMean <<endl;
197  } else {
198  DTSuperLayerId slId((*sl)->id().chamberId(),3);
199  tTrigMap->get(slId,
200  tempttrigMean,
201  tempttrigSigma,
202  tempkfactor,
204  if (abs(tempttrigMean - average) < rmsLimit*rms) {
205  newTTrigMean = tempttrigMean;
206  newTTrigSigma = tempttrigSigma;
207  newkfactor = tempkfactor;
208  cout <<"Chamber "<< chamber << " sl " << ((*sl)->id().superlayer()) << "has ttrig "<< ttrigMean
209  << "-> takes value of sl 3 " << newTTrigMean <<endl;
210  } else {
211  cout << "No correction possible within same chamber (sl2) " <<endl;
212  newTTrigMean = average;
213  newTTrigSigma = averageSigma;
214  newkfactor = averagekfactor;
215  cout<<"####### Bad SL: " << (*sl)->id() << " from "<< ttrigMean <<" to "<< newTTrigMean <<endl;
216  }
217  }
218 
219 
220  } else if (((*sl)->id().superlayer()) == 3) {
221  //cout << " superlayer " << ((*sl)->id().superlayer()) <<endl;
222  DTSuperLayerId slId((*sl)->id().chamberId(),1);
223  tTrigMap->get(slId,
224  tempttrigMean,
225  tempttrigSigma,
226  tempkfactor,
228  if (abs(tempttrigMean - average) < rmsLimit*rms) {
229  newTTrigMean = tempttrigMean;
230  newTTrigSigma = tempttrigSigma;
231  newkfactor = tempkfactor;
232  cout <<"Chamber "<< chamber << " sl " << ((*sl)->id().superlayer()) << "has ttrig "<< ttrigMean
233  << " -> takes value of sl 1 " << newTTrigMean <<endl;
234  } else if(chamber == 4) {
235  cout << "No correction possible within same chamber (sl3)" <<endl;
236  newTTrigMean = average;
237  newTTrigSigma = averageSigma;
238  newkfactor = averagekfactor;
239  cout<<"####### Bad SL: " << (*sl)->id() << " from "<< ttrigMean <<" to "<< newTTrigMean <<endl;
240  } else if(chamber != 4){
241  DTSuperLayerId slId((*sl)->id().chamberId(),2);
242  tTrigMap->get(slId,
243  tempttrigMean,
244  tempttrigSigma,
245  tempkfactor,
247  if (abs(tempttrigMean - average) < rmsLimit*rms) {
248  newTTrigMean = tempttrigMean;
249  newTTrigSigma = tempttrigSigma;
250  newkfactor = tempkfactor;
251  cout <<"Chamber "<< chamber << " sl " << ((*sl)->id().superlayer()) << "has ttrig "<< ttrigMean
252  << " -> takes value of sl 2 " << newTTrigMean <<endl;
253  } else {
254  cout << "No correction possible within same chamber (sl3) " <<endl;
255  newTTrigMean = average;
256  newTTrigSigma = averageSigma;
257  newkfactor = averagekfactor;
258  cout<<"####### Bad SL: " << (*sl)->id() << " from "<< ttrigMean <<" to "<< newTTrigMean <<endl;
259  }
260  }
261 
262  }
263  } else {
264  // cout << "SL not present " << ttrigMean << " " <<((*sl)->id().superlayer()) <<endl;
265  newTTrigMean = average;
266  newTTrigSigma = averageSigma;
267  newkfactor = averagekfactor;
268  cout<<"####### NotPresent SL: " << (*sl)->id() << " from "<< ttrigMean <<" to "<< newTTrigMean <<endl;
269  }
270  }
271 
272  //Store new ttrig in the new map
273  tTrigNewMap->set((*sl)->id(), newTTrigMean, newTTrigSigma, newkfactor, DTTimeUnits::ns);
274  if(debug){
275  cout<<"New tTrig: " << (*sl)->id()
276  << " from "<< ttrigMean <<" to "<< newTTrigMean <<endl;
277  cout<<"New tTrigSigma: " << (*sl)->id()
278  << " from "<<ttrigSigma <<" to "<< newTTrigSigma <<endl;
279 
280  }
281  }//End of loop on superlayers
282 
283 
284  //Write object to DB
285  cout << "[DTTTrigCorrection]: Writing ttrig object to DB!" << endl;
286  string record = "DTTtrigRcd";
287  DTCalibDBUtils::writeToDB<DTTtrig>(record, tTrigNewMap);
288 }
int set(int wheelId, int stationId, int sectorId, int slId, float tTrig, float tTrms, float kFact, DTTimeUnits::type unit)
Definition: DTTtrig.cc:262
JetCorrectorParameters::Record record
Definition: classes.h:11
#define abs(x)
Definition: mlp_lapack.h:159
T sqrt(T t)
Definition: SSEVec.h:46
int get(int wheelId, int stationId, int sectorId, int slId, float &tTrig, float &tTrms, float &kFact, DTTimeUnits::type unit) const
get content
Definition: DTTtrig.cc:87
int average
Definition: PDRates.py:137
tuple cout
Definition: gather_cfg.py:121
edm::ESHandle< DTGeometry > muonGeom

Member Data Documentation

std::string DTTTrigCorrectionFirst::dbLabel
private

Definition at line 44 of file DTTTrigCorrectionFirst.h.

bool DTTTrigCorrectionFirst::debug
private

Definition at line 46 of file DTTTrigCorrectionFirst.h.

edm::ESHandle<DTGeometry> DTTTrigCorrectionFirst::muonGeom
private

Definition at line 42 of file DTTTrigCorrectionFirst.h.

double DTTTrigCorrectionFirst::rmsLimit
private

Definition at line 47 of file DTTTrigCorrectionFirst.h.

const DTTtrig* DTTTrigCorrectionFirst::tTrigMap
private

Definition at line 41 of file DTTTrigCorrectionFirst.h.

double DTTTrigCorrectionFirst::ttrigMax
private

Definition at line 47 of file DTTTrigCorrectionFirst.h.

double DTTTrigCorrectionFirst::ttrigMin
private

Definition at line 47 of file DTTTrigCorrectionFirst.h.