00001
00009 #include "MuonDTDigis.h"
00010
00011 #include <iostream>
00012 #include <string>
00013
00014 #include "TFile.h"
00015
00016 #include "SimMuon/DTDigitizer/test/Histograms.h"
00017
00018 using namespace edm;
00019 using namespace std;
00020
00021 MuonDTDigis::MuonDTDigis(const ParameterSet& pset){
00022
00023
00024
00025 verbose_ = pset.getUntrackedParameter<bool>("verbose",false);
00026
00027
00028 SimHitLabel = pset.getUntrackedParameter<string>("SimHitLabel");
00029
00030
00031 DigiLabel = pset.getUntrackedParameter<string>("DigiLabel");
00032
00033
00034
00035 outputFile_ = pset.getUntrackedParameter<std::string>("outputFile", "");
00036 if ( outputFile_.size() != 0 ) {
00037 LogInfo("OutputInfo") << " DT Muon Digis Task histograms will be saved to '" << outputFile_.c_str() << "'";
00038 } else {
00039 LogInfo("OutputInfo") << " DT Muon Digis Task histograms will NOT be saved";
00040 }
00041
00042 string::size_type loc = outputFile_.find( ".root", 0 );
00043 std::string outputFile_more_plots_;
00044 if( loc != string::npos ) {
00045 outputFile_more_plots_ = outputFile_.substr(0,loc)+"_more_plots.root";
00046 } else {
00047 outputFile_more_plots_ = " DTDigis_more_plots.root";
00048 }
00049
00050
00051
00052
00053
00054
00055
00056
00057 hDigis_global = new hDigis("Global");
00058 hDigis_W0 = new hDigis("Wheel0");
00059 hDigis_W1 = new hDigis("Wheel1");
00060 hDigis_W2 = new hDigis("Wheel2");
00061 hAllHits = new hHits("AllHits");
00062
00063
00064
00065
00066
00067
00068
00069 dbe_ = 0;
00070 dbe_ = Service<DQMStore>().operator->();
00071 if ( dbe_ ) {
00072 if ( verbose_ ) {
00073 dbe_->setVerbose(1);
00074 } else {
00075 dbe_->setVerbose(0);
00076 }
00077 }
00078 if ( dbe_ ) {
00079 if ( verbose_ ) dbe_->showDirStructure();
00080 }
00081
00082
00083
00084 meDigiTimeBox_ = 0;
00085 meDigiTimeBox_wheel2m_ = 0;
00086 meDigiTimeBox_wheel1m_ = 0;
00087 meDigiTimeBox_wheel0_ = 0;
00088 meDigiTimeBox_wheel1p_ = 0;
00089 meDigiTimeBox_wheel2p_ = 0;
00090 meDigiEfficiency_ = 0;
00091 meDigiEfficiencyMu_ = 0;
00092 meDoubleDigi_ = 0;
00093 meSimvsDigi_ = 0;
00094 meWire_DoubleDigi_ = 0;
00095
00096 meMB1_sim_occup_ = 0;
00097 meMB1_digi_occup_ = 0;
00098 meMB2_sim_occup_ = 0;
00099 meMB2_digi_occup_ = 0;
00100 meMB3_sim_occup_ = 0;
00101 meMB3_digi_occup_ = 0;
00102 meMB4_sim_occup_ = 0;
00103 meMB4_digi_occup_ = 0;
00104
00105
00106 meDigiHisto_ = 0;
00107
00108
00109
00110
00111
00112
00113 Char_t histo_n[100];
00114 Char_t histo_t[100];
00115
00116 if ( dbe_ ) {
00117 dbe_->setCurrentFolder("MuonDTDigisV/DTDigiValidationTask");
00118
00119 sprintf (histo_n, "DigiTimeBox" );
00120 sprintf (histo_t, "Digi Time Box" );
00121 meDigiTimeBox_ = dbe_->book1D(histo_n, histo_t, 1536,0,1200);
00122
00123 sprintf (histo_n, "DigiTimeBox_wheel2m" );
00124 sprintf (histo_t, "Digi Time Box wheel -2" );
00125 meDigiTimeBox_wheel2m_ = dbe_->book1D(histo_n, histo_t, 384,0,1200);
00126
00127 sprintf (histo_n, "DigiTimeBox_wheel1m" );
00128 sprintf (histo_t, "Digi Time Box wheel -1" );
00129 meDigiTimeBox_wheel1m_ = dbe_->book1D(histo_n, histo_t, 384,0,1200);
00130
00131 sprintf (histo_n, "DigiTimeBox_wheel0" );
00132 sprintf (histo_t, "Digi Time Box wheel 0" );
00133 meDigiTimeBox_wheel0_ = dbe_->book1D(histo_n, histo_t, 384,0,1200);
00134
00135 sprintf (histo_n, "DigiTimeBox_wheel1p" );
00136 sprintf (histo_t, "Digi Time Box wheel 1" );
00137 meDigiTimeBox_wheel1p_ = dbe_->book1D(histo_n, histo_t, 384,0,1200);
00138
00139 sprintf (histo_n, "DigiTimeBox_wheel2p" );
00140 sprintf (histo_t, "Digi Time Box wheel 2" );
00141 meDigiTimeBox_wheel2p_ = dbe_->book1D(histo_n, histo_t, 384,0,1200);
00142
00143 sprintf (histo_n, "DigiEfficiencyMu" );
00144 sprintf (histo_t, "Ratio (#Digis Mu)/(#SimHits Mu)" );
00145 meDigiEfficiencyMu_ = dbe_->book1D(histo_n, histo_t, 100, 0., 5.);
00146
00147 sprintf (histo_n, "DigiEfficiency" );
00148 sprintf (histo_t, "Ratio (#Digis)/(#SimHits)" );
00149 meDigiEfficiency_ = dbe_->book1D(histo_n, histo_t, 100, 0., 5.);
00150
00151 sprintf (histo_n, "Number_Digi_per_layer" );
00152 sprintf (histo_t, "Number_Digi_per_layer" );
00153 meDoubleDigi_ = dbe_->book1D(histo_n, histo_t, 10,0.,10.);
00154
00155 sprintf (histo_n, "Number_simhit_vs_digi" );
00156 sprintf (histo_t, "Number_simhit_vs_digi" );
00157 meSimvsDigi_ = dbe_->book2D(histo_n, histo_t, 100, 0., 140., 100, 0., 140.);
00158
00159 sprintf (histo_n, "Wire_Number_with_double_Digi" );
00160 sprintf (histo_t, "Wire_Number_with_double_Digi" );
00161 meWire_DoubleDigi_ = dbe_->book1D(histo_n, histo_t, 100,0.,100.);
00162
00163 sprintf (histo_n, "Simhit_occupancy_MB1" );
00164 sprintf (histo_t, "Simhit_occupancy_MB1" );
00165 meMB1_sim_occup_ = dbe_->book1D(histo_n, histo_t, 55, 0., 55. );
00166
00167 sprintf (histo_n, "Digi_occupancy_MB1" );
00168 sprintf (histo_t, "Digi_occupancy_MB1" );
00169 meMB1_digi_occup_ = dbe_->book1D(histo_n, histo_t, 55, 0., 55. );
00170
00171 sprintf (histo_n, "Simhit_occupancy_MB2" );
00172 sprintf (histo_t, "Simhit_occupancy_MB2" );
00173 meMB2_sim_occup_ = dbe_->book1D(histo_n, histo_t, 63, 0., 63. );
00174
00175 sprintf (histo_n, "Digi_occupancy_MB2" );
00176 sprintf (histo_t, "Digi_occupancy_MB2" );
00177 meMB2_digi_occup_ = dbe_->book1D(histo_n, histo_t, 63, 0., 63. );
00178
00179 sprintf (histo_n, "Simhit_occupancy_MB3" );
00180 sprintf (histo_t, "Simhit_occupancy_MB3" );
00181 meMB3_sim_occup_ = dbe_->book1D(histo_n, histo_t, 75, 0., 75. );
00182
00183 sprintf (histo_n, "Digi_occupancy_MB3" );
00184 sprintf (histo_t, "Digi_occupancy_MB3" );
00185 meMB3_digi_occup_ = dbe_->book1D(histo_n, histo_t, 75, 0., 75. );
00186
00187 sprintf (histo_n, "Simhit_occupancy_MB4" );
00188 sprintf (histo_t, "Simhit_occupancy_MB4" );
00189 meMB4_sim_occup_ = dbe_->book1D(histo_n, histo_t, 99, 0., 99. );
00190
00191 sprintf (histo_n, "Digi_occupancy_MB4" );
00192 sprintf (histo_t, "Digi_occupancy_MB4" );
00193 meMB4_digi_occup_ = dbe_->book1D(histo_n, histo_t, 99, 0., 99. );
00194
00195
00196
00197
00198
00199
00200
00201
00202
00203
00204
00205
00206
00207
00208
00209
00210
00211
00212
00213
00214 char stringcham[40];
00215 for ( int slnum = 1; slnum < 62; ++slnum ) {
00216 sprintf(stringcham, "DigiTimeBox_slid_%d", slnum) ;
00217 meDigiHisto_ = dbe_->book1D(stringcham, stringcham, 100,0,1200);
00218 meDigiTimeBox_SL_.push_back(meDigiHisto_);
00219 }
00220 }
00221
00222 }
00223
00224 MuonDTDigis::~MuonDTDigis(){
00225
00226
00227
00228
00229
00230
00231
00232
00233
00234
00235
00236
00237
00238
00239
00240
00241 if ( outputFile_.size() != 0 && dbe_ ) dbe_->save(outputFile_);
00242
00243 if(verbose_)
00244 cout << "[MuonDTDigis] Destructor called" << endl;
00245
00246 }
00247
00248
00249
00250
00251
00252 void MuonDTDigis::analyze(const Event & event, const EventSetup& eventSetup){
00253
00254 if(verbose_)
00255 cout << "--- [MuonDTDigis] Analysing Event: #Run: " << event.id().run()
00256 << " #Event: " << event.id().event() << endl;
00257
00258
00259 ESHandle<DTGeometry> muonGeom;
00260 eventSetup.get<MuonGeometryRecord>().get(muonGeom);
00261
00262
00263 Handle<DTDigiCollection> dtDigis;
00264 event.getByLabel(DigiLabel, dtDigis);
00265
00266
00267 Handle<PSimHitContainer> simHits;
00268 event.getByLabel(SimHitLabel,"MuonDTHits",simHits);
00269
00270
00271
00272
00273
00274 int num_simhits;
00275 int num_mudigis;
00276 int num_musimhits;
00277 int num_digis;
00278 int num_digis_layer;
00279 int cham_num ;
00280 int wire_touched;
00281 num_digis = 0;
00282 num_mudigis = 0;
00283 num_musimhits = 0;
00284 DTWireIdMap wireMap;
00285
00286 num_simhits = simHits->size();
00287
00288
00289 for(vector<PSimHit>::const_iterator hit = simHits->begin();
00290 hit != simHits->end(); hit++){
00291
00292 DTWireId wireId(hit->detUnitId());
00293
00294
00295
00296 wireMap[wireId].push_back(&(*hit));
00297
00298 LocalPoint entryP = hit->entryPoint();
00299 LocalPoint exitP = hit->exitPoint();
00300 int partType = hit->particleType();
00301 if ( abs(partType) == 13 ) num_musimhits++;
00302
00303 if ( wireId.station() == 1 && abs(partType) == 13 ) meMB1_sim_occup_->Fill(wireId.wire());
00304 if ( wireId.station() == 2 && abs(partType) == 13 ) meMB2_sim_occup_->Fill(wireId.wire());
00305 if ( wireId.station() == 3 && abs(partType) == 13 ) meMB3_sim_occup_->Fill(wireId.wire());
00306 if ( wireId.station() == 4 && abs(partType) == 13 ) meMB4_sim_occup_->Fill(wireId.wire());
00307
00308
00309 float path = (exitP-entryP).mag();
00310 float path_x = fabs((exitP-entryP).x());
00311
00312 hAllHits->Fill(entryP.x(),exitP.x(),
00313 entryP.y(),exitP.y(),
00314 entryP.z(),exitP.z(),
00315 path , path_x,
00316 partType, hit->processType(),
00317 hit->pabs());
00318
00319 }
00320
00321
00322
00323 DTDigiCollection::DigiRangeIterator detUnitIt;
00324 for (detUnitIt=dtDigis->begin();
00325 detUnitIt!=dtDigis->end();
00326 ++detUnitIt){
00327
00328 const DTLayerId& id = (*detUnitIt).first;
00329 const DTDigiCollection::Range& range = (*detUnitIt).second;
00330
00331 num_digis_layer = 0 ;
00332 cham_num = 0 ;
00333 wire_touched = 0;
00334
00335
00336 for (DTDigiCollection::const_iterator digiIt = range.first;
00337 digiIt!=range.second;
00338 ++digiIt){
00339
00340
00341
00342 num_digis++;
00343 num_digis_layer++;
00344 if (num_digis_layer > 1 )
00345 {
00346 if ( (*digiIt).wire() == wire_touched )
00347 {
00348 meWire_DoubleDigi_->Fill((*digiIt).wire());
00349
00350 }
00351 }
00352 wire_touched = (*digiIt).wire();
00353
00354 meDigiTimeBox_->Fill((*digiIt).time());
00355 if (id.wheel() == -2 ) meDigiTimeBox_wheel2m_->Fill((*digiIt).time());
00356 if (id.wheel() == -1 ) meDigiTimeBox_wheel1m_->Fill((*digiIt).time());
00357 if (id.wheel() == 0 ) meDigiTimeBox_wheel0_ ->Fill((*digiIt).time());
00358 if (id.wheel() == 1 ) meDigiTimeBox_wheel1p_->Fill((*digiIt).time());
00359 if (id.wheel() == 2 ) meDigiTimeBox_wheel2p_->Fill((*digiIt).time());
00360
00361
00362
00363 cham_num = (id.wheel() +2)*12 + (id.station() -1)*3 + id.superlayer();
00364
00365
00366 meDigiTimeBox_SL_[cham_num]->Fill((*digiIt).time());
00367
00368
00369
00370 DTWireId wireId(id,(*digiIt).wire());
00371 if (wireId.station() == 1 ) meMB1_digi_occup_->Fill((*digiIt).wire());
00372 if (wireId.station() == 2 ) meMB2_digi_occup_->Fill((*digiIt).wire());
00373 if (wireId.station() == 3 ) meMB3_digi_occup_->Fill((*digiIt).wire());
00374 if (wireId.station() == 4 ) meMB4_digi_occup_->Fill((*digiIt).wire());
00375
00376 int mu=0;
00377 float theta = 0;
00378
00379 for(vector<const PSimHit*>::iterator hit = wireMap[wireId].begin();
00380 hit != wireMap[wireId].end(); hit++)
00381 if( abs((*hit)->particleType()) == 13){
00382 theta = atan( (*hit)->momentumAtEntry().x()/ (-(*hit)->momentumAtEntry().z()) )*180/M_PI;
00383
00384
00385
00386 mu++;
00387 }
00388
00389 if( mu ) num_mudigis++;
00390
00391 if(mu && theta){
00392 hDigis_global->Fill((*digiIt).time(),theta,id.superlayer());
00393
00394 WheelHistos(id.wheel())->Fill((*digiIt).time(),theta,id.superlayer());
00395 }
00396
00397 }
00398
00399 meDoubleDigi_->Fill( (float)num_digis_layer );
00400
00401 }
00402
00403
00404
00405 if (num_musimhits != 0) {
00406 meDigiEfficiencyMu_->Fill( (float)num_mudigis/(float)num_musimhits );
00407 meDigiEfficiency_->Fill( (float)num_digis/(float)num_musimhits );
00408 }
00409
00410 meSimvsDigi_->Fill( (float)num_musimhits, (float)num_digis ) ;
00411
00412
00413 }
00414
00415 hDigis* MuonDTDigis::WheelHistos(int wheel){
00416 switch(abs(wheel)){
00417
00418 case 0: return hDigis_W0;
00419
00420 case 1: return hDigis_W1;
00421
00422 case 2: return hDigis_W2;
00423
00424 default: return NULL;
00425 }
00426 }
00427 #include "FWCore/PluginManager/interface/ModuleDef.h"
00428 #include "FWCore/Framework/interface/MakerMacros.h"
00429 #include "DQMServices/Core/interface/DQMStore.h"
00430
00431 DEFINE_FWK_MODULE(MuonDTDigis);